| | |
| | | (function (global, factory) { |
| | | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| | | typeof define === 'function' && define.amd ? define(factory) : |
| | | (global = global || self, global.prettier = factory()); |
| | | }(this, (function () { 'use strict'; |
| | | (function(e){if(typeof exports=="object"&&typeof module=="object")module.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var f=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:this||{};f.prettier=e()}})(function(){"use strict";var be=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Ye=be((yg,ru)=>{var er=function(e){return e&&e.Math==Math&&e};ru.exports=er(typeof globalThis=="object"&&globalThis)||er(typeof window=="object"&&window)||er(typeof self=="object"&&self)||er(typeof global=="object"&&global)||function(){return this}()||Function("return this")()});var ft=be((hg,nu)=>{nu.exports=function(e){try{return!!e()}catch{return!0}}});var ht=be((Cg,uu)=>{var vo=ft();uu.exports=!vo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var tr=be((Eg,su)=>{var Fo=ft();su.exports=!Fo(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")})});var Ct=be((vg,au)=>{var Ao=tr(),rr=Function.prototype.call;au.exports=Ao?rr.bind(rr):function(){return rr.apply(rr,arguments)}});var lu=be(cu=>{"use strict";var iu={}.propertyIsEnumerable,ou=Object.getOwnPropertyDescriptor,So=ou&&!iu.call({1:2},1);cu.f=So?function(n){var t=ou(this,n);return!!t&&t.enumerable}:iu});var nr=be((Ag,pu)=>{pu.exports=function(e,n){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:n}}});var at=be((Sg,mu)=>{var fu=tr(),Du=Function.prototype,xo=Du.bind,Lr=Du.call,bo=fu&&xo.bind(Lr,Lr);mu.exports=fu?function(e){return e&&bo(e)}:function(e){return e&&function(){return Lr.apply(e,arguments)}}});var ur=be((xg,gu)=>{var du=at(),To=du({}.toString),Bo=du("".slice);gu.exports=function(e){return Bo(To(e),8,-1)}});var hu=be((bg,yu)=>{var No=Ye(),wo=at(),_o=ft(),Po=ur(),Or=No.Object,Io=wo("".split);yu.exports=_o(function(){return!Or("z").propertyIsEnumerable(0)})?function(e){return Po(e)=="String"?Io(e,""):Or(e)}:Or});var jr=be((Tg,Cu)=>{var ko=Ye(),Lo=ko.TypeError;Cu.exports=function(e){if(e==null)throw Lo("Can't call method on "+e);return e}});var sr=be((Bg,Eu)=>{var Oo=hu(),jo=jr();Eu.exports=function(e){return Oo(jo(e))}});var it=be((Ng,vu)=>{vu.exports=function(e){return typeof e=="function"}});var Et=be((wg,Fu)=>{var qo=it();Fu.exports=function(e){return typeof e=="object"?e!==null:qo(e)}});var Mt=be((_g,Au)=>{var qr=Ye(),Mo=it(),Ro=function(e){return Mo(e)?e:void 0};Au.exports=function(e,n){return arguments.length<2?Ro(qr[e]):qr[e]&&qr[e][n]}});var Mr=be((Pg,Su)=>{var Vo=at();Su.exports=Vo({}.isPrototypeOf)});var bu=be((Ig,xu)=>{var Wo=Mt();xu.exports=Wo("navigator","userAgent")||""});var Iu=be((kg,Pu)=>{var _u=Ye(),Rr=bu(),Tu=_u.process,Bu=_u.Deno,Nu=Tu&&Tu.versions||Bu&&Bu.version,wu=Nu&&Nu.v8,lt,ar;wu&&(lt=wu.split("."),ar=lt[0]>0&<[0]<4?1:+(lt[0]+lt[1]));!ar&&Rr&&(lt=Rr.match(/Edge\/(\d+)/),(!lt||lt[1]>=74)&&(lt=Rr.match(/Chrome\/(\d+)/),lt&&(ar=+lt[1])));Pu.exports=ar});var Vr=be((Lg,Lu)=>{var ku=Iu(),$o=ft();Lu.exports=!!Object.getOwnPropertySymbols&&!$o(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ku&&ku<41})});var Wr=be((Og,Ou)=>{var Ho=Vr();Ou.exports=Ho&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var $r=be((jg,ju)=>{var Go=Ye(),Jo=Mt(),Uo=it(),zo=Mr(),Xo=Wr(),Ko=Go.Object;ju.exports=Xo?function(e){return typeof e=="symbol"}:function(e){var n=Jo("Symbol");return Uo(n)&&zo(n.prototype,Ko(e))}});var ir=be((qg,qu)=>{var Yo=Ye(),Qo=Yo.String;qu.exports=function(e){try{return Qo(e)}catch{return"Object"}}});var Rt=be((Mg,Mu)=>{var Zo=Ye(),ec=it(),tc=ir(),rc=Zo.TypeError;Mu.exports=function(e){if(ec(e))return e;throw rc(tc(e)+" is not a function")}});var or=be((Rg,Ru)=>{var nc=Rt();Ru.exports=function(e,n){var t=e[n];return t==null?void 0:nc(t)}});var Wu=be((Vg,Vu)=>{var uc=Ye(),Hr=Ct(),Gr=it(),Jr=Et(),sc=uc.TypeError;Vu.exports=function(e,n){var t,s;if(n==="string"&&Gr(t=e.toString)&&!Jr(s=Hr(t,e))||Gr(t=e.valueOf)&&!Jr(s=Hr(t,e))||n!=="string"&&Gr(t=e.toString)&&!Jr(s=Hr(t,e)))return s;throw sc("Can't convert object to primitive value")}});var Hu=be((Wg,$u)=>{$u.exports=!1});var cr=be(($g,Ju)=>{var Gu=Ye(),ac=Object.defineProperty;Ju.exports=function(e,n){try{ac(Gu,e,{value:n,configurable:!0,writable:!0})}catch{Gu[e]=n}return n}});var lr=be((Hg,zu)=>{var ic=Ye(),oc=cr(),Uu="__core-js_shared__",cc=ic[Uu]||oc(Uu,{});zu.exports=cc});var Ur=be((Gg,Ku)=>{var lc=Hu(),Xu=lr();(Ku.exports=function(e,n){return Xu[e]||(Xu[e]=n!==void 0?n:{})})("versions",[]).push({version:"3.21.1",mode:lc?"pure":"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE",source:"https://github.com/zloirock/core-js"})});var pr=be((Jg,Yu)=>{var pc=Ye(),fc=jr(),Dc=pc.Object;Yu.exports=function(e){return Dc(fc(e))}});var mt=be((Ug,Qu)=>{var mc=at(),dc=pr(),gc=mc({}.hasOwnProperty);Qu.exports=Object.hasOwn||function(n,t){return gc(dc(n),t)}});var zr=be((zg,Zu)=>{var yc=at(),hc=0,Cc=Math.random(),Ec=yc(1 .toString);Zu.exports=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Ec(++hc+Cc,36)}});var Ft=be((Xg,us)=>{var vc=Ye(),Fc=Ur(),es=mt(),Ac=zr(),ts=Vr(),ns=Wr(),Tt=Fc("wks"),vt=vc.Symbol,rs=vt&&vt.for,Sc=ns?vt:vt&&vt.withoutSetter||Ac;us.exports=function(e){if(!es(Tt,e)||!(ts||typeof Tt[e]=="string")){var n="Symbol."+e;ts&&es(vt,e)?Tt[e]=vt[e]:ns&&rs?Tt[e]=rs(n):Tt[e]=Sc(n)}return Tt[e]}});var os=be((Kg,is)=>{var xc=Ye(),bc=Ct(),ss=Et(),as=$r(),Tc=or(),Bc=Wu(),Nc=Ft(),wc=xc.TypeError,_c=Nc("toPrimitive");is.exports=function(e,n){if(!ss(e)||as(e))return e;var t=Tc(e,_c),s;if(t){if(n===void 0&&(n="default"),s=bc(t,e,n),!ss(s)||as(s))return s;throw wc("Can't convert object to primitive value")}return n===void 0&&(n="number"),Bc(e,n)}});var fr=be((Yg,cs)=>{var Pc=os(),Ic=$r();cs.exports=function(e){var n=Pc(e,"string");return Ic(n)?n:n+""}});var fs=be((Qg,ps)=>{var kc=Ye(),ls=Et(),Xr=kc.document,Lc=ls(Xr)&&ls(Xr.createElement);ps.exports=function(e){return Lc?Xr.createElement(e):{}}});var Kr=be((Zg,Ds)=>{var Oc=ht(),jc=ft(),qc=fs();Ds.exports=!Oc&&!jc(function(){return Object.defineProperty(qc("div"),"a",{get:function(){return 7}}).a!=7})});var Yr=be(ds=>{var Mc=ht(),Rc=Ct(),Vc=lu(),Wc=nr(),$c=sr(),Hc=fr(),Gc=mt(),Jc=Kr(),ms=Object.getOwnPropertyDescriptor;ds.f=Mc?ms:function(n,t){if(n=$c(n),t=Hc(t),Jc)try{return ms(n,t)}catch{}if(Gc(n,t))return Wc(!Rc(Vc.f,n,t),n[t])}});var ys=be((t0,gs)=>{var Uc=ht(),zc=ft();gs.exports=Uc&&zc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var Bt=be((r0,Cs)=>{var hs=Ye(),Xc=Et(),Kc=hs.String,Yc=hs.TypeError;Cs.exports=function(e){if(Xc(e))return e;throw Yc(Kc(e)+" is not an object")}});var mr=be(vs=>{var Qc=Ye(),Zc=ht(),el=Kr(),tl=ys(),Dr=Bt(),Es=fr(),rl=Qc.TypeError,Qr=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,Zr="enumerable",en="configurable",tn="writable";vs.f=Zc?tl?function(n,t,s){if(Dr(n),t=Es(t),Dr(s),typeof n=="function"&&t==="prototype"&&"value"in s&&tn in s&&!s[tn]){var i=nl(n,t);i&&i[tn]&&(n[t]=s.value,s={configurable:en in s?s[en]:i[en],enumerable:Zr in s?s[Zr]:i[Zr],writable:!1})}return Qr(n,t,s)}:Qr:function(n,t,s){if(Dr(n),t=Es(t),Dr(s),el)try{return Qr(n,t,s)}catch{}if("get"in s||"set"in s)throw rl("Accessors not supported");return"value"in s&&(n[t]=s.value),n}});var dr=be((u0,Fs)=>{var ul=ht(),sl=mr(),al=nr();Fs.exports=ul?function(e,n,t){return sl.f(e,n,al(1,t))}:function(e,n,t){return e[n]=t,e}});var gr=be((s0,As)=>{var il=at(),ol=it(),rn=lr(),cl=il(Function.toString);ol(rn.inspectSource)||(rn.inspectSource=function(e){return cl(e)});As.exports=rn.inspectSource});var bs=be((a0,xs)=>{var ll=Ye(),pl=it(),fl=gr(),Ss=ll.WeakMap;xs.exports=pl(Ss)&&/native code/.test(fl(Ss))});var Ns=be((i0,Bs)=>{var Dl=Ur(),ml=zr(),Ts=Dl("keys");Bs.exports=function(e){return Ts[e]||(Ts[e]=ml(e))}});var nn=be((o0,ws)=>{ws.exports={}});var Os=be((c0,Ls)=>{var dl=bs(),ks=Ye(),un=at(),gl=Et(),yl=dr(),sn=mt(),an=lr(),hl=Ns(),Cl=nn(),_s="Object already initialized",cn=ks.TypeError,El=ks.WeakMap,yr,Vt,hr,vl=function(e){return hr(e)?Vt(e):yr(e,{})},Fl=function(e){return function(n){var t;if(!gl(n)||(t=Vt(n)).type!==e)throw cn("Incompatible receiver, "+e+" required");return t}};dl||an.state?(dt=an.state||(an.state=new El),Ps=un(dt.get),on=un(dt.has),Is=un(dt.set),yr=function(e,n){if(on(dt,e))throw new cn(_s);return n.facade=e,Is(dt,e,n),n},Vt=function(e){return Ps(dt,e)||{}},hr=function(e){return on(dt,e)}):(At=hl("state"),Cl[At]=!0,yr=function(e,n){if(sn(e,At))throw new cn(_s);return n.facade=e,yl(e,At,n),n},Vt=function(e){return sn(e,At)?e[At]:{}},hr=function(e){return sn(e,At)});var dt,Ps,on,Is,At;Ls.exports={set:yr,get:Vt,has:hr,enforce:vl,getterFor:Fl}});var Ms=be((l0,qs)=>{var ln=ht(),Al=mt(),js=Function.prototype,Sl=ln&&Object.getOwnPropertyDescriptor,pn=Al(js,"name"),xl=pn&&function(){}.name==="something",bl=pn&&(!ln||ln&&Sl(js,"name").configurable);qs.exports={EXISTS:pn,PROPER:xl,CONFIGURABLE:bl}});var Hs=be((p0,$s)=>{var Tl=Ye(),Rs=it(),Bl=mt(),Vs=dr(),Nl=cr(),wl=gr(),Ws=Os(),_l=Ms().CONFIGURABLE,Pl=Ws.get,Il=Ws.enforce,kl=String(String).split("String");($s.exports=function(e,n,t,s){var i=s?!!s.unsafe:!1,r=s?!!s.enumerable:!1,u=s?!!s.noTargetGet:!1,a=s&&s.name!==void 0?s.name:n,c;if(Rs(t)&&(String(a).slice(0,7)==="Symbol("&&(a="["+String(a).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!Bl(t,"name")||_l&&t.name!==a)&&Vs(t,"name",a),c=Il(t),c.source||(c.source=kl.join(typeof a=="string"?a:""))),e===Tl){r?e[n]=t:Nl(n,t);return}else i?!u&&e[n]&&(r=!0):delete e[n];r?e[n]=t:Vs(e,n,t)})(Function.prototype,"toString",function(){return Rs(this)&&Pl(this).source||wl(this)})});var Cr=be((f0,Gs)=>{var Ll=Math.ceil,Ol=Math.floor;Gs.exports=function(e){var n=+e;return n!==n||n===0?0:(n>0?Ol:Ll)(n)}});var Us=be((D0,Js)=>{var jl=Cr(),ql=Math.max,Ml=Math.min;Js.exports=function(e,n){var t=jl(e);return t<0?ql(t+n,0):Ml(t,n)}});var Xs=be((m0,zs)=>{var Rl=Cr(),Vl=Math.min;zs.exports=function(e){return e>0?Vl(Rl(e),9007199254740991):0}});var Nt=be((d0,Ks)=>{var Wl=Xs();Ks.exports=function(e){return Wl(e.length)}});var Zs=be((g0,Qs)=>{var $l=sr(),Hl=Us(),Gl=Nt(),Ys=function(e){return function(n,t,s){var i=$l(n),r=Gl(i),u=Hl(s,r),a;if(e&&t!=t){for(;r>u;)if(a=i[u++],a!=a)return!0}else for(;r>u;u++)if((e||u in i)&&i[u]===t)return e||u||0;return!e&&-1}};Qs.exports={includes:Ys(!0),indexOf:Ys(!1)}});var ra=be((y0,ta)=>{var Jl=at(),fn=mt(),Ul=sr(),zl=Zs().indexOf,Xl=nn(),ea=Jl([].push);ta.exports=function(e,n){var t=Ul(e),s=0,i=[],r;for(r in t)!fn(Xl,r)&&fn(t,r)&&ea(i,r);for(;n.length>s;)fn(t,r=n[s++])&&(~zl(i,r)||ea(i,r));return i}});var ua=be((h0,na)=>{na.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var aa=be(sa=>{var Kl=ra(),Yl=ua(),Ql=Yl.concat("length","prototype");sa.f=Object.getOwnPropertyNames||function(n){return Kl(n,Ql)}});var oa=be(ia=>{ia.f=Object.getOwnPropertySymbols});var la=be((v0,ca)=>{var Zl=Mt(),ep=at(),tp=aa(),rp=oa(),np=Bt(),up=ep([].concat);ca.exports=Zl("Reflect","ownKeys")||function(n){var t=tp.f(np(n)),s=rp.f;return s?up(t,s(n)):t}});var Da=be((F0,fa)=>{var pa=mt(),sp=la(),ap=Yr(),ip=mr();fa.exports=function(e,n,t){for(var s=sp(n),i=ip.f,r=ap.f,u=0;u<s.length;u++){var a=s[u];!pa(e,a)&&!(t&&pa(t,a))&&i(e,a,r(n,a))}}});var da=be((A0,ma)=>{var op=ft(),cp=it(),lp=/#|\.prototype\./,Wt=function(e,n){var t=fp[pp(e)];return t==mp?!0:t==Dp?!1:cp(n)?op(n):!!n},pp=Wt.normalize=function(e){return String(e).replace(lp,".").toLowerCase()},fp=Wt.data={},Dp=Wt.NATIVE="N",mp=Wt.POLYFILL="P";ma.exports=Wt});var $t=be((S0,ga)=>{var Dn=Ye(),dp=Yr().f,gp=dr(),yp=Hs(),hp=cr(),Cp=Da(),Ep=da();ga.exports=function(e,n){var t=e.target,s=e.global,i=e.stat,r,u,a,c,l,C;if(s?u=Dn:i?u=Dn[t]||hp(t,{}):u=(Dn[t]||{}).prototype,u)for(a in n){if(l=n[a],e.noTargetGet?(C=dp(u,a),c=C&&C.value):c=u[a],r=Ep(s?a:t+(i?".":"#")+a,e.forced),!r&&c!==void 0){if(typeof l==typeof c)continue;Cp(l,c)}(e.sham||c&&c.sham)&&gp(l,"sham",!0),yp(u,a,l,e)}}});var mn=be((x0,ya)=>{var vp=ur();ya.exports=Array.isArray||function(n){return vp(n)=="Array"}});var dn=be((b0,Ca)=>{var ha=at(),Fp=Rt(),Ap=tr(),Sp=ha(ha.bind);Ca.exports=function(e,n){return Fp(e),n===void 0?e:Ap?Sp(e,n):function(){return e.apply(n,arguments)}}});var gn=be((T0,va)=>{"use strict";var xp=Ye(),bp=mn(),Tp=Nt(),Bp=dn(),Np=xp.TypeError,Ea=function(e,n,t,s,i,r,u,a){for(var c=i,l=0,C=u?Bp(u,a):!1,m,g;l<s;){if(l in t){if(m=C?C(t[l],l,n):t[l],r>0&&bp(m))g=Tp(m),c=Ea(e,n,m,g,c,r-1)-1;else{if(c>=9007199254740991)throw Np("Exceed the acceptable array length");e[c]=m}c++}l++}return c};va.exports=Ea});var Sa=be((B0,Aa)=>{var wp=Ft(),_p=wp("toStringTag"),Fa={};Fa[_p]="z";Aa.exports=String(Fa)==="[object z]"});var yn=be((N0,xa)=>{var Pp=Ye(),Ip=Sa(),kp=it(),Er=ur(),Lp=Ft(),Op=Lp("toStringTag"),jp=Pp.Object,qp=Er(function(){return arguments}())=="Arguments",Mp=function(e,n){try{return e[n]}catch{}};xa.exports=Ip?Er:function(e){var n,t,s;return e===void 0?"Undefined":e===null?"Null":typeof(t=Mp(n=jp(e),Op))=="string"?t:qp?Er(n):(s=Er(n))=="Object"&&kp(n.callee)?"Arguments":s}});var _a=be((w0,wa)=>{var Rp=at(),Vp=ft(),ba=it(),Wp=yn(),$p=Mt(),Hp=gr(),Ta=function(){},Gp=[],Ba=$p("Reflect","construct"),hn=/^\s*(?:class|function)\b/,Jp=Rp(hn.exec),Up=!hn.exec(Ta),Ht=function(n){if(!ba(n))return!1;try{return Ba(Ta,Gp,n),!0}catch{return!1}},Na=function(n){if(!ba(n))return!1;switch(Wp(n)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Up||!!Jp(hn,Hp(n))}catch{return!0}};Na.sham=!0;wa.exports=!Ba||Vp(function(){var e;return Ht(Ht.call)||!Ht(Object)||!Ht(function(){e=!0})||e})?Na:Ht});var La=be((_0,ka)=>{var zp=Ye(),Pa=mn(),Xp=_a(),Kp=Et(),Yp=Ft(),Qp=Yp("species"),Ia=zp.Array;ka.exports=function(e){var n;return Pa(e)&&(n=e.constructor,Xp(n)&&(n===Ia||Pa(n.prototype))?n=void 0:Kp(n)&&(n=n[Qp],n===null&&(n=void 0))),n===void 0?Ia:n}});var Cn=be((P0,Oa)=>{var Zp=La();Oa.exports=function(e,n){return new(Zp(e))(n===0?0:n)}});var ja=be(()=>{"use strict";var ef=$t(),tf=gn(),rf=Rt(),nf=pr(),uf=Nt(),sf=Cn();ef({target:"Array",proto:!0},{flatMap:function(n){var t=nf(this),s=uf(t),i;return rf(n),i=sf(t,0),i.length=tf(i,t,t,s,0,1,n,arguments.length>1?arguments[1]:void 0),i}})});var En=be((L0,qa)=>{qa.exports={}});var Ra=be((O0,Ma)=>{var af=Ft(),of=En(),cf=af("iterator"),lf=Array.prototype;Ma.exports=function(e){return e!==void 0&&(of.Array===e||lf[cf]===e)}});var vn=be((j0,Wa)=>{var pf=yn(),Va=or(),ff=En(),Df=Ft(),mf=Df("iterator");Wa.exports=function(e){if(e!=null)return Va(e,mf)||Va(e,"@@iterator")||ff[pf(e)]}});var Ha=be((q0,$a)=>{var df=Ye(),gf=Ct(),yf=Rt(),hf=Bt(),Cf=ir(),Ef=vn(),vf=df.TypeError;$a.exports=function(e,n){var t=arguments.length<2?Ef(e):n;if(yf(t))return hf(gf(t,e));throw vf(Cf(e)+" is not iterable")}});var Ua=be((M0,Ja)=>{var Ff=Ct(),Ga=Bt(),Af=or();Ja.exports=function(e,n,t){var s,i;Ga(e);try{if(s=Af(e,"return"),!s){if(n==="throw")throw t;return t}s=Ff(s,e)}catch(r){i=!0,s=r}if(n==="throw")throw t;if(i)throw s;return Ga(s),t}});var Qa=be((R0,Ya)=>{var Sf=Ye(),xf=dn(),bf=Ct(),Tf=Bt(),Bf=ir(),Nf=Ra(),wf=Nt(),za=Mr(),_f=Ha(),Pf=vn(),Xa=Ua(),If=Sf.TypeError,vr=function(e,n){this.stopped=e,this.result=n},Ka=vr.prototype;Ya.exports=function(e,n,t){var s=t&&t.that,i=!!(t&&t.AS_ENTRIES),r=!!(t&&t.IS_ITERATOR),u=!!(t&&t.INTERRUPTED),a=xf(n,s),c,l,C,m,g,p,f,h=function(T){return c&&Xa(c,"normal",T),new vr(!0,T)},N=function(T){return i?(Tf(T),u?a(T[0],T[1],h):a(T[0],T[1])):u?a(T,h):a(T)};if(r)c=e;else{if(l=Pf(e),!l)throw If(Bf(e)+" is not iterable");if(Nf(l)){for(C=0,m=wf(e);m>C;C++)if(g=N(e[C]),g&&za(Ka,g))return g;return new vr(!1)}c=_f(e,l)}for(p=c.next;!(f=bf(p,c)).done;){try{g=N(f.value)}catch(T){Xa(c,"throw",T)}if(typeof g=="object"&&g&&za(Ka,g))return g}return new vr(!1)}});var ei=be((V0,Za)=>{"use strict";var kf=fr(),Lf=mr(),Of=nr();Za.exports=function(e,n,t){var s=kf(n);s in e?Lf.f(e,s,Of(0,t)):e[s]=t}});var ti=be(()=>{var jf=$t(),qf=Qa(),Mf=ei();jf({target:"Object",stat:!0},{fromEntries:function(n){var t={};return qf(n,function(s,i){Mf(t,s,i)},{AS_ENTRIES:!0}),t}})});var ri=be(()=>{var Rf=$t(),Vf=Ye();Rf({global:!0},{globalThis:Vf})});var ni=be(()=>{ri()});var ui=be(()=>{"use strict";var Wf=$t(),$f=gn(),Hf=pr(),Gf=Nt(),Jf=Cr(),Uf=Cn();Wf({target:"Array",proto:!0},{flat:function(){var n=arguments.length?arguments[0]:void 0,t=Hf(this),s=Gf(t),i=Uf(t,0);return i.length=$f(i,t,t,s,0,n===void 0?1:Jf(n)),i}})});var dg=be((Y0,yo)=>{var zf=["cliName","cliCategory","cliDescription"],Xf=["_"],Kf=["languageId"],si,ai,ii,oi,ci,li;function _n(e,n){if(e==null)return{};var t=Yf(e,n),s,i;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)s=r[i],!(n.indexOf(s)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,s)||(t[s]=e[s]))}return t}function Yf(e,n){if(e==null)return{};var t={},s=Object.keys(e),i,r;for(r=0;r<s.length;r++)i=s[r],!(n.indexOf(i)>=0)&&(t[i]=e[i]);return t}ja();ti();ni();ui();function wt(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var Pn=Object.defineProperty,Qf=Object.getOwnPropertyDescriptor,In=Object.getOwnPropertyNames,Zf=Object.prototype.hasOwnProperty,br=(e,n)=>function(){return e&&(n=(0,e[In(e)[0]])(e=0)),n},Z=(e,n)=>function(){return n||(0,e[In(e)[0]])((n={exports:{}}).exports,n),n.exports},kn=(e,n)=>{for(var t in n)Pn(e,t,{get:n[t],enumerable:!0})},eD=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of In(n))!Zf.call(e,i)&&i!==t&&Pn(e,i,{get:()=>n[i],enumerable:!(s=Qf(n,i))||s.enumerable});return e},pt=e=>eD(Pn({},"__esModule",{value:!0}),e),pi,fi,xt,ae=br({"<define:process>"(){pi={},fi=[],xt={env:pi,argv:fi}}}),gi=Z({"package.json"(e,n){n.exports={version:"2.6.2"}}}),tD=Z({"node_modules/diff/lib/diff/base.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=n;function n(){}n.prototype={diff:function(r,u){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},c=a.callback;typeof a=="function"&&(c=a,a={}),this.options=a;var l=this;function C(b){return c?(setTimeout(function(){c(void 0,b)},0),!0):b}r=this.castInput(r),u=this.castInput(u),r=this.removeEmpty(this.tokenize(r)),u=this.removeEmpty(this.tokenize(u));var m=u.length,g=r.length,p=1,f=m+g,h=[{newPos:-1,components:[]}],N=this.extractCommon(h[0],u,r,0);if(h[0].newPos+1>=m&&N+1>=g)return C([{value:this.join(u),count:u.length}]);function T(){for(var b=-1*p;b<=p;b+=2){var v=void 0,B=h[b-1],w=h[b+1],I=(w?w.newPos:0)-b;B&&(h[b-1]=void 0);var E=B&&B.newPos+1<m,D=w&&0<=I&&I<g;if(!E&&!D){h[b]=void 0;continue}if(!E||D&&B.newPos<w.newPos?(v=s(w),l.pushComponent(v.components,void 0,!0)):(v=B,v.newPos++,l.pushComponent(v.components,!0,void 0)),I=l.extractCommon(v,u,r,b),v.newPos+1>=m&&I+1>=g)return C(t(l,v.components,u,r,l.useLongestToken));h[b]=v}p++}if(c)(function b(){setTimeout(function(){if(p>f)return c();T()||b()},0)})();else for(;p<=f;){var A=T();if(A)return A}},pushComponent:function(r,u,a){var c=r[r.length-1];c&&c.added===u&&c.removed===a?r[r.length-1]={count:c.count+1,added:u,removed:a}:r.push({count:1,added:u,removed:a})},extractCommon:function(r,u,a,c){for(var l=u.length,C=a.length,m=r.newPos,g=m-c,p=0;m+1<l&&g+1<C&&this.equals(u[m+1],a[g+1]);)m++,g++,p++;return p&&r.components.push({count:p}),r.newPos=m,g},equals:function(r,u){return this.options.comparator?this.options.comparator(r,u):r===u||this.options.ignoreCase&&r.toLowerCase()===u.toLowerCase()},removeEmpty:function(r){for(var u=[],a=0;a<r.length;a++)r[a]&&u.push(r[a]);return u},castInput:function(r){return r},tokenize:function(r){return r.split("")},join:function(r){return r.join("")}};function t(i,r,u,a,c){for(var l=0,C=r.length,m=0,g=0;l<C;l++){var p=r[l];if(p.removed){if(p.value=i.join(a.slice(g,g+p.count)),g+=p.count,l&&r[l-1].added){var h=r[l-1];r[l-1]=r[l],r[l]=h}}else{if(!p.added&&c){var f=u.slice(m,m+p.count);f=f.map(function(T,A){var b=a[g+A];return b.length>T.length?b:T}),p.value=i.join(f)}else p.value=i.join(u.slice(m,m+p.count));m+=p.count,p.added||(g+=p.count)}}var N=r[C-1];return C>1&&typeof N.value=="string"&&(N.added||N.removed)&&i.equals("",N.value)&&(r[C-2].value+=N.value,r.pop()),r}function s(i){return{newPos:i.newPos,components:i.components.slice(0)}}}}),rD=Z({"node_modules/diff/lib/diff/array.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.diffArrays=i,e.arrayDiff=void 0;var n=t(tD());function t(r){return r&&r.__esModule?r:{default:r}}var s=new n.default;e.arrayDiff=s,s.tokenize=function(r){return r.slice()},s.join=s.removeEmpty=function(r){return r};function i(r,u,a){return s.diff(r,u,a)}}}),Ln=Z({"src/document/doc-builders.js"(e,n){"use strict";ae();function t(y){return{type:"concat",parts:y}}function s(y){return{type:"indent",contents:y}}function i(y,o){return{type:"align",contents:o,n:y}}function r(y){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return{type:"group",id:o.id,contents:y,break:Boolean(o.shouldBreak),expandedStates:o.expandedStates}}function u(y){return i(Number.NEGATIVE_INFINITY,y)}function a(y){return i({type:"root"},y)}function c(y){return i(-1,y)}function l(y,o){return r(y[0],Object.assign(Object.assign({},o),{},{expandedStates:y}))}function C(y){return{type:"fill",parts:y}}function m(y,o){let x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return{type:"if-break",breakContents:y,flatContents:o,groupId:x.groupId}}function g(y,o){return{type:"indent-if-break",contents:y,groupId:o.groupId,negate:o.negate}}function p(y){return{type:"line-suffix",contents:y}}var f={type:"line-suffix-boundary"},h={type:"break-parent"},N={type:"trim"},T={type:"line",hard:!0},A={type:"line",hard:!0,literal:!0},b={type:"line"},v={type:"line",soft:!0},B=t([T,h]),w=t([A,h]),I={type:"cursor",placeholder:Symbol("cursor")};function E(y,o){let x=[];for(let F=0;F<o.length;F++)F!==0&&x.push(y),x.push(o[F]);return t(x)}function D(y,o,x){let F=y;if(o>0){for(let S=0;S<Math.floor(o/x);++S)F=s(F);F=i(o%x,F),F=i(Number.NEGATIVE_INFINITY,F)}return F}function d(y,o){return{type:"label",label:y,contents:o}}n.exports={concat:t,join:E,line:b,softline:v,hardline:B,literalline:w,group:r,conditionalGroup:l,fill:C,lineSuffix:p,lineSuffixBoundary:f,cursor:I,breakParent:h,ifBreak:m,trim:N,indent:s,indentIfBreak:g,align:i,addAlignmentToDoc:D,markAsRoot:a,dedentToRoot:u,dedent:c,hardlineWithoutBreakParent:T,literallineWithoutBreakParent:A,label:d}}}),On=Z({"src/common/end-of-line.js"(e,n){"use strict";ae();function t(u){let a=u.indexOf("\r");return a>=0?u.charAt(a+1)===` |
| | | `?"crlf":"cr":"lf"}function s(u){switch(u){case"cr":return"\r";case"crlf":return`\r |
| | | `;default:return` |
| | | `}}function i(u,a){let c;switch(a){case` |
| | | `:c=/\n/g;break;case"\r":c=/\r/g;break;case`\r |
| | | `:c=/\r\n/g;break;default:throw new Error('Unexpected "eol" '.concat(JSON.stringify(a),"."))}let l=u.match(c);return l?l.length:0}function r(u){return u.replace(/\r\n?/g,` |
| | | `)}n.exports={guessEndOfLine:t,convertEndOfLineToChars:s,countEndOfLineChars:i,normalizeEndOfLine:r}}}),st=Z({"src/utils/get-last.js"(e,n){"use strict";ae();var t=s=>s[s.length-1];n.exports=t}}),nD=Z({"vendors/string-width.js"(e,n){ae();var t=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,u=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,c=(v,B)=>function(){return B||(0,v[r(v)[0]])((B={exports:{}}).exports,B),B.exports},l=(v,B)=>{for(var w in B)s(v,w,{get:B[w],enumerable:!0})},C=(v,B,w,I)=>{if(B&&typeof B=="object"||typeof B=="function")for(let E of r(B))!a.call(v,E)&&E!==w&&s(v,E,{get:()=>B[E],enumerable:!(I=i(B,E))||I.enumerable});return v},m=(v,B,w)=>(w=v!=null?t(u(v)):{},C(B||!v||!v.__esModule?s(w,"default",{value:v,enumerable:!0}):w,v)),g=v=>C(s({},"__esModule",{value:!0}),v),p=c({"node_modules/emoji-regex/index.js"(v,B){"use strict";B.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}}}),f={};l(f,{default:()=>b}),n.exports=g(f);function h(){let{onlyFirst:v=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(B,v?void 0:"g")}function N(v){if(typeof v!="string")throw new TypeError("Expected a `string`, got `".concat(typeof v,"`"));return v.replace(h(),"")}function T(v){return Number.isInteger(v)?v>=4352&&(v<=4447||v===9001||v===9002||11904<=v&&v<=12871&&v!==12351||12880<=v&&v<=19903||19968<=v&&v<=42182||43360<=v&&v<=43388||44032<=v&&v<=55203||63744<=v&&v<=64255||65040<=v&&v<=65049||65072<=v&&v<=65131||65281<=v&&v<=65376||65504<=v&&v<=65510||110592<=v&&v<=110593||127488<=v&&v<=127569||131072<=v&&v<=262141):!1}var A=m(p(),1);function b(v){if(typeof v!="string"||v.length===0||(v=N(v),v.length===0))return 0;v=v.replace((0,A.default)()," ");let B=0;for(let w=0;w<v.length;w++){let I=v.codePointAt(w);I<=31||I>=127&&I<=159||I>=768&&I<=879||(I>65535&&w++,B+=T(I)?2:1)}return B}}}),yi=Z({"src/utils/get-string-width.js"(e,n){"use strict";ae();var t=nD().default,s=/[^\x20-\x7F]/;function i(r){return r?s.test(r)?t(r):r.length:0}n.exports=i}}),jn=Z({"src/document/doc-utils.js"(e,n){"use strict";ae();var t=st(),{literalline:s,join:i}=Ln(),r=o=>Array.isArray(o)||o&&o.type==="concat",u=o=>{if(Array.isArray(o))return o;if(o.type!=="concat"&&o.type!=="fill")throw new Error("Expect doc type to be `concat` or `fill`.");return o.parts},a={};function c(o,x,F,S){let k=[o];for(;k.length>0;){let _=k.pop();if(_===a){F(k.pop());continue}if(F&&k.push(_,a),!x||x(_)!==!1)if(r(_)||_.type==="fill"){let O=u(_);for(let R=O.length,M=R-1;M>=0;--M)k.push(O[M])}else if(_.type==="if-break")_.flatContents&&k.push(_.flatContents),_.breakContents&&k.push(_.breakContents);else if(_.type==="group"&&_.expandedStates)if(S)for(let O=_.expandedStates.length,R=O-1;R>=0;--R)k.push(_.expandedStates[R]);else k.push(_.contents);else _.contents&&k.push(_.contents)}}function l(o,x){let F=new Map;return S(o);function S(_){if(F.has(_))return F.get(_);let O=k(_);return F.set(_,O),O}function k(_){if(Array.isArray(_))return x(_.map(S));if(_.type==="concat"||_.type==="fill"){let O=_.parts.map(S);return x(Object.assign(Object.assign({},_),{},{parts:O}))}if(_.type==="if-break"){let O=_.breakContents&&S(_.breakContents),R=_.flatContents&&S(_.flatContents);return x(Object.assign(Object.assign({},_),{},{breakContents:O,flatContents:R}))}if(_.type==="group"&&_.expandedStates){let O=_.expandedStates.map(S),R=O[0];return x(Object.assign(Object.assign({},_),{},{contents:R,expandedStates:O}))}if(_.contents){let O=S(_.contents);return x(Object.assign(Object.assign({},_),{},{contents:O}))}return x(_)}}function C(o,x,F){let S=F,k=!1;function _(O){let R=x(O);if(R!==void 0&&(k=!0,S=R),k)return!1}return c(o,_),S}function m(o){if(o.type==="group"&&o.break||o.type==="line"&&o.hard||o.type==="break-parent")return!0}function g(o){return C(o,m,!1)}function p(o){if(o.length>0){let x=t(o);!x.expandedStates&&!x.break&&(x.break="propagated")}return null}function f(o){let x=new Set,F=[];function S(_){if(_.type==="break-parent"&&p(F),_.type==="group"){if(F.push(_),x.has(_))return!1;x.add(_)}}function k(_){_.type==="group"&&F.pop().break&&p(F)}c(o,S,k,!0)}function h(o){return o.type==="line"&&!o.hard?o.soft?"":" ":o.type==="if-break"?o.flatContents||"":o}function N(o){return l(o,h)}var T=(o,x)=>o&&o.type==="line"&&o.hard&&x&&x.type==="break-parent";function A(o){if(!o)return o;if(r(o)||o.type==="fill"){let x=u(o);for(;x.length>1&&T(...x.slice(-2));)x.length-=2;if(x.length>0){let F=A(t(x));x[x.length-1]=F}return Array.isArray(o)?x:Object.assign(Object.assign({},o),{},{parts:x})}switch(o.type){case"align":case"indent":case"indent-if-break":case"group":case"line-suffix":case"label":{let x=A(o.contents);return Object.assign(Object.assign({},o),{},{contents:x})}case"if-break":{let x=A(o.breakContents),F=A(o.flatContents);return Object.assign(Object.assign({},o),{},{breakContents:x,flatContents:F})}}return o}function b(o){return A(B(o))}function v(o){switch(o.type){case"fill":if(o.parts.every(F=>F===""))return"";break;case"group":if(!o.contents&&!o.id&&!o.break&&!o.expandedStates)return"";if(o.contents.type==="group"&&o.contents.id===o.id&&o.contents.break===o.break&&o.contents.expandedStates===o.expandedStates)return o.contents;break;case"align":case"indent":case"indent-if-break":case"line-suffix":if(!o.contents)return"";break;case"if-break":if(!o.flatContents&&!o.breakContents)return"";break}if(!r(o))return o;let x=[];for(let F of u(o)){if(!F)continue;let[S,...k]=r(F)?u(F):[F];typeof S=="string"&&typeof t(x)=="string"?x[x.length-1]+=S:x.push(S),x.push(...k)}return x.length===0?"":x.length===1?x[0]:Array.isArray(o)?x:Object.assign(Object.assign({},o),{},{parts:x})}function B(o){return l(o,x=>v(x))}function w(o){let x=[],F=o.filter(Boolean);for(;F.length>0;){let S=F.shift();if(!!S){if(r(S)){F.unshift(...u(S));continue}if(x.length>0&&typeof t(x)=="string"&&typeof S=="string"){x[x.length-1]+=S;continue}x.push(S)}}return x}function I(o){return l(o,x=>Array.isArray(x)?w(x):x.parts?Object.assign(Object.assign({},x),{},{parts:w(x.parts)}):x)}function E(o){return l(o,x=>typeof x=="string"&&x.includes(` |
| | | `)?D(x):x)}function D(o){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s;return i(x,o.split(` |
| | | `)).parts}function d(o){if(o.type==="line")return!0}function y(o){return C(o,d,!1)}n.exports={isConcat:r,getDocParts:u,willBreak:g,traverseDoc:c,findInDoc:C,mapDoc:l,propagateBreaks:f,removeLines:N,stripTrailingHardline:b,normalizeParts:w,normalizeDoc:I,cleanDoc:B,replaceTextEndOfLine:D,replaceEndOfLine:E,canBreak:y}}}),uD=Z({"src/document/doc-printer.js"(e,n){"use strict";ae();var{convertEndOfLineToChars:t}=On(),s=st(),i=yi(),{fill:r,cursor:u,indent:a}=Ln(),{isConcat:c,getDocParts:l}=jn(),C,m=1,g=2;function p(){return{value:"",length:0,queue:[]}}function f(v,B){return N(v,{type:"indent"},B)}function h(v,B,w){return B===Number.NEGATIVE_INFINITY?v.root||p():B<0?N(v,{type:"dedent"},w):B?B.type==="root"?Object.assign(Object.assign({},v),{},{root:v}):N(v,{type:typeof B=="string"?"stringAlign":"numberAlign",n:B},w):v}function N(v,B,w){let I=B.type==="dedent"?v.queue.slice(0,-1):[...v.queue,B],E="",D=0,d=0,y=0;for(let O of I)switch(O.type){case"indent":F(),w.useTabs?o(1):x(w.tabWidth);break;case"stringAlign":F(),E+=O.n,D+=O.n.length;break;case"numberAlign":d+=1,y+=O.n;break;default:throw new Error("Unexpected type '".concat(O.type,"'"))}return k(),Object.assign(Object.assign({},v),{},{value:E,length:D,queue:I});function o(O){E+=" ".repeat(O),D+=w.tabWidth*O}function x(O){E+=" ".repeat(O),D+=O}function F(){w.useTabs?S():k()}function S(){d>0&&o(d),_()}function k(){y>0&&x(y),_()}function _(){d=0,y=0}}function T(v){if(v.length===0)return 0;let B=0;for(;v.length>0&&typeof s(v)=="string"&&/^[\t ]*$/.test(s(v));)B+=v.pop().length;if(v.length>0&&typeof s(v)=="string"){let w=s(v).replace(/[\t ]*$/,"");B+=s(v).length-w.length,v[v.length-1]=w}return B}function A(v,B,w,I,E,D){let d=B.length,y=[v],o=[];for(;w>=0;){if(y.length===0){if(d===0)return!0;y.push(B[d-1]),d--;continue}let[x,F,S]=y.pop();if(typeof S=="string")o.push(S),w-=i(S);else if(c(S)){let k=l(S);for(let _=k.length-1;_>=0;_--)y.push([x,F,k[_]])}else switch(S.type){case"indent":y.push([f(x,I),F,S.contents]);break;case"align":y.push([h(x,S.n,I),F,S.contents]);break;case"trim":w+=T(o);break;case"group":{if(D&&S.break)return!1;let k=S.break?m:F;y.push([x,k,S.expandedStates&&k===m?s(S.expandedStates):S.contents]),S.id&&(C[S.id]=k);break}case"fill":for(let k=S.parts.length-1;k>=0;k--)y.push([x,F,S.parts[k]]);break;case"if-break":case"indent-if-break":{let k=S.groupId?C[S.groupId]:F;if(k===m){let _=S.type==="if-break"?S.breakContents:S.negate?S.contents:a(S.contents);_&&y.push([x,F,_])}if(k===g){let _=S.type==="if-break"?S.flatContents:S.negate?a(S.contents):S.contents;_&&y.push([x,F,_])}break}case"line":switch(F){case g:if(!S.hard){S.soft||(o.push(" "),w-=1);break}return!0;case m:return!0}break;case"line-suffix":E=!0;break;case"line-suffix-boundary":if(E)return!1;break;case"label":y.push([x,F,S.contents]);break}}return!1}function b(v,B){C={};let w=B.printWidth,I=t(B.endOfLine),E=0,D=[[p(),m,v]],d=[],y=!1,o=[];for(;D.length>0;){let[F,S,k]=D.pop();if(typeof k=="string"){let _=I!==` |
| | | `?k.replace(/\n/g,I):k;d.push(_),E+=i(_)}else if(c(k)){let _=l(k);for(let O=_.length-1;O>=0;O--)D.push([F,S,_[O]])}else switch(k.type){case"cursor":d.push(u.placeholder);break;case"indent":D.push([f(F,B),S,k.contents]);break;case"align":D.push([h(F,k.n,B),S,k.contents]);break;case"trim":E-=T(d);break;case"group":switch(S){case g:if(!y){D.push([F,k.break?m:g,k.contents]);break}case m:{y=!1;let _=[F,g,k.contents],O=w-E,R=o.length>0;if(!k.break&&A(_,D,O,B,R))D.push(_);else if(k.expandedStates){let M=s(k.expandedStates);if(k.break){D.push([F,m,M]);break}else for(let H=1;H<k.expandedStates.length+1;H++)if(H>=k.expandedStates.length){D.push([F,m,M]);break}else{let P=k.expandedStates[H],G=[F,g,P];if(A(G,D,O,B,R)){D.push(G);break}}}else D.push([F,m,k.contents]);break}}k.id&&(C[k.id]=s(D)[1]);break;case"fill":{let _=w-E,{parts:O}=k;if(O.length===0)break;let[R,M]=O,H=[F,g,R],P=[F,m,R],G=A(H,[],_,B,o.length>0,!0);if(O.length===1){G?D.push(H):D.push(P);break}let re=[F,g,M],$=[F,m,M];if(O.length===2){G?D.push(re,H):D.push($,P);break}O.splice(0,2);let W=[F,S,r(O)],ee=O[0];A([F,g,[R,M,ee]],[],_,B,o.length>0,!0)?D.push(W,re,H):G?D.push(W,$,H):D.push(W,$,P);break}case"if-break":case"indent-if-break":{let _=k.groupId?C[k.groupId]:S;if(_===m){let O=k.type==="if-break"?k.breakContents:k.negate?k.contents:a(k.contents);O&&D.push([F,S,O])}if(_===g){let O=k.type==="if-break"?k.flatContents:k.negate?a(k.contents):k.contents;O&&D.push([F,S,O])}break}case"line-suffix":o.push([F,S,k.contents]);break;case"line-suffix-boundary":o.length>0&&D.push([F,S,{type:"line",hard:!0}]);break;case"line":switch(S){case g:if(k.hard)y=!0;else{k.soft||(d.push(" "),E+=1);break}case m:if(o.length>0){D.push([F,S,k],...o.reverse()),o=[];break}k.literal?F.root?(d.push(I,F.root.value),E=F.root.length):(d.push(I),E=0):(E-=T(d),d.push(I+F.value),E=F.length);break}break;case"label":D.push([F,S,k.contents]);break;default:}D.length===0&&o.length>0&&(D.push(...o.reverse()),o=[])}let x=d.indexOf(u.placeholder);if(x!==-1){let F=d.indexOf(u.placeholder,x+1),S=d.slice(0,x).join(""),k=d.slice(x+1,F).join(""),_=d.slice(F+1).join("");return{formatted:S+k+_,cursorNodeStart:S.length,cursorNodeText:k}}return{formatted:d.join("")}}n.exports={printDocToString:b}}}),sD=Z({"src/document/doc-debug.js"(e,n){"use strict";ae();var{isConcat:t,getDocParts:s}=jn();function i(u){if(!u)return"";if(t(u)){let a=[];for(let c of s(u))if(t(c))a.push(...i(c).parts);else{let l=i(c);l!==""&&a.push(l)}return{type:"concat",parts:a}}return u.type==="if-break"?Object.assign(Object.assign({},u),{},{breakContents:i(u.breakContents),flatContents:i(u.flatContents)}):u.type==="group"?Object.assign(Object.assign({},u),{},{contents:i(u.contents),expandedStates:u.expandedStates&&u.expandedStates.map(i)}):u.type==="fill"?{type:"fill",parts:u.parts.map(i)}:u.contents?Object.assign(Object.assign({},u),{},{contents:i(u.contents)}):u}function r(u){let a=Object.create(null),c=new Set;return l(i(u));function l(m,g,p){if(typeof m=="string")return JSON.stringify(m);if(t(m)){let f=s(m).map(l).filter(Boolean);return f.length===1?f[0]:"[".concat(f.join(", "),"]")}if(m.type==="line"){let f=Array.isArray(p)&&p[g+1]&&p[g+1].type==="break-parent";return m.literal?f?"literalline":"literallineWithoutBreakParent":m.hard?f?"hardline":"hardlineWithoutBreakParent":m.soft?"softline":"line"}if(m.type==="break-parent")return Array.isArray(p)&&p[g-1]&&p[g-1].type==="line"&&p[g-1].hard?void 0:"breakParent";if(m.type==="trim")return"trim";if(m.type==="indent")return"indent("+l(m.contents)+")";if(m.type==="align")return m.n===Number.NEGATIVE_INFINITY?"dedentToRoot("+l(m.contents)+")":m.n<0?"dedent("+l(m.contents)+")":m.n.type==="root"?"markAsRoot("+l(m.contents)+")":"align("+JSON.stringify(m.n)+", "+l(m.contents)+")";if(m.type==="if-break")return"ifBreak("+l(m.breakContents)+(m.flatContents?", "+l(m.flatContents):"")+(m.groupId?(m.flatContents?"":', ""')+", { groupId: ".concat(C(m.groupId)," }"):"")+")";if(m.type==="indent-if-break"){let f=[];m.negate&&f.push("negate: true"),m.groupId&&f.push("groupId: ".concat(C(m.groupId)));let h=f.length>0?", { ".concat(f.join(", ")," }"):"";return"indentIfBreak(".concat(l(m.contents)).concat(h,")")}if(m.type==="group"){let f=[];m.break&&m.break!=="propagated"&&f.push("shouldBreak: true"),m.id&&f.push("id: ".concat(C(m.id)));let h=f.length>0?", { ".concat(f.join(", ")," }"):"";return m.expandedStates?"conditionalGroup([".concat(m.expandedStates.map(N=>l(N)).join(","),"]").concat(h,")"):"group(".concat(l(m.contents)).concat(h,")")}if(m.type==="fill")return"fill([".concat(m.parts.map(f=>l(f)).join(", "),"])");if(m.type==="line-suffix")return"lineSuffix("+l(m.contents)+")";if(m.type==="line-suffix-boundary")return"lineSuffixBoundary";if(m.type==="label")return"label(".concat(JSON.stringify(m.label),", ").concat(l(m.contents),")");throw new Error("Unknown doc type "+m.type)}function C(m){if(typeof m!="symbol")return JSON.stringify(String(m));if(m in a)return a[m];let g=String(m).slice(7,-1)||"symbol";for(let p=0;;p++){let f=g+(p>0?" #".concat(p):"");if(!c.has(f))return c.add(f),a[m]="Symbol.for(".concat(JSON.stringify(f),")")}}}n.exports={printDocToDebug:r}}}),Le=Z({"src/document/index.js"(e,n){"use strict";ae(),n.exports={builders:Ln(),printer:uD(),utils:jn(),debug:sD()}}}),aD=Z({"vendors/escape-string-regexp.js"(e,n){ae();var t=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,u=(m,g)=>{for(var p in g)t(m,p,{get:g[p],enumerable:!0})},a=(m,g,p,f)=>{if(g&&typeof g=="object"||typeof g=="function")for(let h of i(g))!r.call(m,h)&&h!==p&&t(m,h,{get:()=>g[h],enumerable:!(f=s(g,h))||f.enumerable});return m},c=m=>a(t({},"__esModule",{value:!0}),m),l={};u(l,{default:()=>C}),n.exports=c(l);function C(m){if(typeof m!="string")throw new TypeError("Expected a string");return m.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}}}),hi=Z({"node_modules/semver/internal/debug.js"(e,n){ae();var t=typeof xt=="object"&&xt.env&&xt.env.NODE_DEBUG&&/\bsemver\b/i.test(xt.env.NODE_DEBUG)?function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return console.error("SEMVER",...i)}:()=>{};n.exports=t}}),Ci=Z({"node_modules/semver/internal/constants.js"(e,n){ae();var t="2.0.0",s=256,i=Number.MAX_SAFE_INTEGER||9007199254740991,r=16;n.exports={SEMVER_SPEC_VERSION:t,MAX_LENGTH:s,MAX_SAFE_INTEGER:i,MAX_SAFE_COMPONENT_LENGTH:r}}}),iD=Z({"node_modules/semver/internal/re.js"(e,n){ae();var{MAX_SAFE_COMPONENT_LENGTH:t}=Ci(),s=hi();e=n.exports={};var i=e.re=[],r=e.src=[],u=e.t={},a=0,c=(l,C,m)=>{let g=a++;s(g,C),u[l]=g,r[g]=C,i[g]=new RegExp(C,m?"g":void 0)};c("NUMERICIDENTIFIER","0|[1-9]\\d*"),c("NUMERICIDENTIFIERLOOSE","[0-9]+"),c("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),c("MAINVERSION","(".concat(r[u.NUMERICIDENTIFIER],")\\.(").concat(r[u.NUMERICIDENTIFIER],")\\.(").concat(r[u.NUMERICIDENTIFIER],")")),c("MAINVERSIONLOOSE","(".concat(r[u.NUMERICIDENTIFIERLOOSE],")\\.(").concat(r[u.NUMERICIDENTIFIERLOOSE],")\\.(").concat(r[u.NUMERICIDENTIFIERLOOSE],")")),c("PRERELEASEIDENTIFIER","(?:".concat(r[u.NUMERICIDENTIFIER],"|").concat(r[u.NONNUMERICIDENTIFIER],")")),c("PRERELEASEIDENTIFIERLOOSE","(?:".concat(r[u.NUMERICIDENTIFIERLOOSE],"|").concat(r[u.NONNUMERICIDENTIFIER],")")),c("PRERELEASE","(?:-(".concat(r[u.PRERELEASEIDENTIFIER],"(?:\\.").concat(r[u.PRERELEASEIDENTIFIER],")*))")),c("PRERELEASELOOSE","(?:-?(".concat(r[u.PRERELEASEIDENTIFIERLOOSE],"(?:\\.").concat(r[u.PRERELEASEIDENTIFIERLOOSE],")*))")),c("BUILDIDENTIFIER","[0-9A-Za-z-]+"),c("BUILD","(?:\\+(".concat(r[u.BUILDIDENTIFIER],"(?:\\.").concat(r[u.BUILDIDENTIFIER],")*))")),c("FULLPLAIN","v?".concat(r[u.MAINVERSION]).concat(r[u.PRERELEASE],"?").concat(r[u.BUILD],"?")),c("FULL","^".concat(r[u.FULLPLAIN],"$")),c("LOOSEPLAIN","[v=\\s]*".concat(r[u.MAINVERSIONLOOSE]).concat(r[u.PRERELEASELOOSE],"?").concat(r[u.BUILD],"?")),c("LOOSE","^".concat(r[u.LOOSEPLAIN],"$")),c("GTLT","((?:<|>)?=?)"),c("XRANGEIDENTIFIERLOOSE","".concat(r[u.NUMERICIDENTIFIERLOOSE],"|x|X|\\*")),c("XRANGEIDENTIFIER","".concat(r[u.NUMERICIDENTIFIER],"|x|X|\\*")),c("XRANGEPLAIN","[v=\\s]*(".concat(r[u.XRANGEIDENTIFIER],")(?:\\.(").concat(r[u.XRANGEIDENTIFIER],")(?:\\.(").concat(r[u.XRANGEIDENTIFIER],")(?:").concat(r[u.PRERELEASE],")?").concat(r[u.BUILD],"?)?)?")),c("XRANGEPLAINLOOSE","[v=\\s]*(".concat(r[u.XRANGEIDENTIFIERLOOSE],")(?:\\.(").concat(r[u.XRANGEIDENTIFIERLOOSE],")(?:\\.(").concat(r[u.XRANGEIDENTIFIERLOOSE],")(?:").concat(r[u.PRERELEASELOOSE],")?").concat(r[u.BUILD],"?)?)?")),c("XRANGE","^".concat(r[u.GTLT],"\\s*").concat(r[u.XRANGEPLAIN],"$")),c("XRANGELOOSE","^".concat(r[u.GTLT],"\\s*").concat(r[u.XRANGEPLAINLOOSE],"$")),c("COERCE","(^|[^\\d])(\\d{1,".concat(t,"})(?:\\.(\\d{1,").concat(t,"}))?(?:\\.(\\d{1,").concat(t,"}))?(?:$|[^\\d])")),c("COERCERTL",r[u.COERCE],!0),c("LONETILDE","(?:~>?)"),c("TILDETRIM","(\\s*)".concat(r[u.LONETILDE],"\\s+"),!0),e.tildeTrimReplace="$1~",c("TILDE","^".concat(r[u.LONETILDE]).concat(r[u.XRANGEPLAIN],"$")),c("TILDELOOSE","^".concat(r[u.LONETILDE]).concat(r[u.XRANGEPLAINLOOSE],"$")),c("LONECARET","(?:\\^)"),c("CARETTRIM","(\\s*)".concat(r[u.LONECARET],"\\s+"),!0),e.caretTrimReplace="$1^",c("CARET","^".concat(r[u.LONECARET]).concat(r[u.XRANGEPLAIN],"$")),c("CARETLOOSE","^".concat(r[u.LONECARET]).concat(r[u.XRANGEPLAINLOOSE],"$")),c("COMPARATORLOOSE","^".concat(r[u.GTLT],"\\s*(").concat(r[u.LOOSEPLAIN],")$|^$")),c("COMPARATOR","^".concat(r[u.GTLT],"\\s*(").concat(r[u.FULLPLAIN],")$|^$")),c("COMPARATORTRIM","(\\s*)".concat(r[u.GTLT],"\\s*(").concat(r[u.LOOSEPLAIN],"|").concat(r[u.XRANGEPLAIN],")"),!0),e.comparatorTrimReplace="$1$2$3",c("HYPHENRANGE","^\\s*(".concat(r[u.XRANGEPLAIN],")\\s+-\\s+(").concat(r[u.XRANGEPLAIN],")\\s*$")),c("HYPHENRANGELOOSE","^\\s*(".concat(r[u.XRANGEPLAINLOOSE],")\\s+-\\s+(").concat(r[u.XRANGEPLAINLOOSE],")\\s*$")),c("STAR","(<|>)?=?\\s*\\*"),c("GTE0","^\\s*>=\\s*0.0.0\\s*$"),c("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}}),oD=Z({"node_modules/semver/internal/parse-options.js"(e,n){ae();var t=["includePrerelease","loose","rtl"],s=i=>i?typeof i!="object"?{loose:!0}:t.filter(r=>i[r]).reduce((r,u)=>(r[u]=!0,r),{}):{};n.exports=s}}),cD=Z({"node_modules/semver/internal/identifiers.js"(e,n){ae();var t=/^[0-9]+$/,s=(r,u)=>{let a=t.test(r),c=t.test(u);return a&&c&&(r=+r,u=+u),r===u?0:a&&!c?-1:c&&!a?1:r<u?-1:1},i=(r,u)=>s(u,r);n.exports={compareIdentifiers:s,rcompareIdentifiers:i}}}),lD=Z({"node_modules/semver/classes/semver.js"(e,n){ae();var t=hi(),{MAX_LENGTH:s,MAX_SAFE_INTEGER:i}=Ci(),{re:r,t:u}=iD(),a=oD(),{compareIdentifiers:c}=cD(),l=class{constructor(C,m){if(m=a(m),C instanceof l){if(C.loose===!!m.loose&&C.includePrerelease===!!m.includePrerelease)return C;C=C.version}else if(typeof C!="string")throw new TypeError("Invalid Version: ".concat(C));if(C.length>s)throw new TypeError("version is longer than ".concat(s," characters"));t("SemVer",C,m),this.options=m,this.loose=!!m.loose,this.includePrerelease=!!m.includePrerelease;let g=C.trim().match(m.loose?r[u.LOOSE]:r[u.FULL]);if(!g)throw new TypeError("Invalid Version: ".concat(C));if(this.raw=C,this.major=+g[1],this.minor=+g[2],this.patch=+g[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");g[4]?this.prerelease=g[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){let f=+p;if(f>=0&&f<i)return f}return p}):this.prerelease=[],this.build=g[5]?g[5].split("."):[],this.format()}format(){return this.version="".concat(this.major,".").concat(this.minor,".").concat(this.patch),this.prerelease.length&&(this.version+="-".concat(this.prerelease.join("."))),this.version}toString(){return this.version}compare(C){if(t("SemVer.compare",this.version,this.options,C),!(C instanceof l)){if(typeof C=="string"&&C===this.version)return 0;C=new l(C,this.options)}return C.version===this.version?0:this.compareMain(C)||this.comparePre(C)}compareMain(C){return C instanceof l||(C=new l(C,this.options)),c(this.major,C.major)||c(this.minor,C.minor)||c(this.patch,C.patch)}comparePre(C){if(C instanceof l||(C=new l(C,this.options)),this.prerelease.length&&!C.prerelease.length)return-1;if(!this.prerelease.length&&C.prerelease.length)return 1;if(!this.prerelease.length&&!C.prerelease.length)return 0;let m=0;do{let g=this.prerelease[m],p=C.prerelease[m];if(t("prerelease compare",m,g,p),g===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(g===void 0)return-1;if(g===p)continue;return c(g,p)}while(++m)}compareBuild(C){C instanceof l||(C=new l(C,this.options));let m=0;do{let g=this.build[m],p=C.build[m];if(t("prerelease compare",m,g,p),g===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(g===void 0)return-1;if(g===p)continue;return c(g,p)}while(++m)}inc(C,m){switch(C){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",m),this.inc("pre",m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",m),this.inc("pre",m);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let g=this.prerelease.length;for(;--g>=0;)typeof this.prerelease[g]=="number"&&(this.prerelease[g]++,g=-2);g===-1&&this.prerelease.push(0)}m&&(this.prerelease[0]===m?isNaN(this.prerelease[1])&&(this.prerelease=[m,0]):this.prerelease=[m,0]);break;default:throw new Error("invalid increment argument: ".concat(C))}return this.format(),this.raw=this.version,this}};n.exports=l}}),qn=Z({"node_modules/semver/functions/compare.js"(e,n){ae();var t=lD(),s=(i,r,u)=>new t(i,u).compare(new t(r,u));n.exports=s}}),pD=Z({"node_modules/semver/functions/lt.js"(e,n){ae();var t=qn(),s=(i,r,u)=>t(i,r,u)<0;n.exports=s}}),fD=Z({"node_modules/semver/functions/gte.js"(e,n){ae();var t=qn(),s=(i,r,u)=>t(i,r,u)>=0;n.exports=s}}),DD=Z({"src/utils/arrayify.js"(e,n){"use strict";ae(),n.exports=(t,s)=>Object.entries(t).map(i=>{let[r,u]=i;return Object.assign({[s]:r},u)})}}),mD=Z({"node_modules/outdent/lib/index.js"(e,n){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.outdent=void 0;function t(){for(var A=[],b=0;b<arguments.length;b++)A[b]=arguments[b]}function s(){return typeof WeakMap<"u"?new WeakMap:i()}function i(){return{add:t,delete:t,get:t,set:t,has:function(A){return!1}}}var r=Object.prototype.hasOwnProperty,u=function(A,b){return r.call(A,b)};function a(A,b){for(var v in b)u(b,v)&&(A[v]=b[v]);return A}var c=/^[ \t]*(?:\r\n|\r|\n)/,l=/(?:\r\n|\r|\n)[ \t]*$/,C=/^(?:[\r\n]|$)/,m=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,g=/^[ \t]*[\r\n][ \t\r\n]*$/;function p(A,b,v){var B=0,w=A[0].match(m);w&&(B=w[1].length);var I="(\\r\\n|\\r|\\n).{0,"+B+"}",E=new RegExp(I,"g");b&&(A=A.slice(1));var D=v.newline,d=v.trimLeadingNewline,y=v.trimTrailingNewline,o=typeof D=="string",x=A.length,F=A.map(function(S,k){return S=S.replace(E,"$1"),k===0&&d&&(S=S.replace(c,"")),k===x-1&&y&&(S=S.replace(l,"")),o&&(S=S.replace(/\r\n|\n|\r/g,function(_){return D})),S});return F}function f(A,b){for(var v="",B=0,w=A.length;B<w;B++)v+=A[B],B<w-1&&(v+=b[B]);return v}function h(A){return u(A,"raw")&&u(A,"length")}function N(A){var b=s(),v=s();function B(I){for(var E=[],D=1;D<arguments.length;D++)E[D-1]=arguments[D];if(h(I)){var d=I,y=(E[0]===B||E[0]===T)&&g.test(d[0])&&C.test(d[1]),o=y?v:b,x=o.get(d);if(x||(x=p(d,y,A),o.set(d,x)),E.length===0)return x[0];var F=f(x,y?E.slice(1):E);return F}else return N(a(a({},A),I||{}))}var w=a(B,{string:function(I){return p([I],!1,A)[0]}});return w}var T=N({trimLeadingNewline:!0,trimTrailingNewline:!0});if(e.outdent=T,e.default=T,typeof n<"u")try{n.exports=T,Object.defineProperty(T,"__esModule",{value:!0}),T.default=T,T.outdent=T}catch{}}}),dD=Z({"src/main/core-options.js"(e,n){"use strict";ae();var{outdent:t}=mD(),s="Config",i="Editor",r="Format",u="Other",a="Output",c="Global",l="Special",C={cursorOffset:{since:"1.4.0",category:l,type:"int",default:-1,range:{start:-1,end:Number.POSITIVE_INFINITY,step:1},description:t(si||(si=wt([` |
| | | Print (to stderr) where a cursor at the given position would move to after formatting. |
| | | This option cannot be used with --range-start and --range-end. |
| | | `]))),cliCategory:i},endOfLine:{since:"1.15.0",category:c,type:"choice",default:[{since:"1.15.0",value:"auto"},{since:"2.0.0",value:"lf"}],description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:t(ai||(ai=wt([` |
| | | Maintain existing |
| | | (mixed values within one file are normalised by looking at what's used after the first line) |
| | | `])))}]},filepath:{since:"1.4.0",category:l,type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:u,cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{since:"1.8.0",category:l,type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:u},parser:{since:"0.0.10",category:c,type:"choice",default:[{since:"0.0.10",value:"babylon"},{since:"1.13.0",value:void 0}],description:"Which parser to use.",exception:m=>typeof m=="string"||typeof m=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",since:"1.16.0",description:"JavaScript"},{value:"babel-flow",since:"1.16.0",description:"Flow"},{value:"babel-ts",since:"2.0.0",description:"TypeScript"},{value:"typescript",since:"1.4.0",description:"TypeScript"},{value:"acorn",since:"2.6.0",description:"JavaScript"},{value:"espree",since:"2.2.0",description:"JavaScript"},{value:"meriyah",since:"2.2.0",description:"JavaScript"},{value:"css",since:"1.7.1",description:"CSS"},{value:"less",since:"1.7.1",description:"Less"},{value:"scss",since:"1.7.1",description:"SCSS"},{value:"json",since:"1.5.0",description:"JSON"},{value:"json5",since:"1.13.0",description:"JSON5"},{value:"json-stringify",since:"1.13.0",description:"JSON.stringify"},{value:"graphql",since:"1.5.0",description:"GraphQL"},{value:"markdown",since:"1.8.0",description:"Markdown"},{value:"mdx",since:"1.15.0",description:"MDX"},{value:"vue",since:"1.10.0",description:"Vue"},{value:"yaml",since:"1.14.0",description:"YAML"},{value:"glimmer",since:"2.3.0",description:"Ember / Handlebars"},{value:"html",since:"1.15.0",description:"HTML"},{value:"angular",since:"1.15.0",description:"Angular"},{value:"lwc",since:"1.17.0",description:"Lightning Web Components"}]},plugins:{since:"1.10.0",type:"path",array:!0,default:[{value:[]}],category:c,description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:m=>typeof m=="string"||typeof m=="object",cliName:"plugin",cliCategory:s},pluginSearchDirs:{since:"1.13.0",type:"path",array:!0,default:[{value:[]}],category:c,description:t(ii||(ii=wt([` |
| | | Custom directory that contains prettier plugins in node_modules subdirectory. |
| | | Overrides default behavior when plugins are searched relatively to the location of Prettier. |
| | | Multiple values are accepted. |
| | | `]))),exception:m=>typeof m=="string"||typeof m=="object",cliName:"plugin-search-dir",cliCategory:s},printWidth:{since:"0.0.0",category:c,type:"int",default:80,description:"The line length where Prettier will try wrap.",range:{start:0,end:Number.POSITIVE_INFINITY,step:1}},rangeEnd:{since:"1.4.0",category:l,type:"int",default:Number.POSITIVE_INFINITY,range:{start:0,end:Number.POSITIVE_INFINITY,step:1},description:t(oi||(oi=wt([` |
| | | Format code ending at a given character offset (exclusive). |
| | | The range will extend forwards to the end of the selected statement. |
| | | This option cannot be used with --cursor-offset. |
| | | `]))),cliCategory:i},rangeStart:{since:"1.4.0",category:l,type:"int",default:0,range:{start:0,end:Number.POSITIVE_INFINITY,step:1},description:t(ci||(ci=wt([` |
| | | Format code starting at a given character offset. |
| | | The range will extend backwards to the start of the first line containing the selected statement. |
| | | This option cannot be used with --cursor-offset. |
| | | `]))),cliCategory:i},requirePragma:{since:"1.7.0",category:l,type:"boolean",default:!1,description:t(li||(li=wt([` |
| | | Require either '@prettier' or '@format' to be present in the file's first docblock comment |
| | | in order for it to be formatted. |
| | | `]))),cliCategory:u},tabWidth:{type:"int",category:c,default:2,description:"Number of spaces per indentation level.",range:{start:0,end:Number.POSITIVE_INFINITY,step:1}},useTabs:{since:"1.0.0",category:c,type:"boolean",default:!1,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{since:"2.1.0",category:c,type:"choice",default:[{since:"2.1.0",value:"auto"}],description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};n.exports={CATEGORY_CONFIG:s,CATEGORY_EDITOR:i,CATEGORY_FORMAT:r,CATEGORY_OTHER:u,CATEGORY_OUTPUT:a,CATEGORY_GLOBAL:c,CATEGORY_SPECIAL:l,options:C}}}),Mn=Z({"src/main/support.js"(e,n){"use strict";ae();var t={compare:qn(),lt:pD(),gte:fD()},s=DD(),i=gi().version,r=dD().options;function u(){let{plugins:c=[],showUnreleased:l=!1,showDeprecated:C=!1,showInternal:m=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},g=i.split("-",1)[0],p=c.flatMap(A=>A.languages||[]).filter(h),f=s(Object.assign({},...c.map(A=>{let{options:b}=A;return b}),r),"name").filter(A=>h(A)&&N(A)).sort((A,b)=>A.name===b.name?0:A.name<b.name?-1:1).map(T).map(A=>{A=Object.assign({},A),Array.isArray(A.default)&&(A.default=A.default.length===1?A.default[0].value:A.default.filter(h).sort((v,B)=>t.compare(B.since,v.since))[0].value),Array.isArray(A.choices)&&(A.choices=A.choices.filter(v=>h(v)&&N(v)),A.name==="parser"&&a(A,p,c));let b=Object.fromEntries(c.filter(v=>v.defaultOptions&&v.defaultOptions[A.name]!==void 0).map(v=>[v.name,v.defaultOptions[A.name]]));return Object.assign(Object.assign({},A),{},{pluginDefaults:b})});return{languages:p,options:f};function h(A){return l||!("since"in A)||A.since&&t.gte(g,A.since)}function N(A){return C||!("deprecated"in A)||A.deprecated&&t.lt(g,A.deprecated)}function T(A){if(m)return A;let{cliName:b,cliCategory:v,cliDescription:B}=A;return _n(A,zf)}}function a(c,l,C){let m=new Set(c.choices.map(g=>g.value));for(let g of l)if(g.parsers){for(let p of g.parsers)if(!m.has(p)){m.add(p);let f=C.find(N=>N.parsers&&N.parsers[p]),h=g.name;f&&f.name&&(h+=" (plugin: ".concat(f.name,")")),c.choices.push({value:p,description:h})}}}n.exports={getSupportInfo:u}}}),Rn=Z({"src/utils/is-non-empty-array.js"(e,n){"use strict";ae();function t(s){return Array.isArray(s)&&s.length>0}n.exports=t}}),Tr=Z({"src/utils/text/skip.js"(e,n){"use strict";ae();function t(a){return(c,l,C)=>{let m=C&&C.backwards;if(l===!1)return!1;let{length:g}=c,p=l;for(;p>=0&&p<g;){let f=c.charAt(p);if(a instanceof RegExp){if(!a.test(f))return p}else if(!a.includes(f))return p;m?p--:p++}return p===-1||p===g?p:!1}}var s=t(/\s/),i=t(" "),r=t(",; "),u=t(/[^\n\r]/);n.exports={skipWhitespace:s,skipSpaces:i,skipToLineEnd:r,skipEverythingButNewLine:u}}}),Ei=Z({"src/utils/text/skip-inline-comment.js"(e,n){"use strict";ae();function t(s,i){if(i===!1)return!1;if(s.charAt(i)==="/"&&s.charAt(i+1)==="*"){for(let r=i+2;r<s.length;++r)if(s.charAt(r)==="*"&&s.charAt(r+1)==="/")return r+2}return i}n.exports=t}}),vi=Z({"src/utils/text/skip-trailing-comment.js"(e,n){"use strict";ae();var{skipEverythingButNewLine:t}=Tr();function s(i,r){return r===!1?!1:i.charAt(r)==="/"&&i.charAt(r+1)==="/"?t(i,r):r}n.exports=s}}),Fi=Z({"src/utils/text/skip-newline.js"(e,n){"use strict";ae();function t(s,i,r){let u=r&&r.backwards;if(i===!1)return!1;let a=s.charAt(i);if(u){if(s.charAt(i-1)==="\r"&&a===` |
| | | `)return i-2;if(a===` |
| | | `||a==="\r"||a==="\u2028"||a==="\u2029")return i-1}else{if(a==="\r"&&s.charAt(i+1)===` |
| | | `)return i+2;if(a===` |
| | | `||a==="\r"||a==="\u2028"||a==="\u2029")return i+1}return i}n.exports=t}}),gD=Z({"src/utils/text/get-next-non-space-non-comment-character-index-with-start-index.js"(e,n){"use strict";ae();var t=Ei(),s=Fi(),i=vi(),{skipSpaces:r}=Tr();function u(a,c){let l=null,C=c;for(;C!==l;)l=C,C=r(a,C),C=t(a,C),C=i(a,C),C=s(a,C);return C}n.exports=u}}),Ge=Z({"src/common/util.js"(e,n){"use strict";ae();var{default:t}=aD(),s=st(),{getSupportInfo:i}=Mn(),r=Rn(),u=yi(),{skipWhitespace:a,skipSpaces:c,skipToLineEnd:l,skipEverythingButNewLine:C}=Tr(),m=Ei(),g=vi(),p=Fi(),f=gD(),h=$=>$[$.length-2];function N($){return(W,ee,U)=>{let ne=U&&U.backwards;if(ee===!1)return!1;let{length:se}=W,V=ee;for(;V>=0&&V<se;){let oe=W.charAt(V);if($ instanceof RegExp){if(!$.test(oe))return V}else if(!$.includes(oe))return V;ne?V--:V++}return V===-1||V===se?V:!1}}function T($,W){let ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=c($,ee.backwards?W-1:W,ee),ne=p($,U,ee);return U!==ne}function A($,W,ee){for(let U=W;U<ee;++U)if($.charAt(U)===` |
| | | `)return!0;return!1}function b($,W,ee){let U=ee(W)-1;U=c($,U,{backwards:!0}),U=p($,U,{backwards:!0}),U=c($,U,{backwards:!0});let ne=p($,U,{backwards:!0});return U!==ne}function v($,W){let ee=null,U=W;for(;U!==ee;)ee=U,U=l($,U),U=m($,U),U=c($,U);return U=g($,U),U=p($,U),U!==!1&&T($,U)}function B($,W,ee){return v($,ee(W))}function w($,W,ee){return f($,ee(W))}function I($,W,ee){return $.charAt(w($,W,ee))}function E($,W){let ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return c($,ee.backwards?W-1:W,ee)!==W}function D($,W){let ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,U=0;for(let ne=ee;ne<$.length;++ne)$[ne]===" "?U=U+W-U%W:U++;return U}function d($,W){let ee=$.lastIndexOf(` |
| | | `);return ee===-1?0:D($.slice(ee+1).match(/^[\t ]*/)[0],W)}function y($,W){let ee={quote:'"',regex:/"/g,escaped:"""},U={quote:"'",regex:/'/g,escaped:"'"},ne=W==="'"?U:ee,se=ne===U?ee:U,V=ne;if($.includes(ne.quote)||$.includes(se.quote)){let oe=($.match(ne.regex)||[]).length,K=($.match(se.regex)||[]).length;V=oe>K?se:ne}return V}function o($,W){let ee=$.slice(1,-1),U=W.parser==="json"||W.parser==="json5"&&W.quoteProps==="preserve"&&!W.singleQuote?'"':W.__isInHtmlAttribute?"'":y(ee,W.singleQuote?"'":'"').quote;return x(ee,U,!(W.parser==="css"||W.parser==="less"||W.parser==="scss"||W.__embeddedInHtml))}function x($,W,ee){let U=W==='"'?"'":'"',ne=/\\(.)|(["'])/gs,se=$.replace(ne,(V,oe,K)=>oe===U?oe:K===W?"\\"+K:K||(ee&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(oe)?oe:"\\"+oe));return W+se+W}function F($){return $.toLowerCase().replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/,"$1$2$3").replace(/^([+-]?[\d.]+)e[+-]?0+$/,"$1").replace(/^([+-])?\./,"$10.").replace(/(\.\d+?)0+(?=e|$)/,"$1").replace(/\.(?=e|$)/,"")}function S($,W){let ee=$.match(new RegExp("(".concat(t(W),")+"),"g"));return ee===null?0:ee.reduce((U,ne)=>Math.max(U,ne.length/W.length),0)}function k($,W){let ee=$.match(new RegExp("(".concat(t(W),")+"),"g"));if(ee===null)return 0;let U=new Map,ne=0;for(let se of ee){let V=se.length/W.length;U.set(V,!0),V>ne&&(ne=V)}for(let se=1;se<ne;se++)if(!U.get(se))return se;return ne+1}function _($,W){($.comments||($.comments=[])).push(W),W.printed=!1,W.nodeDescription=re($)}function O($,W){W.leading=!0,W.trailing=!1,_($,W)}function R($,W,ee){W.leading=!1,W.trailing=!1,ee&&(W.marker=ee),_($,W)}function M($,W){W.leading=!1,W.trailing=!0,_($,W)}function H($,W){let{languages:ee}=i({plugins:W.plugins}),U=ee.find(ne=>{let{name:se}=ne;return se.toLowerCase()===$})||ee.find(ne=>{let{aliases:se}=ne;return Array.isArray(se)&&se.includes($)})||ee.find(ne=>{let{extensions:se}=ne;return Array.isArray(se)&&se.includes(".".concat($))});return U&&U.parsers[0]}function P($){return $&&$.type==="front-matter"}function G($){let W=new WeakMap;return function(ee){return W.has(ee)||W.set(ee,Symbol($)),W.get(ee)}}function re($){let W=$.type||$.kind||"(unknown type)",ee=String($.name||$.id&&(typeof $.id=="object"?$.id.name:$.id)||$.key&&(typeof $.key=="object"?$.key.name:$.key)||$.value&&(typeof $.value=="object"?"":String($.value))||$.operator||"");return ee.length>20&&(ee=ee.slice(0,19)+"\u2026"),W+(ee?" "+ee:"")}n.exports={inferParserByLanguage:H,getStringWidth:u,getMaxContinuousCount:S,getMinNotPresentContinuousCount:k,getPenultimate:h,getLast:s,getNextNonSpaceNonCommentCharacterIndexWithStartIndex:f,getNextNonSpaceNonCommentCharacterIndex:w,getNextNonSpaceNonCommentCharacter:I,skip:N,skipWhitespace:a,skipSpaces:c,skipToLineEnd:l,skipEverythingButNewLine:C,skipInlineComment:m,skipTrailingComment:g,skipNewline:p,isNextLineEmptyAfterIndex:v,isNextLineEmpty:B,isPreviousLineEmpty:b,hasNewline:T,hasNewlineInRange:A,hasSpaces:E,getAlignmentSize:D,getIndentSize:d,getPreferredQuote:y,printString:o,printNumber:F,makeString:x,addLeadingComment:O,addDanglingComment:R,addTrailingComment:M,isFrontMatterNode:P,isNonEmptyArray:r,createGroupIdMapper:G}}}),Ai={};kn(Ai,{basename:()=>Bi,default:()=>wi,delimiter:()=>bn,dirname:()=>Ti,extname:()=>Ni,isAbsolute:()=>Wn,join:()=>xi,normalize:()=>Vn,relative:()=>bi,resolve:()=>xr,sep:()=>xn});function Si(e,n){for(var t=0,s=e.length-1;s>=0;s--){var i=e[s];i==="."?e.splice(s,1):i===".."?(e.splice(s,1),t++):t&&(e.splice(s,1),t--)}if(n)for(;t--;t)e.unshift("..");return e}function xr(){for(var e="",n=!1,t=arguments.length-1;t>=-1&&!n;t--){var s=t>=0?arguments[t]:"/";if(typeof s!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!s)continue;e=s+"/"+e,n=s.charAt(0)==="/"}return e=Si($n(e.split("/"),function(i){return!!i}),!n).join("/"),(n?"/":"")+e||"."}function Vn(e){var n=Wn(e),t=_i(e,-1)==="/";return e=Si($n(e.split("/"),function(s){return!!s}),!n).join("/"),!e&&!n&&(e="."),e&&t&&(e+="/"),(n?"/":"")+e}function Wn(e){return e.charAt(0)==="/"}function xi(){var e=Array.prototype.slice.call(arguments,0);return Vn($n(e,function(n,t){if(typeof n!="string")throw new TypeError("Arguments to path.join must be strings");return n}).join("/"))}function bi(e,n){e=xr(e).substr(1),n=xr(n).substr(1);function t(l){for(var C=0;C<l.length&&l[C]==="";C++);for(var m=l.length-1;m>=0&&l[m]==="";m--);return C>m?[]:l.slice(C,m-C+1)}for(var s=t(e.split("/")),i=t(n.split("/")),r=Math.min(s.length,i.length),u=r,a=0;a<r;a++)if(s[a]!==i[a]){u=a;break}for(var c=[],a=u;a<s.length;a++)c.push("..");return c=c.concat(i.slice(u)),c.join("/")}function Ti(e){var n=Br(e),t=n[0],s=n[1];return!t&&!s?".":(s&&(s=s.substr(0,s.length-1)),t+s)}function Bi(e,n){var t=Br(e)[2];return n&&t.substr(-1*n.length)===n&&(t=t.substr(0,t.length-n.length)),t}function Ni(e){return Br(e)[3]}function $n(e,n){if(e.filter)return e.filter(n);for(var t=[],s=0;s<e.length;s++)n(e[s],s,e)&&t.push(e[s]);return t}var Di,Br,xn,bn,wi,_i,yD=br({"node-modules-polyfills:path"(){ae(),Di=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Br=function(e){return Di.exec(e).slice(1)},xn="/",bn=":",wi={extname:Ni,basename:Bi,dirname:Ti,sep:xn,delimiter:bn,relative:bi,join:xi,isAbsolute:Wn,normalize:Vn,resolve:xr},_i="ab".substr(-1)==="b"?function(e,n,t){return e.substr(n,t)}:function(e,n,t){return n<0&&(n=e.length+n),e.substr(n,t)}}}),Pi=Z({"node-modules-polyfills-commonjs:path"(e,n){ae();var t=(yD(),pt(Ai));if(t&&t.default){n.exports=t.default;for(let s in t)n.exports[s]=t[s]}else t&&(n.exports=t)}}),Jt=Z({"src/common/errors.js"(e,n){"use strict";ae();var t=class extends Error{},s=class extends Error{},i=class extends Error{},r=class extends Error{};n.exports={ConfigError:t,DebugError:s,UndefinedParserError:i,ArgExpansionBailout:r}}}),Dt={};kn(Dt,{__assign:()=>Sr,__asyncDelegator:()=>wD,__asyncGenerator:()=>ND,__asyncValues:()=>_D,__await:()=>Gt,__awaiter:()=>AD,__classPrivateFieldGet:()=>LD,__classPrivateFieldSet:()=>OD,__createBinding:()=>xD,__decorate:()=>ED,__exportStar:()=>bD,__extends:()=>hD,__generator:()=>SD,__importDefault:()=>kD,__importStar:()=>ID,__makeTemplateObject:()=>PD,__metadata:()=>FD,__param:()=>vD,__read:()=>Ii,__rest:()=>CD,__spread:()=>TD,__spreadArrays:()=>BD,__values:()=>Tn});function hD(e,n){Ar(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}function CD(e,n){var t={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&n.indexOf(s)<0&&(t[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)n.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(t[s[i]]=e[s[i]]);return t}function ED(e,n,t,s){var i=arguments.length,r=i<3?n:s===null?s=Object.getOwnPropertyDescriptor(n,t):s,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(e,n,t,s);else for(var a=e.length-1;a>=0;a--)(u=e[a])&&(r=(i<3?u(r):i>3?u(n,t,r):u(n,t))||r);return i>3&&r&&Object.defineProperty(n,t,r),r}function vD(e,n){return function(t,s){n(t,s,e)}}function FD(e,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,n)}function AD(e,n,t,s){function i(r){return r instanceof t?r:new t(function(u){u(r)})}return new(t||(t=Promise))(function(r,u){function a(C){try{l(s.next(C))}catch(m){u(m)}}function c(C){try{l(s.throw(C))}catch(m){u(m)}}function l(C){C.done?r(C.value):i(C.value).then(a,c)}l((s=s.apply(e,n||[])).next())})}function SD(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,i,r,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(l){return function(C){return c([l,C])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;t;)try{if(s=1,i&&(r=l[0]&2?i.return:l[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;switch(i=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1],r=l;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(l);break}r[2]&&t.ops.pop(),t.trys.pop();continue}l=n.call(e,t)}catch(C){l=[6,C],i=0}finally{s=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function xD(e,n,t,s){s===void 0&&(s=t),e[s]=n[t]}function bD(e,n){for(var t in e)t!=="default"&&!n.hasOwnProperty(t)&&(n[t]=e[t])}function Tn(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],s=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ii(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var s=t.call(e),i,r=[],u;try{for(;(n===void 0||n-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(a){u={error:a}}finally{try{i&&!i.done&&(t=s.return)&&t.call(s)}finally{if(u)throw u.error}}return r}function TD(){for(var e=[],n=0;n<arguments.length;n++)e=e.concat(Ii(arguments[n]));return e}function BD(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;for(var s=Array(e),i=0,n=0;n<t;n++)for(var r=arguments[n],u=0,a=r.length;u<a;u++,i++)s[i]=r[u];return s}function Gt(e){return this instanceof Gt?(this.v=e,this):new Gt(e)}function ND(e,n,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(e,n||[]),i,r=[];return i={},u("next"),u("throw"),u("return"),i[Symbol.asyncIterator]=function(){return this},i;function u(g){s[g]&&(i[g]=function(p){return new Promise(function(f,h){r.push([g,p,f,h])>1||a(g,p)})})}function a(g,p){try{c(s[g](p))}catch(f){m(r[0][3],f)}}function c(g){g.value instanceof Gt?Promise.resolve(g.value.v).then(l,C):m(r[0][2],g)}function l(g){a("next",g)}function C(g){a("throw",g)}function m(g,p){g(p),r.shift(),r.length&&a(r[0][0],r[0][1])}}function wD(e){var n,t;return n={},s("next"),s("throw",function(i){throw i}),s("return"),n[Symbol.iterator]=function(){return this},n;function s(i,r){n[i]=e[i]?function(u){return(t=!t)?{value:Gt(e[i](u)),done:i==="return"}:r?r(u):u}:r}}function _D(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e[Symbol.asyncIterator],t;return n?n.call(e):(e=typeof Tn=="function"?Tn(e):e[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(r){t[r]=e[r]&&function(u){return new Promise(function(a,c){u=e[r](u),i(a,c,u.done,u.value)})}}function i(r,u,a,c){Promise.resolve(c).then(function(l){r({value:l,done:a})},u)}}function PD(e,n){return Object.defineProperty?Object.defineProperty(e,"raw",{value:n}):e.raw=n,e}function ID(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var t in e)Object.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}function kD(e){return e&&e.__esModule?e:{default:e}}function LD(e,n){if(!n.has(e))throw new TypeError("attempted to get private field on non-instance");return n.get(e)}function OD(e,n,t){if(!n.has(e))throw new TypeError("attempted to set private field on non-instance");return n.set(e,t),t}var Ar,Sr,gt=br({"node_modules/tslib/tslib.es6.js"(){ae(),Ar=function(e,n){return Ar=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)s.hasOwnProperty(i)&&(t[i]=s[i])},Ar(e,n)},Sr=function(){return Sr=Object.assign||function(n){for(var t,s=1,i=arguments.length;s<i;s++){t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Sr.apply(this,arguments)}}}),ki=Z({"node_modules/vnopts/lib/descriptors/api.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.apiDescriptor={key:n=>/^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(n)?n:JSON.stringify(n),value(n){if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return"[".concat(n.map(s=>e.apiDescriptor.value(s)).join(", "),"]");let t=Object.keys(n);return t.length===0?"{}":"{ ".concat(t.map(s=>"".concat(e.apiDescriptor.key(s),": ").concat(e.apiDescriptor.value(n[s]))).join(", ")," }")},pair:n=>{let{key:t,value:s}=n;return e.apiDescriptor.value({[t]:s})}}}}),jD=Z({"node_modules/vnopts/lib/descriptors/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(ki(),e)}}),Nr=Z({"scripts/build/shims/chalk.cjs"(e,n){"use strict";ae();var t=s=>s;t.grey=t,t.red=t,t.bold=t,t.yellow=t,t.blue=t,t.default=t,n.exports=t}}),Li=Z({"node_modules/vnopts/lib/handlers/deprecated/common.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=Nr();e.commonDeprecatedHandler=(t,s,i)=>{let{descriptor:r}=i,u=["".concat(n.default.yellow(typeof t=="string"?r.key(t):r.pair(t))," is deprecated")];return s&&u.push("we now treat it as ".concat(n.default.blue(typeof s=="string"?r.key(s):r.pair(s)))),u.join("; ")+"."}}}),qD=Z({"node_modules/vnopts/lib/handlers/deprecated/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(Li(),e)}}),MD=Z({"node_modules/vnopts/lib/handlers/invalid/common.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=Nr();e.commonInvalidHandler=(t,s,i)=>["Invalid ".concat(n.default.red(i.descriptor.key(t))," value."),"Expected ".concat(n.default.blue(i.schemas[t].expected(i)),","),"but received ".concat(n.default.red(i.descriptor.value(s)),".")].join(" ")}}),Oi=Z({"node_modules/vnopts/lib/handlers/invalid/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(MD(),e)}}),RD=Z({"node_modules/vnopts/node_modules/leven/index.js"(e,n){"use strict";ae();var t=[],s=[];n.exports=function(i,r){if(i===r)return 0;var u=i;i.length>r.length&&(i=r,r=u);var a=i.length,c=r.length;if(a===0)return c;if(c===0)return a;for(;a>0&&i.charCodeAt(~-a)===r.charCodeAt(~-c);)a--,c--;if(a===0)return c;for(var l=0;l<a&&i.charCodeAt(l)===r.charCodeAt(l);)l++;if(a-=l,c-=l,a===0)return c;for(var C,m,g,p,f=0,h=0;f<a;)s[l+f]=i.charCodeAt(l+f),t[f]=++f;for(;h<c;)for(C=r.charCodeAt(l+h),g=h++,m=h,f=0;f<a;f++)p=C===s[l+f]?g:g+1,g=t[f],m=t[f]=g>m?p>m?m+1:p:p>g?g+1:p;return m}}}),ji=Z({"node_modules/vnopts/lib/handlers/unknown/leven.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=Nr(),t=RD();e.levenUnknownHandler=(s,i,r)=>{let{descriptor:u,logger:a,schemas:c}=r,l=["Ignored unknown option ".concat(n.default.yellow(u.pair({key:s,value:i})),".")],C=Object.keys(c).sort().find(m=>t(s,m)<3);C&&l.push("Did you mean ".concat(n.default.blue(u.key(C)),"?")),a.warn(l.join(" "))}}}),VD=Z({"node_modules/vnopts/lib/handlers/unknown/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(ji(),e)}}),WD=Z({"node_modules/vnopts/lib/handlers/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(qD(),e),n.__exportStar(Oi(),e),n.__exportStar(VD(),e)}}),yt=Z({"node_modules/vnopts/lib/schema.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=["default","expected","validate","deprecated","forward","redirect","overlap","preprocess","postprocess"];function t(r,u){let a=new r(u),c=Object.create(a);for(let l of n)l in u&&(c[l]=i(u[l],a,s.prototype[l].length));return c}e.createSchema=t;var s=class{constructor(r){this.name=r.name}static create(r){return t(this,r)}default(r){}expected(r){return"nothing"}validate(r,u){return!1}deprecated(r,u){return!1}forward(r,u){}redirect(r,u){}overlap(r,u,a){return r}preprocess(r,u){return r}postprocess(r,u){return r}};e.Schema=s;function i(r,u,a){return typeof r=="function"?function(){for(var c=arguments.length,l=new Array(c),C=0;C<c;C++)l[C]=arguments[C];return r(...l.slice(0,a-1),u,...l.slice(a-1))}:()=>r}}}),$D=Z({"node_modules/vnopts/lib/schemas/alias.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=class extends n.Schema{constructor(s){super(s);this._sourceName=s.sourceName}expected(s){return s.schemas[this._sourceName].expected(s)}validate(s,i){return i.schemas[this._sourceName].validate(s,i)}redirect(s,i){return this._sourceName}};e.AliasSchema=t}}),HD=Z({"node_modules/vnopts/lib/schemas/any.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=class extends n.Schema{expected(){return"anything"}validate(){return!0}};e.AnySchema=t}}),GD=Z({"node_modules/vnopts/lib/schemas/array.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt)),t=yt(),s=class extends t.Schema{constructor(r){var{valueSchema:u,name:a=u.name}=r,c=n.__rest(r,["valueSchema","name"]);super(Object.assign({},c,{name:a}));this._valueSchema=u}expected(r){return"an array of ".concat(this._valueSchema.expected(r))}validate(r,u){if(!Array.isArray(r))return!1;let a=[];for(let c of r){let l=u.normalizeValidateResult(this._valueSchema.validate(c,u),c);l!==!0&&a.push(l.value)}return a.length===0?!0:{value:a}}deprecated(r,u){let a=[];for(let c of r){let l=u.normalizeDeprecatedResult(this._valueSchema.deprecated(c,u),c);l!==!1&&a.push(...l.map(C=>{let{value:m}=C;return{value:[m]}}))}return a}forward(r,u){let a=[];for(let c of r){let l=u.normalizeForwardResult(this._valueSchema.forward(c,u),c);a.push(...l.map(i))}return a}redirect(r,u){let a=[],c=[];for(let l of r){let C=u.normalizeRedirectResult(this._valueSchema.redirect(l,u),l);"remain"in C&&a.push(C.remain),c.push(...C.redirect.map(i))}return a.length===0?{redirect:c}:{redirect:c,remain:a}}overlap(r,u){return r.concat(u)}};e.ArraySchema=s;function i(r){let{from:u,to:a}=r;return{from:[u],to:a}}}}),JD=Z({"node_modules/vnopts/lib/schemas/boolean.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=class extends n.Schema{expected(){return"true or false"}validate(s){return typeof s=="boolean"}};e.BooleanSchema=t}}),Hn=Z({"node_modules/vnopts/lib/utils.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});function n(p,f){let h=Object.create(null);for(let N of p){let T=N[f];if(h[T])throw new Error("Duplicate ".concat(f," ").concat(JSON.stringify(T)));h[T]=N}return h}e.recordFromArray=n;function t(p,f){let h=new Map;for(let N of p){let T=N[f];if(h.has(T))throw new Error("Duplicate ".concat(f," ").concat(JSON.stringify(T)));h.set(T,N)}return h}e.mapFromArray=t;function s(){let p=Object.create(null);return f=>{let h=JSON.stringify(f);return p[h]?!0:(p[h]=!0,!1)}}e.createAutoChecklist=s;function i(p,f){let h=[],N=[];for(let T of p)f(T)?h.push(T):N.push(T);return[h,N]}e.partition=i;function r(p){return p===Math.floor(p)}e.isInt=r;function u(p,f){if(p===f)return 0;let h=typeof p,N=typeof f,T=["undefined","object","boolean","number","string"];return h!==N?T.indexOf(h)-T.indexOf(N):h!=="string"?Number(p)-Number(f):p.localeCompare(f)}e.comparePrimitive=u;function a(p){return p===void 0?{}:p}e.normalizeDefaultResult=a;function c(p,f){return p===!0?!0:p===!1?{value:f}:p}e.normalizeValidateResult=c;function l(p,f){let h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return p===!1?!1:p===!0?h?!0:[{value:f}]:"value"in p?[p]:p.length===0?!1:p}e.normalizeDeprecatedResult=l;function C(p,f){return typeof p=="string"||"key"in p?{from:f,to:p}:"from"in p?{from:p.from,to:p.to}:{from:f,to:p.to}}e.normalizeTransferResult=C;function m(p,f){return p===void 0?[]:Array.isArray(p)?p.map(h=>C(h,f)):[C(p,f)]}e.normalizeForwardResult=m;function g(p,f){let h=m(typeof p=="object"&&"redirect"in p?p.redirect:p,f);return h.length===0?{remain:f,redirect:h}:typeof p=="object"&&"remain"in p?{remain:p.remain,redirect:h}:{redirect:h}}e.normalizeRedirectResult=g}}),UD=Z({"node_modules/vnopts/lib/schemas/choice.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=Hn(),s=class extends n.Schema{constructor(i){super(i);this._choices=t.mapFromArray(i.choices.map(r=>r&&typeof r=="object"?r:{value:r}),"value")}expected(i){let{descriptor:r}=i,u=Array.from(this._choices.keys()).map(l=>this._choices.get(l)).filter(l=>!l.deprecated).map(l=>l.value).sort(t.comparePrimitive).map(r.value),a=u.slice(0,-2),c=u.slice(-2);return a.concat(c.join(" or ")).join(", ")}validate(i){return this._choices.has(i)}deprecated(i){let r=this._choices.get(i);return r&&r.deprecated?{value:i}:!1}forward(i){let r=this._choices.get(i);return r?r.forward:void 0}redirect(i){let r=this._choices.get(i);return r?r.redirect:void 0}};e.ChoiceSchema=s}}),qi=Z({"node_modules/vnopts/lib/schemas/number.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=class extends n.Schema{expected(){return"a number"}validate(s,i){return typeof s=="number"}};e.NumberSchema=t}}),zD=Z({"node_modules/vnopts/lib/schemas/integer.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=Hn(),t=qi(),s=class extends t.NumberSchema{expected(){return"an integer"}validate(i,r){return r.normalizeValidateResult(super.validate(i,r),i)===!0&&n.isInt(i)}};e.IntegerSchema=s}}),XD=Z({"node_modules/vnopts/lib/schemas/string.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=yt(),t=class extends n.Schema{expected(){return"a string"}validate(s){return typeof s=="string"}};e.StringSchema=t}}),KD=Z({"node_modules/vnopts/lib/schemas/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar($D(),e),n.__exportStar(HD(),e),n.__exportStar(GD(),e),n.__exportStar(JD(),e),n.__exportStar(UD(),e),n.__exportStar(zD(),e),n.__exportStar(qi(),e),n.__exportStar(XD(),e)}}),YD=Z({"node_modules/vnopts/lib/defaults.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=ki(),t=Li(),s=Oi(),i=ji();e.defaultDescriptor=n.apiDescriptor,e.defaultUnknownHandler=i.levenUnknownHandler,e.defaultInvalidHandler=s.commonInvalidHandler,e.defaultDeprecatedHandler=t.commonDeprecatedHandler}}),QD=Z({"node_modules/vnopts/lib/normalize.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=YD(),t=Hn();e.normalize=(i,r,u)=>new s(r,u).normalize(i);var s=class{constructor(i,r){let{logger:u=console,descriptor:a=n.defaultDescriptor,unknown:c=n.defaultUnknownHandler,invalid:l=n.defaultInvalidHandler,deprecated:C=n.defaultDeprecatedHandler}=r||{};this._utils={descriptor:a,logger:u||{warn:()=>{}},schemas:t.recordFromArray(i,"name"),normalizeDefaultResult:t.normalizeDefaultResult,normalizeDeprecatedResult:t.normalizeDeprecatedResult,normalizeForwardResult:t.normalizeForwardResult,normalizeRedirectResult:t.normalizeRedirectResult,normalizeValidateResult:t.normalizeValidateResult},this._unknownHandler=c,this._invalidHandler=l,this._deprecatedHandler=C,this.cleanHistory()}cleanHistory(){this._hasDeprecationWarned=t.createAutoChecklist()}normalize(i){let r={},u=[i],a=()=>{for(;u.length!==0;){let c=u.shift(),l=this._applyNormalization(c,r);u.push(...l)}};a();for(let c of Object.keys(this._utils.schemas)){let l=this._utils.schemas[c];if(!(c in r)){let C=t.normalizeDefaultResult(l.default(this._utils));"value"in C&&u.push({[c]:C.value})}}a();for(let c of Object.keys(this._utils.schemas)){let l=this._utils.schemas[c];c in r&&(r[c]=l.postprocess(r[c],this._utils))}return r}_applyNormalization(i,r){let u=[],[a,c]=t.partition(Object.keys(i),l=>l in this._utils.schemas);for(let l of a){let C=this._utils.schemas[l],m=C.preprocess(i[l],this._utils),g=t.normalizeValidateResult(C.validate(m,this._utils),m);if(g!==!0){let{value:T}=g,A=this._invalidHandler(l,T,this._utils);throw typeof A=="string"?new Error(A):A}let p=T=>{let{from:A,to:b}=T;u.push(typeof b=="string"?{[b]:A}:{[b.key]:b.value})},f=T=>{let{value:A,redirectTo:b}=T,v=t.normalizeDeprecatedResult(C.deprecated(A,this._utils),m,!0);if(v!==!1)if(v===!0)this._hasDeprecationWarned(l)||this._utils.logger.warn(this._deprecatedHandler(l,b,this._utils));else for(let{value:B}of v){let w={key:l,value:B};if(!this._hasDeprecationWarned(w)){let I=typeof b=="string"?{key:b,value:B}:b;this._utils.logger.warn(this._deprecatedHandler(w,I,this._utils))}}};t.normalizeForwardResult(C.forward(m,this._utils),m).forEach(p);let N=t.normalizeRedirectResult(C.redirect(m,this._utils),m);if(N.redirect.forEach(p),"remain"in N){let T=N.remain;r[l]=l in r?C.overlap(r[l],T,this._utils):T,f({value:T})}for(let{from:T,to:A}of N.redirect)f({value:T,redirectTo:A})}for(let l of c){let C=i[l],m=this._unknownHandler(l,C,this._utils);if(m)for(let g of Object.keys(m)){let p={[g]:m[g]};g in this._utils.schemas?u.push(p):Object.assign(r,p)}}return u}};e.Normalizer=s}}),ZD=Z({"node_modules/vnopts/lib/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=(gt(),pt(Dt));n.__exportStar(jD(),e),n.__exportStar(WD(),e),n.__exportStar(KD(),e),n.__exportStar(QD(),e),n.__exportStar(yt(),e)}}),em=Z({"src/main/options-normalizer.js"(e,n){"use strict";ae();var t=ZD(),s=st(),i={key:g=>g.length===1?"-".concat(g):"--".concat(g),value:g=>t.apiDescriptor.value(g),pair:g=>{let{key:p,value:f}=g;return f===!1?"--no-".concat(p):f===!0?i.key(p):f===""?"".concat(i.key(p)," without an argument"):"".concat(i.key(p),"=").concat(f)}},r=g=>{let{colorsModule:p,levenshteinDistance:f}=g;return class extends t.ChoiceSchema{constructor(N){let{name:T,flags:A}=N;super({name:T,choices:A});this._flags=[...A].sort()}preprocess(N,T){if(typeof N=="string"&&N.length>0&&!this._flags.includes(N)){let A=this._flags.find(b=>f(b,N)<3);if(A)return T.logger.warn(["Unknown flag ".concat(p.yellow(T.descriptor.value(N)),","),"did you mean ".concat(p.blue(T.descriptor.value(A)),"?")].join(" ")),A}return N}expected(){return"a flag"}}},u;function a(g,p){let{logger:f,isCLI:h=!1,passThrough:N=!1,colorsModule:T,levenshteinDistance:A}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},b=N?Array.isArray(N)?(D,d)=>N.includes(D)?{[D]:d}:void 0:(D,d)=>({[D]:d}):(D,d,y)=>{let o=y.schemas,{_:x}=o,F=_n(o,Xf);return t.levenUnknownHandler(D,d,Object.assign(Object.assign({},y),{},{schemas:F}))},v=h?i:t.apiDescriptor,B=c(p,{isCLI:h,colorsModule:T,levenshteinDistance:A}),w=new t.Normalizer(B,{logger:f,unknown:b,descriptor:v}),I=f!==!1;I&&u&&(w._hasDeprecationWarned=u);let E=w.normalize(g);return I&&(u=w._hasDeprecationWarned),h&&E["plugin-search"]===!1&&(E["plugin-search-dir"]=!1),E}function c(g,p){let{isCLI:f,colorsModule:h,levenshteinDistance:N}=p,T=[];f&&T.push(t.AnySchema.create({name:"_"}));for(let A of g)T.push(l(A,{isCLI:f,optionInfos:g,colorsModule:h,levenshteinDistance:N})),A.alias&&f&&T.push(t.AliasSchema.create({name:A.alias,sourceName:A.name}));return T}function l(g,p){let{isCLI:f,optionInfos:h,colorsModule:N,levenshteinDistance:T}=p,{name:A}=g;if(A==="plugin-search-dir"||A==="pluginSearchDirs")return t.AnySchema.create({name:A,preprocess(w){return w===!1||(w=Array.isArray(w)?w:[w]),w},validate(w){return w===!1?!0:w.every(I=>typeof I=="string")},expected(){return"false or paths to plugin search dir"}});let b={name:A},v,B={};switch(g.type){case"int":v=t.IntegerSchema,f&&(b.preprocess=w=>Number(w));break;case"string":v=t.StringSchema;break;case"choice":v=t.ChoiceSchema,b.choices=g.choices.map(w=>typeof w=="object"&&w.redirect?Object.assign(Object.assign({},w),{},{redirect:{to:{key:g.name,value:w.redirect}}}):w);break;case"boolean":v=t.BooleanSchema;break;case"flag":v=r({colorsModule:N,levenshteinDistance:T}),b.flags=h.flatMap(w=>[w.alias,w.description&&w.name,w.oppositeDescription&&"no-".concat(w.name)].filter(Boolean));break;case"path":v=t.StringSchema;break;default:throw new Error("Unexpected type ".concat(g.type))}if(g.exception?b.validate=(w,I,E)=>g.exception(w)||I.validate(w,E):b.validate=(w,I,E)=>w===void 0||I.validate(w,E),g.redirect&&(B.redirect=w=>w?{to:{key:g.redirect.option,value:g.redirect.value}}:void 0),g.deprecated&&(B.deprecated=!0),f&&!g.array){let w=b.preprocess||(I=>I);b.preprocess=(I,E,D)=>E.preprocess(w(Array.isArray(I)?s(I):I),D)}return g.array?t.ArraySchema.create(Object.assign(Object.assign(Object.assign({},f?{preprocess:w=>Array.isArray(w)?w:[w]}:{}),B),{},{valueSchema:v.create(b)})):v.create(Object.assign(Object.assign({},b),B))}function C(g,p,f){return a(g,p,f)}function m(g,p,f){return a(g,p,Object.assign({isCLI:!0},f))}n.exports={normalizeApiOptions:C,normalizeCliOptions:m}}}),nt=Z({"src/language-js/loc.js"(e,n){"use strict";ae();var t=Rn();function s(c,l){let{ignoreDecorators:C}=l||{};if(!C){let m=c.declaration&&c.declaration.decorators||c.decorators;if(t(m))return s(m[0])}return c.range?c.range[0]:c.start}function i(c){return c.range?c.range[1]:c.end}function r(c,l){let C=s(c);return Number.isInteger(C)&&C===s(l)}function u(c,l){let C=i(c);return Number.isInteger(C)&&C===i(l)}function a(c,l){return r(c,l)&&u(c,l)}n.exports={locStart:s,locEnd:i,hasSameLocStart:r,hasSameLoc:a}}}),tm=Z({"scripts/build/shims/babel-highlight.cjs"(e,n){"use strict";ae();var t=Nr(),s={shouldHighlight:()=>!1,getChalk:()=>t};n.exports=s}}),rm=Z({"node_modules/@babel/code-frame/lib/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.codeFrameColumns=u,e.default=a;var n=tm(),t=!1;function s(c){return{gutter:c.grey,marker:c.red.bold,message:c.red.bold}}var i=/\r\n|[\n\r\u2028\u2029]/;function r(c,l,C){let m=Object.assign({column:0,line:-1},c.start),g=Object.assign({},m,c.end),{linesAbove:p=2,linesBelow:f=3}=C||{},h=m.line,N=m.column,T=g.line,A=g.column,b=Math.max(h-(p+1),0),v=Math.min(l.length,T+f);h===-1&&(b=0),T===-1&&(v=l.length);let B=T-h,w={};if(B)for(let I=0;I<=B;I++){let E=I+h;if(!N)w[E]=!0;else if(I===0){let D=l[E-1].length;w[E]=[N,D-N+1]}else if(I===B)w[E]=[0,A];else{let D=l[E-I].length;w[E]=[0,D]}}else N===A?N?w[h]=[N,0]:w[h]=!0:w[h]=[N,A-N];return{start:b,end:v,markerLines:w}}function u(c,l){let C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},m=(C.highlightCode||C.forceColor)&&(0,n.shouldHighlight)(C),g=(0,n.getChalk)(C),p=s(g),f=(I,E)=>m?I(E):E,h=c.split(i),{start:N,end:T,markerLines:A}=r(l,h,C),b=l.start&&typeof l.start.column=="number",v=String(T).length,w=(m?(0,n.default)(c,C):c).split(i,T).slice(N,T).map((I,E)=>{let D=N+1+E,d=" ".concat(D).slice(-v),y=" ".concat(d," |"),o=A[D],x=!A[D+1];if(o){let F="";if(Array.isArray(o)){let S=I.slice(0,Math.max(o[0]-1,0)).replace(/[^\t]/g," "),k=o[1]||1;F=[` |
| | | `,f(p.gutter,y.replace(/\d/g," "))," ",S,f(p.marker,"^").repeat(k)].join(""),x&&C.message&&(F+=" "+f(p.message,C.message))}return[f(p.marker,">"),f(p.gutter,y),I.length>0?" ".concat(I):"",F].join("")}else return" ".concat(f(p.gutter,y)).concat(I.length>0?" ".concat(I):"")}).join(` |
| | | `);return C.message&&!b&&(w="".concat(" ".repeat(v+1)).concat(C.message,` |
| | | `).concat(w)),m?g.reset(w):w}function a(c,l,C){let m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};if(!t){t=!0;let p="Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";if(xt.emitWarning)xt.emitWarning(p,"DeprecationWarning");else{let f=new Error(p);f.name="DeprecationWarning",console.warn(new Error(p))}}return C=Math.max(C,0),u(c,{start:{column:C,line:l}},m)}}}),Gn=Z({"src/main/parser.js"(e,n){"use strict";ae();var t=Pi(),{ConfigError:s}=Jt(),i=nt(),{locStart:r,locEnd:u}=i,a=Object.getOwnPropertyNames,c=Object.getOwnPropertyDescriptor;function l(g){let p={};for(let f of g.plugins)if(!!f.parsers)for(let h of a(f.parsers))Object.defineProperty(p,h,c(f.parsers,h));return p}function C(g){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l(g);if(typeof g.parser=="function")return{parse:g.parser,astFormat:"estree",locStart:r,locEnd:u};if(typeof g.parser=="string"){if(Object.prototype.hasOwnProperty.call(p,g.parser))return p[g.parser];throw new s(`Couldn't resolve parser "`.concat(g.parser,'". Parsers must be explicitly added to the standalone bundle.'))}}function m(g,p){let f=l(p),h=Object.defineProperties({},Object.fromEntries(Object.keys(f).map(T=>[T,{enumerable:!0,get(){return f[T].parse}}]))),N=C(p,f);try{return N.preprocess&&(g=N.preprocess(g,p)),{text:g,ast:N.parse(g,h,p)}}catch(T){let{loc:A}=T;if(A){let{codeFrameColumns:b}=rm();throw T.codeFrame=b(g,A,{highlightCode:!0}),T.message+=` |
| | | `+T.codeFrame,T}throw T.stack}}n.exports={parse:m,resolveParser:C}}}),Mi=Z({"src/main/options.js"(e,n){"use strict";ae();var t=Pi(),{UndefinedParserError:s}=Jt(),{getSupportInfo:i}=Mn(),r=em(),{resolveParser:u}=Gn(),a={astFormat:"estree",printer:{},originalText:void 0,locStart:null,locEnd:null};function c(m){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=Object.assign({},m),f=i({plugins:m.plugins,showUnreleased:!0,showDeprecated:!0}).options,h=Object.assign(Object.assign({},a),Object.fromEntries(f.filter(v=>v.default!==void 0).map(v=>[v.name,v.default])));if(!p.parser){if(!p.filepath)(g.logger||console).warn("No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred."),p.parser="babel";else if(p.parser=C(p.filepath,p.plugins),!p.parser)throw new s("No parser could be inferred for file: ".concat(p.filepath))}let N=u(r.normalizeApiOptions(p,[f.find(v=>v.name==="parser")],{passThrough:!0,logger:!1}));p.astFormat=N.astFormat,p.locEnd=N.locEnd,p.locStart=N.locStart;let T=l(p);p.printer=T.printers[p.astFormat];let A=Object.fromEntries(f.filter(v=>v.pluginDefaults&&v.pluginDefaults[T.name]!==void 0).map(v=>[v.name,v.pluginDefaults[T.name]])),b=Object.assign(Object.assign({},h),A);for(let[v,B]of Object.entries(b))(p[v]===null||p[v]===void 0)&&(p[v]=B);return p.parser==="json"&&(p.trailingComma="none"),r.normalizeApiOptions(p,f,Object.assign({passThrough:Object.keys(a)},g))}function l(m){let{astFormat:g}=m;if(!g)throw new Error("getPlugin() requires astFormat to be set");let p=m.plugins.find(f=>f.printers&&f.printers[g]);if(!p)throw new Error(`Couldn't find plugin for AST format "`.concat(g,'"'));return p}function C(m,g){let p=t.basename(m).toLowerCase(),h=i({plugins:g}).languages.filter(N=>N.since!==null).find(N=>N.extensions&&N.extensions.some(T=>p.endsWith(T))||N.filenames&&N.filenames.some(T=>T.toLowerCase()===p));return h&&h.parsers[0]}n.exports={normalize:c,hiddenDefaults:a,inferParser:C}}}),nm=Z({"src/main/massage-ast.js"(e,n){"use strict";ae();function t(s,i,r){if(Array.isArray(s))return s.map(l=>t(l,i,r)).filter(Boolean);if(!s||typeof s!="object")return s;let u=i.printer.massageAstNode,a;u&&u.ignoredProperties?a=u.ignoredProperties:a=new Set;let c={};for(let[l,C]of Object.entries(s))!a.has(l)&&typeof C!="function"&&(c[l]=t(C,i,s));if(u){let l=u(s,c,r);if(l===null)return;if(l)return l}return c}n.exports=t}}),Ut=Z({"scripts/build/shims/assert.cjs"(e,n){"use strict";ae();var t=()=>{};t.ok=t,t.strictEqual=t,n.exports=t}}),Qe=Z({"src/main/comments.js"(e,n){"use strict";ae();var t=Ut(),{builders:{line:s,hardline:i,breakParent:r,indent:u,lineSuffix:a,join:c,cursor:l}}=Le(),{hasNewline:C,skipNewline:m,skipSpaces:g,isPreviousLineEmpty:p,addLeadingComment:f,addDanglingComment:h,addTrailingComment:N}=Ge(),T=new WeakMap;function A(O,R,M){if(!O)return;let{printer:H,locStart:P,locEnd:G}=R;if(M){if(H.canAttachComment&&H.canAttachComment(O)){let $;for($=M.length-1;$>=0&&!(P(M[$])<=P(O)&&G(M[$])<=G(O));--$);M.splice($+1,0,O);return}}else if(T.has(O))return T.get(O);let re=H.getCommentChildNodes&&H.getCommentChildNodes(O,R)||typeof O=="object"&&Object.entries(O).filter($=>{let[W]=$;return W!=="enclosingNode"&&W!=="precedingNode"&&W!=="followingNode"&&W!=="tokens"&&W!=="comments"&&W!=="parent"}).map($=>{let[,W]=$;return W});if(!!re){M||(M=[],T.set(O,M));for(let $ of re)A($,R,M);return M}}function b(O,R,M,H){let{locStart:P,locEnd:G}=M,re=P(R),$=G(R),W=A(O,M),ee,U,ne=0,se=W.length;for(;ne<se;){let V=ne+se>>1,oe=W[V],K=P(oe),Ee=G(oe);if(K<=re&&$<=Ee)return b(oe,R,M,oe);if(Ee<=re){ee=oe,ne=V+1;continue}if($<=K){U=oe,se=V;continue}throw new Error("Comment location overlaps with node location")}if(H&&H.type==="TemplateLiteral"){let{quasis:V}=H,oe=y(V,R,M);ee&&y(V,ee,M)!==oe&&(ee=null),U&&y(V,U,M)!==oe&&(U=null)}return{enclosingNode:H,precedingNode:ee,followingNode:U}}var v=()=>!1;function B(O,R,M,H){if(!Array.isArray(O))return;let P=[],{locStart:G,locEnd:re,printer:{handleComments:$={}}}=H,{avoidAstMutation:W,ownLine:ee=v,endOfLine:U=v,remaining:ne=v}=$,se=O.map((V,oe)=>Object.assign(Object.assign({},b(R,V,H)),{},{comment:V,text:M,options:H,ast:R,isLastComment:O.length-1===oe}));for(let[V,oe]of se.entries()){let{comment:K,precedingNode:Ee,enclosingNode:q,followingNode:le,text:ue,options:Q,ast:de,isLastComment:ge}=oe;if(Q.parser==="json"||Q.parser==="json5"||Q.parser==="__js_expression"||Q.parser==="__vue_expression"){if(G(K)-G(de)<=0){f(de,K);continue}if(re(K)-re(de)>=0){N(de,K);continue}}let ve;if(W?ve=[oe]:(K.enclosingNode=q,K.precedingNode=Ee,K.followingNode=le,ve=[K,ue,Q,de,ge]),I(ue,Q,se,V))K.placement="ownLine",ee(...ve)||(le?f(le,K):Ee?N(Ee,K):h(q||de,K));else if(E(ue,Q,se,V))K.placement="endOfLine",U(...ve)||(Ee?N(Ee,K):le?f(le,K):h(q||de,K));else if(K.placement="remaining",!ne(...ve))if(Ee&&le){let xe=P.length;xe>0&&P[xe-1].followingNode!==le&&D(P,ue,Q),P.push(oe)}else Ee?N(Ee,K):le?f(le,K):h(q||de,K)}if(D(P,M,H),!W)for(let V of O)delete V.precedingNode,delete V.enclosingNode,delete V.followingNode}var w=O=>!/[\S\n\u2028\u2029]/.test(O);function I(O,R,M,H){let{comment:P,precedingNode:G}=M[H],{locStart:re,locEnd:$}=R,W=re(P);if(G)for(let ee=H-1;ee>=0;ee--){let{comment:U,precedingNode:ne}=M[ee];if(ne!==G||!w(O.slice($(U),W)))break;W=re(U)}return C(O,W,{backwards:!0})}function E(O,R,M,H){let{comment:P,followingNode:G}=M[H],{locStart:re,locEnd:$}=R,W=$(P);if(G)for(let ee=H+1;ee<M.length;ee++){let{comment:U,followingNode:ne}=M[ee];if(ne!==G||!w(O.slice(W,re(U))))break;W=$(U)}return C(O,W)}function D(O,R,M){let H=O.length;if(H===0)return;let{precedingNode:P,followingNode:G,enclosingNode:re}=O[0],$=M.printer.getGapRegex&&M.printer.getGapRegex(re)||/^[\s(]*$/,W=M.locStart(G),ee;for(ee=H;ee>0;--ee){let{comment:U,precedingNode:ne,followingNode:se}=O[ee-1];t.strictEqual(ne,P),t.strictEqual(se,G);let V=R.slice(M.locEnd(U),W);if($.test(V))W=M.locStart(U);else break}for(let[U,{comment:ne}]of O.entries())U<ee?N(P,ne):f(G,ne);for(let U of[P,G])U.comments&&U.comments.length>1&&U.comments.sort((ne,se)=>M.locStart(ne)-M.locStart(se));O.length=0}function d(O,R){let M=O.getValue();return M.printed=!0,R.printer.printComment(O,R)}function y(O,R,M){let H=M.locStart(R)-1;for(let P=1;P<O.length;++P)if(H<M.locStart(O[P]))return P-1;return 0}function o(O,R){let M=O.getValue(),H=[d(O,R)],{printer:P,originalText:G,locStart:re,locEnd:$}=R;if(P.isBlockComment&&P.isBlockComment(M)){let U=C(G,$(M))?C(G,re(M),{backwards:!0})?i:s:" ";H.push(U)}else H.push(i);let ee=m(G,g(G,$(M)));return ee!==!1&&C(G,ee)&&H.push(i),H}function x(O,R){let M=O.getValue(),H=d(O,R),{printer:P,originalText:G,locStart:re}=R,$=P.isBlockComment&&P.isBlockComment(M);if(C(G,re(M),{backwards:!0})){let ee=p(G,M,re);return a([i,ee?i:"",H])}let W=[" ",H];return $||(W=[a(W),r]),W}function F(O,R,M,H){let P=[],G=O.getValue();return!G||!G.comments||(O.each(()=>{let re=O.getValue();!re.leading&&!re.trailing&&(!H||H(re))&&P.push(d(O,R))},"comments"),P.length===0)?"":M?c(i,P):u([i,c(i,P)])}function S(O,R,M){let H=O.getValue();if(!H)return{};let P=H.comments||[];M&&(P=P.filter(W=>!M.has(W)));let G=H===R.cursorNode;if(P.length===0){let W=G?l:"";return{leading:W,trailing:W}}let re=[],$=[];return O.each(()=>{let W=O.getValue();if(M&&M.has(W))return;let{leading:ee,trailing:U}=W;ee?re.push(o(O,R)):U&&$.push(x(O,R))},"comments"),G&&(re.unshift(l),$.push(l)),{leading:re,trailing:$}}function k(O,R,M,H){let{leading:P,trailing:G}=S(O,M,H);return!P&&!G?R:[P,R,G]}function _(O){if(!!O)for(let R of O){if(!R.printed)throw new Error('Comment "'+R.value.trim()+'" was not printed. Please report this error!');delete R.printed}}n.exports={attach:B,printComments:k,printCommentsSeparately:S,printDanglingComments:F,getSortedChildNodes:A,ensureAllCommentsPrinted:_}}}),um=Z({"src/common/ast-path.js"(e,n){"use strict";ae();var t=st();function s(u,a){let c=i(u.stack,a);return c===-1?null:u.stack[c]}function i(u,a){for(let c=u.length-1;c>=0;c-=2){let l=u[c];if(l&&!Array.isArray(l)&&--a<0)return c}return-1}var r=class{constructor(u){this.stack=[u]}getName(){let{stack:u}=this,{length:a}=u;return a>1?u[a-2]:null}getValue(){return t(this.stack)}getNode(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return s(this,u)}getParentNode(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return s(this,u+1)}call(u){let{stack:a}=this,{length:c}=a,l=t(a);for(var C=arguments.length,m=new Array(C>1?C-1:0),g=1;g<C;g++)m[g-1]=arguments[g];for(let f of m)l=l[f],a.push(f,l);let p=u(this);return a.length=c,p}callParent(u){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,c=i(this.stack,a+1),l=this.stack.splice(c+1),C=u(this);return this.stack.push(...l),C}each(u){let{stack:a}=this,{length:c}=a,l=t(a);for(var C=arguments.length,m=new Array(C>1?C-1:0),g=1;g<C;g++)m[g-1]=arguments[g];for(let p of m)l=l[p],a.push(p,l);for(let p=0;p<l.length;++p)a.push(p,l[p]),u(this,p,l),a.length-=2;a.length=c}map(u){let a=[];for(var c=arguments.length,l=new Array(c>1?c-1:0),C=1;C<c;C++)l[C-1]=arguments[C];return this.each((m,g,p)=>{a[g]=u(m,g,p)},...l),a}try(u){let{stack:a}=this,c=[...a];try{return u()}finally{a.length=0,a.push(...c)}}match(){let u=this.stack.length-1,a=null,c=this.stack[u--];for(var l=arguments.length,C=new Array(l),m=0;m<l;m++)C[m]=arguments[m];for(let g of C){if(c===void 0)return!1;let p=null;if(typeof a=="number"&&(p=a,a=this.stack[u--],c=this.stack[u--]),g&&!g(c,a,p))return!1;a=this.stack[u--],c=this.stack[u--]}return!0}findAncestor(u){let a=this.stack.length-1,c=null,l=this.stack[a--];for(;l;){let C=null;if(typeof c=="number"&&(C=c,c=this.stack[a--],l=this.stack[a--]),c!==null&&u(l,c,C))return l;c=this.stack[a--],l=this.stack[a--]}}};n.exports=r}}),sm=Z({"src/main/multiparser.js"(e,n){"use strict";ae();var{utils:{stripTrailingHardline:t}}=Le(),{normalize:s}=Mi(),i=Qe();function r(a,c,l,C){if(l.printer.embed&&l.embeddedLanguageFormatting==="auto")return l.printer.embed(a,c,(m,g,p)=>u(m,g,l,C,p),l)}function u(a,c,l,C){let{stripTrailingHardline:m=!1}=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},g=s(Object.assign(Object.assign(Object.assign({},l),c),{},{parentParser:l.parser,originalText:a}),{passThrough:!0}),p=Gn().parse(a,g),{ast:f}=p;a=p.text;let h=f.comments;delete f.comments,i.attach(h,f,a,g),g[Symbol.for("comments")]=h||[],g[Symbol.for("tokens")]=f.tokens||[];let N=C(f,g);return i.ensureAllCommentsPrinted(h),m?typeof N=="string"?N.replace(/(?:\r?\n)*$/,""):t(N):N}n.exports={printSubtree:r}}}),am=Z({"src/main/ast-to-doc.js"(e,n){"use strict";ae();var t=um(),{builders:{hardline:s,addAlignmentToDoc:i},utils:{propagateBreaks:r}}=Le(),{printComments:u}=Qe(),a=sm();function c(m,g){let p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,{printer:f}=g;f.preprocess&&(m=f.preprocess(m,g));let h=new Map,N=new t(m),T=A();return p>0&&(T=i([s,T],p,g.tabWidth)),r(T),T;function A(v,B){return v===void 0||v===N?b(B):Array.isArray(v)?N.call(()=>b(B),...v):N.call(()=>b(B),v)}function b(v){let B=N.getValue(),w=B&&typeof B=="object"&&v===void 0;if(w&&h.has(B))return h.get(B);let I=C(N,g,A,v);return w&&h.set(B,I),I}}function l(m,g){let{originalText:p,[Symbol.for("comments")]:f,locStart:h,locEnd:N}=g,T=h(m),A=N(m),b=new Set;for(let v of f)h(v)>=T&&N(v)<=A&&(v.printed=!0,b.add(v));return{doc:p.slice(T,A),printedComments:b}}function C(m,g,p,f){let h=m.getValue(),{printer:N}=g,T,A;if(N.hasPrettierIgnore&&N.hasPrettierIgnore(m))({doc:T,printedComments:A}=l(h,g));else{if(h)try{T=a.printSubtree(m,p,g,c)}catch(b){if(globalThis.PRETTIER_DEBUG)throw b}T||(T=N.print(m,g,p,f))}return(!N.willPrintOwnComments||!N.willPrintOwnComments(m,g))&&(T=u(m,T,g,A)),T}n.exports=c}}),im=Z({"src/main/range-util.js"(e,n){"use strict";ae();var t=Ut(),s=Qe(),i=f=>{let{parser:h}=f;return h==="json"||h==="json5"||h==="json-stringify"};function r(f,h){let N=[f.node,...f.parentNodes],T=new Set([h.node,...h.parentNodes]);return N.find(A=>C.has(A.type)&&T.has(A))}function u(f){let h=f.length-1;for(;;){let N=f[h];if(N&&(N.type==="Program"||N.type==="File"))h--;else break}return f.slice(0,h+1)}function a(f,h,N){let{locStart:T,locEnd:A}=N,b=f.node,v=h.node;if(b===v)return{startNode:b,endNode:v};let B=T(f.node);for(let I of u(h.parentNodes))if(T(I)>=B)v=I;else break;let w=A(h.node);for(let I of u(f.parentNodes))if(A(I)<=w)b=I;else break;return{startNode:b,endNode:v}}function c(f,h,N,T){let A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:[],b=arguments.length>5?arguments[5]:void 0,{locStart:v,locEnd:B}=N,w=v(f),I=B(f);if(!(h>I||h<w||b==="rangeEnd"&&h===w||b==="rangeStart"&&h===I)){for(let E of s.getSortedChildNodes(f,N)){let D=c(E,h,N,T,[f,...A],b);if(D)return D}if(!T||T(f,A[0]))return{node:f,parentNodes:A}}}function l(f,h){return h!=="DeclareExportDeclaration"&&f!=="TypeParameterDeclaration"&&(f==="Directive"||f==="TypeAlias"||f==="TSExportAssignment"||f.startsWith("Declare")||f.startsWith("TSDeclare")||f.endsWith("Statement")||f.endsWith("Declaration"))}var C=new Set(["ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),m=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function g(f,h,N){if(!h)return!1;switch(f.parser){case"flow":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"__babel_estree":return l(h.type,N&&N.type);case"json":case"json5":case"json-stringify":return C.has(h.type);case"graphql":return m.has(h.kind);case"vue":return h.tag!=="root"}return!1}function p(f,h,N){let{rangeStart:T,rangeEnd:A,locStart:b,locEnd:v}=h;t.ok(A>T);let B=f.slice(T,A).search(/\S/),w=B===-1;if(!w)for(T+=B;A>T&&!/\S/.test(f[A-1]);--A);let I=c(N,T,h,(y,o)=>g(h,y,o),[],"rangeStart"),E=w?I:c(N,A,h,y=>g(h,y),[],"rangeEnd");if(!I||!E)return{rangeStart:0,rangeEnd:0};let D,d;if(i(h)){let y=r(I,E);D=y,d=y}else({startNode:D,endNode:d}=a(I,E,h));return{rangeStart:Math.min(b(D),b(d)),rangeEnd:Math.max(v(D),v(d))}}n.exports={calculateRange:p,findNodeAtOffset:c}}}),om=Z({"src/main/core.js"(e,n){"use strict";ae();var{diffArrays:t}=rD(),{printer:{printDocToString:s},debug:{printDocToDebug:i}}=Le(),{getAlignmentSize:r}=Ge(),{guessEndOfLine:u,convertEndOfLineToChars:a,countEndOfLineChars:c,normalizeEndOfLine:l}=On(),C=Mi().normalize,m=nm(),g=Qe(),p=Gn(),f=am(),h=im(),N="\uFEFF",T=Symbol("cursor");function A(d,y,o){let x=y.comments;return x&&(delete y.comments,g.attach(x,y,d,o)),o[Symbol.for("comments")]=x||[],o[Symbol.for("tokens")]=y.tokens||[],o.originalText=d,x}function b(d,y){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!d||d.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:x,text:F}=p.parse(d,y);if(y.cursorOffset>=0){let O=h.findNodeAtOffset(x,y.cursorOffset,y);O&&O.node&&(y.cursorNode=O.node)}let S=A(F,x,y),k=f(x,y,o),_=s(k,y);if(g.ensureAllCommentsPrinted(S),o>0){let O=_.formatted.trim();_.cursorNodeStart!==void 0&&(_.cursorNodeStart-=_.formatted.indexOf(O)),_.formatted=O+a(y.endOfLine)}if(y.cursorOffset>=0){let O,R,M,H,P;if(y.cursorNode&&_.cursorNodeText?(O=y.locStart(y.cursorNode),R=F.slice(O,y.locEnd(y.cursorNode)),M=y.cursorOffset-O,H=_.cursorNodeStart,P=_.cursorNodeText):(O=0,R=F,M=y.cursorOffset,H=0,P=_.formatted),R===P)return{formatted:_.formatted,cursorOffset:H+M,comments:S};let G=[...R];G.splice(M,0,T);let re=[...P],$=t(G,re),W=H;for(let ee of $)if(ee.removed){if(ee.value.includes(T))break}else W+=ee.count;return{formatted:_.formatted,cursorOffset:W,comments:S}}return{formatted:_.formatted,cursorOffset:-1,comments:S}}function v(d,y){let{ast:o,text:x}=p.parse(d,y),{rangeStart:F,rangeEnd:S}=h.calculateRange(x,y,o),k=x.slice(F,S),_=Math.min(F,x.lastIndexOf(` |
| | | `,F)+1),O=x.slice(_,F).match(/^\s*/)[0],R=r(O,y.tabWidth),M=b(k,Object.assign(Object.assign({},y),{},{rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:y.cursorOffset>F&&y.cursorOffset<=S?y.cursorOffset-F:-1,endOfLine:"lf"}),R),H=M.formatted.trimEnd(),{cursorOffset:P}=y;P>S?P+=H.length-k.length:M.cursorOffset>=0&&(P=M.cursorOffset+F);let G=x.slice(0,F)+H+x.slice(S);if(y.endOfLine!=="lf"){let re=a(y.endOfLine);P>=0&&re===`\r |
| | | `&&(P+=c(G.slice(0,P),` |
| | | `)),G=G.replace(/\n/g,re)}return{formatted:G,cursorOffset:P,comments:M.comments}}function B(d,y,o){return typeof y!="number"||Number.isNaN(y)||y<0||y>d.length?o:y}function w(d,y){let{cursorOffset:o,rangeStart:x,rangeEnd:F}=y;return o=B(d,o,-1),x=B(d,x,0),F=B(d,F,d.length),Object.assign(Object.assign({},y),{},{cursorOffset:o,rangeStart:x,rangeEnd:F})}function I(d,y){let{cursorOffset:o,rangeStart:x,rangeEnd:F,endOfLine:S}=w(d,y),k=d.charAt(0)===N;if(k&&(d=d.slice(1),o--,x--,F--),S==="auto"&&(S=u(d)),d.includes("\r")){let _=O=>c(d.slice(0,Math.max(O,0)),`\r |
| | | `);o-=_(o),x-=_(x),F-=_(F),d=l(d)}return{hasBOM:k,text:d,options:w(d,Object.assign(Object.assign({},y),{},{cursorOffset:o,rangeStart:x,rangeEnd:F,endOfLine:S}))}}function E(d,y){let o=p.resolveParser(y);return!o.hasPragma||o.hasPragma(d)}function D(d,y){let{hasBOM:o,text:x,options:F}=I(d,C(y));if(F.rangeStart>=F.rangeEnd&&x!==""||F.requirePragma&&!E(x,F))return{formatted:d,cursorOffset:y.cursorOffset,comments:[]};let S;return F.rangeStart>0||F.rangeEnd<x.length?S=v(x,F):(!F.requirePragma&&F.insertPragma&&F.printer.insertPragma&&!E(x,F)&&(x=F.printer.insertPragma(x)),S=b(x,F)),o&&(S.formatted=N+S.formatted,S.cursorOffset>=0&&S.cursorOffset++),S}n.exports={formatWithCursor:D,parse(d,y,o){let{text:x,options:F}=I(d,C(y)),S=p.parse(x,F);return o&&(S.ast=m(S.ast,F)),S},formatAST(d,y){y=C(y);let o=f(d,y);return s(o,y)},formatDoc(d,y){return D(i(d),Object.assign(Object.assign({},y),{},{parser:"__js_expression"})).formatted},printToDoc(d,y){y=C(y);let{ast:o,text:x}=p.parse(d,y);return A(x,o,y),f(o,y)},printDocToString(d,y){return s(d,C(y))}}}}),cm=Z({"src/common/util-shared.js"(e,n){"use strict";ae();var{getMaxContinuousCount:t,getStringWidth:s,getAlignmentSize:i,getIndentSize:r,skip:u,skipWhitespace:a,skipSpaces:c,skipNewline:l,skipToLineEnd:C,skipEverythingButNewLine:m,skipInlineComment:g,skipTrailingComment:p,hasNewline:f,hasNewlineInRange:h,hasSpaces:N,isNextLineEmpty:T,isNextLineEmptyAfterIndex:A,isPreviousLineEmpty:b,getNextNonSpaceNonCommentCharacterIndex:v,makeString:B,addLeadingComment:w,addDanglingComment:I,addTrailingComment:E}=Ge();n.exports={getMaxContinuousCount:t,getStringWidth:s,getAlignmentSize:i,getIndentSize:r,skip:u,skipWhitespace:a,skipSpaces:c,skipNewline:l,skipToLineEnd:C,skipEverythingButNewLine:m,skipInlineComment:g,skipTrailingComment:p,hasNewline:f,hasNewlineInRange:h,hasSpaces:N,isNextLineEmpty:T,isNextLineEmptyAfterIndex:A,isPreviousLineEmpty:b,getNextNonSpaceNonCommentCharacterIndex:v,makeString:B,addLeadingComment:w,addDanglingComment:I,addTrailingComment:E}}}),bt=Z({"src/utils/create-language.js"(e,n){"use strict";ae(),n.exports=function(t,s){let{languageId:i}=t,r=_n(t,Kf);return Object.assign(Object.assign({linguistLanguageId:i},r),s(t))}}}),lm=Z({"node_modules/esutils/lib/ast.js"(e,n){ae(),function(){"use strict";function t(c){if(c==null)return!1;switch(c.type){case"ArrayExpression":case"AssignmentExpression":case"BinaryExpression":case"CallExpression":case"ConditionalExpression":case"FunctionExpression":case"Identifier":case"Literal":case"LogicalExpression":case"MemberExpression":case"NewExpression":case"ObjectExpression":case"SequenceExpression":case"ThisExpression":case"UnaryExpression":case"UpdateExpression":return!0}return!1}function s(c){if(c==null)return!1;switch(c.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1}function i(c){if(c==null)return!1;switch(c.type){case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExpressionStatement":case"ForInStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"VariableDeclaration":case"WhileStatement":case"WithStatement":return!0}return!1}function r(c){return i(c)||c!=null&&c.type==="FunctionDeclaration"}function u(c){switch(c.type){case"IfStatement":return c.alternate!=null?c.alternate:c.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return c.body}return null}function a(c){var l;if(c.type!=="IfStatement"||c.alternate==null)return!1;l=c.consequent;do{if(l.type==="IfStatement"&&l.alternate==null)return!0;l=u(l)}while(l);return!1}n.exports={isExpression:t,isStatement:i,isIterationStatement:s,isSourceElement:r,isProblematicIfStatement:a,trailingStatement:u}}()}}),Ri=Z({"node_modules/esutils/lib/code.js"(e,n){ae(),function(){"use strict";var t,s,i,r,u,a;s={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,NonAsciiIdentifierPart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/},t={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};function c(A){return 48<=A&&A<=57}function l(A){return 48<=A&&A<=57||97<=A&&A<=102||65<=A&&A<=70}function C(A){return A>=48&&A<=55}i=[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function m(A){return A===32||A===9||A===11||A===12||A===160||A>=5760&&i.indexOf(A)>=0}function g(A){return A===10||A===13||A===8232||A===8233}function p(A){if(A<=65535)return String.fromCharCode(A);var b=String.fromCharCode(Math.floor((A-65536)/1024)+55296),v=String.fromCharCode((A-65536)%1024+56320);return b+v}for(r=new Array(128),a=0;a<128;++a)r[a]=a>=97&&a<=122||a>=65&&a<=90||a===36||a===95;for(u=new Array(128),a=0;a<128;++a)u[a]=a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57||a===36||a===95;function f(A){return A<128?r[A]:s.NonAsciiIdentifierStart.test(p(A))}function h(A){return A<128?u[A]:s.NonAsciiIdentifierPart.test(p(A))}function N(A){return A<128?r[A]:t.NonAsciiIdentifierStart.test(p(A))}function T(A){return A<128?u[A]:t.NonAsciiIdentifierPart.test(p(A))}n.exports={isDecimalDigit:c,isHexDigit:l,isOctalDigit:C,isWhiteSpace:m,isLineTerminator:g,isIdentifierStartES5:f,isIdentifierPartES5:h,isIdentifierStartES6:N,isIdentifierPartES6:T}}()}}),pm=Z({"node_modules/esutils/lib/keyword.js"(e,n){ae(),function(){"use strict";var t=Ri();function s(f){switch(f){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"let":return!0;default:return!1}}function i(f,h){return!h&&f==="yield"?!1:r(f,h)}function r(f,h){if(h&&s(f))return!0;switch(f.length){case 2:return f==="if"||f==="in"||f==="do";case 3:return f==="var"||f==="for"||f==="new"||f==="try";case 4:return f==="this"||f==="else"||f==="case"||f==="void"||f==="with"||f==="enum";case 5:return f==="while"||f==="break"||f==="catch"||f==="throw"||f==="const"||f==="yield"||f==="class"||f==="super";case 6:return f==="return"||f==="typeof"||f==="delete"||f==="switch"||f==="export"||f==="import";case 7:return f==="default"||f==="finally"||f==="extends";case 8:return f==="function"||f==="continue"||f==="debugger";case 10:return f==="instanceof";default:return!1}}function u(f,h){return f==="null"||f==="true"||f==="false"||i(f,h)}function a(f,h){return f==="null"||f==="true"||f==="false"||r(f,h)}function c(f){return f==="eval"||f==="arguments"}function l(f){var h,N,T;if(f.length===0||(T=f.charCodeAt(0),!t.isIdentifierStartES5(T)))return!1;for(h=1,N=f.length;h<N;++h)if(T=f.charCodeAt(h),!t.isIdentifierPartES5(T))return!1;return!0}function C(f,h){return(f-55296)*1024+(h-56320)+65536}function m(f){var h,N,T,A,b;if(f.length===0)return!1;for(b=t.isIdentifierStartES6,h=0,N=f.length;h<N;++h){if(T=f.charCodeAt(h),55296<=T&&T<=56319){if(++h,h>=N||(A=f.charCodeAt(h),!(56320<=A&&A<=57343)))return!1;T=C(T,A)}if(!b(T))return!1;b=t.isIdentifierPartES6}return!0}function g(f,h){return l(f)&&!u(f,h)}function p(f,h){return m(f)&&!a(f,h)}n.exports={isKeywordES5:i,isKeywordES6:r,isReservedWordES5:u,isReservedWordES6:a,isRestrictedWord:c,isIdentifierNameES5:l,isIdentifierNameES6:m,isIdentifierES5:g,isIdentifierES6:p}}()}}),fm=Z({"node_modules/esutils/lib/utils.js"(e){ae(),function(){"use strict";e.ast=lm(),e.code=Ri(),e.keyword=pm()}()}}),Pt=Z({"src/language-js/utils/is-block-comment.js"(e,n){"use strict";ae();function t(s){return s.type==="Block"||s.type==="CommentBlock"||s.type==="MultiLine"}n.exports=t}}),Xe=Z({"src/language-js/utils/index.js"(e,n){"use strict";ae();var t=fm().keyword.isIdentifierNameES5,{getLast:s,hasNewline:i,skipWhitespace:r,isNonEmptyArray:u,isNextLineEmptyAfterIndex:a,getStringWidth:c}=Ge(),{locStart:l,locEnd:C,hasSameLocStart:m}=nt(),g=Pt(),p="(?:(?=.)\\s)",f=new RegExp("^".concat(p,"*:")),h=new RegExp("^".concat(p,"*::"));function N(L){return L.extra&&L.extra.parenthesized&&u(L.trailingComments)&&g(L.trailingComments[0])&&f.test(L.trailingComments[0].value)}function T(L){return u(L)&&g(L[0])&&h.test(L[0].value)}function A(L,De){if(!L||typeof L!="object")return!1;if(Array.isArray(L))return L.some(We=>A(We,De));let ke=De(L);return typeof ke=="boolean"?ke:Object.values(L).some(We=>A(We,De))}function b(L){return L.type==="AssignmentExpression"||L.type==="BinaryExpression"||L.type==="LogicalExpression"||L.type==="NGPipeExpression"||L.type==="ConditionalExpression"||Ee(L)||q(L)||L.type==="SequenceExpression"||L.type==="TaggedTemplateExpression"||L.type==="BindExpression"||L.type==="UpdateExpression"&&!L.prefix||L.type==="TSAsExpression"||L.type==="TSNonNullExpression"}function v(L){return L.expressions?L.expressions[0]:L.left||L.test||L.callee||L.object||L.tag||L.argument||L.expression}function B(L,De){if(De.expressions)return["expressions",0];if(De.left)return["left"];if(De.test)return["test"];if(De.object)return["object"];if(De.callee)return["callee"];if(De.tag)return["tag"];if(De.argument)return["argument"];if(De.expression)return["expression"];throw new Error("Unexpected node has no left side.")}function w(L){return L.type==="Line"||L.type==="CommentLine"||L.type==="SingleLine"||L.type==="HashbangComment"||L.type==="HTMLOpen"||L.type==="HTMLClose"}var I=new Set(["ExportDefaultDeclaration","ExportDefaultSpecifier","DeclareExportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"]);function E(L){return L&&I.has(L.type)}function D(L){let De=L.getParentNode();return L.getName()==="declaration"&&E(De)?De:null}function d(L){return L.type==="BooleanLiteral"||L.type==="DirectiveLiteral"||L.type==="Literal"||L.type==="NullLiteral"||L.type==="NumericLiteral"||L.type==="BigIntLiteral"||L.type==="DecimalLiteral"||L.type==="RegExpLiteral"||L.type==="StringLiteral"||L.type==="TemplateLiteral"||L.type==="TSTypeLiteral"||L.type==="JSXText"}function y(L){return L.type==="NumericLiteral"||L.type==="Literal"&&typeof L.value=="number"}function o(L){return L.type==="UnaryExpression"&&(L.operator==="+"||L.operator==="-")&&y(L.argument)}function x(L){return L.type==="StringLiteral"||L.type==="Literal"&&typeof L.value=="string"}function F(L){return L.type==="ObjectTypeAnnotation"||L.type==="TSTypeLiteral"||L.type==="TSMappedType"}function S(L){return L.type==="FunctionExpression"||L.type==="ArrowFunctionExpression"}function k(L){return L.type==="FunctionExpression"||L.type==="ArrowFunctionExpression"&&L.body.type==="BlockStatement"}function _(L){return L.type==="TemplateLiteral"}function O(L){return Ee(L)&&L.callee.type==="Identifier"&&["async","inject","fakeAsync","waitForAsync"].includes(L.callee.name)}function R(L){return L.type==="JSXElement"||L.type==="JSXFragment"}function M(L,De){if(L.parentParser!=="markdown"&&L.parentParser!=="mdx")return!1;let ke=De.getNode();if(!ke.expression||!R(ke.expression))return!1;let We=De.getParentNode();return We.type==="Program"&&We.body.length===1}function H(L){return L.kind==="get"||L.kind==="set"}function P(L){return H(L)||m(L,L.value)}function G(L){return(L.type==="ObjectTypeProperty"||L.type==="ObjectTypeInternalSlot")&&L.value.type==="FunctionTypeAnnotation"&&!L.static&&!P(L)}function re(L){return(L.type==="TypeAnnotation"||L.type==="TSTypeAnnotation")&&L.typeAnnotation.type==="FunctionTypeAnnotation"&&!L.static&&!m(L,L.typeAnnotation)}var $=new Set(["BinaryExpression","LogicalExpression","NGPipeExpression"]);function W(L){return $.has(L.type)}function ee(L){return q(L)||L.type==="BindExpression"&&Boolean(L.object)}var U=new Set(["AnyTypeAnnotation","TSAnyKeyword","NullLiteralTypeAnnotation","TSNullKeyword","ThisTypeAnnotation","TSThisType","NumberTypeAnnotation","TSNumberKeyword","VoidTypeAnnotation","TSVoidKeyword","BooleanTypeAnnotation","TSBooleanKeyword","BigIntTypeAnnotation","TSBigIntKeyword","SymbolTypeAnnotation","TSSymbolKeyword","StringTypeAnnotation","TSStringKeyword","BooleanLiteralTypeAnnotation","StringLiteralTypeAnnotation","BigIntLiteralTypeAnnotation","NumberLiteralTypeAnnotation","TSLiteralType","TSTemplateLiteralType","EmptyTypeAnnotation","MixedTypeAnnotation","TSNeverKeyword","TSObjectKeyword","TSUndefinedKeyword","TSUnknownKeyword"]);function ne(L){return L?!!((L.type==="GenericTypeAnnotation"||L.type==="TSTypeReference")&&!L.typeParameters||U.has(L.type)):!1}var se=/^(?:skip|[fx]?(?:it|describe|test))$/;function V(L){return q(L.callee)&&L.callee.object.type==="Identifier"&&L.callee.property.type==="Identifier"&&se.test(L.callee.object.name)&&(L.callee.property.name==="only"||L.callee.property.name==="skip")}function oe(L){let De=/^(?:before|after)(?:Each|All)$/;return L.callee.type==="Identifier"&&De.test(L.callee.name)&&L.arguments.length===1}function K(L,De){if(L.type!=="CallExpression")return!1;if(L.arguments.length===1){if(O(L)&&De&&K(De))return S(L.arguments[0]);if(oe(L))return O(L.arguments[0])}else if((L.arguments.length===2||L.arguments.length===3)&&(L.callee.type==="Identifier"&&se.test(L.callee.name)||V(L))&&(_(L.arguments[0])||x(L.arguments[0])))return L.arguments[2]&&!y(L.arguments[2])?!1:(L.arguments.length===2?S(L.arguments[1]):k(L.arguments[1])&&Ke(L.arguments[1]).length<=1)||O(L.arguments[1]);return!1}function Ee(L){return L&&(L.type==="CallExpression"||L.type==="OptionalCallExpression")}function q(L){return L&&(L.type==="MemberExpression"||L.type==="OptionalMemberExpression")}function le(L){let De="expressions";L.type==="TSTemplateLiteralType"&&(De="types");let ke=L[De];return ke.length===0?!1:ke.every(We=>{if(Me(We))return!1;if(We.type==="Identifier"||We.type==="ThisExpression")return!0;if(q(We)){let $e=We;for(;q($e);)if($e.property.type!=="Identifier"&&$e.property.type!=="Literal"&&$e.property.type!=="StringLiteral"&&$e.property.type!=="NumericLiteral"||($e=$e.object,Me($e)))return!1;return $e.type==="Identifier"||$e.type==="ThisExpression"}return!1})}function ue(L,De){return L==="+"?"+"+De:L==="-"?"-"+De:De}function Q(L,De){let ke=l(De),We=r(L,C(De));return We!==!1&&L.slice(ke,ke+2)==="/*"&&L.slice(We,We+2)==="*/"}function de(L,De){return R(De)?Ae(De):Me(De,Pe.Leading,ke=>i(L,C(ke)))}function ge(L,De){return De.parser!=="json"&&x(L.key)&&J(L.key).slice(1,-1)===L.key.value&&(t(L.key.value)&&!(De.parser==="babel-ts"&&L.type==="ClassProperty"||De.parser==="typescript"&&L.type==="PropertyDefinition")||ve(L.key.value)&&String(Number(L.key.value))===L.key.value&&(De.parser==="babel"||De.parser==="acorn"||De.parser==="espree"||De.parser==="meriyah"||De.parser==="__babel_estree"))}function ve(L){return/^(?:\d+|\d+\.\d+)$/.test(L)}function xe(L,De){let ke=/^[fx]?(?:describe|it|test)$/;return De.type==="TaggedTemplateExpression"&&De.quasi===L&&De.tag.type==="MemberExpression"&&De.tag.property.type==="Identifier"&&De.tag.property.name==="each"&&(De.tag.object.type==="Identifier"&&ke.test(De.tag.object.name)||De.tag.object.type==="MemberExpression"&&De.tag.object.property.type==="Identifier"&&(De.tag.object.property.name==="only"||De.tag.object.property.name==="skip")&&De.tag.object.object.type==="Identifier"&&ke.test(De.tag.object.object.name))}function we(L){return L.quasis.some(De=>De.value.raw.includes(` |
| | | `))}function fe(L,De){return(L.type==="TemplateLiteral"&&we(L)||L.type==="TaggedTemplateExpression"&&we(L.quasi))&&!i(De,l(L),{backwards:!0})}function pe(L){if(!Me(L))return!1;let De=s(qe(L,Pe.Dangling));return De&&!g(De)}function me(L){if(L.length<=1)return!1;let De=0;for(let ke of L)if(S(ke)){if(De+=1,De>1)return!0}else if(Ee(ke)){for(let We of ke.arguments)if(S(We))return!0}return!1}function ce(L){let De=L.getValue(),ke=L.getParentNode();return Ee(De)&&Ee(ke)&&ke.callee===De&&De.arguments.length>ke.arguments.length&&ke.arguments.length>0}function he(L,De){if(De>=2)return!1;let ke=$e=>he($e,De+1),We=L.type==="Literal"&&"regex"in L&&L.regex.pattern||L.type==="RegExpLiteral"&&L.pattern;return We&&c(We)>5?!1:L.type==="Literal"||L.type==="BigIntLiteral"||L.type==="DecimalLiteral"||L.type==="BooleanLiteral"||L.type==="NullLiteral"||L.type==="NumericLiteral"||L.type==="RegExpLiteral"||L.type==="StringLiteral"||L.type==="Identifier"||L.type==="ThisExpression"||L.type==="Super"||L.type==="PrivateName"||L.type==="PrivateIdentifier"||L.type==="ArgumentPlaceholder"||L.type==="Import"?!0:L.type==="TemplateLiteral"?L.quasis.every($e=>!$e.value.raw.includes(` |
| | | `))&&L.expressions.every(ke):L.type==="ObjectExpression"?L.properties.every($e=>!$e.computed&&($e.shorthand||$e.value&&ke($e.value))):L.type==="ArrayExpression"?L.elements.every($e=>$e===null||ke($e)):rt(L)?(L.type==="ImportExpression"||he(L.callee,De))&&Be(L).every(ke):q(L)?he(L.object,De)&&he(L.property,De):L.type==="UnaryExpression"&&(L.operator==="!"||L.operator==="-")?he(L.argument,De):L.type==="TSNonNullExpression"?he(L.expression,De):!1}function J(L){return L.extra?L.extra.raw:L.raw}function ye(L){return L}function X(L){return L.filepath&&/\.tsx$/i.test(L.filepath)}function Y(L){let De=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"es5";return L.trailingComma==="es5"&&De==="es5"||L.trailingComma==="all"&&(De==="all"||De==="es5")}function te(L,De){switch(L=tt(L),L.type){case"FunctionExpression":case"ClassExpression":case"DoExpression":return De;case"ObjectExpression":return!0;case"MemberExpression":case"OptionalMemberExpression":return te(L.object,De);case"TaggedTemplateExpression":return L.tag.type==="FunctionExpression"?!1:te(L.tag,De);case"CallExpression":case"OptionalCallExpression":return L.callee.type==="FunctionExpression"?!1:te(L.callee,De);case"ConditionalExpression":return te(L.test,De);case"UpdateExpression":return!L.prefix&&te(L.argument,De);case"BindExpression":return L.object&&te(L.object,De);case"SequenceExpression":return te(L.expressions[0],De);case"TSAsExpression":case"TSNonNullExpression":return te(L.expression,De);default:return!1}}var z={"==":!0,"!=":!0,"===":!0,"!==":!0},j={"*":!0,"/":!0,"%":!0},Ce={">>":!0,">>>":!0,"<<":!0};function Ne(L,De){return!(Ue(De)!==Ue(L)||L==="**"||z[L]&&z[De]||De==="%"&&j[L]||L==="%"&&j[De]||De!==L&&j[De]&&j[L]||Ce[L]&&Ce[De])}var je={};for(let[L,De]of[["|>"],["??"],["||"],["&&"],["|"],["^"],["&"],["==","===","!=","!=="],["<",">","<=",">=","in","instanceof"],[">>","<<",">>>"],["+","-"],["*","/","%"],["**"]].entries())for(let ke of De)je[ke]=L;function Ue(L){return je[L]}function tt(L){for(;L.left;)L=L.left;return L}function Te(L){return Boolean(Ce[L])||L==="|"||L==="^"||L==="&"}function _e(L){if(L.rest)return!0;let De=Ke(L);return De.length>0&&s(De).type==="RestElement"}var Fe=new WeakMap;function Ke(L){if(Fe.has(L))return Fe.get(L);let De=[];return L.this&&De.push(L.this),Array.isArray(L.parameters)?De.push(...L.parameters):Array.isArray(L.params)&&De.push(...L.params),L.rest&&De.push(L.rest),Fe.set(L,De),De}function Se(L,De){let ke=L.getValue(),We=0,$e=ut=>De(ut,We++);ke.this&&L.call($e,"this"),Array.isArray(ke.parameters)?L.each($e,"parameters"):Array.isArray(ke.params)&&L.each($e,"params"),ke.rest&&L.call($e,"rest")}var ze=new WeakMap;function Be(L){if(ze.has(L))return ze.get(L);let De=L.arguments;return L.type==="ImportExpression"&&(De=[L.source],L.attributes&&De.push(L.attributes)),ze.set(L,De),De}function Ie(L,De){let ke=L.getValue();ke.type==="ImportExpression"?(L.call(We=>De(We,0),"source"),ke.attributes&&L.call(We=>De(We,1),"attributes")):L.each(De,"arguments")}function Ve(L){return L.value.trim()==="prettier-ignore"&&!L.unignore}function Ae(L){return L&&(L.prettierIgnore||Me(L,Pe.PrettierIgnore))}function Oe(L){let De=L.getValue();return Ae(De)}var Pe={Leading:1<<1,Trailing:1<<2,Dangling:1<<3,Block:1<<4,Line:1<<5,PrettierIgnore:1<<6,First:1<<7,Last:1<<8},ie=(L,De)=>{if(typeof L=="function"&&(De=L,L=0),L||De)return(ke,We,$e)=>!(L&Pe.Leading&&!ke.leading||L&Pe.Trailing&&!ke.trailing||L&Pe.Dangling&&(ke.leading||ke.trailing)||L&Pe.Block&&!g(ke)||L&Pe.Line&&!w(ke)||L&Pe.First&&We!==0||L&Pe.Last&&We!==$e.length-1||L&Pe.PrettierIgnore&&!Ve(ke)||De&&!De(ke))};function Me(L,De,ke){if(!L||!u(L.comments))return!1;let We=ie(De,ke);return We?L.comments.some(We):!0}function qe(L,De,ke){if(!L||!Array.isArray(L.comments))return[];let We=ie(De,ke);return We?L.comments.filter(We):L.comments}var Je=(L,De)=>{let{originalText:ke}=De;return a(ke,C(L))};function rt(L){return Ee(L)||L.type==="NewExpression"||L.type==="ImportExpression"}function Ze(L){return L&&(L.type==="ObjectProperty"||L.type==="Property"&&!L.method&&L.kind==="init")}function ct(L){return Boolean(L.__isUsingHackPipeline)}var qt=Symbol("ifWithoutBlockAndSameLineComment");n.exports={getFunctionParameters:Ke,iterateFunctionParametersPath:Se,getCallArguments:Be,iterateCallArgumentsPath:Ie,hasRestParameter:_e,getLeftSide:v,getLeftSidePathName:B,getParentExportDeclaration:D,getTypeScriptMappedTypeModifier:ue,hasFlowAnnotationComment:T,hasFlowShorthandAnnotationComment:N,hasLeadingOwnLineComment:de,hasNakedLeftSide:b,hasNode:A,hasIgnoreComment:Oe,hasNodeIgnoreComment:Ae,identity:ye,isBinaryish:W,isCallLikeExpression:rt,isEnabledHackPipeline:ct,isLineComment:w,isPrettierIgnoreComment:Ve,isCallExpression:Ee,isMemberExpression:q,isExportDeclaration:E,isFlowAnnotationComment:Q,isFunctionCompositionArgs:me,isFunctionNotation:P,isFunctionOrArrowExpression:S,isGetterOrSetter:H,isJestEachTemplateLiteral:xe,isJsxNode:R,isLiteral:d,isLongCurriedCallExpression:ce,isSimpleCallArgument:he,isMemberish:ee,isNumericLiteral:y,isSignedNumericLiteral:o,isObjectProperty:Ze,isObjectType:F,isObjectTypePropertyAFunction:G,isSimpleType:ne,isSimpleNumber:ve,isSimpleTemplateLiteral:le,isStringLiteral:x,isStringPropSafeToUnquote:ge,isTemplateOnItsOwnLine:fe,isTestCall:K,isTheOnlyJsxElementInMarkdown:M,isTSXFile:X,isTypeAnnotationAFunction:re,isNextLineEmpty:Je,needsHardlineAfterDanglingComment:pe,rawText:J,shouldPrintComma:Y,isBitwiseOperator:Te,shouldFlatten:Ne,startsWithNoLookaheadToken:te,getPrecedence:Ue,hasComment:Me,getComments:qe,CommentCheckFlags:Pe,markerForIfWithoutBlockAndSameLineComment:qt}}}),It=Z({"src/language-js/print/template-literal.js"(e,n){"use strict";ae();var t=st(),{getStringWidth:s,getIndentSize:i}=Ge(),{builders:{join:r,hardline:u,softline:a,group:c,indent:l,align:C,lineSuffixBoundary:m,addAlignmentToDoc:g},printer:{printDocToString:p},utils:{mapDoc:f}}=Le(),{isBinaryish:h,isJestEachTemplateLiteral:N,isSimpleTemplateLiteral:T,hasComment:A,isMemberExpression:b}=Xe();function v(d,y,o){let x=d.getValue();if(x.type==="TemplateLiteral"&&N(x,d.getParentNode())){let R=B(d,o,y);if(R)return R}let S="expressions";x.type==="TSTemplateLiteralType"&&(S="types");let k=[],_=d.map(y,S),O=T(x);return O&&(_=_.map(R=>p(R,Object.assign(Object.assign({},o),{},{printWidth:Number.POSITIVE_INFINITY})).formatted)),k.push(m,"`"),d.each(R=>{let M=R.getName();if(k.push(y()),M<_.length){let{tabWidth:H}=o,P=R.getValue(),G=i(P.value.raw,H),re=_[M];if(!O){let W=x[S][M];(A(W)||b(W)||W.type==="ConditionalExpression"||W.type==="SequenceExpression"||W.type==="TSAsExpression"||h(W))&&(re=[l([a,re]),a])}let $=G===0&&P.value.raw.endsWith(` |
| | | `)?C(Number.NEGATIVE_INFINITY,re):g(re,G,H);k.push(c(["${",$,m,"}"]))}},"quasis"),k.push("`"),k}function B(d,y,o){let x=d.getNode(),F=x.quasis[0].value.raw.trim().split(/\s*\|\s*/);if(F.length>1||F.some(S=>S.length>0)){y.__inJestEach=!0;let S=d.map(o,"expressions");y.__inJestEach=!1;let k=[],_=S.map(P=>"${"+p(P,Object.assign(Object.assign({},y),{},{printWidth:Number.POSITIVE_INFINITY,endOfLine:"lf"})).formatted+"}"),O=[{hasLineBreak:!1,cells:[]}];for(let P=1;P<x.quasis.length;P++){let G=t(O),re=_[P-1];G.cells.push(re),re.includes(` |
| | | `)&&(G.hasLineBreak=!0),x.quasis[P].value.raw.includes(` |
| | | `)&&O.push({hasLineBreak:!1,cells:[]})}let R=Math.max(F.length,...O.map(P=>P.cells.length)),M=Array.from({length:R}).fill(0),H=[{cells:F},...O.filter(P=>P.cells.length>0)];for(let{cells:P}of H.filter(G=>!G.hasLineBreak))for(let[G,re]of P.entries())M[G]=Math.max(M[G],s(re));return k.push(m,"`",l([u,r(u,H.map(P=>r(" | ",P.cells.map((G,re)=>P.hasLineBreak?G:G+" ".repeat(M[re]-s(G))))))]),u,"`"),k}}function w(d,y){let o=d.getValue(),x=y();return A(o)&&(x=c([l([a,x]),a])),["${",x,m,"}"]}function I(d,y){return d.map(o=>w(o,y),"expressions")}function E(d,y){return f(d,o=>typeof o=="string"?y?o.replace(/(\\*)`/g,"$1$1\\`"):D(o):o)}function D(d){return d.replace(/([\\`]|\${)/g,"\\$1")}n.exports={printTemplateLiteral:v,printTemplateExpressions:I,escapeTemplateCharacters:E,uncookTemplateElementValue:D}}}),Dm=Z({"src/language-js/embed/markdown.js"(e,n){"use strict";ae();var{builders:{indent:t,softline:s,literalline:i,dedentToRoot:r}}=Le(),{escapeTemplateCharacters:u}=It();function a(l,C,m){let p=l.getValue().quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g,(T,A)=>"\\".repeat(A.length/2)+"`"),f=c(p),h=f!=="";h&&(p=p.replace(new RegExp("^".concat(f),"gm"),""));let N=u(m(p,{parser:"markdown",__inJsTemplate:!0},{stripTrailingHardline:!0}),!0);return["`",h?t([s,N]):[i,r(N)],s,"`"]}function c(l){let C=l.match(/^([^\S\n]*)\S/m);return C===null?"":C[1]}n.exports=a}}),mm=Z({"src/language-js/embed/css.js"(e,n){"use strict";ae();var{isNonEmptyArray:t}=Ge(),{builders:{indent:s,hardline:i,softline:r},utils:{mapDoc:u,replaceEndOfLine:a,cleanDoc:c}}=Le(),{printTemplateExpressions:l}=It();function C(p,f,h){let N=p.getValue(),T=N.quasis.map(w=>w.value.raw),A=0,b=T.reduce((w,I,E)=>E===0?I:w+"@prettier-placeholder-"+A+++"-id"+I,""),v=h(b,{parser:"scss"},{stripTrailingHardline:!0}),B=l(p,f);return m(v,N,B)}function m(p,f,h){if(f.quasis.length===1&&!f.quasis[0].value.raw.trim())return"``";let T=g(p,h);if(!T)throw new Error("Couldn't insert all the expressions");return["`",s([i,T]),r,"`"]}function g(p,f){if(!t(f))return p;let h=0,N=u(c(p),T=>typeof T!="string"||!T.includes("@prettier-placeholder")?T:T.split(/@prettier-placeholder-(\d+)-id/).map((A,b)=>b%2===0?a(A):(h++,f[A])));return f.length===h?N:null}n.exports=C}}),dm=Z({"src/language-js/embed/graphql.js"(e,n){"use strict";ae();var{builders:{indent:t,join:s,hardline:i}}=Le(),{escapeTemplateCharacters:r,printTemplateExpressions:u}=It();function a(l,C,m){let g=l.getValue(),p=g.quasis.length;if(p===1&&g.quasis[0].value.raw.trim()==="")return"``";let f=u(l,C),h=[];for(let N=0;N<p;N++){let T=g.quasis[N],A=N===0,b=N===p-1,v=T.value.cooked,B=v.split(` |
| | | `),w=B.length,I=f[N],E=w>2&&B[0].trim()===""&&B[1].trim()==="",D=w>2&&B[w-1].trim()===""&&B[w-2].trim()==="",d=B.every(o=>/^\s*(?:#[^\n\r]*)?$/.test(o));if(!b&&/#[^\n\r]*$/.test(B[w-1]))return null;let y=null;d?y=c(B):y=m(v,{parser:"graphql"},{stripTrailingHardline:!0}),y?(y=r(y,!1),!A&&E&&h.push(""),h.push(y),!b&&D&&h.push("")):!A&&!b&&E&&h.push(""),I&&h.push(I)}return["`",t([i,s(i,h)]),i,"`"]}function c(l){let C=[],m=!1,g=l.map(p=>p.trim());for(let[p,f]of g.entries())f!==""&&(g[p-1]===""&&m?C.push([i,f]):C.push(f),m=!0);return C.length===0?null:s(i,C)}n.exports=a}}),gm=Z({"src/language-js/embed/html.js"(e,n){"use strict";ae();var{builders:{indent:t,line:s,hardline:i,group:r},utils:{mapDoc:u}}=Le(),{printTemplateExpressions:a,uncookTemplateElementValue:c}=It(),l=0;function C(m,g,p,f,h){let{parser:N}=h,T=m.getValue(),A=l;l=l+1>>>0;let b=x=>"PRETTIER_HTML_PLACEHOLDER_".concat(x,"_").concat(A,"_IN_JS"),v=T.quasis.map((x,F,S)=>F===S.length-1?x.value.cooked:x.value.cooked+b(F)).join(""),B=a(m,g);if(B.length===0&&v.trim().length===0)return"``";let w=new RegExp(b("(\\d+)"),"g"),I=0,E=p(v,{parser:N,__onHtmlRoot(x){I=x.children.length}},{stripTrailingHardline:!0}),D=u(E,x=>{if(typeof x!="string")return x;let F=[],S=x.split(w);for(let k=0;k<S.length;k++){let _=S[k];if(k%2===0){_&&(_=c(_),f.__embeddedInHtml&&(_=_.replace(/<\/(script)\b/gi,"<\\/$1")),F.push(_));continue}let O=Number(_);F.push(B[O])}return F}),d=/^\s/.test(v)?" ":"",y=/\s$/.test(v)?" ":"",o=f.htmlWhitespaceSensitivity==="ignore"?i:d&&y?s:null;return r(o?["`",t([o,r(D)]),o,"`"]:["`",d,I>1?t(r(D)):r(D),y,"`"])}n.exports=C}}),ym=Z({"src/language-js/embed.js"(e,n){"use strict";ae();var{hasComment:t,CommentCheckFlags:s,isObjectProperty:i}=Xe(),r=Dm(),u=mm(),a=dm(),c=gm();function l(E){if(g(E)||N(E)||T(E)||p(E))return"css";if(v(E))return"graphql";if(w(E))return"html";if(f(E))return"angular";if(m(E))return"markdown"}function C(E,D,d,y){let o=E.getValue();if(o.type!=="TemplateLiteral"||I(o))return;let x=l(E);if(!!x){if(x==="markdown")return r(E,D,d);if(x==="css")return u(E,D,d);if(x==="graphql")return a(E,D,d);if(x==="html"||x==="angular")return c(E,D,d,y,{parser:x})}}function m(E){let D=E.getValue(),d=E.getParentNode();return d&&d.type==="TaggedTemplateExpression"&&D.quasis.length===1&&d.tag.type==="Identifier"&&(d.tag.name==="md"||d.tag.name==="markdown")}function g(E){let D=E.getValue(),d=E.getParentNode(),y=E.getParentNode(1);return y&&D.quasis&&d.type==="JSXExpressionContainer"&&y.type==="JSXElement"&&y.openingElement.name.name==="style"&&y.openingElement.attributes.some(o=>o.name.name==="jsx")||d&&d.type==="TaggedTemplateExpression"&&d.tag.type==="Identifier"&&d.tag.name==="css"||d&&d.type==="TaggedTemplateExpression"&&d.tag.type==="MemberExpression"&&d.tag.object.name==="css"&&(d.tag.property.name==="global"||d.tag.property.name==="resolve")}function p(E){return E.match(D=>D.type==="TemplateLiteral",(D,d)=>D.type==="ArrayExpression"&&d==="elements",(D,d)=>i(D)&&D.key.type==="Identifier"&&D.key.name==="styles"&&d==="value",...h)}function f(E){return E.match(D=>D.type==="TemplateLiteral",(D,d)=>i(D)&&D.key.type==="Identifier"&&D.key.name==="template"&&d==="value",...h)}var h=[(E,D)=>E.type==="ObjectExpression"&&D==="properties",(E,D)=>E.type==="CallExpression"&&E.callee.type==="Identifier"&&E.callee.name==="Component"&&D==="arguments",(E,D)=>E.type==="Decorator"&&D==="expression"];function N(E){let D=E.getParentNode();if(!D||D.type!=="TaggedTemplateExpression")return!1;let d=D.tag.type==="ParenthesizedExpression"?D.tag.expression:D.tag;switch(d.type){case"MemberExpression":return A(d.object)||b(d);case"CallExpression":return A(d.callee)||d.callee.type==="MemberExpression"&&(d.callee.object.type==="MemberExpression"&&(A(d.callee.object.object)||b(d.callee.object))||d.callee.object.type==="CallExpression"&&A(d.callee.object.callee));case"Identifier":return d.name==="css";default:return!1}}function T(E){let D=E.getParentNode(),d=E.getParentNode(1);return d&&D.type==="JSXExpressionContainer"&&d.type==="JSXAttribute"&&d.name.type==="JSXIdentifier"&&d.name.name==="css"}function A(E){return E.type==="Identifier"&&E.name==="styled"}function b(E){return/^[A-Z]/.test(E.object.name)&&E.property.name==="extend"}function v(E){let D=E.getValue(),d=E.getParentNode();return B(D,"GraphQL")||d&&(d.type==="TaggedTemplateExpression"&&(d.tag.type==="MemberExpression"&&d.tag.object.name==="graphql"&&d.tag.property.name==="experimental"||d.tag.type==="Identifier"&&(d.tag.name==="gql"||d.tag.name==="graphql"))||d.type==="CallExpression"&&d.callee.type==="Identifier"&&d.callee.name==="graphql")}function B(E,D){return t(E,s.Block|s.Leading,d=>{let{value:y}=d;return y===" ".concat(D," ")})}function w(E){return B(E.getValue(),"HTML")||E.match(D=>D.type==="TemplateLiteral",(D,d)=>D.type==="TaggedTemplateExpression"&&D.tag.type==="Identifier"&&D.tag.name==="html"&&d==="quasi")}function I(E){let{quasis:D}=E;return D.some(d=>{let{value:{cooked:y}}=d;return y===null})}n.exports=C}}),hm=Z({"src/language-js/clean.js"(e,n){"use strict";ae();var t=Pt(),s=new Set(["range","raw","comments","leadingComments","trailingComments","innerComments","extra","start","end","loc","flags","errors","tokens"]),i=u=>{for(let a of u.quasis)delete a.value};function r(u,a,c){if(u.type==="Program"&&delete a.sourceType,(u.type==="BigIntLiteral"||u.type==="BigIntLiteralTypeAnnotation")&&a.value&&(a.value=a.value.toLowerCase()),(u.type==="BigIntLiteral"||u.type==="Literal")&&a.bigint&&(a.bigint=a.bigint.toLowerCase()),u.type==="DecimalLiteral"&&(a.value=Number(a.value)),u.type==="Literal"&&a.decimal&&(a.decimal=Number(a.decimal)),u.type==="EmptyStatement"||u.type==="JSXText"||u.type==="JSXExpressionContainer"&&(u.expression.type==="Literal"||u.expression.type==="StringLiteral")&&u.expression.value===" ")return null;if((u.type==="Property"||u.type==="ObjectProperty"||u.type==="MethodDefinition"||u.type==="ClassProperty"||u.type==="ClassMethod"||u.type==="PropertyDefinition"||u.type==="TSDeclareMethod"||u.type==="TSPropertySignature"||u.type==="ObjectTypeProperty")&&typeof u.key=="object"&&u.key&&(u.key.type==="Literal"||u.key.type==="NumericLiteral"||u.key.type==="StringLiteral"||u.key.type==="Identifier")&&delete a.key,u.type==="JSXElement"&&u.openingElement.name.name==="style"&&u.openingElement.attributes.some(C=>C.name.name==="jsx"))for(let{type:C,expression:m}of a.children)C==="JSXExpressionContainer"&&m.type==="TemplateLiteral"&&i(m);u.type==="JSXAttribute"&&u.name.name==="css"&&u.value.type==="JSXExpressionContainer"&&u.value.expression.type==="TemplateLiteral"&&i(a.value.expression),u.type==="JSXAttribute"&&u.value&&u.value.type==="Literal"&&/["']|"|'/.test(u.value.value)&&(a.value.value=a.value.value.replace(/["']|"|'/g,'"'));let l=u.expression||u.callee;if(u.type==="Decorator"&&l.type==="CallExpression"&&l.callee.name==="Component"&&l.arguments.length===1){let C=u.expression.arguments[0].properties;for(let[m,g]of a.expression.arguments[0].properties.entries())switch(C[m].key.name){case"styles":g.value.type==="ArrayExpression"&&i(g.value.elements[0]);break;case"template":g.value.type==="TemplateLiteral"&&i(g.value);break}}if(u.type==="TaggedTemplateExpression"&&(u.tag.type==="MemberExpression"||u.tag.type==="Identifier"&&(u.tag.name==="gql"||u.tag.name==="graphql"||u.tag.name==="css"||u.tag.name==="md"||u.tag.name==="markdown"||u.tag.name==="html")||u.tag.type==="CallExpression")&&i(a.quasi),u.type==="TemplateLiteral"&&(u.leadingComments&&u.leadingComments.some(m=>t(m)&&["GraphQL","HTML"].some(g=>m.value===" ".concat(g," ")))||c.type==="CallExpression"&&c.callee.name==="graphql"||!u.leadingComments)&&i(a),u.type==="InterpreterDirective"&&(a.value=a.value.trimEnd()),(u.type==="TSIntersectionType"||u.type==="TSUnionType")&&u.types.length===1)return a.types[0]}r.ignoredProperties=s,n.exports=r}}),Vi={};kn(Vi,{EOL:()=>wn,arch:()=>Cm,cpus:()=>zi,default:()=>Zi,endianness:()=>Wi,freemem:()=>Ji,getNetworkInterfaces:()=>Qi,hostname:()=>$i,loadavg:()=>Hi,networkInterfaces:()=>Yi,platform:()=>Em,release:()=>Ki,tmpDir:()=>Bn,tmpdir:()=>Nn,totalmem:()=>Ui,type:()=>Xi,uptime:()=>Gi});function Wi(){if(typeof Fr>"u"){var e=new ArrayBuffer(2),n=new Uint8Array(e),t=new Uint16Array(e);if(n[0]=1,n[1]=2,t[0]===258)Fr="BE";else if(t[0]===513)Fr="LE";else throw new Error("unable to figure out endianess")}return Fr}function $i(){return typeof globalThis.location<"u"?globalThis.location.hostname:""}function Hi(){return[]}function Gi(){return 0}function Ji(){return Number.MAX_VALUE}function Ui(){return Number.MAX_VALUE}function zi(){return[]}function Xi(){return"Browser"}function Ki(){return typeof globalThis.navigator<"u"?globalThis.navigator.appVersion:""}function Yi(){}function Qi(){}function Cm(){return"javascript"}function Em(){return"browser"}function Bn(){return"/tmp"}var Fr,Nn,wn,Zi,vm=br({"node-modules-polyfills:os"(){ae(),Nn=Bn,wn=` |
| | | `,Zi={EOL:wn,tmpdir:Nn,tmpDir:Bn,networkInterfaces:Yi,getNetworkInterfaces:Qi,release:Ki,type:Xi,cpus:zi,totalmem:Ui,freemem:Ji,uptime:Gi,loadavg:Hi,hostname:$i,endianness:Wi}}}),Fm=Z({"node-modules-polyfills-commonjs:os"(e,n){ae();var t=(vm(),pt(Vi));if(t&&t.default){n.exports=t.default;for(let s in t)n.exports[s]=t[s]}else t&&(n.exports=t)}}),Am=Z({"node_modules/detect-newline/index.js"(e,n){"use strict";ae();var t=s=>{if(typeof s!="string")throw new TypeError("Expected a string");let i=s.match(/(?:\r?\n)/g)||[];if(i.length===0)return;let r=i.filter(a=>a===`\r |
| | | `).length,u=i.length-r;return r>u?`\r |
| | | `:` |
| | | `};n.exports=t,n.exports.graceful=s=>typeof s=="string"&&t(s)||` |
| | | `}}),Sm=Z({"node_modules/jest-docblock/build/index.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.extract=p,e.parse=h,e.parseWithComments=N,e.print=T,e.strip=f;function n(){let b=Fm();return n=function(){return b},b}function t(){let b=s(Am());return t=function(){return b},b}function s(b){return b&&b.__esModule?b:{default:b}}var i=/\*\/$/,r=/^\/\*\*/,u=/^\s*(\/\*\*?(.|\r?\n)*?\*\/)/,a=/(^|\s+)\/\/([^\r\n]*)/g,c=/^(\r?\n)+/,l=/(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g,C=/(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g,m=/(\r?\n|^) *\* ?/g,g=[];function p(b){let v=b.match(u);return v?v[0].trimLeft():""}function f(b){let v=b.match(u);return v&&v[0]?b.substring(v[0].length):b}function h(b){return N(b).pragmas}function N(b){let v=(0,t().default)(b)||n().EOL;b=b.replace(r,"").replace(i,"").replace(m,"$1");let B="";for(;B!==b;)B=b,b=b.replace(l,"".concat(v,"$1 $2").concat(v));b=b.replace(c,"").trimRight();let w=Object.create(null),I=b.replace(C,"").replace(c,"").trimRight(),E;for(;E=C.exec(b);){let D=E[2].replace(a,"");typeof w[E[1]]=="string"||Array.isArray(w[E[1]])?w[E[1]]=g.concat(w[E[1]],D):w[E[1]]=D}return{comments:I,pragmas:w}}function T(b){let{comments:v="",pragmas:B={}}=b,w=(0,t().default)(v)||n().EOL,I="/**",E=" *",D=" */",d=Object.keys(B),y=d.map(x=>A(x,B[x])).reduce((x,F)=>x.concat(F),[]).map(x=>E+" "+x+w).join("");if(!v){if(d.length===0)return"";if(d.length===1&&!Array.isArray(B[d[0]])){let x=B[d[0]];return"".concat(I," ").concat(A(d[0],x)[0]).concat(D)}}let o=v.split(w).map(x=>"".concat(E," ").concat(x)).join(w)+w;return I+w+(v?o:"")+(v&&d.length?E+w:"")+y+D}function A(b,v){return g.concat(v).map(B=>"@".concat(b," ").concat(B).trim())}}}),xm=Z({"src/language-js/utils/get-shebang.js"(e,n){"use strict";ae();function t(s){if(!s.startsWith("#!"))return"";let i=s.indexOf(` |
| | | `);return i===-1?s:s.slice(0,i)}n.exports=t}}),eo=Z({"src/language-js/pragma.js"(e,n){"use strict";ae();var{parseWithComments:t,strip:s,extract:i,print:r}=Sm(),{normalizeEndOfLine:u}=On(),a=xm();function c(m){let g=a(m);g&&(m=m.slice(g.length+1));let p=i(m),{pragmas:f,comments:h}=t(p);return{shebang:g,text:m,pragmas:f,comments:h}}function l(m){let g=Object.keys(c(m).pragmas);return g.includes("prettier")||g.includes("format")}function C(m){let{shebang:g,text:p,pragmas:f,comments:h}=c(m),N=s(p),T=r({pragmas:Object.assign({format:""},f),comments:h.trimStart()});return(g?"".concat(g,` |
| | | `):"")+u(T)+(N.startsWith(` |
| | | `)?` |
| | | `:` |
| | | |
| | | var name = "prettier"; |
| | | var version = "1.19.1"; |
| | | var description = "Prettier is an opinionated code formatter"; |
| | | var bin = { |
| | | prettier: "./bin/prettier.js" |
| | | }; |
| | | var repository = "prettier/prettier"; |
| | | var homepage = "https://prettier.io"; |
| | | var author = "James Long"; |
| | | var license = "MIT"; |
| | | var main = "./index.js"; |
| | | var engines = { |
| | | node: ">=8" |
| | | }; |
| | | var dependencies = { |
| | | "@angular/compiler": "8.2.13", |
| | | "@babel/code-frame": "7.5.5", |
| | | "@babel/parser": "7.7.3", |
| | | "@glimmer/syntax": "0.41.0", |
| | | "@iarna/toml": "2.2.3", |
| | | "@typescript-eslint/typescript-estree": "2.6.1", |
| | | "angular-estree-parser": "1.1.5", |
| | | "angular-html-parser": "1.3.0", |
| | | camelcase: "5.3.1", |
| | | chalk: "2.4.2", |
| | | "cjk-regex": "2.0.0", |
| | | cosmiconfig: "5.2.1", |
| | | dashify: "2.0.0", |
| | | dedent: "0.7.0", |
| | | diff: "4.0.1", |
| | | editorconfig: "0.15.3", |
| | | "editorconfig-to-prettier": "0.1.1", |
| | | "escape-string-regexp": "1.0.5", |
| | | esutils: "2.0.3", |
| | | "find-parent-dir": "0.3.0", |
| | | "find-project-root": "1.1.1", |
| | | "flow-parser": "0.111.3", |
| | | "get-stream": "4.1.0", |
| | | globby: "6.1.0", |
| | | graphql: "14.5.8", |
| | | "html-element-attributes": "2.2.0", |
| | | "html-styles": "1.0.0", |
| | | "html-tag-names": "1.1.4", |
| | | ignore: "4.0.6", |
| | | "is-ci": "2.0.0", |
| | | "jest-docblock": "24.9.0", |
| | | "json-stable-stringify": "1.0.1", |
| | | leven: "3.1.0", |
| | | "lines-and-columns": "1.1.6", |
| | | "linguist-languages": "7.6.0", |
| | | "lodash.uniqby": "4.7.0", |
| | | mem: "5.1.1", |
| | | minimatch: "3.0.4", |
| | | minimist: "1.2.0", |
| | | "n-readlines": "1.0.0", |
| | | "normalize-path": "3.0.0", |
| | | "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee", |
| | | "postcss-less": "2.0.0", |
| | | "postcss-media-query-parser": "0.2.3", |
| | | "postcss-scss": "2.0.0", |
| | | "postcss-selector-parser": "2.2.3", |
| | | "postcss-values-parser": "1.5.0", |
| | | "regexp-util": "1.2.2", |
| | | "remark-math": "1.0.6", |
| | | "remark-parse": "5.0.0", |
| | | resolve: "1.12.0", |
| | | semver: "6.3.0", |
| | | "string-width": "4.1.0", |
| | | typescript: "3.7.2", |
| | | "unicode-regex": "3.0.0", |
| | | unified: "8.4.1", |
| | | vnopts: "1.0.2", |
| | | "yaml-unist-parser": "1.1.1" |
| | | }; |
| | | var devDependencies = { |
| | | "@babel/core": "7.7.2", |
| | | "@babel/preset-env": "7.7.1", |
| | | "@rollup/plugin-alias": "2.2.0", |
| | | "@rollup/plugin-replace": "2.2.1", |
| | | "babel-loader": "8.0.6", |
| | | benchmark: "2.1.4", |
| | | "builtin-modules": "3.1.0", |
| | | codecov: "3.6.1", |
| | | "cross-env": "6.0.3", |
| | | eslint: "6.6.0", |
| | | "eslint-config-prettier": "6.5.0", |
| | | "eslint-formatter-friendly": "7.0.0", |
| | | "eslint-plugin-import": "2.18.2", |
| | | "eslint-plugin-prettier": "3.1.1", |
| | | "eslint-plugin-react": "7.16.0", |
| | | execa: "3.2.0", |
| | | jest: "23.3.0", |
| | | "jest-junit": "9.0.0", |
| | | "jest-snapshot-serializer-ansi": "1.0.0", |
| | | "jest-snapshot-serializer-raw": "1.1.0", |
| | | "jest-watch-typeahead": "0.4.0", |
| | | mkdirp: "0.5.1", |
| | | prettier: "1.19.0", |
| | | prettylint: "1.0.0", |
| | | rimraf: "3.0.0", |
| | | rollup: "1.26.3", |
| | | "rollup-plugin-babel": "4.3.3", |
| | | "rollup-plugin-commonjs": "10.1.0", |
| | | "rollup-plugin-json": "4.0.0", |
| | | "rollup-plugin-node-globals": "1.4.0", |
| | | "rollup-plugin-node-resolve": "5.2.0", |
| | | "rollup-plugin-terser": "5.1.2", |
| | | shelljs: "0.8.3", |
| | | "snapshot-diff": "0.4.0", |
| | | "strip-ansi": "5.2.0", |
| | | "synchronous-promise": "2.0.10", |
| | | tempy: "0.2.1", |
| | | "terser-webpack-plugin": "2.2.1", |
| | | webpack: "4.41.2" |
| | | }; |
| | | var scripts = { |
| | | prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1", |
| | | "prepare-release": "yarn && yarn build && yarn test:dist", |
| | | test: "jest", |
| | | "test:dist": "node ./scripts/test-dist.js", |
| | | "test-integration": "jest tests_integration", |
| | | "perf-repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", |
| | | "perf-repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", |
| | | "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", |
| | | "check-types": "tsc", |
| | | lint: "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly", |
| | | "lint-docs": "prettylint {.,docs,website,website/blog}/*.md", |
| | | "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"", |
| | | build: "node --max-old-space-size=3072 ./scripts/build/build.js", |
| | | "build-docs": "node ./scripts/build-docs.js", |
| | | "check-deps": "node ./scripts/check-deps.js", |
| | | spellcheck: "npx -p cspell@4.0.31 cspell {bin,scripts,src}/**/*.js {docs,website/blog,changelog_unreleased}/**/*.md" |
| | | }; |
| | | var _package = { |
| | | name: name, |
| | | version: version, |
| | | description: description, |
| | | bin: bin, |
| | | repository: repository, |
| | | homepage: homepage, |
| | | author: author, |
| | | license: license, |
| | | main: main, |
| | | engines: engines, |
| | | dependencies: dependencies, |
| | | devDependencies: devDependencies, |
| | | scripts: scripts |
| | | }; |
| | | `)+N}n.exports={hasPragma:l,insertPragma:C}}}),to=Z({"src/language-js/comments.js"(e,n){"use strict";ae();var{getLast:t,hasNewline:s,getNextNonSpaceNonCommentCharacterIndexWithStartIndex:i,getNextNonSpaceNonCommentCharacter:r,hasNewlineInRange:u,addLeadingComment:a,addTrailingComment:c,addDanglingComment:l,getNextNonSpaceNonCommentCharacterIndex:C,isNonEmptyArray:m}=Ge(),{getFunctionParameters:g,isPrettierIgnoreComment:p,isJsxNode:f,hasFlowShorthandAnnotationComment:h,hasFlowAnnotationComment:N,hasIgnoreComment:T,isCallLikeExpression:A,getCallArguments:b,isCallExpression:v,isMemberExpression:B,isObjectProperty:w,isLineComment:I,getComments:E,CommentCheckFlags:D,markerForIfWithoutBlockAndSameLineComment:d}=Xe(),{locStart:y,locEnd:o}=nt(),x=Pt();function F(X){return[fe,V,G,M,H,P,W,oe,de,le,Q,ge,ve,ee,K,Ee].some(Y=>Y(X))}function S(X){return[R,V,re,oe,M,H,P,W,K,q,ue,Q,xe,Ee,me].some(Y=>Y(X))}function k(X){return[fe,M,H,$,se,ee,Q,ne,U,pe,Ee,we].some(Y=>Y(X))}function _(X,Y){let te=(X.body||X.properties).find(z=>{let{type:j}=z;return j!=="EmptyStatement"});te?a(te,Y):l(X,Y)}function O(X,Y){X.type==="BlockStatement"?_(X,Y):a(X,Y)}function R(X){let{comment:Y,followingNode:te}=X;return te&&J(Y)?(a(te,Y),!0):!1}function M(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j,text:Ce}=X;if(!z||z.type!=="IfStatement"||!j)return!1;if(r(Ce,Y,o)===")")return c(te,Y),!0;if(te===z.consequent&&j===z.alternate){if(te.type==="BlockStatement")c(te,Y);else{let je=Y.type==="SingleLine"||Y.loc.start.line===Y.loc.end.line,Ue=Y.loc.start.line===te.loc.start.line;je&&Ue?l(te,Y,d):l(z,Y)}return!0}return j.type==="BlockStatement"?(_(j,Y),!0):j.type==="IfStatement"?(O(j.consequent,Y),!0):z.consequent===j?(a(j,Y),!0):!1}function H(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j,text:Ce}=X;return!z||z.type!=="WhileStatement"||!j?!1:r(Ce,Y,o)===")"?(c(te,Y),!0):j.type==="BlockStatement"?(_(j,Y),!0):z.body===j?(a(j,Y),!0):!1}function P(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j}=X;return!z||z.type!=="TryStatement"&&z.type!=="CatchClause"||!j?!1:z.type==="CatchClause"&&te?(c(te,Y),!0):j.type==="BlockStatement"?(_(j,Y),!0):j.type==="TryStatement"?(O(j.finalizer,Y),!0):j.type==="CatchClause"?(O(j.body,Y),!0):!1}function G(X){let{comment:Y,enclosingNode:te,followingNode:z}=X;return B(te)&&z&&z.type==="Identifier"?(a(te,Y),!0):!1}function re(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j,text:Ce}=X,Ne=te&&!u(Ce,o(te),y(Y));return(!te||!Ne)&&z&&(z.type==="ConditionalExpression"||z.type==="TSConditionalType")&&j?(a(j,Y),!0):!1}function $(X){let{comment:Y,precedingNode:te,enclosingNode:z}=X;return w(z)&&z.shorthand&&z.key===te&&z.value.type==="AssignmentPattern"?(c(z.value.left,Y),!0):!1}function W(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j}=X;if(z&&(z.type==="ClassDeclaration"||z.type==="ClassExpression"||z.type==="DeclareClass"||z.type==="DeclareInterface"||z.type==="InterfaceDeclaration"||z.type==="TSInterfaceDeclaration")){if(m(z.decorators)&&!(j&&j.type==="Decorator"))return c(t(z.decorators),Y),!0;if(z.body&&j===z.body)return _(z.body,Y),!0;if(j){if(z.superClass&&j===z.superClass&&te&&(te===z.id||te===z.typeParameters))return c(te,Y),!0;for(let Ce of["implements","extends","mixins"])if(z[Ce]&&j===z[Ce][0])return te&&(te===z.id||te===z.typeParameters||te===z.superClass)?c(te,Y):l(z,Y,Ce),!0}}return!1}function ee(X){let{comment:Y,precedingNode:te,enclosingNode:z,text:j}=X;return z&&te&&r(j,Y,o)==="("&&(z.type==="Property"||z.type==="TSDeclareMethod"||z.type==="TSAbstractMethodDefinition")&&te.type==="Identifier"&&z.key===te&&r(j,te,o)!==":"||te&&z&&te.type==="Decorator"&&(z.type==="ClassMethod"||z.type==="ClassProperty"||z.type==="PropertyDefinition"||z.type==="TSAbstractPropertyDefinition"||z.type==="TSAbstractMethodDefinition"||z.type==="TSDeclareMethod"||z.type==="MethodDefinition")?(c(te,Y),!0):!1}function U(X){let{comment:Y,precedingNode:te,enclosingNode:z,text:j}=X;return r(j,Y,o)!=="("?!1:te&&z&&(z.type==="FunctionDeclaration"||z.type==="FunctionExpression"||z.type==="ClassMethod"||z.type==="MethodDefinition"||z.type==="ObjectMethod")?(c(te,Y),!0):!1}function ne(X){let{comment:Y,enclosingNode:te,text:z}=X;if(!(te&&te.type==="ArrowFunctionExpression"))return!1;let j=C(z,Y,o);return j!==!1&&z.slice(j,j+2)==="=>"?(l(te,Y),!0):!1}function se(X){let{comment:Y,enclosingNode:te,text:z}=X;return r(z,Y,o)!==")"?!1:te&&(ce(te)&&g(te).length===0||A(te)&&b(te).length===0)?(l(te,Y),!0):te&&(te.type==="MethodDefinition"||te.type==="TSAbstractMethodDefinition")&&g(te.value).length===0?(l(te.value,Y),!0):!1}function V(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j,text:Ce}=X;if(te&&te.type==="FunctionTypeParam"&&z&&z.type==="FunctionTypeAnnotation"&&j&&j.type!=="FunctionTypeParam"||te&&(te.type==="Identifier"||te.type==="AssignmentPattern")&&z&&ce(z)&&r(Ce,Y,o)===")")return c(te,Y),!0;if(z&&z.type==="FunctionDeclaration"&&j&&j.type==="BlockStatement"){let Ne=(()=>{let je=g(z);if(je.length>0)return i(Ce,o(t(je)));let Ue=i(Ce,o(z.id));return Ue!==!1&&i(Ce,Ue+1)})();if(y(Y)>Ne)return _(j,Y),!0}return!1}function oe(X){let{comment:Y,enclosingNode:te}=X;return te&&te.type==="ImportSpecifier"?(a(te,Y),!0):!1}function K(X){let{comment:Y,enclosingNode:te}=X;return te&&te.type==="LabeledStatement"?(a(te,Y),!0):!1}function Ee(X){let{comment:Y,enclosingNode:te}=X;return te&&(te.type==="ContinueStatement"||te.type==="BreakStatement")&&!te.label?(c(te,Y),!0):!1}function q(X){let{comment:Y,precedingNode:te,enclosingNode:z}=X;return v(z)&&te&&z.callee===te&&z.arguments.length>0?(a(z.arguments[0],Y),!0):!1}function le(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j}=X;return z&&(z.type==="UnionTypeAnnotation"||z.type==="TSUnionType")?(p(Y)&&(j.prettierIgnore=!0,Y.unignore=!0),te?(c(te,Y),!0):!1):(j&&(j.type==="UnionTypeAnnotation"||j.type==="TSUnionType")&&p(Y)&&(j.types[0].prettierIgnore=!0,Y.unignore=!0),!1)}function ue(X){let{comment:Y,enclosingNode:te}=X;return w(te)?(a(te,Y),!0):!1}function Q(X){let{comment:Y,enclosingNode:te,followingNode:z,ast:j,isLastComment:Ce}=X;return j&&j.body&&j.body.length===0?(Ce?l(j,Y):a(j,Y),!0):te&&te.type==="Program"&&te.body.length===0&&!m(te.directives)?(Ce?l(te,Y):a(te,Y),!0):z&&z.type==="Program"&&z.body.length===0&&te&&te.type==="ModuleExpression"?(l(z,Y),!0):!1}function de(X){let{comment:Y,enclosingNode:te}=X;return te&&(te.type==="ForInStatement"||te.type==="ForOfStatement")?(a(te,Y),!0):!1}function ge(X){let{comment:Y,precedingNode:te,enclosingNode:z,text:j}=X;return te&&te.type==="ImportSpecifier"&&z&&z.type==="ImportDeclaration"&&s(j,o(Y))?(c(te,Y),!0):!1}function ve(X){let{comment:Y,enclosingNode:te}=X;return te&&te.type==="AssignmentPattern"?(a(te,Y),!0):!1}function xe(X){let{comment:Y,enclosingNode:te,followingNode:z}=X;return te&&(te.type==="VariableDeclarator"||te.type==="AssignmentExpression"||te.type==="TypeAlias"||te.type==="TSTypeAliasDeclaration")&&z&&(z.type==="ObjectExpression"||z.type==="ArrayExpression"||z.type==="TemplateLiteral"||z.type==="TaggedTemplateExpression"||z.type==="ObjectTypeAnnotation"||z.type==="TSTypeLiteral"||x(Y))?(a(z,Y),!0):!1}function we(X){let{comment:Y,enclosingNode:te,followingNode:z,text:j}=X;return!z&&te&&(te.type==="TSMethodSignature"||te.type==="TSDeclareFunction"||te.type==="TSAbstractMethodDefinition")&&r(j,Y,o)===";"?(c(te,Y),!0):!1}function fe(X){let{comment:Y,enclosingNode:te,followingNode:z}=X;if(p(Y)&&te&&te.type==="TSMappedType"&&z&&z.type==="TSTypeParameter"&&z.constraint)return te.prettierIgnore=!0,Y.unignore=!0,!0}function pe(X){let{comment:Y,precedingNode:te,enclosingNode:z,followingNode:j}=X;return!z||z.type!=="TSMappedType"?!1:j&&j.type==="TSTypeParameter"&&j.name?(a(j.name,Y),!0):te&&te.type==="TSTypeParameter"&&te.constraint?(c(te.constraint,Y),!0):!1}function me(X){let{comment:Y,enclosingNode:te,followingNode:z}=X;return!te||te.type!=="SwitchCase"||te.test?!1:(z.type==="BlockStatement"&&I(Y)?_(z,Y):l(te,Y),!0)}function ce(X){return X.type==="ArrowFunctionExpression"||X.type==="FunctionExpression"||X.type==="FunctionDeclaration"||X.type==="ObjectMethod"||X.type==="ClassMethod"||X.type==="TSDeclareFunction"||X.type==="TSCallSignatureDeclaration"||X.type==="TSConstructSignatureDeclaration"||X.type==="TSMethodSignature"||X.type==="TSConstructorType"||X.type==="TSFunctionType"||X.type==="TSDeclareMethod"}function he(X,Y){if((Y.parser==="typescript"||Y.parser==="flow"||Y.parser==="acorn"||Y.parser==="espree"||Y.parser==="meriyah"||Y.parser==="__babel_estree")&&X.type==="MethodDefinition"&&X.value&&X.value.type==="FunctionExpression"&&g(X.value).length===0&&!X.value.returnType&&!m(X.value.typeParameters)&&X.value.body)return[...X.decorators||[],X.key,X.value.body]}function J(X){return x(X)&&X.value[0]==="*"&&/@type\b/.test(X.value)}function ye(X){let Y=X.getValue(),te=X.getParentNode(),z=j=>N(E(j,D.Leading))||N(E(j,D.Trailing));return(Y&&(f(Y)||h(Y)||v(te)&&z(Y))||te&&(te.type==="JSXSpreadAttribute"||te.type==="JSXSpreadChild"||te.type==="UnionTypeAnnotation"||te.type==="TSUnionType"||(te.type==="ClassDeclaration"||te.type==="ClassExpression")&&te.superClass===Y))&&(!T(X)||te.type==="UnionTypeAnnotation"||te.type==="TSUnionType")}n.exports={handleOwnLineComment:F,handleEndOfLineComment:S,handleRemainingComment:k,isTypeCastComment:J,getCommentChildNodes:he,willPrintOwnComments:ye}}}),kt=Z({"src/language-js/needs-parens.js"(e,n){"use strict";ae();var t=st(),s=Rn(),{getFunctionParameters:i,getLeftSidePathName:r,hasFlowShorthandAnnotationComment:u,hasNakedLeftSide:a,hasNode:c,isBitwiseOperator:l,startsWithNoLookaheadToken:C,shouldFlatten:m,getPrecedence:g,isCallExpression:p,isMemberExpression:f,isObjectProperty:h}=Xe();function N(I,E){let D=I.getParentNode();if(!D)return!1;let d=I.getName(),y=I.getNode();if(E.__isInHtmlInterpolation&&!E.bracketSpacing&&v(y)&&B(I))return!0;if(T(y))return!1;if(E.parser!=="flow"&&u(I.getValue()))return!0;if(y.type==="Identifier")return!!(y.extra&&y.extra.parenthesized&&/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(y.name)||d==="left"&&y.name==="async"&&D.type==="ForOfStatement"&&!D.await);switch(D.type){case"ParenthesizedExpression":return!1;case"ClassDeclaration":case"ClassExpression":{if(d==="superClass"&&(y.type==="ArrowFunctionExpression"||y.type==="AssignmentExpression"||y.type==="AwaitExpression"||y.type==="BinaryExpression"||y.type==="ConditionalExpression"||y.type==="LogicalExpression"||y.type==="NewExpression"||y.type==="ObjectExpression"||y.type==="SequenceExpression"||y.type==="TaggedTemplateExpression"||y.type==="UnaryExpression"||y.type==="UpdateExpression"||y.type==="YieldExpression"||y.type==="TSNonNullExpression"))return!0;break}case"ExportDefaultDeclaration":return w(I,E)||y.type==="SequenceExpression";case"Decorator":{if(d==="expression"){let o=!1,x=!1,F=y;for(;F;)switch(F.type){case"MemberExpression":x=!0,F=F.object;break;case"CallExpression":if(x||o)return E.parser!=="typescript";o=!0,F=F.callee;break;case"Identifier":return!1;case"TaggedTemplateExpression":return E.parser!=="typescript";default:return!0}return!0}break}case"ExpressionStatement":{if(C(y,!0))return!0;break}case"ArrowFunctionExpression":{if(d==="body"&&y.type!=="SequenceExpression"&&C(y,!1))return!0;break}}switch(y.type){case"UpdateExpression":if(D.type==="UnaryExpression")return y.prefix&&(y.operator==="++"&&D.operator==="+"||y.operator==="--"&&D.operator==="-");case"UnaryExpression":switch(D.type){case"UnaryExpression":return y.operator===D.operator&&(y.operator==="+"||y.operator==="-");case"BindExpression":return!0;case"MemberExpression":case"OptionalMemberExpression":return d==="object";case"TaggedTemplateExpression":return!0;case"NewExpression":case"CallExpression":case"OptionalCallExpression":return d==="callee";case"BinaryExpression":return d==="left"&&D.operator==="**";case"TSNonNullExpression":return!0;default:return!1}case"BinaryExpression":{if(D.type==="UpdateExpression"||y.operator==="in"&&A(I))return!0;if(y.operator==="|>"&&y.extra&&y.extra.parenthesized){let o=I.getParentNode(1);if(o.type==="BinaryExpression"&&o.operator==="|>")return!0}}case"TSTypeAssertion":case"TSAsExpression":case"LogicalExpression":switch(D.type){case"TSAsExpression":return y.type!=="TSAsExpression";case"ConditionalExpression":return y.type==="TSAsExpression";case"CallExpression":case"NewExpression":case"OptionalCallExpression":return d==="callee";case"ClassExpression":case"ClassDeclaration":return d==="superClass";case"TSTypeAssertion":case"TaggedTemplateExpression":case"UnaryExpression":case"JSXSpreadAttribute":case"SpreadElement":case"SpreadProperty":case"BindExpression":case"AwaitExpression":case"TSNonNullExpression":case"UpdateExpression":return!0;case"MemberExpression":case"OptionalMemberExpression":return d==="object";case"AssignmentExpression":case"AssignmentPattern":return d==="left"&&(y.type==="TSTypeAssertion"||y.type==="TSAsExpression");case"LogicalExpression":if(y.type==="LogicalExpression")return D.operator!==y.operator;case"BinaryExpression":{let{operator:o,type:x}=y;if(!o&&x!=="TSTypeAssertion")return!0;let F=g(o),S=D.operator,k=g(S);return k>F||d==="right"&&k===F||k===F&&!m(S,o)?!0:k<F&&o==="%"?S==="+"||S==="-":!!l(S)}default:return!1}case"SequenceExpression":switch(D.type){case"ReturnStatement":return!1;case"ForStatement":return!1;case"ExpressionStatement":return d!=="expression";case"ArrowFunctionExpression":return d!=="body";default:return!0}case"YieldExpression":if(D.type==="UnaryExpression"||D.type==="AwaitExpression"||D.type==="TSAsExpression"||D.type==="TSNonNullExpression")return!0;case"AwaitExpression":switch(D.type){case"TaggedTemplateExpression":case"UnaryExpression":case"LogicalExpression":case"SpreadElement":case"SpreadProperty":case"TSAsExpression":case"TSNonNullExpression":case"BindExpression":return!0;case"MemberExpression":case"OptionalMemberExpression":return d==="object";case"NewExpression":case"CallExpression":case"OptionalCallExpression":return d==="callee";case"ConditionalExpression":return d==="test";case"BinaryExpression":return!(!y.argument&&D.operator==="|>");default:return!1}case"TSConditionalType":if(d==="extendsType"&&D.type==="TSConditionalType")return!0;case"TSFunctionType":case"TSConstructorType":if(d==="checkType"&&D.type==="TSConditionalType")return!0;case"TSUnionType":case"TSIntersectionType":if((D.type==="TSUnionType"||D.type==="TSIntersectionType")&&D.types.length>1&&(!y.types||y.types.length>1))return!0;case"TSInferType":if(y.type==="TSInferType"&&D.type==="TSRestType")return!1;case"TSTypeOperator":return D.type==="TSArrayType"||D.type==="TSOptionalType"||D.type==="TSRestType"||d==="objectType"&&D.type==="TSIndexedAccessType"||D.type==="TSTypeOperator"||D.type==="TSTypeAnnotation"&&I.getParentNode(1).type.startsWith("TSJSDoc");case"ArrayTypeAnnotation":return D.type==="NullableTypeAnnotation";case"IntersectionTypeAnnotation":case"UnionTypeAnnotation":return D.type==="ArrayTypeAnnotation"||D.type==="NullableTypeAnnotation"||D.type==="IntersectionTypeAnnotation"||D.type==="UnionTypeAnnotation"||d==="objectType"&&(D.type==="IndexedAccessType"||D.type==="OptionalIndexedAccessType");case"NullableTypeAnnotation":return D.type==="ArrayTypeAnnotation"||d==="objectType"&&(D.type==="IndexedAccessType"||D.type==="OptionalIndexedAccessType");case"FunctionTypeAnnotation":{let o=D.type==="NullableTypeAnnotation"?I.getParentNode(1):D;return o.type==="UnionTypeAnnotation"||o.type==="IntersectionTypeAnnotation"||o.type==="ArrayTypeAnnotation"||d==="objectType"&&(o.type==="IndexedAccessType"||o.type==="OptionalIndexedAccessType")||o.type==="NullableTypeAnnotation"||D.type==="FunctionTypeParam"&&D.name===null&&i(y).some(x=>x.typeAnnotation&&x.typeAnnotation.type==="NullableTypeAnnotation")}case"OptionalIndexedAccessType":return d==="objectType"&&D.type==="IndexedAccessType";case"TypeofTypeAnnotation":return d==="objectType"&&(D.type==="IndexedAccessType"||D.type==="OptionalIndexedAccessType");case"StringLiteral":case"NumericLiteral":case"Literal":if(typeof y.value=="string"&&D.type==="ExpressionStatement"&&!D.directive){let o=I.getParentNode(1);return o.type==="Program"||o.type==="BlockStatement"}return d==="object"&&D.type==="MemberExpression"&&typeof y.value=="number";case"AssignmentExpression":{let o=I.getParentNode(1);return d==="body"&&D.type==="ArrowFunctionExpression"?!0:d==="key"&&(D.type==="ClassProperty"||D.type==="PropertyDefinition")&&D.computed||(d==="init"||d==="update")&&D.type==="ForStatement"?!1:D.type==="ExpressionStatement"?y.left.type==="ObjectPattern":!(d==="key"&&D.type==="TSPropertySignature"||D.type==="AssignmentExpression"||D.type==="SequenceExpression"&&o&&o.type==="ForStatement"&&(o.init===D||o.update===D)||d==="value"&&D.type==="Property"&&o&&o.type==="ObjectPattern"&&o.properties.includes(D)||D.type==="NGChainedExpression")}case"ConditionalExpression":switch(D.type){case"TaggedTemplateExpression":case"UnaryExpression":case"SpreadElement":case"SpreadProperty":case"BinaryExpression":case"LogicalExpression":case"NGPipeExpression":case"ExportDefaultDeclaration":case"AwaitExpression":case"JSXSpreadAttribute":case"TSTypeAssertion":case"TypeCastExpression":case"TSAsExpression":case"TSNonNullExpression":return!0;case"NewExpression":case"CallExpression":case"OptionalCallExpression":return d==="callee";case"ConditionalExpression":return d==="test";case"MemberExpression":case"OptionalMemberExpression":return d==="object";default:return!1}case"FunctionExpression":switch(D.type){case"NewExpression":case"CallExpression":case"OptionalCallExpression":return d==="callee";case"TaggedTemplateExpression":return!0;default:return!1}case"ArrowFunctionExpression":switch(D.type){case"BinaryExpression":return D.operator!=="|>"||y.extra&&y.extra.parenthesized;case"NewExpression":case"CallExpression":case"OptionalCallExpression":return d==="callee";case"MemberExpression":case"OptionalMemberExpression":return d==="object";case"TSAsExpression":case"TSNonNullExpression":case"BindExpression":case"TaggedTemplateExpression":case"UnaryExpression":case"LogicalExpression":case"AwaitExpression":case"TSTypeAssertion":return!0;case"ConditionalExpression":return d==="test";default:return!1}case"ClassExpression":if(s(y.decorators))return!0;switch(D.type){case"NewExpression":return d==="callee";default:return!1}case"OptionalMemberExpression":case"OptionalCallExpression":{let o=I.getParentNode(1);if(d==="object"&&D.type==="MemberExpression"||d==="callee"&&(D.type==="CallExpression"||D.type==="NewExpression")||D.type==="TSNonNullExpression"&&o.type==="MemberExpression"&&o.object===D)return!0}case"CallExpression":case"MemberExpression":case"TaggedTemplateExpression":case"TSNonNullExpression":if(d==="callee"&&(D.type==="BindExpression"||D.type==="NewExpression")){let o=y;for(;o;)switch(o.type){case"CallExpression":case"OptionalCallExpression":return!0;case"MemberExpression":case"OptionalMemberExpression":case"BindExpression":o=o.object;break;case"TaggedTemplateExpression":o=o.tag;break;case"TSNonNullExpression":o=o.expression;break;default:return!1}}return!1;case"BindExpression":return d==="callee"&&(D.type==="BindExpression"||D.type==="NewExpression")||d==="object"&&f(D);case"NGPipeExpression":return!(D.type==="NGRoot"||D.type==="NGMicrosyntaxExpression"||D.type==="ObjectProperty"&&!(y.extra&&y.extra.parenthesized)||D.type==="ArrayExpression"||p(D)&&D.arguments[d]===y||d==="right"&&D.type==="NGPipeExpression"||d==="property"&&D.type==="MemberExpression"||D.type==="AssignmentExpression");case"JSXFragment":case"JSXElement":return d==="callee"||d==="left"&&D.type==="BinaryExpression"&&D.operator==="<"||D.type!=="ArrayExpression"&&D.type!=="ArrowFunctionExpression"&&D.type!=="AssignmentExpression"&&D.type!=="AssignmentPattern"&&D.type!=="BinaryExpression"&&D.type!=="NewExpression"&&D.type!=="ConditionalExpression"&&D.type!=="ExpressionStatement"&&D.type!=="JsExpressionRoot"&&D.type!=="JSXAttribute"&&D.type!=="JSXElement"&&D.type!=="JSXExpressionContainer"&&D.type!=="JSXFragment"&&D.type!=="LogicalExpression"&&!p(D)&&!h(D)&&D.type!=="ReturnStatement"&&D.type!=="ThrowStatement"&&D.type!=="TypeCastExpression"&&D.type!=="VariableDeclarator"&&D.type!=="YieldExpression";case"TypeAnnotation":return d==="returnType"&&D.type==="ArrowFunctionExpression"&&b(y)}return!1}function T(I){return I.type==="BlockStatement"||I.type==="BreakStatement"||I.type==="ClassBody"||I.type==="ClassDeclaration"||I.type==="ClassMethod"||I.type==="ClassProperty"||I.type==="PropertyDefinition"||I.type==="ClassPrivateProperty"||I.type==="ContinueStatement"||I.type==="DebuggerStatement"||I.type==="DeclareClass"||I.type==="DeclareExportAllDeclaration"||I.type==="DeclareExportDeclaration"||I.type==="DeclareFunction"||I.type==="DeclareInterface"||I.type==="DeclareModule"||I.type==="DeclareModuleExports"||I.type==="DeclareVariable"||I.type==="DoWhileStatement"||I.type==="EnumDeclaration"||I.type==="ExportAllDeclaration"||I.type==="ExportDefaultDeclaration"||I.type==="ExportNamedDeclaration"||I.type==="ExpressionStatement"||I.type==="ForInStatement"||I.type==="ForOfStatement"||I.type==="ForStatement"||I.type==="FunctionDeclaration"||I.type==="IfStatement"||I.type==="ImportDeclaration"||I.type==="InterfaceDeclaration"||I.type==="LabeledStatement"||I.type==="MethodDefinition"||I.type==="ReturnStatement"||I.type==="SwitchStatement"||I.type==="ThrowStatement"||I.type==="TryStatement"||I.type==="TSDeclareFunction"||I.type==="TSEnumDeclaration"||I.type==="TSImportEqualsDeclaration"||I.type==="TSInterfaceDeclaration"||I.type==="TSModuleDeclaration"||I.type==="TSNamespaceExportDeclaration"||I.type==="TypeAlias"||I.type==="VariableDeclaration"||I.type==="WhileStatement"||I.type==="WithStatement"}function A(I){let E=0,D=I.getValue();for(;D;){let d=I.getParentNode(E++);if(d&&d.type==="ForStatement"&&d.init===D)return!0;D=d}return!1}function b(I){return c(I,E=>E.type==="ObjectTypeAnnotation"&&c(E,D=>D.type==="FunctionTypeAnnotation"||void 0)||void 0)}function v(I){switch(I.type){case"ObjectExpression":return!0;default:return!1}}function B(I){let E=I.getValue(),D=I.getParentNode(),d=I.getName();switch(D.type){case"NGPipeExpression":if(typeof d=="number"&&D.arguments[d]===E&&D.arguments.length-1===d)return I.callParent(B);break;case"ObjectProperty":if(d==="value"){let y=I.getParentNode(1);return t(y.properties)===D}break;case"BinaryExpression":case"LogicalExpression":if(d==="right")return I.callParent(B);break;case"ConditionalExpression":if(d==="alternate")return I.callParent(B);break;case"UnaryExpression":if(D.prefix)return I.callParent(B);break}return!1}function w(I,E){let D=I.getValue(),d=I.getParentNode();return D.type==="FunctionExpression"||D.type==="ClassExpression"?d.type==="ExportDefaultDeclaration"||!N(I,E):!a(D)||d.type!=="ExportDefaultDeclaration"&&N(I,E)?!1:I.call(y=>w(y,E),...r(I,D))}n.exports=N}}),ro=Z({"src/language-js/print-preprocess.js"(e,n){"use strict";ae();function t(s,i){switch(i.parser){case"json":case"json5":case"json-stringify":case"__js_expression":case"__vue_expression":return Object.assign(Object.assign({},s),{},{type:i.parser.startsWith("__")?"JsExpressionRoot":"JsonRoot",node:s,comments:[],rootMarker:i.rootMarker});default:return s}}n.exports=t}}),bm=Z({"src/language-js/print/html-binding.js"(e,n){"use strict";ae();var{builders:{join:t,line:s,group:i,softline:r,indent:u}}=Le();function a(l,C,m){let g=l.getValue();if(C.__onHtmlBindingRoot&&l.getName()===null&&C.__onHtmlBindingRoot(g,C),g.type==="File"){if(C.__isVueForBindingLeft)return l.call(p=>{let f=t([",",s],p.map(m,"params")),{params:h}=p.getValue();return h.length===1?f:["(",u([r,i(f)]),r,")"]},"program","body",0);if(C.__isVueBindings)return l.call(p=>t([",",s],p.map(m,"params")),"program","body",0)}}function c(l){switch(l.type){case"MemberExpression":switch(l.property.type){case"Identifier":case"NumericLiteral":case"StringLiteral":return c(l.object)}return!1;case"Identifier":return!0;default:return!1}}n.exports={isVueEventBindingExpression:c,printHtmlBinding:a}}}),Jn=Z({"src/language-js/print/binaryish.js"(e,n){"use strict";ae();var{printComments:t}=Qe(),{getLast:s}=Ge(),{builders:{join:i,line:r,softline:u,group:a,indent:c,align:l,ifBreak:C,indentIfBreak:m},utils:{cleanDoc:g,getDocParts:p,isConcat:f}}=Le(),{hasLeadingOwnLineComment:h,isBinaryish:N,isJsxNode:T,shouldFlatten:A,hasComment:b,CommentCheckFlags:v,isCallExpression:B,isMemberExpression:w,isObjectProperty:I,isEnabledHackPipeline:E}=Xe(),D=0;function d(x,F,S){let k=x.getValue(),_=x.getParentNode(),O=x.getParentNode(1),R=k!==_.body&&(_.type==="IfStatement"||_.type==="WhileStatement"||_.type==="SwitchStatement"||_.type==="DoWhileStatement"),M=E(F)&&k.operator==="|>",H=y(x,S,F,!1,R);if(R)return H;if(M)return a(H);if(B(_)&&_.callee===k||_.type==="UnaryExpression"||w(_)&&!_.computed)return a([c([u,...H]),u]);let P=_.type==="ReturnStatement"||_.type==="ThrowStatement"||_.type==="JSXExpressionContainer"&&O.type==="JSXAttribute"||k.operator!=="|"&&_.type==="JsExpressionRoot"||k.type!=="NGPipeExpression"&&(_.type==="NGRoot"&&F.parser==="__ng_binding"||_.type==="NGMicrosyntaxExpression"&&O.type==="NGMicrosyntax"&&O.body.length===1)||k===_.body&&_.type==="ArrowFunctionExpression"||k!==_.body&&_.type==="ForStatement"||_.type==="ConditionalExpression"&&O.type!=="ReturnStatement"&&O.type!=="ThrowStatement"&&!B(O)||_.type==="TemplateLiteral",G=_.type==="AssignmentExpression"||_.type==="VariableDeclarator"||_.type==="ClassProperty"||_.type==="PropertyDefinition"||_.type==="TSAbstractPropertyDefinition"||_.type==="ClassPrivateProperty"||I(_),re=N(k.left)&&A(k.operator,k.left.operator);if(P||o(k)&&!re||!o(k)&&G)return a(H);if(H.length===0)return"";let $=T(k.right),W=H.findIndex(oe=>typeof oe!="string"&&!Array.isArray(oe)&&oe.type==="group"),ee=H.slice(0,W===-1?1:W+1),U=H.slice(ee.length,$?-1:void 0),ne=Symbol("logicalChain-"+ ++D),se=a([...ee,c(U)],{id:ne});if(!$)return se;let V=s(H);return a([se,m(V,{groupId:ne})])}function y(x,F,S,k,_){let O=x.getValue();if(!N(O))return[a(F())];let R=[];A(O.operator,O.left.operator)?R=x.call(U=>y(U,F,S,!0,_),"left"):R.push(a(F("left")));let M=o(O),H=(O.operator==="|>"||O.type==="NGPipeExpression"||O.operator==="|"&&S.parser==="__vue_expression")&&!h(S.originalText,O.right),P=O.type==="NGPipeExpression"?"|":O.operator,G=O.type==="NGPipeExpression"&&O.arguments.length>0?a(c([u,": ",i([u,":",C(" ")],x.map(F,"arguments").map(U=>l(2,a(U))))])):"",re;if(M)re=[P," ",F("right"),G];else{let ne=E(S)&&P==="|>"?x.call(se=>y(se,F,S,!0,_),"right"):F("right");re=[H?r:"",P,H?" ":r,ne,G]}let $=x.getParentNode(),W=b(O.left,v.Trailing|v.Line),ee=W||!(_&&O.type==="LogicalExpression")&&$.type!==O.type&&O.left.type!==O.type&&O.right.type!==O.type;if(R.push(H?"":" ",ee?a(re,{shouldBreak:W}):re),k&&b(O)){let U=g(t(x,R,S));return f(U)||U.type==="fill"?p(U):[U]}return R}function o(x){return x.type!=="LogicalExpression"?!1:!!(x.right.type==="ObjectExpression"&&x.right.properties.length>0||x.right.type==="ArrayExpression"&&x.right.elements.length>0||T(x.right))}n.exports={printBinaryishExpression:d,shouldInlineLogicalExpression:o}}}),Tm=Z({"src/language-js/print/angular.js"(e,n){"use strict";ae();var{builders:{join:t,line:s,group:i}}=Le(),{hasNode:r,hasComment:u,getComments:a}=Xe(),{printBinaryishExpression:c}=Jn();function l(g,p,f){let h=g.getValue();if(!!h.type.startsWith("NG"))switch(h.type){case"NGRoot":return[f("node"),u(h.node)?" //"+a(h.node)[0].value.trimEnd():""];case"NGPipeExpression":return c(g,p,f);case"NGChainedExpression":return i(t([";",s],g.map(N=>m(N)?f():["(",f(),")"],"expressions")));case"NGEmptyExpression":return"";case"NGQuotedExpression":return[h.prefix,": ",h.value.trim()];case"NGMicrosyntax":return g.map((N,T)=>[T===0?"":C(N.getValue(),T,h)?" ":[";",s],f()],"body");case"NGMicrosyntaxKey":return/^[$_a-z][\w$]*(?:-[$_a-z][\w$])*$/i.test(h.name)?h.name:JSON.stringify(h.name);case"NGMicrosyntaxExpression":return[f("expression"),h.alias===null?"":[" as ",f("alias")]];case"NGMicrosyntaxKeyedExpression":{let N=g.getName(),T=g.getParentNode(),A=C(h,N,T)||(N===1&&(h.key.name==="then"||h.key.name==="else")||N===2&&h.key.name==="else"&&T.body[N-1].type==="NGMicrosyntaxKeyedExpression"&&T.body[N-1].key.name==="then")&&T.body[0].type==="NGMicrosyntaxExpression";return[f("key"),A?" ":": ",f("expression")]}case"NGMicrosyntaxLet":return["let ",f("key"),h.value===null?"":[" = ",f("value")]];case"NGMicrosyntaxAs":return[f("key")," as ",f("alias")];default:throw new Error("Unknown Angular node type: ".concat(JSON.stringify(h.type),"."))}}function C(g,p,f){return g.type==="NGMicrosyntaxKeyedExpression"&&g.key.name==="of"&&p===1&&f.body[0].type==="NGMicrosyntaxLet"&&f.body[0].value===null}function m(g){return r(g.getValue(),p=>{switch(p.type){case void 0:return!1;case"CallExpression":case"OptionalCallExpression":case"AssignmentExpression":return!0}})}n.exports={printAngular:l}}}),Bm=Z({"src/language-js/print/jsx.js"(e,n){"use strict";ae();var{printComments:t,printDanglingComments:s}=Qe(),{builders:{line:i,hardline:r,softline:u,group:a,indent:c,conditionalGroup:l,fill:C,ifBreak:m,lineSuffixBoundary:g,join:p},utils:{willBreak:f}}=Le(),{getLast:h,getPreferredQuote:N}=Ge(),{isJsxNode:T,rawText:A,isLiteral:b,isCallExpression:v,isStringLiteral:B,isBinaryish:w,hasComment:I,CommentCheckFlags:E,hasNodeIgnoreComment:D}=Xe(),d=kt(),{willPrintOwnComments:y}=to(),o=q=>q===""||q===i||q===r||q===u;function x(q,le,ue){let Q=q.getValue();if(Q.type==="JSXElement"&&V(Q))return[ue("openingElement"),ue("closingElement")];let de=Q.type==="JSXElement"?ue("openingElement"):ue("openingFragment"),ge=Q.type==="JSXElement"?ue("closingElement"):ue("closingFragment");if(Q.children.length===1&&Q.children[0].type==="JSXExpressionContainer"&&(Q.children[0].expression.type==="TemplateLiteral"||Q.children[0].expression.type==="TaggedTemplateExpression"))return[de,...q.map(ue,"children"),ge];Q.children=Q.children.map(z=>K(z)?{type:"JSXText",value:" ",raw:" "}:z);let ve=Q.children.some(T),xe=Q.children.filter(z=>z.type==="JSXExpressionContainer").length>1,we=Q.type==="JSXElement"&&Q.openingElement.attributes.length>1,fe=f(de)||ve||we||xe,pe=q.getParentNode().rootMarker==="mdx",me=le.singleQuote?"{' '}":'{" "}',ce=pe?" ":m([me,u]," "),he=Q.openingElement&&Q.openingElement.name&&Q.openingElement.name.name==="fbt",J=F(q,le,ue,ce,he),ye=Q.children.some(z=>oe(z));for(let z=J.length-2;z>=0;z--){let j=J[z]===""&&J[z+1]==="",Ce=J[z]===r&&J[z+1]===""&&J[z+2]===r,Ne=(J[z]===u||J[z]===r)&&J[z+1]===""&&J[z+2]===ce,je=J[z]===ce&&J[z+1]===""&&(J[z+2]===u||J[z+2]===r),Ue=J[z]===ce&&J[z+1]===""&&J[z+2]===ce,tt=J[z]===u&&J[z+1]===""&&J[z+2]===r||J[z]===r&&J[z+1]===""&&J[z+2]===u;Ce&&ye||j||Ne||Ue||tt?J.splice(z,2):je&&J.splice(z+1,2)}for(;J.length>0&&o(h(J));)J.pop();for(;J.length>1&&o(J[0])&&o(J[1]);)J.shift(),J.shift();let X=[];for(let[z,j]of J.entries()){if(j===ce){if(z===1&&J[z-1]===""){if(J.length===2){X.push(me);continue}X.push([me,r]);continue}else if(z===J.length-1){X.push(me);continue}else if(J[z-1]===""&&J[z-2]===r){X.push(me);continue}}X.push(j),f(j)&&(fe=!0)}let Y=ye?C(X):a(X,{shouldBreak:!0});if(pe)return Y;let te=a([de,c([r,Y]),r,ge]);return fe?te:l([a([de,...J,ge]),te])}function F(q,le,ue,Q,de){let ge=[];return q.each((ve,xe,we)=>{let fe=ve.getValue();if(b(fe)){let pe=A(fe);if(oe(fe)){let me=pe.split(U);if(me[0]===""){if(ge.push(""),me.shift(),/\n/.test(me[0])){let he=we[xe+1];ge.push(k(de,me[1],fe,he))}else ge.push(Q);me.shift()}let ce;if(h(me)===""&&(me.pop(),ce=me.pop()),me.length===0)return;for(let[he,J]of me.entries())he%2===1?ge.push(i):ge.push(J);if(ce!==void 0)if(/\n/.test(ce)){let he=we[xe+1];ge.push(k(de,h(ge),fe,he))}else ge.push(Q);else{let he=we[xe+1];ge.push(S(de,h(ge),fe,he))}}else/\n/.test(pe)?pe.match(/\n/g).length>1&&ge.push("",r):ge.push("",Q)}else{let pe=ue();ge.push(pe);let me=we[xe+1];if(me&&oe(me)){let he=se(A(me)).split(U)[0];ge.push(S(de,he,fe,me))}else ge.push(r)}},"children"),ge}function S(q,le,ue,Q){return q?"":ue.type==="JSXElement"&&!ue.closingElement||Q&&Q.type==="JSXElement"&&!Q.closingElement?le.length===1?u:r:u}function k(q,le,ue,Q){return q?r:le.length===1?ue.type==="JSXElement"&&!ue.closingElement||Q&&Q.type==="JSXElement"&&!Q.closingElement?r:u:r}function _(q,le,ue){let Q=q.getParentNode();if(!Q||{ArrayExpression:!0,JSXAttribute:!0,JSXElement:!0,JSXExpressionContainer:!0,JSXFragment:!0,ExpressionStatement:!0,CallExpression:!0,OptionalCallExpression:!0,ConditionalExpression:!0,JsExpressionRoot:!0}[Q.type])return le;let ge=q.match(void 0,xe=>xe.type==="ArrowFunctionExpression",v,xe=>xe.type==="JSXExpressionContainer"),ve=d(q,ue);return a([ve?"":m("("),c([u,le]),u,ve?"":m(")")],{shouldBreak:ge})}function O(q,le,ue){let Q=q.getValue(),de=[];if(de.push(ue("name")),Q.value){let ge;if(B(Q.value)){let xe=A(Q.value).slice(1,-1).replace(/'/g,"'").replace(/"/g,'"'),{escaped:we,quote:fe,regex:pe}=N(xe,le.jsxSingleQuote?"'":'"');xe=xe.replace(pe,we),ge=[fe,xe,fe]}else ge=ue("value");de.push("=",ge)}return de}function R(q,le,ue){let Q=q.getValue(),de=(ge,ve)=>ge.type==="JSXEmptyExpression"||!I(ge)&&(ge.type==="ArrayExpression"||ge.type==="ObjectExpression"||ge.type==="ArrowFunctionExpression"||ge.type==="AwaitExpression"&&(de(ge.argument,ge)||ge.argument.type==="JSXElement")||v(ge)||ge.type==="FunctionExpression"||ge.type==="TemplateLiteral"||ge.type==="TaggedTemplateExpression"||ge.type==="DoExpression"||T(ve)&&(ge.type==="ConditionalExpression"||w(ge)));return de(Q.expression,q.getParentNode(0))?a(["{",ue("expression"),g,"}"]):a(["{",c([u,ue("expression")]),u,g,"}"])}function M(q,le,ue){let Q=q.getValue(),de=Q.name&&I(Q.name)||Q.typeParameters&&I(Q.typeParameters);if(Q.selfClosing&&Q.attributes.length===0&&!de)return["<",ue("name"),ue("typeParameters")," />"];if(Q.attributes&&Q.attributes.length===1&&Q.attributes[0].value&&B(Q.attributes[0].value)&&!Q.attributes[0].value.value.includes(` |
| | | `)&&!de&&!I(Q.attributes[0]))return a(["<",ue("name"),ue("typeParameters")," ",...q.map(ue,"attributes"),Q.selfClosing?" />":">"]);let ge=Q.attributes.length>0&&I(h(Q.attributes),E.Trailing),ve=Q.attributes.length===0&&!de||(le.bracketSameLine||le.jsxBracketSameLine)&&(!de||Q.attributes.length>0)&&!ge,xe=Q.attributes&&Q.attributes.some(fe=>fe.value&&B(fe.value)&&fe.value.value.includes(` |
| | | `)),we=le.singleAttributePerLine&&Q.attributes.length>1?r:i;return a(["<",ue("name"),ue("typeParameters"),c(q.map(()=>[we,ue()],"attributes")),Q.selfClosing?i:ve?">":u,Q.selfClosing?"/>":ve?"":">"],{shouldBreak:xe})}function H(q,le,ue){let Q=q.getValue(),de=[];de.push("</");let ge=ue("name");return I(Q.name,E.Leading|E.Line)?de.push(c([r,ge]),r):I(Q.name,E.Leading|E.Block)?de.push(" ",ge):de.push(ge),de.push(">"),de}function P(q,le){let ue=q.getValue(),Q=I(ue),de=I(ue,E.Line),ge=ue.type==="JSXOpeningFragment";return[ge?"<":"</",c([de?r:Q&&!ge?" ":"",s(q,le,!0)]),de?r:"",">"]}function G(q,le,ue){let Q=t(q,x(q,le,ue),le);return _(q,Q,le)}function re(q,le){let ue=q.getValue(),Q=I(ue,E.Line);return[s(q,le,!Q),Q?r:""]}function $(q,le,ue){let Q=q.getValue();return["{",q.call(de=>{let ge=["...",ue()],ve=de.getValue();return!I(ve)||!y(de)?ge:[c([u,t(de,ge,le)]),u]},Q.type==="JSXSpreadAttribute"?"argument":"expression"),"}"]}function W(q,le,ue){let Q=q.getValue();if(!!Q.type.startsWith("JSX"))switch(Q.type){case"JSXAttribute":return O(q,le,ue);case"JSXIdentifier":return String(Q.name);case"JSXNamespacedName":return p(":",[ue("namespace"),ue("name")]);case"JSXMemberExpression":return p(".",[ue("object"),ue("property")]);case"JSXSpreadAttribute":return $(q,le,ue);case"JSXSpreadChild":return $(q,le,ue);case"JSXExpressionContainer":return R(q,le,ue);case"JSXFragment":case"JSXElement":return G(q,le,ue);case"JSXOpeningElement":return M(q,le,ue);case"JSXClosingElement":return H(q,le,ue);case"JSXOpeningFragment":case"JSXClosingFragment":return P(q,le);case"JSXEmptyExpression":return re(q,le);case"JSXText":throw new Error("JSXTest should be handled by JSXElement");default:throw new Error("Unknown JSX node type: ".concat(JSON.stringify(Q.type),"."))}}var ee=` |
| | | \r `,U=new RegExp("(["+ee+"]+)"),ne=new RegExp("[^"+ee+"]"),se=q=>q.replace(new RegExp("(?:^"+U.source+"|"+U.source+"$)"),"");function V(q){if(q.children.length===0)return!0;if(q.children.length>1)return!1;let le=q.children[0];return b(le)&&!oe(le)}function oe(q){return b(q)&&(ne.test(A(q))||!/\n/.test(A(q)))}function K(q){return q.type==="JSXExpressionContainer"&&b(q.expression)&&q.expression.value===" "&&!I(q.expression)}function Ee(q){let le=q.getValue(),ue=q.getParentNode();if(!ue||!le||!T(le)||!T(ue))return!1;let Q=ue.children.indexOf(le),de=null;for(let ge=Q;ge>0;ge--){let ve=ue.children[ge-1];if(!(ve.type==="JSXText"&&!oe(ve))){de=ve;break}}return de&&de.type==="JSXExpressionContainer"&&de.expression.type==="JSXEmptyExpression"&&D(de.expression)}n.exports={hasJsxIgnoreComment:Ee,printJsx:W}}}),ot=Z({"src/language-js/print/misc.js"(e,n){"use strict";ae();var{isNonEmptyArray:t}=Ge(),{builders:{indent:s,join:i,line:r}}=Le(),{isFlowAnnotationComment:u}=Xe();function a(h){let N=h.getValue();return!N.optional||N.type==="Identifier"&&N===h.getParentNode().key?"":N.type==="OptionalCallExpression"||N.type==="OptionalMemberExpression"&&N.computed?"?.":"?"}function c(h){return h.getValue().definite||h.match(void 0,(N,T)=>T==="id"&&N.type==="VariableDeclarator"&&N.definite)?"!":""}function l(h,N,T){let A=h.getValue();return A.typeArguments?T("typeArguments"):A.typeParameters?T("typeParameters"):""}function C(h,N,T){let A=h.getValue();if(!A.typeAnnotation)return"";let b=h.getParentNode(),v=b.type==="DeclareFunction"&&b.id===A;return u(N.originalText,A.typeAnnotation)?[" /*: ",T("typeAnnotation")," */"]:[v?"":": ",T("typeAnnotation")]}function m(h,N,T){return["::",T("callee")]}function g(h,N,T){let A=h.getValue();return t(A.modifiers)?[i(" ",h.map(T,"modifiers"))," "]:""}function p(h,N,T){return h.type==="EmptyStatement"?";":h.type==="BlockStatement"||T?[" ",N]:s([r,N])}function f(h,N,T){return["...",T("argument"),C(h,N,T)]}n.exports={printOptionalToken:a,printDefiniteToken:c,printFunctionTypeParameters:l,printBindExpressionCallee:m,printTypeScriptModifiers:g,printTypeAnnotation:C,printRestSpread:f,adjustClause:p}}}),zt=Z({"src/language-js/print/array.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{builders:{line:s,softline:i,hardline:r,group:u,indent:a,ifBreak:c,fill:l}}=Le(),{getLast:C,hasNewline:m}=Ge(),{shouldPrintComma:g,hasComment:p,CommentCheckFlags:f,isNextLineEmpty:h,isNumericLiteral:N,isSignedNumericLiteral:T}=Xe(),{locStart:A}=nt(),{printOptionalToken:b,printTypeAnnotation:v}=ot();function B(D,d,y){let o=D.getValue(),x=[],F=o.type==="TupleExpression"?"#[":"[",S="]";if(o.elements.length===0)p(o,f.Dangling)?x.push(u([F,t(D,d),i,S])):x.push(F,S);else{let k=C(o.elements),_=!(k&&k.type==="RestElement"),O=k===null,R=Symbol("array"),M=!d.__inJestEach&&o.elements.length>1&&o.elements.every((G,re,$)=>{let W=G&&G.type;if(W!=="ArrayExpression"&&W!=="ObjectExpression")return!1;let ee=$[re+1];if(ee&&W!==ee.type)return!1;let U=W==="ArrayExpression"?"elements":"properties";return G[U]&&G[U].length>1}),H=w(o,d),P=_?O?",":g(d)?H?c(",","",{groupId:R}):c(","):"":"";x.push(u([F,a([i,H?E(D,d,y,P):[I(D,d,"elements",y),P],t(D,d,!0)]),i,S],{shouldBreak:M,id:R}))}return x.push(b(D),v(D,d,y)),x}function w(D,d){return D.elements.length>1&&D.elements.every(y=>y&&(N(y)||T(y)&&!p(y.argument))&&!p(y,f.Trailing|f.Line,o=>!m(d.originalText,A(o),{backwards:!0})))}function I(D,d,y,o){let x=[],F=[];return D.each(S=>{x.push(F,u(o())),F=[",",s],S.getValue()&&h(S.getValue(),d)&&F.push(i)},y),x}function E(D,d,y,o){let x=[];return D.each((F,S,k)=>{let _=S===k.length-1;x.push([y(),_?o:","]),_||x.push(h(F.getValue(),d)?[r,r]:p(k[S+1],f.Leading|f.Line)?r:s)},"elements"),l(x)}n.exports={printArray:B,printArrayItems:I,isConciselyPrintedArray:w}}}),no=Z({"src/language-js/print/call-arguments.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{getLast:s,getPenultimate:i}=Ge(),{getFunctionParameters:r,hasComment:u,CommentCheckFlags:a,isFunctionCompositionArgs:c,isJsxNode:l,isLongCurriedCallExpression:C,shouldPrintComma:m,getCallArguments:g,iterateCallArgumentsPath:p,isNextLineEmpty:f,isCallExpression:h,isStringLiteral:N,isObjectProperty:T}=Xe(),{builders:{line:A,hardline:b,softline:v,group:B,indent:w,conditionalGroup:I,ifBreak:E,breakParent:D},utils:{willBreak:d}}=Le(),{ArgExpansionBailout:y}=Jt(),{isConciselyPrintedArray:o}=zt();function x(M,H,P){let G=M.getValue(),re=G.type==="ImportExpression",$=g(G);if($.length===0)return["(",t(M,H,!0),")"];if(_($))return["(",P(["arguments",0]),", ",P(["arguments",1]),")"];let W=!1,ee=!1,U=$.length-1,ne=[];p(M,(q,le)=>{let ue=q.getNode(),Q=[P()];le===U||(f(ue,H)?(le===0&&(ee=!0),W=!0,Q.push(",",b,b)):Q.push(",",A)),ne.push(Q)});let se=!(re||G.callee&&G.callee.type==="Import")&&m(H,"all")?",":"";function V(){return B(["(",w([A,...ne]),se,A,")"],{shouldBreak:!0})}if(W||M.getParentNode().type!=="Decorator"&&c($))return V();let oe=k($),K=S($,H);if(oe||K){if(oe?ne.slice(1).some(d):ne.slice(0,-1).some(d))return V();let q=[];try{M.try(()=>{p(M,(le,ue)=>{oe&&ue===0&&(q=[[P([],{expandFirstArg:!0}),ne.length>1?",":"",ee?b:A,ee?b:""],...ne.slice(1)]),K&&ue===U&&(q=[...ne.slice(0,-1),P([],{expandLastArg:!0})])})})}catch(le){if(le instanceof y)return V();throw le}return[ne.some(d)?D:"",I([["(",...q,")"],oe?["(",B(q[0],{shouldBreak:!0}),...q.slice(1),")"]:["(",...ne.slice(0,-1),B(s(q),{shouldBreak:!0}),")"],V()])]}let Ee=["(",w([v,...ne]),E(se),v,")"];return C(M)?Ee:B(Ee,{shouldBreak:ne.some(d)||W})}function F(M){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return M.type==="ObjectExpression"&&(M.properties.length>0||u(M))||M.type==="ArrayExpression"&&(M.elements.length>0||u(M))||M.type==="TSTypeAssertion"&&F(M.expression)||M.type==="TSAsExpression"&&F(M.expression)||M.type==="FunctionExpression"||M.type==="ArrowFunctionExpression"&&(!M.returnType||!M.returnType.typeAnnotation||M.returnType.typeAnnotation.type!=="TSTypeReference"||O(M.body))&&(M.body.type==="BlockStatement"||M.body.type==="ArrowFunctionExpression"&&F(M.body,!0)||M.body.type==="ObjectExpression"||M.body.type==="ArrayExpression"||!H&&(h(M.body)||M.body.type==="ConditionalExpression")||l(M.body))||M.type==="DoExpression"||M.type==="ModuleExpression"}function S(M,H){let P=s(M),G=i(M);return!u(P,a.Leading)&&!u(P,a.Trailing)&&F(P)&&(!G||G.type!==P.type)&&(M.length!==2||G.type!=="ArrowFunctionExpression"||P.type!=="ArrayExpression")&&!(M.length>1&&P.type==="ArrayExpression"&&o(P,H))}function k(M){if(M.length!==2)return!1;let[H,P]=M;return H.type==="ModuleExpression"&&R(P)?!0:!u(H)&&(H.type==="FunctionExpression"||H.type==="ArrowFunctionExpression"&&H.body.type==="BlockStatement")&&P.type!=="FunctionExpression"&&P.type!=="ArrowFunctionExpression"&&P.type!=="ConditionalExpression"&&!F(P)}function _(M){return M.length===2&&M[0].type==="ArrowFunctionExpression"&&r(M[0]).length===0&&M[0].body.type==="BlockStatement"&&M[1].type==="ArrayExpression"&&!M.some(H=>u(H))}function O(M){return M.type==="BlockStatement"&&(M.body.some(H=>H.type!=="EmptyStatement")||u(M,a.Dangling))}function R(M){return M.type==="ObjectExpression"&&M.properties.length===1&&T(M.properties[0])&&M.properties[0].key.type==="Identifier"&&M.properties[0].key.name==="type"&&N(M.properties[0].value)&&M.properties[0].value.value==="module"}n.exports=x}}),uo=Z({"src/language-js/print/member.js"(e,n){"use strict";ae();var{builders:{softline:t,group:s,indent:i,label:r}}=Le(),{isNumericLiteral:u,isMemberExpression:a,isCallExpression:c}=Xe(),{printOptionalToken:l}=ot();function C(g,p,f){let h=g.getValue(),N=g.getParentNode(),T,A=0;do T=g.getParentNode(A),A++;while(T&&(a(T)||T.type==="TSNonNullExpression"));let b=f("object"),v=m(g,p,f),B=T&&(T.type==="NewExpression"||T.type==="BindExpression"||T.type==="AssignmentExpression"&&T.left.type!=="Identifier")||h.computed||h.object.type==="Identifier"&&h.property.type==="Identifier"&&!a(N)||(N.type==="AssignmentExpression"||N.type==="VariableDeclarator")&&(c(h.object)&&h.object.arguments.length>0||h.object.type==="TSNonNullExpression"&&c(h.object.expression)&&h.object.expression.arguments.length>0||b.label==="member-chain");return r(b.label==="member-chain"?"member-chain":"member",[b,B?v:s(i([t,v]))])}function m(g,p,f){let h=f("property"),N=g.getValue(),T=l(g);return N.computed?!N.property||u(N.property)?[T,"[",h,"]"]:s([T,"[",i([t,h]),t,"]"]):[T,".",h]}n.exports={printMemberExpression:C,printMemberLookup:m}}}),Nm=Z({"src/language-js/print/member-chain.js"(e,n){"use strict";ae();var{printComments:t}=Qe(),{getLast:s,isNextLineEmptyAfterIndex:i,getNextNonSpaceNonCommentCharacterIndex:r}=Ge(),u=kt(),{isCallExpression:a,isMemberExpression:c,isFunctionOrArrowExpression:l,isLongCurriedCallExpression:C,isMemberish:m,isNumericLiteral:g,isSimpleCallArgument:p,hasComment:f,CommentCheckFlags:h,isNextLineEmpty:N}=Xe(),{locEnd:T}=nt(),{builders:{join:A,hardline:b,group:v,indent:B,conditionalGroup:w,breakParent:I,label:E},utils:{willBreak:D}}=Le(),d=no(),{printMemberLookup:y}=uo(),{printOptionalToken:o,printFunctionTypeParameters:x,printBindExpressionCallee:F}=ot();function S(k,_,O){let R=k.getParentNode(),M=!R||R.type==="ExpressionStatement",H=[];function P(me){let{originalText:ce}=_,he=r(ce,me,T);return ce.charAt(he)===")"?he!==!1&&i(ce,he+1):N(me,_)}function G(me){let ce=me.getValue();a(ce)&&(m(ce.callee)||a(ce.callee))?(H.unshift({node:ce,printed:[t(me,[o(me),x(me,_,O),d(me,_,O)],_),P(ce)?b:""]}),me.call(he=>G(he),"callee")):m(ce)?(H.unshift({node:ce,needsParens:u(me,_),printed:t(me,c(ce)?y(me,_,O):F(me,_,O),_)}),me.call(he=>G(he),"object")):ce.type==="TSNonNullExpression"?(H.unshift({node:ce,printed:t(me,"!",_)}),me.call(he=>G(he),"expression")):H.unshift({node:ce,printed:O()})}let re=k.getValue();H.unshift({node:re,printed:[o(k),x(k,_,O),d(k,_,O)]}),re.callee&&k.call(me=>G(me),"callee");let $=[],W=[H[0]],ee=1;for(;ee<H.length&&(H[ee].node.type==="TSNonNullExpression"||a(H[ee].node)||c(H[ee].node)&&H[ee].node.computed&&g(H[ee].node.property));++ee)W.push(H[ee]);if(!a(H[0].node))for(;ee+1<H.length&&(m(H[ee].node)&&m(H[ee+1].node));++ee)W.push(H[ee]);$.push(W),W=[];let U=!1;for(;ee<H.length;++ee){if(U&&m(H[ee].node)){if(H[ee].node.computed&&g(H[ee].node.property)){W.push(H[ee]);continue}$.push(W),W=[],U=!1}(a(H[ee].node)||H[ee].node.type==="ImportExpression")&&(U=!0),W.push(H[ee]),f(H[ee].node,h.Trailing)&&($.push(W),W=[],U=!1)}W.length>0&&$.push(W);function ne(me){return/^[A-Z]|^[$_]+$/.test(me)}function se(me){return me.length<=_.tabWidth}function V(me){let ce=me[1].length>0&&me[1][0].node.computed;if(me[0].length===1){let J=me[0][0].node;return J.type==="ThisExpression"||J.type==="Identifier"&&(ne(J.name)||M&&se(J.name)||ce)}let he=s(me[0]).node;return c(he)&&he.property.type==="Identifier"&&(ne(he.property.name)||ce)}let oe=$.length>=2&&!f($[1][0].node)&&V($);function K(me){let ce=me.map(he=>he.printed);return me.length>0&&s(me).needsParens?["(",...ce,")"]:ce}function Ee(me){return me.length===0?"":B(v([b,A(b,me.map(K))]))}let q=$.map(K),le=q,ue=oe?3:2,Q=$.flat(),de=Q.slice(1,-1).some(me=>f(me.node,h.Leading))||Q.slice(0,-1).some(me=>f(me.node,h.Trailing))||$[ue]&&f($[ue][0].node,h.Leading);if($.length<=ue&&!de)return C(k)?le:v(le);let ge=s($[oe?1:0]).node,ve=!a(ge)&&P(ge),xe=[K($[0]),oe?$.slice(1,2).map(K):"",ve?b:"",Ee($.slice(oe?2:1))],we=H.map(me=>{let{node:ce}=me;return ce}).filter(a);function fe(){let me=s(s($)).node,ce=s(q);return a(me)&&D(ce)&&we.slice(0,-1).some(he=>he.arguments.some(l))}let pe;return de||we.length>2&&we.some(me=>!me.arguments.every(ce=>p(ce,0)))||q.slice(0,-1).some(D)||fe()?pe=v(xe):pe=[D(le)||ve?I:"",w([le,xe])],E("member-chain",pe)}n.exports=S}}),so=Z({"src/language-js/print/call-expression.js"(e,n){"use strict";ae();var{builders:{join:t,group:s}}=Le(),i=kt(),{getCallArguments:r,hasFlowAnnotationComment:u,isCallExpression:a,isMemberish:c,isStringLiteral:l,isTemplateOnItsOwnLine:C,isTestCall:m,iterateCallArgumentsPath:g}=Xe(),p=Nm(),f=no(),{printOptionalToken:h,printFunctionTypeParameters:N}=ot();function T(b,v,B){let w=b.getValue(),I=b.getParentNode(),E=w.type==="NewExpression",D=w.type==="ImportExpression",d=h(b),y=r(w);if(y.length>0&&(!D&&!E&&A(w,I)||y.length===1&&C(y[0],v.originalText)||!E&&m(w,I))){let F=[];return g(b,()=>{F.push(B())}),[E?"new ":"",B("callee"),d,N(b,v,B),"(",t(", ",F),")"]}let o=(v.parser==="babel"||v.parser==="babel-flow")&&w.callee&&w.callee.type==="Identifier"&&u(w.callee.trailingComments);if(o&&(w.callee.trailingComments[0].printed=!0),!D&&!E&&c(w.callee)&&!b.call(F=>i(F,v),"callee"))return p(b,v,B);let x=[E?"new ":"",D?"import":B("callee"),d,o?"/*:: ".concat(w.callee.trailingComments[0].value.slice(2).trim()," */"):"",N(b,v,B),f(b,v,B)];return D||a(w.callee)?s(x):x}function A(b,v){if(b.callee.type!=="Identifier")return!1;if(b.callee.name==="require")return!0;if(b.callee.name==="define"){let B=r(b);return v.type==="ExpressionStatement"&&(B.length===1||B.length===2&&B[0].type==="ArrayExpression"||B.length===3&&l(B[0])&&B[1].type==="ArrayExpression")}return!1}n.exports={printCallExpression:T}}}),Xt=Z({"src/language-js/print/assignment.js"(e,n){"use strict";ae();var{isNonEmptyArray:t,getStringWidth:s}=Ge(),{builders:{line:i,group:r,indent:u,indentIfBreak:a,lineSuffixBoundary:c},utils:{cleanDoc:l,willBreak:C,canBreak:m}}=Le(),{hasLeadingOwnLineComment:g,isBinaryish:p,isStringLiteral:f,isLiteral:h,isNumericLiteral:N,isCallExpression:T,isMemberExpression:A,getCallArguments:b,rawText:v,hasComment:B,isSignedNumericLiteral:w,isObjectProperty:I}=Xe(),{shouldInlineLogicalExpression:E}=Jn(),{printCallExpression:D}=so();function d(V,oe,K,Ee,q,le){let ue=x(V,oe,K,Ee,le),Q=K(le,{assignmentLayout:ue});switch(ue){case"break-after-operator":return r([r(Ee),q,r(u([i,Q]))]);case"never-break-after-operator":return r([r(Ee),q," ",Q]);case"fluid":{let de=Symbol("assignment");return r([r(Ee),q,r(u(i),{id:de}),c,a(Q,{groupId:de})])}case"break-lhs":return r([Ee,q," ",r(Q)]);case"chain":return[r(Ee),q,i,Q];case"chain-tail":return[r(Ee),q,u([i,Q])];case"chain-tail-arrow-chain":return[r(Ee),q,Q];case"only-left":return Ee}}function y(V,oe,K){let Ee=V.getValue();return d(V,oe,K,K("left"),[" ",Ee.operator],"right")}function o(V,oe,K){return d(V,oe,K,K("id")," =","init")}function x(V,oe,K,Ee,q){let le=V.getValue(),ue=le[q];if(!ue)return"only-left";let Q=!k(ue);if(V.match(k,_,xe=>!Q||xe.type!=="ExpressionStatement"&&xe.type!=="VariableDeclaration"))return Q?ue.type==="ArrowFunctionExpression"&&ue.body.type==="ArrowFunctionExpression"?"chain-tail-arrow-chain":"chain-tail":"chain";if(!Q&&k(ue.right)||g(oe.originalText,ue))return"break-after-operator";if(ue.type==="CallExpression"&&ue.callee.name==="require"||oe.parser==="json5"||oe.parser==="json")return"never-break-after-operator";if(S(le)||O(le)||H(le)||P(le)&&m(Ee))return"break-lhs";let ve=U(le,Ee,oe);return V.call(()=>F(V,oe,K,ve),q)?"break-after-operator":ve||ue.type==="TemplateLiteral"||ue.type==="TaggedTemplateExpression"||ue.type==="BooleanLiteral"||N(ue)||ue.type==="ClassExpression"?"never-break-after-operator":"fluid"}function F(V,oe,K,Ee){let q=V.getValue();if(p(q)&&!E(q))return!0;switch(q.type){case"StringLiteralTypeAnnotation":case"SequenceExpression":return!0;case"ConditionalExpression":{let{test:Q}=q;return p(Q)&&!E(Q)}case"ClassExpression":return t(q.decorators)}if(Ee)return!1;let le=q,ue=[];for(;;)if(le.type==="UnaryExpression")le=le.argument,ue.push("argument");else if(le.type==="TSNonNullExpression")le=le.expression,ue.push("expression");else break;return!!(f(le)||V.call(()=>$(V,oe,K),...ue))}function S(V){if(_(V)){let oe=V.left||V.id;return oe.type==="ObjectPattern"&&oe.properties.length>2&&oe.properties.some(K=>I(K)&&(!K.shorthand||K.value&&K.value.type==="AssignmentPattern"))}return!1}function k(V){return V.type==="AssignmentExpression"}function _(V){return k(V)||V.type==="VariableDeclarator"}function O(V){let oe=R(V);if(t(oe)){let K=V.type==="TSTypeAliasDeclaration"?"constraint":"bound";if(oe.length>1&&oe.some(Ee=>Ee[K]||Ee.default))return!0}return!1}function R(V){return M(V)&&V.typeParameters&&V.typeParameters.params?V.typeParameters.params:null}function M(V){return V.type==="TSTypeAliasDeclaration"||V.type==="TypeAlias"}function H(V){if(V.type!=="VariableDeclarator")return!1;let{typeAnnotation:oe}=V.id;if(!oe||!oe.typeAnnotation)return!1;let K=G(oe.typeAnnotation);return t(K)&&K.length>1&&K.some(Ee=>t(G(Ee))||Ee.type==="TSConditionalType")}function P(V){return V.type==="VariableDeclarator"&&V.init&&V.init.type==="ArrowFunctionExpression"}function G(V){return re(V)&&V.typeParameters&&V.typeParameters.params?V.typeParameters.params:null}function re(V){return V.type==="TSTypeReference"||V.type==="GenericTypeAnnotation"}function $(V,oe,K){let Ee=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,q=V.getValue(),le=()=>$(V,oe,K,!0);if(q.type==="TSNonNullExpression")return V.call(le,"expression");if(T(q)){if(D(V,oe,K).label==="member-chain")return!1;let Q=b(q);return!(Q.length===0||Q.length===1&&ee(Q[0],oe))||ne(q,K)?!1:V.call(le,"callee")}return A(q)?V.call(le,"object"):Ee&&(q.type==="Identifier"||q.type==="ThisExpression")}var W=.25;function ee(V,oe){let{printWidth:K}=oe;if(B(V))return!1;let Ee=K*W;if(V.type==="ThisExpression"||V.type==="Identifier"&&V.name.length<=Ee||w(V)&&!B(V.argument))return!0;let q=V.type==="Literal"&&"regex"in V&&V.regex.pattern||V.type==="RegExpLiteral"&&V.pattern;return q?q.length<=Ee:f(V)?v(V).length<=Ee:V.type==="TemplateLiteral"?V.expressions.length===0&&V.quasis[0].value.raw.length<=Ee&&!V.quasis[0].value.raw.includes(` |
| | | `):h(V)}function U(V,oe,K){if(!I(V))return!1;oe=l(oe);let Ee=3;return typeof oe=="string"&&s(oe)<K.tabWidth+Ee}function ne(V,oe){let K=se(V);if(t(K)){if(K.length>1)return!0;if(K.length===1){let q=K[0];if(q.type==="TSUnionType"||q.type==="UnionTypeAnnotation"||q.type==="TSIntersectionType"||q.type==="IntersectionTypeAnnotation"||q.type==="TSTypeLiteral"||q.type==="ObjectTypeAnnotation")return!0}let Ee=V.typeParameters?"typeParameters":"typeArguments";if(C(oe(Ee)))return!0}return!1}function se(V){return V.typeParameters&&V.typeParameters.params||V.typeArguments&&V.typeArguments.params}n.exports={printVariableDeclarator:o,printAssignmentExpression:y,printAssignment:d,isArrowFunctionVariableDeclarator:P}}}),wr=Z({"src/language-js/print/function-parameters.js"(e,n){"use strict";ae();var{getNextNonSpaceNonCommentCharacter:t}=Ge(),{printDanglingComments:s}=Qe(),{builders:{line:i,hardline:r,softline:u,group:a,indent:c,ifBreak:l},utils:{removeLines:C,willBreak:m}}=Le(),{getFunctionParameters:g,iterateFunctionParametersPath:p,isSimpleType:f,isTestCall:h,isTypeAnnotationAFunction:N,isObjectType:T,isObjectTypePropertyAFunction:A,hasRestParameter:b,shouldPrintComma:v,hasComment:B,isNextLineEmpty:w}=Xe(),{locEnd:I}=nt(),{ArgExpansionBailout:E}=Jt(),{printFunctionTypeParameters:D}=ot();function d(F,S,k,_,O){let R=F.getValue(),M=g(R),H=O?D(F,k,S):"";if(M.length===0)return[H,"(",s(F,k,!0,U=>t(k.originalText,U,I)===")"),")"];let P=F.getParentNode(),G=h(P),re=y(R),$=[];if(p(F,(U,ne)=>{let se=ne===M.length-1;se&&R.rest&&$.push("..."),$.push(S()),!se&&($.push(","),G||re?$.push(" "):w(M[ne],k)?$.push(r,r):$.push(i))}),_){if(m(H)||m($))throw new E;return a([C(H),"(",C($),")"])}let W=M.every(U=>!U.decorators);return re&&W?[H,"(",...$,")"]:G?[H,"(",...$,")"]:(A(P)||N(P)||P.type==="TypeAlias"||P.type==="UnionTypeAnnotation"||P.type==="TSUnionType"||P.type==="IntersectionTypeAnnotation"||P.type==="FunctionTypeAnnotation"&&P.returnType===R)&&M.length===1&&M[0].name===null&&R.this!==M[0]&&M[0].typeAnnotation&&R.typeParameters===null&&f(M[0].typeAnnotation)&&!R.rest?k.arrowParens==="always"?["(",...$,")"]:$:[H,"(",c([u,...$]),l(!b(R)&&v(k,"all")?",":""),u,")"]}function y(F){if(!F)return!1;let S=g(F);if(S.length!==1)return!1;let[k]=S;return!B(k)&&(k.type==="ObjectPattern"||k.type==="ArrayPattern"||k.type==="Identifier"&&k.typeAnnotation&&(k.typeAnnotation.type==="TypeAnnotation"||k.typeAnnotation.type==="TSTypeAnnotation")&&T(k.typeAnnotation.typeAnnotation)||k.type==="FunctionTypeParam"&&T(k.typeAnnotation)||k.type==="AssignmentPattern"&&(k.left.type==="ObjectPattern"||k.left.type==="ArrayPattern")&&(k.right.type==="Identifier"||k.right.type==="ObjectExpression"&&k.right.properties.length===0||k.right.type==="ArrayExpression"&&k.right.elements.length===0))}function o(F){let S;return F.returnType?(S=F.returnType,S.typeAnnotation&&(S=S.typeAnnotation)):F.typeAnnotation&&(S=F.typeAnnotation),S}function x(F,S){let k=o(F);if(!k)return!1;let _=F.typeParameters&&F.typeParameters.params;if(_){if(_.length>1)return!1;if(_.length===1){let O=_[0];if(O.constraint||O.default)return!1}}return g(F).length===1&&(T(k)||m(S))}n.exports={printFunctionParameters:d,shouldHugFunctionParameters:y,shouldGroupFunctionParameters:x}}}),_r=Z({"src/language-js/print/type-annotation.js"(e,n){"use strict";ae();var{printComments:t,printDanglingComments:s}=Qe(),{isNonEmptyArray:i}=Ge(),{builders:{group:r,join:u,line:a,softline:c,indent:l,align:C,ifBreak:m}}=Le(),g=kt(),{locStart:p}=nt(),{isSimpleType:f,isObjectType:h,hasLeadingOwnLineComment:N,isObjectTypePropertyAFunction:T,shouldPrintComma:A}=Xe(),{printAssignment:b}=Xt(),{printFunctionParameters:v,shouldGroupFunctionParameters:B}=wr(),{printArrayItems:w}=zt();function I(S){if(f(S)||h(S))return!0;if(S.type==="UnionTypeAnnotation"||S.type==="TSUnionType"){let k=S.types.filter(O=>O.type==="VoidTypeAnnotation"||O.type==="TSVoidKeyword"||O.type==="NullLiteralTypeAnnotation"||O.type==="TSNullKeyword").length,_=S.types.some(O=>O.type==="ObjectTypeAnnotation"||O.type==="TSTypeLiteral"||O.type==="GenericTypeAnnotation"||O.type==="TSTypeReference");if(S.types.length-1===k&&_)return!0}return!1}function E(S,k,_){let O=k.semi?";":"",R=S.getValue(),M=[];return M.push("opaque type ",_("id"),_("typeParameters")),R.supertype&&M.push(": ",_("supertype")),R.impltype&&M.push(" = ",_("impltype")),M.push(O),M}function D(S,k,_){let O=k.semi?";":"",R=S.getValue(),M=[];R.declare&&M.push("declare "),M.push("type ",_("id"),_("typeParameters"));let H=R.type==="TSTypeAliasDeclaration"?"typeAnnotation":"right";return[b(S,k,_,M," =",H),O]}function d(S,k,_){let O=S.getValue(),R=S.map(_,"types"),M=[],H=!1;for(let P=0;P<R.length;++P)P===0?M.push(R[P]):h(O.types[P-1])&&h(O.types[P])?M.push([" & ",H?l(R[P]):R[P]]):!h(O.types[P-1])&&!h(O.types[P])?M.push(l([" &",a,R[P]])):(P>1&&(H=!0),M.push(" & ",P>1?l(R[P]):R[P]));return r(M)}function y(S,k,_){let O=S.getValue(),R=S.getParentNode(),M=R.type!=="TypeParameterInstantiation"&&R.type!=="TSTypeParameterInstantiation"&&R.type!=="GenericTypeAnnotation"&&R.type!=="TSTypeReference"&&R.type!=="TSTypeAssertion"&&R.type!=="TupleTypeAnnotation"&&R.type!=="TSTupleType"&&!(R.type==="FunctionTypeParam"&&!R.name&&S.getParentNode(1).this!==R)&&!((R.type==="TypeAlias"||R.type==="VariableDeclarator"||R.type==="TSTypeAliasDeclaration")&&N(k.originalText,O)),H=I(O),P=S.map($=>{let W=_();return H||(W=C(2,W)),t($,W,k)},"types");if(H)return u(" | ",P);let G=M&&!N(k.originalText,O),re=[m([G?a:"","| "]),u([a,"| "],P)];return g(S,k)?r([l(re),c]):R.type==="TupleTypeAnnotation"&&R.types.length>1||R.type==="TSTupleType"&&R.elementTypes.length>1?r([l([m(["(",c]),re]),c,m(")")]):r(M?l(re):re)}function o(S,k,_){let O=S.getValue(),R=[],M=S.getParentNode(0),H=S.getParentNode(1),P=S.getParentNode(2),G=O.type==="TSFunctionType"||!((M.type==="ObjectTypeProperty"||M.type==="ObjectTypeInternalSlot")&&!M.variance&&!M.optional&&p(M)===p(O)||M.type==="ObjectTypeCallProperty"||P&&P.type==="DeclareFunction"),re=G&&(M.type==="TypeAnnotation"||M.type==="TSTypeAnnotation"),$=re&&G&&(M.type==="TypeAnnotation"||M.type==="TSTypeAnnotation")&&H.type==="ArrowFunctionExpression";T(M)&&(G=!0,re=!0),$&&R.push("(");let W=v(S,_,k,!1,!0),ee=O.returnType||O.predicate||O.typeAnnotation?[G?" => ":": ",_("returnType"),_("predicate"),_("typeAnnotation")]:"",U=B(O,ee);return R.push(U?r(W):W),ee&&R.push(ee),$&&R.push(")"),r(R)}function x(S,k,_){let O=S.getValue(),R=O.type==="TSTupleType"?"elementTypes":"types",M=O[R],H=i(M),P=H?c:"";return r(["[",l([P,w(S,k,R,_)]),m(H&&A(k,"all")?",":""),s(S,k,!0),P,"]"])}function F(S,k,_){let O=S.getValue(),R=O.type==="OptionalIndexedAccessType"&&O.optional?"?.[":"[";return[_("objectType"),R,_("indexType"),"]"]}n.exports={printOpaqueType:E,printTypeAlias:D,printIntersectionType:d,printUnionType:y,printFunctionType:o,printTupleType:x,printIndexedAccessType:F,shouldHugType:I}}}),Pr=Z({"src/language-js/print/type-parameters.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{builders:{join:s,line:i,hardline:r,softline:u,group:a,indent:c,ifBreak:l}}=Le(),{isTestCall:C,hasComment:m,CommentCheckFlags:g,isTSXFile:p,shouldPrintComma:f,getFunctionParameters:h,isObjectType:N}=Xe(),{createGroupIdMapper:T}=Ge(),{shouldHugType:A}=_r(),{isArrowFunctionVariableDeclarator:b}=Xt(),v=T("typeParameters");function B(E,D,d,y){let o=E.getValue();if(!o[y])return"";if(!Array.isArray(o[y]))return d(y);let x=E.getNode(2),F=x&&C(x);if(!E.match(O=>!(O[y].length===1&&N(O[y][0])),void 0,(O,R)=>R==="typeAnnotation",O=>O.type==="Identifier",b)&&(F||o[y].length===0||o[y].length===1&&(o[y][0].type==="NullableTypeAnnotation"||A(o[y][0]))))return["<",s(", ",E.map(d,y)),w(E,D),">"];let _=o.type==="TSTypeParameterInstantiation"?"":h(o).length===1&&p(D)&&!o[y][0].constraint&&E.getParentNode().type==="ArrowFunctionExpression"?",":f(D,"all")?l(","):"";return a(["<",c([u,s([",",i],E.map(d,y))]),_,u,">"],{id:v(o)})}function w(E,D){let d=E.getValue();if(!m(d,g.Dangling))return"";let y=!m(d,g.Line),o=t(E,D,y);return y?o:[o,r]}function I(E,D,d){let y=E.getValue(),o=[],x=E.getParentNode();return x.type==="TSMappedType"?(o.push("[",d("name")),y.constraint&&o.push(" in ",d("constraint")),x.nameType&&o.push(" as ",E.callParent(()=>d("nameType"))),o.push("]"),o):(y.variance&&o.push(d("variance")),o.push(d("name")),y.bound&&o.push(": ",d("bound")),y.constraint&&o.push(" extends ",d("constraint")),y.default&&o.push(" = ",d("default")),o)}n.exports={printTypeParameter:I,printTypeParameters:B,getTypeParametersGroupId:v}}}),Kt=Z({"src/language-js/print/property.js"(e,n){"use strict";ae();var{printComments:t}=Qe(),{printString:s,printNumber:i}=Ge(),{isNumericLiteral:r,isSimpleNumber:u,isStringLiteral:a,isStringPropSafeToUnquote:c,rawText:l}=Xe(),{printAssignment:C}=Xt(),m=new WeakMap;function g(f,h,N){let T=f.getNode();if(T.computed)return["[",N("key"),"]"];let A=f.getParentNode(),{key:b}=T;if(T.type==="ClassPrivateProperty"&&b.type==="Identifier")return["#",N("key")];if(h.quoteProps==="consistent"&&!m.has(A)){let v=(A.properties||A.body||A.members).some(B=>!B.computed&&B.key&&a(B.key)&&!c(B,h));m.set(A,v)}if((b.type==="Identifier"||r(b)&&u(i(l(b)))&&String(b.value)===i(l(b))&&!(h.parser==="typescript"||h.parser==="babel-ts"))&&(h.parser==="json"||h.quoteProps==="consistent"&&m.get(A))){let v=s(JSON.stringify(b.type==="Identifier"?b.name:b.value.toString()),h);return f.call(B=>t(B,v,h),"key")}return c(T,h)&&(h.quoteProps==="as-needed"||h.quoteProps==="consistent"&&!m.get(A))?f.call(v=>t(v,/^\d/.test(b.value)?i(b.value):b.value,h),"key"):N("key")}function p(f,h,N){return f.getValue().shorthand?N("value"):C(f,h,N,g(f,h,N),":","value")}n.exports={printProperty:p,printPropertyKey:g}}}),Ir=Z({"src/language-js/print/function.js"(e,n){"use strict";ae();var t=Ut(),{printDanglingComments:s,printCommentsSeparately:i}=Qe(),r=st(),{getNextNonSpaceNonCommentCharacterIndex:u}=Ge(),{builders:{line:a,softline:c,group:l,indent:C,ifBreak:m,hardline:g,join:p,indentIfBreak:f},utils:{removeLines:h,willBreak:N}}=Le(),{ArgExpansionBailout:T}=Jt(),{getFunctionParameters:A,hasLeadingOwnLineComment:b,isFlowAnnotationComment:v,isJsxNode:B,isTemplateOnItsOwnLine:w,shouldPrintComma:I,startsWithNoLookaheadToken:E,isBinaryish:D,isLineComment:d,hasComment:y,getComments:o,CommentCheckFlags:x,isCallLikeExpression:F,isCallExpression:S,getCallArguments:k,hasNakedLeftSide:_,getLeftSide:O}=Xe(),{locEnd:R}=nt(),{printFunctionParameters:M,shouldGroupFunctionParameters:H}=wr(),{printPropertyKey:P}=Kt(),{printFunctionTypeParameters:G}=ot();function re(ue,Q,de,ge){let ve=ue.getValue(),xe=!1;if((ve.type==="FunctionDeclaration"||ve.type==="FunctionExpression")&&ge&&ge.expandLastArg){let ce=ue.getParentNode();S(ce)&&k(ce).length>1&&(xe=!0)}let we=[];ve.type==="TSDeclareFunction"&&ve.declare&&we.push("declare "),ve.async&&we.push("async "),ve.generator?we.push("function* "):we.push("function "),ve.id&&we.push(Q("id"));let fe=M(ue,Q,de,xe),pe=oe(ue,Q,de),me=H(ve,pe);return we.push(G(ue,de,Q),l([me?l(fe):fe,pe]),ve.body?" ":"",Q("body")),de.semi&&(ve.declare||!ve.body)&&we.push(";"),we}function $(ue,Q,de){let ge=ue.getNode(),{kind:ve}=ge,xe=ge.value||ge,we=[];return!ve||ve==="init"||ve==="method"||ve==="constructor"?xe.async&&we.push("async "):(t.ok(ve==="get"||ve==="set"),we.push(ve," ")),xe.generator&&we.push("*"),we.push(P(ue,Q,de),ge.optional||ge.key.optional?"?":""),ge===xe?we.push(W(ue,Q,de)):xe.type==="FunctionExpression"?we.push(ue.call(fe=>W(fe,Q,de),"value")):we.push(de("value")),we}function W(ue,Q,de){let ge=ue.getNode(),ve=M(ue,de,Q),xe=oe(ue,de,Q),we=H(ge,xe),fe=[G(ue,Q,de),l([we?l(ve):ve,xe])];return ge.body?fe.push(" ",de("body")):fe.push(Q.semi?";":""),fe}function ee(ue,Q,de,ge){let ve=ue.getValue(),xe=[];if(ve.async&&xe.push("async "),V(ue,Q))xe.push(de(["params",0]));else{let fe=ge&&(ge.expandLastArg||ge.expandFirstArg),pe=oe(ue,de,Q);if(fe){if(N(pe))throw new T;pe=l(h(pe))}xe.push(l([M(ue,de,Q,fe,!0),pe]))}let we=s(ue,Q,!0,fe=>{let pe=u(Q.originalText,fe,R);return pe!==!1&&Q.originalText.slice(pe,pe+2)==="=>"});return we&&xe.push(" ",we),xe}function U(ue,Q,de,ge,ve,xe){let we=ue.getName(),fe=ue.getParentNode(),pe=F(fe)&&we==="callee",me=Boolean(Q&&Q.assignmentLayout),ce=xe.body.type!=="BlockStatement"&&xe.body.type!=="ObjectExpression"&&xe.body.type!=="SequenceExpression",he=pe&&ce||Q&&Q.assignmentLayout==="chain-tail-arrow-chain",J=Symbol("arrow-chain");return xe.body.type==="SequenceExpression"&&(ve=l(["(",C([c,ve]),c,")"])),l([l(C([pe||me?c:"",l(p([" =>",a],de),{shouldBreak:ge})]),{id:J,shouldBreak:he})," =>",f(ce?C([a,ve]):[" ",ve],{groupId:J}),pe?m(c,"",{groupId:J}):""])}function ne(ue,Q,de,ge){let ve=ue.getValue(),xe=[],we=[],fe=!1;if(function J(){let ye=ee(ue,Q,de,ge);if(xe.length===0)xe.push(ye);else{let{leading:X,trailing:Y}=i(ue,Q);xe.push([X,ye]),we.unshift(Y)}fe=fe||ve.returnType&&A(ve).length>0||ve.typeParameters||A(ve).some(X=>X.type!=="Identifier"),ve.body.type!=="ArrowFunctionExpression"||ge&&ge.expandLastArg?we.unshift(de("body",ge)):(ve=ve.body,ue.call(J,"body"))}(),xe.length>1)return U(ue,ge,xe,fe,we,ve);let pe=xe;if(pe.push(" =>"),!b(Q.originalText,ve.body)&&(ve.body.type==="ArrayExpression"||ve.body.type==="ObjectExpression"||ve.body.type==="BlockStatement"||B(ve.body)||w(ve.body,Q.originalText)||ve.body.type==="ArrowFunctionExpression"||ve.body.type==="DoExpression"))return l([...pe," ",we]);if(ve.body.type==="SequenceExpression")return l([...pe,l([" (",C([c,we]),c,")"])]);let me=(ge&&ge.expandLastArg||ue.getParentNode().type==="JSXExpressionContainer")&&!y(ve),ce=ge&&ge.expandLastArg&&I(Q,"all"),he=ve.body.type==="ConditionalExpression"&&!E(ve.body,!1);return l([...pe,l([C([a,he?m("","("):"",we,he?m("",")"):""]),me?[m(ce?",":""),c]:""])])}function se(ue){let Q=A(ue);return Q.length===1&&!ue.typeParameters&&!y(ue,x.Dangling)&&Q[0].type==="Identifier"&&!Q[0].typeAnnotation&&!y(Q[0])&&!Q[0].optional&&!ue.predicate&&!ue.returnType}function V(ue,Q){if(Q.arrowParens==="always")return!1;if(Q.arrowParens==="avoid"){let de=ue.getValue();return se(de)}return!1}function oe(ue,Q,de){let ge=ue.getValue(),ve=Q("returnType");if(ge.returnType&&v(de.originalText,ge.returnType))return[" /*: ",ve," */"];let xe=[ve];return ge.returnType&&ge.returnType.typeAnnotation&&xe.unshift(": "),ge.predicate&&xe.push(ge.returnType?" ":": ",Q("predicate")),xe}function K(ue,Q,de){let ge=ue.getValue(),ve=Q.semi?";":"",xe=[];ge.argument&&(le(Q,ge.argument)?xe.push([" (",C([g,de("argument")]),g,")"]):D(ge.argument)||ge.argument.type==="SequenceExpression"?xe.push(l([m(" ("," "),C([c,de("argument")]),c,m(")")])):xe.push(" ",de("argument")));let we=o(ge),fe=r(we),pe=fe&&d(fe);return pe&&xe.push(ve),y(ge,x.Dangling)&&xe.push(" ",s(ue,Q,!0)),pe||xe.push(ve),xe}function Ee(ue,Q,de){return["return",K(ue,Q,de)]}function q(ue,Q,de){return["throw",K(ue,Q,de)]}function le(ue,Q){if(b(ue.originalText,Q))return!0;if(_(Q)){let de=Q,ge;for(;ge=O(de);)if(de=ge,b(ue.originalText,de))return!0}return!1}n.exports={printFunction:re,printArrowFunction:ne,printMethod:$,printReturnStatement:Ee,printThrowStatement:q,printMethodInternal:W,shouldPrintParamsWithoutParens:V}}}),Un=Z({"src/language-js/print/decorators.js"(e,n){"use strict";ae();var{isNonEmptyArray:t,hasNewline:s}=Ge(),{builders:{line:i,hardline:r,join:u,breakParent:a,group:c}}=Le(),{locStart:l,locEnd:C}=nt(),{getParentExportDeclaration:m}=Xe();function g(T,A,b){let v=T.getValue();return c([u(i,T.map(b,"decorators")),h(v,A)?r:i])}function p(T,A,b){return[u(r,T.map(b,"declaration","decorators")),r]}function f(T,A,b){let v=T.getValue(),{decorators:B}=v;if(!t(B)||N(T.getParentNode()))return;let w=v.type==="ClassExpression"||v.type==="ClassDeclaration"||h(v,A);return[m(T)?r:w?a:"",u(i,T.map(b,"decorators")),i]}function h(T,A){return T.decorators.some(b=>s(A.originalText,C(b)))}function N(T){if(T.type!=="ExportDefaultDeclaration"&&T.type!=="ExportNamedDeclaration"&&T.type!=="DeclareExportDeclaration")return!1;let A=T.declaration&&T.declaration.decorators;return t(A)&&l(T,{ignoreDecorators:!0})>l(A[0])}n.exports={printDecorators:f,printClassMemberDecorators:g,printDecoratorsBeforeExport:p,hasDecoratorsBeforeExport:N}}}),Yt=Z({"src/language-js/print/class.js"(e,n){"use strict";ae();var{isNonEmptyArray:t,createGroupIdMapper:s}=Ge(),{printComments:i,printDanglingComments:r}=Qe(),{builders:{join:u,line:a,hardline:c,softline:l,group:C,indent:m,ifBreak:g}}=Le(),{hasComment:p,CommentCheckFlags:f}=Xe(),{getTypeParametersGroupId:h}=Pr(),{printMethod:N}=Ir(),{printOptionalToken:T,printTypeAnnotation:A,printDefiniteToken:b}=ot(),{printPropertyKey:v}=Kt(),{printAssignment:B}=Xt(),{printClassMemberDecorators:w}=Un();function I(k,_,O){let R=k.getValue(),M=[];R.declare&&M.push("declare "),R.abstract&&M.push("abstract "),M.push("class");let H=R.id&&p(R.id,f.Trailing)||R.typeParameters&&p(R.typeParameters,f.Trailing)||R.superClass&&p(R.superClass)||t(R.extends)||t(R.mixins)||t(R.implements),P=[],G=[];if(R.id&&P.push(" ",O("id")),P.push(O("typeParameters")),R.superClass){let re=[x(k,_,O),O("superTypeParameters")],$=k.call(W=>["extends ",i(W,re,_)],"superClass");H?G.push(a,C($)):G.push(" ",$)}else G.push(o(k,_,O,"extends"));if(G.push(o(k,_,O,"mixins"),o(k,_,O,"implements")),H){let re;y(R)?re=[...P,m(G)]:re=m([...P,G]),M.push(C(re,{id:E(R)}))}else M.push(...P,...G);return M.push(" ",O("body")),M}var E=s("heritageGroup");function D(k){return g(c,"",{groupId:E(k)})}function d(k){return["superClass","extends","mixins","implements"].filter(_=>Boolean(k[_])).length>1}function y(k){return k.typeParameters&&!p(k.typeParameters,f.Trailing|f.Line)&&!d(k)}function o(k,_,O,R){let M=k.getValue();if(!t(M[R]))return"";let H=r(k,_,!0,P=>{let{marker:G}=P;return G===R});return[y(M)?g(" ",a,{groupId:h(M.typeParameters)}):a,H,H&&c,R,C(m([a,u([",",a],k.map(O,R))]))]}function x(k,_,O){let R=O("superClass");return k.getParentNode().type==="AssignmentExpression"?C(g(["(",m([l,R]),l,")"],R)):R}function F(k,_,O){let R=k.getValue(),M=[];return t(R.decorators)&&M.push(w(k,_,O)),R.accessibility&&M.push(R.accessibility+" "),R.readonly&&M.push("readonly "),R.declare&&M.push("declare "),R.static&&M.push("static "),(R.type==="TSAbstractMethodDefinition"||R.abstract)&&M.push("abstract "),R.override&&M.push("override "),M.push(N(k,_,O)),M}function S(k,_,O){let R=k.getValue(),M=[],H=_.semi?";":"";return t(R.decorators)&&M.push(w(k,_,O)),R.accessibility&&M.push(R.accessibility+" "),R.declare&&M.push("declare "),R.static&&M.push("static "),(R.type==="TSAbstractPropertyDefinition"||R.abstract)&&M.push("abstract "),R.override&&M.push("override "),R.readonly&&M.push("readonly "),R.variance&&M.push(O("variance")),R.type==="ClassAccessorProperty"&&M.push("accessor "),M.push(v(k,_,O),T(k),b(k),A(k,_,O)),[B(k,_,O,M," =","value"),H]}n.exports={printClass:I,printClassMethod:F,printClassProperty:S,printHardlineAfterHeritage:D}}}),ao=Z({"src/language-js/print/interface.js"(e,n){"use strict";ae();var{isNonEmptyArray:t}=Ge(),{builders:{join:s,line:i,group:r,indent:u,ifBreak:a}}=Le(),{hasComment:c,identity:l,CommentCheckFlags:C}=Xe(),{getTypeParametersGroupId:m}=Pr(),{printTypeScriptModifiers:g}=ot();function p(f,h,N){let T=f.getValue(),A=[];T.declare&&A.push("declare "),T.type==="TSInterfaceDeclaration"&&A.push(T.abstract?"abstract ":"",g(f,h,N)),A.push("interface");let b=[],v=[];T.type!=="InterfaceTypeAnnotation"&&b.push(" ",N("id"),N("typeParameters"));let B=T.typeParameters&&!c(T.typeParameters,C.Trailing|C.Line);return t(T.extends)&&v.push(B?a(" ",i,{groupId:m(T.typeParameters)}):i,"extends ",(T.extends.length===1?l:u)(s([",",i],f.map(N,"extends")))),T.id&&c(T.id,C.Trailing)||t(T.extends)?B?A.push(r([...b,u(v)])):A.push(r(u([...b,...v]))):A.push(...b,...v),A.push(" ",N("body")),r(A)}n.exports={printInterface:p}}}),io=Z({"src/language-js/print/module.js"(e,n){"use strict";ae();var{isNonEmptyArray:t}=Ge(),{builders:{softline:s,group:i,indent:r,join:u,line:a,ifBreak:c,hardline:l}}=Le(),{printDanglingComments:C}=Qe(),{hasComment:m,CommentCheckFlags:g,shouldPrintComma:p,needsHardlineAfterDanglingComment:f,isStringLiteral:h,rawText:N}=Xe(),{locStart:T,hasSameLoc:A}=nt(),{hasDecoratorsBeforeExport:b,printDecoratorsBeforeExport:v}=Un();function B(S,k,_){let O=S.getValue(),R=k.semi?";":"",M=[],{importKind:H}=O;return M.push("import"),H&&H!=="value"&&M.push(" ",H),M.push(d(S,k,_),D(S,k,_),o(S,k,_),R),M}function w(S,k,_){let O=S.getValue(),R=[];b(O)&&R.push(v(S,k,_));let{type:M,exportKind:H,declaration:P}=O;return R.push("export"),(O.default||M==="ExportDefaultDeclaration")&&R.push(" default"),m(O,g.Dangling)&&(R.push(" ",C(S,k,!0)),f(O)&&R.push(l)),P?R.push(" ",_("declaration")):R.push(H==="type"?" type":"",d(S,k,_),D(S,k,_),o(S,k,_)),E(O,k)&&R.push(";"),R}function I(S,k,_){let O=S.getValue(),R=k.semi?";":"",M=[],{exportKind:H,exported:P}=O;return M.push("export"),H==="type"&&M.push(" type"),M.push(" *"),P&&M.push(" as ",_("exported")),M.push(D(S,k,_),o(S,k,_),R),M}function E(S,k){if(!k.semi)return!1;let{type:_,declaration:O}=S,R=S.default||_==="ExportDefaultDeclaration";if(!O)return!0;let{type:M}=O;return!!(R&&M!=="ClassDeclaration"&&M!=="FunctionDeclaration"&&M!=="TSInterfaceDeclaration"&&M!=="DeclareClass"&&M!=="DeclareFunction"&&M!=="TSDeclareFunction"&&M!=="EnumDeclaration")}function D(S,k,_){let O=S.getValue();if(!O.source)return"";let R=[];return y(O,k)||R.push(" from"),R.push(" ",_("source")),R}function d(S,k,_){let O=S.getValue();if(y(O,k))return"";let R=[" "];if(t(O.specifiers)){let M=[],H=[];S.each(()=>{let P=S.getValue().type;if(P==="ExportNamespaceSpecifier"||P==="ExportDefaultSpecifier"||P==="ImportNamespaceSpecifier"||P==="ImportDefaultSpecifier")M.push(_());else if(P==="ExportSpecifier"||P==="ImportSpecifier")H.push(_());else throw new Error("Unknown specifier type ".concat(JSON.stringify(P)))},"specifiers"),R.push(u(", ",M)),H.length>0&&(M.length>0&&R.push(", "),H.length>1||M.length>0||O.specifiers.some(G=>m(G))?R.push(i(["{",r([k.bracketSpacing?a:s,u([",",a],H)]),c(p(k)?",":""),k.bracketSpacing?a:s,"}"])):R.push(["{",k.bracketSpacing?" ":"",...H,k.bracketSpacing?" ":"","}"]))}else R.push("{}");return R}function y(S,k){let{type:_,importKind:O,source:R,specifiers:M}=S;return _!=="ImportDeclaration"||t(M)||O==="type"?!1:!/{\s*}/.test(k.originalText.slice(T(S),T(R)))}function o(S,k,_){let O=S.getNode();return t(O.assertions)?[" assert {",k.bracketSpacing?" ":"",u(", ",S.map(_,"assertions")),k.bracketSpacing?" ":"","}"]:""}function x(S,k,_){let O=S.getNode(),{type:R}=O,M=[],H=R==="ImportSpecifier"?O.importKind:O.exportKind;H&&H!=="value"&&M.push(H," ");let P=R.startsWith("Import"),G=P?"imported":"local",re=P?"local":"exported",$=O[G],W=O[re],ee="",U="";return R==="ExportNamespaceSpecifier"||R==="ImportNamespaceSpecifier"?ee="*":$&&(ee=_(G)),W&&!F(O)&&(U=_(re)),M.push(ee,ee&&U?" as ":"",U),M}function F(S){if(S.type!=="ImportSpecifier"&&S.type!=="ExportSpecifier")return!1;let{local:k,[S.type==="ImportSpecifier"?"imported":"exported"]:_}=S;if(k.type!==_.type||!A(k,_))return!1;if(h(k))return k.value===_.value&&N(k)===N(_);switch(k.type){case"Identifier":return k.name===_.name;default:return!1}}n.exports={printImportDeclaration:B,printExportDeclaration:w,printExportAllDeclaration:I,printModuleSpecifier:x}}}),zn=Z({"src/language-js/print/object.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{builders:{line:s,softline:i,group:r,indent:u,ifBreak:a,hardline:c}}=Le(),{getLast:l,hasNewlineInRange:C,hasNewline:m,isNonEmptyArray:g}=Ge(),{shouldPrintComma:p,hasComment:f,getComments:h,CommentCheckFlags:N,isNextLineEmpty:T}=Xe(),{locStart:A,locEnd:b}=nt(),{printOptionalToken:v,printTypeAnnotation:B}=ot(),{shouldHugFunctionParameters:w}=wr(),{shouldHugType:I}=_r(),{printHardlineAfterHeritage:E}=Yt();function D(d,y,o){let x=y.semi?";":"",F=d.getValue(),S;F.type==="TSTypeLiteral"?S="members":F.type==="TSInterfaceBody"?S="body":S="properties";let k=F.type==="ObjectTypeAnnotation",_=[S];k&&_.push("indexers","callProperties","internalSlots");let O=_.map(V=>F[V][0]).sort((V,oe)=>A(V)-A(oe))[0],R=d.getParentNode(0),M=k&&R&&(R.type==="InterfaceDeclaration"||R.type==="DeclareInterface"||R.type==="DeclareClass")&&d.getName()==="body",H=F.type==="TSInterfaceBody"||M||F.type==="ObjectPattern"&&R.type!=="FunctionDeclaration"&&R.type!=="FunctionExpression"&&R.type!=="ArrowFunctionExpression"&&R.type!=="ObjectMethod"&&R.type!=="ClassMethod"&&R.type!=="ClassPrivateMethod"&&R.type!=="AssignmentPattern"&&R.type!=="CatchClause"&&F.properties.some(V=>V.value&&(V.value.type==="ObjectPattern"||V.value.type==="ArrayPattern"))||F.type!=="ObjectPattern"&&O&&C(y.originalText,A(F),A(O)),P=M?";":F.type==="TSInterfaceBody"||F.type==="TSTypeLiteral"?a(x,";"):",",G=F.type==="RecordExpression"?"#{":F.exact?"{|":"{",re=F.exact?"|}":"}",$=[];for(let V of _)d.each(oe=>{let K=oe.getValue();$.push({node:K,printed:o(),loc:A(K)})},V);_.length>1&&$.sort((V,oe)=>V.loc-oe.loc);let W=[],ee=$.map(V=>{let oe=[...W,r(V.printed)];return W=[P,s],(V.node.type==="TSPropertySignature"||V.node.type==="TSMethodSignature"||V.node.type==="TSConstructSignatureDeclaration")&&f(V.node,N.PrettierIgnore)&&W.shift(),T(V.node,y)&&W.push(c),oe});if(F.inexact){let V;if(f(F,N.Dangling)){let oe=f(F,N.Line);V=[t(d,y,!0),oe||m(y.originalText,b(l(h(F))))?c:s,"..."]}else V=["..."];ee.push([...W,...V])}let U=l(F[S]),ne=!(F.inexact||U&&U.type==="RestElement"||U&&(U.type==="TSPropertySignature"||U.type==="TSCallSignatureDeclaration"||U.type==="TSMethodSignature"||U.type==="TSConstructSignatureDeclaration")&&f(U,N.PrettierIgnore)),se;if(ee.length===0){if(!f(F,N.Dangling))return[G,re,B(d,y,o)];se=r([G,t(d,y),i,re,v(d),B(d,y,o)])}else se=[M&&g(F.properties)?E(R):"",G,u([y.bracketSpacing?s:i,...ee]),a(ne&&(P!==","||p(y))?P:""),y.bracketSpacing?s:i,re,v(d),B(d,y,o)];return d.match(V=>V.type==="ObjectPattern"&&!V.decorators,(V,oe,K)=>w(V)&&(oe==="params"||oe==="parameters"||oe==="this"||oe==="rest")&&K===0)||d.match(I,(V,oe)=>oe==="typeAnnotation",(V,oe)=>oe==="typeAnnotation",(V,oe,K)=>w(V)&&(oe==="params"||oe==="parameters"||oe==="this"||oe==="rest")&&K===0)||!H&&d.match(V=>V.type==="ObjectPattern",V=>V.type==="AssignmentExpression"||V.type==="VariableDeclarator")?se:r(se,{shouldBreak:H})}n.exports={printObject:D}}}),wm=Z({"src/language-js/print/flow.js"(e,n){"use strict";ae();var t=Ut(),{printDanglingComments:s}=Qe(),{printString:i,printNumber:r}=Ge(),{builders:{hardline:u,softline:a,group:c,indent:l}}=Le(),{getParentExportDeclaration:C,isFunctionNotation:m,isGetterOrSetter:g,rawText:p,shouldPrintComma:f}=Xe(),{locStart:h,locEnd:N}=nt(),{printClass:T}=Yt(),{printOpaqueType:A,printTypeAlias:b,printIntersectionType:v,printUnionType:B,printFunctionType:w,printTupleType:I,printIndexedAccessType:E}=_r(),{printInterface:D}=ao(),{printTypeParameter:d,printTypeParameters:y}=Pr(),{printExportDeclaration:o,printExportAllDeclaration:x}=io(),{printArrayItems:F}=zt(),{printObject:S}=zn(),{printPropertyKey:k}=Kt(),{printOptionalToken:_,printTypeAnnotation:O,printRestSpread:R}=ot();function M(P,G,re){let $=P.getValue(),W=G.semi?";":"",ee=[];switch($.type){case"DeclareClass":return H(P,T(P,G,re));case"DeclareFunction":return H(P,["function ",re("id"),$.predicate?" ":"",re("predicate"),W]);case"DeclareModule":return H(P,["module ",re("id")," ",re("body")]);case"DeclareModuleExports":return H(P,["module.exports",": ",re("typeAnnotation"),W]);case"DeclareVariable":return H(P,["var ",re("id"),W]);case"DeclareOpaqueType":return H(P,A(P,G,re));case"DeclareInterface":return H(P,D(P,G,re));case"DeclareTypeAlias":return H(P,b(P,G,re));case"DeclareExportDeclaration":return H(P,o(P,G,re));case"DeclareExportAllDeclaration":return H(P,x(P,G,re));case"OpaqueType":return A(P,G,re);case"TypeAlias":return b(P,G,re);case"IntersectionTypeAnnotation":return v(P,G,re);case"UnionTypeAnnotation":return B(P,G,re);case"FunctionTypeAnnotation":return w(P,G,re);case"TupleTypeAnnotation":return I(P,G,re);case"GenericTypeAnnotation":return[re("id"),y(P,G,re,"typeParameters")];case"IndexedAccessType":case"OptionalIndexedAccessType":return E(P,G,re);case"TypeAnnotation":return re("typeAnnotation");case"TypeParameter":return d(P,G,re);case"TypeofTypeAnnotation":return["typeof ",re("argument")];case"ExistsTypeAnnotation":return"*";case"EmptyTypeAnnotation":return"empty";case"MixedTypeAnnotation":return"mixed";case"ArrayTypeAnnotation":return[re("elementType"),"[]"];case"BooleanLiteralTypeAnnotation":return String($.value);case"EnumDeclaration":return["enum ",re("id")," ",re("body")];case"EnumBooleanBody":case"EnumNumberBody":case"EnumStringBody":case"EnumSymbolBody":{if($.type==="EnumSymbolBody"||$.explicitType){let U=null;switch($.type){case"EnumBooleanBody":U="boolean";break;case"EnumNumberBody":U="number";break;case"EnumStringBody":U="string";break;case"EnumSymbolBody":U="symbol";break}ee.push("of ",U," ")}if($.members.length===0&&!$.hasUnknownMembers)ee.push(c(["{",s(P,G),a,"}"]));else{let U=$.members.length>0?[u,F(P,G,"members",re),$.hasUnknownMembers||f(G)?",":""]:[];ee.push(c(["{",l([...U,...$.hasUnknownMembers?[u,"..."]:[]]),s(P,G,!0),u,"}"]))}return ee}case"EnumBooleanMember":case"EnumNumberMember":case"EnumStringMember":return[re("id")," = ",typeof $.init=="object"?re("init"):String($.init)];case"EnumDefaultedMember":return re("id");case"FunctionTypeParam":{let U=$.name?re("name"):P.getParentNode().this===$?"this":"";return[U,_(P),U?": ":"",re("typeAnnotation")]}case"InterfaceDeclaration":case"InterfaceTypeAnnotation":return D(P,G,re);case"ClassImplements":case"InterfaceExtends":return[re("id"),re("typeParameters")];case"NullableTypeAnnotation":return["?",re("typeAnnotation")];case"Variance":{let{kind:U}=$;return t.ok(U==="plus"||U==="minus"),U==="plus"?"+":"-"}case"ObjectTypeCallProperty":return $.static&&ee.push("static "),ee.push(re("value")),ee;case"ObjectTypeIndexer":return[$.static?"static ":"",$.variance?re("variance"):"","[",re("id"),$.id?": ":"",re("key"),"]: ",re("value")];case"ObjectTypeProperty":{let U="";return $.proto?U="proto ":$.static&&(U="static "),[U,g($)?$.kind+" ":"",$.variance?re("variance"):"",k(P,G,re),_(P),m($)?"":": ",re("value")]}case"ObjectTypeAnnotation":return S(P,G,re);case"ObjectTypeInternalSlot":return[$.static?"static ":"","[[",re("id"),"]]",_(P),$.method?"":": ",re("value")];case"ObjectTypeSpreadProperty":return R(P,G,re);case"QualifiedTypeofIdentifier":case"QualifiedTypeIdentifier":return[re("qualification"),".",re("id")];case"StringLiteralTypeAnnotation":return i(p($),G);case"NumberLiteralTypeAnnotation":t.strictEqual(typeof $.value,"number");case"BigIntLiteralTypeAnnotation":return $.extra?r($.extra.raw):r($.raw);case"TypeCastExpression":return["(",re("expression"),O(P,G,re),")"];case"TypeParameterDeclaration":case"TypeParameterInstantiation":{let U=y(P,G,re,"params");if(G.parser==="flow"){let ne=h($),se=N($),V=G.originalText.lastIndexOf("/*",ne),oe=G.originalText.indexOf("*/",se);if(V!==-1&&oe!==-1){let K=G.originalText.slice(V+2,oe).trim();if(K.startsWith("::")&&!K.includes("/*")&&!K.includes("*/"))return["/*:: ",U," */"]}}return U}case"InferredPredicate":return"%checks";case"DeclaredPredicate":return["%checks(",re("value"),")"];case"AnyTypeAnnotation":return"any";case"BooleanTypeAnnotation":return"boolean";case"BigIntTypeAnnotation":return"bigint";case"NullLiteralTypeAnnotation":return"null";case"NumberTypeAnnotation":return"number";case"SymbolTypeAnnotation":return"symbol";case"StringTypeAnnotation":return"string";case"VoidTypeAnnotation":return"void";case"ThisTypeAnnotation":return"this";case"Node":case"Printable":case"SourceLocation":case"Position":case"Statement":case"Function":case"Pattern":case"Expression":case"Declaration":case"Specifier":case"NamedSpecifier":case"Comment":case"MemberTypeAnnotation":case"Type":throw new Error("unprintable type: "+JSON.stringify($.type))}}function H(P,G){let re=C(P);return re?(t.strictEqual(re.type,"DeclareExportDeclaration"),G):["declare ",G]}n.exports={printFlow:M}}}),_m=Z({"src/language-js/utils/is-ts-keyword-type.js"(e,n){"use strict";ae();function t(s){let{type:i}=s;return i.startsWith("TS")&&i.endsWith("Keyword")}n.exports=t}}),oo=Z({"src/language-js/print/ternary.js"(e,n){"use strict";ae();var{hasNewlineInRange:t}=Ge(),{isJsxNode:s,getComments:i,isCallExpression:r,isMemberExpression:u}=Xe(),{locStart:a,locEnd:c}=nt(),l=Pt(),{builders:{line:C,softline:m,group:g,indent:p,align:f,ifBreak:h,dedent:N,breakParent:T}}=Le();function A(I){let E=[I];for(let D=0;D<E.length;D++){let d=E[D];for(let y of["test","consequent","alternate"]){let o=d[y];if(s(o))return!0;o.type==="ConditionalExpression"&&E.push(o)}}return!1}function b(I,E,D){let d=I.getValue(),y=d.type==="ConditionalExpression",o=y?"alternate":"falseType",x=I.getParentNode(),F=y?D("test"):[D("checkType")," ","extends"," ",D("extendsType")];return x.type===d.type&&x[o]===d?f(2,F):F}var v=new Map([["AssignmentExpression","right"],["VariableDeclarator","init"],["ReturnStatement","argument"],["ThrowStatement","argument"],["UnaryExpression","argument"],["YieldExpression","argument"]]);function B(I){let E=I.getValue();if(E.type!=="ConditionalExpression")return!1;let D,d=E;for(let y=0;!D;y++){let o=I.getParentNode(y);if(r(o)&&o.callee===d||u(o)&&o.object===d||o.type==="TSNonNullExpression"&&o.expression===d){d=o;continue}o.type==="NewExpression"&&o.callee===d||o.type==="TSAsExpression"&&o.expression===d?(D=I.getParentNode(y+1),d=o):D=o}return d===E?!1:D[v.get(D.type)]===d}function w(I,E,D){let d=I.getValue(),y=d.type==="ConditionalExpression",o=y?"consequent":"trueType",x=y?"alternate":"falseType",F=y?["test"]:["checkType","extendsType"],S=d[o],k=d[x],_=[],O=!1,R=I.getParentNode(),M=R.type===d.type&&F.some(K=>R[K]===d),H=R.type===d.type&&!M,P,G,re=0;do G=P||d,P=I.getParentNode(re),re++;while(P&&P.type===d.type&&F.every(K=>P[K]!==G));let $=P||R,W=G;if(y&&(s(d[F[0]])||s(S)||s(k)||A(W))){O=!0,H=!0;let K=q=>[h("("),p([m,q]),m,h(")")],Ee=q=>q.type==="NullLiteral"||q.type==="Literal"&&q.value===null||q.type==="Identifier"&&q.name==="undefined";_.push(" ? ",Ee(S)?D(o):K(D(o))," : ",k.type===d.type||Ee(k)?D(x):K(D(x)))}else{let K=[C,"? ",S.type===d.type?h("","("):"",f(2,D(o)),S.type===d.type?h("",")"):"",C,": ",k.type===d.type?D(x):f(2,D(x))];_.push(R.type!==d.type||R[x]===d||M?K:E.useTabs?N(p(K)):f(Math.max(0,E.tabWidth-2),K))}let U=[...F.map(K=>i(d[K])),i(S),i(k)].flat().some(K=>l(K)&&t(E.originalText,a(K),c(K))),ne=K=>R===$?g(K,{shouldBreak:U}):U?[K,T]:K,se=!O&&(u(R)||R.type==="NGPipeExpression"&&R.left===d)&&!R.computed,V=B(I),oe=ne([b(I,E,D),H?_:p(_),y&&se&&!V?m:""]);return M||V?g([p([m,oe]),m]):oe}n.exports={printTernary:w}}}),co=Z({"src/language-js/print/statement.js"(e,n){"use strict";ae();var{builders:{hardline:t}}=Le(),s=kt(),{getLeftSidePathName:i,hasNakedLeftSide:r,isJsxNode:u,isTheOnlyJsxElementInMarkdown:a,hasComment:c,CommentCheckFlags:l,isNextLineEmpty:C}=Xe(),{shouldPrintParamsWithoutParens:m}=Ir();function g(v,B,w,I){let E=v.getValue(),D=[],d=E.type==="ClassBody",y=p(E[I]);return v.each((o,x,F)=>{let S=o.getValue();if(S.type==="EmptyStatement")return;let k=w();!B.semi&&!d&&!a(B,o)&&f(o,B)?c(S,l.Leading)?D.push(w([],{needsSemi:!0})):D.push(";",k):D.push(k),!B.semi&&d&&A(S)&&b(S,F[x+1])&&D.push(";"),S!==y&&(D.push(t),C(S,B)&&D.push(t))},I),D}function p(v){for(let B=v.length-1;B>=0;B--){let w=v[B];if(w.type!=="EmptyStatement")return w}}function f(v,B){return v.getNode().type!=="ExpressionStatement"?!1:v.call(I=>h(I,B),"expression")}function h(v,B){let w=v.getValue();switch(w.type){case"ParenthesizedExpression":case"TypeCastExpression":case"ArrayExpression":case"ArrayPattern":case"TemplateLiteral":case"TemplateElement":case"RegExpLiteral":return!0;case"ArrowFunctionExpression":{if(!m(v,B))return!0;break}case"UnaryExpression":{let{prefix:I,operator:E}=w;if(I&&(E==="+"||E==="-"))return!0;break}case"BindExpression":{if(!w.object)return!0;break}case"Literal":{if(w.regex)return!0;break}default:if(u(w))return!0}return s(v,B)?!0:r(w)?v.call(I=>h(I,B),...i(v,w)):!1}function N(v,B,w){return g(v,B,w,"body")}function T(v,B,w){return g(v,B,w,"consequent")}var A=v=>{let{type:B}=v;return B==="ClassProperty"||B==="PropertyDefinition"||B==="ClassPrivateProperty"||B==="ClassAccessorProperty"};function b(v,B){let w=v.key&&v.key.name;if((w==="static"||w==="get"||w==="set")&&!v.value&&!v.typeAnnotation)return!0;if(!B||B.static||B.accessibility)return!1;if(!B.computed){let I=B.key&&B.key.name;if(I==="in"||I==="instanceof")return!0}if(A(B)&&B.variance&&!B.static&&!B.declare)return!0;switch(B.type){case"ClassProperty":case"PropertyDefinition":case"TSAbstractPropertyDefinition":return B.computed;case"MethodDefinition":case"TSAbstractMethodDefinition":case"ClassMethod":case"ClassPrivateMethod":{if((B.value?B.value.async:B.async)||B.kind==="get"||B.kind==="set")return!1;let E=B.value?B.value.generator:B.generator;return!!(B.computed||E)}case"TSIndexSignature":return!0}return!1}n.exports={printBody:N,printSwitchCaseConsequent:T}}}),lo=Z({"src/language-js/print/block.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{isNonEmptyArray:s}=Ge(),{builders:{hardline:i,indent:r}}=Le(),{hasComment:u,CommentCheckFlags:a,isNextLineEmpty:c}=Xe(),{printHardlineAfterHeritage:l}=Yt(),{printBody:C}=co();function m(p,f,h){let N=p.getValue(),T=[];if(N.type==="StaticBlock"&&T.push("static "),N.type==="ClassBody"&&s(N.body)){let b=p.getParentNode();T.push(l(b))}T.push("{");let A=g(p,f,h);if(A)T.push(r([i,A]),i);else{let b=p.getParentNode(),v=p.getParentNode(1);b.type==="ArrowFunctionExpression"||b.type==="FunctionExpression"||b.type==="FunctionDeclaration"||b.type==="ObjectMethod"||b.type==="ClassMethod"||b.type==="ClassPrivateMethod"||b.type==="ForStatement"||b.type==="WhileStatement"||b.type==="DoWhileStatement"||b.type==="DoExpression"||b.type==="CatchClause"&&!v.finalizer||b.type==="TSModuleDeclaration"||b.type==="TSDeclareFunction"||N.type==="StaticBlock"||N.type==="ClassBody"||T.push(i)}return T.push("}"),T}function g(p,f,h){let N=p.getValue(),T=s(N.directives),A=N.body.some(B=>B.type!=="EmptyStatement"),b=u(N,a.Dangling);if(!T&&!A&&!b)return"";let v=[];if(T&&p.each((B,w,I)=>{v.push(h()),(w<I.length-1||A||b)&&(v.push(i),c(B.getValue(),f)&&v.push(i))},"directives"),A&&v.push(C(p,f,h)),b&&v.push(t(p,f,!0)),N.type==="Program"){let B=p.getParentNode();(!B||B.type!=="ModuleExpression")&&v.push(i)}return v}n.exports={printBlock:m,printBlockBody:g}}}),Pm=Z({"src/language-js/print/typescript.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{hasNewlineInRange:s}=Ge(),{builders:{join:i,line:r,hardline:u,softline:a,group:c,indent:l,conditionalGroup:C,ifBreak:m}}=Le(),{isLiteral:g,getTypeScriptMappedTypeModifier:p,shouldPrintComma:f,isCallExpression:h,isMemberExpression:N}=Xe(),T=_m(),{locStart:A,locEnd:b}=nt(),{printOptionalToken:v,printTypeScriptModifiers:B}=ot(),{printTernary:w}=oo(),{printFunctionParameters:I,shouldGroupFunctionParameters:E}=wr(),{printTemplateLiteral:D}=It(),{printArrayItems:d}=zt(),{printObject:y}=zn(),{printClassProperty:o,printClassMethod:x}=Yt(),{printTypeParameter:F,printTypeParameters:S}=Pr(),{printPropertyKey:k}=Kt(),{printFunction:_,printMethodInternal:O}=Ir(),{printInterface:R}=ao(),{printBlock:M}=lo(),{printTypeAlias:H,printIntersectionType:P,printUnionType:G,printFunctionType:re,printTupleType:$,printIndexedAccessType:W}=_r();function ee(U,ne,se){let V=U.getValue();if(!V.type.startsWith("TS"))return;if(T(V))return V.type.slice(2,-7).toLowerCase();let oe=ne.semi?";":"",K=[];switch(V.type){case"TSThisType":return"this";case"TSTypeAssertion":{let Ee=!(V.expression.type==="ArrayExpression"||V.expression.type==="ObjectExpression"),q=c(["<",l([a,se("typeAnnotation")]),a,">"]),le=[m("("),l([a,se("expression")]),a,m(")")];return Ee?C([[q,se("expression")],[q,c(le,{shouldBreak:!0})],[q,se("expression")]]):c([q,se("expression")])}case"TSDeclareFunction":return _(U,se,ne);case"TSExportAssignment":return["export = ",se("expression"),oe];case"TSModuleBlock":return M(U,ne,se);case"TSInterfaceBody":case"TSTypeLiteral":return y(U,ne,se);case"TSTypeAliasDeclaration":return H(U,ne,se);case"TSQualifiedName":return i(".",[se("left"),se("right")]);case"TSAbstractMethodDefinition":case"TSDeclareMethod":return x(U,ne,se);case"TSAbstractPropertyDefinition":return o(U,ne,se);case"TSInterfaceHeritage":case"TSExpressionWithTypeArguments":return K.push(se("expression")),V.typeParameters&&K.push(se("typeParameters")),K;case"TSTemplateLiteralType":return D(U,se,ne);case"TSNamedTupleMember":return[se("label"),V.optional?"?":"",": ",se("elementType")];case"TSRestType":return["...",se("typeAnnotation")];case"TSOptionalType":return[se("typeAnnotation"),"?"];case"TSInterfaceDeclaration":return R(U,ne,se);case"TSClassImplements":return[se("expression"),se("typeParameters")];case"TSTypeParameterDeclaration":case"TSTypeParameterInstantiation":return S(U,ne,se,"params");case"TSTypeParameter":return F(U,ne,se);case"TSAsExpression":{K.push(se("expression")," as ",se("typeAnnotation"));let Ee=U.getParentNode();return h(Ee)&&Ee.callee===V||N(Ee)&&Ee.object===V?c([l([a,...K]),a]):K}case"TSArrayType":return[se("elementType"),"[]"];case"TSPropertySignature":return V.readonly&&K.push("readonly "),K.push(k(U,ne,se),v(U)),V.typeAnnotation&&K.push(": ",se("typeAnnotation")),V.initializer&&K.push(" = ",se("initializer")),K;case"TSParameterProperty":return V.accessibility&&K.push(V.accessibility+" "),V.export&&K.push("export "),V.static&&K.push("static "),V.override&&K.push("override "),V.readonly&&K.push("readonly "),K.push(se("parameter")),K;case"TSTypeQuery":return["typeof ",se("exprName")];case"TSIndexSignature":{let Ee=U.getParentNode(),q=V.parameters.length>1?m(f(ne)?",":""):"",le=c([l([a,i([", ",a],U.map(se,"parameters"))]),q,a]);return[V.export?"export ":"",V.accessibility?[V.accessibility," "]:"",V.static?"static ":"",V.readonly?"readonly ":"",V.declare?"declare ":"","[",V.parameters?le:"",V.typeAnnotation?"]: ":"]",V.typeAnnotation?se("typeAnnotation"):"",Ee.type==="ClassBody"?oe:""]}case"TSTypePredicate":return[V.asserts?"asserts ":"",se("parameterName"),V.typeAnnotation?[" is ",se("typeAnnotation")]:""];case"TSNonNullExpression":return[se("expression"),"!"];case"TSImportType":return[V.isTypeOf?"typeof ":"","import(",se(V.parameter?"parameter":"argument"),")",V.qualifier?[".",se("qualifier")]:"",S(U,ne,se,"typeParameters")];case"TSLiteralType":return se("literal");case"TSIndexedAccessType":return W(U,ne,se);case"TSConstructSignatureDeclaration":case"TSCallSignatureDeclaration":case"TSConstructorType":{if(V.type==="TSConstructorType"&&V.abstract&&K.push("abstract "),V.type!=="TSCallSignatureDeclaration"&&K.push("new "),K.push(c(I(U,se,ne,!1,!0))),V.returnType||V.typeAnnotation){let Ee=V.type==="TSConstructorType";K.push(Ee?" => ":": ",se("returnType"),se("typeAnnotation"))}return K}case"TSTypeOperator":return[V.operator," ",se("typeAnnotation")];case"TSMappedType":{let Ee=s(ne.originalText,A(V),b(V));return c(["{",l([ne.bracketSpacing?r:a,V.readonly?[p(V.readonly,"readonly")," "]:"",B(U,ne,se),se("typeParameter"),V.optional?p(V.optional,"?"):"",V.typeAnnotation?": ":"",se("typeAnnotation"),m(oe)]),t(U,ne,!0),ne.bracketSpacing?r:a,"}"],{shouldBreak:Ee})}case"TSMethodSignature":{let Ee=V.kind&&V.kind!=="method"?"".concat(V.kind," "):"";K.push(V.accessibility?[V.accessibility," "]:"",Ee,V.export?"export ":"",V.static?"static ":"",V.readonly?"readonly ":"",V.abstract?"abstract ":"",V.declare?"declare ":"",V.computed?"[":"",se("key"),V.computed?"]":"",v(U));let q=I(U,se,ne,!1,!0),le=V.returnType?"returnType":"typeAnnotation",ue=V[le],Q=ue?se(le):"",de=E(V,Q);return K.push(de?c(q):q),ue&&K.push(": ",c(Q)),c(K)}case"TSNamespaceExportDeclaration":return K.push("export as namespace ",se("id")),ne.semi&&K.push(";"),c(K);case"TSEnumDeclaration":return V.declare&&K.push("declare "),V.modifiers&&K.push(B(U,ne,se)),V.const&&K.push("const "),K.push("enum ",se("id")," "),V.members.length===0?K.push(c(["{",t(U,ne),a,"}"])):K.push(c(["{",l([u,d(U,ne,"members",se),f(ne,"es5")?",":""]),t(U,ne,!0),u,"}"])),K;case"TSEnumMember":return K.push(se("id")),V.initializer&&K.push(" = ",se("initializer")),K;case"TSImportEqualsDeclaration":return V.isExport&&K.push("export "),K.push("import "),V.importKind&&V.importKind!=="value"&&K.push(V.importKind," "),K.push(se("id")," = ",se("moduleReference")),ne.semi&&K.push(";"),c(K);case"TSExternalModuleReference":return["require(",se("expression"),")"];case"TSModuleDeclaration":{let Ee=U.getParentNode(),q=g(V.id),le=Ee.type==="TSModuleDeclaration",ue=V.body&&V.body.type==="TSModuleDeclaration";if(le)K.push(".");else{V.declare&&K.push("declare "),K.push(B(U,ne,se));let Q=ne.originalText.slice(A(V),A(V.id));V.id.type==="Identifier"&&V.id.name==="global"&&!/namespace|module/.test(Q)||K.push(q||/(?:^|\s)module(?:\s|$)/.test(Q)?"module ":"namespace ")}return K.push(se("id")),ue?K.push(se("body")):V.body?K.push(" ",c(se("body"))):K.push(oe),K}case"TSConditionalType":return w(U,ne,se);case"TSInferType":return["infer"," ",se("typeParameter")];case"TSIntersectionType":return P(U,ne,se);case"TSUnionType":return G(U,ne,se);case"TSFunctionType":return re(U,ne,se);case"TSTupleType":return $(U,ne,se);case"TSTypeReference":return[se("typeName"),S(U,ne,se,"typeParameters")];case"TSTypeAnnotation":return se("typeAnnotation");case"TSEmptyBodyFunctionExpression":return O(U,ne,se);case"TSJSDocAllType":return"*";case"TSJSDocUnknownType":return"?";case"TSJSDocNullableType":return["?",se("typeAnnotation")];case"TSJSDocNonNullableType":return["!",se("typeAnnotation")];default:throw new Error("Unknown TypeScript node type: ".concat(JSON.stringify(V.type),"."))}}n.exports={printTypescript:ee}}}),Im=Z({"src/language-js/print/comment.js"(e,n){"use strict";ae();var{hasNewline:t}=Ge(),{builders:{join:s,hardline:i},utils:{replaceTextEndOfLine:r}}=Le(),{isLineComment:u}=Xe(),{locStart:a,locEnd:c}=nt(),l=Pt();function C(p,f){let h=p.getValue();if(u(h))return f.originalText.slice(a(h),c(h)).trimEnd();if(l(h)){if(m(h)){let A=g(h);return h.trailing&&!t(f.originalText,a(h),{backwards:!0})?[i,A]:A}let N=c(h),T=f.originalText.slice(N-3,N)==="*-/";return["/*",r(h.value),T?"*-/":"*/"]}throw new Error("Not a comment: "+JSON.stringify(h))}function m(p){let f="*".concat(p.value,"*").split(` |
| | | `);return f.length>1&&f.every(h=>h.trim()[0]==="*")}function g(p){let f=p.value.split(` |
| | | `);return["/*",s(i,f.map((h,N)=>N===0?h.trimEnd():" "+(N<f.length-1?h.trim():h.trimStart()))),"*/"]}n.exports={printComment:C}}}),km=Z({"src/language-js/print/literal.js"(e,n){"use strict";ae();var{printString:t,printNumber:s}=Ge();function i(a,c){let l=a.getNode();switch(l.type){case"RegExpLiteral":return u(l);case"BigIntLiteral":return r(l.bigint||l.extra.raw);case"NumericLiteral":return s(l.extra.raw);case"StringLiteral":return t(l.extra.raw,c);case"NullLiteral":return"null";case"BooleanLiteral":return String(l.value);case"DecimalLiteral":return s(l.value)+"m";case"Literal":{if(l.regex)return u(l.regex);if(l.bigint)return r(l.raw);if(l.decimal)return s(l.decimal)+"m";let{value:C}=l;return typeof C=="number"?s(l.raw):typeof C=="string"?t(l.raw,c):String(C)}}}function r(a){return a.toLowerCase()}function u(a){let{pattern:c,flags:l}=a;return l=[...l].sort().join(""),"/".concat(c,"/").concat(l)}n.exports={printLiteral:i}}}),Lm=Z({"src/language-js/printer-estree.js"(e,n){"use strict";ae();var{printDanglingComments:t}=Qe(),{hasNewline:s}=Ge(),{builders:{join:i,line:r,hardline:u,softline:a,group:c,indent:l},utils:{replaceTextEndOfLine:C}}=Le(),m=ym(),g=hm(),{insertPragma:p}=eo(),f=to(),h=kt(),N=ro(),{hasFlowShorthandAnnotationComment:T,hasComment:A,CommentCheckFlags:b,isTheOnlyJsxElementInMarkdown:v,isLineComment:B,isNextLineEmpty:w,needsHardlineAfterDanglingComment:I,rawText:E,hasIgnoreComment:D,isCallExpression:d,isMemberExpression:y,markerForIfWithoutBlockAndSameLineComment:o}=Xe(),{locStart:x,locEnd:F}=nt(),S=Pt(),{printHtmlBinding:k,isVueEventBindingExpression:_}=bm(),{printAngular:O}=Tm(),{printJsx:R,hasJsxIgnoreComment:M}=Bm(),{printFlow:H}=wm(),{printTypescript:P}=Pm(),{printOptionalToken:G,printBindExpressionCallee:re,printTypeAnnotation:$,adjustClause:W,printRestSpread:ee,printDefiniteToken:U}=ot(),{printImportDeclaration:ne,printExportDeclaration:se,printExportAllDeclaration:V,printModuleSpecifier:oe}=io(),{printTernary:K}=oo(),{printTemplateLiteral:Ee}=It(),{printArray:q}=zt(),{printObject:le}=zn(),{printClass:ue,printClassMethod:Q,printClassProperty:de}=Yt(),{printProperty:ge}=Kt(),{printFunction:ve,printArrowFunction:xe,printMethod:we,printReturnStatement:fe,printThrowStatement:pe}=Ir(),{printCallExpression:me}=so(),{printVariableDeclarator:ce,printAssignmentExpression:he}=Xt(),{printBinaryishExpression:J}=Jn(),{printSwitchCaseConsequent:ye}=co(),{printMemberExpression:X}=uo(),{printBlock:Y,printBlockBody:te}=lo(),{printComment:z}=Im(),{printLiteral:j}=km(),{printDecorators:Ce}=Un();function Ne(Te,_e,Fe,Ke){let Se=je(Te,_e,Fe,Ke);if(!Se)return"";let ze=Te.getValue(),{type:Be}=ze;if(Be==="ClassMethod"||Be==="ClassPrivateMethod"||Be==="ClassProperty"||Be==="ClassAccessorProperty"||Be==="PropertyDefinition"||Be==="TSAbstractPropertyDefinition"||Be==="ClassPrivateProperty"||Be==="MethodDefinition"||Be==="TSAbstractMethodDefinition"||Be==="TSDeclareMethod")return Se;let Ie=[Se],Ve=Ce(Te,_e,Fe),Ae=ze.type==="ClassExpression"&&Ve;if(Ve&&(Ie=[...Ve,Se],!Ae))return c(Ie);if(!h(Te,_e))return Ke&&Ke.needsSemi&&Ie.unshift(";"),Ie.length===1&&Ie[0]===Se?Se:Ie;if(Ae&&(Ie=[l([r,...Ie])]),Ie.unshift("("),Ke&&Ke.needsSemi&&Ie.unshift(";"),T(ze)){let[Pe]=ze.trailingComments;Ie.push(" /*",Pe.value.trimStart(),"*/"),Pe.printed=!0}return Ae&&Ie.push(r),Ie.push(")"),Ie}function je(Te,_e,Fe,Ke){let Se=Te.getValue(),ze=_e.semi?";":"";if(!Se)return"";if(typeof Se=="string")return Se;for(let Ie of[j,k,O,R,H,P]){let Ve=Ie(Te,_e,Fe);if(typeof Ve<"u")return Ve}let Be=[];switch(Se.type){case"JsExpressionRoot":return Fe("node");case"JsonRoot":return[Fe("node"),u];case"File":return Se.program&&Se.program.interpreter&&Be.push(Fe(["program","interpreter"])),Be.push(Fe("program")),Be;case"Program":return te(Te,_e,Fe);case"EmptyStatement":return"";case"ExpressionStatement":{if(Se.directive)return[Ue(Se.expression,_e),ze];if(_e.parser==="__vue_event_binding"){let Ve=Te.getParentNode();if(Ve.type==="Program"&&Ve.body.length===1&&Ve.body[0]===Se)return[Fe("expression"),_(Se.expression)?";":""]}let Ie=t(Te,_e,!0,Ve=>{let{marker:Ae}=Ve;return Ae===o});return[Fe("expression"),v(_e,Te)?"":ze,Ie?[" ",Ie]:""]}case"ParenthesizedExpression":return!A(Se.expression)&&(Se.expression.type==="ObjectExpression"||Se.expression.type==="ArrayExpression")?["(",Fe("expression"),")"]:c(["(",l([a,Fe("expression")]),a,")"]);case"AssignmentExpression":return he(Te,_e,Fe);case"VariableDeclarator":return ce(Te,_e,Fe);case"BinaryExpression":case"LogicalExpression":return J(Te,_e,Fe);case"AssignmentPattern":return[Fe("left")," = ",Fe("right")];case"OptionalMemberExpression":case"MemberExpression":return X(Te,_e,Fe);case"MetaProperty":return[Fe("meta"),".",Fe("property")];case"BindExpression":return Se.object&&Be.push(Fe("object")),Be.push(c(l([a,re(Te,_e,Fe)]))),Be;case"Identifier":return[Se.name,G(Te),U(Te),$(Te,_e,Fe)];case"V8IntrinsicIdentifier":return["%",Se.name];case"SpreadElement":case"SpreadElementPattern":case"SpreadProperty":case"SpreadPropertyPattern":case"RestElement":return ee(Te,_e,Fe);case"FunctionDeclaration":case"FunctionExpression":return ve(Te,Fe,_e,Ke);case"ArrowFunctionExpression":return xe(Te,_e,Fe,Ke);case"YieldExpression":return Be.push("yield"),Se.delegate&&Be.push("*"),Se.argument&&Be.push(" ",Fe("argument")),Be;case"AwaitExpression":{if(Be.push("await"),Se.argument){Be.push(" ",Fe("argument"));let Ie=Te.getParentNode();if(d(Ie)&&Ie.callee===Se||y(Ie)&&Ie.object===Se){Be=[l([a,...Be]),a];let Ve=Te.findAncestor(Ae=>Ae.type==="AwaitExpression"||Ae.type==="BlockStatement");if(!Ve||Ve.type!=="AwaitExpression")return c(Be)}}return Be}case"ExportDefaultDeclaration":case"ExportNamedDeclaration":return se(Te,_e,Fe);case"ExportAllDeclaration":return V(Te,_e,Fe);case"ImportDeclaration":return ne(Te,_e,Fe);case"ImportSpecifier":case"ExportSpecifier":case"ImportNamespaceSpecifier":case"ExportNamespaceSpecifier":case"ImportDefaultSpecifier":case"ExportDefaultSpecifier":return oe(Te,_e,Fe);case"ImportAttribute":return[Fe("key"),": ",Fe("value")];case"Import":return"import";case"BlockStatement":case"StaticBlock":case"ClassBody":return Y(Te,_e,Fe);case"ThrowStatement":return pe(Te,_e,Fe);case"ReturnStatement":return fe(Te,_e,Fe);case"NewExpression":case"ImportExpression":case"OptionalCallExpression":case"CallExpression":return me(Te,_e,Fe);case"ObjectExpression":case"ObjectPattern":case"RecordExpression":return le(Te,_e,Fe);case"ObjectProperty":case"Property":return Se.method||Se.kind==="get"||Se.kind==="set"?we(Te,_e,Fe):ge(Te,_e,Fe);case"ObjectMethod":return we(Te,_e,Fe);case"Decorator":return["@",Fe("expression")];case"ArrayExpression":case"ArrayPattern":case"TupleExpression":return q(Te,_e,Fe);case"SequenceExpression":{let Ie=Te.getParentNode(0);if(Ie.type==="ExpressionStatement"||Ie.type==="ForStatement"){let Ve=[];return Te.each((Ae,Oe)=>{Oe===0?Ve.push(Fe()):Ve.push(",",l([r,Fe()]))},"expressions"),c(Ve)}return c(i([",",r],Te.map(Fe,"expressions")))}case"ThisExpression":return"this";case"Super":return"super";case"Directive":return[Fe("value"),ze];case"DirectiveLiteral":return Ue(Se,_e);case"UnaryExpression":return Be.push(Se.operator),/[a-z]$/.test(Se.operator)&&Be.push(" "),A(Se.argument)?Be.push(c(["(",l([a,Fe("argument")]),a,")"])):Be.push(Fe("argument")),Be;case"UpdateExpression":return Be.push(Fe("argument"),Se.operator),Se.prefix&&Be.reverse(),Be;case"ConditionalExpression":return K(Te,_e,Fe);case"VariableDeclaration":{let Ie=Te.map(Fe,"declarations"),Ve=Te.getParentNode(),Ae=Ve.type==="ForStatement"||Ve.type==="ForInStatement"||Ve.type==="ForOfStatement",Oe=Se.declarations.some(ie=>ie.init),Pe;return Ie.length===1&&!A(Se.declarations[0])?Pe=Ie[0]:Ie.length>0&&(Pe=l(Ie[0])),Be=[Se.declare?"declare ":"",Se.kind,Pe?[" ",Pe]:"",l(Ie.slice(1).map(ie=>[",",Oe&&!Ae?u:r,ie]))],Ae&&Ve.body!==Se||Be.push(ze),c(Be)}case"WithStatement":return c(["with (",Fe("object"),")",W(Se.body,Fe("body"))]);case"IfStatement":{let Ie=W(Se.consequent,Fe("consequent")),Ve=c(["if (",c([l([a,Fe("test")]),a]),")",Ie]);if(Be.push(Ve),Se.alternate){let Ae=A(Se.consequent,b.Trailing|b.Line)||I(Se),Oe=Se.consequent.type==="BlockStatement"&&!Ae;Be.push(Oe?" ":u),A(Se,b.Dangling)&&Be.push(t(Te,_e,!0),Ae?u:" "),Be.push("else",c(W(Se.alternate,Fe("alternate"),Se.alternate.type==="IfStatement")))}return Be}case"ForStatement":{let Ie=W(Se.body,Fe("body")),Ve=t(Te,_e,!0),Ae=Ve?[Ve,a]:"";return!Se.init&&!Se.test&&!Se.update?[Ae,c(["for (;;)",Ie])]:[Ae,c(["for (",c([l([a,Fe("init"),";",r,Fe("test"),";",r,Fe("update")]),a]),")",Ie])]}case"WhileStatement":return c(["while (",c([l([a,Fe("test")]),a]),")",W(Se.body,Fe("body"))]);case"ForInStatement":return c(["for (",Fe("left")," in ",Fe("right"),")",W(Se.body,Fe("body"))]);case"ForOfStatement":return c(["for",Se.await?" await":""," (",Fe("left")," of ",Fe("right"),")",W(Se.body,Fe("body"))]);case"DoWhileStatement":{let Ie=W(Se.body,Fe("body"));return Be=[c(["do",Ie])],Se.body.type==="BlockStatement"?Be.push(" "):Be.push(u),Be.push("while (",c([l([a,Fe("test")]),a]),")",ze),Be}case"DoExpression":return[Se.async?"async ":"","do ",Fe("body")];case"BreakStatement":return Be.push("break"),Se.label&&Be.push(" ",Fe("label")),Be.push(ze),Be;case"ContinueStatement":return Be.push("continue"),Se.label&&Be.push(" ",Fe("label")),Be.push(ze),Be;case"LabeledStatement":return Se.body.type==="EmptyStatement"?[Fe("label"),":;"]:[Fe("label"),": ",Fe("body")];case"TryStatement":return["try ",Fe("block"),Se.handler?[" ",Fe("handler")]:"",Se.finalizer?[" finally ",Fe("finalizer")]:""];case"CatchClause":if(Se.param){let Ie=A(Se.param,Ae=>!S(Ae)||Ae.leading&&s(_e.originalText,F(Ae))||Ae.trailing&&s(_e.originalText,x(Ae),{backwards:!0})),Ve=Fe("param");return["catch ",Ie?["(",l([a,Ve]),a,") "]:["(",Ve,") "],Fe("body")]}return["catch ",Fe("body")];case"SwitchStatement":return[c(["switch (",l([a,Fe("discriminant")]),a,")"])," {",Se.cases.length>0?l([u,i(u,Te.map((Ie,Ve,Ae)=>{let Oe=Ie.getValue();return[Fe(),Ve!==Ae.length-1&&w(Oe,_e)?u:""]},"cases"))]):"",u,"}"];case"SwitchCase":{Se.test?Be.push("case ",Fe("test"),":"):Be.push("default:"),A(Se,b.Dangling)&&Be.push(" ",t(Te,_e,!0));let Ie=Se.consequent.filter(Ve=>Ve.type!=="EmptyStatement");if(Ie.length>0){let Ve=ye(Te,_e,Fe);Be.push(Ie.length===1&&Ie[0].type==="BlockStatement"?[" ",Ve]:l([u,Ve]))}return Be}case"DebuggerStatement":return["debugger",ze];case"ClassDeclaration":case"ClassExpression":return ue(Te,_e,Fe);case"ClassMethod":case"ClassPrivateMethod":case"MethodDefinition":return Q(Te,_e,Fe);case"ClassProperty":case"PropertyDefinition":case"ClassPrivateProperty":case"ClassAccessorProperty":return de(Te,_e,Fe);case"TemplateElement":return C(Se.value.raw);case"TemplateLiteral":return Ee(Te,Fe,_e);case"TaggedTemplateExpression":return[Fe("tag"),Fe("typeParameters"),Fe("quasi")];case"PrivateIdentifier":return["#",Fe("name")];case"PrivateName":return["#",Fe("id")];case"InterpreterDirective":return Be.push("#!",Se.value,u),w(Se,_e)&&Be.push(u),Be;case"TopicReference":return"%";case"ArgumentPlaceholder":return"?";case"ModuleExpression":{Be.push("module {");let Ie=Fe("body");return Ie&&Be.push(l([u,Ie]),u),Be.push("}"),Be}default:throw new Error("unknown type: "+JSON.stringify(Se.type))}}function Ue(Te,_e){let Fe=E(Te),Ke=Fe.slice(1,-1);if(Ke.includes('"')||Ke.includes("'"))return Fe;let Se=_e.singleQuote?"'":'"';return Se+Ke+Se}function tt(Te){return Te.type&&!S(Te)&&!B(Te)&&Te.type!=="EmptyStatement"&&Te.type!=="TemplateElement"&&Te.type!=="Import"&&Te.type!=="TSEmptyBodyFunctionExpression"}n.exports={preprocess:N,print:Ne,embed:m,insertPragma:p,massageAstNode:g,hasPrettierIgnore(Te){return D(Te)||M(Te)},willPrintOwnComments:f.willPrintOwnComments,canAttachComment:tt,printComment:z,isBlockComment:S,handleComments:{avoidAstMutation:!0,ownLine:f.handleOwnLineComment,endOfLine:f.handleEndOfLineComment,remaining:f.handleRemainingComment},getCommentChildNodes:f.getCommentChildNodes}}}),Om=Z({"src/language-js/printer-estree-json.js"(e,n){"use strict";ae();var{builders:{hardline:t,indent:s,join:i}}=Le(),r=ro();function u(l,C,m){let g=l.getValue();switch(g.type){case"JsonRoot":return[m("node"),t];case"ArrayExpression":{if(g.elements.length===0)return"[]";let p=l.map(()=>l.getValue()===null?"null":m(),"elements");return["[",s([t,i([",",t],p)]),t,"]"]}case"ObjectExpression":return g.properties.length===0?"{}":["{",s([t,i([",",t],l.map(m,"properties"))]),t,"}"];case"ObjectProperty":return[m("key"),": ",m("value")];case"UnaryExpression":return[g.operator==="+"?"":g.operator,m("argument")];case"NullLiteral":return"null";case"BooleanLiteral":return g.value?"true":"false";case"StringLiteral":case"NumericLiteral":return JSON.stringify(g.value);case"Identifier":{let p=l.getParentNode();return p&&p.type==="ObjectProperty"&&p.key===g?JSON.stringify(g.name):g.name}case"TemplateLiteral":return m(["quasis",0]);case"TemplateElement":return JSON.stringify(g.value.cooked);default:throw new Error("unknown type: "+JSON.stringify(g.type))}}var a=new Set(["start","end","extra","loc","comments","leadingComments","trailingComments","innerComments","errors","range","tokens"]);function c(l,C){let{type:m}=l;if(m==="ObjectProperty"&&l.key.type==="Identifier"){C.key={type:"StringLiteral",value:l.key.name};return}if(m==="UnaryExpression"&&l.operator==="+")return C.argument;if(m==="ArrayExpression"){for(let[g,p]of l.elements.entries())p===null&&C.elements.splice(g,0,{type:"NullLiteral"});return}if(m==="TemplateLiteral")return{type:"StringLiteral",value:l.quasis[0].value.cooked}}c.ignoredProperties=a,n.exports={preprocess:r,print:u,massageAstNode:c}}}),Lt=Z({"src/common/common-options.js"(e,n){"use strict";ae();var t="Common";n.exports={bracketSpacing:{since:"0.0.0",category:t,type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},singleQuote:{since:"0.0.0",category:t,type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{since:"1.8.2",category:t,type:"choice",default:[{since:"1.8.2",value:!0},{since:"1.9.0",value:"preserve"}],description:"How to wrap prose.",choices:[{since:"1.9.0",value:"always",description:"Wrap prose if it exceeds the print width."},{since:"1.9.0",value:"never",description:"Do not wrap prose."},{since:"1.9.0",value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{since:"2.4.0",category:t,type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{since:"2.6.0",category:t,type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}}}}),jm=Z({"src/language-js/options.js"(e,n){"use strict";ae();var t=Lt(),s="JavaScript";n.exports={arrowParens:{since:"1.9.0",category:s,type:"choice",default:[{since:"1.9.0",value:"avoid"},{since:"2.0.0",value:"always"}],description:"Include parentheses around a sole arrow function parameter.",choices:[{value:"always",description:"Always include parens. Example: `(x) => x`"},{value:"avoid",description:"Omit parens when possible. Example: `x => x`"}]},bracketSameLine:t.bracketSameLine,bracketSpacing:t.bracketSpacing,jsxBracketSameLine:{since:"0.17.0",category:s,type:"boolean",description:"Put > on the last line instead of at a new line.",deprecated:"2.4.0"},semi:{since:"1.0.0",category:s,type:"boolean",default:!0,description:"Print semicolons.",oppositeDescription:"Do not print semicolons, except at the beginning of lines which may need them."},singleQuote:t.singleQuote,jsxSingleQuote:{since:"1.15.0",category:s,type:"boolean",default:!1,description:"Use single quotes in JSX."},quoteProps:{since:"1.17.0",category:s,type:"choice",default:"as-needed",description:"Change when properties in objects are quoted.",choices:[{value:"as-needed",description:"Only add quotes around object properties where required."},{value:"consistent",description:"If at least one property in an object requires quotes, quote all properties."},{value:"preserve",description:"Respect the input use of quotes in object properties."}]},trailingComma:{since:"0.0.0",category:s,type:"choice",default:[{since:"0.0.0",value:!1},{since:"0.19.0",value:"none"},{since:"2.0.0",value:"es5"}],description:"Print trailing commas wherever possible when multi-line.",choices:[{value:"es5",description:"Trailing commas where valid in ES5 (objects, arrays, etc.)"},{value:"none",description:"No trailing commas."},{value:"all",description:"Trailing commas wherever possible (including function arguments)."}]},singleAttributePerLine:t.singleAttributePerLine}}}),qm=Z({"src/language-js/parse/parsers.js"(){ae()}}),Fn=Z({"node_modules/linguist-languages/data/JavaScript.json"(e,n){n.exports={name:"JavaScript",type:"programming",tmScope:"source.js",aceMode:"javascript",codemirrorMode:"javascript",codemirrorMimeType:"text/javascript",color:"#f1e05a",aliases:["js","node"],extensions:[".js","._js",".bones",".cjs",".es",".es6",".frag",".gs",".jake",".jsb",".jscad",".jsfl",".jsm",".jss",".jsx",".mjs",".njs",".pac",".sjs",".ssjs",".xsjs",".xsjslib"],filenames:["Jakefile"],interpreters:["chakra","d8","gjs","js","node","nodejs","qjs","rhino","v8","v8-shell"],languageId:183}}}),Mm=Z({"node_modules/linguist-languages/data/TypeScript.json"(e,n){n.exports={name:"TypeScript",type:"programming",color:"#2b7489",aliases:["ts"],interpreters:["deno","ts-node"],extensions:[".ts"],tmScope:"source.ts",aceMode:"typescript",codemirrorMode:"javascript",codemirrorMimeType:"application/typescript",languageId:378}}}),Rm=Z({"node_modules/linguist-languages/data/TSX.json"(e,n){n.exports={name:"TSX",type:"programming",group:"TypeScript",extensions:[".tsx"],tmScope:"source.tsx",aceMode:"javascript",codemirrorMode:"jsx",codemirrorMimeType:"text/jsx",languageId:94901924}}}),mi=Z({"node_modules/linguist-languages/data/JSON.json"(e,n){n.exports={name:"JSON",type:"data",tmScope:"source.json",aceMode:"json",codemirrorMode:"javascript",codemirrorMimeType:"application/json",extensions:[".json",".avsc",".geojson",".gltf",".har",".ice",".JSON-tmLanguage",".jsonl",".mcmeta",".tfstate",".tfstate.backup",".topojson",".webapp",".webmanifest",".yy",".yyp"],filenames:[".arcconfig",".htmlhintrc",".imgbotconfig",".tern-config",".tern-project",".watchmanconfig","Pipfile.lock","composer.lock","mcmod.info"],languageId:174}}}),Vm=Z({"node_modules/linguist-languages/data/JSON with Comments.json"(e,n){n.exports={name:"JSON with Comments",type:"data",group:"JSON",tmScope:"source.js",aceMode:"javascript",codemirrorMode:"javascript",codemirrorMimeType:"text/javascript",aliases:["jsonc"],extensions:[".jsonc",".sublime-build",".sublime-commands",".sublime-completions",".sublime-keymap",".sublime-macro",".sublime-menu",".sublime-mousemap",".sublime-project",".sublime-settings",".sublime-theme",".sublime-workspace",".sublime_metrics",".sublime_session"],filenames:[".babelrc",".eslintrc.json",".jscsrc",".jshintrc",".jslintrc","api-extractor.json","devcontainer.json","jsconfig.json","language-configuration.json","tsconfig.json","tslint.json"],languageId:423}}}),Wm=Z({"node_modules/linguist-languages/data/JSON5.json"(e,n){n.exports={name:"JSON5",type:"data",extensions:[".json5"],tmScope:"source.js",aceMode:"javascript",codemirrorMode:"javascript",codemirrorMimeType:"application/json",languageId:175}}}),$m=Z({"src/language-js/index.js"(e,n){"use strict";ae();var t=bt(),s=Lm(),i=Om(),r=jm(),u=qm(),a=[t(Fn(),l=>({since:"0.0.0",parsers:["babel","acorn","espree","meriyah","babel-flow","babel-ts","flow","typescript"],vscodeLanguageIds:["javascript","mongo"],interpreters:[...l.interpreters,"zx"],extensions:[...l.extensions.filter(C=>C!==".jsx"),".wxs"]})),t(Fn(),()=>({name:"Flow",since:"0.0.0",parsers:["flow","babel-flow"],vscodeLanguageIds:["javascript"],aliases:[],filenames:[],extensions:[".js.flow"]})),t(Fn(),()=>({name:"JSX",since:"0.0.0",parsers:["babel","babel-flow","babel-ts","flow","typescript","espree","meriyah"],vscodeLanguageIds:["javascriptreact"],aliases:void 0,filenames:void 0,extensions:[".jsx"],group:"JavaScript",interpreters:void 0,tmScope:"source.js.jsx",aceMode:"javascript",codemirrorMode:"jsx",codemirrorMimeType:"text/jsx",color:void 0})),t(Mm(),l=>({since:"1.4.0",parsers:["typescript","babel-ts"],vscodeLanguageIds:["typescript"],extensions:[...l.extensions,".mts",".cts"]})),t(Rm(),()=>({since:"1.4.0",parsers:["typescript","babel-ts"],vscodeLanguageIds:["typescriptreact"]})),t(mi(),()=>({name:"JSON.stringify",since:"1.13.0",parsers:["json-stringify"],vscodeLanguageIds:["json"],extensions:[],filenames:["package.json","package-lock.json","composer.json"]})),t(mi(),l=>({since:"1.5.0",parsers:["json"],vscodeLanguageIds:["json"],extensions:l.extensions.filter(C=>C!==".jsonl")})),t(Vm(),l=>({since:"1.5.0",parsers:["json"],vscodeLanguageIds:["jsonc"],filenames:[...l.filenames,".eslintrc",".swcrc"]})),t(Wm(),()=>({since:"1.13.0",parsers:["json5"],vscodeLanguageIds:["json5"]}))],c={estree:s,"estree-json":i};n.exports={languages:a,options:r,printers:c,parsers:u}}}),Hm=Z({"src/language-css/clean.js"(e,n){"use strict";ae();var{isFrontMatterNode:t}=Ge(),s=st(),i=new Set(["raw","raws","sourceIndex","source","before","after","trailingComma"]);function r(a,c,l){if(t(a)&&a.lang==="yaml"&&delete c.value,a.type==="css-comment"&&l.type==="css-root"&&l.nodes.length>0&&((l.nodes[0]===a||t(l.nodes[0])&&l.nodes[1]===a)&&(delete c.text,/^\*\s*@(?:format|prettier)\s*$/.test(a.text))||l.type==="css-root"&&s(l.nodes)===a))return null;if(a.type==="value-root"&&delete c.text,(a.type==="media-query"||a.type==="media-query-list"||a.type==="media-feature-expression")&&delete c.value,a.type==="css-rule"&&delete c.params,a.type==="selector-combinator"&&(c.value=c.value.replace(/\s+/g," ")),a.type==="media-feature"&&(c.value=c.value.replace(/ /g,"")),(a.type==="value-word"&&(a.isColor&&a.isHex||["initial","inherit","unset","revert"].includes(c.value.replace().toLowerCase()))||a.type==="media-feature"||a.type==="selector-root-invalid"||a.type==="selector-pseudo")&&(c.value=c.value.toLowerCase()),a.type==="css-decl"&&(c.prop=c.prop.toLowerCase()),(a.type==="css-atrule"||a.type==="css-import")&&(c.name=c.name.toLowerCase()),a.type==="value-number"&&(c.unit=c.unit.toLowerCase()),(a.type==="media-feature"||a.type==="media-keyword"||a.type==="media-type"||a.type==="media-unknown"||a.type==="media-url"||a.type==="media-value"||a.type==="selector-attribute"||a.type==="selector-string"||a.type==="selector-class"||a.type==="selector-combinator"||a.type==="value-string")&&c.value&&(c.value=u(c.value)),a.type==="selector-attribute"&&(c.attribute=c.attribute.trim(),c.namespace&&typeof c.namespace=="string"&&(c.namespace=c.namespace.trim(),c.namespace.length===0&&(c.namespace=!0)),c.value&&(c.value=c.value.trim().replace(/^["']|["']$/g,""),delete c.quoted)),(a.type==="media-value"||a.type==="media-type"||a.type==="value-number"||a.type==="selector-root-invalid"||a.type==="selector-class"||a.type==="selector-combinator"||a.type==="selector-tag")&&c.value&&(c.value=c.value.replace(/([\d+.Ee-]+)([A-Za-z]*)/g,(C,m,g)=>{let p=Number(m);return Number.isNaN(p)?C:p+g.toLowerCase()})),a.type==="selector-tag"){let C=a.value.toLowerCase();["from","to"].includes(C)&&(c.value=C)}if(a.type==="css-atrule"&&a.name.toLowerCase()==="supports"&&delete c.value,a.type==="selector-unknown"&&delete c.value,a.type==="value-comma_group"){let C=a.groups.findIndex(m=>m.type==="value-number"&&m.unit==="...");C!==-1&&(c.groups[C].unit="",c.groups.splice(C+1,0,{type:"value-word",value:"...",isColor:!1,isHex:!1}))}}r.ignoredProperties=i;function u(a){return a.replace(/'/g,'"').replace(/\\([^\dA-Fa-f])/g,"$1")}n.exports=r}}),Xn=Z({"src/utils/front-matter/print.js"(e,n){"use strict";ae();var{builders:{hardline:t,markAsRoot:s}}=Le();function i(r,u){if(r.lang==="yaml"){let a=r.value.trim(),c=a?u(a,{parser:"yaml"},{stripTrailingHardline:!0}):"";return s([r.startDelimiter,t,c,c?t:"",r.endDelimiter])}}n.exports=i}}),Gm=Z({"src/language-css/embed.js"(e,n){"use strict";ae();var{builders:{hardline:t}}=Le(),s=Xn();function i(r,u,a){let c=r.getValue();if(c.type==="front-matter"){let l=s(c,a);return l?[l,t]:""}}n.exports=i}}),po=Z({"src/utils/front-matter/parse.js"(e,n){"use strict";ae();var t=new RegExp("^(?<startDelimiter>-{3}|\\+{3})(?<language>[^\\n]*)\\n(?:|(?<value>.*?)\\n)(?<endDelimiter>\\k<startDelimiter>|\\.{3})[^\\S\\n]*(?:\\n|$)","s");function s(i){let r=i.match(t);if(!r)return{content:i};let{startDelimiter:u,language:a,value:c="",endDelimiter:l}=r.groups,C=a.trim()||"yaml";if(u==="+++"&&(C="toml"),C!=="yaml"&&u!==l)return{content:i};let[m]=r;return{frontMatter:{type:"front-matter",lang:C,value:c,startDelimiter:u,endDelimiter:l,raw:m.replace(/\n$/,"")},content:m.replace(/[^\n]/g," ")+i.slice(m.length)}}n.exports=s}}),Jm=Z({"src/language-css/pragma.js"(e,n){"use strict";ae();var t=eo(),s=po();function i(u){return t.hasPragma(s(u).content)}function r(u){let{frontMatter:a,content:c}=s(u);return(a?a.raw+` |
| | | |
| | | var _package$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name, |
| | | version: version, |
| | | description: description, |
| | | bin: bin, |
| | | repository: repository, |
| | | homepage: homepage, |
| | | author: author, |
| | | license: license, |
| | | main: main, |
| | | engines: engines, |
| | | dependencies: dependencies, |
| | | devDependencies: devDependencies, |
| | | scripts: scripts, |
| | | 'default': _package |
| | | }); |
| | | `:"")+t.insertPragma(c)}n.exports={hasPragma:i,insertPragma:r}}}),Um=Z({"src/language-css/utils/index.js"(e,n){"use strict";ae();var t=new Set(["red","green","blue","alpha","a","rgb","hue","h","saturation","s","lightness","l","whiteness","w","blackness","b","tint","shade","blend","blenda","contrast","hsl","hsla","hwb","hwba"]);function s(q,le){let ue=Array.isArray(le)?le:[le],Q=-1,de;for(;de=q.getParentNode(++Q);)if(ue.includes(de.type))return Q;return-1}function i(q,le){let ue=s(q,le);return ue===-1?null:q.getParentNode(ue)}function r(q){let le=i(q,"css-decl");return le&&le.prop&&le.prop.toLowerCase()}function u(q){return["initial","inherit","unset","revert"].includes(q.toLowerCase())}function a(q,le){let ue=i(q,"css-atrule");return ue&&ue.name&&ue.name.toLowerCase().endsWith("keyframes")&&["from","to"].includes(le.toLowerCase())}function c(q){return q.includes("$")||q.includes("@")||q.includes("#")||q.startsWith("%")||q.startsWith("--")||q.startsWith(":--")||q.includes("(")&&q.includes(")")?q:q.toLowerCase()}function l(q,le){let ue=i(q,"value-func");return ue&&ue.value&&ue.value.toLowerCase()===le}function C(q){let le=i(q,"css-rule");return le&&le.raws&&le.raws.selector&&(le.raws.selector.startsWith(":import")||le.raws.selector.startsWith(":export"))}function m(q,le){let ue=Array.isArray(le)?le:[le],Q=i(q,"css-atrule");return Q&&ue.includes(Q.name.toLowerCase())}function g(q){let le=q.getValue(),ue=i(q,"css-atrule");return ue&&ue.name==="import"&&le.groups[0].value==="url"&&le.groups.length===2}function p(q){return q.type==="value-func"&&q.value.toLowerCase()==="url"}function f(q,le){let ue=q.getParentNode();if(!ue)return!1;let{nodes:Q}=ue;return Q&&Q.indexOf(le)===Q.length-1}function h(q){return q.selector?typeof q.selector=="string"&&/^@.+:.*$/.test(q.selector)||q.selector.value&&/^@.+:.*$/.test(q.selector.value):!1}function N(q){return q.type==="value-word"&&["from","through","end"].includes(q.value)}function T(q){return q.type==="value-word"&&["and","or","not"].includes(q.value)}function A(q){return q.type==="value-word"&&q.value==="in"}function b(q){return q.type==="value-operator"&&q.value==="*"}function v(q){return q.type==="value-operator"&&q.value==="/"}function B(q){return q.type==="value-operator"&&q.value==="+"}function w(q){return q.type==="value-operator"&&q.value==="-"}function I(q){return q.type==="value-operator"&&q.value==="%"}function E(q){return b(q)||v(q)||B(q)||w(q)||I(q)}function D(q){return q.type==="value-word"&&["==","!="].includes(q.value)}function d(q){return q.type==="value-word"&&["<",">","<=",">="].includes(q.value)}function y(q){return q.type==="css-atrule"&&["if","else","for","each","while"].includes(q.name)}function o(q){return q.raws&&q.raws.params&&/^\(\s*\)$/.test(q.raws.params)}function x(q){return q.name.startsWith("prettier-placeholder")}function F(q){return q.prop.startsWith("@prettier-placeholder")}function S(q,le){return q.value==="$$"&&q.type==="value-func"&&le&&le.type==="value-word"&&!le.raws.before}function k(q){return q.value&&q.value.type==="value-root"&&q.value.group&&q.value.group.type==="value-value"&&q.prop.toLowerCase()==="composes"}function _(q){return q.value&&q.value.group&&q.value.group.group&&q.value.group.group.type==="value-paren_group"&&q.value.group.group.open!==null&&q.value.group.group.close!==null}function O(q){return q.raws&&q.raws.before===""}function R(q){return q.type==="value-comma_group"&&q.groups&&q.groups[1]&&q.groups[1].type==="value-colon"}function M(q){return q.type==="value-paren_group"&&q.groups&&q.groups[0]&&R(q.groups[0])}function H(q){let le=q.getValue();if(le.groups.length===0)return!1;let ue=q.getParentNode(1);if(!M(le)&&!(ue&&M(ue)))return!1;let Q=i(q,"css-decl");return!!(Q&&Q.prop&&Q.prop.startsWith("$")||M(ue)||ue.type==="value-func")}function P(q){return q.type==="value-comment"&&q.inline}function G(q){return q.type==="value-word"&&q.value==="#"}function re(q){return q.type==="value-word"&&q.value==="{"}function $(q){return q.type==="value-word"&&q.value==="}"}function W(q){return["value-word","value-atword"].includes(q.type)}function ee(q){return q&&q.type==="value-colon"}function U(q,le){if(!R(le))return!1;let{groups:ue}=le,Q=ue.indexOf(q);return Q===-1?!1:ee(ue[Q+1])}function ne(q){return q.value&&["not","and","or"].includes(q.value.toLowerCase())}function se(q){return q.type!=="value-func"?!1:t.has(q.value.toLowerCase())}function V(q){return/\/\//.test(q.split(/[\n\r]/).pop())}function oe(q){return q&&q.type==="value-atword"&&q.value.startsWith("prettier-placeholder-")}function K(q,le){if(!q.open||q.open.value!=="("||!q.close||q.close.value!==")"||q.groups.some(ue=>ue.type!=="value-comma_group"))return!1;if(le.type==="value-comma_group"){let ue=le.groups.indexOf(q)-1,Q=le.groups[ue];if(Q&&Q.type==="value-word"&&Q.value==="with")return!0}return!1}function Ee(q){return q.type==="value-paren_group"&&q.open&&q.open.value==="("&&q.close&&q.close.value===")"}n.exports={getAncestorCounter:s,getAncestorNode:i,getPropOfDeclNode:r,maybeToLowerCase:c,insideValueFunctionNode:l,insideICSSRuleNode:C,insideAtRuleNode:m,insideURLFunctionInImportAtRuleNode:g,isKeyframeAtRuleKeywords:a,isWideKeywords:u,isLastNode:f,isSCSSControlDirectiveNode:y,isDetachedRulesetDeclarationNode:h,isRelationalOperatorNode:d,isEqualityOperatorNode:D,isMultiplicationNode:b,isDivisionNode:v,isAdditionNode:B,isSubtractionNode:w,isModuloNode:I,isMathOperatorNode:E,isEachKeywordNode:A,isForKeywordNode:N,isURLFunctionNode:p,isIfElseKeywordNode:T,hasComposesNode:k,hasParensAroundNode:_,hasEmptyRawBefore:O,isDetachedRulesetCallNode:o,isTemplatePlaceholderNode:x,isTemplatePropNode:F,isPostcssSimpleVarNode:S,isKeyValuePairNode:R,isKeyValuePairInParenGroupNode:M,isKeyInValuePairNode:U,isSCSSMapItemNode:H,isInlineValueCommentNode:P,isHashNode:G,isLeftCurlyBraceNode:re,isRightCurlyBraceNode:$,isWordNode:W,isColonNode:ee,isMediaAndSupportsKeywords:ne,isColorAdjusterFuncNode:se,lastLineHasInlineComment:V,isAtWordPlaceholderNode:oe,isConfigurationNode:K,isParenGroupNode:Ee}}}),zm=Z({"src/utils/line-column-to-index.js"(e,n){"use strict";ae(),n.exports=function(t,s){let i=0;for(let r=0;r<t.line-1;++r)i=s.indexOf(` |
| | | `,i)+1;return i+t.column}}}),Xm=Z({"src/language-css/loc.js"(e,n){"use strict";ae();var{skipEverythingButNewLine:t}=Tr(),s=st(),i=zm();function r(p,f){return typeof p.sourceIndex=="number"?p.sourceIndex:p.source?i(p.source.start,f)-1:null}function u(p,f){if(p.type==="css-comment"&&p.inline)return t(f,p.source.startOffset);let h=p.nodes&&s(p.nodes);return h&&p.source&&!p.source.end&&(p=h),p.source&&p.source.end?i(p.source.end,f):null}function a(p,f){p.source&&(p.source.startOffset=r(p,f),p.source.endOffset=u(p,f));for(let h in p){let N=p[h];h==="source"||!N||typeof N!="object"||(N.type==="value-root"||N.type==="value-unknown"?c(N,l(p),N.text||N.value):a(N,f))}}function c(p,f,h){p.source&&(p.source.startOffset=r(p,h)+f,p.source.endOffset=u(p,h)+f);for(let N in p){let T=p[N];N==="source"||!T||typeof T!="object"||c(T,f,h)}}function l(p){let f=p.source.startOffset;return typeof p.prop=="string"&&(f+=p.prop.length),p.type==="css-atrule"&&typeof p.name=="string"&&(f+=1+p.name.length+p.raws.afterName.match(/^\s*:?\s*/)[0].length),p.type!=="css-atrule"&&p.raws&&typeof p.raws.between=="string"&&(f+=p.raws.between.length),f}function C(p){let f="initial",h="initial",N,T=!1,A=[];for(let b=0;b<p.length;b++){let v=p[b];switch(f){case"initial":if(v==="'"){f="single-quotes";continue}if(v==='"'){f="double-quotes";continue}if((v==="u"||v==="U")&&p.slice(b,b+4).toLowerCase()==="url("){f="url",b+=3;continue}if(v==="*"&&p[b-1]==="/"){f="comment-block";continue}if(v==="/"&&p[b-1]==="/"){f="comment-inline",N=b-1;continue}continue;case"single-quotes":if(v==="'"&&p[b-1]!=="\\"&&(f=h,h="initial"),v===` |
| | | `||v==="\r")return p;continue;case"double-quotes":if(v==='"'&&p[b-1]!=="\\"&&(f=h,h="initial"),v===` |
| | | `||v==="\r")return p;continue;case"url":if(v===")"&&(f="initial"),v===` |
| | | `||v==="\r")return p;if(v==="'"){f="single-quotes",h="url";continue}if(v==='"'){f="double-quotes",h="url";continue}continue;case"comment-block":v==="/"&&p[b-1]==="*"&&(f="initial");continue;case"comment-inline":(v==='"'||v==="'"||v==="*")&&(T=!0),(v===` |
| | | `||v==="\r")&&(T&&A.push([N,b]),f="initial",T=!1);continue}}for(let[b,v]of A)p=p.slice(0,b)+p.slice(b,v).replace(/["'*]/g," ")+p.slice(v);return p}function m(p){return p.source.startOffset}function g(p){return p.source.endOffset}n.exports={locStart:m,locEnd:g,calculateLoc:a,replaceQuotesInInlineComments:C}}}),Km=Z({"src/language-css/utils/is-less-parser.js"(e,n){"use strict";ae();function t(s){return s.parser==="css"||s.parser==="less"}n.exports=t}}),Ym=Z({"src/language-css/utils/is-scss.js"(e,n){"use strict";ae();function t(s,i){return s==="less"||s==="scss"?s==="scss":/(?:\w\s*:\s*[^:}]+|#){|@import[^\n]+(?:url|,)/.test(i)}n.exports=t}}),Qm=Z({"src/language-css/utils/css-units.evaluate.js"(e,n){n.exports={em:"em",rem:"rem",ex:"ex",rex:"rex",cap:"cap",rcap:"rcap",ch:"ch",rch:"rch",ic:"ic",ric:"ric",lh:"lh",rlh:"rlh",vw:"vw",vh:"vh",vi:"vi",vb:"vb",vmin:"vmin",vmax:"vmax",cm:"cm",mm:"mm",q:"Q",in:"in",pt:"pt",pc:"pc",px:"px",deg:"deg",grad:"grad",rad:"rad",turn:"turn",s:"s",ms:"ms",hz:"Hz",khz:"kHz",dpi:"dpi",dpcm:"dpcm",dppx:"dppx",x:"x"}}}),Zm=Z({"src/language-css/utils/print-unit.js"(e,n){"use strict";ae();var t=Qm();function s(i){let r=i.toLowerCase();return Object.prototype.hasOwnProperty.call(t,r)?t[r]:i}n.exports=s}}),ed=Z({"src/language-css/printer-postcss.js"(e,n){"use strict";ae();var t=st(),{printNumber:s,printString:i,hasNewline:r,isFrontMatterNode:u,isNextLineEmpty:a,isNonEmptyArray:c}=Ge(),{builders:{join:l,line:C,hardline:m,softline:g,group:p,fill:f,indent:h,dedent:N,ifBreak:T,breakParent:A},utils:{removeLines:b,getDocParts:v}}=Le(),B=Hm(),w=Gm(),{insertPragma:I}=Jm(),{getAncestorNode:E,getPropOfDeclNode:D,maybeToLowerCase:d,insideValueFunctionNode:y,insideICSSRuleNode:o,insideAtRuleNode:x,insideURLFunctionInImportAtRuleNode:F,isKeyframeAtRuleKeywords:S,isWideKeywords:k,isLastNode:_,isSCSSControlDirectiveNode:O,isDetachedRulesetDeclarationNode:R,isRelationalOperatorNode:M,isEqualityOperatorNode:H,isMultiplicationNode:P,isDivisionNode:G,isAdditionNode:re,isSubtractionNode:$,isMathOperatorNode:W,isEachKeywordNode:ee,isForKeywordNode:U,isURLFunctionNode:ne,isIfElseKeywordNode:se,hasComposesNode:V,hasParensAroundNode:oe,hasEmptyRawBefore:K,isKeyValuePairNode:Ee,isKeyInValuePairNode:q,isDetachedRulesetCallNode:le,isTemplatePlaceholderNode:ue,isTemplatePropNode:Q,isPostcssSimpleVarNode:de,isSCSSMapItemNode:ge,isInlineValueCommentNode:ve,isHashNode:xe,isLeftCurlyBraceNode:we,isRightCurlyBraceNode:fe,isWordNode:pe,isColonNode:me,isMediaAndSupportsKeywords:ce,isColorAdjusterFuncNode:he,lastLineHasInlineComment:J,isAtWordPlaceholderNode:ye,isConfigurationNode:X,isParenGroupNode:Y}=Um(),{locStart:te,locEnd:z}=Xm(),j=Km(),Ce=Ym(),Ne=Zm();function je(Ae){return Ae.trailingComma==="es5"||Ae.trailingComma==="all"}function Ue(Ae,Oe,Pe){let ie=Ae.getValue();if(!ie)return"";if(typeof ie=="string")return ie;switch(ie.type){case"front-matter":return[ie.raw,m];case"css-root":{let Me=tt(Ae,Oe,Pe),qe=ie.raws.after.trim();return[Me,qe?" ".concat(qe):"",v(Me).length>0?m:""]}case"css-comment":{let Me=ie.inline||ie.raws.inline,qe=Oe.originalText.slice(te(ie),z(ie));return Me?qe.trimEnd():qe}case"css-rule":return[Pe("selector"),ie.important?" !important":"",ie.nodes?[ie.selector&&ie.selector.type==="selector-unknown"&&J(ie.selector.value)?C:" ","{",ie.nodes.length>0?h([m,tt(Ae,Oe,Pe)]):"",m,"}",R(ie)?";":""]:";"];case"css-decl":{let Me=Ae.getParentNode(),{between:qe}=ie.raws,Je=qe.trim(),rt=Je===":",Ze=V(ie)?b(Pe("value")):Pe("value");return!rt&&J(Je)&&(Ze=h([m,N(Ze)])),[ie.raws.before.replace(/[\s;]/g,""),o(Ae)?ie.prop:d(ie.prop),Je.startsWith("//")?" ":"",Je,ie.extend?"":" ",j(Oe)&&ie.extend&&ie.selector?["extend(",Pe("selector"),")"]:"",Ze,ie.raws.important?ie.raws.important.replace(/\s*!\s*important/i," !important"):ie.important?" !important":"",ie.raws.scssDefault?ie.raws.scssDefault.replace(/\s*!default/i," !default"):ie.scssDefault?" !default":"",ie.raws.scssGlobal?ie.raws.scssGlobal.replace(/\s*!global/i," !global"):ie.scssGlobal?" !global":"",ie.nodes?[" {",h([g,tt(Ae,Oe,Pe)]),g,"}"]:Q(ie)&&!Me.raws.semicolon&&Oe.originalText[z(ie)-1]!==";"?"":Oe.__isHTMLStyleAttribute&&_(Ae,ie)?T(";"):";"]}case"css-atrule":{let Me=Ae.getParentNode(),qe=ue(ie)&&!Me.raws.semicolon&&Oe.originalText[z(ie)-1]!==";";if(j(Oe)){if(ie.mixin)return[Pe("selector"),ie.important?" !important":"",qe?"":";"];if(ie.function)return[ie.name,Pe("params"),qe?"":";"];if(ie.variable)return["@",ie.name,": ",ie.value?Pe("value"):"",ie.raws.between.trim()?ie.raws.between.trim()+" ":"",ie.nodes?["{",h([ie.nodes.length>0?g:"",tt(Ae,Oe,Pe)]),g,"}"]:"",qe?"":";"]}return["@",le(ie)||ie.name.endsWith(":")?ie.name:d(ie.name),ie.params?[le(ie)?"":ue(ie)?ie.raws.afterName===""?"":ie.name.endsWith(":")?" ":/^\s*\n\s*\n/.test(ie.raws.afterName)?[m,m]:/^\s*\n/.test(ie.raws.afterName)?m:" ":" ",Pe("params")]:"",ie.selector?h([" ",Pe("selector")]):"",ie.value?p([" ",Pe("value"),O(ie)?oe(ie)?" ":C:""]):ie.name==="else"?" ":"",ie.nodes?[O(ie)?"":ie.selector&&!ie.selector.nodes&&typeof ie.selector.value=="string"&&J(ie.selector.value)||!ie.selector&&typeof ie.params=="string"&&J(ie.params)?C:" ","{",h([ie.nodes.length>0?g:"",tt(Ae,Oe,Pe)]),g,"}"]:qe?"":";"]}case"media-query-list":{let Me=[];return Ae.each(qe=>{let Je=qe.getValue();Je.type==="media-query"&&Je.value===""||Me.push(Pe())},"nodes"),p(h(l(C,Me)))}case"media-query":return[l(" ",Ae.map(Pe,"nodes")),_(Ae,ie)?"":","];case"media-type":return Ie(ze(ie.value,Oe));case"media-feature-expression":return ie.nodes?["(",...Ae.map(Pe,"nodes"),")"]:ie.value;case"media-feature":return d(ze(ie.value.replace(/ +/g," "),Oe));case"media-colon":return[ie.value," "];case"media-value":return Ie(ze(ie.value,Oe));case"media-keyword":return ze(ie.value,Oe);case"media-url":return ze(ie.value.replace(/^url\(\s+/gi,"url(").replace(/\s+\)$/g,")"),Oe);case"media-unknown":return ie.value;case"selector-root":return p([x(Ae,"custom-selector")?[E(Ae,"css-atrule").customSelector,C]:"",l([",",x(Ae,["extend","custom-selector","nest"])?C:m],Ae.map(Pe,"nodes"))]);case"selector-selector":return p(h(Ae.map(Pe,"nodes")));case"selector-comment":return ie.value;case"selector-string":return ze(ie.value,Oe);case"selector-tag":{let Me=Ae.getParentNode(),qe=Me&&Me.nodes.indexOf(ie),Je=qe&&Me.nodes[qe-1];return[ie.namespace?[ie.namespace===!0?"":ie.namespace.trim(),"|"]:"",Je.type==="selector-nesting"?ie.value:Ie(S(Ae,ie.value)?ie.value.toLowerCase():ie.value)]}case"selector-id":return["#",ie.value];case"selector-class":return[".",Ie(ze(ie.value,Oe))];case"selector-attribute":return["[",ie.namespace?[ie.namespace===!0?"":ie.namespace.trim(),"|"]:"",ie.attribute.trim(),ie.operator?ie.operator:"",ie.value?Be(ze(ie.value.trim(),Oe),Oe):"",ie.insensitive?" i":"","]"];case"selector-combinator":{if(ie.value==="+"||ie.value===">"||ie.value==="~"||ie.value===">>>"){let Je=Ae.getParentNode();return[Je.type==="selector-selector"&&Je.nodes[0]===ie?"":C,ie.value,_(Ae,ie)?"":" "]}let Me=ie.value.trim().startsWith("(")?C:"",qe=Ie(ze(ie.value.trim(),Oe))||C;return[Me,qe]}case"selector-universal":return[ie.namespace?[ie.namespace===!0?"":ie.namespace.trim(),"|"]:"",ie.value];case"selector-pseudo":return[d(ie.value),c(ie.nodes)?["(",l(", ",Ae.map(Pe,"nodes")),")"]:""];case"selector-nesting":return ie.value;case"selector-unknown":{let Me=E(Ae,"css-rule");if(Me&&Me.isSCSSNesterProperty)return Ie(ze(d(ie.value),Oe));let qe=Ae.getParentNode();if(qe.raws&&qe.raws.selector){let rt=te(qe),Ze=rt+qe.raws.selector.length;return Oe.originalText.slice(rt,Ze).trim()}let Je=Ae.getParentNode(1);if(qe.type==="value-paren_group"&&Je&&Je.type==="value-func"&&Je.value==="selector"){let rt=z(qe.open)+1,Ze=te(qe.close),ct=Oe.originalText.slice(rt,Ze).trim();return J(ct)?[A,ct]:ct}return ie.value}case"value-value":case"value-root":return Pe("group");case"value-comment":return Oe.originalText.slice(te(ie),z(ie));case"value-comma_group":{let Me=Ae.getParentNode(),qe=Ae.getParentNode(1),Je=D(Ae),rt=Je&&Me.type==="value-value"&&(Je==="grid"||Je.startsWith("grid-template")),Ze=E(Ae,"css-atrule"),ct=Ze&&O(Ze),qt=ie.groups.some(ut=>ve(ut)),L=Ae.map(Pe,"groups"),De=[],ke=y(Ae,"url"),We=!1,$e=!1;for(let ut=0;ut<ie.groups.length;++ut){De.push(L[ut]);let et=ie.groups[ut-1],Re=ie.groups[ut],He=ie.groups[ut+1],Zt=ie.groups[ut+2];if(ke){(He&&re(He)||re(Re))&&De.push(" ");continue}if(x(Ae,"forward")&&Re.type==="value-word"&&Re.value&&et!==void 0&&et.type==="value-word"&&et.value==="as"&&He.type==="value-operator"&&He.value==="*"||!He||Re.type==="value-word"&&Re.value.endsWith("-")&&ye(He))continue;let ho=Re.type==="value-string"&&Re.value.startsWith("#{"),Co=We&&He.type==="value-string"&&He.value.endsWith("}");if(ho||Co){We=!We;continue}if(We||me(Re)||me(He)||Re.type==="value-atword"&&Re.value===""||Re.value==="~"||Re.value&&Re.value.includes("\\")&&He&&He.type!=="value-comment"||et&&et.value&&et.value.indexOf("\\")===et.value.length-1&&Re.type==="value-operator"&&Re.value==="/"||Re.value==="\\"||de(Re,He)||xe(Re)||we(Re)||fe(He)||we(He)&&K(He)||fe(Re)&&K(He)||Re.value==="--"&&xe(He))continue;let Qn=W(Re),Zn=W(He);if((Qn&&xe(He)||Zn&&fe(Re))&&K(He)||!et&&G(Re)||y(Ae,"calc")&&(re(Re)||re(He)||$(Re)||$(He))&&K(He))continue;let Eo=(re(Re)||$(Re))&&ut===0&&(He.type==="value-number"||He.isHex)&&qe&&he(qe)&&!K(He),eu=Zt&&Zt.type==="value-func"||Zt&&pe(Zt)||Re.type==="value-func"||pe(Re),tu=He.type==="value-func"||pe(He)||et&&et.type==="value-func"||et&&pe(et);if(!(!(P(He)||P(Re))&&!y(Ae,"calc")&&!Eo&&(G(He)&&!eu||G(Re)&&!tu||re(He)&&!eu||re(Re)&&!tu||$(He)||$(Re))&&(K(He)||Qn&&(!et||et&&W(et))))){if(ve(Re)){if(Me.type==="value-paren_group"){De.push(N(m));continue}De.push(m);continue}if(ct&&(H(He)||M(He)||se(He)||ee(Re)||U(Re))){De.push(" ");continue}if(Ze&&Ze.name.toLowerCase()==="namespace"){De.push(" ");continue}if(rt){Re.source&&He.source&&Re.source.start.line!==He.source.start.line?(De.push(m),$e=!0):De.push(" ");continue}if(Zn){De.push(" ");continue}if(!(He&&He.value==="...")&&!(ye(Re)&&ye(He)&&z(Re)===te(He))){if(ye(Re)&&Y(He)&&z(Re)===te(He.open)){De.push(g);continue}if(Re.value==="with"&&Y(He)){De.push(" ");continue}De.push(C)}}}return qt&&De.push(A),$e&&De.unshift(m),ct?p(h(De)):F(Ae)?p(f(De)):p(h(f(De)))}case"value-paren_group":{let Me=Ae.getParentNode();if(Me&&ne(Me)&&(ie.groups.length===1||ie.groups.length>0&&ie.groups[0].type==="value-comma_group"&&ie.groups[0].groups.length>0&&ie.groups[0].groups[0].type==="value-word"&&ie.groups[0].groups[0].value.startsWith("data:")))return[ie.open?Pe("open"):"",l(",",Ae.map(Pe,"groups")),ie.close?Pe("close"):""];if(!ie.open){let ke=Ae.map(Pe,"groups"),We=[];for(let $e=0;$e<ke.length;$e++)$e!==0&&We.push([",",C]),We.push(ke[$e]);return p(h(f(We)))}let qe=ge(Ae),Je=t(ie.groups),rt=Je&&Je.type==="value-comment",Ze=q(ie,Me),ct=X(ie,Me),qt=ct||qe&&!Ze,L=ct||Ze,De=p([ie.open?Pe("open"):"",h([g,l([C],Ae.map((ke,We)=>{let $e=ke.getValue(),ut=We===ie.groups.length-1,et=[Pe(),ut?"":","];if(Ee($e)&&$e.type==="value-comma_group"&&$e.groups&&$e.groups[0].type!=="value-paren_group"&&$e.groups[2]&&$e.groups[2].type==="value-paren_group"){let Re=v(et[0].contents.contents);return Re[1]=p(Re[1]),p(N(et))}if(!ut&&$e.type==="value-comma_group"&&c($e.groups)){let Re=t($e.groups);Re.source&&a(Oe.originalText,Re,z)&&et.push(m)}return et},"groups"))]),T(!rt&&Ce(Oe.parser,Oe.originalText)&&qe&&je(Oe)?",":""),g,ie.close?Pe("close"):""],{shouldBreak:qt});return L?N(De):De}case"value-func":return[ie.value,x(Ae,"supports")&&ce(ie)?" ":"",Pe("group")];case"value-paren":return ie.value;case"value-number":return[Ve(ie.value),Ne(ie.unit)];case"value-operator":return ie.value;case"value-word":return ie.isColor&&ie.isHex||k(ie.value)?ie.value.toLowerCase():ie.value;case"value-colon":{let Me=Ae.getParentNode(),qe=Me&&Me.groups.indexOf(ie),Je=qe&&Me.groups[qe-1];return[ie.value,Je&&typeof Je.value=="string"&&t(Je.value)==="\\"||y(Ae,"url")?"":C]}case"value-comma":return[ie.value," "];case"value-string":return i(ie.raws.quote+ie.value+ie.raws.quote,Oe);case"value-atword":return["@",ie.value];case"value-unicode-range":return ie.value;case"value-unknown":return ie.value;default:throw new Error("Unknown postcss type ".concat(JSON.stringify(ie.type)))}}function tt(Ae,Oe,Pe){let ie=[];return Ae.each((Me,qe,Je)=>{let rt=Je[qe-1];if(rt&&rt.type==="css-comment"&&rt.text.trim()==="prettier-ignore"){let Ze=Me.getValue();ie.push(Oe.originalText.slice(te(Ze),z(Ze)))}else ie.push(Pe());qe!==Je.length-1&&(Je[qe+1].type==="css-comment"&&!r(Oe.originalText,te(Je[qe+1]),{backwards:!0})&&!u(Je[qe])||Je[qe+1].type==="css-atrule"&&Je[qe+1].name==="else"&&Je[qe].type!=="css-comment"?ie.push(" "):(ie.push(Oe.__isHTMLStyleAttribute?C:m),a(Oe.originalText,Me.getValue(),z)&&!u(Je[qe])&&ie.push(m)))},"nodes"),ie}var Te=/(["'])(?:(?!\1)[^\\]|\\.)*\1/gs,_e=/(?:\d*\.\d+|\d+\.?)(?:[Ee][+-]?\d+)?/g,Fe=/[A-Za-z]+/g,Ke=/[$@]?[A-Z_a-z\u0080-\uFFFF][\w\u0080-\uFFFF-]*/g,Se=new RegExp(Te.source+"|(".concat(Ke.source,")?(").concat(_e.source,")(").concat(Fe.source,")?"),"g");function ze(Ae,Oe){return Ae.replace(Te,Pe=>i(Pe,Oe))}function Be(Ae,Oe){let Pe=Oe.singleQuote?"'":'"';return Ae.includes('"')||Ae.includes("'")?Ae:Pe+Ae+Pe}function Ie(Ae){return Ae.replace(Se,(Oe,Pe,ie,Me,qe)=>!ie&&Me?Ve(Me)+d(qe||""):Oe)}function Ve(Ae){return s(Ae).replace(/\.0(?=$|e)/,"")}n.exports={print:Ue,embed:w,insertPragma:I,massageAstNode:B}}}),td=Z({"src/language-css/options.js"(e,n){"use strict";ae();var t=Lt();n.exports={singleQuote:t.singleQuote}}}),rd=Z({"src/language-css/parsers.js"(){ae()}}),nd=Z({"node_modules/linguist-languages/data/CSS.json"(e,n){n.exports={name:"CSS",type:"markup",tmScope:"source.css",aceMode:"css",codemirrorMode:"css",codemirrorMimeType:"text/css",color:"#563d7c",extensions:[".css"],languageId:50}}}),ud=Z({"node_modules/linguist-languages/data/PostCSS.json"(e,n){n.exports={name:"PostCSS",type:"markup",tmScope:"source.postcss",group:"CSS",extensions:[".pcss",".postcss"],aceMode:"text",languageId:262764437}}}),sd=Z({"node_modules/linguist-languages/data/Less.json"(e,n){n.exports={name:"Less",type:"markup",color:"#1d365d",extensions:[".less"],tmScope:"source.css.less",aceMode:"less",codemirrorMode:"css",codemirrorMimeType:"text/css",languageId:198}}}),ad=Z({"node_modules/linguist-languages/data/SCSS.json"(e,n){n.exports={name:"SCSS",type:"markup",color:"#c6538c",tmScope:"source.css.scss",aceMode:"scss",codemirrorMode:"css",codemirrorMimeType:"text/x-scss",extensions:[".scss"],languageId:329}}}),id=Z({"src/language-css/index.js"(e,n){"use strict";ae();var t=bt(),s=ed(),i=td(),r=rd(),u=[t(nd(),c=>({since:"1.4.0",parsers:["css"],vscodeLanguageIds:["css"],extensions:[...c.extensions,".wxss"]})),t(ud(),()=>({since:"1.4.0",parsers:["css"],vscodeLanguageIds:["postcss"]})),t(sd(),()=>({since:"1.4.0",parsers:["less"],vscodeLanguageIds:["less"]})),t(ad(),()=>({since:"1.4.0",parsers:["scss"],vscodeLanguageIds:["scss"]}))],a={postcss:s};n.exports={languages:u,options:i,printers:a,parsers:r}}}),od=Z({"src/language-handlebars/loc.js"(e,n){"use strict";ae();function t(i){return i.loc.start.offset}function s(i){return i.loc.end.offset}n.exports={locStart:t,locEnd:s}}}),cd=Z({"src/language-handlebars/clean.js"(e,n){"use strict";ae();function t(s,i){if(s.type==="TextNode"){let r=s.chars.trim();if(!r)return null;i.chars=r.replace(/[\t\n\f\r ]+/g," ")}s.type==="AttrNode"&&s.name.toLowerCase()==="class"&&delete i.value}t.ignoredProperties=new Set(["loc","selfClosing"]),n.exports=t}}),ld=Z({"vendors/html-void-elements.json"(e,n){n.exports={htmlVoidElements:["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","isindex","keygen","link","menuitem","meta","nextid","param","source","track","wbr"]}}}),pd=Z({"src/language-handlebars/utils.js"(e,n){"use strict";ae();var{htmlVoidElements:t}=ld(),s=st();function i(b){let v=b.getValue(),B=b.getParentNode(0);return!!(m(b,["ElementNode"])&&s(B.children)===v||m(b,["Block"])&&s(B.body)===v)}function r(b){return b.toUpperCase()===b}function u(b){return C(b,["ElementNode"])&&typeof b.tag=="string"&&b.tag[0]!==":"&&(r(b.tag[0])||b.tag.includes("."))}var a=new Set(t);function c(b){return u(b)&&b.children.every(v=>l(v))||a.has(b.tag)}function l(b){return C(b,["TextNode"])&&!/\S/.test(b.chars)}function C(b,v){return b&&v.includes(b.type)}function m(b,v){let B=b.getParentNode(0);return C(B,v)}function g(b,v){let B=h(b);return C(B,v)}function p(b,v){let B=N(b);return C(B,v)}function f(b,v){let B=b.getValue(),w=b.getParentNode(0)||{},I=w.children||w.body||w.parts||[],E=I.indexOf(B);return E!==-1&&I[E+v]}function h(b){let v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return f(b,-v)}function N(b){return f(b,1)}function T(b){return C(b,["MustacheCommentStatement"])&&typeof b.value=="string"&&b.value.trim()==="prettier-ignore"}function A(b){let v=b.getValue(),B=h(b,2);return T(v)||T(B)}n.exports={getNextNode:N,getPreviousNode:h,hasPrettierIgnore:A,isLastNodeOfSiblings:i,isNextNodeOfSomeType:p,isNodeOfSomeType:C,isParentOfSomeType:m,isPreviousNodeOfSomeType:g,isVoid:c,isWhitespaceNode:l}}}),fd=Z({"src/language-handlebars/printer-glimmer.js"(e,n){"use strict";ae();var{builders:{dedent:t,fill:s,group:i,hardline:r,ifBreak:u,indent:a,join:c,line:l,softline:C},utils:{getDocParts:m,replaceTextEndOfLine:g}}=Le(),{getPreferredQuote:p,isNonEmptyArray:f}=Ge(),{locStart:h,locEnd:N}=od(),T=cd(),{getNextNode:A,getPreviousNode:b,hasPrettierIgnore:v,isLastNodeOfSiblings:B,isNextNodeOfSomeType:w,isNodeOfSomeType:I,isParentOfSomeType:E,isPreviousNodeOfSomeType:D,isVoid:d,isWhitespaceNode:y}=pd(),o=2;function x(J,ye,X){let Y=J.getValue();if(!Y)return"";if(v(J))return ye.originalText.slice(h(Y),N(Y));let te=ye.singleQuote?"'":'"';switch(Y.type){case"Block":case"Program":case"Template":return i(J.map(X,"body"));case"ElementNode":{let z=i(S(J,X)),j=ye.htmlWhitespaceSensitivity==="ignore"&&w(J,["ElementNode"])?C:"";if(d(Y))return[z,j];let Ce=["</",Y.tag,">"];return Y.children.length===0?[z,a(Ce),j]:ye.htmlWhitespaceSensitivity==="ignore"?[z,a(k(J,ye,X)),r,a(Ce),j]:[z,a(i(k(J,ye,X))),a(Ce),j]}case"BlockStatement":{let z=J.getParentNode(1);return z&&z.inverse&&z.inverse.body.length===1&&z.inverse.body[0]===Y&&z.inverse.body[0].path.parts[0]==="if"?[U(J,X),K(J,X,ye),Ee(J,X,ye)]:[W(J,X),i([K(J,X,ye),Ee(J,X,ye),ne(J,X,ye)])]}case"ElementModifierStatement":return i(["{{",pe(J,X),"}}"]);case"MustacheStatement":return i([O(Y),pe(J,X),R(Y)]);case"SubExpression":return i(["(",fe(J,X),C,")"]);case"AttrNode":{let z=Y.value.type==="TextNode";if(z&&Y.value.chars===""&&h(Y.value)===N(Y.value))return Y.name;let Ce=z?p(Y.value.chars,te).quote:Y.value.type==="ConcatStatement"?p(Y.value.parts.filter(je=>je.type==="TextNode").map(je=>je.chars).join(""),te).quote:"",Ne=X("value");return[Y.name,"=",Ce,Y.name==="class"&&Ce?i(a(Ne)):Ne,Ce]}case"ConcatStatement":return J.map(X,"parts");case"Hash":return c(l,J.map(X,"pairs"));case"HashPair":return[Y.key,"=",X("value")];case"TextNode":{let z=Y.chars.replace(/{{/g,"\\{{"),j=ue(J);if(j){if(j==="class"){let Se=z.trim().split(/\s+/).join(" "),ze=!1,Be=!1;return E(J,["ConcatStatement"])&&(D(J,["MustacheStatement"])&&/^\s/.test(z)&&(ze=!0),w(J,["MustacheStatement"])&&/\s$/.test(z)&&Se!==""&&(Be=!0)),[ze?l:"",Se,Be?l:""]}return g(z)}let Ne=/^[\t\n\f\r ]*$/.test(z),je=!b(J),Ue=!A(J);if(ye.htmlWhitespaceSensitivity!=="ignore"){let Se=/^[\t\n\f\r ]*/,ze=/[\t\n\f\r ]*$/,Be=Ue&&E(J,["Template"]),Ie=je&&E(J,["Template"]);if(Ne){if(Ie||Be)return"";let ie=[l],Me=Q(z);return Me&&(ie=ve(Me)),B(J)&&(ie=ie.map(qe=>t(qe))),ie}let[Ve]=z.match(Se),[Ae]=z.match(ze),Oe=[];if(Ve){Oe=[l];let ie=Q(Ve);ie&&(Oe=ve(ie)),z=z.replace(Se,"")}let Pe=[];if(Ae){if(!Be){Pe=[l];let ie=Q(Ae);ie&&(Pe=ve(ie)),B(J)&&(Pe=Pe.map(Me=>t(Me)))}z=z.replace(ze,"")}return[...Oe,s(q(z)),...Pe]}let tt=Q(z),Te=de(z),_e=ge(z);if((je||Ue)&&Ne&&E(J,["Block","ElementNode","Template"]))return"";Ne&&tt?(Te=Math.min(tt,o),_e=0):(w(J,["BlockStatement","ElementNode"])&&(_e=Math.max(_e,1)),D(J,["BlockStatement","ElementNode"])&&(Te=Math.max(Te,1)));let Fe="",Ke="";return _e===0&&w(J,["MustacheStatement"])&&(Ke=" "),Te===0&&D(J,["MustacheStatement"])&&(Fe=" "),je&&(Te=0,Fe=""),Ue&&(_e=0,Ke=""),z=z.replace(/^[\t\n\f\r ]+/g,Fe).replace(/[\t\n\f\r ]+$/,Ke),[...ve(Te),s(q(z)),...ve(_e)]}case"MustacheCommentStatement":{let z=h(Y),j=N(Y),Ce=ye.originalText.charAt(z+2)==="~",Ne=ye.originalText.charAt(j-3)==="~",je=Y.value.includes("}}")?"--":"";return["{{",Ce?"~":"","!",je,Y.value,je,Ne?"~":"","}}"]}case"PathExpression":return Y.original;case"BooleanLiteral":return String(Y.value);case"CommentStatement":return["<!--",Y.value,"-->"];case"StringLiteral":{if(we(J)){let z=ye.singleQuote?'"':"'";return xe(Y.value,z)}return xe(Y.value,te)}case"NumberLiteral":return String(Y.value);case"UndefinedLiteral":return"undefined";case"NullLiteral":return"null";default:throw new Error("unknown glimmer type: "+JSON.stringify(Y.type))}}function F(J,ye){return h(J)-h(ye)}function S(J,ye){let X=J.getValue(),Y=["attributes","modifiers","comments"].filter(z=>f(X[z])),te=Y.flatMap(z=>X[z]).sort(F);for(let z of Y)J.each(j=>{let Ce=te.indexOf(j.getValue());te.splice(Ce,1,[l,ye()])},z);return f(X.blockParams)&&te.push(l,he(X)),["<",X.tag,a(te),_(X)]}function k(J,ye,X){let te=J.getValue().children.every(z=>y(z));return ye.htmlWhitespaceSensitivity==="ignore"&&te?"":J.map((z,j)=>{let Ce=X();return j===0&&ye.htmlWhitespaceSensitivity==="ignore"?[C,Ce]:Ce},"children")}function _(J){return d(J)?u([C,"/>"],[" />",C]):u([C,">"],">")}function O(J){let ye=J.escaped===!1?"{{{":"{{",X=J.strip&&J.strip.open?"~":"";return[ye,X]}function R(J){let ye=J.escaped===!1?"}}}":"}}";return[J.strip&&J.strip.close?"~":"",ye]}function M(J){let ye=O(J),X=J.openStrip.open?"~":"";return[ye,X,"#"]}function H(J){let ye=R(J);return[J.openStrip.close?"~":"",ye]}function P(J){let ye=O(J),X=J.closeStrip.open?"~":"";return[ye,X,"/"]}function G(J){let ye=R(J);return[J.closeStrip.close?"~":"",ye]}function re(J){let ye=O(J),X=J.inverseStrip.open?"~":"";return[ye,X]}function $(J){let ye=R(J);return[J.inverseStrip.close?"~":"",ye]}function W(J,ye){let X=J.getValue(),Y=M(X),te=H(X),z=[me(J,ye)],j=ce(J,ye);if(j&&z.push(l,j),f(X.program.blockParams)){let Ce=he(X.program);z.push(l,Ce)}return i([Y,a(z),C,te])}function ee(J,ye){return[ye.htmlWhitespaceSensitivity==="ignore"?r:"",re(J),"else",$(J)]}function U(J,ye){let X=J.getParentNode(1);return[re(X),"else if ",ce(J,ye),$(X)]}function ne(J,ye,X){let Y=J.getValue();return X.htmlWhitespaceSensitivity==="ignore"?[se(Y)?C:r,P(Y),ye("path"),G(Y)]:[P(Y),ye("path"),G(Y)]}function se(J){return I(J,["BlockStatement"])&&J.program.body.every(ye=>y(ye))}function V(J){return oe(J)&&J.inverse.body.length===1&&I(J.inverse.body[0],["BlockStatement"])&&J.inverse.body[0].path.parts[0]==="if"}function oe(J){return I(J,["BlockStatement"])&&J.inverse}function K(J,ye,X){let Y=J.getValue();if(se(Y))return"";let te=ye("program");return X.htmlWhitespaceSensitivity==="ignore"?a([r,te]):a(te)}function Ee(J,ye,X){let Y=J.getValue(),te=ye("inverse"),z=X.htmlWhitespaceSensitivity==="ignore"?[r,te]:te;return V(Y)?z:oe(Y)?[ee(Y,X),a(z)]:""}function q(J){return m(c(l,le(J)))}function le(J){return J.split(/[\t\n\f\r ]+/)}function ue(J){for(let ye=0;ye<2;ye++){let X=J.getParentNode(ye);if(X&&X.type==="AttrNode")return X.name.toLowerCase()}}function Q(J){return J=typeof J=="string"?J:"",J.split(` |
| | | `).length-1}function de(J){J=typeof J=="string"?J:"";let ye=(J.match(/^([^\S\n\r]*[\n\r])+/g)||[])[0]||"";return Q(ye)}function ge(J){J=typeof J=="string"?J:"";let ye=(J.match(/([\n\r][^\S\n\r]*)+$/g)||[])[0]||"";return Q(ye)}function ve(){let J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return Array.from({length:Math.min(J,o)}).fill(r)}function xe(J,ye){let{quote:X,regex:Y}=p(J,ye);return[X,J.replace(Y,"\\".concat(X)),X]}function we(J){let ye=0,X=J.getParentNode(ye);for(;X&&I(X,["SubExpression"]);)ye++,X=J.getParentNode(ye);return!!(X&&I(J.getParentNode(ye+1),["ConcatStatement"])&&I(J.getParentNode(ye+2),["AttrNode"]))}function fe(J,ye){let X=me(J,ye),Y=ce(J,ye);return Y?a([X,l,i(Y)]):X}function pe(J,ye){let X=me(J,ye),Y=ce(J,ye);return Y?[a([X,l,Y]),C]:X}function me(J,ye){return ye("path")}function ce(J,ye){let X=J.getValue(),Y=[];if(X.params.length>0){let te=J.map(ye,"params");Y.push(...te)}if(X.hash&&X.hash.pairs.length>0){let te=ye("hash");Y.push(te)}return Y.length===0?"":c(l,Y)}function he(J){return["as |",J.blockParams.join(" "),"|"]}n.exports={print:x,massageAstNode:T}}}),Dd=Z({"src/language-handlebars/parsers.js"(){ae()}}),md=Z({"node_modules/linguist-languages/data/Handlebars.json"(e,n){n.exports={name:"Handlebars",type:"markup",color:"#f7931e",aliases:["hbs","htmlbars"],extensions:[".handlebars",".hbs"],tmScope:"text.html.handlebars",aceMode:"handlebars",languageId:155}}}),dd=Z({"src/language-handlebars/index.js"(e,n){"use strict";ae();var t=bt(),s=fd(),i=Dd(),r=[t(md(),()=>({since:"2.3.0",parsers:["glimmer"],vscodeLanguageIds:["handlebars"]}))],u={glimmer:s};n.exports={languages:r,printers:u,parsers:i}}}),gd=Z({"src/language-graphql/pragma.js"(e,n){"use strict";ae();function t(i){return/^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/.test(i)}function s(i){return`# @format |
| | | |
| | | function _typeof(obj) { |
| | | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
| | | _typeof = function (obj) { |
| | | return typeof obj; |
| | | }; |
| | | } else { |
| | | _typeof = function (obj) { |
| | | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| | | }; |
| | | } |
| | | `+i}n.exports={hasPragma:t,insertPragma:s}}}),yd=Z({"src/language-graphql/loc.js"(e,n){"use strict";ae();function t(i){return typeof i.start=="number"?i.start:i.loc&&i.loc.start}function s(i){return typeof i.end=="number"?i.end:i.loc&&i.loc.end}n.exports={locStart:t,locEnd:s}}}),hd=Z({"src/language-graphql/printer-graphql.js"(e,n){"use strict";ae();var{builders:{join:t,hardline:s,line:i,softline:r,group:u,indent:a,ifBreak:c}}=Le(),{isNextLineEmpty:l,isNonEmptyArray:C}=Ge(),{insertPragma:m}=gd(),{locStart:g,locEnd:p}=yd();function f(w,I,E){let D=w.getValue();if(!D)return"";if(typeof D=="string")return D;switch(D.kind){case"Document":{let d=[];return w.each((y,o,x)=>{d.push(E()),o!==x.length-1&&(d.push(s),l(I.originalText,y.getValue(),p)&&d.push(s))},"definitions"),[...d,s]}case"OperationDefinition":{let d=I.originalText[g(D)]!=="{",y=Boolean(D.name);return[d?D.operation:"",d&&y?[" ",E("name")]:"",d&&!y&&C(D.variableDefinitions)?" ":"",C(D.variableDefinitions)?u(["(",a([r,t([c("",", "),r],w.map(E,"variableDefinitions"))]),r,")"]):"",h(w,E,D),D.selectionSet?!d&&!y?"":" ":"",E("selectionSet")]}case"FragmentDefinition":return["fragment ",E("name"),C(D.variableDefinitions)?u(["(",a([r,t([c("",", "),r],w.map(E,"variableDefinitions"))]),r,")"]):""," on ",E("typeCondition"),h(w,E,D)," ",E("selectionSet")];case"SelectionSet":return["{",a([s,t(s,N(w,I,E,"selections"))]),s,"}"];case"Field":return u([D.alias?[E("alias"),": "]:"",E("name"),D.arguments.length>0?u(["(",a([r,t([c("",", "),r],N(w,I,E,"arguments"))]),r,")"]):"",h(w,E,D),D.selectionSet?" ":"",E("selectionSet")]);case"Name":return D.value;case"StringValue":return D.block?['"""',s,t(s,D.value.replace(/"""/g,"\\$&").split(` |
| | | `)),s,'"""']:['"',D.value.replace(/["\\]/g,"\\$&").replace(/\n/g,"\\n"),'"'];case"IntValue":case"FloatValue":case"EnumValue":return D.value;case"BooleanValue":return D.value?"true":"false";case"NullValue":return"null";case"Variable":return["$",E("name")];case"ListValue":return u(["[",a([r,t([c("",", "),r],w.map(E,"values"))]),r,"]"]);case"ObjectValue":return u(["{",I.bracketSpacing&&D.fields.length>0?" ":"",a([r,t([c("",", "),r],w.map(E,"fields"))]),r,c("",I.bracketSpacing&&D.fields.length>0?" ":""),"}"]);case"ObjectField":case"Argument":return[E("name"),": ",E("value")];case"Directive":return["@",E("name"),D.arguments.length>0?u(["(",a([r,t([c("",", "),r],N(w,I,E,"arguments"))]),r,")"]):""];case"NamedType":return E("name");case"VariableDefinition":return[E("variable"),": ",E("type"),D.defaultValue?[" = ",E("defaultValue")]:"",h(w,E,D)];case"ObjectTypeExtension":case"ObjectTypeDefinition":return[E("description"),D.description?s:"",D.kind==="ObjectTypeExtension"?"extend ":"","type ",E("name"),D.interfaces.length>0?[" implements ",...b(w,I,E)]:"",h(w,E,D),D.fields.length>0?[" {",a([s,t(s,N(w,I,E,"fields"))]),s,"}"]:""];case"FieldDefinition":return[E("description"),D.description?s:"",E("name"),D.arguments.length>0?u(["(",a([r,t([c("",", "),r],N(w,I,E,"arguments"))]),r,")"]):"",": ",E("type"),h(w,E,D)];case"DirectiveDefinition":return[E("description"),D.description?s:"","directive ","@",E("name"),D.arguments.length>0?u(["(",a([r,t([c("",", "),r],N(w,I,E,"arguments"))]),r,")"]):"",D.repeatable?" repeatable":""," on ",t(" | ",w.map(E,"locations"))];case"EnumTypeExtension":case"EnumTypeDefinition":return[E("description"),D.description?s:"",D.kind==="EnumTypeExtension"?"extend ":"","enum ",E("name"),h(w,E,D),D.values.length>0?[" {",a([s,t(s,N(w,I,E,"values"))]),s,"}"]:""];case"EnumValueDefinition":return[E("description"),D.description?s:"",E("name"),h(w,E,D)];case"InputValueDefinition":return[E("description"),D.description?D.description.block?s:i:"",E("name"),": ",E("type"),D.defaultValue?[" = ",E("defaultValue")]:"",h(w,E,D)];case"InputObjectTypeExtension":case"InputObjectTypeDefinition":return[E("description"),D.description?s:"",D.kind==="InputObjectTypeExtension"?"extend ":"","input ",E("name"),h(w,E,D),D.fields.length>0?[" {",a([s,t(s,N(w,I,E,"fields"))]),s,"}"]:""];case"SchemaDefinition":return[E("description"),D.description?s:"","schema",h(w,E,D)," {",D.operationTypes.length>0?a([s,t(s,N(w,I,E,"operationTypes"))]):"",s,"}"];case"OperationTypeDefinition":return[E("operation"),": ",E("type")];case"InterfaceTypeExtension":case"InterfaceTypeDefinition":return[E("description"),D.description?s:"",D.kind==="InterfaceTypeExtension"?"extend ":"","interface ",E("name"),D.interfaces.length>0?[" implements ",...b(w,I,E)]:"",h(w,E,D),D.fields.length>0?[" {",a([s,t(s,N(w,I,E,"fields"))]),s,"}"]:""];case"FragmentSpread":return["...",E("name"),h(w,E,D)];case"InlineFragment":return["...",D.typeCondition?[" on ",E("typeCondition")]:"",h(w,E,D)," ",E("selectionSet")];case"UnionTypeExtension":case"UnionTypeDefinition":return u([E("description"),D.description?s:"",u([D.kind==="UnionTypeExtension"?"extend ":"","union ",E("name"),h(w,E,D),D.types.length>0?[" =",c(""," "),a([c([i," "]),t([i,"| "],w.map(E,"types"))])]:""])]);case"ScalarTypeExtension":case"ScalarTypeDefinition":return[E("description"),D.description?s:"",D.kind==="ScalarTypeExtension"?"extend ":"","scalar ",E("name"),h(w,E,D)];case"NonNullType":return[E("type"),"!"];case"ListType":return["[",E("type"),"]"];default:throw new Error("unknown graphql type: "+JSON.stringify(D.kind))}}function h(w,I,E){if(E.directives.length===0)return"";let D=t(i,w.map(I,"directives"));return E.kind==="FragmentDefinition"||E.kind==="OperationDefinition"?u([i,D]):[" ",u(a([r,D]))]}function N(w,I,E,D){return w.map((d,y,o)=>{let x=E();return y<o.length-1&&l(I.originalText,d.getValue(),p)?[x,s]:x},D)}function T(w){return w.kind&&w.kind!=="Comment"}function A(w){let I=w.getValue();if(I.kind==="Comment")return"#"+I.value.trimEnd();throw new Error("Not a comment: "+JSON.stringify(I))}function b(w,I,E){let D=w.getNode(),d=[],{interfaces:y}=D,o=w.map(x=>E(x),"interfaces");for(let x=0;x<y.length;x++){let F=y[x];d.push(o[x]);let S=y[x+1];if(S){let k=I.originalText.slice(F.loc.end,S.loc.start),_=k.includes("#"),O=k.replace(/#.*/g,"").trim();d.push(O===","?",":" &",_?i:" ")}}return d}function v(){}v.ignoredProperties=new Set(["loc","comments"]);function B(w){let I=w.getValue();return I&&Array.isArray(I.comments)&&I.comments.some(E=>E.value.trim()==="prettier-ignore")}n.exports={print:f,massageAstNode:v,hasPrettierIgnore:B,insertPragma:m,printComment:A,canAttachComment:T}}}),Cd=Z({"src/language-graphql/options.js"(e,n){"use strict";ae();var t=Lt();n.exports={bracketSpacing:t.bracketSpacing}}}),Ed=Z({"src/language-graphql/parsers.js"(){ae()}}),vd=Z({"node_modules/linguist-languages/data/GraphQL.json"(e,n){n.exports={name:"GraphQL",type:"data",color:"#e10098",extensions:[".graphql",".gql",".graphqls"],tmScope:"source.graphql",aceMode:"text",languageId:139}}}),Fd=Z({"src/language-graphql/index.js"(e,n){"use strict";ae();var t=bt(),s=hd(),i=Cd(),r=Ed(),u=[t(vd(),()=>({since:"1.5.0",parsers:["graphql"],vscodeLanguageIds:["graphql"]}))],a={graphql:s};n.exports={languages:u,options:i,printers:a,parsers:r}}}),fo=Z({"src/language-markdown/loc.js"(e,n){"use strict";ae();function t(i){return i.position.start.offset}function s(i){return i.position.end.offset}n.exports={locStart:t,locEnd:s}}}),Ad=Z({"src/language-markdown/constants.evaluate.js"(e,n){n.exports={cjkPattern:"(?:[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d])(?:[\\ufe00-\\ufe0f]|\\udb40[\\udd00-\\uddef])?",kPattern:"[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",punctuationPattern:"[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"}}}),Kn=Z({"src/language-markdown/utils.js"(e,n){"use strict";ae();var{getLast:t}=Ge(),{locStart:s,locEnd:i}=fo(),{cjkPattern:r,kPattern:u,punctuationPattern:a}=Ad(),c=["liquidNode","inlineCode","emphasis","esComment","strong","delete","wikiLink","link","linkReference","image","imageReference","footnote","footnoteReference","sentence","whitespace","word","break","inlineMath"],l=[...c,"tableCell","paragraph","heading"],C=new RegExp(u),m=new RegExp(a);function g(A,b){let v="non-cjk",B="cj-letter",w="k-letter",I="cjk-punctuation",E=[],D=(b.proseWrap==="preserve"?A:A.replace(new RegExp("(".concat(r,`) |
| | | (`).concat(r,")"),"g"),"$1$2")).split(/([\t\n ]+)/);for(let[y,o]of D.entries()){if(y%2===1){E.push({type:"whitespace",value:/\n/.test(o)?` |
| | | `:" "});continue}if((y===0||y===D.length-1)&&o==="")continue;let x=o.split(new RegExp("(".concat(r,")")));for(let[F,S]of x.entries())if(!((F===0||F===x.length-1)&&S==="")){if(F%2===0){S!==""&&d({type:"word",value:S,kind:v,hasLeadingPunctuation:m.test(S[0]),hasTrailingPunctuation:m.test(t(S))});continue}d(m.test(S)?{type:"word",value:S,kind:I,hasLeadingPunctuation:!0,hasTrailingPunctuation:!0}:{type:"word",value:S,kind:C.test(S)?w:B,hasLeadingPunctuation:!1,hasTrailingPunctuation:!1})}}return E;function d(y){let o=t(E);o&&o.type==="word"&&(o.kind===v&&y.kind===B&&!o.hasTrailingPunctuation||o.kind===B&&y.kind===v&&!y.hasLeadingPunctuation?E.push({type:"whitespace",value:" "}):!x(v,I)&&![o.value,y.value].some(F=>/\u3000/.test(F))&&E.push({type:"whitespace",value:""})),E.push(y);function x(F,S){return o.kind===F&&y.kind===S||o.kind===S&&y.kind===F}}}function p(A,b){let[,v,B,w]=b.slice(A.position.start.offset,A.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);return{numberText:v,marker:B,leadingSpaces:w}}function f(A,b){if(!A.ordered||A.children.length<2)return!1;let v=Number(p(A.children[0],b.originalText).numberText),B=Number(p(A.children[1],b.originalText).numberText);if(v===0&&A.children.length>2){let w=Number(p(A.children[2],b.originalText).numberText);return B===1&&w===1}return B===1}function h(A,b){let{value:v}=A;return A.position.end.offset===b.length&&v.endsWith(` |
| | | `)&&b.endsWith(` |
| | | `)?v.slice(0,-1):v}function N(A,b){return function v(B,w,I){let E=Object.assign({},b(B,w,I));return E.children&&(E.children=E.children.map((D,d)=>v(D,d,[E,...I]))),E}(A,null,[])}function T(A){if(!A||A.type!=="link"||A.children.length!==1)return!1;let b=A.children[0];return b&&s(A)===s(b)&&i(A)===i(b)}n.exports={mapAst:N,splitText:g,punctuationPattern:a,getFencedCodeBlockValue:h,getOrderedListItemInfo:p,hasGitDiffFriendlyOrderedList:f,INLINE_NODE_TYPES:c,INLINE_NODE_WRAPPER_TYPES:l,isAutolink:T}}}),Sd=Z({"src/language-markdown/embed.js"(e,n){"use strict";ae();var{inferParserByLanguage:t,getMaxContinuousCount:s}=Ge(),{builders:{hardline:i,markAsRoot:r},utils:{replaceEndOfLine:u}}=Le(),a=Xn(),{getFencedCodeBlockValue:c}=Kn();function l(C,m,g,p){let f=C.getValue();if(f.type==="code"&&f.lang!==null){let h=t(f.lang,p);if(h){let N=p.__inJsTemplate?"~":"`",T=N.repeat(Math.max(3,s(f.value,N)+1)),A={parser:h};f.lang==="tsx"&&(A.filepath="dummy.tsx");let b=g(c(f,p.originalText),A,{stripTrailingHardline:!0});return r([T,f.lang,f.meta?" "+f.meta:"",i,u(b),i,T])}}switch(f.type){case"front-matter":return a(f,g);case"importExport":return[g(f.value,{parser:"babel"},{stripTrailingHardline:!0}),i];case"jsx":return g("<$>".concat(f.value,"</$>"),{parser:"__js_expression",rootMarker:"mdx"},{stripTrailingHardline:!0})}return null}n.exports=l}}),Do=Z({"src/language-markdown/pragma.js"(e,n){"use strict";ae();var t=po(),s=["format","prettier"];function i(r){let u="@(".concat(s.join("|"),")"),a=new RegExp(["<!--\\s*".concat(u,"\\s*-->"),"{\\s*\\/\\*\\s*".concat(u,"\\s*\\*\\/\\s*}"),`<!--.*\r? |
| | | [\\s\\S]*(^| |
| | | )[^\\S |
| | | ]*`.concat(u,`[^\\S |
| | | ]*($| |
| | | )[\\s\\S]* |
| | | .*-->`)].join("|"),"m"),c=r.match(a);return c&&c.index===0}n.exports={startWithPragma:i,hasPragma:r=>i(t(r).content.trimStart()),insertPragma:r=>{let u=t(r),a="<!-- @".concat(s[0]," -->");return u.frontMatter?"".concat(u.frontMatter.raw,` |
| | | |
| | | return _typeof(obj); |
| | | } |
| | | `).concat(a,` |
| | | |
| | | function _classCallCheck(instance, Constructor) { |
| | | if (!(instance instanceof Constructor)) { |
| | | throw new TypeError("Cannot call a class as a function"); |
| | | } |
| | | } |
| | | `).concat(u.content):"".concat(a,` |
| | | |
| | | function _defineProperties(target, props) { |
| | | for (var i = 0; i < props.length; i++) { |
| | | var descriptor = props[i]; |
| | | descriptor.enumerable = descriptor.enumerable || false; |
| | | descriptor.configurable = true; |
| | | if ("value" in descriptor) descriptor.writable = true; |
| | | Object.defineProperty(target, descriptor.key, descriptor); |
| | | } |
| | | } |
| | | `).concat(u.content)}}}}),xd=Z({"src/language-markdown/print-preprocess.js"(e,n){"use strict";ae();var t=st(),{getOrderedListItemInfo:s,mapAst:i,splitText:r}=Kn(),u=/^.$/su;function a(T,A){return T=C(T,A),T=p(T),T=l(T),T=h(T,A),T=N(T,A),T=f(T,A),T=c(T),T=m(T),T}function c(T){return i(T,A=>A.type!=="import"&&A.type!=="export"?A:Object.assign(Object.assign({},A),{},{type:"importExport"}))}function l(T){return i(T,A=>A.type!=="inlineCode"?A:Object.assign(Object.assign({},A),{},{value:A.value.replace(/\s+/g," ")}))}function C(T,A){return i(T,b=>b.type!=="text"||b.value==="*"||b.value==="_"||!u.test(b.value)||b.position.end.offset-b.position.start.offset===b.value.length?b:Object.assign(Object.assign({},b),{},{value:A.originalText.slice(b.position.start.offset,b.position.end.offset)}))}function m(T){return g(T,(A,b)=>A.type==="importExport"&&b.type==="importExport",(A,b)=>({type:"importExport",value:A.value+` |
| | | |
| | | function _createClass(Constructor, protoProps, staticProps) { |
| | | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| | | if (staticProps) _defineProperties(Constructor, staticProps); |
| | | return Constructor; |
| | | } |
| | | `+b.value,position:{start:A.position.start,end:b.position.end}}))}function g(T,A,b){return i(T,v=>{if(!v.children)return v;let B=v.children.reduce((w,I)=>{let E=t(w);return E&&A(E,I)?w.splice(-1,1,b(E,I)):w.push(I),w},[]);return Object.assign(Object.assign({},v),{},{children:B})})}function p(T){return g(T,(A,b)=>A.type==="text"&&b.type==="text",(A,b)=>({type:"text",value:A.value+b.value,position:{start:A.position.start,end:b.position.end}}))}function f(T,A){return i(T,(b,v,B)=>{let[w]=B;if(b.type!=="text")return b;let{value:I}=b;return w.type==="paragraph"&&(v===0&&(I=I.trimStart()),v===w.children.length-1&&(I=I.trimEnd())),{type:"sentence",position:b.position,children:r(I,A)}})}function h(T,A){return i(T,(b,v,B)=>{if(b.type==="code"){let w=/^\n?(?: {4,}|\t)/.test(A.originalText.slice(b.position.start.offset,b.position.end.offset));if(b.isIndented=w,w)for(let I=0;I<B.length;I++){let E=B[I];if(E.hasIndentedCodeblock)break;E.type==="list"&&(E.hasIndentedCodeblock=!0)}}return b})}function N(T,A){return i(T,(B,w,I)=>{if(B.type==="list"&&B.children.length>0){for(let E=0;E<I.length;E++){let D=I[E];if(D.type==="list"&&!D.isAligned)return B.isAligned=!1,B}B.isAligned=v(B)}return B});function b(B){return B.children.length===0?-1:B.children[0].position.start.column-1}function v(B){if(!B.ordered)return!0;let[w,I]=B.children;if(s(w,A.originalText).leadingSpaces.length>1)return!0;let D=b(w);if(D===-1)return!1;if(B.children.length===1)return D%A.tabWidth===0;let d=b(I);return D!==d?!1:D%A.tabWidth===0?!0:s(I,A.originalText).leadingSpaces.length>1}}n.exports=a}}),bd=Z({"src/language-markdown/clean.js"(e,n){"use strict";ae();var{isFrontMatterNode:t}=Ge(),{startWithPragma:s}=Do(),i=new Set(["position","raw"]);function r(u,a,c){if((u.type==="front-matter"||u.type==="code"||u.type==="yaml"||u.type==="import"||u.type==="export"||u.type==="jsx")&&delete a.value,u.type==="list"&&delete a.isAligned,(u.type==="list"||u.type==="listItem")&&(delete a.spread,delete a.loose),u.type==="text"||(u.type==="inlineCode"&&(a.value=u.value.replace(/[\t\n ]+/g," ")),u.type==="wikiLink"&&(a.value=u.value.trim().replace(/[\t\n]+/g," ")),(u.type==="definition"||u.type==="linkReference")&&(a.label=u.label.trim().replace(/[\t\n ]+/g," ").toLowerCase()),(u.type==="definition"||u.type==="link"||u.type==="image")&&u.title&&(a.title=u.title.replace(/\\(["')])/g,"$1")),c&&c.type==="root"&&c.children.length>0&&(c.children[0]===u||t(c.children[0])&&c.children[1]===u)&&u.type==="html"&&s(u.value)))return null}r.ignoredProperties=i,n.exports=r}}),Td=Z({"src/language-markdown/printer-markdown.js"(e,n){"use strict";ae();var{getLast:t,getMinNotPresentContinuousCount:s,getMaxContinuousCount:i,getStringWidth:r,isNonEmptyArray:u}=Ge(),{builders:{breakParent:a,join:c,line:l,literalline:C,markAsRoot:m,hardline:g,softline:p,ifBreak:f,fill:h,align:N,indent:T,group:A,hardlineWithoutBreakParent:b},utils:{normalizeDoc:v,replaceTextEndOfLine:B},printer:{printDocToString:w}}=Le(),I=Sd(),{insertPragma:E}=Do(),{locStart:D,locEnd:d}=fo(),y=xd(),o=bd(),{getFencedCodeBlockValue:x,hasGitDiffFriendlyOrderedList:F,splitText:S,punctuationPattern:k,INLINE_NODE_TYPES:_,INLINE_NODE_WRAPPER_TYPES:O,isAutolink:R}=Kn(),M=new Set(["importExport"]),H=["heading","tableCell","link","wikiLink"],P=new Set(["listItem","definition","footnoteDefinition"]);function G(fe,pe,me){let ce=fe.getValue();if(de(fe))return S(pe.originalText.slice(ce.position.start.offset,ce.position.end.offset),pe).map(he=>he.type==="word"?he.value:he.value===""?"":se(fe,he.value,pe));switch(ce.type){case"front-matter":return pe.originalText.slice(ce.position.start.offset,ce.position.end.offset);case"root":return ce.children.length===0?"":[v(oe(fe,pe,me)),M.has(Ee(ce).type)?"":g];case"paragraph":return K(fe,pe,me,{postprocessor:h});case"sentence":return K(fe,pe,me);case"word":{let he=ce.value.replace(/\*/g,"\\$&").replace(new RegExp(["(^|".concat(k,")(_+)"),"(_+)(".concat(k,"|$)")].join("|"),"g"),(X,Y,te,z,j)=>(te?"".concat(Y).concat(te):"".concat(z).concat(j)).replace(/_/g,"\\_")),J=(X,Y,te)=>X.type==="sentence"&&te===0,ye=(X,Y,te)=>R(X.children[te-1]);return he!==ce.value&&(fe.match(void 0,J,ye)||fe.match(void 0,J,(X,Y,te)=>X.type==="emphasis"&&te===0,ye))&&(he=he.replace(/^(\\?[*_])+/,X=>X.replace(/\\/g,""))),he}case"whitespace":{let he=fe.getParentNode(),J=he.children.indexOf(ce),ye=he.children[J+1],X=ye&&/^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(ye.value)?"never":pe.proseWrap;return se(fe,ce.value,{proseWrap:X})}case"emphasis":{let he;if(R(ce.children[0]))he=pe.originalText[ce.position.start.offset];else{let J=fe.getParentNode(),ye=J.children.indexOf(ce),X=J.children[ye-1],Y=J.children[ye+1];he=X&&X.type==="sentence"&&X.children.length>0&&t(X.children).type==="word"&&!t(X.children).hasTrailingPunctuation||Y&&Y.type==="sentence"&&Y.children.length>0&&Y.children[0].type==="word"&&!Y.children[0].hasLeadingPunctuation||ne(fe,"emphasis")?"*":"_"}return[he,K(fe,pe,me),he]}case"strong":return["**",K(fe,pe,me),"**"];case"delete":return["~~",K(fe,pe,me),"~~"];case"inlineCode":{let he=s(ce.value,"`"),J="`".repeat(he||1),ye=he&&!/^\s/.test(ce.value)?" ":"";return[J,ye,ce.value,ye,J]}case"wikiLink":{let he="";return pe.proseWrap==="preserve"?he=ce.value:he=ce.value.replace(/[\t\n]+/g," "),["[[",he,"]]"]}case"link":switch(pe.originalText[ce.position.start.offset]){case"<":{let he="mailto:",J=ce.url.startsWith(he)&&pe.originalText.slice(ce.position.start.offset+1,ce.position.start.offset+1+he.length)!==he?ce.url.slice(he.length):ce.url;return["<",J,">"]}case"[":return["[",K(fe,pe,me),"](",ge(ce.url,")"),ve(ce.title,pe),")"];default:return pe.originalText.slice(ce.position.start.offset,ce.position.end.offset)}case"image":return[""),ve(ce.title,pe),")"];case"blockquote":return["> ",N("> ",K(fe,pe,me))];case"heading":return["#".repeat(ce.depth)+" ",K(fe,pe,me)];case"code":{if(ce.isIndented){let ye=" ".repeat(4);return N(ye,[ye,...B(ce.value,g)])}let he=pe.__inJsTemplate?"~":"`",J=he.repeat(Math.max(3,i(ce.value,he)+1));return[J,ce.lang||"",ce.meta?" "+ce.meta:"",g,...B(x(ce,pe.originalText),g),g,J]}case"html":{let he=fe.getParentNode(),J=he.type==="root"&&t(he.children)===ce?ce.value.trimEnd():ce.value,ye=/^<!--.*-->$/s.test(J);return B(J,ye?g:m(C))}case"list":{let he=W(ce,fe.getParentNode()),J=F(ce,pe);return K(fe,pe,me,{processor:(ye,X)=>{let Y=z(),te=ye.getValue();if(te.children.length===2&&te.children[1].type==="html"&&te.children[0].position.start.column!==te.children[1].position.start.column)return[Y,re(ye,pe,me,Y)];return[Y,N(" ".repeat(Y.length),re(ye,pe,me,Y))];function z(){let j=ce.ordered?(X===0?ce.start:J?1:ce.start+X)+(he%2===0?". ":") "):he%2===0?"- ":"* ";return ce.isAligned||ce.hasIndentedCodeblock?$(j,pe):j}}})}case"thematicBreak":{let he=U(fe,"list");return he===-1?"---":W(fe.getParentNode(he),fe.getParentNode(he+1))%2===0?"***":"---"}case"linkReference":return["[",K(fe,pe,me),"]",ce.referenceType==="full"?["[",ce.identifier,"]"]:ce.referenceType==="collapsed"?"[]":""];case"imageReference":switch(ce.referenceType){case"full":return["![",ce.alt||"","][",ce.identifier,"]"];default:return["![",ce.alt,"]",ce.referenceType==="collapsed"?"[]":""]}case"definition":{let he=pe.proseWrap==="always"?l:" ";return A(["[",ce.identifier,"]:",T([he,ge(ce.url),ce.title===null?"":[he,ve(ce.title,pe,!1)]])])}case"footnote":return["[^",K(fe,pe,me),"]"];case"footnoteReference":return["[^",ce.identifier,"]"];case"footnoteDefinition":{let he=fe.getParentNode().children[fe.getName()+1],J=ce.children.length===1&&ce.children[0].type==="paragraph"&&(pe.proseWrap==="never"||pe.proseWrap==="preserve"&&ce.children[0].position.start.line===ce.children[0].position.end.line);return["[^",ce.identifier,"]: ",J?K(fe,pe,me):A([N(" ".repeat(4),K(fe,pe,me,{processor:(ye,X)=>X===0?A([p,me()]):me()})),he&&he.type==="footnoteDefinition"?p:""])]}case"table":return V(fe,pe,me);case"tableCell":return K(fe,pe,me);case"break":return/\s/.test(pe.originalText[ce.position.start.offset])?[" ",m(C)]:["\\",g];case"liquidNode":return B(ce.value,g);case"importExport":return[ce.value,g];case"esComment":return["{/* ",ce.value," */}"];case"jsx":return ce.value;case"math":return["$$",g,ce.value?[...B(ce.value,g),g]:"","$$"];case"inlineMath":return pe.originalText.slice(D(ce),d(ce));case"tableRow":case"listItem":default:throw new Error("Unknown markdown type ".concat(JSON.stringify(ce.type)))}}function re(fe,pe,me,ce){let he=fe.getValue(),J=he.checked===null?"":he.checked?"[x] ":"[ ] ";return[J,K(fe,pe,me,{processor:(ye,X)=>{if(X===0&&ye.getValue().type!=="list")return N(" ".repeat(J.length),me());let Y=" ".repeat(xe(pe.tabWidth-ce.length,0,3));return[Y,N(Y,me())]}})]}function $(fe,pe){let me=ce();return fe+" ".repeat(me>=4?0:me);function ce(){let he=fe.length%pe.tabWidth;return he===0?0:pe.tabWidth-he}}function W(fe,pe){return ee(fe,pe,me=>me.ordered===fe.ordered)}function ee(fe,pe,me){let ce=-1;for(let he of pe.children)if(he.type===fe.type&&me(he)?ce++:ce=-1,he===fe)return ce}function U(fe,pe){let me=Array.isArray(pe)?pe:[pe],ce=-1,he;for(;he=fe.getParentNode(++ce);)if(me.includes(he.type))return ce;return-1}function ne(fe,pe){let me=U(fe,pe);return me===-1?null:fe.getParentNode(me)}function se(fe,pe,me){if(me.proseWrap==="preserve"&&pe===` |
| | | `)return g;let ce=me.proseWrap==="always"&&!ne(fe,H);return pe!==""?ce?l:" ":ce?p:""}function V(fe,pe,me){let ce=fe.getValue(),he=[],J=fe.map(j=>j.map((Ce,Ne)=>{let je=w(me(),pe).formatted,Ue=r(je);return he[Ne]=Math.max(he[Ne]||3,Ue),{text:je,width:Ue}},"children"),"children"),ye=Y(!1);if(pe.proseWrap!=="never")return[a,ye];let X=Y(!0);return[a,A(f(X,ye))];function Y(j){let Ce=[z(J[0],j),te(j)];return J.length>1&&Ce.push(c(b,J.slice(1).map(Ne=>z(Ne,j)))),c(b,Ce)}function te(j){let Ce=he.map((Ne,je)=>{let Ue=ce.align[je],tt=Ue==="center"||Ue==="left"?":":"-",Te=Ue==="center"||Ue==="right"?":":"-",_e=j?"-":"-".repeat(Ne-2);return"".concat(tt).concat(_e).concat(Te)});return"| ".concat(Ce.join(" | ")," |")}function z(j,Ce){let Ne=j.map((je,Ue)=>{let{text:tt,width:Te}=je;if(Ce)return tt;let _e=he[Ue]-Te,Fe=ce.align[Ue],Ke=0;Fe==="right"?Ke=_e:Fe==="center"&&(Ke=Math.floor(_e/2));let Se=_e-Ke;return"".concat(" ".repeat(Ke)).concat(tt).concat(" ".repeat(Se))});return"| ".concat(Ne.join(" | ")," |")}}function oe(fe,pe,me){let ce=[],he=null,{children:J}=fe.getValue();for(let[ye,X]of J.entries())switch(q(X)){case"start":he===null&&(he={index:ye,offset:X.position.end.offset});break;case"end":he!==null&&(ce.push({start:he,end:{index:ye,offset:X.position.start.offset}}),he=null);break;default:break}return K(fe,pe,me,{processor:(ye,X)=>{if(ce.length>0){let Y=ce[0];if(X===Y.start.index)return[J[Y.start.index].value,pe.originalText.slice(Y.start.offset,Y.end.offset),J[Y.end.index].value];if(Y.start.index<X&&X<Y.end.index)return!1;if(X===Y.end.index)return ce.shift(),!1}return me()}})}function K(fe,pe,me){let ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},{postprocessor:he}=ce,J=ce.processor||(()=>me()),ye=fe.getValue(),X=[],Y;return fe.each((te,z)=>{let j=te.getValue(),Ce=J(te,z);if(Ce!==!1){let Ne={parts:X,prevNode:Y,parentNode:ye,options:pe};le(j,Ne)&&(X.push(g),Y&&M.has(Y.type)||(ue(j,Ne)||Q(j,Ne))&&X.push(g),Q(j,Ne)&&X.push(g)),X.push(Ce),Y=j}},"children"),he?he(X):X}function Ee(fe){let pe=fe;for(;u(pe.children);)pe=t(pe.children);return pe}function q(fe){let pe;if(fe.type==="html")pe=fe.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);else{let me;fe.type==="esComment"?me=fe:fe.type==="paragraph"&&fe.children.length===1&&fe.children[0].type==="esComment"&&(me=fe.children[0]),me&&(pe=me.value.match(/^prettier-ignore(?:-(start|end))?$/))}return pe?pe[1]?pe[1]:"next":!1}function le(fe,pe){let me=pe.parts.length===0,ce=_.includes(fe.type),he=fe.type==="html"&&O.includes(pe.parentNode.type);return!me&&!ce&&!he}function ue(fe,pe){let ce=(pe.prevNode&&pe.prevNode.type)===fe.type&&P.has(fe.type),he=pe.parentNode.type==="listItem"&&!pe.parentNode.loose,J=pe.prevNode&&pe.prevNode.type==="listItem"&&pe.prevNode.loose,ye=q(pe.prevNode)==="next",X=fe.type==="html"&&pe.prevNode&&pe.prevNode.type==="html"&&pe.prevNode.position.end.line+1===fe.position.start.line,Y=fe.type==="html"&&pe.parentNode.type==="listItem"&&pe.prevNode&&pe.prevNode.type==="paragraph"&&pe.prevNode.position.end.line+1===fe.position.start.line;return J||!(ce||he||ye||X||Y)}function Q(fe,pe){let me=pe.prevNode&&pe.prevNode.type==="list",ce=fe.type==="code"&&fe.isIndented;return me&&ce}function de(fe){let pe=ne(fe,["linkReference","imageReference"]);return pe&&(pe.type!=="linkReference"||pe.referenceType!=="full")}function ge(fe){let pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],me=[" ",...Array.isArray(pe)?pe:[pe]];return new RegExp(me.map(ce=>"\\".concat(ce)).join("|")).test(fe)?"<".concat(fe,">"):fe}function ve(fe,pe){let me=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!fe)return"";if(me)return" "+ve(fe,pe,!1);if(fe=fe.replace(/\\(["')])/g,"$1"),fe.includes('"')&&fe.includes("'")&&!fe.includes(")"))return"(".concat(fe,")");let ce=fe.split("'").length-1,he=fe.split('"').length-1,J=ce>he?'"':he>ce||pe.singleQuote?"'":'"';return fe=fe.replace(/\\/,"\\\\"),fe=fe.replace(new RegExp("(".concat(J,")"),"g"),"\\$1"),"".concat(J).concat(fe).concat(J)}function xe(fe,pe,me){return fe<pe?pe:fe>me?me:fe}function we(fe){let pe=Number(fe.getName());if(pe===0)return!1;let me=fe.getParentNode().children[pe-1];return q(me)==="next"}n.exports={preprocess:y,print:G,embed:I,massageAstNode:o,hasPrettierIgnore:we,insertPragma:E}}}),Bd=Z({"src/language-markdown/options.js"(e,n){"use strict";ae();var t=Lt();n.exports={proseWrap:t.proseWrap,singleQuote:t.singleQuote}}}),Nd=Z({"src/language-markdown/parsers.js"(){ae()}}),di=Z({"node_modules/linguist-languages/data/Markdown.json"(e,n){n.exports={name:"Markdown",type:"prose",color:"#083fa1",aliases:["pandoc"],aceMode:"markdown",codemirrorMode:"gfm",codemirrorMimeType:"text/x-gfm",wrap:!0,extensions:[".md",".markdown",".mdown",".mdwn",".mdx",".mkd",".mkdn",".mkdown",".ronn",".scd",".workbook"],filenames:["contents.lr"],tmScope:"source.gfm",languageId:222}}}),wd=Z({"src/language-markdown/index.js"(e,n){"use strict";ae();var t=bt(),s=Td(),i=Bd(),r=Nd(),u=[t(di(),c=>({since:"1.8.0",parsers:["markdown"],vscodeLanguageIds:["markdown"],filenames:[...c.filenames,"README"],extensions:c.extensions.filter(l=>l!==".mdx")})),t(di(),()=>({name:"MDX",since:"1.15.0",parsers:["mdx"],vscodeLanguageIds:["mdx"],filenames:[],extensions:[".mdx"]}))],a={mdast:s};n.exports={languages:u,options:i,printers:a,parsers:r}}}),_d=Z({"src/language-html/clean.js"(e,n){"use strict";ae();var{isFrontMatterNode:t}=Ge(),s=new Set(["sourceSpan","startSourceSpan","endSourceSpan","nameSpan","valueSpan","parent"]);function i(r,u){if(r.type==="text"||r.type==="comment"||t(r)||r.type==="yaml"||r.type==="toml")return null;r.type==="attribute"&&delete u.value,r.type==="docType"&&delete u.value}i.ignoredProperties=s,n.exports=i}}),Pd=Z({"src/language-html/constants.evaluate.js"(e,n){n.exports={CSS_DISPLAY_TAGS:{area:"none",base:"none",basefont:"none",datalist:"none",head:"none",link:"none",meta:"none",noembed:"none",noframes:"none",param:"block",rp:"none",script:"block",source:"block",style:"none",template:"inline",track:"block",title:"none",html:"block",body:"block",address:"block",blockquote:"block",center:"block",div:"block",figure:"block",figcaption:"block",footer:"block",form:"block",header:"block",hr:"block",legend:"block",listing:"block",main:"block",p:"block",plaintext:"block",pre:"block",xmp:"block",slot:"contents",ruby:"ruby",rt:"ruby-text",article:"block",aside:"block",h1:"block",h2:"block",h3:"block",h4:"block",h5:"block",h6:"block",hgroup:"block",nav:"block",section:"block",dir:"block",dd:"block",dl:"block",dt:"block",ol:"block",ul:"block",li:"list-item",table:"table",caption:"table-caption",colgroup:"table-column-group",col:"table-column",thead:"table-header-group",tbody:"table-row-group",tfoot:"table-footer-group",tr:"table-row",td:"table-cell",th:"table-cell",fieldset:"block",button:"inline-block",details:"block",summary:"block",dialog:"block",meter:"inline-block",progress:"inline-block",object:"inline-block",video:"inline-block",audio:"inline-block",select:"inline-block",option:"block",optgroup:"block"},CSS_DISPLAY_DEFAULT:"inline",CSS_WHITE_SPACE_TAGS:{listing:"pre",plaintext:"pre",pre:"pre",xmp:"pre",nobr:"nowrap",table:"initial",textarea:"pre-wrap"},CSS_WHITE_SPACE_DEFAULT:"normal"}}}),Id=Z({"src/language-html/utils/is-unknown-namespace.js"(e,n){"use strict";ae();function t(s){return s.type==="element"&&!s.hasExplicitNamespace&&!["html","svg"].includes(s.namespace)}n.exports=t}}),Ot=Z({"src/language-html/utils/index.js"(e,n){"use strict";ae();var{inferParserByLanguage:t,isFrontMatterNode:s}=Ge(),{builders:{line:i,hardline:r,join:u},utils:{getDocParts:a,replaceTextEndOfLine:c}}=Le(),{CSS_DISPLAY_TAGS:l,CSS_DISPLAY_DEFAULT:C,CSS_WHITE_SPACE_TAGS:m,CSS_WHITE_SPACE_DEFAULT:g}=Pd(),p=Id(),f=new Set([" ",` |
| | | `,"\f","\r"," "]),h=j=>j.replace(/^[\t\n\f\r ]+/,""),N=j=>j.replace(/[\t\n\f\r ]+$/,""),T=j=>h(N(j)),A=j=>j.replace(/^[\t\f\r ]*\n/g,""),b=j=>A(N(j)),v=j=>j.split(/[\t\n\f\r ]+/),B=j=>j.match(/^[\t\n\f\r ]*/)[0],w=j=>{let[,Ce,Ne,je]=j.match(/^([\t\n\f\r ]*)(.*?)([\t\n\f\r ]*)$/s);return{leadingWhitespace:Ce,trailingWhitespace:je,text:Ne}},I=j=>/[\t\n\f\r ]/.test(j);function E(j,Ce){return!!(j.type==="ieConditionalComment"&&j.lastChild&&!j.lastChild.isSelfClosing&&!j.lastChild.endSourceSpan||j.type==="ieConditionalComment"&&!j.complete||de(j)&&j.children.some(Ne=>Ne.type!=="text"&&Ne.type!=="interpolation")||X(j,Ce)&&!o(j)&&j.type!=="interpolation")}function D(j){return j.type==="attribute"||!j.parent||!j.prev?!1:d(j.prev)}function d(j){return j.type==="comment"&&j.value.trim()==="prettier-ignore"}function y(j){return j.type==="text"||j.type==="comment"}function o(j){return j.type==="element"&&(j.fullName==="script"||j.fullName==="style"||j.fullName==="svg:style"||p(j)&&(j.name==="script"||j.name==="style"))}function x(j){return j.children&&!o(j)}function F(j){return o(j)||j.type==="interpolation"||S(j)}function S(j){return we(j).startsWith("pre")}function k(j,Ce){let Ne=je();if(Ne&&!j.prev&&j.parent&&j.parent.tagDefinition&&j.parent.tagDefinition.ignoreFirstLf)return j.type==="interpolation";return Ne;function je(){return s(j)?!1:(j.type==="text"||j.type==="interpolation")&&j.prev&&(j.prev.type==="text"||j.prev.type==="interpolation")?!0:!j.parent||j.parent.cssDisplay==="none"?!1:de(j.parent)?!0:!(!j.prev&&(j.parent.type==="root"||de(j)&&j.parent||o(j.parent)||J(j.parent,Ce)||!Ee(j.parent.cssDisplay))||j.prev&&!ue(j.prev.cssDisplay))}}function _(j,Ce){return s(j)?!1:(j.type==="text"||j.type==="interpolation")&&j.next&&(j.next.type==="text"||j.next.type==="interpolation")?!0:!j.parent||j.parent.cssDisplay==="none"?!1:de(j.parent)?!0:!(!j.next&&(j.parent.type==="root"||de(j)&&j.parent||o(j.parent)||J(j.parent,Ce)||!q(j.parent.cssDisplay))||j.next&&!le(j.next.cssDisplay))}function O(j){return Q(j.cssDisplay)&&!o(j)}function R(j){return s(j)||j.next&&j.sourceSpan.end&&j.sourceSpan.end.line+1<j.next.sourceSpan.start.line}function M(j){return H(j)||j.type==="element"&&j.children.length>0&&(["body","script","style"].includes(j.name)||j.children.some(Ce=>ne(Ce)))||j.firstChild&&j.firstChild===j.lastChild&&j.firstChild.type!=="text"&&$(j.firstChild)&&(!j.lastChild.isTrailingSpaceSensitive||W(j.lastChild))}function H(j){return j.type==="element"&&j.children.length>0&&(["html","head","ul","ol","select"].includes(j.name)||j.cssDisplay.startsWith("table")&&j.cssDisplay!=="table-cell")}function P(j){return ee(j)||j.prev&&G(j.prev)||re(j)}function G(j){return ee(j)||j.type==="element"&&j.fullName==="br"||re(j)}function re(j){return $(j)&&W(j)}function $(j){return j.hasLeadingSpaces&&(j.prev?j.prev.sourceSpan.end.line<j.sourceSpan.start.line:j.parent.type==="root"||j.parent.startSourceSpan.end.line<j.sourceSpan.start.line)}function W(j){return j.hasTrailingSpaces&&(j.next?j.next.sourceSpan.start.line>j.sourceSpan.end.line:j.parent.type==="root"||j.parent.endSourceSpan&&j.parent.endSourceSpan.start.line>j.sourceSpan.end.line)}function ee(j){switch(j.type){case"ieConditionalComment":case"comment":case"directive":return!0;case"element":return["script","select"].includes(j.name)}return!1}function U(j){return j.lastChild?U(j.lastChild):j}function ne(j){return j.children&&j.children.some(Ce=>Ce.type!=="text")}function se(j){let{type:Ce,lang:Ne}=j.attrMap;if(Ce==="module"||Ce==="text/javascript"||Ce==="text/babel"||Ce==="application/javascript"||Ne==="jsx")return"babel";if(Ce==="application/x-typescript"||Ne==="ts"||Ne==="tsx")return"typescript";if(Ce==="text/markdown")return"markdown";if(Ce==="text/html")return"html";if(Ce&&(Ce.endsWith("json")||Ce.endsWith("importmap")))return"json";if(Ce==="text/x-handlebars-template")return"glimmer"}function V(j){let{lang:Ce}=j.attrMap;if(!Ce||Ce==="postcss"||Ce==="css")return"css";if(Ce==="scss")return"scss";if(Ce==="less")return"less"}function oe(j,Ce){if(j.name==="script"&&!j.attrMap.src)return!j.attrMap.lang&&!j.attrMap.type?"babel":se(j);if(j.name==="style")return V(j);if(Ce&&X(j,Ce))return se(j)||!("src"in j.attrMap)&&t(j.attrMap.lang,Ce)}function K(j){return j==="block"||j==="list-item"||j.startsWith("table")}function Ee(j){return!K(j)&&j!=="inline-block"}function q(j){return!K(j)&&j!=="inline-block"}function le(j){return!K(j)}function ue(j){return!K(j)}function Q(j){return!K(j)&&j!=="inline-block"}function de(j){return we(j).startsWith("pre")}function ge(j,Ce){let Ne=0;for(let je=j.stack.length-1;je>=0;je--){let Ue=j.stack[je];Ue&&typeof Ue=="object"&&!Array.isArray(Ue)&&Ce(Ue)&&Ne++}return Ne}function ve(j,Ce){let Ne=j;for(;Ne;){if(Ce(Ne))return!0;Ne=Ne.parent}return!1}function xe(j,Ce){if(j.prev&&j.prev.type==="comment"){let je=j.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);if(je)return je[1]}let Ne=!1;if(j.type==="element"&&j.namespace==="svg")if(ve(j,je=>je.fullName==="svg:foreignObject"))Ne=!0;else return j.name==="svg"?"inline-block":"block";switch(Ce.htmlWhitespaceSensitivity){case"strict":return"inline";case"ignore":return"block";default:return Ce.parser==="vue"&&j.parent&&j.parent.type==="root"?"block":j.type==="element"&&(!j.namespace||Ne||p(j))&&l[j.name]||C}}function we(j){return j.type==="element"&&(!j.namespace||p(j))&&m[j.name]||g}function fe(j){let Ce=Number.POSITIVE_INFINITY;for(let Ne of j.split(` |
| | | `)){if(Ne.length===0)continue;if(!f.has(Ne[0]))return 0;let je=B(Ne).length;Ne.length!==je&&je<Ce&&(Ce=je)}return Ce===Number.POSITIVE_INFINITY?0:Ce}function pe(j){let Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fe(j);return Ce===0?j:j.split(` |
| | | `).map(Ne=>Ne.slice(Ce)).join(` |
| | | `)}function me(j,Ce){let Ne=0;for(let je=0;je<j.length;je++)j[je]===Ce&&Ne++;return Ne}function ce(j){return j.replace(/'/g,"'").replace(/"/g,'"')}var he=new Set(["template","style","script"]);function J(j,Ce){return ye(j,Ce)&&!he.has(j.fullName)}function ye(j,Ce){return Ce.parser==="vue"&&j.type==="element"&&j.parent.type==="root"&&j.fullName.toLowerCase()!=="html"}function X(j,Ce){return ye(j,Ce)&&(J(j,Ce)||j.attrMap.lang&&j.attrMap.lang!=="html")}function Y(j){let Ce=j.fullName;return Ce.charAt(0)==="#"||Ce==="slot-scope"||Ce==="v-slot"||Ce.startsWith("v-slot:")}function te(j,Ce){let Ne=j.parent;if(!ye(Ne,Ce))return!1;let je=Ne.fullName,Ue=j.fullName;return je==="script"&&Ue==="setup"||je==="style"&&Ue==="vars"}function z(j){let Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:j.value;return j.parent.isWhitespaceSensitive?j.parent.isIndentationSensitive?c(Ce):c(pe(b(Ce)),r):a(u(i,v(Ce)))}n.exports={htmlTrim:T,htmlTrimPreserveIndentation:b,hasHtmlWhitespace:I,getLeadingAndTrailingHtmlWhitespace:w,canHaveInterpolation:x,countChars:me,countParents:ge,dedentString:pe,forceBreakChildren:H,forceBreakContent:M,forceNextEmptyLine:R,getLastDescendant:U,getNodeCssStyleDisplay:xe,getNodeCssStyleWhiteSpace:we,hasPrettierIgnore:D,inferScriptParser:oe,isVueCustomBlock:J,isVueNonHtmlBlock:X,isVueSlotAttribute:Y,isVueSfcBindingsAttribute:te,isDanglingSpaceSensitiveNode:O,isIndentationSensitiveNode:S,isLeadingSpaceSensitiveNode:k,isPreLikeNode:de,isScriptLikeTag:o,isTextLikeNode:y,isTrailingSpaceSensitiveNode:_,isWhitespaceSensitiveNode:F,isUnknownNamespace:p,preferHardlineAsLeadingSpaces:P,preferHardlineAsTrailingSpaces:G,shouldPreserveContent:E,unescapeQuoteEntities:ce,getTextValueParts:z}}}),kd=Z({"node_modules/angular-html-parser/lib/compiler/src/chars.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0}),e.$EOF=0,e.$BSPACE=8,e.$TAB=9,e.$LF=10,e.$VTAB=11,e.$FF=12,e.$CR=13,e.$SPACE=32,e.$BANG=33,e.$DQ=34,e.$HASH=35,e.$$=36,e.$PERCENT=37,e.$AMPERSAND=38,e.$SQ=39,e.$LPAREN=40,e.$RPAREN=41,e.$STAR=42,e.$PLUS=43,e.$COMMA=44,e.$MINUS=45,e.$PERIOD=46,e.$SLASH=47,e.$COLON=58,e.$SEMICOLON=59,e.$LT=60,e.$EQ=61,e.$GT=62,e.$QUESTION=63,e.$0=48,e.$7=55,e.$9=57,e.$A=65,e.$E=69,e.$F=70,e.$X=88,e.$Z=90,e.$LBRACKET=91,e.$BACKSLASH=92,e.$RBRACKET=93,e.$CARET=94,e.$_=95,e.$a=97,e.$b=98,e.$e=101,e.$f=102,e.$n=110,e.$r=114,e.$t=116,e.$u=117,e.$v=118,e.$x=120,e.$z=122,e.$LBRACE=123,e.$BAR=124,e.$RBRACE=125,e.$NBSP=160,e.$PIPE=124,e.$TILDA=126,e.$AT=64,e.$BT=96;function n(a){return a>=e.$TAB&&a<=e.$SPACE||a==e.$NBSP}e.isWhitespace=n;function t(a){return e.$0<=a&&a<=e.$9}e.isDigit=t;function s(a){return a>=e.$a&&a<=e.$z||a>=e.$A&&a<=e.$Z}e.isAsciiLetter=s;function i(a){return a>=e.$a&&a<=e.$f||a>=e.$A&&a<=e.$F||t(a)}e.isAsciiHexDigit=i;function r(a){return a===e.$LF||a===e.$CR}e.isNewLine=r;function u(a){return e.$0<=a&&a<=e.$7}e.isOctalDigit=u}}),Ld=Z({"node_modules/angular-html-parser/lib/compiler/src/aot/static_symbol.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=class{constructor(s,i,r){this.filePath=s,this.name=i,this.members=r}assertNoMembers(){if(this.members.length)throw new Error("Illegal state: symbol without members expected, but got ".concat(JSON.stringify(this),"."))}};e.StaticSymbol=n;var t=class{constructor(){this.cache=new Map}get(s,i,r){r=r||[];let u=r.length?".".concat(r.join(".")):"",a='"'.concat(s,'".').concat(i).concat(u),c=this.cache.get(a);return c||(c=new n(s,i,r),this.cache.set(a,c)),c}};e.StaticSymbolCache=t}}),Od=Z({"node_modules/angular-html-parser/lib/compiler/src/util.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=/-+([a-z0-9])/g;function t(o){return o.replace(n,function(){for(var x=arguments.length,F=new Array(x),S=0;S<x;S++)F[S]=arguments[S];return F[1].toUpperCase()})}e.dashCaseToCamelCase=t;function s(o,x){return r(o,":",x)}e.splitAtColon=s;function i(o,x){return r(o,".",x)}e.splitAtPeriod=i;function r(o,x,F){let S=o.indexOf(x);return S==-1?F:[o.slice(0,S).trim(),o.slice(S+1).trim()]}function u(o,x,F){return Array.isArray(o)?x.visitArray(o,F):A(o)?x.visitStringMap(o,F):o==null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"?x.visitPrimitive(o,F):x.visitOther(o,F)}e.visitValue=u;function a(o){return o!=null}e.isDefined=a;function c(o){return o===void 0?null:o}e.noUndefined=c;var l=class{visitArray(o,x){return o.map(F=>u(F,this,x))}visitStringMap(o,x){let F={};return Object.keys(o).forEach(S=>{F[S]=u(o[S],this,x)}),F}visitPrimitive(o,x){return o}visitOther(o,x){return o}};e.ValueTransformer=l,e.SyncAsync={assertSync:o=>{if(w(o))throw new Error("Illegal state: value cannot be a promise");return o},then:(o,x)=>w(o)?o.then(x):x(o),all:o=>o.some(w)?Promise.all(o):o};function C(o){throw new Error("Internal Error: ".concat(o))}e.error=C;function m(o,x){let F=Error(o);return F[g]=!0,x&&(F[p]=x),F}e.syntaxError=m;var g="ngSyntaxError",p="ngParseErrors";function f(o){return o[g]}e.isSyntaxError=f;function h(o){return o[p]||[]}e.getParseErrors=h;function N(o){return o.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}e.escapeRegExp=N;var T=Object.getPrototypeOf({});function A(o){return typeof o=="object"&&o!==null&&Object.getPrototypeOf(o)===T}function b(o){let x="";for(let F=0;F<o.length;F++){let S=o.charCodeAt(F);if(S>=55296&&S<=56319&&o.length>F+1){let k=o.charCodeAt(F+1);k>=56320&&k<=57343&&(F++,S=(S-55296<<10)+k-56320+65536)}S<=127?x+=String.fromCharCode(S):S<=2047?x+=String.fromCharCode(S>>6&31|192,S&63|128):S<=65535?x+=String.fromCharCode(S>>12|224,S>>6&63|128,S&63|128):S<=2097151&&(x+=String.fromCharCode(S>>18&7|240,S>>12&63|128,S>>6&63|128,S&63|128))}return x}e.utf8Encode=b;function v(o){if(typeof o=="string")return o;if(o instanceof Array)return"["+o.map(v).join(", ")+"]";if(o==null)return""+o;if(o.overriddenName)return"".concat(o.overriddenName);if(o.name)return"".concat(o.name);if(!o.toString)return"object";let x=o.toString();if(x==null)return""+x;let F=x.indexOf(` |
| | | `);return F===-1?x:x.substring(0,F)}e.stringify=v;function B(o){return typeof o=="function"&&o.hasOwnProperty("__forward_ref__")?o():o}e.resolveForwardRef=B;function w(o){return!!o&&typeof o.then=="function"}e.isPromise=w;var I=class{constructor(o){this.full=o;let x=o.split(".");this.major=x[0],this.minor=x[1],this.patch=x.slice(2).join(".")}};e.Version=I;var E=typeof window<"u"&&window,D=typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self,d=typeof globalThis<"u"&&globalThis,y=d||E||D;e.global=y}}),jd=Z({"node_modules/angular-html-parser/lib/compiler/src/compile_metadata.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=Ld(),t=Od(),s=/^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;function i(F){return F.replace(/\W/g,"_")}e.sanitizeIdentifier=i;var r=0;function u(F){if(!F||!F.reference)return null;let S=F.reference;if(S instanceof n.StaticSymbol)return S.name;if(S.__anonymousType)return S.__anonymousType;let k=t.stringify(S);return k.indexOf("(")>=0?(k="anonymous_".concat(r++),S.__anonymousType=k):k=i(k),k}e.identifierName=u;function a(F){let S=F.reference;return S instanceof n.StaticSymbol?S.filePath:"./".concat(t.stringify(S))}e.identifierModuleUrl=a;function c(F,S){return"View_".concat(u({reference:F}),"_").concat(S)}e.viewClassName=c;function l(F){return"RenderType_".concat(u({reference:F}))}e.rendererTypeName=l;function C(F){return"HostView_".concat(u({reference:F}))}e.hostViewClassName=C;function m(F){return"".concat(u({reference:F}),"NgFactory")}e.componentFactoryName=m;var g;(function(F){F[F.Pipe=0]="Pipe",F[F.Directive=1]="Directive",F[F.NgModule=2]="NgModule",F[F.Injectable=3]="Injectable"})(g=e.CompileSummaryKind||(e.CompileSummaryKind={}));function p(F){return F.value!=null?i(F.value):u(F.identifier)}e.tokenName=p;function f(F){return F.identifier!=null?F.identifier.reference:F.value}e.tokenReference=f;var h=class{constructor(){let{moduleUrl:F,styles:S,styleUrls:k}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.moduleUrl=F||null,this.styles=w(S),this.styleUrls=w(k)}};e.CompileStylesheetMetadata=h;var N=class{constructor(F){let{encapsulation:S,template:k,templateUrl:_,htmlAst:O,styles:R,styleUrls:M,externalStylesheets:H,animations:P,ngContentSelectors:G,interpolation:re,isInline:$,preserveWhitespaces:W}=F;if(this.encapsulation=S,this.template=k,this.templateUrl=_,this.htmlAst=O,this.styles=w(R),this.styleUrls=w(M),this.externalStylesheets=w(H),this.animations=P?E(P):[],this.ngContentSelectors=G||[],re&&re.length!=2)throw new Error("'interpolation' should have a start and an end symbol.");this.interpolation=re,this.isInline=$,this.preserveWhitespaces=W}toSummary(){return{ngContentSelectors:this.ngContentSelectors,encapsulation:this.encapsulation,styles:this.styles,animations:this.animations}}};e.CompileTemplateMetadata=N;var T=class{static create(F){let{isHost:S,type:k,isComponent:_,selector:O,exportAs:R,changeDetection:M,inputs:H,outputs:P,host:G,providers:re,viewProviders:$,queries:W,guards:ee,viewQueries:U,entryComponents:ne,template:se,componentViewType:V,rendererType:oe,componentFactory:K}=F,Ee={},q={},le={};G!=null&&Object.keys(G).forEach(de=>{let ge=G[de],ve=de.match(s);ve===null?le[de]=ge:ve[1]!=null?q[ve[1]]=ge:ve[2]!=null&&(Ee[ve[2]]=ge)});let ue={};H!=null&&H.forEach(de=>{let ge=t.splitAtColon(de,[de,de]);ue[ge[0]]=ge[1]});let Q={};return P!=null&&P.forEach(de=>{let ge=t.splitAtColon(de,[de,de]);Q[ge[0]]=ge[1]}),new T({isHost:S,type:k,isComponent:!!_,selector:O,exportAs:R,changeDetection:M,inputs:ue,outputs:Q,hostListeners:Ee,hostProperties:q,hostAttributes:le,providers:re,viewProviders:$,queries:W,guards:ee,viewQueries:U,entryComponents:ne,template:se,componentViewType:V,rendererType:oe,componentFactory:K})}constructor(F){let{isHost:S,type:k,isComponent:_,selector:O,exportAs:R,changeDetection:M,inputs:H,outputs:P,hostListeners:G,hostProperties:re,hostAttributes:$,providers:W,viewProviders:ee,queries:U,guards:ne,viewQueries:se,entryComponents:V,template:oe,componentViewType:K,rendererType:Ee,componentFactory:q}=F;this.isHost=!!S,this.type=k,this.isComponent=_,this.selector=O,this.exportAs=R,this.changeDetection=M,this.inputs=H,this.outputs=P,this.hostListeners=G,this.hostProperties=re,this.hostAttributes=$,this.providers=w(W),this.viewProviders=w(ee),this.queries=w(U),this.guards=ne,this.viewQueries=w(se),this.entryComponents=w(V),this.template=oe,this.componentViewType=K,this.rendererType=Ee,this.componentFactory=q}toSummary(){return{summaryKind:g.Directive,type:this.type,isComponent:this.isComponent,selector:this.selector,exportAs:this.exportAs,inputs:this.inputs,outputs:this.outputs,hostListeners:this.hostListeners,hostProperties:this.hostProperties,hostAttributes:this.hostAttributes,providers:this.providers,viewProviders:this.viewProviders,queries:this.queries,guards:this.guards,viewQueries:this.viewQueries,entryComponents:this.entryComponents,changeDetection:this.changeDetection,template:this.template&&this.template.toSummary(),componentViewType:this.componentViewType,rendererType:this.rendererType,componentFactory:this.componentFactory}}};e.CompileDirectiveMetadata=T;var A=class{constructor(F){let{type:S,name:k,pure:_}=F;this.type=S,this.name=k,this.pure=!!_}toSummary(){return{summaryKind:g.Pipe,type:this.type,name:this.name,pure:this.pure}}};e.CompilePipeMetadata=A;var b=class{};e.CompileShallowModuleMetadata=b;var v=class{constructor(F){let{type:S,providers:k,declaredDirectives:_,exportedDirectives:O,declaredPipes:R,exportedPipes:M,entryComponents:H,bootstrapComponents:P,importedModules:G,exportedModules:re,schemas:$,transitiveModule:W,id:ee}=F;this.type=S||null,this.declaredDirectives=w(_),this.exportedDirectives=w(O),this.declaredPipes=w(R),this.exportedPipes=w(M),this.providers=w(k),this.entryComponents=w(H),this.bootstrapComponents=w(P),this.importedModules=w(G),this.exportedModules=w(re),this.schemas=w($),this.id=ee||null,this.transitiveModule=W||null}toSummary(){let F=this.transitiveModule;return{summaryKind:g.NgModule,type:this.type,entryComponents:F.entryComponents,providers:F.providers,modules:F.modules,exportedDirectives:F.exportedDirectives,exportedPipes:F.exportedPipes}}};e.CompileNgModuleMetadata=v;var B=class{constructor(){this.directivesSet=new Set,this.directives=[],this.exportedDirectivesSet=new Set,this.exportedDirectives=[],this.pipesSet=new Set,this.pipes=[],this.exportedPipesSet=new Set,this.exportedPipes=[],this.modulesSet=new Set,this.modules=[],this.entryComponentsSet=new Set,this.entryComponents=[],this.providers=[]}addProvider(F,S){this.providers.push({provider:F,module:S})}addDirective(F){this.directivesSet.has(F.reference)||(this.directivesSet.add(F.reference),this.directives.push(F))}addExportedDirective(F){this.exportedDirectivesSet.has(F.reference)||(this.exportedDirectivesSet.add(F.reference),this.exportedDirectives.push(F))}addPipe(F){this.pipesSet.has(F.reference)||(this.pipesSet.add(F.reference),this.pipes.push(F))}addExportedPipe(F){this.exportedPipesSet.has(F.reference)||(this.exportedPipesSet.add(F.reference),this.exportedPipes.push(F))}addModule(F){this.modulesSet.has(F.reference)||(this.modulesSet.add(F.reference),this.modules.push(F))}addEntryComponent(F){this.entryComponentsSet.has(F.componentType)||(this.entryComponentsSet.add(F.componentType),this.entryComponents.push(F))}};e.TransitiveCompileNgModuleMetadata=B;function w(F){return F||[]}var I=class{constructor(F,S){let{useClass:k,useValue:_,useExisting:O,useFactory:R,deps:M,multi:H}=S;this.token=F,this.useClass=k||null,this.useValue=_,this.useExisting=O,this.useFactory=R||null,this.dependencies=M||null,this.multi=!!H}};e.ProviderMeta=I;function E(F){return F.reduce((S,k)=>{let _=Array.isArray(k)?E(k):k;return S.concat(_)},[])}e.flatten=E;function D(F){return F.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/,"ng:///")}function d(F,S,k){let _;return k.isInline?S.type.reference instanceof n.StaticSymbol?_="".concat(S.type.reference.filePath,".").concat(S.type.reference.name,".html"):_="".concat(u(F),"/").concat(u(S.type),".html"):_=k.templateUrl,S.type.reference instanceof n.StaticSymbol?_:D(_)}e.templateSourceUrl=d;function y(F,S){let k=F.moduleUrl.split(/\/\\/g),_=k[k.length-1];return D("css/".concat(S).concat(_,".ngstyle.js"))}e.sharedStylesheetJitUrl=y;function o(F){return D("".concat(u(F.type),"/module.ngfactory.js"))}e.ngModuleJitUrl=o;function x(F,S){return D("".concat(u(F),"/").concat(u(S.type),".ngfactory.js"))}e.templateJitUrl=x}}),qd=Z({"node_modules/angular-html-parser/lib/compiler/src/parse_util.js"(e){"use strict";ae(),Object.defineProperty(e,"__esModule",{value:!0});var n=kd(),t=jd(),s=class{constructor(C,m,g,p){this.file=C,this.offset=m,this.line=g,this.col=p}toString(){return this.offset!=null?"".concat(this.file.url,"@").concat(this.line,":").concat(this.col):this.file.url}moveBy(C){let m=this.file.content,g=m.length,p=this.offset,f=this.line,h=this.col;for(;p>0&&C<0;)if(p--,C++,m.charCodeAt(p)==n.$LF){f--;let T=m.substr(0,p-1).lastIndexOf(String.fromCharCode(n.$LF));h=T>0?p-T:p}else h--;for(;p<g&&C>0;){let N=m.charCodeAt(p);p++,C--,N==n.$LF?(f++,h=0):h++}return new s(this.file,p,f,h)}getContext(C,m){let g=this.file.content,p=this.offset;if(p!=null){p>g.length-1&&(p=g.length-1);let f=p,h=0,N=0;for(;h<C&&p>0&&(p--,h++,!(g[p]==` |
| | | `&&++N==m)););for(h=0,N=0;h<C&&f<g.length-1&&(f++,h++,!(g[f]==` |
| | | `&&++N==m)););return{before:g.substring(p,this.offset),after:g.substring(this.offset,f+1)}}return null}};e.ParseLocation=s;var i=class{constructor(C,m){this.content=C,this.url=m}};e.ParseSourceFile=i;var r=class{constructor(C,m){let g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;this.start=C,this.end=m,this.details=g}toString(){return this.start.file.content.substring(this.start.offset,this.end.offset)}};e.ParseSourceSpan=r,e.EMPTY_PARSE_LOCATION=new s(new i("",""),0,0,0),e.EMPTY_SOURCE_SPAN=new r(e.EMPTY_PARSE_LOCATION,e.EMPTY_PARSE_LOCATION);var u;(function(C){C[C.WARNING=0]="WARNING",C[C.ERROR=1]="ERROR"})(u=e.ParseErrorLevel||(e.ParseErrorLevel={}));var a=class{constructor(C,m){let g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.ERROR;this.span=C,this.msg=m,this.level=g}contextualMessage(){let C=this.span.start.getContext(100,3);return C?"".concat(this.msg,' ("').concat(C.before,"[").concat(u[this.level]," ->]").concat(C.after,'")'):this.msg}toString(){let C=this.span.details?", ".concat(this.span.details):"";return"".concat(this.contextualMessage(),": ").concat(this.span.start).concat(C)}};e.ParseError=a;function c(C,m){let g=t.identifierModuleUrl(m),p=g!=null?"in ".concat(C," ").concat(t.identifierName(m)," in ").concat(g):"in ".concat(C," ").concat(t.identifierName(m)),f=new i("",p);return new r(new s(f,-1,-1,-1),new s(f,-1,-1,-1))}e.typeSourceSpan=c;function l(C,m,g){let p="in ".concat(C," ").concat(m," in ").concat(g),f=new i("",p);return new r(new s(f,-1,-1,-1),new s(f,-1,-1,-1))}e.r3JitTypeSourceSpan=l}}),Md=Z({"src/language-html/print-preprocess.js"(e,n){"use strict";ae();var{ParseSourceSpan:t}=qd(),{htmlTrim:s,getLeadingAndTrailingHtmlWhitespace:i,hasHtmlWhitespace:r,canHaveInterpolation:u,getNodeCssStyleDisplay:a,isDanglingSpaceSensitiveNode:c,isIndentationSensitiveNode:l,isLeadingSpaceSensitiveNode:C,isTrailingSpaceSensitiveNode:m,isWhitespaceSensitiveNode:g}=Ot(),p=[h,N,A,v,B,E,w,I,D,b];function f(d,y){for(let o of p)o(d,y);return d}function h(d){d.walk(y=>{if(y.type==="element"&&y.tagDefinition.ignoreFirstLf&&y.children.length>0&&y.children[0].type==="text"&&y.children[0].value[0]===` |
| | | `){let o=y.children[0];o.value.length===1?y.removeChild(o):o.value=o.value.slice(1)}})}function N(d){let y=o=>o.type==="element"&&o.prev&&o.prev.type==="ieConditionalStartComment"&&o.prev.sourceSpan.end.offset===o.startSourceSpan.start.offset&&o.firstChild&&o.firstChild.type==="ieConditionalEndComment"&&o.firstChild.sourceSpan.start.offset===o.startSourceSpan.end.offset;d.walk(o=>{if(o.children)for(let x=0;x<o.children.length;x++){let F=o.children[x];if(!y(F))continue;let S=F.prev,k=F.firstChild;o.removeChild(S),x--;let _=new t(S.sourceSpan.start,k.sourceSpan.end),O=new t(_.start,F.sourceSpan.end);F.condition=S.condition,F.sourceSpan=O,F.startSourceSpan=_,F.removeChild(k)}})}function T(d,y,o){d.walk(x=>{if(x.children)for(let F=0;F<x.children.length;F++){let S=x.children[F];if(S.type!=="text"&&!y(S))continue;S.type!=="text"&&(S.type="text",S.value=o(S));let k=S.prev;!k||k.type!=="text"||(k.value+=S.value,k.sourceSpan=new t(k.sourceSpan.start,S.sourceSpan.end),x.removeChild(S),F--)}})}function A(d){return T(d,y=>y.type==="cdata",y=>"<![CDATA[".concat(y.value,"]]>"))}function b(d){let y=o=>o.type==="element"&&o.attrs.length===0&&o.children.length===1&&o.firstChild.type==="text"&&!r(o.children[0].value)&&!o.firstChild.hasLeadingSpaces&&!o.firstChild.hasTrailingSpaces&&o.isLeadingSpaceSensitive&&!o.hasLeadingSpaces&&o.isTrailingSpaceSensitive&&!o.hasTrailingSpaces&&o.prev&&o.prev.type==="text"&&o.next&&o.next.type==="text";d.walk(o=>{if(o.children)for(let x=0;x<o.children.length;x++){let F=o.children[x];if(!y(F))continue;let S=F.prev,k=F.next;S.value+="<".concat(F.rawName,">")+F.firstChild.value+"</".concat(F.rawName,">")+k.value,S.sourceSpan=new t(S.sourceSpan.start,k.sourceSpan.end),S.isTrailingSpaceSensitive=k.isTrailingSpaceSensitive,S.hasTrailingSpaces=k.hasTrailingSpaces,o.removeChild(F),x--,o.removeChild(k)}})}function v(d,y){if(y.parser==="html")return;let o=/{{(.+?)}}/s;d.walk(x=>{if(!!u(x))for(let F of x.children){if(F.type!=="text")continue;let S=F.sourceSpan.start,k=null,_=F.value.split(o);for(let O=0;O<_.length;O++,S=k){let R=_[O];if(O%2===0){k=S.moveBy(R.length),R.length>0&&x.insertChildBefore(F,{type:"text",value:R,sourceSpan:new t(S,k)});continue}k=S.moveBy(R.length+4),x.insertChildBefore(F,{type:"interpolation",sourceSpan:new t(S,k),children:R.length===0?[]:[{type:"text",value:R,sourceSpan:new t(S.moveBy(2),k.moveBy(-2))}]})}x.removeChild(F)}})}function B(d){d.walk(y=>{if(!y.children)return;if(y.children.length===0||y.children.length===1&&y.children[0].type==="text"&&s(y.children[0].value).length===0){y.hasDanglingSpaces=y.children.length>0,y.children=[];return}let o=g(y),x=l(y);if(!o)for(let F=0;F<y.children.length;F++){let S=y.children[F];if(S.type!=="text")continue;let{leadingWhitespace:k,text:_,trailingWhitespace:O}=i(S.value),R=S.prev,M=S.next;_?(S.value=_,S.sourceSpan=new t(S.sourceSpan.start.moveBy(k.length),S.sourceSpan.end.moveBy(-O.length)),k&&(R&&(R.hasTrailingSpaces=!0),S.hasLeadingSpaces=!0),O&&(S.hasTrailingSpaces=!0,M&&(M.hasLeadingSpaces=!0))):(y.removeChild(S),F--,(k||O)&&(R&&(R.hasTrailingSpaces=!0),M&&(M.hasLeadingSpaces=!0)))}y.isWhitespaceSensitive=o,y.isIndentationSensitive=x})}function w(d){d.walk(y=>{y.isSelfClosing=!y.children||y.type==="element"&&(y.tagDefinition.isVoid||y.startSourceSpan===y.endSourceSpan)})}function I(d,y){d.walk(o=>{o.type==="element"&&(o.hasHtmComponentClosingTag=o.endSourceSpan&&/^<\s*\/\s*\/\s*>$/.test(y.originalText.slice(o.endSourceSpan.start.offset,o.endSourceSpan.end.offset)))})}function E(d,y){d.walk(o=>{o.cssDisplay=a(o,y)})}function D(d,y){d.walk(o=>{let{children:x}=o;if(!!x){if(x.length===0){o.isDanglingSpaceSensitive=c(o);return}for(let F of x)F.isLeadingSpaceSensitive=C(F,y),F.isTrailingSpaceSensitive=m(F,y);for(let F=0;F<x.length;F++){let S=x[F];S.isLeadingSpaceSensitive=(F===0||S.prev.isTrailingSpaceSensitive)&&S.isLeadingSpaceSensitive,S.isTrailingSpaceSensitive=(F===x.length-1||S.next.isLeadingSpaceSensitive)&&S.isTrailingSpaceSensitive}}})}n.exports=f}}),Rd=Z({"src/language-html/pragma.js"(e,n){"use strict";ae();function t(i){return/^\s*<!--\s*@(?:format|prettier)\s*-->/.test(i)}function s(i){return`<!-- @format --> |
| | | |
| | | function _defineProperty(obj, key, value) { |
| | | if (key in obj) { |
| | | Object.defineProperty(obj, key, { |
| | | value: value, |
| | | enumerable: true, |
| | | configurable: true, |
| | | writable: true |
| | | }); |
| | | } else { |
| | | obj[key] = value; |
| | | } |
| | | `+i.replace(/^\s*\n/,"")}n.exports={hasPragma:t,insertPragma:s}}}),Yn=Z({"src/language-html/loc.js"(e,n){"use strict";ae();function t(i){return i.sourceSpan.start.offset}function s(i){return i.sourceSpan.end.offset}n.exports={locStart:t,locEnd:s}}}),Qt=Z({"src/language-html/print/tag.js"(e,n){"use strict";ae();var t=Ut(),{isNonEmptyArray:s}=Ge(),{builders:{indent:i,join:r,line:u,softline:a,hardline:c},utils:{replaceTextEndOfLine:l}}=Le(),{locStart:C,locEnd:m}=Yn(),{isTextLikeNode:g,getLastDescendant:p,isPreLikeNode:f,hasPrettierIgnore:h,shouldPreserveContent:N}=Ot();function T(P,G){return[P.isSelfClosing?"":A(P,G),b(P,G)]}function A(P,G){return P.lastChild&&y(P.lastChild)?"":[v(P,G),w(P,G)]}function b(P,G){return(P.next?D(P.next):d(P.parent))?"":[I(P,G),B(P,G)]}function v(P,G){return d(P)?I(P.lastChild,G):""}function B(P,G){return y(P)?w(P.parent,G):o(P)?M(P.next):""}function w(P,G){if(t(!P.isSelfClosing),E(P,G))return"";switch(P.type){case"ieConditionalComment":return"<!";case"element":if(P.hasHtmComponentClosingTag)return"<//";default:return"</".concat(P.rawName)}}function I(P,G){if(E(P,G))return"";switch(P.type){case"ieConditionalComment":case"ieConditionalEndComment":return"[endif]-->";case"ieConditionalStartComment":return"]><!-->";case"interpolation":return"}}";case"element":if(P.isSelfClosing)return"/>";default:return">"}}function E(P,G){return!P.isSelfClosing&&!P.endSourceSpan&&(h(P)||N(P.parent,G))}function D(P){return P.prev&&P.prev.type!=="docType"&&!g(P.prev)&&P.isLeadingSpaceSensitive&&!P.hasLeadingSpaces}function d(P){return P.lastChild&&P.lastChild.isTrailingSpaceSensitive&&!P.lastChild.hasTrailingSpaces&&!g(p(P.lastChild))&&!f(P)}function y(P){return!P.next&&!P.hasTrailingSpaces&&P.isTrailingSpaceSensitive&&g(p(P))}function o(P){return P.next&&!g(P.next)&&g(P)&&P.isTrailingSpaceSensitive&&!P.hasTrailingSpaces}function x(P){let G=P.trim().match(/^prettier-ignore-attribute(?:\s+(.+))?$/s);return G?G[1]?G[1].split(/\s+/):!0:!1}function F(P){return!P.prev&&P.isLeadingSpaceSensitive&&!P.hasLeadingSpaces}function S(P,G,re){let $=P.getValue();if(!s($.attrs))return $.isSelfClosing?" ":"";let W=$.prev&&$.prev.type==="comment"&&x($.prev.value),ee=typeof W=="boolean"?()=>W:Array.isArray(W)?oe=>W.includes(oe.rawName):()=>!1,U=P.map(oe=>{let K=oe.getValue();return ee(K)?l(G.originalText.slice(C(K),m(K))):re()},"attrs"),ne=$.type==="element"&&$.fullName==="script"&&$.attrs.length===1&&$.attrs[0].fullName==="src"&&$.children.length===0,se=G.singleAttributePerLine&&$.attrs.length>1?c:u,V=[i([ne?" ":u,r(se,U)])];return $.firstChild&&F($.firstChild)||$.isSelfClosing&&d($.parent)||ne?V.push($.isSelfClosing?" ":""):V.push(G.bracketSameLine?$.isSelfClosing?" ":"":$.isSelfClosing?u:a),V}function k(P){return P.firstChild&&F(P.firstChild)?"":H(P)}function _(P,G,re){let $=P.getValue();return[O($,G),S(P,G,re),$.isSelfClosing?"":k($)]}function O(P,G){return P.prev&&o(P.prev)?"":[R(P,G),M(P)]}function R(P,G){return F(P)?H(P.parent):D(P)?I(P.prev,G):""}function M(P){switch(P.type){case"ieConditionalComment":case"ieConditionalStartComment":return"<!--[if ".concat(P.condition);case"ieConditionalEndComment":return"<!--<!";case"interpolation":return"{{";case"docType":return"<!DOCTYPE";case"element":if(P.condition)return"<!--[if ".concat(P.condition,"]><!--><").concat(P.rawName);default:return"<".concat(P.rawName)}}function H(P){switch(t(!P.isSelfClosing),P.type){case"ieConditionalComment":return"]>";case"element":if(P.condition)return"><!--<![endif]-->";default:return">"}}n.exports={printClosingTag:T,printClosingTagStart:A,printClosingTagStartMarker:w,printClosingTagEndMarker:I,printClosingTagSuffix:B,printClosingTagEnd:b,needsToBorrowLastChildClosingTagEndMarker:d,needsToBorrowParentClosingTagStartMarker:y,needsToBorrowPrevClosingTagEndMarker:D,printOpeningTag:_,printOpeningTagStart:O,printOpeningTagPrefix:R,printOpeningTagStartMarker:M,printOpeningTagEndMarker:H,needsToBorrowNextOpeningTagStartMarker:o,needsToBorrowParentOpeningTagEndMarker:F}}}),Vd=Z({"node_modules/parse-srcset/src/parse-srcset.js"(e,n){ae(),function(t,s){typeof define=="function"&&define.amd?define([],s):typeof n=="object"&&n.exports?n.exports=s():t.parseSrcset=s()}(e,function(){return function(t,s){var i=s&&s.logger||console;function r(I){return I===" "||I===" "||I===` |
| | | `||I==="\f"||I==="\r"}function u(I){var E,D=I.exec(t.substring(b));if(D)return E=D[0],b+=E.length,E}for(var a=t.length,c=/^[ \t\n\r\u000c]+/,l=/^[, \t\n\r\u000c]+/,C=/^[^ \t\n\r\u000c]+/,m=/[,]+$/,g=/^\d+$/,p=/^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,f,h,N,T,A,b=0,v=[];;){if(u(l),b>=a)return v;f=u(C),h=[],f.slice(-1)===","?(f=f.replace(m,""),w()):B()}function B(){for(u(c),N="",T="in descriptor";;){if(A=t.charAt(b),T==="in descriptor")if(r(A))N&&(h.push(N),N="",T="after descriptor");else if(A===","){b+=1,N&&h.push(N),w();return}else if(A==="(")N=N+A,T="in parens";else if(A===""){N&&h.push(N),w();return}else N=N+A;else if(T==="in parens")if(A===")")N=N+A,T="in descriptor";else if(A===""){h.push(N),w();return}else N=N+A;else if(T==="after descriptor"&&!r(A))if(A===""){w();return}else T="in descriptor",b-=1;b+=1}}function w(){var I=!1,E,D,d,y,o={},x,F,S,k,_;for(y=0;y<h.length;y++)x=h[y],F=x[x.length-1],S=x.substring(0,x.length-1),k=parseInt(S,10),_=parseFloat(S),g.test(S)&&F==="w"?((E||D)&&(I=!0),k===0?I=!0:E=k):p.test(S)&&F==="x"?((E||D||d)&&(I=!0),_<0?I=!0:D=_):g.test(S)&&F==="h"?((d||D)&&(I=!0),k===0?I=!0:d=k):I=!0;I?i&&i.error&&i.error("Invalid srcset descriptor found in '"+t+"' at '"+x+"'."):(o.url=f,E&&(o.w=E),D&&(o.d=D),d&&(o.h=d),v.push(o))}}})}}),Wd=Z({"src/language-html/syntax-attribute.js"(e,n){"use strict";ae();var t=Vd(),{builders:{ifBreak:s,join:i,line:r}}=Le();function u(c){let l=t(c,{logger:{error(B){throw new Error(B)}}}),C=l.some(B=>{let{w}=B;return w}),m=l.some(B=>{let{h:w}=B;return w}),g=l.some(B=>{let{d:w}=B;return w});if(C+m+g>1)throw new Error("Mixed descriptor in srcset is not supported");let p=C?"w":m?"h":"d",f=C?"w":m?"h":"x",h=B=>Math.max(...B),N=l.map(B=>B.url),T=h(N.map(B=>B.length)),A=l.map(B=>B[p]).map(B=>B?B.toString():""),b=A.map(B=>{let w=B.indexOf(".");return w===-1?B.length:w}),v=h(b);return i([",",r],N.map((B,w)=>{let I=[B],E=A[w];if(E){let D=T-B.length+1,d=v-b[w],y=" ".repeat(D+d);I.push(s(y," "),E+f)}return I}))}function a(c){return c.trim().split(/\s+/).join(" ")}n.exports={printImgSrcset:u,printClassNames:a}}}),$d=Z({"src/language-html/syntax-vue.js"(e,n){"use strict";ae();var{builders:{group:t}}=Le();function s(a,c){let{left:l,operator:C,right:m}=i(a);return[t(c("function _(".concat(l,") {}"),{parser:"babel",__isVueForBindingLeft:!0}))," ",C," ",c(m,{parser:"__js_expression"},{stripTrailingHardline:!0})]}function i(a){let c=/(.*?)\s+(in|of)\s+(.*)/s,l=/,([^,\]}]*)(?:,([^,\]}]*))?$/,C=/^\(|\)$/g,m=a.match(c);if(!m)return;let g={};if(g.for=m[3].trim(),!g.for)return;let p=m[1].trim().replace(C,""),f=p.match(l);f?(g.alias=p.replace(l,""),g.iterator1=f[1].trim(),f[2]&&(g.iterator2=f[2].trim())):g.alias=p;let h=[g.alias,g.iterator1,g.iterator2];if(!h.some((N,T)=>!N&&(T===0||h.slice(T+1).some(Boolean))))return{left:h.filter(Boolean).join(","),operator:m[2],right:g.for}}function r(a,c){return c("function _(".concat(a,") {}"),{parser:"babel",__isVueBindings:!0})}function u(a){let c=/^(?:[\w$]+|\([^)]*\))\s*=>|^function\s*\(/,l=/^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*']|\["[^"]*"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/,C=a.trim();return c.test(C)||l.test(C)}n.exports={isVueEventBindingExpression:u,printVueFor:s,printVueBindings:r}}}),mo=Z({"src/language-html/get-node-content.js"(e,n){"use strict";ae();var{needsToBorrowParentClosingTagStartMarker:t,printClosingTagStartMarker:s,needsToBorrowLastChildClosingTagEndMarker:i,printClosingTagEndMarker:r,needsToBorrowParentOpeningTagEndMarker:u,printOpeningTagEndMarker:a}=Qt();function c(l,C){let m=l.startSourceSpan.end.offset;l.firstChild&&u(l.firstChild)&&(m-=a(l).length);let g=l.endSourceSpan.start.offset;return l.lastChild&&t(l.lastChild)?g+=s(l,C).length:i(l)&&(g-=r(l.lastChild,C).length),C.originalText.slice(m,g)}n.exports=c}}),Hd=Z({"src/language-html/embed.js"(e,n){"use strict";ae();var{builders:{breakParent:t,group:s,hardline:i,indent:r,line:u,fill:a,softline:c},utils:{mapDoc:l,replaceTextEndOfLine:C}}=Le(),m=Xn(),{printClosingTag:g,printClosingTagSuffix:p,needsToBorrowPrevClosingTagEndMarker:f,printOpeningTagPrefix:h,printOpeningTag:N}=Qt(),{printImgSrcset:T,printClassNames:A}=Wd(),{printVueFor:b,printVueBindings:v,isVueEventBindingExpression:B}=$d(),{isScriptLikeTag:w,isVueNonHtmlBlock:I,inferScriptParser:E,htmlTrimPreserveIndentation:D,dedentString:d,unescapeQuoteEntities:y,isVueSlotAttribute:o,isVueSfcBindingsAttribute:x,getTextValueParts:F}=Ot(),S=mo();function k(O,R,M){let H=ne=>new RegExp(ne.join("|")).test(O.fullName),P=()=>y(O.value),G=!1,re=(ne,se)=>{let V=ne.type==="NGRoot"?ne.node.type==="NGMicrosyntax"&&ne.node.body.length===1&&ne.node.body[0].type==="NGMicrosyntaxExpression"?ne.node.body[0].expression:ne.node:ne.type==="JsExpressionRoot"?ne.node:ne;V&&(V.type==="ObjectExpression"||V.type==="ArrayExpression"||se.parser==="__vue_expression"&&(V.type==="TemplateLiteral"||V.type==="StringLiteral"))&&(G=!0)},$=ne=>s(ne),W=function(ne){let se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return s([r([c,ne]),se?c:""])},ee=ne=>G?$(ne):W(ne),U=(ne,se)=>R(ne,Object.assign({__onHtmlBindingRoot:re,__embeddedInHtml:!0},se));if(O.fullName==="srcset"&&(O.parent.fullName==="img"||O.parent.fullName==="source"))return W(T(P()));if(O.fullName==="class"&&!M.parentParser){let ne=P();if(!ne.includes("{{"))return A(ne)}if(O.fullName==="style"&&!M.parentParser){let ne=P();if(!ne.includes("{{"))return W(U(ne,{parser:"css",__isHTMLStyleAttribute:!0}))}if(M.parser==="vue"){if(O.fullName==="v-for")return b(P(),U);if(o(O)||x(O,M))return v(P(),U);let ne=["^@","^v-on:"],se=["^:","^v-bind:"],V=["^v-"];if(H(ne)){let oe=P();return ee(U(oe,{parser:B(oe)?"__js_expression":"__vue_event_binding"}))}if(H(se))return ee(U(P(),{parser:"__vue_expression"}));if(H(V))return ee(U(P(),{parser:"__js_expression"}))}if(M.parser==="angular"){let ne=(le,ue)=>U(le,Object.assign(Object.assign({},ue),{},{trailingComma:"none"})),se=["^\\*"],V=["^\\(.+\\)$","^on-"],oe=["^\\[.+\\]$","^bind(on)?-","^ng-(if|show|hide|class|style)$"],K=["^i18n(-.+)?$"];if(H(V))return ee(ne(P(),{parser:"__ng_action"}));if(H(oe))return ee(ne(P(),{parser:"__ng_binding"}));if(H(K)){let le=P().trim();return W(a(F(O,le)),!le.includes("@@"))}if(H(se))return ee(ne(P(),{parser:"__ng_directive"}));let Ee=/{{(.+?)}}/s,q=P();if(Ee.test(q)){let le=[];for(let[ue,Q]of q.split(Ee).entries())if(ue%2===0)le.push(C(Q));else try{le.push(s(["{{",r([u,ne(Q,{parser:"__ng_interpolation",__isInHtmlInterpolation:!0})]),u,"}}"]))}catch{le.push("{{",C(Q),"}}")}return s(le)}}return null}function _(O,R,M,H){let P=O.getValue();switch(P.type){case"element":{if(w(P)||P.type==="interpolation")return;if(!P.isSelfClosing&&I(P,H)){let G=E(P,H);if(!G)return;let re=S(P,H),$=/^\s*$/.test(re),W="";return $||(W=M(D(re),{parser:G,__embeddedInHtml:!0},{stripTrailingHardline:!0}),$=W===""),[h(P,H),s(N(O,H,R)),$?"":i,W,$?"":i,g(P,H),p(P,H)]}break}case"text":{if(w(P.parent)){let G=E(P.parent);if(G){let re=G==="markdown"?d(P.value.replace(/^[^\S\n]*\n/,"")):P.value,$={parser:G,__embeddedInHtml:!0};if(H.parser==="html"&&G==="babel"){let W="script",{attrMap:ee}=P.parent;ee&&(ee.type==="module"||ee.type==="text/babel"&&ee["data-type"]==="module")&&(W="module"),$.__babelSourceType=W}return[t,h(P,H),M(re,$,{stripTrailingHardline:!0}),p(P,H)]}}else if(P.parent.type==="interpolation"){let G={__isInHtmlInterpolation:!0,__embeddedInHtml:!0};return H.parser==="angular"?(G.parser="__ng_interpolation",G.trailingComma="none"):H.parser==="vue"?G.parser="__vue_expression":G.parser="__js_expression",[r([u,M(P.value,G,{stripTrailingHardline:!0})]),P.parent.next&&f(P.parent.next)?" ":u]}break}case"attribute":{if(!P.value)break;if(/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(H.originalText.slice(P.valueSpan.start.offset,P.valueSpan.end.offset)))return[P.rawName,"=",P.value];if(H.parser==="lwc"&&/^{.*}$/s.test(H.originalText.slice(P.valueSpan.start.offset,P.valueSpan.end.offset)))return[P.rawName,"=",P.value];let G=k(P,(re,$)=>M(re,Object.assign({__isInHtmlAttribute:!0,__embeddedInHtml:!0},$),{stripTrailingHardline:!0}),H);if(G)return[P.rawName,'="',s(l(G,re=>typeof re=="string"?re.replace(/"/g,"""):re)),'"'];break}case"front-matter":return m(P,M)}}n.exports=_}}),go=Z({"src/language-html/print/children.js"(e,n){"use strict";ae();var{builders:{breakParent:t,group:s,ifBreak:i,line:r,softline:u,hardline:a},utils:{replaceTextEndOfLine:c}}=Le(),{locStart:l,locEnd:C}=Yn(),{forceBreakChildren:m,forceNextEmptyLine:g,isTextLikeNode:p,hasPrettierIgnore:f,preferHardlineAsLeadingSpaces:h}=Ot(),{printOpeningTagPrefix:N,needsToBorrowNextOpeningTagStartMarker:T,printOpeningTagStartMarker:A,needsToBorrowPrevClosingTagEndMarker:b,printClosingTagEndMarker:v,printClosingTagSuffix:B,needsToBorrowParentClosingTagStartMarker:w}=Qt();function I(d,y,o){let x=d.getValue();return f(x)?[N(x,y),...c(y.originalText.slice(l(x)+(x.prev&&T(x.prev)?A(x).length:0),C(x)-(x.next&&b(x.next)?v(x,y).length:0))),B(x,y)]:o()}function E(d,y){return p(d)&&p(y)?d.isTrailingSpaceSensitive?d.hasTrailingSpaces?h(y)?a:r:"":h(y)?a:u:T(d)&&(f(y)||y.firstChild||y.isSelfClosing||y.type==="element"&&y.attrs.length>0)||d.type==="element"&&d.isSelfClosing&&b(y)?"":!y.isLeadingSpaceSensitive||h(y)||b(y)&&d.lastChild&&w(d.lastChild)&&d.lastChild.lastChild&&w(d.lastChild.lastChild)?a:y.hasLeadingSpaces?r:u}function D(d,y,o){let x=d.getValue();if(m(x))return[t,...d.map(S=>{let k=S.getValue(),_=k.prev?E(k.prev,k):"";return[_?[_,g(k.prev)?a:""]:"",I(S,y,o)]},"children")];let F=x.children.map(()=>Symbol(""));return d.map((S,k)=>{let _=S.getValue();if(p(_)){if(_.prev&&p(_.prev)){let re=E(_.prev,_);if(re)return g(_.prev)?[a,a,I(S,y,o)]:[re,I(S,y,o)]}return I(S,y,o)}let O=[],R=[],M=[],H=[],P=_.prev?E(_.prev,_):"",G=_.next?E(_,_.next):"";return P&&(g(_.prev)?O.push(a,a):P===a?O.push(a):p(_.prev)?R.push(P):R.push(i("",u,{groupId:F[k-1]}))),G&&(g(_)?p(_.next)&&H.push(a,a):G===a?p(_.next)&&H.push(a):M.push(G)),[...O,s([...R,s([I(S,y,o),...M],{id:F[k]})]),...H]},"children")}n.exports={printChildren:D}}}),Gd=Z({"src/language-html/print/element.js"(e,n){"use strict";ae();var{builders:{breakParent:t,dedentToRoot:s,group:i,ifBreak:r,indentIfBreak:u,indent:a,line:c,softline:l},utils:{replaceTextEndOfLine:C}}=Le(),m=mo(),{shouldPreserveContent:g,isScriptLikeTag:p,isVueCustomBlock:f,countParents:h,forceBreakContent:N}=Ot(),{printOpeningTagPrefix:T,printOpeningTag:A,printClosingTagSuffix:b,printClosingTag:v,needsToBorrowPrevClosingTagEndMarker:B,needsToBorrowLastChildClosingTagEndMarker:w}=Qt(),{printChildren:I}=go();function E(D,d,y){let o=D.getValue();if(g(o,d))return[T(o,d),i(A(D,d,y)),...C(m(o,d)),...v(o,d),b(o,d)];let x=o.children.length===1&&o.firstChild.type==="interpolation"&&o.firstChild.isLeadingSpaceSensitive&&!o.firstChild.hasLeadingSpaces&&o.lastChild.isTrailingSpaceSensitive&&!o.lastChild.hasTrailingSpaces,F=Symbol("element-attr-group-id"),S=R=>i([i(A(D,d,y),{id:F}),R,v(o,d)]),k=R=>x?u(R,{groupId:F}):(p(o)||f(o,d))&&o.parent.type==="root"&&d.parser==="vue"&&!d.vueIndentScriptAndStyle?R:a(R),_=()=>x?r(l,"",{groupId:F}):o.firstChild.hasLeadingSpaces&&o.firstChild.isLeadingSpaceSensitive?c:o.firstChild.type==="text"&&o.isWhitespaceSensitive&&o.isIndentationSensitive?s(l):l,O=()=>(o.next?B(o.next):w(o.parent))?o.lastChild.hasTrailingSpaces&&o.lastChild.isTrailingSpaceSensitive?" ":"":x?r(l,"",{groupId:F}):o.lastChild.hasTrailingSpaces&&o.lastChild.isTrailingSpaceSensitive?c:(o.lastChild.type==="comment"||o.lastChild.type==="text"&&o.isWhitespaceSensitive&&o.isIndentationSensitive)&&new RegExp("\\n[\\t ]{".concat(d.tabWidth*h(D,M=>M.parent&&M.parent.type!=="root"),"}$")).test(o.lastChild.value)?"":l;return o.children.length===0?S(o.hasDanglingSpaces&&o.isDanglingSpaceSensitive?c:""):S([N(o)?t:"",k([_(),I(D,d,y)]),O()])}n.exports={printElement:E}}}),Jd=Z({"src/language-html/printer-html.js"(e,n){"use strict";ae();var{builders:{fill:t,group:s,hardline:i,literalline:r},utils:{cleanDoc:u,getDocParts:a,isConcat:c,replaceTextEndOfLine:l}}=Le(),C=_d(),{countChars:m,unescapeQuoteEntities:g,getTextValueParts:p}=Ot(),f=Md(),{insertPragma:h}=Rd(),{locStart:N,locEnd:T}=Yn(),A=Hd(),{printClosingTagSuffix:b,printClosingTagEnd:v,printOpeningTagPrefix:B,printOpeningTagStart:w}=Qt(),{printElement:I}=Gd(),{printChildren:E}=go();function D(d,y,o){let x=d.getValue();switch(x.type){case"front-matter":return l(x.raw);case"root":return y.__onHtmlRoot&&y.__onHtmlRoot(x),[s(E(d,y,o)),i];case"element":case"ieConditionalComment":return I(d,y,o);case"ieConditionalStartComment":case"ieConditionalEndComment":return[w(x),v(x)];case"interpolation":return[w(x,y),...d.map(o,"children"),v(x,y)];case"text":{if(x.parent.type==="interpolation"){let S=/\n[^\S\n]*$/,k=S.test(x.value),_=k?x.value.replace(S,""):x.value;return[...l(_),k?i:""]}let F=u([B(x,y),...p(x),b(x,y)]);return c(F)||F.type==="fill"?t(a(F)):F}case"docType":return[s([w(x,y)," ",x.value.replace(/^html\b/i,"html").replace(/\s+/g," ")]),v(x,y)];case"comment":return[B(x,y),...l(y.originalText.slice(N(x),T(x)),r),b(x,y)];case"attribute":{if(x.value===null)return x.rawName;let F=g(x.value),S=m(F,"'"),k=m(F,'"'),_=S<k?"'":'"';return[x.rawName,"=",_,...l(_==='"'?F.replace(/"/g,"""):F.replace(/'/g,"'")),_]}default:throw new Error("Unexpected node type ".concat(x.type))}}n.exports={preprocess:f,print:D,insertPragma:h,massageAstNode:C,embed:A}}}),Ud=Z({"src/language-html/options.js"(e,n){"use strict";ae();var t=Lt(),s="HTML";n.exports={bracketSameLine:t.bracketSameLine,htmlWhitespaceSensitivity:{since:"1.15.0",category:s,type:"choice",default:"css",description:"How to handle whitespaces in HTML.",choices:[{value:"css",description:"Respect the default value of CSS display property."},{value:"strict",description:"Whitespaces are considered sensitive."},{value:"ignore",description:"Whitespaces are considered insensitive."}]},singleAttributePerLine:t.singleAttributePerLine,vueIndentScriptAndStyle:{since:"1.19.0",category:s,type:"boolean",default:!1,description:"Indent script and style tags in Vue files."}}}}),zd=Z({"src/language-html/parsers.js"(){ae()}}),An=Z({"node_modules/linguist-languages/data/HTML.json"(e,n){n.exports={name:"HTML",type:"markup",tmScope:"text.html.basic",aceMode:"html",codemirrorMode:"htmlmixed",codemirrorMimeType:"text/html",color:"#e34c26",aliases:["xhtml"],extensions:[".html",".htm",".html.hl",".inc",".xht",".xhtml"],languageId:146}}}),Xd=Z({"node_modules/linguist-languages/data/Vue.json"(e,n){n.exports={name:"Vue",type:"markup",color:"#41b883",extensions:[".vue"],tmScope:"text.html.vue",aceMode:"html",languageId:391}}}),Kd=Z({"src/language-html/index.js"(e,n){"use strict";ae();var t=bt(),s=Jd(),i=Ud(),r=zd(),u=[t(An(),()=>({name:"Angular",since:"1.15.0",parsers:["angular"],vscodeLanguageIds:["html"],extensions:[".component.html"],filenames:[]})),t(An(),c=>({since:"1.15.0",parsers:["html"],vscodeLanguageIds:["html"],extensions:[...c.extensions,".mjml"]})),t(An(),()=>({name:"Lightning Web Components",since:"1.17.0",parsers:["lwc"],vscodeLanguageIds:["html"],extensions:[],filenames:[]})),t(Xd(),()=>({since:"1.10.0",parsers:["vue"],vscodeLanguageIds:["vue"]}))],a={html:s};n.exports={languages:u,printers:a,options:i,parsers:r}}}),Yd=Z({"src/language-yaml/pragma.js"(e,n){"use strict";ae();function t(r){return/^\s*@(?:prettier|format)\s*$/.test(r)}function s(r){return/^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(r)}function i(r){return`# @format |
| | | |
| | | return obj; |
| | | } |
| | | |
| | | function _inherits(subClass, superClass) { |
| | | if (typeof superClass !== "function" && superClass !== null) { |
| | | throw new TypeError("Super expression must either be null or a function"); |
| | | } |
| | | |
| | | subClass.prototype = Object.create(superClass && superClass.prototype, { |
| | | constructor: { |
| | | value: subClass, |
| | | writable: true, |
| | | configurable: true |
| | | } |
| | | }); |
| | | if (superClass) _setPrototypeOf(subClass, superClass); |
| | | } |
| | | |
| | | function _getPrototypeOf(o) { |
| | | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
| | | return o.__proto__ || Object.getPrototypeOf(o); |
| | | }; |
| | | return _getPrototypeOf(o); |
| | | } |
| | | |
| | | function _setPrototypeOf(o, p) { |
| | | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
| | | o.__proto__ = p; |
| | | return o; |
| | | }; |
| | | |
| | | return _setPrototypeOf(o, p); |
| | | } |
| | | |
| | | function isNativeReflectConstruct() { |
| | | if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| | | if (Reflect.construct.sham) return false; |
| | | if (typeof Proxy === "function") return true; |
| | | |
| | | try { |
| | | Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); |
| | | return true; |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function _construct(Parent, args, Class) { |
| | | if (isNativeReflectConstruct()) { |
| | | _construct = Reflect.construct; |
| | | } else { |
| | | _construct = function _construct(Parent, args, Class) { |
| | | var a = [null]; |
| | | a.push.apply(a, args); |
| | | var Constructor = Function.bind.apply(Parent, a); |
| | | var instance = new Constructor(); |
| | | if (Class) _setPrototypeOf(instance, Class.prototype); |
| | | return instance; |
| | | }; |
| | | } |
| | | |
| | | return _construct.apply(null, arguments); |
| | | } |
| | | |
| | | function _isNativeFunction(fn) { |
| | | return Function.toString.call(fn).indexOf("[native code]") !== -1; |
| | | } |
| | | |
| | | function _wrapNativeSuper(Class) { |
| | | var _cache = typeof Map === "function" ? new Map() : undefined; |
| | | |
| | | _wrapNativeSuper = function _wrapNativeSuper(Class) { |
| | | if (Class === null || !_isNativeFunction(Class)) return Class; |
| | | |
| | | if (typeof Class !== "function") { |
| | | throw new TypeError("Super expression must either be null or a function"); |
| | | } |
| | | |
| | | if (typeof _cache !== "undefined") { |
| | | if (_cache.has(Class)) return _cache.get(Class); |
| | | |
| | | _cache.set(Class, Wrapper); |
| | | } |
| | | |
| | | function Wrapper() { |
| | | return _construct(Class, arguments, _getPrototypeOf(this).constructor); |
| | | } |
| | | |
| | | Wrapper.prototype = Object.create(Class.prototype, { |
| | | constructor: { |
| | | value: Wrapper, |
| | | enumerable: false, |
| | | writable: true, |
| | | configurable: true |
| | | } |
| | | }); |
| | | return _setPrototypeOf(Wrapper, Class); |
| | | }; |
| | | |
| | | return _wrapNativeSuper(Class); |
| | | } |
| | | |
| | | function _assertThisInitialized(self) { |
| | | if (self === void 0) { |
| | | throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| | | } |
| | | |
| | | return self; |
| | | } |
| | | |
| | | function _possibleConstructorReturn(self, call) { |
| | | if (call && (typeof call === "object" || typeof call === "function")) { |
| | | return call; |
| | | } |
| | | |
| | | return _assertThisInitialized(self); |
| | | } |
| | | |
| | | function _superPropBase(object, property) { |
| | | while (!Object.prototype.hasOwnProperty.call(object, property)) { |
| | | object = _getPrototypeOf(object); |
| | | if (object === null) break; |
| | | } |
| | | |
| | | return object; |
| | | } |
| | | |
| | | function _get(target, property, receiver) { |
| | | if (typeof Reflect !== "undefined" && Reflect.get) { |
| | | _get = Reflect.get; |
| | | } else { |
| | | _get = function _get(target, property, receiver) { |
| | | var base = _superPropBase(target, property); |
| | | |
| | | if (!base) return; |
| | | var desc = Object.getOwnPropertyDescriptor(base, property); |
| | | |
| | | if (desc.get) { |
| | | return desc.get.call(receiver); |
| | | } |
| | | |
| | | return desc.value; |
| | | }; |
| | | } |
| | | |
| | | return _get(target, property, receiver || target); |
| | | } |
| | | |
| | | function _taggedTemplateLiteral(strings, raw) { |
| | | if (!raw) { |
| | | raw = strings.slice(0); |
| | | } |
| | | |
| | | return Object.freeze(Object.defineProperties(strings, { |
| | | raw: { |
| | | value: Object.freeze(raw) |
| | | } |
| | | })); |
| | | } |
| | | |
| | | function _slicedToArray(arr, i) { |
| | | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); |
| | | } |
| | | |
| | | function _toConsumableArray(arr) { |
| | | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); |
| | | } |
| | | |
| | | function _arrayWithoutHoles(arr) { |
| | | if (Array.isArray(arr)) { |
| | | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; |
| | | |
| | | return arr2; |
| | | } |
| | | } |
| | | |
| | | function _arrayWithHoles(arr) { |
| | | if (Array.isArray(arr)) return arr; |
| | | } |
| | | |
| | | function _iterableToArray(iter) { |
| | | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
| | | } |
| | | |
| | | function _iterableToArrayLimit(arr, i) { |
| | | if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { |
| | | return; |
| | | } |
| | | |
| | | var _arr = []; |
| | | var _n = true; |
| | | var _d = false; |
| | | var _e = undefined; |
| | | |
| | | try { |
| | | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
| | | _arr.push(_s.value); |
| | | |
| | | if (i && _arr.length === i) break; |
| | | } |
| | | } catch (err) { |
| | | _d = true; |
| | | _e = err; |
| | | } finally { |
| | | try { |
| | | if (!_n && _i["return"] != null) _i["return"](); |
| | | } finally { |
| | | if (_d) throw _e; |
| | | } |
| | | } |
| | | |
| | | return _arr; |
| | | } |
| | | |
| | | function _nonIterableSpread() { |
| | | throw new TypeError("Invalid attempt to spread non-iterable instance"); |
| | | } |
| | | |
| | | function _nonIterableRest() { |
| | | throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
| | | } |
| | | |
| | | function Diff() {} |
| | | |
| | | Diff.prototype = { |
| | | diff: function diff(oldString, newString) { |
| | | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
| | | var callback = options.callback; |
| | | |
| | | if (typeof options === 'function') { |
| | | callback = options; |
| | | options = {}; |
| | | } |
| | | |
| | | this.options = options; |
| | | var self = this; |
| | | |
| | | function done(value) { |
| | | if (callback) { |
| | | setTimeout(function () { |
| | | callback(undefined, value); |
| | | }, 0); |
| | | return true; |
| | | } else { |
| | | return value; |
| | | } |
| | | } // Allow subclasses to massage the input prior to running |
| | | |
| | | |
| | | oldString = this.castInput(oldString); |
| | | newString = this.castInput(newString); |
| | | oldString = this.removeEmpty(this.tokenize(oldString)); |
| | | newString = this.removeEmpty(this.tokenize(newString)); |
| | | var newLen = newString.length, |
| | | oldLen = oldString.length; |
| | | var editLength = 1; |
| | | var maxEditLength = newLen + oldLen; |
| | | var bestPath = [{ |
| | | newPos: -1, |
| | | components: [] |
| | | }]; // Seed editLength = 0, i.e. the content starts with the same values |
| | | |
| | | var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); |
| | | |
| | | if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { |
| | | // Identity per the equality and tokenizer |
| | | return done([{ |
| | | value: this.join(newString), |
| | | count: newString.length |
| | | }]); |
| | | } // Main worker method. checks all permutations of a given edit length for acceptance. |
| | | |
| | | |
| | | function execEditLength() { |
| | | for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { |
| | | var basePath = void 0; |
| | | |
| | | var addPath = bestPath[diagonalPath - 1], |
| | | removePath = bestPath[diagonalPath + 1], |
| | | _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; |
| | | |
| | | if (addPath) { |
| | | // No one else is going to attempt to use this value, clear it |
| | | bestPath[diagonalPath - 1] = undefined; |
| | | } |
| | | |
| | | var canAdd = addPath && addPath.newPos + 1 < newLen, |
| | | canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; |
| | | |
| | | if (!canAdd && !canRemove) { |
| | | // If this path is a terminal then prune |
| | | bestPath[diagonalPath] = undefined; |
| | | continue; |
| | | } // Select the diagonal that we want to branch from. We select the prior |
| | | // path whose position in the new string is the farthest from the origin |
| | | // and does not pass the bounds of the diff graph |
| | | |
| | | |
| | | if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { |
| | | basePath = clonePath(removePath); |
| | | self.pushComponent(basePath.components, undefined, true); |
| | | } else { |
| | | basePath = addPath; // No need to clone, we've pulled it from the list |
| | | |
| | | basePath.newPos++; |
| | | self.pushComponent(basePath.components, true, undefined); |
| | | } |
| | | |
| | | _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done |
| | | |
| | | if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { |
| | | return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); |
| | | } else { |
| | | // Otherwise track this path as a potential candidate and continue. |
| | | bestPath[diagonalPath] = basePath; |
| | | } |
| | | } |
| | | |
| | | editLength++; |
| | | } // Performs the length of edit iteration. Is a bit fugly as this has to support the |
| | | // sync and async mode which is never fun. Loops over execEditLength until a value |
| | | // is produced. |
| | | |
| | | |
| | | if (callback) { |
| | | (function exec() { |
| | | setTimeout(function () { |
| | | // This should not happen, but we want to be safe. |
| | | |
| | | /* istanbul ignore next */ |
| | | if (editLength > maxEditLength) { |
| | | return callback(); |
| | | } |
| | | |
| | | if (!execEditLength()) { |
| | | exec(); |
| | | } |
| | | }, 0); |
| | | })(); |
| | | } else { |
| | | while (editLength <= maxEditLength) { |
| | | var ret = execEditLength(); |
| | | |
| | | if (ret) { |
| | | return ret; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | pushComponent: function pushComponent(components, added, removed) { |
| | | var last = components[components.length - 1]; |
| | | |
| | | if (last && last.added === added && last.removed === removed) { |
| | | // We need to clone here as the component clone operation is just |
| | | // as shallow array clone |
| | | components[components.length - 1] = { |
| | | count: last.count + 1, |
| | | added: added, |
| | | removed: removed |
| | | }; |
| | | } else { |
| | | components.push({ |
| | | count: 1, |
| | | added: added, |
| | | removed: removed |
| | | }); |
| | | } |
| | | }, |
| | | extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { |
| | | var newLen = newString.length, |
| | | oldLen = oldString.length, |
| | | newPos = basePath.newPos, |
| | | oldPos = newPos - diagonalPath, |
| | | commonCount = 0; |
| | | |
| | | while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { |
| | | newPos++; |
| | | oldPos++; |
| | | commonCount++; |
| | | } |
| | | |
| | | if (commonCount) { |
| | | basePath.components.push({ |
| | | count: commonCount |
| | | }); |
| | | } |
| | | |
| | | basePath.newPos = newPos; |
| | | return oldPos; |
| | | }, |
| | | equals: function equals(left, right) { |
| | | if (this.options.comparator) { |
| | | return this.options.comparator(left, right); |
| | | } else { |
| | | return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); |
| | | } |
| | | }, |
| | | removeEmpty: function removeEmpty(array) { |
| | | var ret = []; |
| | | |
| | | for (var i = 0; i < array.length; i++) { |
| | | if (array[i]) { |
| | | ret.push(array[i]); |
| | | } |
| | | } |
| | | |
| | | return ret; |
| | | }, |
| | | castInput: function castInput(value) { |
| | | return value; |
| | | }, |
| | | tokenize: function tokenize(value) { |
| | | return value.split(''); |
| | | }, |
| | | join: function join(chars) { |
| | | return chars.join(''); |
| | | } |
| | | }; |
| | | |
| | | function buildValues(diff, components, newString, oldString, useLongestToken) { |
| | | var componentPos = 0, |
| | | componentLen = components.length, |
| | | newPos = 0, |
| | | oldPos = 0; |
| | | |
| | | for (; componentPos < componentLen; componentPos++) { |
| | | var component = components[componentPos]; |
| | | |
| | | if (!component.removed) { |
| | | if (!component.added && useLongestToken) { |
| | | var value = newString.slice(newPos, newPos + component.count); |
| | | value = value.map(function (value, i) { |
| | | var oldValue = oldString[oldPos + i]; |
| | | return oldValue.length > value.length ? oldValue : value; |
| | | }); |
| | | component.value = diff.join(value); |
| | | } else { |
| | | component.value = diff.join(newString.slice(newPos, newPos + component.count)); |
| | | } |
| | | |
| | | newPos += component.count; // Common case |
| | | |
| | | if (!component.added) { |
| | | oldPos += component.count; |
| | | } |
| | | } else { |
| | | component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); |
| | | oldPos += component.count; // Reverse add and remove so removes are output first to match common convention |
| | | // The diffing algorithm is tied to add then remove output and this is the simplest |
| | | // route to get the desired output with minimal overhead. |
| | | |
| | | if (componentPos && components[componentPos - 1].added) { |
| | | var tmp = components[componentPos - 1]; |
| | | components[componentPos - 1] = components[componentPos]; |
| | | components[componentPos] = tmp; |
| | | } |
| | | } |
| | | } // Special case handle for when one terminal is ignored (i.e. whitespace). |
| | | // For this case we merge the terminal into the prior string and drop the change. |
| | | // This is only available for string mode. |
| | | |
| | | |
| | | var lastComponent = components[componentLen - 1]; |
| | | |
| | | if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { |
| | | components[componentLen - 2].value += lastComponent.value; |
| | | components.pop(); |
| | | } |
| | | |
| | | return components; |
| | | } |
| | | |
| | | function clonePath(path) { |
| | | return { |
| | | newPos: path.newPos, |
| | | components: path.components.slice(0) |
| | | }; |
| | | } |
| | | |
| | | var characterDiff = new Diff(); |
| | | |
| | | function diffChars(oldStr, newStr, options) { |
| | | return characterDiff.diff(oldStr, newStr, options); |
| | | } |
| | | |
| | | function generateOptions(options, defaults) { |
| | | if (typeof options === 'function') { |
| | | defaults.callback = options; |
| | | } else if (options) { |
| | | for (var name in options) { |
| | | /* istanbul ignore else */ |
| | | if (options.hasOwnProperty(name)) { |
| | | defaults[name] = options[name]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return defaults; |
| | | } // |
| | | // Ranges and exceptions: |
| | | // Latin-1 Supplement, 0080–00FF |
| | | // - U+00D7 × Multiplication sign |
| | | // - U+00F7 ÷ Division sign |
| | | // Latin Extended-A, 0100–017F |
| | | // Latin Extended-B, 0180–024F |
| | | // IPA Extensions, 0250–02AF |
| | | // Spacing Modifier Letters, 02B0–02FF |
| | | // - U+02C7 ˇ ˇ Caron |
| | | // - U+02D8 ˘ ˘ Breve |
| | | // - U+02D9 ˙ ˙ Dot Above |
| | | // - U+02DA ˚ ˚ Ring Above |
| | | // - U+02DB ˛ ˛ Ogonek |
| | | // - U+02DC ˜ ˜ Small Tilde |
| | | // - U+02DD ˝ ˝ Double Acute Accent |
| | | // Latin Extended Additional, 1E00–1EFF |
| | | |
| | | |
| | | var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; |
| | | var reWhitespace = /\S/; |
| | | var wordDiff = new Diff(); |
| | | |
| | | wordDiff.equals = function (left, right) { |
| | | if (this.options.ignoreCase) { |
| | | left = left.toLowerCase(); |
| | | right = right.toLowerCase(); |
| | | } |
| | | |
| | | return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); |
| | | }; |
| | | |
| | | wordDiff.tokenize = function (value) { |
| | | var tokens = value.split(/(\s+|[()[\]{}'"]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. |
| | | |
| | | for (var i = 0; i < tokens.length - 1; i++) { |
| | | // If we have an empty string in the next field and we have only word chars before and after, merge |
| | | if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { |
| | | tokens[i] += tokens[i + 2]; |
| | | tokens.splice(i + 1, 2); |
| | | i--; |
| | | } |
| | | } |
| | | |
| | | return tokens; |
| | | }; |
| | | |
| | | function diffWords(oldStr, newStr, options) { |
| | | options = generateOptions(options, { |
| | | ignoreWhitespace: true |
| | | }); |
| | | return wordDiff.diff(oldStr, newStr, options); |
| | | } |
| | | |
| | | function diffWordsWithSpace(oldStr, newStr, options) { |
| | | return wordDiff.diff(oldStr, newStr, options); |
| | | } |
| | | |
| | | var lineDiff = new Diff(); |
| | | |
| | | lineDiff.tokenize = function (value) { |
| | | var retLines = [], |
| | | linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line |
| | | |
| | | if (!linesAndNewlines[linesAndNewlines.length - 1]) { |
| | | linesAndNewlines.pop(); |
| | | } // Merge the content and line separators into single tokens |
| | | |
| | | |
| | | for (var i = 0; i < linesAndNewlines.length; i++) { |
| | | var line = linesAndNewlines[i]; |
| | | |
| | | if (i % 2 && !this.options.newlineIsToken) { |
| | | retLines[retLines.length - 1] += line; |
| | | } else { |
| | | if (this.options.ignoreWhitespace) { |
| | | line = line.trim(); |
| | | } |
| | | |
| | | retLines.push(line); |
| | | } |
| | | } |
| | | |
| | | return retLines; |
| | | }; |
| | | |
| | | function diffLines(oldStr, newStr, callback) { |
| | | return lineDiff.diff(oldStr, newStr, callback); |
| | | } |
| | | |
| | | function diffTrimmedLines(oldStr, newStr, callback) { |
| | | var options = generateOptions(callback, { |
| | | ignoreWhitespace: true |
| | | }); |
| | | return lineDiff.diff(oldStr, newStr, options); |
| | | } |
| | | |
| | | var sentenceDiff = new Diff(); |
| | | |
| | | sentenceDiff.tokenize = function (value) { |
| | | return value.split(/(\S.+?[.!?])(?=\s+|$)/); |
| | | }; |
| | | |
| | | function diffSentences(oldStr, newStr, callback) { |
| | | return sentenceDiff.diff(oldStr, newStr, callback); |
| | | } |
| | | |
| | | var cssDiff = new Diff(); |
| | | |
| | | cssDiff.tokenize = function (value) { |
| | | return value.split(/([{}:;,]|\s+)/); |
| | | }; |
| | | |
| | | function diffCss(oldStr, newStr, callback) { |
| | | return cssDiff.diff(oldStr, newStr, callback); |
| | | } |
| | | |
| | | function _typeof$1(obj) { |
| | | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { |
| | | _typeof$1 = function _typeof$1(obj) { |
| | | return _typeof(obj); |
| | | }; |
| | | } else { |
| | | _typeof$1 = function _typeof$1(obj) { |
| | | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); |
| | | }; |
| | | } |
| | | |
| | | return _typeof$1(obj); |
| | | } |
| | | |
| | | function _toConsumableArray$1(arr) { |
| | | return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1(); |
| | | } |
| | | |
| | | function _arrayWithoutHoles$1(arr) { |
| | | if (Array.isArray(arr)) { |
| | | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
| | | arr2[i] = arr[i]; |
| | | } |
| | | |
| | | return arr2; |
| | | } |
| | | } |
| | | |
| | | function _iterableToArray$1(iter) { |
| | | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
| | | } |
| | | |
| | | function _nonIterableSpread$1() { |
| | | throw new TypeError("Invalid attempt to spread non-iterable instance"); |
| | | } |
| | | |
| | | var objectPrototypeToString = Object.prototype.toString; |
| | | var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a |
| | | // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: |
| | | |
| | | jsonDiff.useLongestToken = true; |
| | | jsonDiff.tokenize = lineDiff.tokenize; |
| | | |
| | | jsonDiff.castInput = function (value) { |
| | | var _this$options = this.options, |
| | | undefinedReplacement = _this$options.undefinedReplacement, |
| | | _this$options$stringi = _this$options.stringifyReplacer, |
| | | stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) { |
| | | return typeof v === 'undefined' ? undefinedReplacement : v; |
| | | } : _this$options$stringi; |
| | | return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); |
| | | }; |
| | | |
| | | jsonDiff.equals = function (left, right) { |
| | | return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')); |
| | | }; |
| | | |
| | | function diffJson(oldObj, newObj, options) { |
| | | return jsonDiff.diff(oldObj, newObj, options); |
| | | } // This function handles the presence of circular references by bailing out when encountering an |
| | | // object that is already on the "stack" of items being processed. Accepts an optional replacer |
| | | |
| | | |
| | | function canonicalize(obj, stack, replacementStack, replacer, key) { |
| | | stack = stack || []; |
| | | replacementStack = replacementStack || []; |
| | | |
| | | if (replacer) { |
| | | obj = replacer(key, obj); |
| | | } |
| | | |
| | | var i; |
| | | |
| | | for (i = 0; i < stack.length; i += 1) { |
| | | if (stack[i] === obj) { |
| | | return replacementStack[i]; |
| | | } |
| | | } |
| | | |
| | | var canonicalizedObj; |
| | | |
| | | if ('[object Array]' === objectPrototypeToString.call(obj)) { |
| | | stack.push(obj); |
| | | canonicalizedObj = new Array(obj.length); |
| | | replacementStack.push(canonicalizedObj); |
| | | |
| | | for (i = 0; i < obj.length; i += 1) { |
| | | canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); |
| | | } |
| | | |
| | | stack.pop(); |
| | | replacementStack.pop(); |
| | | return canonicalizedObj; |
| | | } |
| | | |
| | | if (obj && obj.toJSON) { |
| | | obj = obj.toJSON(); |
| | | } |
| | | |
| | | if (_typeof$1(obj) === 'object' && obj !== null) { |
| | | stack.push(obj); |
| | | canonicalizedObj = {}; |
| | | replacementStack.push(canonicalizedObj); |
| | | |
| | | var sortedKeys = [], |
| | | _key; |
| | | |
| | | for (_key in obj) { |
| | | /* istanbul ignore else */ |
| | | if (obj.hasOwnProperty(_key)) { |
| | | sortedKeys.push(_key); |
| | | } |
| | | } |
| | | |
| | | sortedKeys.sort(); |
| | | |
| | | for (i = 0; i < sortedKeys.length; i += 1) { |
| | | _key = sortedKeys[i]; |
| | | canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); |
| | | } |
| | | |
| | | stack.pop(); |
| | | replacementStack.pop(); |
| | | } else { |
| | | canonicalizedObj = obj; |
| | | } |
| | | |
| | | return canonicalizedObj; |
| | | } |
| | | |
| | | var arrayDiff = new Diff(); |
| | | |
| | | arrayDiff.tokenize = function (value) { |
| | | return value.slice(); |
| | | }; |
| | | |
| | | arrayDiff.join = arrayDiff.removeEmpty = function (value) { |
| | | return value; |
| | | }; |
| | | |
| | | function diffArrays(oldArr, newArr, callback) { |
| | | return arrayDiff.diff(oldArr, newArr, callback); |
| | | } |
| | | |
| | | function parsePatch(uniDiff) { |
| | | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| | | var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), |
| | | delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
| | | list = [], |
| | | i = 0; |
| | | |
| | | function parseIndex() { |
| | | var index = {}; |
| | | list.push(index); // Parse diff metadata |
| | | |
| | | while (i < diffstr.length) { |
| | | var line = diffstr[i]; // File header found, end parsing diff metadata |
| | | |
| | | if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { |
| | | break; |
| | | } // Diff index |
| | | |
| | | |
| | | var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); |
| | | |
| | | if (header) { |
| | | index.index = header[1]; |
| | | } |
| | | |
| | | i++; |
| | | } // Parse file headers if they are defined. Unified diff requires them, but |
| | | // there's no technical issues to have an isolated hunk without file header |
| | | |
| | | |
| | | parseFileHeader(index); |
| | | parseFileHeader(index); // Parse hunks |
| | | |
| | | index.hunks = []; |
| | | |
| | | while (i < diffstr.length) { |
| | | var _line = diffstr[i]; |
| | | |
| | | if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { |
| | | break; |
| | | } else if (/^@@/.test(_line)) { |
| | | index.hunks.push(parseHunk()); |
| | | } else if (_line && options.strict) { |
| | | // Ignore unexpected content unless in strict mode |
| | | throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); |
| | | } else { |
| | | i++; |
| | | } |
| | | } |
| | | } // Parses the --- and +++ headers, if none are found, no lines |
| | | // are consumed. |
| | | |
| | | |
| | | function parseFileHeader(index) { |
| | | var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]); |
| | | |
| | | if (fileHeader) { |
| | | var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; |
| | | var data = fileHeader[2].split('\t', 2); |
| | | var fileName = data[0].replace(/\\\\/g, '\\'); |
| | | |
| | | if (/^".*"$/.test(fileName)) { |
| | | fileName = fileName.substr(1, fileName.length - 2); |
| | | } |
| | | |
| | | index[keyPrefix + 'FileName'] = fileName; |
| | | index[keyPrefix + 'Header'] = (data[1] || '').trim(); |
| | | i++; |
| | | } |
| | | } // Parses a hunk |
| | | // This assumes that we are at the start of a hunk. |
| | | |
| | | |
| | | function parseHunk() { |
| | | var chunkHeaderIndex = i, |
| | | chunkHeaderLine = diffstr[i++], |
| | | chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); |
| | | var hunk = { |
| | | oldStart: +chunkHeader[1], |
| | | oldLines: +chunkHeader[2] || 1, |
| | | newStart: +chunkHeader[3], |
| | | newLines: +chunkHeader[4] || 1, |
| | | lines: [], |
| | | linedelimiters: [] |
| | | }; |
| | | var addCount = 0, |
| | | removeCount = 0; |
| | | |
| | | for (; i < diffstr.length; i++) { |
| | | // Lines starting with '---' could be mistaken for the "remove line" operation |
| | | // But they could be the header for the next file. Therefore prune such cases out. |
| | | if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { |
| | | break; |
| | | } |
| | | |
| | | var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; |
| | | |
| | | if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { |
| | | hunk.lines.push(diffstr[i]); |
| | | hunk.linedelimiters.push(delimiters[i] || '\n'); |
| | | |
| | | if (operation === '+') { |
| | | addCount++; |
| | | } else if (operation === '-') { |
| | | removeCount++; |
| | | } else if (operation === ' ') { |
| | | addCount++; |
| | | removeCount++; |
| | | } |
| | | } else { |
| | | break; |
| | | } |
| | | } // Handle the empty block count case |
| | | |
| | | |
| | | if (!addCount && hunk.newLines === 1) { |
| | | hunk.newLines = 0; |
| | | } |
| | | |
| | | if (!removeCount && hunk.oldLines === 1) { |
| | | hunk.oldLines = 0; |
| | | } // Perform optional sanity checking |
| | | |
| | | |
| | | if (options.strict) { |
| | | if (addCount !== hunk.newLines) { |
| | | throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
| | | } |
| | | |
| | | if (removeCount !== hunk.oldLines) { |
| | | throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
| | | } |
| | | } |
| | | |
| | | return hunk; |
| | | } |
| | | |
| | | while (i < diffstr.length) { |
| | | parseIndex(); |
| | | } |
| | | |
| | | return list; |
| | | } // Iterator that traverses in the range of [min, max], stepping |
| | | // by distance from a given start position. I.e. for [0, 4], with |
| | | // start of 2, this will iterate 2, 3, 1, 4, 0. |
| | | |
| | | |
| | | function distanceIterator(start, minLine, maxLine) { |
| | | var wantForward = true, |
| | | backwardExhausted = false, |
| | | forwardExhausted = false, |
| | | localOffset = 1; |
| | | return function iterator() { |
| | | if (wantForward && !forwardExhausted) { |
| | | if (backwardExhausted) { |
| | | localOffset++; |
| | | } else { |
| | | wantForward = false; |
| | | } // Check if trying to fit beyond text length, and if not, check it fits |
| | | // after offset location (or desired location on first iteration) |
| | | |
| | | |
| | | if (start + localOffset <= maxLine) { |
| | | return localOffset; |
| | | } |
| | | |
| | | forwardExhausted = true; |
| | | } |
| | | |
| | | if (!backwardExhausted) { |
| | | if (!forwardExhausted) { |
| | | wantForward = true; |
| | | } // Check if trying to fit before text beginning, and if not, check it fits |
| | | // before offset location |
| | | |
| | | |
| | | if (minLine <= start - localOffset) { |
| | | return -localOffset++; |
| | | } |
| | | |
| | | backwardExhausted = true; |
| | | return iterator(); |
| | | } // We tried to fit hunk before text beginning and beyond text length, then |
| | | // hunk can't fit on the text. Return undefined |
| | | |
| | | }; |
| | | } |
| | | |
| | | function applyPatch(source, uniDiff) { |
| | | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
| | | |
| | | if (typeof uniDiff === 'string') { |
| | | uniDiff = parsePatch(uniDiff); |
| | | } |
| | | |
| | | if (Array.isArray(uniDiff)) { |
| | | if (uniDiff.length > 1) { |
| | | throw new Error('applyPatch only works with a single input.'); |
| | | } |
| | | |
| | | uniDiff = uniDiff[0]; |
| | | } // Apply the diff to the input |
| | | |
| | | |
| | | var lines = source.split(/\r\n|[\n\v\f\r\x85]/), |
| | | delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
| | | hunks = uniDiff.hunks, |
| | | compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) { |
| | | return line === patchContent; |
| | | }, |
| | | errorCount = 0, |
| | | fuzzFactor = options.fuzzFactor || 0, |
| | | minLine = 0, |
| | | offset = 0, |
| | | removeEOFNL, |
| | | addEOFNL; |
| | | /** |
| | | * Checks if the hunk exactly fits on the provided location |
| | | */ |
| | | |
| | | |
| | | function hunkFits(hunk, toPos) { |
| | | for (var j = 0; j < hunk.lines.length; j++) { |
| | | var line = hunk.lines[j], |
| | | operation = line.length > 0 ? line[0] : ' ', |
| | | content = line.length > 0 ? line.substr(1) : line; |
| | | |
| | | if (operation === ' ' || operation === '-') { |
| | | // Context sanity check |
| | | if (!compareLine(toPos + 1, lines[toPos], operation, content)) { |
| | | errorCount++; |
| | | |
| | | if (errorCount > fuzzFactor) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | toPos++; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } // Search best fit offsets for each hunk based on the previous ones |
| | | |
| | | |
| | | for (var i = 0; i < hunks.length; i++) { |
| | | var hunk = hunks[i], |
| | | maxLine = lines.length - hunk.oldLines, |
| | | localOffset = 0, |
| | | toPos = offset + hunk.oldStart - 1; |
| | | var iterator = distanceIterator(toPos, minLine, maxLine); |
| | | |
| | | for (; localOffset !== undefined; localOffset = iterator()) { |
| | | if (hunkFits(hunk, toPos + localOffset)) { |
| | | hunk.offset = offset += localOffset; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (localOffset === undefined) { |
| | | return false; |
| | | } // Set lower text limit to end of the current hunk, so next ones don't try |
| | | // to fit over already patched text |
| | | |
| | | |
| | | minLine = hunk.offset + hunk.oldStart + hunk.oldLines; |
| | | } // Apply patch hunks |
| | | |
| | | |
| | | var diffOffset = 0; |
| | | |
| | | for (var _i = 0; _i < hunks.length; _i++) { |
| | | var _hunk = hunks[_i], |
| | | _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; |
| | | |
| | | diffOffset += _hunk.newLines - _hunk.oldLines; |
| | | |
| | | if (_toPos < 0) { |
| | | // Creating a new file |
| | | _toPos = 0; |
| | | } |
| | | |
| | | for (var j = 0; j < _hunk.lines.length; j++) { |
| | | var line = _hunk.lines[j], |
| | | operation = line.length > 0 ? line[0] : ' ', |
| | | content = line.length > 0 ? line.substr(1) : line, |
| | | delimiter = _hunk.linedelimiters[j]; |
| | | |
| | | if (operation === ' ') { |
| | | _toPos++; |
| | | } else if (operation === '-') { |
| | | lines.splice(_toPos, 1); |
| | | delimiters.splice(_toPos, 1); |
| | | /* istanbul ignore else */ |
| | | } else if (operation === '+') { |
| | | lines.splice(_toPos, 0, content); |
| | | delimiters.splice(_toPos, 0, delimiter); |
| | | _toPos++; |
| | | } else if (operation === '\\') { |
| | | var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; |
| | | |
| | | if (previousOperation === '+') { |
| | | removeEOFNL = true; |
| | | } else if (previousOperation === '-') { |
| | | addEOFNL = true; |
| | | } |
| | | } |
| | | } |
| | | } // Handle EOFNL insertion/removal |
| | | |
| | | |
| | | if (removeEOFNL) { |
| | | while (!lines[lines.length - 1]) { |
| | | lines.pop(); |
| | | delimiters.pop(); |
| | | } |
| | | } else if (addEOFNL) { |
| | | lines.push(''); |
| | | delimiters.push('\n'); |
| | | } |
| | | |
| | | for (var _k = 0; _k < lines.length - 1; _k++) { |
| | | lines[_k] = lines[_k] + delimiters[_k]; |
| | | } |
| | | |
| | | return lines.join(''); |
| | | } // Wrapper that supports multiple file patches via callbacks. |
| | | |
| | | |
| | | function applyPatches(uniDiff, options) { |
| | | if (typeof uniDiff === 'string') { |
| | | uniDiff = parsePatch(uniDiff); |
| | | } |
| | | |
| | | var currentIndex = 0; |
| | | |
| | | function processIndex() { |
| | | var index = uniDiff[currentIndex++]; |
| | | |
| | | if (!index) { |
| | | return options.complete(); |
| | | } |
| | | |
| | | options.loadFile(index, function (err, data) { |
| | | if (err) { |
| | | return options.complete(err); |
| | | } |
| | | |
| | | var updatedContent = applyPatch(data, index, options); |
| | | options.patched(index, updatedContent, function (err) { |
| | | if (err) { |
| | | return options.complete(err); |
| | | } |
| | | |
| | | processIndex(); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | processIndex(); |
| | | } |
| | | |
| | | function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
| | | if (!options) { |
| | | options = {}; |
| | | } |
| | | |
| | | if (typeof options.context === 'undefined') { |
| | | options.context = 4; |
| | | } |
| | | |
| | | var diff = diffLines(oldStr, newStr, options); |
| | | diff.push({ |
| | | value: '', |
| | | lines: [] |
| | | }); // Append an empty value to make cleanup easier |
| | | |
| | | function contextLines(lines) { |
| | | return lines.map(function (entry) { |
| | | return ' ' + entry; |
| | | }); |
| | | } |
| | | |
| | | var hunks = []; |
| | | var oldRangeStart = 0, |
| | | newRangeStart = 0, |
| | | curRange = [], |
| | | oldLine = 1, |
| | | newLine = 1; |
| | | |
| | | var _loop = function _loop(i) { |
| | | var current = diff[i], |
| | | lines = current.lines || current.value.replace(/\n$/, '').split('\n'); |
| | | current.lines = lines; |
| | | |
| | | if (current.added || current.removed) { |
| | | var _curRange; // If we have previous context, start with that |
| | | |
| | | |
| | | if (!oldRangeStart) { |
| | | var prev = diff[i - 1]; |
| | | oldRangeStart = oldLine; |
| | | newRangeStart = newLine; |
| | | |
| | | if (prev) { |
| | | curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; |
| | | oldRangeStart -= curRange.length; |
| | | newRangeStart -= curRange.length; |
| | | } |
| | | } // Output our changes |
| | | |
| | | |
| | | (_curRange = curRange).push.apply(_curRange, _toConsumableArray$1(lines.map(function (entry) { |
| | | return (current.added ? '+' : '-') + entry; |
| | | }))); // Track the updated file position |
| | | |
| | | |
| | | if (current.added) { |
| | | newLine += lines.length; |
| | | } else { |
| | | oldLine += lines.length; |
| | | } |
| | | } else { |
| | | // Identical context lines. Track line changes |
| | | if (oldRangeStart) { |
| | | // Close out any changes that have been output (or join overlapping) |
| | | if (lines.length <= options.context * 2 && i < diff.length - 2) { |
| | | var _curRange2; // Overlapping |
| | | |
| | | |
| | | (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray$1(contextLines(lines))); |
| | | } else { |
| | | var _curRange3; // end the range and output |
| | | |
| | | |
| | | var contextSize = Math.min(lines.length, options.context); |
| | | |
| | | (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray$1(contextLines(lines.slice(0, contextSize)))); |
| | | |
| | | var hunk = { |
| | | oldStart: oldRangeStart, |
| | | oldLines: oldLine - oldRangeStart + contextSize, |
| | | newStart: newRangeStart, |
| | | newLines: newLine - newRangeStart + contextSize, |
| | | lines: curRange |
| | | }; |
| | | |
| | | if (i >= diff.length - 2 && lines.length <= options.context) { |
| | | // EOF is inside this hunk |
| | | var oldEOFNewline = /\n$/.test(oldStr); |
| | | var newEOFNewline = /\n$/.test(newStr); |
| | | var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; |
| | | |
| | | if (!oldEOFNewline && noNlBeforeAdds) { |
| | | // special case: old has no eol and no trailing context; no-nl can end up before adds |
| | | curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); |
| | | } |
| | | |
| | | if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { |
| | | curRange.push('\\ No newline at end of file'); |
| | | } |
| | | } |
| | | |
| | | hunks.push(hunk); |
| | | oldRangeStart = 0; |
| | | newRangeStart = 0; |
| | | curRange = []; |
| | | } |
| | | } |
| | | |
| | | oldLine += lines.length; |
| | | newLine += lines.length; |
| | | } |
| | | }; |
| | | |
| | | for (var i = 0; i < diff.length; i++) { |
| | | _loop(i); |
| | | } |
| | | |
| | | return { |
| | | oldFileName: oldFileName, |
| | | newFileName: newFileName, |
| | | oldHeader: oldHeader, |
| | | newHeader: newHeader, |
| | | hunks: hunks |
| | | }; |
| | | } |
| | | |
| | | function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
| | | var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); |
| | | var ret = []; |
| | | |
| | | if (oldFileName == newFileName) { |
| | | ret.push('Index: ' + oldFileName); |
| | | } |
| | | |
| | | ret.push('==================================================================='); |
| | | ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); |
| | | ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); |
| | | |
| | | for (var i = 0; i < diff.hunks.length; i++) { |
| | | var hunk = diff.hunks[i]; |
| | | ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); |
| | | ret.push.apply(ret, hunk.lines); |
| | | } |
| | | |
| | | return ret.join('\n') + '\n'; |
| | | } |
| | | |
| | | function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { |
| | | return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); |
| | | } |
| | | |
| | | function arrayEqual(a, b) { |
| | | if (a.length !== b.length) { |
| | | return false; |
| | | } |
| | | |
| | | return arrayStartsWith(a, b); |
| | | } |
| | | |
| | | function arrayStartsWith(array, start) { |
| | | if (start.length > array.length) { |
| | | return false; |
| | | } |
| | | |
| | | for (var i = 0; i < start.length; i++) { |
| | | if (start[i] !== array[i]) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function calcLineCount(hunk) { |
| | | var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), |
| | | oldLines = _calcOldNewLineCount.oldLines, |
| | | newLines = _calcOldNewLineCount.newLines; |
| | | |
| | | if (oldLines !== undefined) { |
| | | hunk.oldLines = oldLines; |
| | | } else { |
| | | delete hunk.oldLines; |
| | | } |
| | | |
| | | if (newLines !== undefined) { |
| | | hunk.newLines = newLines; |
| | | } else { |
| | | delete hunk.newLines; |
| | | } |
| | | } |
| | | |
| | | function merge(mine, theirs, base) { |
| | | mine = loadPatch(mine, base); |
| | | theirs = loadPatch(theirs, base); |
| | | var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. |
| | | // Leaving sanity checks on this to the API consumer that may know more about the |
| | | // meaning in their own context. |
| | | |
| | | if (mine.index || theirs.index) { |
| | | ret.index = mine.index || theirs.index; |
| | | } |
| | | |
| | | if (mine.newFileName || theirs.newFileName) { |
| | | if (!fileNameChanged(mine)) { |
| | | // No header or no change in ours, use theirs (and ours if theirs does not exist) |
| | | ret.oldFileName = theirs.oldFileName || mine.oldFileName; |
| | | ret.newFileName = theirs.newFileName || mine.newFileName; |
| | | ret.oldHeader = theirs.oldHeader || mine.oldHeader; |
| | | ret.newHeader = theirs.newHeader || mine.newHeader; |
| | | } else if (!fileNameChanged(theirs)) { |
| | | // No header or no change in theirs, use ours |
| | | ret.oldFileName = mine.oldFileName; |
| | | ret.newFileName = mine.newFileName; |
| | | ret.oldHeader = mine.oldHeader; |
| | | ret.newHeader = mine.newHeader; |
| | | } else { |
| | | // Both changed... figure it out |
| | | ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); |
| | | ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); |
| | | ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); |
| | | ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); |
| | | } |
| | | } |
| | | |
| | | ret.hunks = []; |
| | | var mineIndex = 0, |
| | | theirsIndex = 0, |
| | | mineOffset = 0, |
| | | theirsOffset = 0; |
| | | |
| | | while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { |
| | | var mineCurrent = mine.hunks[mineIndex] || { |
| | | oldStart: Infinity |
| | | }, |
| | | theirsCurrent = theirs.hunks[theirsIndex] || { |
| | | oldStart: Infinity |
| | | }; |
| | | |
| | | if (hunkBefore(mineCurrent, theirsCurrent)) { |
| | | // This patch does not overlap with any of the others, yay. |
| | | ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); |
| | | mineIndex++; |
| | | theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; |
| | | } else if (hunkBefore(theirsCurrent, mineCurrent)) { |
| | | // This patch does not overlap with any of the others, yay. |
| | | ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); |
| | | theirsIndex++; |
| | | mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; |
| | | } else { |
| | | // Overlap, merge as best we can |
| | | var mergedHunk = { |
| | | oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), |
| | | oldLines: 0, |
| | | newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), |
| | | newLines: 0, |
| | | lines: [] |
| | | }; |
| | | mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); |
| | | theirsIndex++; |
| | | mineIndex++; |
| | | ret.hunks.push(mergedHunk); |
| | | } |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | function loadPatch(param, base) { |
| | | if (typeof param === 'string') { |
| | | if (/^@@/m.test(param) || /^Index:/m.test(param)) { |
| | | return parsePatch(param)[0]; |
| | | } |
| | | |
| | | if (!base) { |
| | | throw new Error('Must provide a base reference or pass in a patch'); |
| | | } |
| | | |
| | | return structuredPatch(undefined, undefined, base, param); |
| | | } |
| | | |
| | | return param; |
| | | } |
| | | |
| | | function fileNameChanged(patch) { |
| | | return patch.newFileName && patch.newFileName !== patch.oldFileName; |
| | | } |
| | | |
| | | function selectField(index, mine, theirs) { |
| | | if (mine === theirs) { |
| | | return mine; |
| | | } else { |
| | | index.conflict = true; |
| | | return { |
| | | mine: mine, |
| | | theirs: theirs |
| | | }; |
| | | } |
| | | } |
| | | |
| | | function hunkBefore(test, check) { |
| | | return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; |
| | | } |
| | | |
| | | function cloneHunk(hunk, offset) { |
| | | return { |
| | | oldStart: hunk.oldStart, |
| | | oldLines: hunk.oldLines, |
| | | newStart: hunk.newStart + offset, |
| | | newLines: hunk.newLines, |
| | | lines: hunk.lines |
| | | }; |
| | | } |
| | | |
| | | function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { |
| | | // This will generally result in a conflicted hunk, but there are cases where the context |
| | | // is the only overlap where we can successfully merge the content here. |
| | | var mine = { |
| | | offset: mineOffset, |
| | | lines: mineLines, |
| | | index: 0 |
| | | }, |
| | | their = { |
| | | offset: theirOffset, |
| | | lines: theirLines, |
| | | index: 0 |
| | | }; // Handle any leading content |
| | | |
| | | insertLeading(hunk, mine, their); |
| | | insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. |
| | | |
| | | while (mine.index < mine.lines.length && their.index < their.lines.length) { |
| | | var mineCurrent = mine.lines[mine.index], |
| | | theirCurrent = their.lines[their.index]; |
| | | |
| | | if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { |
| | | // Both modified ... |
| | | mutualChange(hunk, mine, their); |
| | | } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { |
| | | var _hunk$lines; // Mine inserted |
| | | |
| | | |
| | | (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray$1(collectChange(mine))); |
| | | } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { |
| | | var _hunk$lines2; // Theirs inserted |
| | | |
| | | |
| | | (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray$1(collectChange(their))); |
| | | } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { |
| | | // Mine removed or edited |
| | | removal(hunk, mine, their); |
| | | } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { |
| | | // Their removed or edited |
| | | removal(hunk, their, mine, true); |
| | | } else if (mineCurrent === theirCurrent) { |
| | | // Context identity |
| | | hunk.lines.push(mineCurrent); |
| | | mine.index++; |
| | | their.index++; |
| | | } else { |
| | | // Context mismatch |
| | | conflict(hunk, collectChange(mine), collectChange(their)); |
| | | } |
| | | } // Now push anything that may be remaining |
| | | |
| | | |
| | | insertTrailing(hunk, mine); |
| | | insertTrailing(hunk, their); |
| | | calcLineCount(hunk); |
| | | } |
| | | |
| | | function mutualChange(hunk, mine, their) { |
| | | var myChanges = collectChange(mine), |
| | | theirChanges = collectChange(their); |
| | | |
| | | if (allRemoves(myChanges) && allRemoves(theirChanges)) { |
| | | // Special case for remove changes that are supersets of one another |
| | | if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { |
| | | var _hunk$lines3; |
| | | |
| | | (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray$1(myChanges)); |
| | | |
| | | return; |
| | | } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { |
| | | var _hunk$lines4; |
| | | |
| | | (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray$1(theirChanges)); |
| | | |
| | | return; |
| | | } |
| | | } else if (arrayEqual(myChanges, theirChanges)) { |
| | | var _hunk$lines5; |
| | | |
| | | (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray$1(myChanges)); |
| | | |
| | | return; |
| | | } |
| | | |
| | | conflict(hunk, myChanges, theirChanges); |
| | | } |
| | | |
| | | function removal(hunk, mine, their, swap) { |
| | | var myChanges = collectChange(mine), |
| | | theirChanges = collectContext(their, myChanges); |
| | | |
| | | if (theirChanges.merged) { |
| | | var _hunk$lines6; |
| | | |
| | | (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray$1(theirChanges.merged)); |
| | | } else { |
| | | conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); |
| | | } |
| | | } |
| | | |
| | | function conflict(hunk, mine, their) { |
| | | hunk.conflict = true; |
| | | hunk.lines.push({ |
| | | conflict: true, |
| | | mine: mine, |
| | | theirs: their |
| | | }); |
| | | } |
| | | |
| | | function insertLeading(hunk, insert, their) { |
| | | while (insert.offset < their.offset && insert.index < insert.lines.length) { |
| | | var line = insert.lines[insert.index++]; |
| | | hunk.lines.push(line); |
| | | insert.offset++; |
| | | } |
| | | } |
| | | |
| | | function insertTrailing(hunk, insert) { |
| | | while (insert.index < insert.lines.length) { |
| | | var line = insert.lines[insert.index++]; |
| | | hunk.lines.push(line); |
| | | } |
| | | } |
| | | |
| | | function collectChange(state) { |
| | | var ret = [], |
| | | operation = state.lines[state.index][0]; |
| | | |
| | | while (state.index < state.lines.length) { |
| | | var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. |
| | | |
| | | if (operation === '-' && line[0] === '+') { |
| | | operation = '+'; |
| | | } |
| | | |
| | | if (operation === line[0]) { |
| | | ret.push(line); |
| | | state.index++; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | function collectContext(state, matchChanges) { |
| | | var changes = [], |
| | | merged = [], |
| | | matchIndex = 0, |
| | | contextChanges = false, |
| | | conflicted = false; |
| | | |
| | | while (matchIndex < matchChanges.length && state.index < state.lines.length) { |
| | | var change = state.lines[state.index], |
| | | match = matchChanges[matchIndex]; // Once we've hit our add, then we are done |
| | | |
| | | if (match[0] === '+') { |
| | | break; |
| | | } |
| | | |
| | | contextChanges = contextChanges || change[0] !== ' '; |
| | | merged.push(match); |
| | | matchIndex++; // Consume any additions in the other block as a conflict to attempt |
| | | // to pull in the remaining context after this |
| | | |
| | | if (change[0] === '+') { |
| | | conflicted = true; |
| | | |
| | | while (change[0] === '+') { |
| | | changes.push(change); |
| | | change = state.lines[++state.index]; |
| | | } |
| | | } |
| | | |
| | | if (match.substr(1) === change.substr(1)) { |
| | | changes.push(change); |
| | | state.index++; |
| | | } else { |
| | | conflicted = true; |
| | | } |
| | | } |
| | | |
| | | if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { |
| | | conflicted = true; |
| | | } |
| | | |
| | | if (conflicted) { |
| | | return changes; |
| | | } |
| | | |
| | | while (matchIndex < matchChanges.length) { |
| | | merged.push(matchChanges[matchIndex++]); |
| | | } |
| | | |
| | | return { |
| | | merged: merged, |
| | | changes: changes |
| | | }; |
| | | } |
| | | |
| | | function allRemoves(changes) { |
| | | return changes.reduce(function (prev, change) { |
| | | return prev && change[0] === '-'; |
| | | }, true); |
| | | } |
| | | |
| | | function skipRemoveSuperset(state, removeChanges, delta) { |
| | | for (var i = 0; i < delta; i++) { |
| | | var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); |
| | | |
| | | if (state.lines[state.index + i] !== ' ' + changeContent) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | state.index += delta; |
| | | return true; |
| | | } |
| | | |
| | | function calcOldNewLineCount(lines) { |
| | | var oldLines = 0; |
| | | var newLines = 0; |
| | | lines.forEach(function (line) { |
| | | if (typeof line !== 'string') { |
| | | var myCount = calcOldNewLineCount(line.mine); |
| | | var theirCount = calcOldNewLineCount(line.theirs); |
| | | |
| | | if (oldLines !== undefined) { |
| | | if (myCount.oldLines === theirCount.oldLines) { |
| | | oldLines += myCount.oldLines; |
| | | } else { |
| | | oldLines = undefined; |
| | | } |
| | | } |
| | | |
| | | if (newLines !== undefined) { |
| | | if (myCount.newLines === theirCount.newLines) { |
| | | newLines += myCount.newLines; |
| | | } else { |
| | | newLines = undefined; |
| | | } |
| | | } |
| | | } else { |
| | | if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { |
| | | newLines++; |
| | | } |
| | | |
| | | if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { |
| | | oldLines++; |
| | | } |
| | | } |
| | | }); |
| | | return { |
| | | oldLines: oldLines, |
| | | newLines: newLines |
| | | }; |
| | | } // See: http://code.google.com/p/google-diff-match-patch/wiki/API |
| | | |
| | | |
| | | function convertChangesToDMP(changes) { |
| | | var ret = [], |
| | | change, |
| | | operation; |
| | | |
| | | for (var i = 0; i < changes.length; i++) { |
| | | change = changes[i]; |
| | | |
| | | if (change.added) { |
| | | operation = 1; |
| | | } else if (change.removed) { |
| | | operation = -1; |
| | | } else { |
| | | operation = 0; |
| | | } |
| | | |
| | | ret.push([operation, change.value]); |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | function convertChangesToXML(changes) { |
| | | var ret = []; |
| | | |
| | | for (var i = 0; i < changes.length; i++) { |
| | | var change = changes[i]; |
| | | |
| | | if (change.added) { |
| | | ret.push('<ins>'); |
| | | } else if (change.removed) { |
| | | ret.push('<del>'); |
| | | } |
| | | |
| | | ret.push(escapeHTML(change.value)); |
| | | |
| | | if (change.added) { |
| | | ret.push('</ins>'); |
| | | } else if (change.removed) { |
| | | ret.push('</del>'); |
| | | } |
| | | } |
| | | |
| | | return ret.join(''); |
| | | } |
| | | |
| | | function escapeHTML(s) { |
| | | var n = s; |
| | | n = n.replace(/&/g, '&'); |
| | | n = n.replace(/</g, '<'); |
| | | n = n.replace(/>/g, '>'); |
| | | n = n.replace(/"/g, '"'); |
| | | return n; |
| | | } |
| | | |
| | | var index_es6 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | Diff: Diff, |
| | | diffChars: diffChars, |
| | | diffWords: diffWords, |
| | | diffWordsWithSpace: diffWordsWithSpace, |
| | | diffLines: diffLines, |
| | | diffTrimmedLines: diffTrimmedLines, |
| | | diffSentences: diffSentences, |
| | | diffCss: diffCss, |
| | | diffJson: diffJson, |
| | | diffArrays: diffArrays, |
| | | structuredPatch: structuredPatch, |
| | | createTwoFilesPatch: createTwoFilesPatch, |
| | | createPatch: createPatch, |
| | | applyPatch: applyPatch, |
| | | applyPatches: applyPatches, |
| | | parsePatch: parsePatch, |
| | | merge: merge, |
| | | convertChangesToDMP: convertChangesToDMP, |
| | | convertChangesToXML: convertChangesToXML, |
| | | canonicalize: canonicalize |
| | | }); |
| | | |
| | | var _shim_fs = {}; |
| | | |
| | | var _shim_fs$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | 'default': _shim_fs |
| | | }); |
| | | |
| | | /*! |
| | | * normalize-path <https://github.com/jonschlinkert/normalize-path> |
| | | * |
| | | * Copyright (c) 2014-2018, Jon Schlinkert. |
| | | * Released under the MIT License. |
| | | */ |
| | | var normalizePath = function normalizePath(path, stripTrailing) { |
| | | if (typeof path !== 'string') { |
| | | throw new TypeError('expected path to be a string'); |
| | | } |
| | | |
| | | if (path === '\\' || path === '/') return '/'; |
| | | var len = path.length; |
| | | if (len <= 1) return path; // ensure that win32 namespaces has two leading slashes, so that the path is |
| | | // handled properly by the win32 version of path.parse() after being normalized |
| | | // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces |
| | | |
| | | var prefix = ''; |
| | | |
| | | if (len > 4 && path[3] === '\\') { |
| | | var ch = path[2]; |
| | | |
| | | if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') { |
| | | path = path.slice(2); |
| | | prefix = '//'; |
| | | } |
| | | } |
| | | |
| | | var segs = path.split(/[/\\]+/); |
| | | |
| | | if (stripTrailing !== false && segs[segs.length - 1] === '') { |
| | | segs.pop(); |
| | | } |
| | | |
| | | return prefix + segs.join('/'); |
| | | }; |
| | | |
| | | var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; |
| | | |
| | | var lookup = []; |
| | | var revLookup = []; |
| | | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; |
| | | var inited = false; |
| | | |
| | | function init() { |
| | | inited = true; |
| | | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
| | | |
| | | for (var i = 0, len = code.length; i < len; ++i) { |
| | | lookup[i] = code[i]; |
| | | revLookup[code.charCodeAt(i)] = i; |
| | | } |
| | | |
| | | revLookup['-'.charCodeAt(0)] = 62; |
| | | revLookup['_'.charCodeAt(0)] = 63; |
| | | } |
| | | |
| | | function toByteArray(b64) { |
| | | if (!inited) { |
| | | init(); |
| | | } |
| | | |
| | | var i, j, l, tmp, placeHolders, arr; |
| | | var len = b64.length; |
| | | |
| | | if (len % 4 > 0) { |
| | | throw new Error('Invalid string. Length must be a multiple of 4'); |
| | | } // the number of equal signs (place holders) |
| | | // if there are two placeholders, than the two characters before it |
| | | // represent one byte |
| | | // if there is only one, then the three characters before it represent 2 bytes |
| | | // this is just a cheap hack to not do indexOf twice |
| | | |
| | | |
| | | placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; // base64 is 4/3 + up to two characters of the original data |
| | | |
| | | arr = new Arr(len * 3 / 4 - placeHolders); // if there are placeholders, only get up to the last complete 4 chars |
| | | |
| | | l = placeHolders > 0 ? len - 4 : len; |
| | | var L = 0; |
| | | |
| | | for (i = 0, j = 0; i < l; i += 4, j += 3) { |
| | | tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; |
| | | arr[L++] = tmp >> 16 & 0xFF; |
| | | arr[L++] = tmp >> 8 & 0xFF; |
| | | arr[L++] = tmp & 0xFF; |
| | | } |
| | | |
| | | if (placeHolders === 2) { |
| | | tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; |
| | | arr[L++] = tmp & 0xFF; |
| | | } else if (placeHolders === 1) { |
| | | tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; |
| | | arr[L++] = tmp >> 8 & 0xFF; |
| | | arr[L++] = tmp & 0xFF; |
| | | } |
| | | |
| | | return arr; |
| | | } |
| | | |
| | | function tripletToBase64(num) { |
| | | return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; |
| | | } |
| | | |
| | | function encodeChunk(uint8, start, end) { |
| | | var tmp; |
| | | var output = []; |
| | | |
| | | for (var i = start; i < end; i += 3) { |
| | | tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2]; |
| | | output.push(tripletToBase64(tmp)); |
| | | } |
| | | |
| | | return output.join(''); |
| | | } |
| | | |
| | | function fromByteArray(uint8) { |
| | | if (!inited) { |
| | | init(); |
| | | } |
| | | |
| | | var tmp; |
| | | var len = uint8.length; |
| | | var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes |
| | | |
| | | var output = ''; |
| | | var parts = []; |
| | | var maxChunkLength = 16383; // must be multiple of 3 |
| | | // go through the array every three bytes, we'll deal with trailing stuff later |
| | | |
| | | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { |
| | | parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); |
| | | } // pad the end with zeros, but make sure to not forget the extra bytes |
| | | |
| | | |
| | | if (extraBytes === 1) { |
| | | tmp = uint8[len - 1]; |
| | | output += lookup[tmp >> 2]; |
| | | output += lookup[tmp << 4 & 0x3F]; |
| | | output += '=='; |
| | | } else if (extraBytes === 2) { |
| | | tmp = (uint8[len - 2] << 8) + uint8[len - 1]; |
| | | output += lookup[tmp >> 10]; |
| | | output += lookup[tmp >> 4 & 0x3F]; |
| | | output += lookup[tmp << 2 & 0x3F]; |
| | | output += '='; |
| | | } |
| | | |
| | | parts.push(output); |
| | | return parts.join(''); |
| | | } |
| | | |
| | | function read(buffer, offset, isLE, mLen, nBytes) { |
| | | var e, m; |
| | | var eLen = nBytes * 8 - mLen - 1; |
| | | var eMax = (1 << eLen) - 1; |
| | | var eBias = eMax >> 1; |
| | | var nBits = -7; |
| | | var i = isLE ? nBytes - 1 : 0; |
| | | var d = isLE ? -1 : 1; |
| | | var s = buffer[offset + i]; |
| | | i += d; |
| | | e = s & (1 << -nBits) - 1; |
| | | s >>= -nBits; |
| | | nBits += eLen; |
| | | |
| | | for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} |
| | | |
| | | m = e & (1 << -nBits) - 1; |
| | | e >>= -nBits; |
| | | nBits += mLen; |
| | | |
| | | for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} |
| | | |
| | | if (e === 0) { |
| | | e = 1 - eBias; |
| | | } else if (e === eMax) { |
| | | return m ? NaN : (s ? -1 : 1) * Infinity; |
| | | } else { |
| | | m = m + Math.pow(2, mLen); |
| | | e = e - eBias; |
| | | } |
| | | |
| | | return (s ? -1 : 1) * m * Math.pow(2, e - mLen); |
| | | } |
| | | function write(buffer, value, offset, isLE, mLen, nBytes) { |
| | | var e, m, c; |
| | | var eLen = nBytes * 8 - mLen - 1; |
| | | var eMax = (1 << eLen) - 1; |
| | | var eBias = eMax >> 1; |
| | | var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; |
| | | var i = isLE ? 0 : nBytes - 1; |
| | | var d = isLE ? 1 : -1; |
| | | var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; |
| | | value = Math.abs(value); |
| | | |
| | | if (isNaN(value) || value === Infinity) { |
| | | m = isNaN(value) ? 1 : 0; |
| | | e = eMax; |
| | | } else { |
| | | e = Math.floor(Math.log(value) / Math.LN2); |
| | | |
| | | if (value * (c = Math.pow(2, -e)) < 1) { |
| | | e--; |
| | | c *= 2; |
| | | } |
| | | |
| | | if (e + eBias >= 1) { |
| | | value += rt / c; |
| | | } else { |
| | | value += rt * Math.pow(2, 1 - eBias); |
| | | } |
| | | |
| | | if (value * c >= 2) { |
| | | e++; |
| | | c /= 2; |
| | | } |
| | | |
| | | if (e + eBias >= eMax) { |
| | | m = 0; |
| | | e = eMax; |
| | | } else if (e + eBias >= 1) { |
| | | m = (value * c - 1) * Math.pow(2, mLen); |
| | | e = e + eBias; |
| | | } else { |
| | | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); |
| | | e = 0; |
| | | } |
| | | } |
| | | |
| | | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} |
| | | |
| | | e = e << mLen | m; |
| | | eLen += mLen; |
| | | |
| | | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} |
| | | |
| | | buffer[offset + i - d] |= s * 128; |
| | | } |
| | | |
| | | var toString = {}.toString; |
| | | var isArray = Array.isArray || function (arr) { |
| | | return toString.call(arr) == '[object Array]'; |
| | | }; |
| | | |
| | | var INSPECT_MAX_BYTES = 50; |
| | | /** |
| | | * If `Buffer.TYPED_ARRAY_SUPPORT`: |
| | | * === true Use Uint8Array implementation (fastest) |
| | | * === false Use Object implementation (most compatible, even IE6) |
| | | * |
| | | * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, |
| | | * Opera 11.6+, iOS 4.2+. |
| | | * |
| | | * Due to various browser bugs, sometimes the Object implementation will be used even |
| | | * when the browser supports typed arrays. |
| | | * |
| | | * Note: |
| | | * |
| | | * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, |
| | | * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. |
| | | * |
| | | * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. |
| | | * |
| | | * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of |
| | | * incorrect length in some situations. |
| | | |
| | | * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they |
| | | * get the Object implementation, which is slower but behaves correctly. |
| | | */ |
| | | |
| | | Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined ? global$1.TYPED_ARRAY_SUPPORT : true; |
| | | |
| | | function kMaxLength() { |
| | | return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff; |
| | | } |
| | | |
| | | function createBuffer(that, length) { |
| | | if (kMaxLength() < length) { |
| | | throw new RangeError('Invalid typed array length'); |
| | | } |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | // Return an augmented `Uint8Array` instance, for best performance |
| | | that = new Uint8Array(length); |
| | | that.__proto__ = Buffer.prototype; |
| | | } else { |
| | | // Fallback: Return an object instance of the Buffer class |
| | | if (that === null) { |
| | | that = new Buffer(length); |
| | | } |
| | | |
| | | that.length = length; |
| | | } |
| | | |
| | | return that; |
| | | } |
| | | /** |
| | | * The Buffer constructor returns instances of `Uint8Array` that have their |
| | | * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of |
| | | * `Uint8Array`, so the returned instances will have all the node `Buffer` methods |
| | | * and the `Uint8Array` methods. Square bracket notation works as expected -- it |
| | | * returns a single octet. |
| | | * |
| | | * The `Uint8Array` prototype remains unmodified. |
| | | */ |
| | | |
| | | |
| | | function Buffer(arg, encodingOrOffset, length) { |
| | | if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { |
| | | return new Buffer(arg, encodingOrOffset, length); |
| | | } // Common case. |
| | | |
| | | |
| | | if (typeof arg === 'number') { |
| | | if (typeof encodingOrOffset === 'string') { |
| | | throw new Error('If encoding is specified then the first argument must be a string'); |
| | | } |
| | | |
| | | return allocUnsafe(this, arg); |
| | | } |
| | | |
| | | return from(this, arg, encodingOrOffset, length); |
| | | } |
| | | Buffer.poolSize = 8192; // not used by this implementation |
| | | // TODO: Legacy, not needed anymore. Remove in next major version. |
| | | |
| | | Buffer._augment = function (arr) { |
| | | arr.__proto__ = Buffer.prototype; |
| | | return arr; |
| | | }; |
| | | |
| | | function from(that, value, encodingOrOffset, length) { |
| | | if (typeof value === 'number') { |
| | | throw new TypeError('"value" argument must not be a number'); |
| | | } |
| | | |
| | | if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { |
| | | return fromArrayBuffer(that, value, encodingOrOffset, length); |
| | | } |
| | | |
| | | if (typeof value === 'string') { |
| | | return fromString(that, value, encodingOrOffset); |
| | | } |
| | | |
| | | return fromObject(that, value); |
| | | } |
| | | /** |
| | | * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError |
| | | * if value is a number. |
| | | * Buffer.from(str[, encoding]) |
| | | * Buffer.from(array) |
| | | * Buffer.from(buffer) |
| | | * Buffer.from(arrayBuffer[, byteOffset[, length]]) |
| | | **/ |
| | | |
| | | |
| | | Buffer.from = function (value, encodingOrOffset, length) { |
| | | return from(null, value, encodingOrOffset, length); |
| | | }; |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | Buffer.prototype.__proto__ = Uint8Array.prototype; |
| | | Buffer.__proto__ = Uint8Array; |
| | | } |
| | | |
| | | function assertSize(size) { |
| | | if (typeof size !== 'number') { |
| | | throw new TypeError('"size" argument must be a number'); |
| | | } else if (size < 0) { |
| | | throw new RangeError('"size" argument must not be negative'); |
| | | } |
| | | } |
| | | |
| | | function alloc(that, size, fill, encoding) { |
| | | assertSize(size); |
| | | |
| | | if (size <= 0) { |
| | | return createBuffer(that, size); |
| | | } |
| | | |
| | | if (fill !== undefined) { |
| | | // Only pay attention to encoding if it's a string. This |
| | | // prevents accidentally sending in a number that would |
| | | // be interpretted as a start offset. |
| | | return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill); |
| | | } |
| | | |
| | | return createBuffer(that, size); |
| | | } |
| | | /** |
| | | * Creates a new filled Buffer instance. |
| | | * alloc(size[, fill[, encoding]]) |
| | | **/ |
| | | |
| | | |
| | | Buffer.alloc = function (size, fill, encoding) { |
| | | return alloc(null, size, fill, encoding); |
| | | }; |
| | | |
| | | function allocUnsafe(that, size) { |
| | | assertSize(size); |
| | | that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); |
| | | |
| | | if (!Buffer.TYPED_ARRAY_SUPPORT) { |
| | | for (var i = 0; i < size; ++i) { |
| | | that[i] = 0; |
| | | } |
| | | } |
| | | |
| | | return that; |
| | | } |
| | | /** |
| | | * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. |
| | | * */ |
| | | |
| | | |
| | | Buffer.allocUnsafe = function (size) { |
| | | return allocUnsafe(null, size); |
| | | }; |
| | | /** |
| | | * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. |
| | | */ |
| | | |
| | | |
| | | Buffer.allocUnsafeSlow = function (size) { |
| | | return allocUnsafe(null, size); |
| | | }; |
| | | |
| | | function fromString(that, string, encoding) { |
| | | if (typeof encoding !== 'string' || encoding === '') { |
| | | encoding = 'utf8'; |
| | | } |
| | | |
| | | if (!Buffer.isEncoding(encoding)) { |
| | | throw new TypeError('"encoding" must be a valid string encoding'); |
| | | } |
| | | |
| | | var length = byteLength(string, encoding) | 0; |
| | | that = createBuffer(that, length); |
| | | var actual = that.write(string, encoding); |
| | | |
| | | if (actual !== length) { |
| | | // Writing a hex string, for example, that contains invalid characters will |
| | | // cause everything after the first invalid character to be ignored. (e.g. |
| | | // 'abxxcd' will be treated as 'ab') |
| | | that = that.slice(0, actual); |
| | | } |
| | | |
| | | return that; |
| | | } |
| | | |
| | | function fromArrayLike(that, array) { |
| | | var length = array.length < 0 ? 0 : checked(array.length) | 0; |
| | | that = createBuffer(that, length); |
| | | |
| | | for (var i = 0; i < length; i += 1) { |
| | | that[i] = array[i] & 255; |
| | | } |
| | | |
| | | return that; |
| | | } |
| | | |
| | | function fromArrayBuffer(that, array, byteOffset, length) { |
| | | array.byteLength; // this throws if `array` is not a valid ArrayBuffer |
| | | |
| | | if (byteOffset < 0 || array.byteLength < byteOffset) { |
| | | throw new RangeError('\'offset\' is out of bounds'); |
| | | } |
| | | |
| | | if (array.byteLength < byteOffset + (length || 0)) { |
| | | throw new RangeError('\'length\' is out of bounds'); |
| | | } |
| | | |
| | | if (byteOffset === undefined && length === undefined) { |
| | | array = new Uint8Array(array); |
| | | } else if (length === undefined) { |
| | | array = new Uint8Array(array, byteOffset); |
| | | } else { |
| | | array = new Uint8Array(array, byteOffset, length); |
| | | } |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | // Return an augmented `Uint8Array` instance, for best performance |
| | | that = array; |
| | | that.__proto__ = Buffer.prototype; |
| | | } else { |
| | | // Fallback: Return an object instance of the Buffer class |
| | | that = fromArrayLike(that, array); |
| | | } |
| | | |
| | | return that; |
| | | } |
| | | |
| | | function fromObject(that, obj) { |
| | | if (internalIsBuffer(obj)) { |
| | | var len = checked(obj.length) | 0; |
| | | that = createBuffer(that, len); |
| | | |
| | | if (that.length === 0) { |
| | | return that; |
| | | } |
| | | |
| | | obj.copy(that, 0, 0, len); |
| | | return that; |
| | | } |
| | | |
| | | if (obj) { |
| | | if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) { |
| | | if (typeof obj.length !== 'number' || isnan(obj.length)) { |
| | | return createBuffer(that, 0); |
| | | } |
| | | |
| | | return fromArrayLike(that, obj); |
| | | } |
| | | |
| | | if (obj.type === 'Buffer' && isArray(obj.data)) { |
| | | return fromArrayLike(that, obj.data); |
| | | } |
| | | } |
| | | |
| | | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.'); |
| | | } |
| | | |
| | | function checked(length) { |
| | | // Note: cannot use `length < kMaxLength()` here because that fails when |
| | | // length is NaN (which is otherwise coerced to zero.) |
| | | if (length >= kMaxLength()) { |
| | | throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes'); |
| | | } |
| | | |
| | | return length | 0; |
| | | } |
| | | Buffer.isBuffer = isBuffer; |
| | | |
| | | function internalIsBuffer(b) { |
| | | return !!(b != null && b._isBuffer); |
| | | } |
| | | |
| | | Buffer.compare = function compare(a, b) { |
| | | if (!internalIsBuffer(a) || !internalIsBuffer(b)) { |
| | | throw new TypeError('Arguments must be Buffers'); |
| | | } |
| | | |
| | | if (a === b) return 0; |
| | | var x = a.length; |
| | | var y = b.length; |
| | | |
| | | for (var i = 0, len = Math.min(x, y); i < len; ++i) { |
| | | if (a[i] !== b[i]) { |
| | | x = a[i]; |
| | | y = b[i]; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (x < y) return -1; |
| | | if (y < x) return 1; |
| | | return 0; |
| | | }; |
| | | |
| | | Buffer.isEncoding = function isEncoding(encoding) { |
| | | switch (String(encoding).toLowerCase()) { |
| | | case 'hex': |
| | | case 'utf8': |
| | | case 'utf-8': |
| | | case 'ascii': |
| | | case 'latin1': |
| | | case 'binary': |
| | | case 'base64': |
| | | case 'ucs2': |
| | | case 'ucs-2': |
| | | case 'utf16le': |
| | | case 'utf-16le': |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | Buffer.concat = function concat(list, length) { |
| | | if (!isArray(list)) { |
| | | throw new TypeError('"list" argument must be an Array of Buffers'); |
| | | } |
| | | |
| | | if (list.length === 0) { |
| | | return Buffer.alloc(0); |
| | | } |
| | | |
| | | var i; |
| | | |
| | | if (length === undefined) { |
| | | length = 0; |
| | | |
| | | for (i = 0; i < list.length; ++i) { |
| | | length += list[i].length; |
| | | } |
| | | } |
| | | |
| | | var buffer = Buffer.allocUnsafe(length); |
| | | var pos = 0; |
| | | |
| | | for (i = 0; i < list.length; ++i) { |
| | | var buf = list[i]; |
| | | |
| | | if (!internalIsBuffer(buf)) { |
| | | throw new TypeError('"list" argument must be an Array of Buffers'); |
| | | } |
| | | |
| | | buf.copy(buffer, pos); |
| | | pos += buf.length; |
| | | } |
| | | |
| | | return buffer; |
| | | }; |
| | | |
| | | function byteLength(string, encoding) { |
| | | if (internalIsBuffer(string)) { |
| | | return string.length; |
| | | } |
| | | |
| | | if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { |
| | | return string.byteLength; |
| | | } |
| | | |
| | | if (typeof string !== 'string') { |
| | | string = '' + string; |
| | | } |
| | | |
| | | var len = string.length; |
| | | if (len === 0) return 0; // Use a for loop to avoid recursion |
| | | |
| | | var loweredCase = false; |
| | | |
| | | for (;;) { |
| | | switch (encoding) { |
| | | case 'ascii': |
| | | case 'latin1': |
| | | case 'binary': |
| | | return len; |
| | | |
| | | case 'utf8': |
| | | case 'utf-8': |
| | | case undefined: |
| | | return utf8ToBytes(string).length; |
| | | |
| | | case 'ucs2': |
| | | case 'ucs-2': |
| | | case 'utf16le': |
| | | case 'utf-16le': |
| | | return len * 2; |
| | | |
| | | case 'hex': |
| | | return len >>> 1; |
| | | |
| | | case 'base64': |
| | | return base64ToBytes(string).length; |
| | | |
| | | default: |
| | | if (loweredCase) return utf8ToBytes(string).length; // assume utf8 |
| | | |
| | | encoding = ('' + encoding).toLowerCase(); |
| | | loweredCase = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Buffer.byteLength = byteLength; |
| | | |
| | | function slowToString(encoding, start, end) { |
| | | var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only |
| | | // property of a typed array. |
| | | // This behaves neither like String nor Uint8Array in that we set start/end |
| | | // to their upper/lower bounds if the value passed is out of range. |
| | | // undefined is handled specially as per ECMA-262 6th Edition, |
| | | // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. |
| | | |
| | | if (start === undefined || start < 0) { |
| | | start = 0; |
| | | } // Return early if start > this.length. Done here to prevent potential uint32 |
| | | // coercion fail below. |
| | | |
| | | |
| | | if (start > this.length) { |
| | | return ''; |
| | | } |
| | | |
| | | if (end === undefined || end > this.length) { |
| | | end = this.length; |
| | | } |
| | | |
| | | if (end <= 0) { |
| | | return ''; |
| | | } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. |
| | | |
| | | |
| | | end >>>= 0; |
| | | start >>>= 0; |
| | | |
| | | if (end <= start) { |
| | | return ''; |
| | | } |
| | | |
| | | if (!encoding) encoding = 'utf8'; |
| | | |
| | | while (true) { |
| | | switch (encoding) { |
| | | case 'hex': |
| | | return hexSlice(this, start, end); |
| | | |
| | | case 'utf8': |
| | | case 'utf-8': |
| | | return utf8Slice(this, start, end); |
| | | |
| | | case 'ascii': |
| | | return asciiSlice(this, start, end); |
| | | |
| | | case 'latin1': |
| | | case 'binary': |
| | | return latin1Slice(this, start, end); |
| | | |
| | | case 'base64': |
| | | return base64Slice(this, start, end); |
| | | |
| | | case 'ucs2': |
| | | case 'ucs-2': |
| | | case 'utf16le': |
| | | case 'utf-16le': |
| | | return utf16leSlice(this, start, end); |
| | | |
| | | default: |
| | | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); |
| | | encoding = (encoding + '').toLowerCase(); |
| | | loweredCase = true; |
| | | } |
| | | } |
| | | } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect |
| | | // Buffer instances. |
| | | |
| | | |
| | | Buffer.prototype._isBuffer = true; |
| | | |
| | | function swap(b, n, m) { |
| | | var i = b[n]; |
| | | b[n] = b[m]; |
| | | b[m] = i; |
| | | } |
| | | |
| | | Buffer.prototype.swap16 = function swap16() { |
| | | var len = this.length; |
| | | |
| | | if (len % 2 !== 0) { |
| | | throw new RangeError('Buffer size must be a multiple of 16-bits'); |
| | | } |
| | | |
| | | for (var i = 0; i < len; i += 2) { |
| | | swap(this, i, i + 1); |
| | | } |
| | | |
| | | return this; |
| | | }; |
| | | |
| | | Buffer.prototype.swap32 = function swap32() { |
| | | var len = this.length; |
| | | |
| | | if (len % 4 !== 0) { |
| | | throw new RangeError('Buffer size must be a multiple of 32-bits'); |
| | | } |
| | | |
| | | for (var i = 0; i < len; i += 4) { |
| | | swap(this, i, i + 3); |
| | | swap(this, i + 1, i + 2); |
| | | } |
| | | |
| | | return this; |
| | | }; |
| | | |
| | | Buffer.prototype.swap64 = function swap64() { |
| | | var len = this.length; |
| | | |
| | | if (len % 8 !== 0) { |
| | | throw new RangeError('Buffer size must be a multiple of 64-bits'); |
| | | } |
| | | |
| | | for (var i = 0; i < len; i += 8) { |
| | | swap(this, i, i + 7); |
| | | swap(this, i + 1, i + 6); |
| | | swap(this, i + 2, i + 5); |
| | | swap(this, i + 3, i + 4); |
| | | } |
| | | |
| | | return this; |
| | | }; |
| | | |
| | | Buffer.prototype.toString = function toString() { |
| | | var length = this.length | 0; |
| | | if (length === 0) return ''; |
| | | if (arguments.length === 0) return utf8Slice(this, 0, length); |
| | | return slowToString.apply(this, arguments); |
| | | }; |
| | | |
| | | Buffer.prototype.equals = function equals(b) { |
| | | if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer'); |
| | | if (this === b) return true; |
| | | return Buffer.compare(this, b) === 0; |
| | | }; |
| | | |
| | | Buffer.prototype.inspect = function inspect() { |
| | | var str = ''; |
| | | var max = INSPECT_MAX_BYTES; |
| | | |
| | | if (this.length > 0) { |
| | | str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); |
| | | if (this.length > max) str += ' ... '; |
| | | } |
| | | |
| | | return '<Buffer ' + str + '>'; |
| | | }; |
| | | |
| | | Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { |
| | | if (!internalIsBuffer(target)) { |
| | | throw new TypeError('Argument must be a Buffer'); |
| | | } |
| | | |
| | | if (start === undefined) { |
| | | start = 0; |
| | | } |
| | | |
| | | if (end === undefined) { |
| | | end = target ? target.length : 0; |
| | | } |
| | | |
| | | if (thisStart === undefined) { |
| | | thisStart = 0; |
| | | } |
| | | |
| | | if (thisEnd === undefined) { |
| | | thisEnd = this.length; |
| | | } |
| | | |
| | | if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { |
| | | throw new RangeError('out of range index'); |
| | | } |
| | | |
| | | if (thisStart >= thisEnd && start >= end) { |
| | | return 0; |
| | | } |
| | | |
| | | if (thisStart >= thisEnd) { |
| | | return -1; |
| | | } |
| | | |
| | | if (start >= end) { |
| | | return 1; |
| | | } |
| | | |
| | | start >>>= 0; |
| | | end >>>= 0; |
| | | thisStart >>>= 0; |
| | | thisEnd >>>= 0; |
| | | if (this === target) return 0; |
| | | var x = thisEnd - thisStart; |
| | | var y = end - start; |
| | | var len = Math.min(x, y); |
| | | var thisCopy = this.slice(thisStart, thisEnd); |
| | | var targetCopy = target.slice(start, end); |
| | | |
| | | for (var i = 0; i < len; ++i) { |
| | | if (thisCopy[i] !== targetCopy[i]) { |
| | | x = thisCopy[i]; |
| | | y = targetCopy[i]; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (x < y) return -1; |
| | | if (y < x) return 1; |
| | | return 0; |
| | | }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, |
| | | // OR the last index of `val` in `buffer` at offset <= `byteOffset`. |
| | | // |
| | | // Arguments: |
| | | // - buffer - a Buffer to search |
| | | // - val - a string, Buffer, or number |
| | | // - byteOffset - an index into `buffer`; will be clamped to an int32 |
| | | // - encoding - an optional encoding, relevant is val is a string |
| | | // - dir - true for indexOf, false for lastIndexOf |
| | | |
| | | |
| | | function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { |
| | | // Empty buffer means no match |
| | | if (buffer.length === 0) return -1; // Normalize byteOffset |
| | | |
| | | if (typeof byteOffset === 'string') { |
| | | encoding = byteOffset; |
| | | byteOffset = 0; |
| | | } else if (byteOffset > 0x7fffffff) { |
| | | byteOffset = 0x7fffffff; |
| | | } else if (byteOffset < -0x80000000) { |
| | | byteOffset = -0x80000000; |
| | | } |
| | | |
| | | byteOffset = +byteOffset; // Coerce to Number. |
| | | |
| | | if (isNaN(byteOffset)) { |
| | | // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer |
| | | byteOffset = dir ? 0 : buffer.length - 1; |
| | | } // Normalize byteOffset: negative offsets start from the end of the buffer |
| | | |
| | | |
| | | if (byteOffset < 0) byteOffset = buffer.length + byteOffset; |
| | | |
| | | if (byteOffset >= buffer.length) { |
| | | if (dir) return -1;else byteOffset = buffer.length - 1; |
| | | } else if (byteOffset < 0) { |
| | | if (dir) byteOffset = 0;else return -1; |
| | | } // Normalize val |
| | | |
| | | |
| | | if (typeof val === 'string') { |
| | | val = Buffer.from(val, encoding); |
| | | } // Finally, search either indexOf (if dir is true) or lastIndexOf |
| | | |
| | | |
| | | if (internalIsBuffer(val)) { |
| | | // Special case: looking for empty string/buffer always fails |
| | | if (val.length === 0) { |
| | | return -1; |
| | | } |
| | | |
| | | return arrayIndexOf(buffer, val, byteOffset, encoding, dir); |
| | | } else if (typeof val === 'number') { |
| | | val = val & 0xFF; // Search for a byte value [0-255] |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') { |
| | | if (dir) { |
| | | return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); |
| | | } else { |
| | | return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); |
| | | } |
| | | } |
| | | |
| | | return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); |
| | | } |
| | | |
| | | throw new TypeError('val must be string, number or Buffer'); |
| | | } |
| | | |
| | | function arrayIndexOf(arr, val, byteOffset, encoding, dir) { |
| | | var indexSize = 1; |
| | | var arrLength = arr.length; |
| | | var valLength = val.length; |
| | | |
| | | if (encoding !== undefined) { |
| | | encoding = String(encoding).toLowerCase(); |
| | | |
| | | if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { |
| | | if (arr.length < 2 || val.length < 2) { |
| | | return -1; |
| | | } |
| | | |
| | | indexSize = 2; |
| | | arrLength /= 2; |
| | | valLength /= 2; |
| | | byteOffset /= 2; |
| | | } |
| | | } |
| | | |
| | | function read(buf, i) { |
| | | if (indexSize === 1) { |
| | | return buf[i]; |
| | | } else { |
| | | return buf.readUInt16BE(i * indexSize); |
| | | } |
| | | } |
| | | |
| | | var i; |
| | | |
| | | if (dir) { |
| | | var foundIndex = -1; |
| | | |
| | | for (i = byteOffset; i < arrLength; i++) { |
| | | if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { |
| | | if (foundIndex === -1) foundIndex = i; |
| | | if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; |
| | | } else { |
| | | if (foundIndex !== -1) i -= i - foundIndex; |
| | | foundIndex = -1; |
| | | } |
| | | } |
| | | } else { |
| | | if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; |
| | | |
| | | for (i = byteOffset; i >= 0; i--) { |
| | | var found = true; |
| | | |
| | | for (var j = 0; j < valLength; j++) { |
| | | if (read(arr, i + j) !== read(val, j)) { |
| | | found = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (found) return i; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | Buffer.prototype.includes = function includes(val, byteOffset, encoding) { |
| | | return this.indexOf(val, byteOffset, encoding) !== -1; |
| | | }; |
| | | |
| | | Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { |
| | | return bidirectionalIndexOf(this, val, byteOffset, encoding, true); |
| | | }; |
| | | |
| | | Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { |
| | | return bidirectionalIndexOf(this, val, byteOffset, encoding, false); |
| | | }; |
| | | |
| | | function hexWrite(buf, string, offset, length) { |
| | | offset = Number(offset) || 0; |
| | | var remaining = buf.length - offset; |
| | | |
| | | if (!length) { |
| | | length = remaining; |
| | | } else { |
| | | length = Number(length); |
| | | |
| | | if (length > remaining) { |
| | | length = remaining; |
| | | } |
| | | } // must be an even number of digits |
| | | |
| | | |
| | | var strLen = string.length; |
| | | if (strLen % 2 !== 0) throw new TypeError('Invalid hex string'); |
| | | |
| | | if (length > strLen / 2) { |
| | | length = strLen / 2; |
| | | } |
| | | |
| | | for (var i = 0; i < length; ++i) { |
| | | var parsed = parseInt(string.substr(i * 2, 2), 16); |
| | | if (isNaN(parsed)) return i; |
| | | buf[offset + i] = parsed; |
| | | } |
| | | |
| | | return i; |
| | | } |
| | | |
| | | function utf8Write(buf, string, offset, length) { |
| | | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); |
| | | } |
| | | |
| | | function asciiWrite(buf, string, offset, length) { |
| | | return blitBuffer(asciiToBytes(string), buf, offset, length); |
| | | } |
| | | |
| | | function latin1Write(buf, string, offset, length) { |
| | | return asciiWrite(buf, string, offset, length); |
| | | } |
| | | |
| | | function base64Write(buf, string, offset, length) { |
| | | return blitBuffer(base64ToBytes(string), buf, offset, length); |
| | | } |
| | | |
| | | function ucs2Write(buf, string, offset, length) { |
| | | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); |
| | | } |
| | | |
| | | Buffer.prototype.write = function write(string, offset, length, encoding) { |
| | | // Buffer#write(string) |
| | | if (offset === undefined) { |
| | | encoding = 'utf8'; |
| | | length = this.length; |
| | | offset = 0; // Buffer#write(string, encoding) |
| | | } else if (length === undefined && typeof offset === 'string') { |
| | | encoding = offset; |
| | | length = this.length; |
| | | offset = 0; // Buffer#write(string, offset[, length][, encoding]) |
| | | } else if (isFinite(offset)) { |
| | | offset = offset | 0; |
| | | |
| | | if (isFinite(length)) { |
| | | length = length | 0; |
| | | if (encoding === undefined) encoding = 'utf8'; |
| | | } else { |
| | | encoding = length; |
| | | length = undefined; |
| | | } // legacy write(string, encoding, offset, length) - remove in v0.13 |
| | | |
| | | } else { |
| | | throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); |
| | | } |
| | | |
| | | var remaining = this.length - offset; |
| | | if (length === undefined || length > remaining) length = remaining; |
| | | |
| | | if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { |
| | | throw new RangeError('Attempt to write outside buffer bounds'); |
| | | } |
| | | |
| | | if (!encoding) encoding = 'utf8'; |
| | | var loweredCase = false; |
| | | |
| | | for (;;) { |
| | | switch (encoding) { |
| | | case 'hex': |
| | | return hexWrite(this, string, offset, length); |
| | | |
| | | case 'utf8': |
| | | case 'utf-8': |
| | | return utf8Write(this, string, offset, length); |
| | | |
| | | case 'ascii': |
| | | return asciiWrite(this, string, offset, length); |
| | | |
| | | case 'latin1': |
| | | case 'binary': |
| | | return latin1Write(this, string, offset, length); |
| | | |
| | | case 'base64': |
| | | // Warning: maxLength not taken into account in base64Write |
| | | return base64Write(this, string, offset, length); |
| | | |
| | | case 'ucs2': |
| | | case 'ucs-2': |
| | | case 'utf16le': |
| | | case 'utf-16le': |
| | | return ucs2Write(this, string, offset, length); |
| | | |
| | | default: |
| | | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); |
| | | encoding = ('' + encoding).toLowerCase(); |
| | | loweredCase = true; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | Buffer.prototype.toJSON = function toJSON() { |
| | | return { |
| | | type: 'Buffer', |
| | | data: Array.prototype.slice.call(this._arr || this, 0) |
| | | }; |
| | | }; |
| | | |
| | | function base64Slice(buf, start, end) { |
| | | if (start === 0 && end === buf.length) { |
| | | return fromByteArray(buf); |
| | | } else { |
| | | return fromByteArray(buf.slice(start, end)); |
| | | } |
| | | } |
| | | |
| | | function utf8Slice(buf, start, end) { |
| | | end = Math.min(buf.length, end); |
| | | var res = []; |
| | | var i = start; |
| | | |
| | | while (i < end) { |
| | | var firstByte = buf[i]; |
| | | var codePoint = null; |
| | | var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; |
| | | |
| | | if (i + bytesPerSequence <= end) { |
| | | var secondByte, thirdByte, fourthByte, tempCodePoint; |
| | | |
| | | switch (bytesPerSequence) { |
| | | case 1: |
| | | if (firstByte < 0x80) { |
| | | codePoint = firstByte; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case 2: |
| | | secondByte = buf[i + 1]; |
| | | |
| | | if ((secondByte & 0xC0) === 0x80) { |
| | | tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; |
| | | |
| | | if (tempCodePoint > 0x7F) { |
| | | codePoint = tempCodePoint; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | |
| | | case 3: |
| | | secondByte = buf[i + 1]; |
| | | thirdByte = buf[i + 2]; |
| | | |
| | | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { |
| | | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; |
| | | |
| | | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { |
| | | codePoint = tempCodePoint; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | |
| | | case 4: |
| | | secondByte = buf[i + 1]; |
| | | thirdByte = buf[i + 2]; |
| | | fourthByte = buf[i + 3]; |
| | | |
| | | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { |
| | | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; |
| | | |
| | | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { |
| | | codePoint = tempCodePoint; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (codePoint === null) { |
| | | // we did not generate a valid codePoint so insert a |
| | | // replacement char (U+FFFD) and advance only 1 byte |
| | | codePoint = 0xFFFD; |
| | | bytesPerSequence = 1; |
| | | } else if (codePoint > 0xFFFF) { |
| | | // encode to utf16 (surrogate pair dance) |
| | | codePoint -= 0x10000; |
| | | res.push(codePoint >>> 10 & 0x3FF | 0xD800); |
| | | codePoint = 0xDC00 | codePoint & 0x3FF; |
| | | } |
| | | |
| | | res.push(codePoint); |
| | | i += bytesPerSequence; |
| | | } |
| | | |
| | | return decodeCodePointsArray(res); |
| | | } // Based on http://stackoverflow.com/a/22747272/680742, the browser with |
| | | // the lowest limit is Chrome, with 0x10000 args. |
| | | // We go 1 magnitude less, for safety |
| | | |
| | | |
| | | var MAX_ARGUMENTS_LENGTH = 0x1000; |
| | | |
| | | function decodeCodePointsArray(codePoints) { |
| | | var len = codePoints.length; |
| | | |
| | | if (len <= MAX_ARGUMENTS_LENGTH) { |
| | | return String.fromCharCode.apply(String, codePoints); // avoid extra slice() |
| | | } // Decode in chunks to avoid "call stack size exceeded". |
| | | |
| | | |
| | | var res = ''; |
| | | var i = 0; |
| | | |
| | | while (i < len) { |
| | | res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | function asciiSlice(buf, start, end) { |
| | | var ret = ''; |
| | | end = Math.min(buf.length, end); |
| | | |
| | | for (var i = start; i < end; ++i) { |
| | | ret += String.fromCharCode(buf[i] & 0x7F); |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | function latin1Slice(buf, start, end) { |
| | | var ret = ''; |
| | | end = Math.min(buf.length, end); |
| | | |
| | | for (var i = start; i < end; ++i) { |
| | | ret += String.fromCharCode(buf[i]); |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | function hexSlice(buf, start, end) { |
| | | var len = buf.length; |
| | | if (!start || start < 0) start = 0; |
| | | if (!end || end < 0 || end > len) end = len; |
| | | var out = ''; |
| | | |
| | | for (var i = start; i < end; ++i) { |
| | | out += toHex(buf[i]); |
| | | } |
| | | |
| | | return out; |
| | | } |
| | | |
| | | function utf16leSlice(buf, start, end) { |
| | | var bytes = buf.slice(start, end); |
| | | var res = ''; |
| | | |
| | | for (var i = 0; i < bytes.length; i += 2) { |
| | | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | Buffer.prototype.slice = function slice(start, end) { |
| | | var len = this.length; |
| | | start = ~~start; |
| | | end = end === undefined ? len : ~~end; |
| | | |
| | | if (start < 0) { |
| | | start += len; |
| | | if (start < 0) start = 0; |
| | | } else if (start > len) { |
| | | start = len; |
| | | } |
| | | |
| | | if (end < 0) { |
| | | end += len; |
| | | if (end < 0) end = 0; |
| | | } else if (end > len) { |
| | | end = len; |
| | | } |
| | | |
| | | if (end < start) end = start; |
| | | var newBuf; |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | newBuf = this.subarray(start, end); |
| | | newBuf.__proto__ = Buffer.prototype; |
| | | } else { |
| | | var sliceLen = end - start; |
| | | newBuf = new Buffer(sliceLen, undefined); |
| | | |
| | | for (var i = 0; i < sliceLen; ++i) { |
| | | newBuf[i] = this[i + start]; |
| | | } |
| | | } |
| | | |
| | | return newBuf; |
| | | }; |
| | | /* |
| | | * Need to make sure that buffer isn't trying to write out of bounds. |
| | | */ |
| | | |
| | | |
| | | function checkOffset(offset, ext, length) { |
| | | if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); |
| | | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); |
| | | } |
| | | |
| | | Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | if (!noAssert) checkOffset(offset, byteLength, this.length); |
| | | var val = this[offset]; |
| | | var mul = 1; |
| | | var i = 0; |
| | | |
| | | while (++i < byteLength && (mul *= 0x100)) { |
| | | val += this[offset + i] * mul; |
| | | } |
| | | |
| | | return val; |
| | | }; |
| | | |
| | | Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | |
| | | if (!noAssert) { |
| | | checkOffset(offset, byteLength, this.length); |
| | | } |
| | | |
| | | var val = this[offset + --byteLength]; |
| | | var mul = 1; |
| | | |
| | | while (byteLength > 0 && (mul *= 0x100)) { |
| | | val += this[offset + --byteLength] * mul; |
| | | } |
| | | |
| | | return val; |
| | | }; |
| | | |
| | | Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 1, this.length); |
| | | return this[offset]; |
| | | }; |
| | | |
| | | Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 2, this.length); |
| | | return this[offset] | this[offset + 1] << 8; |
| | | }; |
| | | |
| | | Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 2, this.length); |
| | | return this[offset] << 8 | this[offset + 1]; |
| | | }; |
| | | |
| | | Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; |
| | | }; |
| | | |
| | | Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); |
| | | }; |
| | | |
| | | Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | if (!noAssert) checkOffset(offset, byteLength, this.length); |
| | | var val = this[offset]; |
| | | var mul = 1; |
| | | var i = 0; |
| | | |
| | | while (++i < byteLength && (mul *= 0x100)) { |
| | | val += this[offset + i] * mul; |
| | | } |
| | | |
| | | mul *= 0x80; |
| | | if (val >= mul) val -= Math.pow(2, 8 * byteLength); |
| | | return val; |
| | | }; |
| | | |
| | | Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | if (!noAssert) checkOffset(offset, byteLength, this.length); |
| | | var i = byteLength; |
| | | var mul = 1; |
| | | var val = this[offset + --i]; |
| | | |
| | | while (i > 0 && (mul *= 0x100)) { |
| | | val += this[offset + --i] * mul; |
| | | } |
| | | |
| | | mul *= 0x80; |
| | | if (val >= mul) val -= Math.pow(2, 8 * byteLength); |
| | | return val; |
| | | }; |
| | | |
| | | Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 1, this.length); |
| | | if (!(this[offset] & 0x80)) return this[offset]; |
| | | return (0xff - this[offset] + 1) * -1; |
| | | }; |
| | | |
| | | Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 2, this.length); |
| | | var val = this[offset] | this[offset + 1] << 8; |
| | | return val & 0x8000 ? val | 0xFFFF0000 : val; |
| | | }; |
| | | |
| | | Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 2, this.length); |
| | | var val = this[offset + 1] | this[offset] << 8; |
| | | return val & 0x8000 ? val | 0xFFFF0000 : val; |
| | | }; |
| | | |
| | | Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; |
| | | }; |
| | | |
| | | Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; |
| | | }; |
| | | |
| | | Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return read(this, offset, true, 23, 4); |
| | | }; |
| | | |
| | | Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 4, this.length); |
| | | return read(this, offset, false, 23, 4); |
| | | }; |
| | | |
| | | Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 8, this.length); |
| | | return read(this, offset, true, 52, 8); |
| | | }; |
| | | |
| | | Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { |
| | | if (!noAssert) checkOffset(offset, 8, this.length); |
| | | return read(this, offset, false, 52, 8); |
| | | }; |
| | | |
| | | function checkInt(buf, value, offset, ext, max, min) { |
| | | if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); |
| | | if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); |
| | | if (offset + ext > buf.length) throw new RangeError('Index out of range'); |
| | | } |
| | | |
| | | Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | |
| | | if (!noAssert) { |
| | | var maxBytes = Math.pow(2, 8 * byteLength) - 1; |
| | | checkInt(this, value, offset, byteLength, maxBytes, 0); |
| | | } |
| | | |
| | | var mul = 1; |
| | | var i = 0; |
| | | this[offset] = value & 0xFF; |
| | | |
| | | while (++i < byteLength && (mul *= 0x100)) { |
| | | this[offset + i] = value / mul & 0xFF; |
| | | } |
| | | |
| | | return offset + byteLength; |
| | | }; |
| | | |
| | | Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | byteLength = byteLength | 0; |
| | | |
| | | if (!noAssert) { |
| | | var maxBytes = Math.pow(2, 8 * byteLength) - 1; |
| | | checkInt(this, value, offset, byteLength, maxBytes, 0); |
| | | } |
| | | |
| | | var i = byteLength - 1; |
| | | var mul = 1; |
| | | this[offset + i] = value & 0xFF; |
| | | |
| | | while (--i >= 0 && (mul *= 0x100)) { |
| | | this[offset + i] = value / mul & 0xFF; |
| | | } |
| | | |
| | | return offset + byteLength; |
| | | }; |
| | | |
| | | Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); |
| | | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); |
| | | this[offset] = value & 0xff; |
| | | return offset + 1; |
| | | }; |
| | | |
| | | function objectWriteUInt16(buf, value, offset, littleEndian) { |
| | | if (value < 0) value = 0xffff + value + 1; |
| | | |
| | | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { |
| | | buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8; |
| | | } |
| | | } |
| | | |
| | | Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value & 0xff; |
| | | this[offset + 1] = value >>> 8; |
| | | } else { |
| | | objectWriteUInt16(this, value, offset, true); |
| | | } |
| | | |
| | | return offset + 2; |
| | | }; |
| | | |
| | | Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value >>> 8; |
| | | this[offset + 1] = value & 0xff; |
| | | } else { |
| | | objectWriteUInt16(this, value, offset, false); |
| | | } |
| | | |
| | | return offset + 2; |
| | | }; |
| | | |
| | | function objectWriteUInt32(buf, value, offset, littleEndian) { |
| | | if (value < 0) value = 0xffffffff + value + 1; |
| | | |
| | | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { |
| | | buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff; |
| | | } |
| | | } |
| | | |
| | | Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset + 3] = value >>> 24; |
| | | this[offset + 2] = value >>> 16; |
| | | this[offset + 1] = value >>> 8; |
| | | this[offset] = value & 0xff; |
| | | } else { |
| | | objectWriteUInt32(this, value, offset, true); |
| | | } |
| | | |
| | | return offset + 4; |
| | | }; |
| | | |
| | | Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value >>> 24; |
| | | this[offset + 1] = value >>> 16; |
| | | this[offset + 2] = value >>> 8; |
| | | this[offset + 3] = value & 0xff; |
| | | } else { |
| | | objectWriteUInt32(this, value, offset, false); |
| | | } |
| | | |
| | | return offset + 4; |
| | | }; |
| | | |
| | | Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | |
| | | if (!noAssert) { |
| | | var limit = Math.pow(2, 8 * byteLength - 1); |
| | | checkInt(this, value, offset, byteLength, limit - 1, -limit); |
| | | } |
| | | |
| | | var i = 0; |
| | | var mul = 1; |
| | | var sub = 0; |
| | | this[offset] = value & 0xFF; |
| | | |
| | | while (++i < byteLength && (mul *= 0x100)) { |
| | | if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { |
| | | sub = 1; |
| | | } |
| | | |
| | | this[offset + i] = (value / mul >> 0) - sub & 0xFF; |
| | | } |
| | | |
| | | return offset + byteLength; |
| | | }; |
| | | |
| | | Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | |
| | | if (!noAssert) { |
| | | var limit = Math.pow(2, 8 * byteLength - 1); |
| | | checkInt(this, value, offset, byteLength, limit - 1, -limit); |
| | | } |
| | | |
| | | var i = byteLength - 1; |
| | | var mul = 1; |
| | | var sub = 0; |
| | | this[offset + i] = value & 0xFF; |
| | | |
| | | while (--i >= 0 && (mul *= 0x100)) { |
| | | if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { |
| | | sub = 1; |
| | | } |
| | | |
| | | this[offset + i] = (value / mul >> 0) - sub & 0xFF; |
| | | } |
| | | |
| | | return offset + byteLength; |
| | | }; |
| | | |
| | | Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); |
| | | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); |
| | | if (value < 0) value = 0xff + value + 1; |
| | | this[offset] = value & 0xff; |
| | | return offset + 1; |
| | | }; |
| | | |
| | | Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value & 0xff; |
| | | this[offset + 1] = value >>> 8; |
| | | } else { |
| | | objectWriteUInt16(this, value, offset, true); |
| | | } |
| | | |
| | | return offset + 2; |
| | | }; |
| | | |
| | | Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value >>> 8; |
| | | this[offset + 1] = value & 0xff; |
| | | } else { |
| | | objectWriteUInt16(this, value, offset, false); |
| | | } |
| | | |
| | | return offset + 2; |
| | | }; |
| | | |
| | | Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value & 0xff; |
| | | this[offset + 1] = value >>> 8; |
| | | this[offset + 2] = value >>> 16; |
| | | this[offset + 3] = value >>> 24; |
| | | } else { |
| | | objectWriteUInt32(this, value, offset, true); |
| | | } |
| | | |
| | | return offset + 4; |
| | | }; |
| | | |
| | | Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { |
| | | value = +value; |
| | | offset = offset | 0; |
| | | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); |
| | | if (value < 0) value = 0xffffffff + value + 1; |
| | | |
| | | if (Buffer.TYPED_ARRAY_SUPPORT) { |
| | | this[offset] = value >>> 24; |
| | | this[offset + 1] = value >>> 16; |
| | | this[offset + 2] = value >>> 8; |
| | | this[offset + 3] = value & 0xff; |
| | | } else { |
| | | objectWriteUInt32(this, value, offset, false); |
| | | } |
| | | |
| | | return offset + 4; |
| | | }; |
| | | |
| | | function checkIEEE754(buf, value, offset, ext, max, min) { |
| | | if (offset + ext > buf.length) throw new RangeError('Index out of range'); |
| | | if (offset < 0) throw new RangeError('Index out of range'); |
| | | } |
| | | |
| | | function writeFloat(buf, value, offset, littleEndian, noAssert) { |
| | | if (!noAssert) { |
| | | checkIEEE754(buf, value, offset, 4); |
| | | } |
| | | |
| | | write(buf, value, offset, littleEndian, 23, 4); |
| | | return offset + 4; |
| | | } |
| | | |
| | | Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { |
| | | return writeFloat(this, value, offset, true, noAssert); |
| | | }; |
| | | |
| | | Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { |
| | | return writeFloat(this, value, offset, false, noAssert); |
| | | }; |
| | | |
| | | function writeDouble(buf, value, offset, littleEndian, noAssert) { |
| | | if (!noAssert) { |
| | | checkIEEE754(buf, value, offset, 8); |
| | | } |
| | | |
| | | write(buf, value, offset, littleEndian, 52, 8); |
| | | return offset + 8; |
| | | } |
| | | |
| | | Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { |
| | | return writeDouble(this, value, offset, true, noAssert); |
| | | }; |
| | | |
| | | Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { |
| | | return writeDouble(this, value, offset, false, noAssert); |
| | | }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) |
| | | |
| | | |
| | | Buffer.prototype.copy = function copy(target, targetStart, start, end) { |
| | | if (!start) start = 0; |
| | | if (!end && end !== 0) end = this.length; |
| | | if (targetStart >= target.length) targetStart = target.length; |
| | | if (!targetStart) targetStart = 0; |
| | | if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done |
| | | |
| | | if (end === start) return 0; |
| | | if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions |
| | | |
| | | if (targetStart < 0) { |
| | | throw new RangeError('targetStart out of bounds'); |
| | | } |
| | | |
| | | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds'); |
| | | if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? |
| | | |
| | | if (end > this.length) end = this.length; |
| | | |
| | | if (target.length - targetStart < end - start) { |
| | | end = target.length - targetStart + start; |
| | | } |
| | | |
| | | var len = end - start; |
| | | var i; |
| | | |
| | | if (this === target && start < targetStart && targetStart < end) { |
| | | // descending copy from end |
| | | for (i = len - 1; i >= 0; --i) { |
| | | target[i + targetStart] = this[i + start]; |
| | | } |
| | | } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { |
| | | // ascending copy from start |
| | | for (i = 0; i < len; ++i) { |
| | | target[i + targetStart] = this[i + start]; |
| | | } |
| | | } else { |
| | | Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart); |
| | | } |
| | | |
| | | return len; |
| | | }; // Usage: |
| | | // buffer.fill(number[, offset[, end]]) |
| | | // buffer.fill(buffer[, offset[, end]]) |
| | | // buffer.fill(string[, offset[, end]][, encoding]) |
| | | |
| | | |
| | | Buffer.prototype.fill = function fill(val, start, end, encoding) { |
| | | // Handle string cases: |
| | | if (typeof val === 'string') { |
| | | if (typeof start === 'string') { |
| | | encoding = start; |
| | | start = 0; |
| | | end = this.length; |
| | | } else if (typeof end === 'string') { |
| | | encoding = end; |
| | | end = this.length; |
| | | } |
| | | |
| | | if (val.length === 1) { |
| | | var code = val.charCodeAt(0); |
| | | |
| | | if (code < 256) { |
| | | val = code; |
| | | } |
| | | } |
| | | |
| | | if (encoding !== undefined && typeof encoding !== 'string') { |
| | | throw new TypeError('encoding must be a string'); |
| | | } |
| | | |
| | | if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { |
| | | throw new TypeError('Unknown encoding: ' + encoding); |
| | | } |
| | | } else if (typeof val === 'number') { |
| | | val = val & 255; |
| | | } // Invalid ranges are not set to a default, so can range check early. |
| | | |
| | | |
| | | if (start < 0 || this.length < start || this.length < end) { |
| | | throw new RangeError('Out of range index'); |
| | | } |
| | | |
| | | if (end <= start) { |
| | | return this; |
| | | } |
| | | |
| | | start = start >>> 0; |
| | | end = end === undefined ? this.length : end >>> 0; |
| | | if (!val) val = 0; |
| | | var i; |
| | | |
| | | if (typeof val === 'number') { |
| | | for (i = start; i < end; ++i) { |
| | | this[i] = val; |
| | | } |
| | | } else { |
| | | var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString()); |
| | | var len = bytes.length; |
| | | |
| | | for (i = 0; i < end - start; ++i) { |
| | | this[i + start] = bytes[i % len]; |
| | | } |
| | | } |
| | | |
| | | return this; |
| | | }; // HELPER FUNCTIONS |
| | | // ================ |
| | | |
| | | |
| | | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; |
| | | |
| | | function base64clean(str) { |
| | | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| | | str = stringtrim(str).replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' |
| | | |
| | | if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| | | |
| | | while (str.length % 4 !== 0) { |
| | | str = str + '='; |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | |
| | | function stringtrim(str) { |
| | | if (str.trim) return str.trim(); |
| | | return str.replace(/^\s+|\s+$/g, ''); |
| | | } |
| | | |
| | | function toHex(n) { |
| | | if (n < 16) return '0' + n.toString(16); |
| | | return n.toString(16); |
| | | } |
| | | |
| | | function utf8ToBytes(string, units) { |
| | | units = units || Infinity; |
| | | var codePoint; |
| | | var length = string.length; |
| | | var leadSurrogate = null; |
| | | var bytes = []; |
| | | |
| | | for (var i = 0; i < length; ++i) { |
| | | codePoint = string.charCodeAt(i); // is surrogate component |
| | | |
| | | if (codePoint > 0xD7FF && codePoint < 0xE000) { |
| | | // last char was a lead |
| | | if (!leadSurrogate) { |
| | | // no lead yet |
| | | if (codePoint > 0xDBFF) { |
| | | // unexpected trail |
| | | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); |
| | | continue; |
| | | } else if (i + 1 === length) { |
| | | // unpaired lead |
| | | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); |
| | | continue; |
| | | } // valid lead |
| | | |
| | | |
| | | leadSurrogate = codePoint; |
| | | continue; |
| | | } // 2 leads in a row |
| | | |
| | | |
| | | if (codePoint < 0xDC00) { |
| | | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); |
| | | leadSurrogate = codePoint; |
| | | continue; |
| | | } // valid surrogate pair |
| | | |
| | | |
| | | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; |
| | | } else if (leadSurrogate) { |
| | | // valid bmp char, but last char was a lead |
| | | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); |
| | | } |
| | | |
| | | leadSurrogate = null; // encode utf8 |
| | | |
| | | if (codePoint < 0x80) { |
| | | if ((units -= 1) < 0) break; |
| | | bytes.push(codePoint); |
| | | } else if (codePoint < 0x800) { |
| | | if ((units -= 2) < 0) break; |
| | | bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); |
| | | } else if (codePoint < 0x10000) { |
| | | if ((units -= 3) < 0) break; |
| | | bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); |
| | | } else if (codePoint < 0x110000) { |
| | | if ((units -= 4) < 0) break; |
| | | bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); |
| | | } else { |
| | | throw new Error('Invalid code point'); |
| | | } |
| | | } |
| | | |
| | | return bytes; |
| | | } |
| | | |
| | | function asciiToBytes(str) { |
| | | var byteArray = []; |
| | | |
| | | for (var i = 0; i < str.length; ++i) { |
| | | // Node's code seems to be doing this and not & 0x7F.. |
| | | byteArray.push(str.charCodeAt(i) & 0xFF); |
| | | } |
| | | |
| | | return byteArray; |
| | | } |
| | | |
| | | function utf16leToBytes(str, units) { |
| | | var c, hi, lo; |
| | | var byteArray = []; |
| | | |
| | | for (var i = 0; i < str.length; ++i) { |
| | | if ((units -= 2) < 0) break; |
| | | c = str.charCodeAt(i); |
| | | hi = c >> 8; |
| | | lo = c % 256; |
| | | byteArray.push(lo); |
| | | byteArray.push(hi); |
| | | } |
| | | |
| | | return byteArray; |
| | | } |
| | | |
| | | function base64ToBytes(str) { |
| | | return toByteArray(base64clean(str)); |
| | | } |
| | | |
| | | function blitBuffer(src, dst, offset, length) { |
| | | for (var i = 0; i < length; ++i) { |
| | | if (i + offset >= dst.length || i >= src.length) break; |
| | | dst[i + offset] = src[i]; |
| | | } |
| | | |
| | | return i; |
| | | } |
| | | |
| | | function isnan(val) { |
| | | return val !== val; // eslint-disable-line no-self-compare |
| | | } // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence |
| | | // The _isBuffer check is for Safari 5-7 support, because it's missing |
| | | // Object.prototype.constructor. Remove this eventually |
| | | |
| | | |
| | | function isBuffer(obj) { |
| | | return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj)); |
| | | } |
| | | |
| | | function isFastBuffer(obj) { |
| | | return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj); |
| | | } // For Node v0.10 support. Remove this eventually. |
| | | |
| | | |
| | | function isSlowBuffer(obj) { |
| | | return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)); |
| | | } |
| | | |
| | | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; |
| | | |
| | | function unwrapExports (x) { |
| | | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; |
| | | } |
| | | |
| | | function createCommonjsModule(fn, module) { |
| | | return module = { exports: {} }, fn(module, module.exports), module.exports; |
| | | } |
| | | |
| | | function getCjsExportFromNamespace (n) { |
| | | return n && n['default'] || n; |
| | | } |
| | | |
| | | var fs = getCjsExportFromNamespace(_shim_fs$1); |
| | | |
| | | /** |
| | | * @class |
| | | */ |
| | | |
| | | |
| | | var LineByLine = |
| | | /*#__PURE__*/ |
| | | function () { |
| | | function LineByLine(file, options) { |
| | | _classCallCheck(this, LineByLine); |
| | | |
| | | options = options || {}; |
| | | if (!options.readChunk) options.readChunk = 1024; |
| | | |
| | | if (!options.newLineCharacter) { |
| | | options.newLineCharacter = 0x0a; //linux line ending |
| | | } else { |
| | | options.newLineCharacter = options.newLineCharacter.charCodeAt(0); |
| | | } |
| | | |
| | | if (typeof file === 'number') { |
| | | this.fd = file; |
| | | } else { |
| | | this.fd = fs.openSync(file, 'r'); |
| | | } |
| | | |
| | | this.options = options; |
| | | this.newLineCharacter = options.newLineCharacter; |
| | | this.reset(); |
| | | } |
| | | |
| | | _createClass(LineByLine, [{ |
| | | key: "_searchInBuffer", |
| | | value: function _searchInBuffer(buffer, hexNeedle) { |
| | | var found = -1; |
| | | |
| | | for (var i = 0; i <= buffer.length; i++) { |
| | | var b_byte = buffer[i]; |
| | | |
| | | if (b_byte === hexNeedle) { |
| | | found = i; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return found; |
| | | } |
| | | }, { |
| | | key: "reset", |
| | | value: function reset() { |
| | | this.eofReached = false; |
| | | this.linesCache = []; |
| | | this.fdPosition = 0; |
| | | } |
| | | }, { |
| | | key: "close", |
| | | value: function close() { |
| | | fs.closeSync(this.fd); |
| | | this.fd = null; |
| | | } |
| | | }, { |
| | | key: "_extractLines", |
| | | value: function _extractLines(buffer) { |
| | | var line; |
| | | var lines = []; |
| | | var bufferPosition = 0; |
| | | var lastNewLineBufferPosition = 0; |
| | | |
| | | while (true) { |
| | | var bufferPositionValue = buffer[bufferPosition++]; |
| | | |
| | | if (bufferPositionValue === this.newLineCharacter) { |
| | | line = buffer.slice(lastNewLineBufferPosition, bufferPosition); |
| | | lines.push(line); |
| | | lastNewLineBufferPosition = bufferPosition; |
| | | } else if (!bufferPositionValue) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | var leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition); |
| | | |
| | | if (leftovers.length) { |
| | | lines.push(leftovers); |
| | | } |
| | | |
| | | return lines; |
| | | } |
| | | }, { |
| | | key: "_readChunk", |
| | | value: function _readChunk(lineLeftovers) { |
| | | var totalBytesRead = 0; |
| | | var bytesRead; |
| | | var buffers = []; |
| | | |
| | | do { |
| | | var readBuffer = new Buffer(this.options.readChunk); |
| | | bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition); |
| | | totalBytesRead = totalBytesRead + bytesRead; |
| | | this.fdPosition = this.fdPosition + bytesRead; |
| | | buffers.push(readBuffer); |
| | | } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1); |
| | | |
| | | var bufferData = Buffer.concat(buffers); |
| | | |
| | | if (bytesRead < this.options.readChunk) { |
| | | this.eofReached = true; |
| | | bufferData = bufferData.slice(0, totalBytesRead); |
| | | } |
| | | |
| | | if (totalBytesRead) { |
| | | this.linesCache = this._extractLines(bufferData); |
| | | |
| | | if (lineLeftovers) { |
| | | this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]); |
| | | } |
| | | } |
| | | |
| | | return totalBytesRead; |
| | | } |
| | | }, { |
| | | key: "next", |
| | | value: function next() { |
| | | if (!this.fd) return false; |
| | | var line = false; |
| | | |
| | | if (this.eofReached && this.linesCache.length === 0) { |
| | | return line; |
| | | } |
| | | |
| | | var bytesRead; |
| | | |
| | | if (!this.linesCache.length) { |
| | | bytesRead = this._readChunk(); |
| | | } |
| | | |
| | | if (this.linesCache.length) { |
| | | line = this.linesCache.shift(); |
| | | var lastLineCharacter = line[line.length - 1]; |
| | | |
| | | if (lastLineCharacter !== 0x0a) { |
| | | bytesRead = this._readChunk(line); |
| | | |
| | | if (bytesRead) { |
| | | line = this.linesCache.shift(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (this.eofReached && this.linesCache.length === 0) { |
| | | this.close(); |
| | | } |
| | | |
| | | if (line && line[line.length - 1] === this.newLineCharacter) { |
| | | line = line.slice(0, line.length - 1); |
| | | } |
| | | |
| | | return line; |
| | | } |
| | | }]); |
| | | |
| | | return LineByLine; |
| | | }(); |
| | | |
| | | var readlines = LineByLine; |
| | | |
| | | var ConfigError = |
| | | /*#__PURE__*/ |
| | | function (_Error) { |
| | | _inherits(ConfigError, _Error); |
| | | |
| | | function ConfigError() { |
| | | _classCallCheck(this, ConfigError); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments)); |
| | | } |
| | | |
| | | return ConfigError; |
| | | }(_wrapNativeSuper(Error)); |
| | | |
| | | var DebugError = |
| | | /*#__PURE__*/ |
| | | function (_Error2) { |
| | | _inherits(DebugError, _Error2); |
| | | |
| | | function DebugError() { |
| | | _classCallCheck(this, DebugError); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments)); |
| | | } |
| | | |
| | | return DebugError; |
| | | }(_wrapNativeSuper(Error)); |
| | | |
| | | var UndefinedParserError = |
| | | /*#__PURE__*/ |
| | | function (_Error3) { |
| | | _inherits(UndefinedParserError, _Error3); |
| | | |
| | | function UndefinedParserError() { |
| | | _classCallCheck(this, UndefinedParserError); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments)); |
| | | } |
| | | |
| | | return UndefinedParserError; |
| | | }(_wrapNativeSuper(Error)); |
| | | |
| | | var errors = { |
| | | ConfigError: ConfigError, |
| | | DebugError: DebugError, |
| | | UndefinedParserError: UndefinedParserError |
| | | }; |
| | | |
| | | // based off https://github.com/defunctzombie/node-process/blob/master/browser.js |
| | | |
| | | function defaultSetTimout() { |
| | | throw new Error('setTimeout has not been defined'); |
| | | } |
| | | |
| | | function defaultClearTimeout() { |
| | | throw new Error('clearTimeout has not been defined'); |
| | | } |
| | | |
| | | var cachedSetTimeout = defaultSetTimout; |
| | | var cachedClearTimeout = defaultClearTimeout; |
| | | |
| | | if (typeof global$1.setTimeout === 'function') { |
| | | cachedSetTimeout = setTimeout; |
| | | } |
| | | |
| | | if (typeof global$1.clearTimeout === 'function') { |
| | | cachedClearTimeout = clearTimeout; |
| | | } |
| | | |
| | | function runTimeout(fun) { |
| | | if (cachedSetTimeout === setTimeout) { |
| | | //normal enviroments in sane situations |
| | | return setTimeout(fun, 0); |
| | | } // if setTimeout wasn't available but was latter defined |
| | | |
| | | |
| | | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
| | | cachedSetTimeout = setTimeout; |
| | | return setTimeout(fun, 0); |
| | | } |
| | | |
| | | try { |
| | | // when when somebody has screwed with setTimeout but no I.E. maddness |
| | | return cachedSetTimeout(fun, 0); |
| | | } catch (e) { |
| | | try { |
| | | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| | | return cachedSetTimeout.call(null, fun, 0); |
| | | } catch (e) { |
| | | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error |
| | | return cachedSetTimeout.call(this, fun, 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function runClearTimeout(marker) { |
| | | if (cachedClearTimeout === clearTimeout) { |
| | | //normal enviroments in sane situations |
| | | return clearTimeout(marker); |
| | | } // if clearTimeout wasn't available but was latter defined |
| | | |
| | | |
| | | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
| | | cachedClearTimeout = clearTimeout; |
| | | return clearTimeout(marker); |
| | | } |
| | | |
| | | try { |
| | | // when when somebody has screwed with setTimeout but no I.E. maddness |
| | | return cachedClearTimeout(marker); |
| | | } catch (e) { |
| | | try { |
| | | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| | | return cachedClearTimeout.call(null, marker); |
| | | } catch (e) { |
| | | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. |
| | | // Some versions of I.E. have different rules for clearTimeout vs setTimeout |
| | | return cachedClearTimeout.call(this, marker); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var queue = []; |
| | | var draining = false; |
| | | var currentQueue; |
| | | var queueIndex = -1; |
| | | |
| | | function cleanUpNextTick() { |
| | | if (!draining || !currentQueue) { |
| | | return; |
| | | } |
| | | |
| | | draining = false; |
| | | |
| | | if (currentQueue.length) { |
| | | queue = currentQueue.concat(queue); |
| | | } else { |
| | | queueIndex = -1; |
| | | } |
| | | |
| | | if (queue.length) { |
| | | drainQueue(); |
| | | } |
| | | } |
| | | |
| | | function drainQueue() { |
| | | if (draining) { |
| | | return; |
| | | } |
| | | |
| | | var timeout = runTimeout(cleanUpNextTick); |
| | | draining = true; |
| | | var len = queue.length; |
| | | |
| | | while (len) { |
| | | currentQueue = queue; |
| | | queue = []; |
| | | |
| | | while (++queueIndex < len) { |
| | | if (currentQueue) { |
| | | currentQueue[queueIndex].run(); |
| | | } |
| | | } |
| | | |
| | | queueIndex = -1; |
| | | len = queue.length; |
| | | } |
| | | |
| | | currentQueue = null; |
| | | draining = false; |
| | | runClearTimeout(timeout); |
| | | } |
| | | |
| | | function nextTick(fun) { |
| | | var args = new Array(arguments.length - 1); |
| | | |
| | | if (arguments.length > 1) { |
| | | for (var i = 1; i < arguments.length; i++) { |
| | | args[i - 1] = arguments[i]; |
| | | } |
| | | } |
| | | |
| | | queue.push(new Item(fun, args)); |
| | | |
| | | if (queue.length === 1 && !draining) { |
| | | runTimeout(drainQueue); |
| | | } |
| | | } // v8 likes predictible objects |
| | | |
| | | function Item(fun, array) { |
| | | this.fun = fun; |
| | | this.array = array; |
| | | } |
| | | |
| | | Item.prototype.run = function () { |
| | | this.fun.apply(null, this.array); |
| | | }; |
| | | |
| | | var title = 'browser'; |
| | | var platform = 'browser'; |
| | | var browser = true; |
| | | var env = {}; |
| | | var argv = []; |
| | | var version$1 = ''; // empty string to avoid regexp issues |
| | | |
| | | var versions = {}; |
| | | var release = {}; |
| | | var config = {}; |
| | | |
| | | function noop() {} |
| | | |
| | | var on = noop; |
| | | var addListener = noop; |
| | | var once = noop; |
| | | var off = noop; |
| | | var removeListener = noop; |
| | | var removeAllListeners = noop; |
| | | var emit = noop; |
| | | function binding(name) { |
| | | throw new Error('process.binding is not supported'); |
| | | } |
| | | function cwd() { |
| | | return '/'; |
| | | } |
| | | function chdir(dir) { |
| | | throw new Error('process.chdir is not supported'); |
| | | } |
| | | function umask() { |
| | | return 0; |
| | | } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js |
| | | |
| | | var performance = global$1.performance || {}; |
| | | |
| | | var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () { |
| | | return new Date().getTime(); |
| | | }; // generate timestamp or delta |
| | | // see http://nodejs.org/api/process.html#process_process_hrtime |
| | | |
| | | |
| | | function hrtime(previousTimestamp) { |
| | | var clocktime = performanceNow.call(performance) * 1e-3; |
| | | var seconds = Math.floor(clocktime); |
| | | var nanoseconds = Math.floor(clocktime % 1 * 1e9); |
| | | |
| | | if (previousTimestamp) { |
| | | seconds = seconds - previousTimestamp[0]; |
| | | nanoseconds = nanoseconds - previousTimestamp[1]; |
| | | |
| | | if (nanoseconds < 0) { |
| | | seconds--; |
| | | nanoseconds += 1e9; |
| | | } |
| | | } |
| | | |
| | | return [seconds, nanoseconds]; |
| | | } |
| | | var startTime = new Date(); |
| | | function uptime() { |
| | | var currentTime = new Date(); |
| | | var dif = currentTime - startTime; |
| | | return dif / 1000; |
| | | } |
| | | var process = { |
| | | nextTick: nextTick, |
| | | title: title, |
| | | browser: browser, |
| | | env: env, |
| | | argv: argv, |
| | | version: version$1, |
| | | versions: versions, |
| | | on: on, |
| | | addListener: addListener, |
| | | once: once, |
| | | off: off, |
| | | removeListener: removeListener, |
| | | removeAllListeners: removeAllListeners, |
| | | emit: emit, |
| | | binding: binding, |
| | | cwd: cwd, |
| | | chdir: chdir, |
| | | umask: umask, |
| | | hrtime: hrtime, |
| | | platform: platform, |
| | | release: release, |
| | | config: config, |
| | | uptime: uptime |
| | | }; |
| | | |
| | | var semver = createCommonjsModule(function (module, exports) { |
| | | exports = module.exports = SemVer; |
| | | var debug; |
| | | /* istanbul ignore next */ |
| | | |
| | | if (_typeof(process) === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) { |
| | | debug = function debug() { |
| | | var args = Array.prototype.slice.call(arguments, 0); |
| | | args.unshift('SEMVER'); |
| | | console.log.apply(console, args); |
| | | }; |
| | | } else { |
| | | debug = function debug() {}; |
| | | } // Note: this is the semver.org version of the spec that it implements |
| | | // Not necessarily the package version of this code. |
| | | |
| | | |
| | | exports.SEMVER_SPEC_VERSION = '2.0.0'; |
| | | var MAX_LENGTH = 256; |
| | | var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || |
| | | /* istanbul ignore next */ |
| | | 9007199254740991; // Max safe segment length for coercion. |
| | | |
| | | var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re |
| | | |
| | | var re = exports.re = []; |
| | | var src = exports.src = []; |
| | | var t = exports.tokens = {}; |
| | | var R = 0; |
| | | |
| | | function tok(n) { |
| | | t[n] = R++; |
| | | } // The following Regular Expressions can be used for tokenizing, |
| | | // validating, and parsing SemVer version strings. |
| | | // ## Numeric Identifier |
| | | // A single `0`, or a non-zero digit followed by zero or more digits. |
| | | |
| | | |
| | | tok('NUMERICIDENTIFIER'); |
| | | src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'; |
| | | tok('NUMERICIDENTIFIERLOOSE'); |
| | | src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier |
| | | // Zero or more digits, followed by a letter or hyphen, and then zero or |
| | | // more letters, digits, or hyphens. |
| | | |
| | | tok('NONNUMERICIDENTIFIER'); |
| | | src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version |
| | | // Three dot-separated numeric identifiers. |
| | | |
| | | tok('MAINVERSION'); |
| | | src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')'; |
| | | tok('MAINVERSIONLOOSE'); |
| | | src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier |
| | | // A numeric identifier, or a non-numeric identifier. |
| | | |
| | | tok('PRERELEASEIDENTIFIER'); |
| | | src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + '|' + src[t.NONNUMERICIDENTIFIER] + ')'; |
| | | tok('PRERELEASEIDENTIFIERLOOSE'); |
| | | src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + '|' + src[t.NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version |
| | | // Hyphen, followed by one or more dot-separated pre-release version |
| | | // identifiers. |
| | | |
| | | tok('PRERELEASE'); |
| | | src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'; |
| | | tok('PRERELEASELOOSE'); |
| | | src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier |
| | | // Any combination of digits, letters, or hyphens. |
| | | |
| | | tok('BUILDIDENTIFIER'); |
| | | src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata |
| | | // Plus sign, followed by one or more period-separated build metadata |
| | | // identifiers. |
| | | |
| | | tok('BUILD'); |
| | | src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'; // ## Full Version String |
| | | // A main version, followed optionally by a pre-release version and |
| | | // build metadata. |
| | | // Note that the only major, minor, patch, and pre-release sections of |
| | | // the version string are capturing groups. The build metadata is not a |
| | | // capturing group, because it should not ever be used in version |
| | | // comparison. |
| | | |
| | | tok('FULL'); |
| | | tok('FULLPLAIN'); |
| | | src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?'; |
| | | src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes. |
| | | // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty |
| | | // common in the npm registry. |
| | | |
| | | tok('LOOSEPLAIN'); |
| | | src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + '?' + src[t.BUILD] + '?'; |
| | | tok('LOOSE'); |
| | | src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'; |
| | | tok('GTLT'); |
| | | src[t.GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x". |
| | | // Note that "x.x" is a valid xRange identifer, meaning "any version" |
| | | // Only the first item is strictly required. |
| | | |
| | | tok('XRANGEIDENTIFIERLOOSE'); |
| | | src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'; |
| | | tok('XRANGEIDENTIFIER'); |
| | | src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'; |
| | | tok('XRANGEPLAIN'); |
| | | src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:' + src[t.PRERELEASE] + ')?' + src[t.BUILD] + '?' + ')?)?'; |
| | | tok('XRANGEPLAINLOOSE'); |
| | | src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[t.PRERELEASELOOSE] + ')?' + src[t.BUILD] + '?' + ')?)?'; |
| | | tok('XRANGE'); |
| | | src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'; |
| | | tok('XRANGELOOSE'); |
| | | src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'; // Coercion. |
| | | // Extract anything that could conceivably be a part of a valid semver |
| | | |
| | | tok('COERCE'); |
| | | src[t.COERCE] = '(^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; |
| | | tok('COERCERTL'); |
| | | re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g'); // Tilde ranges. |
| | | // Meaning is "reasonably at or greater than" |
| | | |
| | | tok('LONETILDE'); |
| | | src[t.LONETILDE] = '(?:~>?)'; |
| | | tok('TILDETRIM'); |
| | | src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'; |
| | | re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g'); |
| | | var tildeTrimReplace = '$1~'; |
| | | tok('TILDE'); |
| | | src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'; |
| | | tok('TILDELOOSE'); |
| | | src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'; // Caret ranges. |
| | | // Meaning is "at least and backwards compatible with" |
| | | |
| | | tok('LONECARET'); |
| | | src[t.LONECARET] = '(?:\\^)'; |
| | | tok('CARETTRIM'); |
| | | src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'; |
| | | re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g'); |
| | | var caretTrimReplace = '$1^'; |
| | | tok('CARET'); |
| | | src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'; |
| | | tok('CARETLOOSE'); |
| | | src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version" |
| | | |
| | | tok('COMPARATORLOOSE'); |
| | | src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'; |
| | | tok('COMPARATOR'); |
| | | src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing |
| | | // it modifies, so that `> 1.2.3` ==> `>1.2.3` |
| | | |
| | | tok('COMPARATORTRIM'); |
| | | src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'; // this one has to use the /g flag |
| | | |
| | | re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g'); |
| | | var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4` |
| | | // Note that these all use the loose form, because they'll be |
| | | // checked against either the strict or loose comparator form |
| | | // later. |
| | | |
| | | tok('HYPHENRANGE'); |
| | | src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAIN] + ')' + '\\s*$'; |
| | | tok('HYPHENRANGELOOSE'); |
| | | src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all. |
| | | |
| | | tok('STAR'); |
| | | src[t.STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects. |
| | | // All are flag-free, unless they were created above with a flag. |
| | | |
| | | for (var i = 0; i < R; i++) { |
| | | debug(i, src[i]); |
| | | |
| | | if (!re[i]) { |
| | | re[i] = new RegExp(src[i]); |
| | | } |
| | | } |
| | | |
| | | exports.parse = parse; |
| | | |
| | | function parse(version, options) { |
| | | if (!options || _typeof(options) !== 'object') { |
| | | options = { |
| | | loose: !!options, |
| | | includePrerelease: false |
| | | }; |
| | | } |
| | | |
| | | if (version instanceof SemVer) { |
| | | return version; |
| | | } |
| | | |
| | | if (typeof version !== 'string') { |
| | | return null; |
| | | } |
| | | |
| | | if (version.length > MAX_LENGTH) { |
| | | return null; |
| | | } |
| | | |
| | | var r = options.loose ? re[t.LOOSE] : re[t.FULL]; |
| | | |
| | | if (!r.test(version)) { |
| | | return null; |
| | | } |
| | | |
| | | try { |
| | | return new SemVer(version, options); |
| | | } catch (er) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | exports.valid = valid; |
| | | |
| | | function valid(version, options) { |
| | | var v = parse(version, options); |
| | | return v ? v.version : null; |
| | | } |
| | | |
| | | exports.clean = clean; |
| | | |
| | | function clean(version, options) { |
| | | var s = parse(version.trim().replace(/^[=v]+/, ''), options); |
| | | return s ? s.version : null; |
| | | } |
| | | |
| | | exports.SemVer = SemVer; |
| | | |
| | | function SemVer(version, options) { |
| | | if (!options || _typeof(options) !== 'object') { |
| | | options = { |
| | | loose: !!options, |
| | | includePrerelease: false |
| | | }; |
| | | } |
| | | |
| | | if (version instanceof SemVer) { |
| | | if (version.loose === options.loose) { |
| | | return version; |
| | | } else { |
| | | version = version.version; |
| | | } |
| | | } else if (typeof version !== 'string') { |
| | | throw new TypeError('Invalid Version: ' + version); |
| | | } |
| | | |
| | | if (version.length > MAX_LENGTH) { |
| | | throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters'); |
| | | } |
| | | |
| | | if (!(this instanceof SemVer)) { |
| | | return new SemVer(version, options); |
| | | } |
| | | |
| | | debug('SemVer', version, options); |
| | | this.options = options; |
| | | this.loose = !!options.loose; |
| | | var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); |
| | | |
| | | if (!m) { |
| | | throw new TypeError('Invalid Version: ' + version); |
| | | } |
| | | |
| | | this.raw = version; // these are actually numbers |
| | | |
| | | this.major = +m[1]; |
| | | this.minor = +m[2]; |
| | | this.patch = +m[3]; |
| | | |
| | | if (this.major > MAX_SAFE_INTEGER || this.major < 0) { |
| | | throw new TypeError('Invalid major version'); |
| | | } |
| | | |
| | | if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { |
| | | throw new TypeError('Invalid minor version'); |
| | | } |
| | | |
| | | if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { |
| | | throw new TypeError('Invalid patch version'); |
| | | } // numberify any prerelease numeric ids |
| | | |
| | | |
| | | if (!m[4]) { |
| | | this.prerelease = []; |
| | | } else { |
| | | this.prerelease = m[4].split('.').map(function (id) { |
| | | if (/^[0-9]+$/.test(id)) { |
| | | var num = +id; |
| | | |
| | | if (num >= 0 && num < MAX_SAFE_INTEGER) { |
| | | return num; |
| | | } |
| | | } |
| | | |
| | | return id; |
| | | }); |
| | | } |
| | | |
| | | this.build = m[5] ? m[5].split('.') : []; |
| | | this.format(); |
| | | } |
| | | |
| | | SemVer.prototype.format = function () { |
| | | this.version = this.major + '.' + this.minor + '.' + this.patch; |
| | | |
| | | if (this.prerelease.length) { |
| | | this.version += '-' + this.prerelease.join('.'); |
| | | } |
| | | |
| | | return this.version; |
| | | }; |
| | | |
| | | SemVer.prototype.toString = function () { |
| | | return this.version; |
| | | }; |
| | | |
| | | SemVer.prototype.compare = function (other) { |
| | | debug('SemVer.compare', this.version, this.options, other); |
| | | |
| | | if (!(other instanceof SemVer)) { |
| | | other = new SemVer(other, this.options); |
| | | } |
| | | |
| | | return this.compareMain(other) || this.comparePre(other); |
| | | }; |
| | | |
| | | SemVer.prototype.compareMain = function (other) { |
| | | if (!(other instanceof SemVer)) { |
| | | other = new SemVer(other, this.options); |
| | | } |
| | | |
| | | return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); |
| | | }; |
| | | |
| | | SemVer.prototype.comparePre = function (other) { |
| | | if (!(other instanceof SemVer)) { |
| | | other = new SemVer(other, this.options); |
| | | } // NOT having a prerelease is > having one |
| | | |
| | | |
| | | if (this.prerelease.length && !other.prerelease.length) { |
| | | return -1; |
| | | } else if (!this.prerelease.length && other.prerelease.length) { |
| | | return 1; |
| | | } else if (!this.prerelease.length && !other.prerelease.length) { |
| | | return 0; |
| | | } |
| | | |
| | | var i = 0; |
| | | |
| | | do { |
| | | var a = this.prerelease[i]; |
| | | var b = other.prerelease[i]; |
| | | debug('prerelease compare', i, a, b); |
| | | |
| | | if (a === undefined && b === undefined) { |
| | | return 0; |
| | | } else if (b === undefined) { |
| | | return 1; |
| | | } else if (a === undefined) { |
| | | return -1; |
| | | } else if (a === b) { |
| | | continue; |
| | | } else { |
| | | return compareIdentifiers(a, b); |
| | | } |
| | | } while (++i); |
| | | }; |
| | | |
| | | SemVer.prototype.compareBuild = function (other) { |
| | | if (!(other instanceof SemVer)) { |
| | | other = new SemVer(other, this.options); |
| | | } |
| | | |
| | | var i = 0; |
| | | |
| | | do { |
| | | var a = this.build[i]; |
| | | var b = other.build[i]; |
| | | debug('prerelease compare', i, a, b); |
| | | |
| | | if (a === undefined && b === undefined) { |
| | | return 0; |
| | | } else if (b === undefined) { |
| | | return 1; |
| | | } else if (a === undefined) { |
| | | return -1; |
| | | } else if (a === b) { |
| | | continue; |
| | | } else { |
| | | return compareIdentifiers(a, b); |
| | | } |
| | | } while (++i); |
| | | }; // preminor will bump the version up to the next minor release, and immediately |
| | | // down to pre-release. premajor and prepatch work the same way. |
| | | |
| | | |
| | | SemVer.prototype.inc = function (release, identifier) { |
| | | switch (release) { |
| | | case 'premajor': |
| | | this.prerelease.length = 0; |
| | | this.patch = 0; |
| | | this.minor = 0; |
| | | this.major++; |
| | | this.inc('pre', identifier); |
| | | break; |
| | | |
| | | case 'preminor': |
| | | this.prerelease.length = 0; |
| | | this.patch = 0; |
| | | this.minor++; |
| | | this.inc('pre', identifier); |
| | | break; |
| | | |
| | | case 'prepatch': |
| | | // If this is already a prerelease, it will bump to the next version |
| | | // drop any prereleases that might already exist, since they are not |
| | | // relevant at this point. |
| | | this.prerelease.length = 0; |
| | | this.inc('patch', identifier); |
| | | this.inc('pre', identifier); |
| | | break; |
| | | // If the input is a non-prerelease version, this acts the same as |
| | | // prepatch. |
| | | |
| | | case 'prerelease': |
| | | if (this.prerelease.length === 0) { |
| | | this.inc('patch', identifier); |
| | | } |
| | | |
| | | this.inc('pre', identifier); |
| | | break; |
| | | |
| | | case 'major': |
| | | // If this is a pre-major version, bump up to the same major version. |
| | | // Otherwise increment major. |
| | | // 1.0.0-5 bumps to 1.0.0 |
| | | // 1.1.0 bumps to 2.0.0 |
| | | if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { |
| | | this.major++; |
| | | } |
| | | |
| | | this.minor = 0; |
| | | this.patch = 0; |
| | | this.prerelease = []; |
| | | break; |
| | | |
| | | case 'minor': |
| | | // If this is a pre-minor version, bump up to the same minor version. |
| | | // Otherwise increment minor. |
| | | // 1.2.0-5 bumps to 1.2.0 |
| | | // 1.2.1 bumps to 1.3.0 |
| | | if (this.patch !== 0 || this.prerelease.length === 0) { |
| | | this.minor++; |
| | | } |
| | | |
| | | this.patch = 0; |
| | | this.prerelease = []; |
| | | break; |
| | | |
| | | case 'patch': |
| | | // If this is not a pre-release version, it will increment the patch. |
| | | // If it is a pre-release it will bump up to the same patch version. |
| | | // 1.2.0-5 patches to 1.2.0 |
| | | // 1.2.0 patches to 1.2.1 |
| | | if (this.prerelease.length === 0) { |
| | | this.patch++; |
| | | } |
| | | |
| | | this.prerelease = []; |
| | | break; |
| | | // This probably shouldn't be used publicly. |
| | | // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. |
| | | |
| | | case 'pre': |
| | | if (this.prerelease.length === 0) { |
| | | this.prerelease = [0]; |
| | | } else { |
| | | var i = this.prerelease.length; |
| | | |
| | | while (--i >= 0) { |
| | | if (typeof this.prerelease[i] === 'number') { |
| | | this.prerelease[i]++; |
| | | i = -2; |
| | | } |
| | | } |
| | | |
| | | if (i === -1) { |
| | | // didn't increment anything |
| | | this.prerelease.push(0); |
| | | } |
| | | } |
| | | |
| | | if (identifier) { |
| | | // 1.2.0-beta.1 bumps to 1.2.0-beta.2, |
| | | // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 |
| | | if (this.prerelease[0] === identifier) { |
| | | if (isNaN(this.prerelease[1])) { |
| | | this.prerelease = [identifier, 0]; |
| | | } |
| | | } else { |
| | | this.prerelease = [identifier, 0]; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | |
| | | default: |
| | | throw new Error('invalid increment argument: ' + release); |
| | | } |
| | | |
| | | this.format(); |
| | | this.raw = this.version; |
| | | return this; |
| | | }; |
| | | |
| | | exports.inc = inc; |
| | | |
| | | function inc(version, release, loose, identifier) { |
| | | if (typeof loose === 'string') { |
| | | identifier = loose; |
| | | loose = undefined; |
| | | } |
| | | |
| | | try { |
| | | return new SemVer(version, loose).inc(release, identifier).version; |
| | | } catch (er) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | exports.diff = diff; |
| | | |
| | | function diff(version1, version2) { |
| | | if (eq(version1, version2)) { |
| | | return null; |
| | | } else { |
| | | var v1 = parse(version1); |
| | | var v2 = parse(version2); |
| | | var prefix = ''; |
| | | |
| | | if (v1.prerelease.length || v2.prerelease.length) { |
| | | prefix = 'pre'; |
| | | var defaultResult = 'prerelease'; |
| | | } |
| | | |
| | | for (var key in v1) { |
| | | if (key === 'major' || key === 'minor' || key === 'patch') { |
| | | if (v1[key] !== v2[key]) { |
| | | return prefix + key; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return defaultResult; // may be undefined |
| | | } |
| | | } |
| | | |
| | | exports.compareIdentifiers = compareIdentifiers; |
| | | var numeric = /^[0-9]+$/; |
| | | |
| | | function compareIdentifiers(a, b) { |
| | | var anum = numeric.test(a); |
| | | var bnum = numeric.test(b); |
| | | |
| | | if (anum && bnum) { |
| | | a = +a; |
| | | b = +b; |
| | | } |
| | | |
| | | return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; |
| | | } |
| | | |
| | | exports.rcompareIdentifiers = rcompareIdentifiers; |
| | | |
| | | function rcompareIdentifiers(a, b) { |
| | | return compareIdentifiers(b, a); |
| | | } |
| | | |
| | | exports.major = major; |
| | | |
| | | function major(a, loose) { |
| | | return new SemVer(a, loose).major; |
| | | } |
| | | |
| | | exports.minor = minor; |
| | | |
| | | function minor(a, loose) { |
| | | return new SemVer(a, loose).minor; |
| | | } |
| | | |
| | | exports.patch = patch; |
| | | |
| | | function patch(a, loose) { |
| | | return new SemVer(a, loose).patch; |
| | | } |
| | | |
| | | exports.compare = compare; |
| | | |
| | | function compare(a, b, loose) { |
| | | return new SemVer(a, loose).compare(new SemVer(b, loose)); |
| | | } |
| | | |
| | | exports.compareLoose = compareLoose; |
| | | |
| | | function compareLoose(a, b) { |
| | | return compare(a, b, true); |
| | | } |
| | | |
| | | exports.compareBuild = compareBuild; |
| | | |
| | | function compareBuild(a, b, loose) { |
| | | var versionA = new SemVer(a, loose); |
| | | var versionB = new SemVer(b, loose); |
| | | return versionA.compare(versionB) || versionA.compareBuild(versionB); |
| | | } |
| | | |
| | | exports.rcompare = rcompare; |
| | | |
| | | function rcompare(a, b, loose) { |
| | | return compare(b, a, loose); |
| | | } |
| | | |
| | | exports.sort = sort; |
| | | |
| | | function sort(list, loose) { |
| | | return list.sort(function (a, b) { |
| | | return exports.compareBuild(a, b, loose); |
| | | }); |
| | | } |
| | | |
| | | exports.rsort = rsort; |
| | | |
| | | function rsort(list, loose) { |
| | | return list.sort(function (a, b) { |
| | | return exports.compareBuild(b, a, loose); |
| | | }); |
| | | } |
| | | |
| | | exports.gt = gt; |
| | | |
| | | function gt(a, b, loose) { |
| | | return compare(a, b, loose) > 0; |
| | | } |
| | | |
| | | exports.lt = lt; |
| | | |
| | | function lt(a, b, loose) { |
| | | return compare(a, b, loose) < 0; |
| | | } |
| | | |
| | | exports.eq = eq; |
| | | |
| | | function eq(a, b, loose) { |
| | | return compare(a, b, loose) === 0; |
| | | } |
| | | |
| | | exports.neq = neq; |
| | | |
| | | function neq(a, b, loose) { |
| | | return compare(a, b, loose) !== 0; |
| | | } |
| | | |
| | | exports.gte = gte; |
| | | |
| | | function gte(a, b, loose) { |
| | | return compare(a, b, loose) >= 0; |
| | | } |
| | | |
| | | exports.lte = lte; |
| | | |
| | | function lte(a, b, loose) { |
| | | return compare(a, b, loose) <= 0; |
| | | } |
| | | |
| | | exports.cmp = cmp; |
| | | |
| | | function cmp(a, op, b, loose) { |
| | | switch (op) { |
| | | case '===': |
| | | if (_typeof(a) === 'object') a = a.version; |
| | | if (_typeof(b) === 'object') b = b.version; |
| | | return a === b; |
| | | |
| | | case '!==': |
| | | if (_typeof(a) === 'object') a = a.version; |
| | | if (_typeof(b) === 'object') b = b.version; |
| | | return a !== b; |
| | | |
| | | case '': |
| | | case '=': |
| | | case '==': |
| | | return eq(a, b, loose); |
| | | |
| | | case '!=': |
| | | return neq(a, b, loose); |
| | | |
| | | case '>': |
| | | return gt(a, b, loose); |
| | | |
| | | case '>=': |
| | | return gte(a, b, loose); |
| | | |
| | | case '<': |
| | | return lt(a, b, loose); |
| | | |
| | | case '<=': |
| | | return lte(a, b, loose); |
| | | |
| | | default: |
| | | throw new TypeError('Invalid operator: ' + op); |
| | | } |
| | | } |
| | | |
| | | exports.Comparator = Comparator; |
| | | |
| | | function Comparator(comp, options) { |
| | | if (!options || _typeof(options) !== 'object') { |
| | | options = { |
| | | loose: !!options, |
| | | includePrerelease: false |
| | | }; |
| | | } |
| | | |
| | | if (comp instanceof Comparator) { |
| | | if (comp.loose === !!options.loose) { |
| | | return comp; |
| | | } else { |
| | | comp = comp.value; |
| | | } |
| | | } |
| | | |
| | | if (!(this instanceof Comparator)) { |
| | | return new Comparator(comp, options); |
| | | } |
| | | |
| | | debug('comparator', comp, options); |
| | | this.options = options; |
| | | this.loose = !!options.loose; |
| | | this.parse(comp); |
| | | |
| | | if (this.semver === ANY) { |
| | | this.value = ''; |
| | | } else { |
| | | this.value = this.operator + this.semver.version; |
| | | } |
| | | |
| | | debug('comp', this); |
| | | } |
| | | |
| | | var ANY = {}; |
| | | |
| | | Comparator.prototype.parse = function (comp) { |
| | | var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; |
| | | var m = comp.match(r); |
| | | |
| | | if (!m) { |
| | | throw new TypeError('Invalid comparator: ' + comp); |
| | | } |
| | | |
| | | this.operator = m[1] !== undefined ? m[1] : ''; |
| | | |
| | | if (this.operator === '=') { |
| | | this.operator = ''; |
| | | } // if it literally is just '>' or '' then allow anything. |
| | | |
| | | |
| | | if (!m[2]) { |
| | | this.semver = ANY; |
| | | } else { |
| | | this.semver = new SemVer(m[2], this.options.loose); |
| | | } |
| | | }; |
| | | |
| | | Comparator.prototype.toString = function () { |
| | | return this.value; |
| | | }; |
| | | |
| | | Comparator.prototype.test = function (version) { |
| | | debug('Comparator.test', version, this.options.loose); |
| | | |
| | | if (this.semver === ANY || version === ANY) { |
| | | return true; |
| | | } |
| | | |
| | | if (typeof version === 'string') { |
| | | try { |
| | | version = new SemVer(version, this.options); |
| | | } catch (er) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return cmp(version, this.operator, this.semver, this.options); |
| | | }; |
| | | |
| | | Comparator.prototype.intersects = function (comp, options) { |
| | | if (!(comp instanceof Comparator)) { |
| | | throw new TypeError('a Comparator is required'); |
| | | } |
| | | |
| | | if (!options || _typeof(options) !== 'object') { |
| | | options = { |
| | | loose: !!options, |
| | | includePrerelease: false |
| | | }; |
| | | } |
| | | |
| | | var rangeTmp; |
| | | |
| | | if (this.operator === '') { |
| | | if (this.value === '') { |
| | | return true; |
| | | } |
| | | |
| | | rangeTmp = new Range(comp.value, options); |
| | | return satisfies(this.value, rangeTmp, options); |
| | | } else if (comp.operator === '') { |
| | | if (comp.value === '') { |
| | | return true; |
| | | } |
| | | |
| | | rangeTmp = new Range(this.value, options); |
| | | return satisfies(comp.semver, rangeTmp, options); |
| | | } |
| | | |
| | | var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>'); |
| | | var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<'); |
| | | var sameSemVer = this.semver.version === comp.semver.version; |
| | | var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<='); |
| | | var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<'); |
| | | var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>'); |
| | | return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan; |
| | | }; |
| | | |
| | | exports.Range = Range; |
| | | |
| | | function Range(range, options) { |
| | | if (!options || _typeof(options) !== 'object') { |
| | | options = { |
| | | loose: !!options, |
| | | includePrerelease: false |
| | | }; |
| | | } |
| | | |
| | | if (range instanceof Range) { |
| | | if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { |
| | | return range; |
| | | } else { |
| | | return new Range(range.raw, options); |
| | | } |
| | | } |
| | | |
| | | if (range instanceof Comparator) { |
| | | return new Range(range.value, options); |
| | | } |
| | | |
| | | if (!(this instanceof Range)) { |
| | | return new Range(range, options); |
| | | } |
| | | |
| | | this.options = options; |
| | | this.loose = !!options.loose; |
| | | this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or || |
| | | |
| | | this.raw = range; |
| | | this.set = range.split(/\s*\|\|\s*/).map(function (range) { |
| | | return this.parseRange(range.trim()); |
| | | }, this).filter(function (c) { |
| | | // throw out any that are not relevant for whatever reason |
| | | return c.length; |
| | | }); |
| | | |
| | | if (!this.set.length) { |
| | | throw new TypeError('Invalid SemVer Range: ' + range); |
| | | } |
| | | |
| | | this.format(); |
| | | } |
| | | |
| | | Range.prototype.format = function () { |
| | | this.range = this.set.map(function (comps) { |
| | | return comps.join(' ').trim(); |
| | | }).join('||').trim(); |
| | | return this.range; |
| | | }; |
| | | |
| | | Range.prototype.toString = function () { |
| | | return this.range; |
| | | }; |
| | | |
| | | Range.prototype.parseRange = function (range) { |
| | | var loose = this.options.loose; |
| | | range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` |
| | | |
| | | var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; |
| | | range = range.replace(hr, hyphenReplace); |
| | | debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` |
| | | |
| | | range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace); |
| | | debug('comparator trim', range, re[t.COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3` |
| | | |
| | | range = range.replace(re[t.TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3` |
| | | |
| | | range = range.replace(re[t.CARETTRIM], caretTrimReplace); // normalize spaces |
| | | |
| | | range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and |
| | | // ready to be split into comparators. |
| | | |
| | | var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; |
| | | var set = range.split(' ').map(function (comp) { |
| | | return parseComparator(comp, this.options); |
| | | }, this).join(' ').split(/\s+/); |
| | | |
| | | if (this.options.loose) { |
| | | // in loose mode, throw out any that are not valid comparators |
| | | set = set.filter(function (comp) { |
| | | return !!comp.match(compRe); |
| | | }); |
| | | } |
| | | |
| | | set = set.map(function (comp) { |
| | | return new Comparator(comp, this.options); |
| | | }, this); |
| | | return set; |
| | | }; |
| | | |
| | | Range.prototype.intersects = function (range, options) { |
| | | if (!(range instanceof Range)) { |
| | | throw new TypeError('a Range is required'); |
| | | } |
| | | |
| | | return this.set.some(function (thisComparators) { |
| | | return isSatisfiable(thisComparators, options) && range.set.some(function (rangeComparators) { |
| | | return isSatisfiable(rangeComparators, options) && thisComparators.every(function (thisComparator) { |
| | | return rangeComparators.every(function (rangeComparator) { |
| | | return thisComparator.intersects(rangeComparator, options); |
| | | }); |
| | | }); |
| | | }); |
| | | }); |
| | | }; // take a set of comparators and determine whether there |
| | | // exists a version which can satisfy it |
| | | |
| | | |
| | | function isSatisfiable(comparators, options) { |
| | | var result = true; |
| | | var remainingComparators = comparators.slice(); |
| | | var testComparator = remainingComparators.pop(); |
| | | |
| | | while (result && remainingComparators.length) { |
| | | result = remainingComparators.every(function (otherComparator) { |
| | | return testComparator.intersects(otherComparator, options); |
| | | }); |
| | | testComparator = remainingComparators.pop(); |
| | | } |
| | | |
| | | return result; |
| | | } // Mostly just for testing and legacy API reasons |
| | | |
| | | |
| | | exports.toComparators = toComparators; |
| | | |
| | | function toComparators(range, options) { |
| | | return new Range(range, options).set.map(function (comp) { |
| | | return comp.map(function (c) { |
| | | return c.value; |
| | | }).join(' ').trim().split(' '); |
| | | }); |
| | | } // comprised of xranges, tildes, stars, and gtlt's at this point. |
| | | // already replaced the hyphen ranges |
| | | // turn into a set of JUST comparators. |
| | | |
| | | |
| | | function parseComparator(comp, options) { |
| | | debug('comp', comp, options); |
| | | comp = replaceCarets(comp, options); |
| | | debug('caret', comp); |
| | | comp = replaceTildes(comp, options); |
| | | debug('tildes', comp); |
| | | comp = replaceXRanges(comp, options); |
| | | debug('xrange', comp); |
| | | comp = replaceStars(comp, options); |
| | | debug('stars', comp); |
| | | return comp; |
| | | } |
| | | |
| | | function isX(id) { |
| | | return !id || id.toLowerCase() === 'x' || id === '*'; |
| | | } // ~, ~> --> * (any, kinda silly) |
| | | // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 |
| | | // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 |
| | | // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 |
| | | // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 |
| | | // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 |
| | | |
| | | |
| | | function replaceTildes(comp, options) { |
| | | return comp.trim().split(/\s+/).map(function (comp) { |
| | | return replaceTilde(comp, options); |
| | | }).join(' '); |
| | | } |
| | | |
| | | function replaceTilde(comp, options) { |
| | | var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]; |
| | | return comp.replace(r, function (_, M, m, p, pr) { |
| | | debug('tilde', comp, _, M, m, p, pr); |
| | | var ret; |
| | | |
| | | if (isX(M)) { |
| | | ret = ''; |
| | | } else if (isX(m)) { |
| | | ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'; |
| | | } else if (isX(p)) { |
| | | // ~1.2 == >=1.2.0 <1.3.0 |
| | | ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'; |
| | | } else if (pr) { |
| | | debug('replaceTilde pr', pr); |
| | | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0'; |
| | | } else { |
| | | // ~1.2.3 == >=1.2.3 <1.3.0 |
| | | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0'; |
| | | } |
| | | |
| | | debug('tilde return', ret); |
| | | return ret; |
| | | }); |
| | | } // ^ --> * (any, kinda silly) |
| | | // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 |
| | | // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 |
| | | // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 |
| | | // ^1.2.3 --> >=1.2.3 <2.0.0 |
| | | // ^1.2.0 --> >=1.2.0 <2.0.0 |
| | | |
| | | |
| | | function replaceCarets(comp, options) { |
| | | return comp.trim().split(/\s+/).map(function (comp) { |
| | | return replaceCaret(comp, options); |
| | | }).join(' '); |
| | | } |
| | | |
| | | function replaceCaret(comp, options) { |
| | | debug('caret', comp, options); |
| | | var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]; |
| | | return comp.replace(r, function (_, M, m, p, pr) { |
| | | debug('caret', comp, _, M, m, p, pr); |
| | | var ret; |
| | | |
| | | if (isX(M)) { |
| | | ret = ''; |
| | | } else if (isX(m)) { |
| | | ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'; |
| | | } else if (isX(p)) { |
| | | if (M === '0') { |
| | | ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'; |
| | | } else { |
| | | ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'; |
| | | } |
| | | } else if (pr) { |
| | | debug('replaceCaret pr', pr); |
| | | |
| | | if (M === '0') { |
| | | if (m === '0') { |
| | | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1); |
| | | } else { |
| | | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0'; |
| | | } |
| | | } else { |
| | | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0'; |
| | | } |
| | | } else { |
| | | debug('no pr'); |
| | | |
| | | if (M === '0') { |
| | | if (m === '0') { |
| | | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1); |
| | | } else { |
| | | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0'; |
| | | } |
| | | } else { |
| | | ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0'; |
| | | } |
| | | } |
| | | |
| | | debug('caret return', ret); |
| | | return ret; |
| | | }); |
| | | } |
| | | |
| | | function replaceXRanges(comp, options) { |
| | | debug('replaceXRanges', comp, options); |
| | | return comp.split(/\s+/).map(function (comp) { |
| | | return replaceXRange(comp, options); |
| | | }).join(' '); |
| | | } |
| | | |
| | | function replaceXRange(comp, options) { |
| | | comp = comp.trim(); |
| | | var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]; |
| | | return comp.replace(r, function (ret, gtlt, M, m, p, pr) { |
| | | debug('xRange', comp, ret, gtlt, M, m, p, pr); |
| | | var xM = isX(M); |
| | | var xm = xM || isX(m); |
| | | var xp = xm || isX(p); |
| | | var anyX = xp; |
| | | |
| | | if (gtlt === '=' && anyX) { |
| | | gtlt = ''; |
| | | } // if we're including prereleases in the match, then we need |
| | | // to fix this to -0, the lowest possible prerelease value |
| | | |
| | | |
| | | pr = options.includePrerelease ? '-0' : ''; |
| | | |
| | | if (xM) { |
| | | if (gtlt === '>' || gtlt === '<') { |
| | | // nothing is allowed |
| | | ret = '<0.0.0-0'; |
| | | } else { |
| | | // nothing is forbidden |
| | | ret = '*'; |
| | | } |
| | | } else if (gtlt && anyX) { |
| | | // we know patch is an x, because we have any x at all. |
| | | // replace X with 0 |
| | | if (xm) { |
| | | m = 0; |
| | | } |
| | | |
| | | p = 0; |
| | | |
| | | if (gtlt === '>') { |
| | | // >1 => >=2.0.0 |
| | | // >1.2 => >=1.3.0 |
| | | // >1.2.3 => >= 1.2.4 |
| | | gtlt = '>='; |
| | | |
| | | if (xm) { |
| | | M = +M + 1; |
| | | m = 0; |
| | | p = 0; |
| | | } else { |
| | | m = +m + 1; |
| | | p = 0; |
| | | } |
| | | } else if (gtlt === '<=') { |
| | | // <=0.7.x is actually <0.8.0, since any 0.7.x should |
| | | // pass. Similarly, <=7.x is actually <8.0.0, etc. |
| | | gtlt = '<'; |
| | | |
| | | if (xm) { |
| | | M = +M + 1; |
| | | } else { |
| | | m = +m + 1; |
| | | } |
| | | } |
| | | |
| | | ret = gtlt + M + '.' + m + '.' + p + pr; |
| | | } else if (xm) { |
| | | ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr; |
| | | } else if (xp) { |
| | | ret = '>=' + M + '.' + m + '.0' + pr + ' <' + M + '.' + (+m + 1) + '.0' + pr; |
| | | } |
| | | |
| | | debug('xRange return', ret); |
| | | return ret; |
| | | }); |
| | | } // Because * is AND-ed with everything else in the comparator, |
| | | // and '' means "any version", just remove the *s entirely. |
| | | |
| | | |
| | | function replaceStars(comp, options) { |
| | | debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets! |
| | | |
| | | return comp.trim().replace(re[t.STAR], ''); |
| | | } // This function is passed to string.replace(re[t.HYPHENRANGE]) |
| | | // M, m, patch, prerelease, build |
| | | // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 |
| | | // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do |
| | | // 1.2 - 3.4 => >=1.2.0 <3.5.0 |
| | | |
| | | |
| | | function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) { |
| | | if (isX(fM)) { |
| | | from = ''; |
| | | } else if (isX(fm)) { |
| | | from = '>=' + fM + '.0.0'; |
| | | } else if (isX(fp)) { |
| | | from = '>=' + fM + '.' + fm + '.0'; |
| | | } else { |
| | | from = '>=' + from; |
| | | } |
| | | |
| | | if (isX(tM)) { |
| | | to = ''; |
| | | } else if (isX(tm)) { |
| | | to = '<' + (+tM + 1) + '.0.0'; |
| | | } else if (isX(tp)) { |
| | | to = '<' + tM + '.' + (+tm + 1) + '.0'; |
| | | } else if (tpr) { |
| | | to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr; |
| | | } else { |
| | | to = '<=' + to; |
| | | } |
| | | |
| | | return (from + ' ' + to).trim(); |
| | | } // if ANY of the sets match ALL of its comparators, then pass |
| | | |
| | | |
| | | Range.prototype.test = function (version) { |
| | | if (!version) { |
| | | return false; |
| | | } |
| | | |
| | | if (typeof version === 'string') { |
| | | try { |
| | | version = new SemVer(version, this.options); |
| | | } catch (er) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | for (var i = 0; i < this.set.length; i++) { |
| | | if (testSet(this.set[i], version, this.options)) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | function testSet(set, version, options) { |
| | | for (var i = 0; i < set.length; i++) { |
| | | if (!set[i].test(version)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (version.prerelease.length && !options.includePrerelease) { |
| | | // Find the set of versions that are allowed to have prereleases |
| | | // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 |
| | | // That should allow `1.2.3-pr.2` to pass. |
| | | // However, `1.2.4-alpha.notready` should NOT be allowed, |
| | | // even though it's within the range set by the comparators. |
| | | for (i = 0; i < set.length; i++) { |
| | | debug(set[i].semver); |
| | | |
| | | if (set[i].semver === ANY) { |
| | | continue; |
| | | } |
| | | |
| | | if (set[i].semver.prerelease.length > 0) { |
| | | var allowed = set[i].semver; |
| | | |
| | | if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) { |
| | | return true; |
| | | } |
| | | } |
| | | } // Version has a -pre, but it's not one of the ones we like. |
| | | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | exports.satisfies = satisfies; |
| | | |
| | | function satisfies(version, range, options) { |
| | | try { |
| | | range = new Range(range, options); |
| | | } catch (er) { |
| | | return false; |
| | | } |
| | | |
| | | return range.test(version); |
| | | } |
| | | |
| | | exports.maxSatisfying = maxSatisfying; |
| | | |
| | | function maxSatisfying(versions, range, options) { |
| | | var max = null; |
| | | var maxSV = null; |
| | | |
| | | try { |
| | | var rangeObj = new Range(range, options); |
| | | } catch (er) { |
| | | return null; |
| | | } |
| | | |
| | | versions.forEach(function (v) { |
| | | if (rangeObj.test(v)) { |
| | | // satisfies(v, range, options) |
| | | if (!max || maxSV.compare(v) === -1) { |
| | | // compare(max, v, true) |
| | | max = v; |
| | | maxSV = new SemVer(max, options); |
| | | } |
| | | } |
| | | }); |
| | | return max; |
| | | } |
| | | |
| | | exports.minSatisfying = minSatisfying; |
| | | |
| | | function minSatisfying(versions, range, options) { |
| | | var min = null; |
| | | var minSV = null; |
| | | |
| | | try { |
| | | var rangeObj = new Range(range, options); |
| | | } catch (er) { |
| | | return null; |
| | | } |
| | | |
| | | versions.forEach(function (v) { |
| | | if (rangeObj.test(v)) { |
| | | // satisfies(v, range, options) |
| | | if (!min || minSV.compare(v) === 1) { |
| | | // compare(min, v, true) |
| | | min = v; |
| | | minSV = new SemVer(min, options); |
| | | } |
| | | } |
| | | }); |
| | | return min; |
| | | } |
| | | |
| | | exports.minVersion = minVersion; |
| | | |
| | | function minVersion(range, loose) { |
| | | range = new Range(range, loose); |
| | | var minver = new SemVer('0.0.0'); |
| | | |
| | | if (range.test(minver)) { |
| | | return minver; |
| | | } |
| | | |
| | | minver = new SemVer('0.0.0-0'); |
| | | |
| | | if (range.test(minver)) { |
| | | return minver; |
| | | } |
| | | |
| | | minver = null; |
| | | |
| | | for (var i = 0; i < range.set.length; ++i) { |
| | | var comparators = range.set[i]; |
| | | comparators.forEach(function (comparator) { |
| | | // Clone to avoid manipulating the comparator's semver object. |
| | | var compver = new SemVer(comparator.semver.version); |
| | | |
| | | switch (comparator.operator) { |
| | | case '>': |
| | | if (compver.prerelease.length === 0) { |
| | | compver.patch++; |
| | | } else { |
| | | compver.prerelease.push(0); |
| | | } |
| | | |
| | | compver.raw = compver.format(); |
| | | |
| | | /* fallthrough */ |
| | | |
| | | case '': |
| | | case '>=': |
| | | if (!minver || gt(minver, compver)) { |
| | | minver = compver; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case '<': |
| | | case '<=': |
| | | /* Ignore maximum versions */ |
| | | break; |
| | | |
| | | /* istanbul ignore next */ |
| | | |
| | | default: |
| | | throw new Error('Unexpected operation: ' + comparator.operator); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (minver && range.test(minver)) { |
| | | return minver; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | exports.validRange = validRange; |
| | | |
| | | function validRange(range, options) { |
| | | try { |
| | | // Return '*' instead of '' so that truthiness works. |
| | | // This will throw if it's invalid anyway |
| | | return new Range(range, options).range || '*'; |
| | | } catch (er) { |
| | | return null; |
| | | } |
| | | } // Determine if version is less than all the versions possible in the range |
| | | |
| | | |
| | | exports.ltr = ltr; |
| | | |
| | | function ltr(version, range, options) { |
| | | return outside(version, range, '<', options); |
| | | } // Determine if version is greater than all the versions possible in the range. |
| | | |
| | | |
| | | exports.gtr = gtr; |
| | | |
| | | function gtr(version, range, options) { |
| | | return outside(version, range, '>', options); |
| | | } |
| | | |
| | | exports.outside = outside; |
| | | |
| | | function outside(version, range, hilo, options) { |
| | | version = new SemVer(version, options); |
| | | range = new Range(range, options); |
| | | var gtfn, ltefn, ltfn, comp, ecomp; |
| | | |
| | | switch (hilo) { |
| | | case '>': |
| | | gtfn = gt; |
| | | ltefn = lte; |
| | | ltfn = lt; |
| | | comp = '>'; |
| | | ecomp = '>='; |
| | | break; |
| | | |
| | | case '<': |
| | | gtfn = lt; |
| | | ltefn = gte; |
| | | ltfn = gt; |
| | | comp = '<'; |
| | | ecomp = '<='; |
| | | break; |
| | | |
| | | default: |
| | | throw new TypeError('Must provide a hilo val of "<" or ">"'); |
| | | } // If it satisifes the range it is not outside |
| | | |
| | | |
| | | if (satisfies(version, range, options)) { |
| | | return false; |
| | | } // From now on, variable terms are as if we're in "gtr" mode. |
| | | // but note that everything is flipped for the "ltr" function. |
| | | |
| | | |
| | | for (var i = 0; i < range.set.length; ++i) { |
| | | var comparators = range.set[i]; |
| | | var high = null; |
| | | var low = null; |
| | | comparators.forEach(function (comparator) { |
| | | if (comparator.semver === ANY) { |
| | | comparator = new Comparator('>=0.0.0'); |
| | | } |
| | | |
| | | high = high || comparator; |
| | | low = low || comparator; |
| | | |
| | | if (gtfn(comparator.semver, high.semver, options)) { |
| | | high = comparator; |
| | | } else if (ltfn(comparator.semver, low.semver, options)) { |
| | | low = comparator; |
| | | } |
| | | }); // If the edge version comparator has a operator then our version |
| | | // isn't outside it |
| | | |
| | | if (high.operator === comp || high.operator === ecomp) { |
| | | return false; |
| | | } // If the lowest version comparator has an operator and our version |
| | | // is less than it then it isn't higher than the range |
| | | |
| | | |
| | | if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) { |
| | | return false; |
| | | } else if (low.operator === ecomp && ltfn(version, low.semver)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | exports.prerelease = prerelease; |
| | | |
| | | function prerelease(version, options) { |
| | | var parsed = parse(version, options); |
| | | return parsed && parsed.prerelease.length ? parsed.prerelease : null; |
| | | } |
| | | |
| | | exports.intersects = intersects; |
| | | |
| | | function intersects(r1, r2, options) { |
| | | r1 = new Range(r1, options); |
| | | r2 = new Range(r2, options); |
| | | return r1.intersects(r2); |
| | | } |
| | | |
| | | exports.coerce = coerce; |
| | | |
| | | function coerce(version, options) { |
| | | if (version instanceof SemVer) { |
| | | return version; |
| | | } |
| | | |
| | | if (typeof version === 'number') { |
| | | version = String(version); |
| | | } |
| | | |
| | | if (typeof version !== 'string') { |
| | | return null; |
| | | } |
| | | |
| | | options = options || {}; |
| | | var match = null; |
| | | |
| | | if (!options.rtl) { |
| | | match = version.match(re[t.COERCE]); |
| | | } else { |
| | | // Find the right-most coercible string that does not share |
| | | // a terminus with a more left-ward coercible string. |
| | | // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' |
| | | // |
| | | // Walk through the string checking with a /g regexp |
| | | // Manually set the index so as to pick up overlapping matches. |
| | | // Stop when we get a match that ends at the string end, since no |
| | | // coercible string can be more right-ward without the same terminus. |
| | | var next; |
| | | |
| | | while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) { |
| | | if (!match || next.index + next[0].length !== match.index + match[0].length) { |
| | | match = next; |
| | | } |
| | | |
| | | re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length; |
| | | } // leave it in a clean state |
| | | |
| | | |
| | | re[t.COERCERTL].lastIndex = -1; |
| | | } |
| | | |
| | | if (match === null) { |
| | | return null; |
| | | } |
| | | |
| | | return parse(match[2] + '.' + (match[3] || '0') + '.' + (match[4] || '0'), options); |
| | | } |
| | | }); |
| | | var semver_1 = semver.SEMVER_SPEC_VERSION; |
| | | var semver_2 = semver.re; |
| | | var semver_3 = semver.src; |
| | | var semver_4 = semver.tokens; |
| | | var semver_5 = semver.parse; |
| | | var semver_6 = semver.valid; |
| | | var semver_7 = semver.clean; |
| | | var semver_8 = semver.SemVer; |
| | | var semver_9 = semver.inc; |
| | | var semver_10 = semver.diff; |
| | | var semver_11 = semver.compareIdentifiers; |
| | | var semver_12 = semver.rcompareIdentifiers; |
| | | var semver_13 = semver.major; |
| | | var semver_14 = semver.minor; |
| | | var semver_15 = semver.patch; |
| | | var semver_16 = semver.compare; |
| | | var semver_17 = semver.compareLoose; |
| | | var semver_18 = semver.compareBuild; |
| | | var semver_19 = semver.rcompare; |
| | | var semver_20 = semver.sort; |
| | | var semver_21 = semver.rsort; |
| | | var semver_22 = semver.gt; |
| | | var semver_23 = semver.lt; |
| | | var semver_24 = semver.eq; |
| | | var semver_25 = semver.neq; |
| | | var semver_26 = semver.gte; |
| | | var semver_27 = semver.lte; |
| | | var semver_28 = semver.cmp; |
| | | var semver_29 = semver.Comparator; |
| | | var semver_30 = semver.Range; |
| | | var semver_31 = semver.toComparators; |
| | | var semver_32 = semver.satisfies; |
| | | var semver_33 = semver.maxSatisfying; |
| | | var semver_34 = semver.minSatisfying; |
| | | var semver_35 = semver.minVersion; |
| | | var semver_36 = semver.validRange; |
| | | var semver_37 = semver.ltr; |
| | | var semver_38 = semver.gtr; |
| | | var semver_39 = semver.outside; |
| | | var semver_40 = semver.prerelease; |
| | | var semver_41 = semver.intersects; |
| | | var semver_42 = semver.coerce; |
| | | |
| | | var arrayify = function arrayify(object, keyName) { |
| | | return Object.keys(object).reduce(function (array, key) { |
| | | return array.concat(Object.assign(_defineProperty({}, keyName, key), object[key])); |
| | | }, []); |
| | | }; |
| | | |
| | | var dedent_1 = createCommonjsModule(function (module) { |
| | | |
| | | function dedent(strings) { |
| | | var raw = void 0; |
| | | |
| | | if (typeof strings === "string") { |
| | | // dedent can be used as a plain function |
| | | raw = [strings]; |
| | | } else { |
| | | raw = strings.raw; |
| | | } // first, perform interpolation |
| | | |
| | | |
| | | var result = ""; |
| | | |
| | | for (var i = 0; i < raw.length; i++) { |
| | | result += raw[i]. // join lines when there is a suppressed newline |
| | | replace(/\\\n[ \t]*/g, ""). // handle escaped backticks |
| | | replace(/\\`/g, "`"); |
| | | |
| | | if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) { |
| | | result += arguments.length <= i + 1 ? undefined : arguments[i + 1]; |
| | | } |
| | | } // now strip indentation |
| | | |
| | | |
| | | var lines = result.split("\n"); |
| | | var mindent = null; |
| | | lines.forEach(function (l) { |
| | | var m = l.match(/^(\s+)\S+/); |
| | | |
| | | if (m) { |
| | | var indent = m[1].length; |
| | | |
| | | if (!mindent) { |
| | | // this is the first indented line |
| | | mindent = indent; |
| | | } else { |
| | | mindent = Math.min(mindent, indent); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | if (mindent !== null) { |
| | | result = lines.map(function (l) { |
| | | return l[0] === " " ? l.slice(mindent) : l; |
| | | }).join("\n"); |
| | | } // dedent eats leading and trailing whitespace too |
| | | |
| | | |
| | | result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too |
| | | |
| | | return result.replace(/\\n/g, "\n"); |
| | | } |
| | | |
| | | { |
| | | module.exports = dedent; |
| | | } |
| | | }); |
| | | |
| | | function _templateObject6() { |
| | | var data = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]); |
| | | |
| | | _templateObject6 = function _templateObject6() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _templateObject5() { |
| | | var data = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]); |
| | | |
| | | _templateObject5 = function _templateObject5() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _templateObject4() { |
| | | var data = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]); |
| | | |
| | | _templateObject4 = function _templateObject4() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _templateObject3() { |
| | | var data = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]); |
| | | |
| | | _templateObject3 = function _templateObject3() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _templateObject2() { |
| | | var data = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "]); |
| | | |
| | | _templateObject2 = function _templateObject2() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _templateObject() { |
| | | var data = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]); |
| | | |
| | | _templateObject = function _templateObject() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | var CATEGORY_CONFIG = "Config"; |
| | | var CATEGORY_EDITOR = "Editor"; |
| | | var CATEGORY_FORMAT = "Format"; |
| | | var CATEGORY_OTHER = "Other"; |
| | | var CATEGORY_OUTPUT = "Output"; |
| | | var CATEGORY_GLOBAL = "Global"; |
| | | var CATEGORY_SPECIAL = "Special"; |
| | | /** |
| | | * @typedef {Object} OptionInfo |
| | | * @property {string} [since] - available since version |
| | | * @property {string} category |
| | | * @property {'int' | 'boolean' | 'choice' | 'path'} type |
| | | * @property {boolean} [array] - indicate it's an array of the specified type |
| | | * @property {OptionValueInfo} [default] |
| | | * @property {OptionRangeInfo} [range] - for type int |
| | | * @property {string} description |
| | | * @property {string} [deprecated] - deprecated since version |
| | | * @property {OptionRedirectInfo} [redirect] - redirect deprecated option |
| | | * @property {(value: any) => boolean} [exception] |
| | | * @property {OptionChoiceInfo[]} [choices] - for type choice |
| | | * @property {string} [cliName] |
| | | * @property {string} [cliCategory] |
| | | * @property {string} [cliDescription] |
| | | * |
| | | * @typedef {number | boolean | string} OptionValue |
| | | * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo |
| | | * |
| | | * @typedef {Object} OptionRedirectInfo |
| | | * @property {string} option |
| | | * @property {OptionValue} value |
| | | * |
| | | * @typedef {Object} OptionRangeInfo |
| | | * @property {number} start - recommended range start |
| | | * @property {number} end - recommended range end |
| | | * @property {number} step - recommended range step |
| | | * |
| | | * @typedef {Object} OptionChoiceInfo |
| | | * @property {boolean | string} value - boolean for the option that is originally boolean type |
| | | * @property {string} description |
| | | * @property {string} [since] - undefined if available since the first version of the option |
| | | * @property {string} [deprecated] - deprecated since version |
| | | * @property {OptionValueInfo} [redirect] - redirect deprecated value |
| | | */ |
| | | |
| | | /** @type {{ [name: string]: OptionInfo }} */ |
| | | |
| | | var options = { |
| | | cursorOffset: { |
| | | since: "1.4.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "int", |
| | | default: -1, |
| | | range: { |
| | | start: -1, |
| | | end: Infinity, |
| | | step: 1 |
| | | }, |
| | | description: dedent_1(_templateObject()), |
| | | cliCategory: CATEGORY_EDITOR |
| | | }, |
| | | endOfLine: { |
| | | since: "1.15.0", |
| | | category: CATEGORY_GLOBAL, |
| | | type: "choice", |
| | | default: "auto", |
| | | description: "Which end of line characters to apply.", |
| | | choices: [{ |
| | | value: "auto", |
| | | description: dedent_1(_templateObject2()) |
| | | }, { |
| | | value: "lf", |
| | | description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos" |
| | | }, { |
| | | value: "crlf", |
| | | description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows" |
| | | }, { |
| | | value: "cr", |
| | | description: "Carriage Return character only (\\r), used very rarely" |
| | | }] |
| | | }, |
| | | filepath: { |
| | | since: "1.4.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "path", |
| | | description: "Specify the input filepath. This will be used to do parser inference.", |
| | | cliName: "stdin-filepath", |
| | | cliCategory: CATEGORY_OTHER, |
| | | cliDescription: "Path to the file to pretend that stdin comes from." |
| | | }, |
| | | insertPragma: { |
| | | since: "1.8.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Insert @format pragma into file's first docblock comment.", |
| | | cliCategory: CATEGORY_OTHER |
| | | }, |
| | | parser: { |
| | | since: "0.0.10", |
| | | category: CATEGORY_GLOBAL, |
| | | type: "choice", |
| | | default: [{ |
| | | since: "0.0.10", |
| | | value: "babylon" |
| | | }, { |
| | | since: "1.13.0", |
| | | value: undefined |
| | | }], |
| | | description: "Which parser to use.", |
| | | exception: function exception(value) { |
| | | return typeof value === "string" || typeof value === "function"; |
| | | }, |
| | | choices: [{ |
| | | value: "flow", |
| | | description: "Flow" |
| | | }, { |
| | | value: "babylon", |
| | | description: "JavaScript", |
| | | deprecated: "1.16.0", |
| | | redirect: "babel" |
| | | }, { |
| | | value: "babel", |
| | | since: "1.16.0", |
| | | description: "JavaScript" |
| | | }, { |
| | | value: "babel-flow", |
| | | since: "1.16.0", |
| | | description: "Flow" |
| | | }, { |
| | | value: "typescript", |
| | | since: "1.4.0", |
| | | description: "TypeScript" |
| | | }, { |
| | | value: "css", |
| | | since: "1.7.1", |
| | | description: "CSS" |
| | | }, { |
| | | value: "postcss", |
| | | since: "1.4.0", |
| | | description: "CSS/Less/SCSS", |
| | | deprecated: "1.7.1", |
| | | redirect: "css" |
| | | }, { |
| | | value: "less", |
| | | since: "1.7.1", |
| | | description: "Less" |
| | | }, { |
| | | value: "scss", |
| | | since: "1.7.1", |
| | | description: "SCSS" |
| | | }, { |
| | | value: "json", |
| | | since: "1.5.0", |
| | | description: "JSON" |
| | | }, { |
| | | value: "json5", |
| | | since: "1.13.0", |
| | | description: "JSON5" |
| | | }, { |
| | | value: "json-stringify", |
| | | since: "1.13.0", |
| | | description: "JSON.stringify" |
| | | }, { |
| | | value: "graphql", |
| | | since: "1.5.0", |
| | | description: "GraphQL" |
| | | }, { |
| | | value: "markdown", |
| | | since: "1.8.0", |
| | | description: "Markdown" |
| | | }, { |
| | | value: "mdx", |
| | | since: "1.15.0", |
| | | description: "MDX" |
| | | }, { |
| | | value: "vue", |
| | | since: "1.10.0", |
| | | description: "Vue" |
| | | }, { |
| | | value: "yaml", |
| | | since: "1.14.0", |
| | | description: "YAML" |
| | | }, { |
| | | value: "glimmer", |
| | | since: null, |
| | | description: "Handlebars" |
| | | }, { |
| | | value: "html", |
| | | since: "1.15.0", |
| | | description: "HTML" |
| | | }, { |
| | | value: "angular", |
| | | since: "1.15.0", |
| | | description: "Angular" |
| | | }, { |
| | | value: "lwc", |
| | | since: "1.17.0", |
| | | description: "Lightning Web Components" |
| | | }] |
| | | }, |
| | | plugins: { |
| | | since: "1.10.0", |
| | | type: "path", |
| | | array: true, |
| | | default: [{ |
| | | value: [] |
| | | }], |
| | | category: CATEGORY_GLOBAL, |
| | | description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.", |
| | | exception: function exception(value) { |
| | | return typeof value === "string" || _typeof(value) === "object"; |
| | | }, |
| | | cliName: "plugin", |
| | | cliCategory: CATEGORY_CONFIG |
| | | }, |
| | | pluginSearchDirs: { |
| | | since: "1.13.0", |
| | | type: "path", |
| | | array: true, |
| | | default: [{ |
| | | value: [] |
| | | }], |
| | | category: CATEGORY_GLOBAL, |
| | | description: dedent_1(_templateObject3()), |
| | | exception: function exception(value) { |
| | | return typeof value === "string" || _typeof(value) === "object"; |
| | | }, |
| | | cliName: "plugin-search-dir", |
| | | cliCategory: CATEGORY_CONFIG |
| | | }, |
| | | printWidth: { |
| | | since: "0.0.0", |
| | | category: CATEGORY_GLOBAL, |
| | | type: "int", |
| | | default: 80, |
| | | description: "The line length where Prettier will try wrap.", |
| | | range: { |
| | | start: 0, |
| | | end: Infinity, |
| | | step: 1 |
| | | } |
| | | }, |
| | | rangeEnd: { |
| | | since: "1.4.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "int", |
| | | default: Infinity, |
| | | range: { |
| | | start: 0, |
| | | end: Infinity, |
| | | step: 1 |
| | | }, |
| | | description: dedent_1(_templateObject4()), |
| | | cliCategory: CATEGORY_EDITOR |
| | | }, |
| | | rangeStart: { |
| | | since: "1.4.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "int", |
| | | default: 0, |
| | | range: { |
| | | start: 0, |
| | | end: Infinity, |
| | | step: 1 |
| | | }, |
| | | description: dedent_1(_templateObject5()), |
| | | cliCategory: CATEGORY_EDITOR |
| | | }, |
| | | requirePragma: { |
| | | since: "1.7.0", |
| | | category: CATEGORY_SPECIAL, |
| | | type: "boolean", |
| | | default: false, |
| | | description: dedent_1(_templateObject6()), |
| | | cliCategory: CATEGORY_OTHER |
| | | }, |
| | | tabWidth: { |
| | | type: "int", |
| | | category: CATEGORY_GLOBAL, |
| | | default: 2, |
| | | description: "Number of spaces per indentation level.", |
| | | range: { |
| | | start: 0, |
| | | end: Infinity, |
| | | step: 1 |
| | | } |
| | | }, |
| | | useFlowParser: { |
| | | since: "0.0.0", |
| | | category: CATEGORY_GLOBAL, |
| | | type: "boolean", |
| | | default: [{ |
| | | since: "0.0.0", |
| | | value: false |
| | | }, { |
| | | since: "1.15.0", |
| | | value: undefined |
| | | }], |
| | | deprecated: "0.0.10", |
| | | description: "Use flow parser.", |
| | | redirect: { |
| | | option: "parser", |
| | | value: "flow" |
| | | }, |
| | | cliName: "flow-parser" |
| | | }, |
| | | useTabs: { |
| | | since: "1.0.0", |
| | | category: CATEGORY_GLOBAL, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Indent with tabs instead of spaces." |
| | | } |
| | | }; |
| | | var coreOptions = { |
| | | CATEGORY_CONFIG: CATEGORY_CONFIG, |
| | | CATEGORY_EDITOR: CATEGORY_EDITOR, |
| | | CATEGORY_FORMAT: CATEGORY_FORMAT, |
| | | CATEGORY_OTHER: CATEGORY_OTHER, |
| | | CATEGORY_OUTPUT: CATEGORY_OUTPUT, |
| | | CATEGORY_GLOBAL: CATEGORY_GLOBAL, |
| | | CATEGORY_SPECIAL: CATEGORY_SPECIAL, |
| | | options: options |
| | | }; |
| | | |
| | | var require$$0 = getCjsExportFromNamespace(_package$1); |
| | | |
| | | var currentVersion = require$$0.version; |
| | | var coreOptions$1 = coreOptions.options; |
| | | |
| | | function getSupportInfo(version, opts) { |
| | | opts = Object.assign({ |
| | | plugins: [], |
| | | showUnreleased: false, |
| | | showDeprecated: false, |
| | | showInternal: false |
| | | }, opts); |
| | | |
| | | if (!version) { |
| | | // pre-release version is smaller than the normal version in semver, |
| | | // we need to treat it as the normal one so as to test new features. |
| | | version = currentVersion.split("-", 1)[0]; |
| | | } |
| | | |
| | | var plugins = opts.plugins; |
| | | var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) { |
| | | return Object.assign(currentOptions, plugin.options); |
| | | }, {}), coreOptions$1), "name").sort(function (a, b) { |
| | | return a.name === b.name ? 0 : a.name < b.name ? -1 : 1; |
| | | }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) { |
| | | var newOption = Object.assign({}, option); |
| | | |
| | | if (Array.isArray(newOption.default)) { |
| | | newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) { |
| | | return semver.compare(info2.since, info1.since); |
| | | })[0].value; |
| | | } |
| | | |
| | | if (Array.isArray(newOption.choices)) { |
| | | newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated); |
| | | } |
| | | |
| | | return newOption; |
| | | }).map(function (option) { |
| | | var filteredPlugins = plugins.filter(function (plugin) { |
| | | return plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined; |
| | | }); |
| | | var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) { |
| | | reduced[plugin.name] = plugin.defaultOptions[option.name]; |
| | | return reduced; |
| | | }, {}); |
| | | return Object.assign(option, { |
| | | pluginDefaults: pluginDefaults |
| | | }); |
| | | }); |
| | | var usePostCssParser = semver.lt(version, "1.7.1"); |
| | | var useBabylonParser = semver.lt(version, "1.16.0"); |
| | | var languages = plugins.reduce(function (all, plugin) { |
| | | return all.concat(plugin.languages || []); |
| | | }, []).filter(filterSince).map(function (language) { |
| | | // Prevent breaking changes |
| | | if (language.name === "Markdown") { |
| | | return Object.assign({}, language, { |
| | | parsers: ["markdown"] |
| | | }); |
| | | } |
| | | |
| | | if (language.name === "TypeScript") { |
| | | return Object.assign({}, language, { |
| | | parsers: ["typescript"] |
| | | }); |
| | | } // "babylon" was renamed to "babel" in 1.16.0 |
| | | |
| | | |
| | | if (useBabylonParser && language.parsers.indexOf("babel") !== -1) { |
| | | return Object.assign({}, language, { |
| | | parsers: language.parsers.map(function (parser) { |
| | | return parser === "babel" ? "babylon" : parser; |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) { |
| | | return Object.assign({}, language, { |
| | | parsers: ["postcss"] |
| | | }); |
| | | } |
| | | |
| | | return language; |
| | | }); |
| | | return { |
| | | languages: languages, |
| | | options: options |
| | | }; |
| | | |
| | | function filterSince(object) { |
| | | return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since); |
| | | } |
| | | |
| | | function filterDeprecated(object) { |
| | | return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated); |
| | | } |
| | | |
| | | function mapDeprecated(object) { |
| | | if (!object.deprecated || opts.showDeprecated) { |
| | | return object; |
| | | } |
| | | |
| | | var newObject = Object.assign({}, object); |
| | | delete newObject.deprecated; |
| | | delete newObject.redirect; |
| | | return newObject; |
| | | } |
| | | |
| | | function mapInternal(object) { |
| | | if (opts.showInternal) { |
| | | return object; |
| | | } |
| | | |
| | | var newObject = Object.assign({}, object); |
| | | delete newObject.cliName; |
| | | delete newObject.cliCategory; |
| | | delete newObject.cliDescription; |
| | | return newObject; |
| | | } |
| | | } |
| | | |
| | | var support = { |
| | | getSupportInfo: getSupportInfo |
| | | }; |
| | | |
| | | /*! *****************************************************************************
|
| | | Copyright (c) Microsoft Corporation. All rights reserved.
|
| | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
| | | this file except in compliance with the License. You may obtain a copy of the
|
| | | License at http://www.apache.org/licenses/LICENSE-2.0
|
| | |
|
| | | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
| | | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
| | | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
| | | MERCHANTABLITY OR NON-INFRINGEMENT.
|
| | |
|
| | | See the Apache Version 2.0 License for specific language governing permissions
|
| | | and limitations under the License.
|
| | | ***************************************************************************** */ |
| | | |
| | | /* global Reflect, Promise */ |
| | | var _extendStatics = function extendStatics(d, b) { |
| | | _extendStatics = Object.setPrototypeOf || { |
| | | __proto__: [] |
| | | } instanceof Array && function (d, b) { |
| | | d.__proto__ = b; |
| | | } || function (d, b) { |
| | | for (var p in b) { |
| | | if (b.hasOwnProperty(p)) d[p] = b[p]; |
| | | } |
| | | }; |
| | | |
| | | return _extendStatics(d, b); |
| | | }; |
| | | |
| | | function __extends(d, b) { |
| | | _extendStatics(d, b); |
| | | |
| | | function __() { |
| | | this.constructor = d; |
| | | } |
| | | |
| | | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| | | } |
| | | |
| | | var _assign = function __assign() { |
| | | _assign = Object.assign || function __assign(t) { |
| | | for (var s, i = 1, n = arguments.length; i < n; i++) { |
| | | s = arguments[i]; |
| | | |
| | | for (var p in s) { |
| | | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| | | } |
| | | } |
| | | |
| | | return t; |
| | | }; |
| | | |
| | | return _assign.apply(this, arguments); |
| | | }; |
| | | function __rest(s, e) { |
| | | var t = {}; |
| | | |
| | | for (var p in s) { |
| | | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; |
| | | } |
| | | |
| | | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
| | | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; |
| | | } |
| | | return t; |
| | | } |
| | | function __decorate(decorators, target, key, desc) { |
| | | var c = arguments.length, |
| | | r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, |
| | | d; |
| | | if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) { |
| | | if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
| | | } |
| | | return c > 3 && r && Object.defineProperty(target, key, r), r; |
| | | } |
| | | function __param(paramIndex, decorator) { |
| | | return function (target, key) { |
| | | decorator(target, key, paramIndex); |
| | | }; |
| | | } |
| | | function __metadata(metadataKey, metadataValue) { |
| | | if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
| | | } |
| | | function __awaiter(thisArg, _arguments, P, generator) { |
| | | return new (P || (P = Promise))(function (resolve, reject) { |
| | | function fulfilled(value) { |
| | | try { |
| | | step(generator.next(value)); |
| | | } catch (e) { |
| | | reject(e); |
| | | } |
| | | } |
| | | |
| | | function rejected(value) { |
| | | try { |
| | | step(generator["throw"](value)); |
| | | } catch (e) { |
| | | reject(e); |
| | | } |
| | | } |
| | | |
| | | function step(result) { |
| | | result.done ? resolve(result.value) : new P(function (resolve) { |
| | | resolve(result.value); |
| | | }).then(fulfilled, rejected); |
| | | } |
| | | |
| | | step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| | | }); |
| | | } |
| | | function __generator(thisArg, body) { |
| | | var _ = { |
| | | label: 0, |
| | | sent: function sent() { |
| | | if (t[0] & 1) throw t[1]; |
| | | return t[1]; |
| | | }, |
| | | trys: [], |
| | | ops: [] |
| | | }, |
| | | f, |
| | | y, |
| | | t, |
| | | g; |
| | | return g = { |
| | | next: verb(0), |
| | | "throw": verb(1), |
| | | "return": verb(2) |
| | | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { |
| | | return this; |
| | | }), g; |
| | | |
| | | function verb(n) { |
| | | return function (v) { |
| | | return step([n, v]); |
| | | }; |
| | | } |
| | | |
| | | function step(op) { |
| | | if (f) throw new TypeError("Generator is already executing."); |
| | | |
| | | while (_) { |
| | | try { |
| | | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
| | | if (y = 0, t) op = [op[0] & 2, t.value]; |
| | | |
| | | switch (op[0]) { |
| | | case 0: |
| | | case 1: |
| | | t = op; |
| | | break; |
| | | |
| | | case 4: |
| | | _.label++; |
| | | return { |
| | | value: op[1], |
| | | done: false |
| | | }; |
| | | |
| | | case 5: |
| | | _.label++; |
| | | y = op[1]; |
| | | op = [0]; |
| | | continue; |
| | | |
| | | case 7: |
| | | op = _.ops.pop(); |
| | | |
| | | _.trys.pop(); |
| | | |
| | | continue; |
| | | |
| | | default: |
| | | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { |
| | | _ = 0; |
| | | continue; |
| | | } |
| | | |
| | | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { |
| | | _.label = op[1]; |
| | | break; |
| | | } |
| | | |
| | | if (op[0] === 6 && _.label < t[1]) { |
| | | _.label = t[1]; |
| | | t = op; |
| | | break; |
| | | } |
| | | |
| | | if (t && _.label < t[2]) { |
| | | _.label = t[2]; |
| | | |
| | | _.ops.push(op); |
| | | |
| | | break; |
| | | } |
| | | |
| | | if (t[2]) _.ops.pop(); |
| | | |
| | | _.trys.pop(); |
| | | |
| | | continue; |
| | | } |
| | | |
| | | op = body.call(thisArg, _); |
| | | } catch (e) { |
| | | op = [6, e]; |
| | | y = 0; |
| | | } finally { |
| | | f = t = 0; |
| | | } |
| | | } |
| | | |
| | | if (op[0] & 5) throw op[1]; |
| | | return { |
| | | value: op[0] ? op[1] : void 0, |
| | | done: true |
| | | }; |
| | | } |
| | | } |
| | | function __exportStar(m, exports) { |
| | | for (var p in m) { |
| | | if (!exports.hasOwnProperty(p)) exports[p] = m[p]; |
| | | } |
| | | } |
| | | function __values(o) { |
| | | var m = typeof Symbol === "function" && o[Symbol.iterator], |
| | | i = 0; |
| | | if (m) return m.call(o); |
| | | return { |
| | | next: function next() { |
| | | if (o && i >= o.length) o = void 0; |
| | | return { |
| | | value: o && o[i++], |
| | | done: !o |
| | | }; |
| | | } |
| | | }; |
| | | } |
| | | function __read(o, n) { |
| | | var m = typeof Symbol === "function" && o[Symbol.iterator]; |
| | | if (!m) return o; |
| | | var i = m.call(o), |
| | | r, |
| | | ar = [], |
| | | e; |
| | | |
| | | try { |
| | | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { |
| | | ar.push(r.value); |
| | | } |
| | | } catch (error) { |
| | | e = { |
| | | error: error |
| | | }; |
| | | } finally { |
| | | try { |
| | | if (r && !r.done && (m = i["return"])) m.call(i); |
| | | } finally { |
| | | if (e) throw e.error; |
| | | } |
| | | } |
| | | |
| | | return ar; |
| | | } |
| | | function __spread() { |
| | | for (var ar = [], i = 0; i < arguments.length; i++) { |
| | | ar = ar.concat(__read(arguments[i])); |
| | | } |
| | | |
| | | return ar; |
| | | } |
| | | function __spreadArrays() { |
| | | for (var s = 0, i = 0, il = arguments.length; i < il; i++) { |
| | | s += arguments[i].length; |
| | | } |
| | | |
| | | for (var r = Array(s), k = 0, i = 0; i < il; i++) { |
| | | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) { |
| | | r[k] = a[j]; |
| | | } |
| | | } |
| | | |
| | | return r; |
| | | } |
| | | function __await(v) { |
| | | return this instanceof __await ? (this.v = v, this) : new __await(v); |
| | | } |
| | | function __asyncGenerator(thisArg, _arguments, generator) { |
| | | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| | | var g = generator.apply(thisArg, _arguments || []), |
| | | i, |
| | | q = []; |
| | | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { |
| | | return this; |
| | | }, i; |
| | | |
| | | function verb(n) { |
| | | if (g[n]) i[n] = function (v) { |
| | | return new Promise(function (a, b) { |
| | | q.push([n, v, a, b]) > 1 || resume(n, v); |
| | | }); |
| | | }; |
| | | } |
| | | |
| | | function resume(n, v) { |
| | | try { |
| | | step(g[n](v)); |
| | | } catch (e) { |
| | | settle(q[0][3], e); |
| | | } |
| | | } |
| | | |
| | | function step(r) { |
| | | r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); |
| | | } |
| | | |
| | | function fulfill(value) { |
| | | resume("next", value); |
| | | } |
| | | |
| | | function reject(value) { |
| | | resume("throw", value); |
| | | } |
| | | |
| | | function settle(f, v) { |
| | | if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); |
| | | } |
| | | } |
| | | function __asyncDelegator(o) { |
| | | var i, p; |
| | | return i = {}, verb("next"), verb("throw", function (e) { |
| | | throw e; |
| | | }), verb("return"), i[Symbol.iterator] = function () { |
| | | return this; |
| | | }, i; |
| | | |
| | | function verb(n, f) { |
| | | i[n] = o[n] ? function (v) { |
| | | return (p = !p) ? { |
| | | value: __await(o[n](v)), |
| | | done: n === "return" |
| | | } : f ? f(v) : v; |
| | | } : f; |
| | | } |
| | | } |
| | | function __asyncValues(o) { |
| | | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| | | var m = o[Symbol.asyncIterator], |
| | | i; |
| | | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { |
| | | return this; |
| | | }, i); |
| | | |
| | | function verb(n) { |
| | | i[n] = o[n] && function (v) { |
| | | return new Promise(function (resolve, reject) { |
| | | v = o[n](v), settle(resolve, reject, v.done, v.value); |
| | | }); |
| | | }; |
| | | } |
| | | |
| | | function settle(resolve, reject, d, v) { |
| | | Promise.resolve(v).then(function (v) { |
| | | resolve({ |
| | | value: v, |
| | | done: d |
| | | }); |
| | | }, reject); |
| | | } |
| | | } |
| | | function __makeTemplateObject(cooked, raw) { |
| | | if (Object.defineProperty) { |
| | | Object.defineProperty(cooked, "raw", { |
| | | value: raw |
| | | }); |
| | | } else { |
| | | cooked.raw = raw; |
| | | } |
| | | |
| | | return cooked; |
| | | } |
| | | function __importStar(mod) { |
| | | if (mod && mod.__esModule) return mod; |
| | | var result = {}; |
| | | if (mod != null) for (var k in mod) { |
| | | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; |
| | | } |
| | | result.default = mod; |
| | | return result; |
| | | } |
| | | function __importDefault(mod) { |
| | | return mod && mod.__esModule ? mod : { |
| | | default: mod |
| | | }; |
| | | } |
| | | |
| | | var tslib_es6 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | __extends: __extends, |
| | | get __assign () { return _assign; }, |
| | | __rest: __rest, |
| | | __decorate: __decorate, |
| | | __param: __param, |
| | | __metadata: __metadata, |
| | | __awaiter: __awaiter, |
| | | __generator: __generator, |
| | | __exportStar: __exportStar, |
| | | __values: __values, |
| | | __read: __read, |
| | | __spread: __spread, |
| | | __spreadArrays: __spreadArrays, |
| | | __await: __await, |
| | | __asyncGenerator: __asyncGenerator, |
| | | __asyncDelegator: __asyncDelegator, |
| | | __asyncValues: __asyncValues, |
| | | __makeTemplateObject: __makeTemplateObject, |
| | | __importStar: __importStar, |
| | | __importDefault: __importDefault |
| | | }); |
| | | |
| | | var api = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.apiDescriptor = { |
| | | key: function key(_key) { |
| | | return /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(_key) ? _key : JSON.stringify(_key); |
| | | }, |
| | | value: function value(_value) { |
| | | if (_value === null || _typeof(_value) !== 'object') { |
| | | return JSON.stringify(_value); |
| | | } |
| | | |
| | | if (Array.isArray(_value)) { |
| | | return "[".concat(_value.map(function (subValue) { |
| | | return exports.apiDescriptor.value(subValue); |
| | | }).join(', '), "]"); |
| | | } |
| | | |
| | | var keys = Object.keys(_value); |
| | | return keys.length === 0 ? '{}' : "{ ".concat(keys.map(function (key) { |
| | | return "".concat(exports.apiDescriptor.key(key), ": ").concat(exports.apiDescriptor.value(_value[key])); |
| | | }).join(', '), " }"); |
| | | }, |
| | | pair: function pair(_ref) { |
| | | var key = _ref.key, |
| | | value = _ref.value; |
| | | return exports.apiDescriptor.value(_defineProperty({}, key, value)); |
| | | } |
| | | }; |
| | | }); |
| | | unwrapExports(api); |
| | | var api_1 = api.apiDescriptor; |
| | | |
| | | var tslib_1 = getCjsExportFromNamespace(tslib_es6); |
| | | |
| | | var descriptors = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(api, exports); |
| | | }); |
| | | unwrapExports(descriptors); |
| | | |
| | | var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; |
| | | |
| | | var escapeStringRegexp = function escapeStringRegexp(str) { |
| | | if (typeof str !== 'string') { |
| | | throw new TypeError('Expected a string'); |
| | | } |
| | | |
| | | return str.replace(matchOperatorsRe, '\\$&'); |
| | | }; |
| | | |
| | | var colorName = { |
| | | "aliceblue": [240, 248, 255], |
| | | "antiquewhite": [250, 235, 215], |
| | | "aqua": [0, 255, 255], |
| | | "aquamarine": [127, 255, 212], |
| | | "azure": [240, 255, 255], |
| | | "beige": [245, 245, 220], |
| | | "bisque": [255, 228, 196], |
| | | "black": [0, 0, 0], |
| | | "blanchedalmond": [255, 235, 205], |
| | | "blue": [0, 0, 255], |
| | | "blueviolet": [138, 43, 226], |
| | | "brown": [165, 42, 42], |
| | | "burlywood": [222, 184, 135], |
| | | "cadetblue": [95, 158, 160], |
| | | "chartreuse": [127, 255, 0], |
| | | "chocolate": [210, 105, 30], |
| | | "coral": [255, 127, 80], |
| | | "cornflowerblue": [100, 149, 237], |
| | | "cornsilk": [255, 248, 220], |
| | | "crimson": [220, 20, 60], |
| | | "cyan": [0, 255, 255], |
| | | "darkblue": [0, 0, 139], |
| | | "darkcyan": [0, 139, 139], |
| | | "darkgoldenrod": [184, 134, 11], |
| | | "darkgray": [169, 169, 169], |
| | | "darkgreen": [0, 100, 0], |
| | | "darkgrey": [169, 169, 169], |
| | | "darkkhaki": [189, 183, 107], |
| | | "darkmagenta": [139, 0, 139], |
| | | "darkolivegreen": [85, 107, 47], |
| | | "darkorange": [255, 140, 0], |
| | | "darkorchid": [153, 50, 204], |
| | | "darkred": [139, 0, 0], |
| | | "darksalmon": [233, 150, 122], |
| | | "darkseagreen": [143, 188, 143], |
| | | "darkslateblue": [72, 61, 139], |
| | | "darkslategray": [47, 79, 79], |
| | | "darkslategrey": [47, 79, 79], |
| | | "darkturquoise": [0, 206, 209], |
| | | "darkviolet": [148, 0, 211], |
| | | "deeppink": [255, 20, 147], |
| | | "deepskyblue": [0, 191, 255], |
| | | "dimgray": [105, 105, 105], |
| | | "dimgrey": [105, 105, 105], |
| | | "dodgerblue": [30, 144, 255], |
| | | "firebrick": [178, 34, 34], |
| | | "floralwhite": [255, 250, 240], |
| | | "forestgreen": [34, 139, 34], |
| | | "fuchsia": [255, 0, 255], |
| | | "gainsboro": [220, 220, 220], |
| | | "ghostwhite": [248, 248, 255], |
| | | "gold": [255, 215, 0], |
| | | "goldenrod": [218, 165, 32], |
| | | "gray": [128, 128, 128], |
| | | "green": [0, 128, 0], |
| | | "greenyellow": [173, 255, 47], |
| | | "grey": [128, 128, 128], |
| | | "honeydew": [240, 255, 240], |
| | | "hotpink": [255, 105, 180], |
| | | "indianred": [205, 92, 92], |
| | | "indigo": [75, 0, 130], |
| | | "ivory": [255, 255, 240], |
| | | "khaki": [240, 230, 140], |
| | | "lavender": [230, 230, 250], |
| | | "lavenderblush": [255, 240, 245], |
| | | "lawngreen": [124, 252, 0], |
| | | "lemonchiffon": [255, 250, 205], |
| | | "lightblue": [173, 216, 230], |
| | | "lightcoral": [240, 128, 128], |
| | | "lightcyan": [224, 255, 255], |
| | | "lightgoldenrodyellow": [250, 250, 210], |
| | | "lightgray": [211, 211, 211], |
| | | "lightgreen": [144, 238, 144], |
| | | "lightgrey": [211, 211, 211], |
| | | "lightpink": [255, 182, 193], |
| | | "lightsalmon": [255, 160, 122], |
| | | "lightseagreen": [32, 178, 170], |
| | | "lightskyblue": [135, 206, 250], |
| | | "lightslategray": [119, 136, 153], |
| | | "lightslategrey": [119, 136, 153], |
| | | "lightsteelblue": [176, 196, 222], |
| | | "lightyellow": [255, 255, 224], |
| | | "lime": [0, 255, 0], |
| | | "limegreen": [50, 205, 50], |
| | | "linen": [250, 240, 230], |
| | | "magenta": [255, 0, 255], |
| | | "maroon": [128, 0, 0], |
| | | "mediumaquamarine": [102, 205, 170], |
| | | "mediumblue": [0, 0, 205], |
| | | "mediumorchid": [186, 85, 211], |
| | | "mediumpurple": [147, 112, 219], |
| | | "mediumseagreen": [60, 179, 113], |
| | | "mediumslateblue": [123, 104, 238], |
| | | "mediumspringgreen": [0, 250, 154], |
| | | "mediumturquoise": [72, 209, 204], |
| | | "mediumvioletred": [199, 21, 133], |
| | | "midnightblue": [25, 25, 112], |
| | | "mintcream": [245, 255, 250], |
| | | "mistyrose": [255, 228, 225], |
| | | "moccasin": [255, 228, 181], |
| | | "navajowhite": [255, 222, 173], |
| | | "navy": [0, 0, 128], |
| | | "oldlace": [253, 245, 230], |
| | | "olive": [128, 128, 0], |
| | | "olivedrab": [107, 142, 35], |
| | | "orange": [255, 165, 0], |
| | | "orangered": [255, 69, 0], |
| | | "orchid": [218, 112, 214], |
| | | "palegoldenrod": [238, 232, 170], |
| | | "palegreen": [152, 251, 152], |
| | | "paleturquoise": [175, 238, 238], |
| | | "palevioletred": [219, 112, 147], |
| | | "papayawhip": [255, 239, 213], |
| | | "peachpuff": [255, 218, 185], |
| | | "peru": [205, 133, 63], |
| | | "pink": [255, 192, 203], |
| | | "plum": [221, 160, 221], |
| | | "powderblue": [176, 224, 230], |
| | | "purple": [128, 0, 128], |
| | | "rebeccapurple": [102, 51, 153], |
| | | "red": [255, 0, 0], |
| | | "rosybrown": [188, 143, 143], |
| | | "royalblue": [65, 105, 225], |
| | | "saddlebrown": [139, 69, 19], |
| | | "salmon": [250, 128, 114], |
| | | "sandybrown": [244, 164, 96], |
| | | "seagreen": [46, 139, 87], |
| | | "seashell": [255, 245, 238], |
| | | "sienna": [160, 82, 45], |
| | | "silver": [192, 192, 192], |
| | | "skyblue": [135, 206, 235], |
| | | "slateblue": [106, 90, 205], |
| | | "slategray": [112, 128, 144], |
| | | "slategrey": [112, 128, 144], |
| | | "snow": [255, 250, 250], |
| | | "springgreen": [0, 255, 127], |
| | | "steelblue": [70, 130, 180], |
| | | "tan": [210, 180, 140], |
| | | "teal": [0, 128, 128], |
| | | "thistle": [216, 191, 216], |
| | | "tomato": [255, 99, 71], |
| | | "turquoise": [64, 224, 208], |
| | | "violet": [238, 130, 238], |
| | | "wheat": [245, 222, 179], |
| | | "white": [255, 255, 255], |
| | | "whitesmoke": [245, 245, 245], |
| | | "yellow": [255, 255, 0], |
| | | "yellowgreen": [154, 205, 50] |
| | | }; |
| | | |
| | | var conversions = createCommonjsModule(function (module) { |
| | | /* MIT license */ |
| | | // NOTE: conversions should only return primitive values (i.e. arrays, or |
| | | // values that give correct `typeof` results). |
| | | // do not use box values types (i.e. Number(), String(), etc.) |
| | | var reverseKeywords = {}; |
| | | |
| | | for (var key in colorName) { |
| | | if (colorName.hasOwnProperty(key)) { |
| | | reverseKeywords[colorName[key]] = key; |
| | | } |
| | | } |
| | | |
| | | var convert = module.exports = { |
| | | rgb: { |
| | | channels: 3, |
| | | labels: 'rgb' |
| | | }, |
| | | hsl: { |
| | | channels: 3, |
| | | labels: 'hsl' |
| | | }, |
| | | hsv: { |
| | | channels: 3, |
| | | labels: 'hsv' |
| | | }, |
| | | hwb: { |
| | | channels: 3, |
| | | labels: 'hwb' |
| | | }, |
| | | cmyk: { |
| | | channels: 4, |
| | | labels: 'cmyk' |
| | | }, |
| | | xyz: { |
| | | channels: 3, |
| | | labels: 'xyz' |
| | | }, |
| | | lab: { |
| | | channels: 3, |
| | | labels: 'lab' |
| | | }, |
| | | lch: { |
| | | channels: 3, |
| | | labels: 'lch' |
| | | }, |
| | | hex: { |
| | | channels: 1, |
| | | labels: ['hex'] |
| | | }, |
| | | keyword: { |
| | | channels: 1, |
| | | labels: ['keyword'] |
| | | }, |
| | | ansi16: { |
| | | channels: 1, |
| | | labels: ['ansi16'] |
| | | }, |
| | | ansi256: { |
| | | channels: 1, |
| | | labels: ['ansi256'] |
| | | }, |
| | | hcg: { |
| | | channels: 3, |
| | | labels: ['h', 'c', 'g'] |
| | | }, |
| | | apple: { |
| | | channels: 3, |
| | | labels: ['r16', 'g16', 'b16'] |
| | | }, |
| | | gray: { |
| | | channels: 1, |
| | | labels: ['gray'] |
| | | } |
| | | }; // hide .channels and .labels properties |
| | | |
| | | for (var model in convert) { |
| | | if (convert.hasOwnProperty(model)) { |
| | | if (!('channels' in convert[model])) { |
| | | throw new Error('missing channels property: ' + model); |
| | | } |
| | | |
| | | if (!('labels' in convert[model])) { |
| | | throw new Error('missing channel labels property: ' + model); |
| | | } |
| | | |
| | | if (convert[model].labels.length !== convert[model].channels) { |
| | | throw new Error('channel and label counts mismatch: ' + model); |
| | | } |
| | | |
| | | var channels = convert[model].channels; |
| | | var labels = convert[model].labels; |
| | | delete convert[model].channels; |
| | | delete convert[model].labels; |
| | | Object.defineProperty(convert[model], 'channels', { |
| | | value: channels |
| | | }); |
| | | Object.defineProperty(convert[model], 'labels', { |
| | | value: labels |
| | | }); |
| | | } |
| | | } |
| | | |
| | | convert.rgb.hsl = function (rgb) { |
| | | var r = rgb[0] / 255; |
| | | var g = rgb[1] / 255; |
| | | var b = rgb[2] / 255; |
| | | var min = Math.min(r, g, b); |
| | | var max = Math.max(r, g, b); |
| | | var delta = max - min; |
| | | var h; |
| | | var s; |
| | | var l; |
| | | |
| | | if (max === min) { |
| | | h = 0; |
| | | } else if (r === max) { |
| | | h = (g - b) / delta; |
| | | } else if (g === max) { |
| | | h = 2 + (b - r) / delta; |
| | | } else if (b === max) { |
| | | h = 4 + (r - g) / delta; |
| | | } |
| | | |
| | | h = Math.min(h * 60, 360); |
| | | |
| | | if (h < 0) { |
| | | h += 360; |
| | | } |
| | | |
| | | l = (min + max) / 2; |
| | | |
| | | if (max === min) { |
| | | s = 0; |
| | | } else if (l <= 0.5) { |
| | | s = delta / (max + min); |
| | | } else { |
| | | s = delta / (2 - max - min); |
| | | } |
| | | |
| | | return [h, s * 100, l * 100]; |
| | | }; |
| | | |
| | | convert.rgb.hsv = function (rgb) { |
| | | var r = rgb[0]; |
| | | var g = rgb[1]; |
| | | var b = rgb[2]; |
| | | var min = Math.min(r, g, b); |
| | | var max = Math.max(r, g, b); |
| | | var delta = max - min; |
| | | var h; |
| | | var s; |
| | | var v; |
| | | |
| | | if (max === 0) { |
| | | s = 0; |
| | | } else { |
| | | s = delta / max * 1000 / 10; |
| | | } |
| | | |
| | | if (max === min) { |
| | | h = 0; |
| | | } else if (r === max) { |
| | | h = (g - b) / delta; |
| | | } else if (g === max) { |
| | | h = 2 + (b - r) / delta; |
| | | } else if (b === max) { |
| | | h = 4 + (r - g) / delta; |
| | | } |
| | | |
| | | h = Math.min(h * 60, 360); |
| | | |
| | | if (h < 0) { |
| | | h += 360; |
| | | } |
| | | |
| | | v = max / 255 * 1000 / 10; |
| | | return [h, s, v]; |
| | | }; |
| | | |
| | | convert.rgb.hwb = function (rgb) { |
| | | var r = rgb[0]; |
| | | var g = rgb[1]; |
| | | var b = rgb[2]; |
| | | var h = convert.rgb.hsl(rgb)[0]; |
| | | var w = 1 / 255 * Math.min(r, Math.min(g, b)); |
| | | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); |
| | | return [h, w * 100, b * 100]; |
| | | }; |
| | | |
| | | convert.rgb.cmyk = function (rgb) { |
| | | var r = rgb[0] / 255; |
| | | var g = rgb[1] / 255; |
| | | var b = rgb[2] / 255; |
| | | var c; |
| | | var m; |
| | | var y; |
| | | var k; |
| | | k = Math.min(1 - r, 1 - g, 1 - b); |
| | | c = (1 - r - k) / (1 - k) || 0; |
| | | m = (1 - g - k) / (1 - k) || 0; |
| | | y = (1 - b - k) / (1 - k) || 0; |
| | | return [c * 100, m * 100, y * 100, k * 100]; |
| | | }; |
| | | /** |
| | | * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance |
| | | * */ |
| | | |
| | | |
| | | function comparativeDistance(x, y) { |
| | | return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2); |
| | | } |
| | | |
| | | convert.rgb.keyword = function (rgb) { |
| | | var reversed = reverseKeywords[rgb]; |
| | | |
| | | if (reversed) { |
| | | return reversed; |
| | | } |
| | | |
| | | var currentClosestDistance = Infinity; |
| | | var currentClosestKeyword; |
| | | |
| | | for (var keyword in colorName) { |
| | | if (colorName.hasOwnProperty(keyword)) { |
| | | var value = colorName[keyword]; // Compute comparative distance |
| | | |
| | | var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest |
| | | |
| | | if (distance < currentClosestDistance) { |
| | | currentClosestDistance = distance; |
| | | currentClosestKeyword = keyword; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return currentClosestKeyword; |
| | | }; |
| | | |
| | | convert.keyword.rgb = function (keyword) { |
| | | return colorName[keyword]; |
| | | }; |
| | | |
| | | convert.rgb.xyz = function (rgb) { |
| | | var r = rgb[0] / 255; |
| | | var g = rgb[1] / 255; |
| | | var b = rgb[2] / 255; // assume sRGB |
| | | |
| | | r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92; |
| | | g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92; |
| | | b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92; |
| | | var x = r * 0.4124 + g * 0.3576 + b * 0.1805; |
| | | var y = r * 0.2126 + g * 0.7152 + b * 0.0722; |
| | | var z = r * 0.0193 + g * 0.1192 + b * 0.9505; |
| | | return [x * 100, y * 100, z * 100]; |
| | | }; |
| | | |
| | | convert.rgb.lab = function (rgb) { |
| | | var xyz = convert.rgb.xyz(rgb); |
| | | var x = xyz[0]; |
| | | var y = xyz[1]; |
| | | var z = xyz[2]; |
| | | var l; |
| | | var a; |
| | | var b; |
| | | x /= 95.047; |
| | | y /= 100; |
| | | z /= 108.883; |
| | | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; |
| | | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; |
| | | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; |
| | | l = 116 * y - 16; |
| | | a = 500 * (x - y); |
| | | b = 200 * (y - z); |
| | | return [l, a, b]; |
| | | }; |
| | | |
| | | convert.hsl.rgb = function (hsl) { |
| | | var h = hsl[0] / 360; |
| | | var s = hsl[1] / 100; |
| | | var l = hsl[2] / 100; |
| | | var t1; |
| | | var t2; |
| | | var t3; |
| | | var rgb; |
| | | var val; |
| | | |
| | | if (s === 0) { |
| | | val = l * 255; |
| | | return [val, val, val]; |
| | | } |
| | | |
| | | if (l < 0.5) { |
| | | t2 = l * (1 + s); |
| | | } else { |
| | | t2 = l + s - l * s; |
| | | } |
| | | |
| | | t1 = 2 * l - t2; |
| | | rgb = [0, 0, 0]; |
| | | |
| | | for (var i = 0; i < 3; i++) { |
| | | t3 = h + 1 / 3 * -(i - 1); |
| | | |
| | | if (t3 < 0) { |
| | | t3++; |
| | | } |
| | | |
| | | if (t3 > 1) { |
| | | t3--; |
| | | } |
| | | |
| | | if (6 * t3 < 1) { |
| | | val = t1 + (t2 - t1) * 6 * t3; |
| | | } else if (2 * t3 < 1) { |
| | | val = t2; |
| | | } else if (3 * t3 < 2) { |
| | | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; |
| | | } else { |
| | | val = t1; |
| | | } |
| | | |
| | | rgb[i] = val * 255; |
| | | } |
| | | |
| | | return rgb; |
| | | }; |
| | | |
| | | convert.hsl.hsv = function (hsl) { |
| | | var h = hsl[0]; |
| | | var s = hsl[1] / 100; |
| | | var l = hsl[2] / 100; |
| | | var smin = s; |
| | | var lmin = Math.max(l, 0.01); |
| | | var sv; |
| | | var v; |
| | | l *= 2; |
| | | s *= l <= 1 ? l : 2 - l; |
| | | smin *= lmin <= 1 ? lmin : 2 - lmin; |
| | | v = (l + s) / 2; |
| | | sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s); |
| | | return [h, sv * 100, v * 100]; |
| | | }; |
| | | |
| | | convert.hsv.rgb = function (hsv) { |
| | | var h = hsv[0] / 60; |
| | | var s = hsv[1] / 100; |
| | | var v = hsv[2] / 100; |
| | | var hi = Math.floor(h) % 6; |
| | | var f = h - Math.floor(h); |
| | | var p = 255 * v * (1 - s); |
| | | var q = 255 * v * (1 - s * f); |
| | | var t = 255 * v * (1 - s * (1 - f)); |
| | | v *= 255; |
| | | |
| | | switch (hi) { |
| | | case 0: |
| | | return [v, t, p]; |
| | | |
| | | case 1: |
| | | return [q, v, p]; |
| | | |
| | | case 2: |
| | | return [p, v, t]; |
| | | |
| | | case 3: |
| | | return [p, q, v]; |
| | | |
| | | case 4: |
| | | return [t, p, v]; |
| | | |
| | | case 5: |
| | | return [v, p, q]; |
| | | } |
| | | }; |
| | | |
| | | convert.hsv.hsl = function (hsv) { |
| | | var h = hsv[0]; |
| | | var s = hsv[1] / 100; |
| | | var v = hsv[2] / 100; |
| | | var vmin = Math.max(v, 0.01); |
| | | var lmin; |
| | | var sl; |
| | | var l; |
| | | l = (2 - s) * v; |
| | | lmin = (2 - s) * vmin; |
| | | sl = s * vmin; |
| | | sl /= lmin <= 1 ? lmin : 2 - lmin; |
| | | sl = sl || 0; |
| | | l /= 2; |
| | | return [h, sl * 100, l * 100]; |
| | | }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb |
| | | |
| | | |
| | | convert.hwb.rgb = function (hwb) { |
| | | var h = hwb[0] / 360; |
| | | var wh = hwb[1] / 100; |
| | | var bl = hwb[2] / 100; |
| | | var ratio = wh + bl; |
| | | var i; |
| | | var v; |
| | | var f; |
| | | var n; // wh + bl cant be > 1 |
| | | |
| | | if (ratio > 1) { |
| | | wh /= ratio; |
| | | bl /= ratio; |
| | | } |
| | | |
| | | i = Math.floor(6 * h); |
| | | v = 1 - bl; |
| | | f = 6 * h - i; |
| | | |
| | | if ((i & 0x01) !== 0) { |
| | | f = 1 - f; |
| | | } |
| | | |
| | | n = wh + f * (v - wh); // linear interpolation |
| | | |
| | | var r; |
| | | var g; |
| | | var b; |
| | | |
| | | switch (i) { |
| | | default: |
| | | case 6: |
| | | case 0: |
| | | r = v; |
| | | g = n; |
| | | b = wh; |
| | | break; |
| | | |
| | | case 1: |
| | | r = n; |
| | | g = v; |
| | | b = wh; |
| | | break; |
| | | |
| | | case 2: |
| | | r = wh; |
| | | g = v; |
| | | b = n; |
| | | break; |
| | | |
| | | case 3: |
| | | r = wh; |
| | | g = n; |
| | | b = v; |
| | | break; |
| | | |
| | | case 4: |
| | | r = n; |
| | | g = wh; |
| | | b = v; |
| | | break; |
| | | |
| | | case 5: |
| | | r = v; |
| | | g = wh; |
| | | b = n; |
| | | break; |
| | | } |
| | | |
| | | return [r * 255, g * 255, b * 255]; |
| | | }; |
| | | |
| | | convert.cmyk.rgb = function (cmyk) { |
| | | var c = cmyk[0] / 100; |
| | | var m = cmyk[1] / 100; |
| | | var y = cmyk[2] / 100; |
| | | var k = cmyk[3] / 100; |
| | | var r; |
| | | var g; |
| | | var b; |
| | | r = 1 - Math.min(1, c * (1 - k) + k); |
| | | g = 1 - Math.min(1, m * (1 - k) + k); |
| | | b = 1 - Math.min(1, y * (1 - k) + k); |
| | | return [r * 255, g * 255, b * 255]; |
| | | }; |
| | | |
| | | convert.xyz.rgb = function (xyz) { |
| | | var x = xyz[0] / 100; |
| | | var y = xyz[1] / 100; |
| | | var z = xyz[2] / 100; |
| | | var r; |
| | | var g; |
| | | var b; |
| | | r = x * 3.2406 + y * -1.5372 + z * -0.4986; |
| | | g = x * -0.9689 + y * 1.8758 + z * 0.0415; |
| | | b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB |
| | | |
| | | r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92; |
| | | g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92; |
| | | b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92; |
| | | r = Math.min(Math.max(0, r), 1); |
| | | g = Math.min(Math.max(0, g), 1); |
| | | b = Math.min(Math.max(0, b), 1); |
| | | return [r * 255, g * 255, b * 255]; |
| | | }; |
| | | |
| | | convert.xyz.lab = function (xyz) { |
| | | var x = xyz[0]; |
| | | var y = xyz[1]; |
| | | var z = xyz[2]; |
| | | var l; |
| | | var a; |
| | | var b; |
| | | x /= 95.047; |
| | | y /= 100; |
| | | z /= 108.883; |
| | | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; |
| | | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; |
| | | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; |
| | | l = 116 * y - 16; |
| | | a = 500 * (x - y); |
| | | b = 200 * (y - z); |
| | | return [l, a, b]; |
| | | }; |
| | | |
| | | convert.lab.xyz = function (lab) { |
| | | var l = lab[0]; |
| | | var a = lab[1]; |
| | | var b = lab[2]; |
| | | var x; |
| | | var y; |
| | | var z; |
| | | y = (l + 16) / 116; |
| | | x = a / 500 + y; |
| | | z = y - b / 200; |
| | | var y2 = Math.pow(y, 3); |
| | | var x2 = Math.pow(x, 3); |
| | | var z2 = Math.pow(z, 3); |
| | | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; |
| | | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; |
| | | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; |
| | | x *= 95.047; |
| | | y *= 100; |
| | | z *= 108.883; |
| | | return [x, y, z]; |
| | | }; |
| | | |
| | | convert.lab.lch = function (lab) { |
| | | var l = lab[0]; |
| | | var a = lab[1]; |
| | | var b = lab[2]; |
| | | var hr; |
| | | var h; |
| | | var c; |
| | | hr = Math.atan2(b, a); |
| | | h = hr * 360 / 2 / Math.PI; |
| | | |
| | | if (h < 0) { |
| | | h += 360; |
| | | } |
| | | |
| | | c = Math.sqrt(a * a + b * b); |
| | | return [l, c, h]; |
| | | }; |
| | | |
| | | convert.lch.lab = function (lch) { |
| | | var l = lch[0]; |
| | | var c = lch[1]; |
| | | var h = lch[2]; |
| | | var a; |
| | | var b; |
| | | var hr; |
| | | hr = h / 360 * 2 * Math.PI; |
| | | a = c * Math.cos(hr); |
| | | b = c * Math.sin(hr); |
| | | return [l, a, b]; |
| | | }; |
| | | |
| | | convert.rgb.ansi16 = function (args) { |
| | | var r = args[0]; |
| | | var g = args[1]; |
| | | var b = args[2]; |
| | | var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization |
| | | |
| | | value = Math.round(value / 50); |
| | | |
| | | if (value === 0) { |
| | | return 30; |
| | | } |
| | | |
| | | var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255)); |
| | | |
| | | if (value === 2) { |
| | | ansi += 60; |
| | | } |
| | | |
| | | return ansi; |
| | | }; |
| | | |
| | | convert.hsv.ansi16 = function (args) { |
| | | // optimization here; we already know the value and don't need to get |
| | | // it converted for us. |
| | | return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); |
| | | }; |
| | | |
| | | convert.rgb.ansi256 = function (args) { |
| | | var r = args[0]; |
| | | var g = args[1]; |
| | | var b = args[2]; // we use the extended greyscale palette here, with the exception of |
| | | // black and white. normal palette only has 4 greyscale shades. |
| | | |
| | | if (r === g && g === b) { |
| | | if (r < 8) { |
| | | return 16; |
| | | } |
| | | |
| | | if (r > 248) { |
| | | return 231; |
| | | } |
| | | |
| | | return Math.round((r - 8) / 247 * 24) + 232; |
| | | } |
| | | |
| | | var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5); |
| | | return ansi; |
| | | }; |
| | | |
| | | convert.ansi16.rgb = function (args) { |
| | | var color = args % 10; // handle greyscale |
| | | |
| | | if (color === 0 || color === 7) { |
| | | if (args > 50) { |
| | | color += 3.5; |
| | | } |
| | | |
| | | color = color / 10.5 * 255; |
| | | return [color, color, color]; |
| | | } |
| | | |
| | | var mult = (~~(args > 50) + 1) * 0.5; |
| | | var r = (color & 1) * mult * 255; |
| | | var g = (color >> 1 & 1) * mult * 255; |
| | | var b = (color >> 2 & 1) * mult * 255; |
| | | return [r, g, b]; |
| | | }; |
| | | |
| | | convert.ansi256.rgb = function (args) { |
| | | // handle greyscale |
| | | if (args >= 232) { |
| | | var c = (args - 232) * 10 + 8; |
| | | return [c, c, c]; |
| | | } |
| | | |
| | | args -= 16; |
| | | var rem; |
| | | var r = Math.floor(args / 36) / 5 * 255; |
| | | var g = Math.floor((rem = args % 36) / 6) / 5 * 255; |
| | | var b = rem % 6 / 5 * 255; |
| | | return [r, g, b]; |
| | | }; |
| | | |
| | | convert.rgb.hex = function (args) { |
| | | var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF); |
| | | var string = integer.toString(16).toUpperCase(); |
| | | return '000000'.substring(string.length) + string; |
| | | }; |
| | | |
| | | convert.hex.rgb = function (args) { |
| | | var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); |
| | | |
| | | if (!match) { |
| | | return [0, 0, 0]; |
| | | } |
| | | |
| | | var colorString = match[0]; |
| | | |
| | | if (match[0].length === 3) { |
| | | colorString = colorString.split('').map(function (char) { |
| | | return char + char; |
| | | }).join(''); |
| | | } |
| | | |
| | | var integer = parseInt(colorString, 16); |
| | | var r = integer >> 16 & 0xFF; |
| | | var g = integer >> 8 & 0xFF; |
| | | var b = integer & 0xFF; |
| | | return [r, g, b]; |
| | | }; |
| | | |
| | | convert.rgb.hcg = function (rgb) { |
| | | var r = rgb[0] / 255; |
| | | var g = rgb[1] / 255; |
| | | var b = rgb[2] / 255; |
| | | var max = Math.max(Math.max(r, g), b); |
| | | var min = Math.min(Math.min(r, g), b); |
| | | var chroma = max - min; |
| | | var grayscale; |
| | | var hue; |
| | | |
| | | if (chroma < 1) { |
| | | grayscale = min / (1 - chroma); |
| | | } else { |
| | | grayscale = 0; |
| | | } |
| | | |
| | | if (chroma <= 0) { |
| | | hue = 0; |
| | | } else if (max === r) { |
| | | hue = (g - b) / chroma % 6; |
| | | } else if (max === g) { |
| | | hue = 2 + (b - r) / chroma; |
| | | } else { |
| | | hue = 4 + (r - g) / chroma + 4; |
| | | } |
| | | |
| | | hue /= 6; |
| | | hue %= 1; |
| | | return [hue * 360, chroma * 100, grayscale * 100]; |
| | | }; |
| | | |
| | | convert.hsl.hcg = function (hsl) { |
| | | var s = hsl[1] / 100; |
| | | var l = hsl[2] / 100; |
| | | var c = 1; |
| | | var f = 0; |
| | | |
| | | if (l < 0.5) { |
| | | c = 2.0 * s * l; |
| | | } else { |
| | | c = 2.0 * s * (1.0 - l); |
| | | } |
| | | |
| | | if (c < 1.0) { |
| | | f = (l - 0.5 * c) / (1.0 - c); |
| | | } |
| | | |
| | | return [hsl[0], c * 100, f * 100]; |
| | | }; |
| | | |
| | | convert.hsv.hcg = function (hsv) { |
| | | var s = hsv[1] / 100; |
| | | var v = hsv[2] / 100; |
| | | var c = s * v; |
| | | var f = 0; |
| | | |
| | | if (c < 1.0) { |
| | | f = (v - c) / (1 - c); |
| | | } |
| | | |
| | | return [hsv[0], c * 100, f * 100]; |
| | | }; |
| | | |
| | | convert.hcg.rgb = function (hcg) { |
| | | var h = hcg[0] / 360; |
| | | var c = hcg[1] / 100; |
| | | var g = hcg[2] / 100; |
| | | |
| | | if (c === 0.0) { |
| | | return [g * 255, g * 255, g * 255]; |
| | | } |
| | | |
| | | var pure = [0, 0, 0]; |
| | | var hi = h % 1 * 6; |
| | | var v = hi % 1; |
| | | var w = 1 - v; |
| | | var mg = 0; |
| | | |
| | | switch (Math.floor(hi)) { |
| | | case 0: |
| | | pure[0] = 1; |
| | | pure[1] = v; |
| | | pure[2] = 0; |
| | | break; |
| | | |
| | | case 1: |
| | | pure[0] = w; |
| | | pure[1] = 1; |
| | | pure[2] = 0; |
| | | break; |
| | | |
| | | case 2: |
| | | pure[0] = 0; |
| | | pure[1] = 1; |
| | | pure[2] = v; |
| | | break; |
| | | |
| | | case 3: |
| | | pure[0] = 0; |
| | | pure[1] = w; |
| | | pure[2] = 1; |
| | | break; |
| | | |
| | | case 4: |
| | | pure[0] = v; |
| | | pure[1] = 0; |
| | | pure[2] = 1; |
| | | break; |
| | | |
| | | default: |
| | | pure[0] = 1; |
| | | pure[1] = 0; |
| | | pure[2] = w; |
| | | } |
| | | |
| | | mg = (1.0 - c) * g; |
| | | return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255]; |
| | | }; |
| | | |
| | | convert.hcg.hsv = function (hcg) { |
| | | var c = hcg[1] / 100; |
| | | var g = hcg[2] / 100; |
| | | var v = c + g * (1.0 - c); |
| | | var f = 0; |
| | | |
| | | if (v > 0.0) { |
| | | f = c / v; |
| | | } |
| | | |
| | | return [hcg[0], f * 100, v * 100]; |
| | | }; |
| | | |
| | | convert.hcg.hsl = function (hcg) { |
| | | var c = hcg[1] / 100; |
| | | var g = hcg[2] / 100; |
| | | var l = g * (1.0 - c) + 0.5 * c; |
| | | var s = 0; |
| | | |
| | | if (l > 0.0 && l < 0.5) { |
| | | s = c / (2 * l); |
| | | } else if (l >= 0.5 && l < 1.0) { |
| | | s = c / (2 * (1 - l)); |
| | | } |
| | | |
| | | return [hcg[0], s * 100, l * 100]; |
| | | }; |
| | | |
| | | convert.hcg.hwb = function (hcg) { |
| | | var c = hcg[1] / 100; |
| | | var g = hcg[2] / 100; |
| | | var v = c + g * (1.0 - c); |
| | | return [hcg[0], (v - c) * 100, (1 - v) * 100]; |
| | | }; |
| | | |
| | | convert.hwb.hcg = function (hwb) { |
| | | var w = hwb[1] / 100; |
| | | var b = hwb[2] / 100; |
| | | var v = 1 - b; |
| | | var c = v - w; |
| | | var g = 0; |
| | | |
| | | if (c < 1) { |
| | | g = (v - c) / (1 - c); |
| | | } |
| | | |
| | | return [hwb[0], c * 100, g * 100]; |
| | | }; |
| | | |
| | | convert.apple.rgb = function (apple) { |
| | | return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255]; |
| | | }; |
| | | |
| | | convert.rgb.apple = function (rgb) { |
| | | return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535]; |
| | | }; |
| | | |
| | | convert.gray.rgb = function (args) { |
| | | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; |
| | | }; |
| | | |
| | | convert.gray.hsl = convert.gray.hsv = function (args) { |
| | | return [0, 0, args[0]]; |
| | | }; |
| | | |
| | | convert.gray.hwb = function (gray) { |
| | | return [0, 100, gray[0]]; |
| | | }; |
| | | |
| | | convert.gray.cmyk = function (gray) { |
| | | return [0, 0, 0, gray[0]]; |
| | | }; |
| | | |
| | | convert.gray.lab = function (gray) { |
| | | return [gray[0], 0, 0]; |
| | | }; |
| | | |
| | | convert.gray.hex = function (gray) { |
| | | var val = Math.round(gray[0] / 100 * 255) & 0xFF; |
| | | var integer = (val << 16) + (val << 8) + val; |
| | | var string = integer.toString(16).toUpperCase(); |
| | | return '000000'.substring(string.length) + string; |
| | | }; |
| | | |
| | | convert.rgb.gray = function (rgb) { |
| | | var val = (rgb[0] + rgb[1] + rgb[2]) / 3; |
| | | return [val / 255 * 100]; |
| | | }; |
| | | }); |
| | | var conversions_1 = conversions.rgb; |
| | | var conversions_2 = conversions.hsl; |
| | | var conversions_3 = conversions.hsv; |
| | | var conversions_4 = conversions.hwb; |
| | | var conversions_5 = conversions.cmyk; |
| | | var conversions_6 = conversions.xyz; |
| | | var conversions_7 = conversions.lab; |
| | | var conversions_8 = conversions.lch; |
| | | var conversions_9 = conversions.hex; |
| | | var conversions_10 = conversions.keyword; |
| | | var conversions_11 = conversions.ansi16; |
| | | var conversions_12 = conversions.ansi256; |
| | | var conversions_13 = conversions.hcg; |
| | | var conversions_14 = conversions.apple; |
| | | var conversions_15 = conversions.gray; |
| | | |
| | | /* |
| | | this function routes a model to all other models. |
| | | |
| | | all functions that are routed have a property `.conversion` attached |
| | | to the returned synthetic function. This property is an array |
| | | of strings, each with the steps in between the 'from' and 'to' |
| | | color models (inclusive). |
| | | |
| | | conversions that are not possible simply are not included. |
| | | */ |
| | | // https://jsperf.com/object-keys-vs-for-in-with-closure/3 |
| | | |
| | | var models = Object.keys(conversions); |
| | | |
| | | function buildGraph() { |
| | | var graph = {}; |
| | | |
| | | for (var len = models.length, i = 0; i < len; i++) { |
| | | graph[models[i]] = { |
| | | // http://jsperf.com/1-vs-infinity |
| | | // micro-opt, but this is simple. |
| | | distance: -1, |
| | | parent: null |
| | | }; |
| | | } |
| | | |
| | | return graph; |
| | | } // https://en.wikipedia.org/wiki/Breadth-first_search |
| | | |
| | | |
| | | function deriveBFS(fromModel) { |
| | | var graph = buildGraph(); |
| | | var queue = [fromModel]; // unshift -> queue -> pop |
| | | |
| | | graph[fromModel].distance = 0; |
| | | |
| | | while (queue.length) { |
| | | var current = queue.pop(); |
| | | var adjacents = Object.keys(conversions[current]); |
| | | |
| | | for (var len = adjacents.length, i = 0; i < len; i++) { |
| | | var adjacent = adjacents[i]; |
| | | var node = graph[adjacent]; |
| | | |
| | | if (node.distance === -1) { |
| | | node.distance = graph[current].distance + 1; |
| | | node.parent = current; |
| | | queue.unshift(adjacent); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return graph; |
| | | } |
| | | |
| | | function link(from, to) { |
| | | return function (args) { |
| | | return to(from(args)); |
| | | }; |
| | | } |
| | | |
| | | function wrapConversion(toModel, graph) { |
| | | var path = [graph[toModel].parent, toModel]; |
| | | var fn = conversions[graph[toModel].parent][toModel]; |
| | | var cur = graph[toModel].parent; |
| | | |
| | | while (graph[cur].parent) { |
| | | path.unshift(graph[cur].parent); |
| | | fn = link(conversions[graph[cur].parent][cur], fn); |
| | | cur = graph[cur].parent; |
| | | } |
| | | |
| | | fn.conversion = path; |
| | | return fn; |
| | | } |
| | | |
| | | var route = function route(fromModel) { |
| | | var graph = deriveBFS(fromModel); |
| | | var conversion = {}; |
| | | var models = Object.keys(graph); |
| | | |
| | | for (var len = models.length, i = 0; i < len; i++) { |
| | | var toModel = models[i]; |
| | | var node = graph[toModel]; |
| | | |
| | | if (node.parent === null) { |
| | | // no possible conversion, or this node is the source model. |
| | | continue; |
| | | } |
| | | |
| | | conversion[toModel] = wrapConversion(toModel, graph); |
| | | } |
| | | |
| | | return conversion; |
| | | }; |
| | | |
| | | var convert = {}; |
| | | var models$1 = Object.keys(conversions); |
| | | |
| | | function wrapRaw(fn) { |
| | | var wrappedFn = function wrappedFn(args) { |
| | | if (args === undefined || args === null) { |
| | | return args; |
| | | } |
| | | |
| | | if (arguments.length > 1) { |
| | | args = Array.prototype.slice.call(arguments); |
| | | } |
| | | |
| | | return fn(args); |
| | | }; // preserve .conversion property if there is one |
| | | |
| | | |
| | | if ('conversion' in fn) { |
| | | wrappedFn.conversion = fn.conversion; |
| | | } |
| | | |
| | | return wrappedFn; |
| | | } |
| | | |
| | | function wrapRounded(fn) { |
| | | var wrappedFn = function wrappedFn(args) { |
| | | if (args === undefined || args === null) { |
| | | return args; |
| | | } |
| | | |
| | | if (arguments.length > 1) { |
| | | args = Array.prototype.slice.call(arguments); |
| | | } |
| | | |
| | | var result = fn(args); // we're assuming the result is an array here. |
| | | // see notice in conversions.js; don't use box types |
| | | // in conversion functions. |
| | | |
| | | if (_typeof(result) === 'object') { |
| | | for (var len = result.length, i = 0; i < len; i++) { |
| | | result[i] = Math.round(result[i]); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | }; // preserve .conversion property if there is one |
| | | |
| | | |
| | | if ('conversion' in fn) { |
| | | wrappedFn.conversion = fn.conversion; |
| | | } |
| | | |
| | | return wrappedFn; |
| | | } |
| | | |
| | | models$1.forEach(function (fromModel) { |
| | | convert[fromModel] = {}; |
| | | Object.defineProperty(convert[fromModel], 'channels', { |
| | | value: conversions[fromModel].channels |
| | | }); |
| | | Object.defineProperty(convert[fromModel], 'labels', { |
| | | value: conversions[fromModel].labels |
| | | }); |
| | | var routes = route(fromModel); |
| | | var routeModels = Object.keys(routes); |
| | | routeModels.forEach(function (toModel) { |
| | | var fn = routes[toModel]; |
| | | convert[fromModel][toModel] = wrapRounded(fn); |
| | | convert[fromModel][toModel].raw = wrapRaw(fn); |
| | | }); |
| | | }); |
| | | var colorConvert = convert; |
| | | |
| | | var ansiStyles = createCommonjsModule(function (module) { |
| | | |
| | | var wrapAnsi16 = function wrapAnsi16(fn, offset) { |
| | | return function () { |
| | | var code = fn.apply(colorConvert, arguments); |
| | | return "\x1B[".concat(code + offset, "m"); |
| | | }; |
| | | }; |
| | | |
| | | var wrapAnsi256 = function wrapAnsi256(fn, offset) { |
| | | return function () { |
| | | var code = fn.apply(colorConvert, arguments); |
| | | return "\x1B[".concat(38 + offset, ";5;").concat(code, "m"); |
| | | }; |
| | | }; |
| | | |
| | | var wrapAnsi16m = function wrapAnsi16m(fn, offset) { |
| | | return function () { |
| | | var rgb = fn.apply(colorConvert, arguments); |
| | | return "\x1B[".concat(38 + offset, ";2;").concat(rgb[0], ";").concat(rgb[1], ";").concat(rgb[2], "m"); |
| | | }; |
| | | }; |
| | | |
| | | function assembleStyles() { |
| | | var codes = new Map(); |
| | | var styles = { |
| | | modifier: { |
| | | reset: [0, 0], |
| | | // 21 isn't widely supported and 22 does the same thing |
| | | bold: [1, 22], |
| | | dim: [2, 22], |
| | | italic: [3, 23], |
| | | underline: [4, 24], |
| | | inverse: [7, 27], |
| | | hidden: [8, 28], |
| | | strikethrough: [9, 29] |
| | | }, |
| | | color: { |
| | | black: [30, 39], |
| | | red: [31, 39], |
| | | green: [32, 39], |
| | | yellow: [33, 39], |
| | | blue: [34, 39], |
| | | magenta: [35, 39], |
| | | cyan: [36, 39], |
| | | white: [37, 39], |
| | | gray: [90, 39], |
| | | // Bright color |
| | | redBright: [91, 39], |
| | | greenBright: [92, 39], |
| | | yellowBright: [93, 39], |
| | | blueBright: [94, 39], |
| | | magentaBright: [95, 39], |
| | | cyanBright: [96, 39], |
| | | whiteBright: [97, 39] |
| | | }, |
| | | bgColor: { |
| | | bgBlack: [40, 49], |
| | | bgRed: [41, 49], |
| | | bgGreen: [42, 49], |
| | | bgYellow: [43, 49], |
| | | bgBlue: [44, 49], |
| | | bgMagenta: [45, 49], |
| | | bgCyan: [46, 49], |
| | | bgWhite: [47, 49], |
| | | // Bright color |
| | | bgBlackBright: [100, 49], |
| | | bgRedBright: [101, 49], |
| | | bgGreenBright: [102, 49], |
| | | bgYellowBright: [103, 49], |
| | | bgBlueBright: [104, 49], |
| | | bgMagentaBright: [105, 49], |
| | | bgCyanBright: [106, 49], |
| | | bgWhiteBright: [107, 49] |
| | | } |
| | | }; // Fix humans |
| | | |
| | | styles.color.grey = styles.color.gray; |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(styles); _i < _Object$keys.length; _i++) { |
| | | var groupName = _Object$keys[_i]; |
| | | var group = styles[groupName]; |
| | | |
| | | for (var _i3 = 0, _Object$keys3 = Object.keys(group); _i3 < _Object$keys3.length; _i3++) { |
| | | var styleName = _Object$keys3[_i3]; |
| | | var style = group[styleName]; |
| | | styles[styleName] = { |
| | | open: "\x1B[".concat(style[0], "m"), |
| | | close: "\x1B[".concat(style[1], "m") |
| | | }; |
| | | group[styleName] = styles[styleName]; |
| | | codes.set(style[0], style[1]); |
| | | } |
| | | |
| | | Object.defineProperty(styles, groupName, { |
| | | value: group, |
| | | enumerable: false |
| | | }); |
| | | Object.defineProperty(styles, 'codes', { |
| | | value: codes, |
| | | enumerable: false |
| | | }); |
| | | } |
| | | |
| | | var ansi2ansi = function ansi2ansi(n) { |
| | | return n; |
| | | }; |
| | | |
| | | var rgb2rgb = function rgb2rgb(r, g, b) { |
| | | return [r, g, b]; |
| | | }; |
| | | |
| | | styles.color.close = "\x1B[39m"; |
| | | styles.bgColor.close = "\x1B[49m"; |
| | | styles.color.ansi = { |
| | | ansi: wrapAnsi16(ansi2ansi, 0) |
| | | }; |
| | | styles.color.ansi256 = { |
| | | ansi256: wrapAnsi256(ansi2ansi, 0) |
| | | }; |
| | | styles.color.ansi16m = { |
| | | rgb: wrapAnsi16m(rgb2rgb, 0) |
| | | }; |
| | | styles.bgColor.ansi = { |
| | | ansi: wrapAnsi16(ansi2ansi, 10) |
| | | }; |
| | | styles.bgColor.ansi256 = { |
| | | ansi256: wrapAnsi256(ansi2ansi, 10) |
| | | }; |
| | | styles.bgColor.ansi16m = { |
| | | rgb: wrapAnsi16m(rgb2rgb, 10) |
| | | }; |
| | | |
| | | for (var _i2 = 0, _Object$keys2 = Object.keys(colorConvert); _i2 < _Object$keys2.length; _i2++) { |
| | | var key = _Object$keys2[_i2]; |
| | | |
| | | if (_typeof(colorConvert[key]) !== 'object') { |
| | | continue; |
| | | } |
| | | |
| | | var suite = colorConvert[key]; |
| | | |
| | | if (key === 'ansi16') { |
| | | key = 'ansi'; |
| | | } |
| | | |
| | | if ('ansi16' in suite) { |
| | | styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); |
| | | styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); |
| | | } |
| | | |
| | | if ('ansi256' in suite) { |
| | | styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); |
| | | styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); |
| | | } |
| | | |
| | | if ('rgb' in suite) { |
| | | styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); |
| | | styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); |
| | | } |
| | | } |
| | | |
| | | return styles; |
| | | } // Make the export immutable |
| | | |
| | | |
| | | Object.defineProperty(module, 'exports', { |
| | | enumerable: true, |
| | | get: assembleStyles |
| | | }); |
| | | }); |
| | | |
| | | var require$$0$1 = { |
| | | EOL: "\n" |
| | | }; |
| | | |
| | | var hasFlag = function hasFlag(flag, argv) { |
| | | argv = argv || process.argv; |
| | | var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--'; |
| | | var pos = argv.indexOf(prefix + flag); |
| | | var terminatorPos = argv.indexOf('--'); |
| | | return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); |
| | | }; |
| | | |
| | | var env$1 = process.env; |
| | | var forceColor; |
| | | |
| | | if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { |
| | | forceColor = false; |
| | | } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { |
| | | forceColor = true; |
| | | } |
| | | |
| | | if ('FORCE_COLOR' in env$1) { |
| | | forceColor = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0; |
| | | } |
| | | |
| | | function translateLevel(level) { |
| | | if (level === 0) { |
| | | return false; |
| | | } |
| | | |
| | | return { |
| | | level: level, |
| | | hasBasic: true, |
| | | has256: level >= 2, |
| | | has16m: level >= 3 |
| | | }; |
| | | } |
| | | |
| | | function supportsColor(stream) { |
| | | if (forceColor === false) { |
| | | return 0; |
| | | } |
| | | |
| | | if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) { |
| | | return 3; |
| | | } |
| | | |
| | | if (hasFlag('color=256')) { |
| | | return 2; |
| | | } |
| | | |
| | | if (stream && !stream.isTTY && forceColor !== true) { |
| | | return 0; |
| | | } |
| | | |
| | | var min = forceColor ? 1 : 0; |
| | | |
| | | if (process.platform === 'win32') { |
| | | // Node.js 7.5.0 is the first version of Node.js to include a patch to |
| | | // libuv that enables 256 color output on Windows. Anything earlier and it |
| | | // won't work. However, here we target Node.js 8 at minimum as it is an LTS |
| | | // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows |
| | | // release that supports 256 colors. Windows 10 build 14931 is the first release |
| | | // that supports 16m/TrueColor. |
| | | var osRelease = require$$0$1.release().split('.'); |
| | | |
| | | if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { |
| | | return Number(osRelease[2]) >= 14931 ? 3 : 2; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | if ('CI' in env$1) { |
| | | if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) { |
| | | return sign in env$1; |
| | | }) || env$1.CI_NAME === 'codeship') { |
| | | return 1; |
| | | } |
| | | |
| | | return min; |
| | | } |
| | | |
| | | if ('TEAMCITY_VERSION' in env$1) { |
| | | return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0; |
| | | } |
| | | |
| | | if (env$1.COLORTERM === 'truecolor') { |
| | | return 3; |
| | | } |
| | | |
| | | if ('TERM_PROGRAM' in env$1) { |
| | | var version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10); |
| | | |
| | | switch (env$1.TERM_PROGRAM) { |
| | | case 'iTerm.app': |
| | | return version >= 3 ? 3 : 2; |
| | | |
| | | case 'Apple_Terminal': |
| | | return 2; |
| | | // No default |
| | | } |
| | | } |
| | | |
| | | if (/-256(color)?$/i.test(env$1.TERM)) { |
| | | return 2; |
| | | } |
| | | |
| | | if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) { |
| | | return 1; |
| | | } |
| | | |
| | | if ('COLORTERM' in env$1) { |
| | | return 1; |
| | | } |
| | | |
| | | if (env$1.TERM === 'dumb') { |
| | | return min; |
| | | } |
| | | |
| | | return min; |
| | | } |
| | | |
| | | function getSupportLevel(stream) { |
| | | var level = supportsColor(stream); |
| | | return translateLevel(level); |
| | | } |
| | | |
| | | var supportsColor_1 = { |
| | | supportsColor: getSupportLevel, |
| | | stdout: getSupportLevel(process.stdout), |
| | | stderr: getSupportLevel(process.stderr) |
| | | }; |
| | | |
| | | var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; |
| | | var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; |
| | | var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; |
| | | var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; |
| | | var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]); |
| | | |
| | | function unescape(c) { |
| | | if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) { |
| | | return String.fromCharCode(parseInt(c.slice(1), 16)); |
| | | } |
| | | |
| | | return ESCAPES.get(c) || c; |
| | | } |
| | | |
| | | function parseArguments(name, args) { |
| | | var results = []; |
| | | var chunks = args.trim().split(/\s*,\s*/g); |
| | | var matches; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var chunk = _step.value; |
| | | |
| | | if (!isNaN(chunk)) { |
| | | results.push(Number(chunk)); |
| | | } else if (matches = chunk.match(STRING_REGEX)) { |
| | | results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) { |
| | | return escape ? unescape(escape) : chr; |
| | | })); |
| | | } else { |
| | | throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')")); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return results; |
| | | } |
| | | |
| | | function parseStyle(style) { |
| | | STYLE_REGEX.lastIndex = 0; |
| | | var results = []; |
| | | var matches; |
| | | |
| | | while ((matches = STYLE_REGEX.exec(style)) !== null) { |
| | | var name = matches[1]; |
| | | |
| | | if (matches[2]) { |
| | | var args = parseArguments(name, matches[2]); |
| | | results.push([name].concat(args)); |
| | | } else { |
| | | results.push([name]); |
| | | } |
| | | } |
| | | |
| | | return results; |
| | | } |
| | | |
| | | function buildStyle(chalk, styles) { |
| | | var enabled = {}; |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var layer = _step2.value; |
| | | var _iteratorNormalCompletion3 = true; |
| | | var _didIteratorError3 = false; |
| | | var _iteratorError3 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
| | | var style = _step3.value; |
| | | enabled[style[0]] = layer.inverse ? null : style.slice(1); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError3 = true; |
| | | _iteratorError3 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion3 && _iterator3.return != null) { |
| | | _iterator3.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError3) { |
| | | throw _iteratorError3; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var current = chalk; |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(enabled); _i < _Object$keys.length; _i++) { |
| | | var styleName = _Object$keys[_i]; |
| | | |
| | | if (Array.isArray(enabled[styleName])) { |
| | | if (!(styleName in current)) { |
| | | throw new Error("Unknown Chalk style: ".concat(styleName)); |
| | | } |
| | | |
| | | if (enabled[styleName].length > 0) { |
| | | current = current[styleName].apply(current, enabled[styleName]); |
| | | } else { |
| | | current = current[styleName]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return current; |
| | | } |
| | | |
| | | var templates = function templates(chalk, tmp) { |
| | | var styles = []; |
| | | var chunks = []; |
| | | var chunk = []; // eslint-disable-next-line max-params |
| | | |
| | | tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) { |
| | | if (escapeChar) { |
| | | chunk.push(unescape(escapeChar)); |
| | | } else if (style) { |
| | | var str = chunk.join(''); |
| | | chunk = []; |
| | | chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); |
| | | styles.push({ |
| | | inverse: inverse, |
| | | styles: parseStyle(style) |
| | | }); |
| | | } else if (close) { |
| | | if (styles.length === 0) { |
| | | throw new Error('Found extraneous } in Chalk template literal'); |
| | | } |
| | | |
| | | chunks.push(buildStyle(chalk, styles)(chunk.join(''))); |
| | | chunk = []; |
| | | styles.pop(); |
| | | } else { |
| | | chunk.push(chr); |
| | | } |
| | | }); |
| | | chunks.push(chunk.join('')); |
| | | |
| | | if (styles.length > 0) { |
| | | var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)"); |
| | | throw new Error(errMsg); |
| | | } |
| | | |
| | | return chunks.join(''); |
| | | }; |
| | | |
| | | var chalk = createCommonjsModule(function (module) { |
| | | |
| | | var stdoutColor = supportsColor_1.stdout; |
| | | var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping |
| | | |
| | | var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such |
| | | |
| | | var skipModels = new Set(['gray']); |
| | | var styles = Object.create(null); |
| | | |
| | | function applyOptions(obj, options) { |
| | | options = options || {}; // Detect level if not set manually |
| | | |
| | | var scLevel = stdoutColor ? stdoutColor.level : 0; |
| | | obj.level = options.level === undefined ? scLevel : options.level; |
| | | obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; |
| | | } |
| | | |
| | | function Chalk(options) { |
| | | // We check for this.template here since calling `chalk.constructor()` |
| | | // by itself will have a `this` of a previously constructed chalk object |
| | | if (!this || !(this instanceof Chalk) || this.template) { |
| | | var _chalk = {}; |
| | | applyOptions(_chalk, options); |
| | | |
| | | _chalk.template = function () { |
| | | var args = [].slice.call(arguments); |
| | | return chalkTag.apply(null, [_chalk.template].concat(args)); |
| | | }; |
| | | |
| | | Object.setPrototypeOf(_chalk, Chalk.prototype); |
| | | Object.setPrototypeOf(_chalk.template, _chalk); |
| | | _chalk.template.constructor = Chalk; |
| | | return _chalk.template; |
| | | } |
| | | |
| | | applyOptions(this, options); |
| | | } // Use bright blue on Windows as the normal blue color is illegible |
| | | |
| | | |
| | | if (isSimpleWindowsTerm) { |
| | | ansiStyles.blue.open = "\x1B[94m"; |
| | | } |
| | | |
| | | var _loop = function _loop() { |
| | | var key = _Object$keys[_i]; |
| | | ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); |
| | | styles[key] = { |
| | | get: function get() { |
| | | var codes = ansiStyles[key]; |
| | | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); |
| | | } |
| | | }; |
| | | }; |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(ansiStyles); _i < _Object$keys.length; _i++) { |
| | | _loop(); |
| | | } |
| | | |
| | | styles.visible = { |
| | | get: function get() { |
| | | return build.call(this, this._styles || [], true, 'visible'); |
| | | } |
| | | }; |
| | | ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); |
| | | |
| | | var _loop2 = function _loop2() { |
| | | var model = _Object$keys2[_i2]; |
| | | |
| | | if (skipModels.has(model)) { |
| | | return "continue"; |
| | | } |
| | | |
| | | styles[model] = { |
| | | get: function get() { |
| | | var level = this.level; |
| | | return function () { |
| | | var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); |
| | | var codes = { |
| | | open: open, |
| | | close: ansiStyles.color.close, |
| | | closeRe: ansiStyles.color.closeRe |
| | | }; |
| | | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); |
| | | }; |
| | | } |
| | | }; |
| | | }; |
| | | |
| | | for (var _i2 = 0, _Object$keys2 = Object.keys(ansiStyles.color.ansi); _i2 < _Object$keys2.length; _i2++) { |
| | | var _ret = _loop2(); |
| | | |
| | | if (_ret === "continue") continue; |
| | | } |
| | | |
| | | ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); |
| | | |
| | | var _loop3 = function _loop3() { |
| | | var model = _Object$keys3[_i3]; |
| | | |
| | | if (skipModels.has(model)) { |
| | | return "continue"; |
| | | } |
| | | |
| | | var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); |
| | | styles[bgModel] = { |
| | | get: function get() { |
| | | var level = this.level; |
| | | return function () { |
| | | var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); |
| | | var codes = { |
| | | open: open, |
| | | close: ansiStyles.bgColor.close, |
| | | closeRe: ansiStyles.bgColor.closeRe |
| | | }; |
| | | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); |
| | | }; |
| | | } |
| | | }; |
| | | }; |
| | | |
| | | for (var _i3 = 0, _Object$keys3 = Object.keys(ansiStyles.bgColor.ansi); _i3 < _Object$keys3.length; _i3++) { |
| | | var _ret2 = _loop3(); |
| | | |
| | | if (_ret2 === "continue") continue; |
| | | } |
| | | |
| | | var proto = Object.defineProperties(function () {}, styles); |
| | | |
| | | function build(_styles, _empty, key) { |
| | | var builder = function builder() { |
| | | return applyStyle.apply(builder, arguments); |
| | | }; |
| | | |
| | | builder._styles = _styles; |
| | | builder._empty = _empty; |
| | | var self = this; |
| | | Object.defineProperty(builder, 'level', { |
| | | enumerable: true, |
| | | get: function get() { |
| | | return self.level; |
| | | }, |
| | | set: function set(level) { |
| | | self.level = level; |
| | | } |
| | | }); |
| | | Object.defineProperty(builder, 'enabled', { |
| | | enumerable: true, |
| | | get: function get() { |
| | | return self.enabled; |
| | | }, |
| | | set: function set(enabled) { |
| | | self.enabled = enabled; |
| | | } |
| | | }); // See below for fix regarding invisible grey/dim combination on Windows |
| | | |
| | | builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is |
| | | // no way to create a function with a different prototype |
| | | |
| | | builder.__proto__ = proto; // eslint-disable-line no-proto |
| | | |
| | | return builder; |
| | | } |
| | | |
| | | function applyStyle() { |
| | | // Support varags, but simply cast to string in case there's only one arg |
| | | var args = arguments; |
| | | var argsLen = args.length; |
| | | var str = String(arguments[0]); |
| | | |
| | | if (argsLen === 0) { |
| | | return ''; |
| | | } |
| | | |
| | | if (argsLen > 1) { |
| | | // Don't slice `arguments`, it prevents V8 optimizations |
| | | for (var a = 1; a < argsLen; a++) { |
| | | str += ' ' + args[a]; |
| | | } |
| | | } |
| | | |
| | | if (!this.enabled || this.level <= 0 || !str) { |
| | | return this._empty ? '' : str; |
| | | } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, |
| | | // see https://github.com/chalk/chalk/issues/58 |
| | | // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. |
| | | |
| | | |
| | | var originalDim = ansiStyles.dim.open; |
| | | |
| | | if (isSimpleWindowsTerm && this.hasGrey) { |
| | | ansiStyles.dim.open = ''; |
| | | } |
| | | |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var code = _step.value; |
| | | // Replace any instances already present with a re-opening code |
| | | // otherwise only the part of the string until said closing code |
| | | // will be colored, and the rest will simply be 'plain'. |
| | | str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen |
| | | // after next line to fix a bleed issue on macOS |
| | | // https://github.com/chalk/chalk/pull/92 |
| | | |
| | | str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open)); |
| | | } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue |
| | | |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | ansiStyles.dim.open = originalDim; |
| | | return str; |
| | | } |
| | | |
| | | function chalkTag(chalk, strings) { |
| | | if (!Array.isArray(strings)) { |
| | | // If chalk() was called by itself or with a string, |
| | | // return the string itself as a string. |
| | | return [].slice.call(arguments, 1).join(' '); |
| | | } |
| | | |
| | | var args = [].slice.call(arguments, 2); |
| | | var parts = [strings.raw[0]]; |
| | | |
| | | for (var i = 1; i < strings.length; i++) { |
| | | parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); |
| | | parts.push(String(strings.raw[i])); |
| | | } |
| | | |
| | | return templates(chalk, parts.join('')); |
| | | } |
| | | |
| | | Object.defineProperties(Chalk.prototype, styles); |
| | | module.exports = Chalk(); // eslint-disable-line new-cap |
| | | |
| | | module.exports.supportsColor = stdoutColor; |
| | | module.exports.default = module.exports; // For TypeScript |
| | | }); |
| | | var chalk_1 = chalk.supportsColor; |
| | | |
| | | var common = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | exports.commonDeprecatedHandler = function (keyOrPair, redirectTo, _ref) { |
| | | var descriptor = _ref.descriptor; |
| | | var messages = ["".concat(chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair)), " is deprecated")]; |
| | | |
| | | if (redirectTo) { |
| | | messages.push("we now treat it as ".concat(chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo)))); |
| | | } |
| | | |
| | | return messages.join('; ') + '.'; |
| | | }; |
| | | }); |
| | | unwrapExports(common); |
| | | var common_1 = common.commonDeprecatedHandler; |
| | | |
| | | var deprecated = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(common, exports); |
| | | }); |
| | | unwrapExports(deprecated); |
| | | |
| | | var common$1 = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | exports.commonInvalidHandler = function (key, value, utils) { |
| | | return ["Invalid ".concat(chalk.default.red(utils.descriptor.key(key)), " value."), "Expected ".concat(chalk.default.blue(utils.schemas[key].expected(utils)), ","), "but received ".concat(chalk.default.red(utils.descriptor.value(value)), ".")].join(' '); |
| | | }; |
| | | }); |
| | | unwrapExports(common$1); |
| | | var common_1$1 = common$1.commonInvalidHandler; |
| | | |
| | | var invalid = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(common$1, exports); |
| | | }); |
| | | unwrapExports(invalid); |
| | | |
| | | /* eslint-disable no-nested-ternary */ |
| | | |
| | | var arr = []; |
| | | var charCodeCache = []; |
| | | |
| | | var leven = function leven(a, b) { |
| | | if (a === b) { |
| | | return 0; |
| | | } |
| | | |
| | | var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the |
| | | // shortest & which one is the longest |
| | | |
| | | if (a.length > b.length) { |
| | | a = b; |
| | | b = swap; |
| | | } |
| | | |
| | | var aLen = a.length; |
| | | var bLen = b.length; |
| | | |
| | | if (aLen === 0) { |
| | | return bLen; |
| | | } |
| | | |
| | | if (bLen === 0) { |
| | | return aLen; |
| | | } // Performing suffix trimming: |
| | | // We can linearly drop suffix common to both strings since they |
| | | // don't increase distance at all |
| | | // Note: `~-` is the bitwise way to perform a `- 1` operation |
| | | |
| | | |
| | | while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) { |
| | | aLen--; |
| | | bLen--; |
| | | } |
| | | |
| | | if (aLen === 0) { |
| | | return bLen; |
| | | } // Performing prefix trimming |
| | | // We can linearly drop prefix common to both strings since they |
| | | // don't increase distance at all |
| | | |
| | | |
| | | var start = 0; |
| | | |
| | | while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) { |
| | | start++; |
| | | } |
| | | |
| | | aLen -= start; |
| | | bLen -= start; |
| | | |
| | | if (aLen === 0) { |
| | | return bLen; |
| | | } |
| | | |
| | | var bCharCode; |
| | | var ret; |
| | | var tmp; |
| | | var tmp2; |
| | | var i = 0; |
| | | var j = 0; |
| | | |
| | | while (i < aLen) { |
| | | charCodeCache[start + i] = a.charCodeAt(start + i); |
| | | arr[i] = ++i; |
| | | } |
| | | |
| | | while (j < bLen) { |
| | | bCharCode = b.charCodeAt(start + j); |
| | | tmp = j++; |
| | | ret = j; |
| | | |
| | | for (i = 0; i < aLen; i++) { |
| | | tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1; |
| | | tmp = arr[i]; |
| | | ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2; |
| | | } |
| | | } |
| | | |
| | | return ret; |
| | | }; |
| | | |
| | | var leven_1 = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | exports.levenUnknownHandler = function (key, value, _ref) { |
| | | var descriptor = _ref.descriptor, |
| | | logger = _ref.logger, |
| | | schemas = _ref.schemas; |
| | | var messages = ["Ignored unknown option ".concat(chalk.default.yellow(descriptor.pair({ |
| | | key: key, |
| | | value: value |
| | | })), ".")]; |
| | | var suggestion = Object.keys(schemas).sort().find(function (knownKey) { |
| | | return leven(key, knownKey) < 3; |
| | | }); |
| | | |
| | | if (suggestion) { |
| | | messages.push("Did you mean ".concat(chalk.default.blue(descriptor.key(suggestion)), "?")); |
| | | } |
| | | |
| | | logger.warn(messages.join(' ')); |
| | | }; |
| | | }); |
| | | unwrapExports(leven_1); |
| | | var leven_2 = leven_1.levenUnknownHandler; |
| | | |
| | | var unknown = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(leven_1, exports); |
| | | }); |
| | | unwrapExports(unknown); |
| | | |
| | | var handlers = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(deprecated, exports); |
| | | |
| | | tslib_1.__exportStar(invalid, exports); |
| | | |
| | | tslib_1.__exportStar(unknown, exports); |
| | | }); |
| | | unwrapExports(handlers); |
| | | |
| | | var schema = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | var HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess']; |
| | | |
| | | function createSchema(SchemaConstructor, parameters) { |
| | | var schema = new SchemaConstructor(parameters); |
| | | var subSchema = Object.create(schema); |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = HANDLER_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var handlerKey = _step.value; |
| | | |
| | | if (handlerKey in parameters) { |
| | | subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return subSchema; |
| | | } |
| | | |
| | | exports.createSchema = createSchema; |
| | | |
| | | var Schema = |
| | | /*#__PURE__*/ |
| | | function () { |
| | | function Schema(parameters) { |
| | | _classCallCheck(this, Schema); |
| | | |
| | | this.name = parameters.name; |
| | | } |
| | | |
| | | _createClass(Schema, [{ |
| | | key: "default", |
| | | value: function _default(_utils) { |
| | | return undefined; |
| | | } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length` |
| | | |
| | | }, { |
| | | key: "expected", |
| | | value: function expected(_utils) { |
| | | return 'nothing'; |
| | | } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length` |
| | | |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(_value, _utils) { |
| | | return false; |
| | | } |
| | | }, { |
| | | key: "deprecated", |
| | | value: function deprecated(_value, _utils) { |
| | | return false; |
| | | } |
| | | }, { |
| | | key: "forward", |
| | | value: function forward(_value, _utils) { |
| | | return undefined; |
| | | } |
| | | }, { |
| | | key: "redirect", |
| | | value: function redirect(_value, _utils) { |
| | | return undefined; |
| | | } |
| | | }, { |
| | | key: "overlap", |
| | | value: function overlap(currentValue, _newValue, _utils) { |
| | | return currentValue; |
| | | } |
| | | }, { |
| | | key: "preprocess", |
| | | value: function preprocess(value, _utils) { |
| | | return value; |
| | | } |
| | | }, { |
| | | key: "postprocess", |
| | | value: function postprocess(value, _utils) { |
| | | return value; |
| | | } |
| | | }], [{ |
| | | key: "create", |
| | | value: function create(parameters) { |
| | | // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863 |
| | | return createSchema(this, parameters); |
| | | } |
| | | }]); |
| | | |
| | | return Schema; |
| | | }(); |
| | | |
| | | exports.Schema = Schema; |
| | | |
| | | function normalizeHandler(handler, superSchema, handlerArgumentsLength) { |
| | | return typeof handler === 'function' ? function () { |
| | | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| | | args[_key] = arguments[_key]; |
| | | } |
| | | |
| | | return handler.apply(void 0, _toConsumableArray(args.slice(0, handlerArgumentsLength - 1)).concat([superSchema], _toConsumableArray(args.slice(handlerArgumentsLength - 1)))); |
| | | } : function () { |
| | | return handler; |
| | | }; |
| | | } |
| | | }); |
| | | unwrapExports(schema); |
| | | var schema_1 = schema.createSchema; |
| | | var schema_2 = schema.Schema; |
| | | |
| | | var alias = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var AliasSchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(AliasSchema, _schema_1$Schema); |
| | | |
| | | function AliasSchema(parameters) { |
| | | var _this; |
| | | |
| | | _classCallCheck(this, AliasSchema); |
| | | |
| | | _this = _possibleConstructorReturn(this, _getPrototypeOf(AliasSchema).call(this, parameters)); |
| | | _this._sourceName = parameters.sourceName; |
| | | return _this; |
| | | } |
| | | |
| | | _createClass(AliasSchema, [{ |
| | | key: "expected", |
| | | value: function expected(utils) { |
| | | return utils.schemas[this._sourceName].expected(utils); |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value, utils) { |
| | | return utils.schemas[this._sourceName].validate(value, utils); |
| | | } |
| | | }, { |
| | | key: "redirect", |
| | | value: function redirect(_value, _utils) { |
| | | return this._sourceName; |
| | | } |
| | | }]); |
| | | |
| | | return AliasSchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.AliasSchema = AliasSchema; |
| | | }); |
| | | unwrapExports(alias); |
| | | var alias_1 = alias.AliasSchema; |
| | | |
| | | var any = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var AnySchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(AnySchema, _schema_1$Schema); |
| | | |
| | | function AnySchema() { |
| | | _classCallCheck(this, AnySchema); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(AnySchema).apply(this, arguments)); |
| | | } |
| | | |
| | | _createClass(AnySchema, [{ |
| | | key: "expected", |
| | | value: function expected() { |
| | | return 'anything'; |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate() { |
| | | return true; |
| | | } |
| | | }]); |
| | | |
| | | return AnySchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.AnySchema = AnySchema; |
| | | }); |
| | | unwrapExports(any); |
| | | var any_1 = any.AnySchema; |
| | | |
| | | var array = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var ArraySchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(ArraySchema, _schema_1$Schema); |
| | | |
| | | function ArraySchema(_a) { |
| | | var _this; |
| | | |
| | | _classCallCheck(this, ArraySchema); |
| | | |
| | | var valueSchema = _a.valueSchema, |
| | | _a$name = _a.name, |
| | | name = _a$name === void 0 ? valueSchema.name : _a$name, |
| | | handlers = tslib_1.__rest(_a, ["valueSchema", "name"]); |
| | | |
| | | _this = _possibleConstructorReturn(this, _getPrototypeOf(ArraySchema).call(this, Object.assign({}, handlers, { |
| | | name: name |
| | | }))); |
| | | _this._valueSchema = valueSchema; |
| | | return _this; |
| | | } |
| | | |
| | | _createClass(ArraySchema, [{ |
| | | key: "expected", |
| | | value: function expected(utils) { |
| | | return "an array of ".concat(this._valueSchema.expected(utils)); |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value, utils) { |
| | | if (!Array.isArray(value)) { |
| | | return false; |
| | | } |
| | | |
| | | var invalidValues = []; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var subValue = _step.value; |
| | | var subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue); |
| | | |
| | | if (subValidateResult !== true) { |
| | | invalidValues.push(subValidateResult.value); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return invalidValues.length === 0 ? true : { |
| | | value: invalidValues |
| | | }; |
| | | } |
| | | }, { |
| | | key: "deprecated", |
| | | value: function deprecated(value, utils) { |
| | | var deprecatedResult = []; |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var subValue = _step2.value; |
| | | var subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue); |
| | | |
| | | if (subDeprecatedResult !== false) { |
| | | deprecatedResult.push.apply(deprecatedResult, _toConsumableArray(subDeprecatedResult.map(function (_ref) { |
| | | var deprecatedValue = _ref.value; |
| | | return { |
| | | value: [deprecatedValue] |
| | | }; |
| | | }))); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return deprecatedResult; |
| | | } |
| | | }, { |
| | | key: "forward", |
| | | value: function forward(value, utils) { |
| | | var forwardResult = []; |
| | | var _iteratorNormalCompletion3 = true; |
| | | var _didIteratorError3 = false; |
| | | var _iteratorError3 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator3 = value[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
| | | var subValue = _step3.value; |
| | | var subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue); |
| | | forwardResult.push.apply(forwardResult, _toConsumableArray(subForwardResult.map(wrapTransferResult))); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError3 = true; |
| | | _iteratorError3 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion3 && _iterator3.return != null) { |
| | | _iterator3.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError3) { |
| | | throw _iteratorError3; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return forwardResult; |
| | | } |
| | | }, { |
| | | key: "redirect", |
| | | value: function redirect(value, utils) { |
| | | var remain = []; |
| | | var redirect = []; |
| | | var _iteratorNormalCompletion4 = true; |
| | | var _didIteratorError4 = false; |
| | | var _iteratorError4 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator4 = value[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { |
| | | var subValue = _step4.value; |
| | | var subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue); |
| | | |
| | | if ('remain' in subRedirectResult) { |
| | | remain.push(subRedirectResult.remain); |
| | | } |
| | | |
| | | redirect.push.apply(redirect, _toConsumableArray(subRedirectResult.redirect.map(wrapTransferResult))); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError4 = true; |
| | | _iteratorError4 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion4 && _iterator4.return != null) { |
| | | _iterator4.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError4) { |
| | | throw _iteratorError4; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return remain.length === 0 ? { |
| | | redirect: redirect |
| | | } : { |
| | | redirect: redirect, |
| | | remain: remain |
| | | }; |
| | | } |
| | | }, { |
| | | key: "overlap", |
| | | value: function overlap(currentValue, newValue) { |
| | | return currentValue.concat(newValue); |
| | | } |
| | | }]); |
| | | |
| | | return ArraySchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.ArraySchema = ArraySchema; |
| | | |
| | | function wrapTransferResult(_ref2) { |
| | | var from = _ref2.from, |
| | | to = _ref2.to; |
| | | return { |
| | | from: [from], |
| | | to: to |
| | | }; |
| | | } |
| | | }); |
| | | unwrapExports(array); |
| | | var array_1 = array.ArraySchema; |
| | | |
| | | var boolean_1 = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var BooleanSchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(BooleanSchema, _schema_1$Schema); |
| | | |
| | | function BooleanSchema() { |
| | | _classCallCheck(this, BooleanSchema); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(BooleanSchema).apply(this, arguments)); |
| | | } |
| | | |
| | | _createClass(BooleanSchema, [{ |
| | | key: "expected", |
| | | value: function expected() { |
| | | return 'true or false'; |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value) { |
| | | return typeof value === 'boolean'; |
| | | } |
| | | }]); |
| | | |
| | | return BooleanSchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.BooleanSchema = BooleanSchema; |
| | | }); |
| | | unwrapExports(boolean_1); |
| | | var boolean_2 = boolean_1.BooleanSchema; |
| | | |
| | | var utils = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | function recordFromArray(array, mainKey) { |
| | | var record = Object.create(null); |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var value = _step.value; |
| | | var key = value[mainKey]; // istanbul ignore next |
| | | |
| | | if (record[key]) { |
| | | throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key))); |
| | | } // @ts-ignore |
| | | |
| | | |
| | | record[key] = value; |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return record; |
| | | } |
| | | |
| | | exports.recordFromArray = recordFromArray; |
| | | |
| | | function mapFromArray(array, mainKey) { |
| | | var map = new Map(); |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = array[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var value = _step2.value; |
| | | var key = value[mainKey]; // istanbul ignore next |
| | | |
| | | if (map.has(key)) { |
| | | throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key))); |
| | | } |
| | | |
| | | map.set(key, value); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | exports.mapFromArray = mapFromArray; |
| | | |
| | | function createAutoChecklist() { |
| | | var map = Object.create(null); |
| | | return function (id) { |
| | | var idString = JSON.stringify(id); |
| | | |
| | | if (map[idString]) { |
| | | return true; |
| | | } |
| | | |
| | | map[idString] = true; |
| | | return false; |
| | | }; |
| | | } |
| | | |
| | | exports.createAutoChecklist = createAutoChecklist; |
| | | |
| | | function partition(array, predicate) { |
| | | var trueArray = []; |
| | | var falseArray = []; |
| | | var _iteratorNormalCompletion3 = true; |
| | | var _didIteratorError3 = false; |
| | | var _iteratorError3 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator3 = array[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
| | | var value = _step3.value; |
| | | |
| | | if (predicate(value)) { |
| | | trueArray.push(value); |
| | | } else { |
| | | falseArray.push(value); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError3 = true; |
| | | _iteratorError3 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion3 && _iterator3.return != null) { |
| | | _iterator3.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError3) { |
| | | throw _iteratorError3; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return [trueArray, falseArray]; |
| | | } |
| | | |
| | | exports.partition = partition; |
| | | |
| | | function isInt(value) { |
| | | return value === Math.floor(value); |
| | | } |
| | | |
| | | exports.isInt = isInt; |
| | | |
| | | function comparePrimitive(a, b) { |
| | | if (a === b) { |
| | | return 0; |
| | | } |
| | | |
| | | var typeofA = _typeof(a); |
| | | |
| | | var typeofB = _typeof(b); |
| | | |
| | | var orders = ['undefined', 'object', 'boolean', 'number', 'string']; |
| | | |
| | | if (typeofA !== typeofB) { |
| | | return orders.indexOf(typeofA) - orders.indexOf(typeofB); |
| | | } |
| | | |
| | | if (typeofA !== 'string') { |
| | | return Number(a) - Number(b); |
| | | } |
| | | |
| | | return a.localeCompare(b); |
| | | } |
| | | |
| | | exports.comparePrimitive = comparePrimitive; |
| | | |
| | | function normalizeDefaultResult(result) { |
| | | return result === undefined ? {} : result; |
| | | } |
| | | |
| | | exports.normalizeDefaultResult = normalizeDefaultResult; |
| | | |
| | | function normalizeValidateResult(result, value) { |
| | | return result === true ? true : result === false ? { |
| | | value: value |
| | | } : result; |
| | | } |
| | | |
| | | exports.normalizeValidateResult = normalizeValidateResult; |
| | | |
| | | function normalizeDeprecatedResult(result, value) { |
| | | var doNotNormalizeTrue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| | | return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{ |
| | | value: value |
| | | }] : 'value' in result ? [result] : result.length === 0 ? false : result; |
| | | } |
| | | |
| | | exports.normalizeDeprecatedResult = normalizeDeprecatedResult; |
| | | |
| | | function normalizeTransferResult(result, value) { |
| | | return typeof result === 'string' || 'key' in result ? { |
| | | from: value, |
| | | to: result |
| | | } : 'from' in result ? { |
| | | from: result.from, |
| | | to: result.to |
| | | } : { |
| | | from: value, |
| | | to: result.to |
| | | }; |
| | | } |
| | | |
| | | exports.normalizeTransferResult = normalizeTransferResult; |
| | | |
| | | function normalizeForwardResult(result, value) { |
| | | return result === undefined ? [] : Array.isArray(result) ? result.map(function (transferResult) { |
| | | return normalizeTransferResult(transferResult, value); |
| | | }) : [normalizeTransferResult(result, value)]; |
| | | } |
| | | |
| | | exports.normalizeForwardResult = normalizeForwardResult; |
| | | |
| | | function normalizeRedirectResult(result, value) { |
| | | var redirect = normalizeForwardResult(_typeof(result) === 'object' && 'redirect' in result ? result.redirect : result, value); |
| | | return redirect.length === 0 ? { |
| | | remain: value, |
| | | redirect: redirect |
| | | } : _typeof(result) === 'object' && 'remain' in result ? { |
| | | remain: result.remain, |
| | | redirect: redirect |
| | | } : { |
| | | redirect: redirect |
| | | }; |
| | | } |
| | | |
| | | exports.normalizeRedirectResult = normalizeRedirectResult; |
| | | }); |
| | | unwrapExports(utils); |
| | | var utils_1 = utils.recordFromArray; |
| | | var utils_2 = utils.mapFromArray; |
| | | var utils_3 = utils.createAutoChecklist; |
| | | var utils_4 = utils.partition; |
| | | var utils_5 = utils.isInt; |
| | | var utils_6 = utils.comparePrimitive; |
| | | var utils_7 = utils.normalizeDefaultResult; |
| | | var utils_8 = utils.normalizeValidateResult; |
| | | var utils_9 = utils.normalizeDeprecatedResult; |
| | | var utils_10 = utils.normalizeTransferResult; |
| | | var utils_11 = utils.normalizeForwardResult; |
| | | var utils_12 = utils.normalizeRedirectResult; |
| | | |
| | | var choice = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var ChoiceSchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(ChoiceSchema, _schema_1$Schema); |
| | | |
| | | function ChoiceSchema(parameters) { |
| | | var _this; |
| | | |
| | | _classCallCheck(this, ChoiceSchema); |
| | | |
| | | _this = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceSchema).call(this, parameters)); |
| | | _this._choices = utils.mapFromArray(parameters.choices.map(function (choice) { |
| | | return choice && _typeof(choice) === 'object' ? choice : { |
| | | value: choice |
| | | }; |
| | | }), 'value'); |
| | | return _this; |
| | | } |
| | | |
| | | _createClass(ChoiceSchema, [{ |
| | | key: "expected", |
| | | value: function expected(_ref) { |
| | | var _this2 = this; |
| | | |
| | | var descriptor = _ref.descriptor; |
| | | var choiceValues = Array.from(this._choices.keys()).map(function (value) { |
| | | return _this2._choices.get(value); |
| | | }).filter(function (choiceInfo) { |
| | | return !choiceInfo.deprecated; |
| | | }).map(function (choiceInfo) { |
| | | return choiceInfo.value; |
| | | }).sort(utils.comparePrimitive).map(descriptor.value); |
| | | var head = choiceValues.slice(0, -2); |
| | | var tail = choiceValues.slice(-2); |
| | | return head.concat(tail.join(' or ')).join(', '); |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value) { |
| | | return this._choices.has(value); |
| | | } |
| | | }, { |
| | | key: "deprecated", |
| | | value: function deprecated(value) { |
| | | var choiceInfo = this._choices.get(value); |
| | | |
| | | return choiceInfo && choiceInfo.deprecated ? { |
| | | value: value |
| | | } : false; |
| | | } |
| | | }, { |
| | | key: "forward", |
| | | value: function forward(value) { |
| | | var choiceInfo = this._choices.get(value); |
| | | |
| | | return choiceInfo ? choiceInfo.forward : undefined; |
| | | } |
| | | }, { |
| | | key: "redirect", |
| | | value: function redirect(value) { |
| | | var choiceInfo = this._choices.get(value); |
| | | |
| | | return choiceInfo ? choiceInfo.redirect : undefined; |
| | | } |
| | | }]); |
| | | |
| | | return ChoiceSchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.ChoiceSchema = ChoiceSchema; |
| | | }); |
| | | unwrapExports(choice); |
| | | var choice_1 = choice.ChoiceSchema; |
| | | |
| | | var number = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var NumberSchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(NumberSchema, _schema_1$Schema); |
| | | |
| | | function NumberSchema() { |
| | | _classCallCheck(this, NumberSchema); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(NumberSchema).apply(this, arguments)); |
| | | } |
| | | |
| | | _createClass(NumberSchema, [{ |
| | | key: "expected", |
| | | value: function expected() { |
| | | return 'a number'; |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value, _utils) { |
| | | return typeof value === 'number'; |
| | | } |
| | | }]); |
| | | |
| | | return NumberSchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.NumberSchema = NumberSchema; |
| | | }); |
| | | unwrapExports(number); |
| | | var number_1 = number.NumberSchema; |
| | | |
| | | var integer = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var IntegerSchema = |
| | | /*#__PURE__*/ |
| | | function (_number_1$NumberSchem) { |
| | | _inherits(IntegerSchema, _number_1$NumberSchem); |
| | | |
| | | function IntegerSchema() { |
| | | _classCallCheck(this, IntegerSchema); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(IntegerSchema).apply(this, arguments)); |
| | | } |
| | | |
| | | _createClass(IntegerSchema, [{ |
| | | key: "expected", |
| | | value: function expected() { |
| | | return 'an integer'; |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value, utils$1) { |
| | | return utils$1.normalizeValidateResult(_get(_getPrototypeOf(IntegerSchema.prototype), "validate", this).call(this, value, utils$1), value) === true && utils.isInt(value); |
| | | } |
| | | }]); |
| | | |
| | | return IntegerSchema; |
| | | }(number.NumberSchema); |
| | | |
| | | exports.IntegerSchema = IntegerSchema; |
| | | }); |
| | | unwrapExports(integer); |
| | | var integer_1 = integer.IntegerSchema; |
| | | |
| | | var string = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | var StringSchema = |
| | | /*#__PURE__*/ |
| | | function (_schema_1$Schema) { |
| | | _inherits(StringSchema, _schema_1$Schema); |
| | | |
| | | function StringSchema() { |
| | | _classCallCheck(this, StringSchema); |
| | | |
| | | return _possibleConstructorReturn(this, _getPrototypeOf(StringSchema).apply(this, arguments)); |
| | | } |
| | | |
| | | _createClass(StringSchema, [{ |
| | | key: "expected", |
| | | value: function expected() { |
| | | return 'a string'; |
| | | } |
| | | }, { |
| | | key: "validate", |
| | | value: function validate(value) { |
| | | return typeof value === 'string'; |
| | | } |
| | | }]); |
| | | |
| | | return StringSchema; |
| | | }(schema.Schema); |
| | | |
| | | exports.StringSchema = StringSchema; |
| | | }); |
| | | unwrapExports(string); |
| | | var string_1 = string.StringSchema; |
| | | |
| | | var schemas = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(alias, exports); |
| | | |
| | | tslib_1.__exportStar(any, exports); |
| | | |
| | | tslib_1.__exportStar(array, exports); |
| | | |
| | | tslib_1.__exportStar(boolean_1, exports); |
| | | |
| | | tslib_1.__exportStar(choice, exports); |
| | | |
| | | tslib_1.__exportStar(integer, exports); |
| | | |
| | | tslib_1.__exportStar(number, exports); |
| | | |
| | | tslib_1.__exportStar(string, exports); |
| | | }); |
| | | unwrapExports(schemas); |
| | | |
| | | var defaults = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.defaultDescriptor = api.apiDescriptor; |
| | | exports.defaultUnknownHandler = leven_1.levenUnknownHandler; |
| | | exports.defaultInvalidHandler = invalid.commonInvalidHandler; |
| | | exports.defaultDeprecatedHandler = common.commonDeprecatedHandler; |
| | | }); |
| | | unwrapExports(defaults); |
| | | var defaults_1 = defaults.defaultDescriptor; |
| | | var defaults_2 = defaults.defaultUnknownHandler; |
| | | var defaults_3 = defaults.defaultInvalidHandler; |
| | | var defaults_4 = defaults.defaultDeprecatedHandler; |
| | | |
| | | var normalize = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | exports.normalize = function (options, schemas, opts) { |
| | | return new Normalizer(schemas, opts).normalize(options); |
| | | }; |
| | | |
| | | var Normalizer = |
| | | /*#__PURE__*/ |
| | | function () { |
| | | function Normalizer(schemas, opts) { |
| | | _classCallCheck(this, Normalizer); |
| | | |
| | | // istanbul ignore next |
| | | var _ref = opts || {}, |
| | | _ref$logger = _ref.logger, |
| | | logger = _ref$logger === void 0 ? console : _ref$logger, |
| | | _ref$descriptor = _ref.descriptor, |
| | | descriptor = _ref$descriptor === void 0 ? defaults.defaultDescriptor : _ref$descriptor, |
| | | _ref$unknown = _ref.unknown, |
| | | unknown = _ref$unknown === void 0 ? defaults.defaultUnknownHandler : _ref$unknown, |
| | | _ref$invalid = _ref.invalid, |
| | | invalid = _ref$invalid === void 0 ? defaults.defaultInvalidHandler : _ref$invalid, |
| | | _ref$deprecated = _ref.deprecated, |
| | | deprecated = _ref$deprecated === void 0 ? defaults.defaultDeprecatedHandler : _ref$deprecated; |
| | | |
| | | this._utils = { |
| | | descriptor: descriptor, |
| | | logger: |
| | | /* istanbul ignore next */ |
| | | logger || { |
| | | warn: function warn() {} |
| | | }, |
| | | schemas: utils.recordFromArray(schemas, 'name'), |
| | | normalizeDefaultResult: utils.normalizeDefaultResult, |
| | | normalizeDeprecatedResult: utils.normalizeDeprecatedResult, |
| | | normalizeForwardResult: utils.normalizeForwardResult, |
| | | normalizeRedirectResult: utils.normalizeRedirectResult, |
| | | normalizeValidateResult: utils.normalizeValidateResult |
| | | }; |
| | | this._unknownHandler = unknown; |
| | | this._invalidHandler = invalid; |
| | | this._deprecatedHandler = deprecated; |
| | | this.cleanHistory(); |
| | | } |
| | | |
| | | _createClass(Normalizer, [{ |
| | | key: "cleanHistory", |
| | | value: function cleanHistory() { |
| | | this._hasDeprecationWarned = utils.createAutoChecklist(); |
| | | } |
| | | }, { |
| | | key: "normalize", |
| | | value: function normalize(options) { |
| | | var _this = this; |
| | | |
| | | var normalized = {}; |
| | | var restOptionsArray = [options]; |
| | | |
| | | var applyNormalization = function applyNormalization() { |
| | | while (restOptionsArray.length !== 0) { |
| | | var currentOptions = restOptionsArray.shift(); |
| | | |
| | | var transferredOptionsArray = _this._applyNormalization(currentOptions, normalized); |
| | | |
| | | restOptionsArray.push.apply(restOptionsArray, _toConsumableArray(transferredOptionsArray)); |
| | | } |
| | | }; |
| | | |
| | | applyNormalization(); |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(this._utils.schemas); _i < _Object$keys.length; _i++) { |
| | | var key = _Object$keys[_i]; |
| | | var schema = this._utils.schemas[key]; |
| | | |
| | | if (!(key in normalized)) { |
| | | var defaultResult = utils.normalizeDefaultResult(schema.default(this._utils)); |
| | | |
| | | if ('value' in defaultResult) { |
| | | restOptionsArray.push(_defineProperty({}, key, defaultResult.value)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | applyNormalization(); |
| | | |
| | | for (var _i2 = 0, _Object$keys2 = Object.keys(this._utils.schemas); _i2 < _Object$keys2.length; _i2++) { |
| | | var _key = _Object$keys2[_i2]; |
| | | var _schema = this._utils.schemas[_key]; |
| | | |
| | | if (_key in normalized) { |
| | | normalized[_key] = _schema.postprocess(normalized[_key], this._utils); |
| | | } |
| | | } |
| | | |
| | | return normalized; |
| | | } |
| | | }, { |
| | | key: "_applyNormalization", |
| | | value: function _applyNormalization(options, normalized) { |
| | | var _this2 = this; |
| | | |
| | | var transferredOptionsArray = []; |
| | | |
| | | var _utils_1$partition = utils.partition(Object.keys(options), function (key) { |
| | | return key in _this2._utils.schemas; |
| | | }), |
| | | _utils_1$partition2 = _slicedToArray(_utils_1$partition, 2), |
| | | knownOptionNames = _utils_1$partition2[0], |
| | | unknownOptionNames = _utils_1$partition2[1]; |
| | | |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | var _loop = function _loop() { |
| | | var key = _step.value; |
| | | var schema = _this2._utils.schemas[key]; |
| | | var value = schema.preprocess(options[key], _this2._utils); |
| | | var validateResult = utils.normalizeValidateResult(schema.validate(value, _this2._utils), value); |
| | | |
| | | if (validateResult !== true) { |
| | | var invalidValue = validateResult.value; |
| | | |
| | | var errorMessageOrError = _this2._invalidHandler(key, invalidValue, _this2._utils); |
| | | |
| | | throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) : |
| | | /* istanbul ignore next*/ |
| | | errorMessageOrError; |
| | | } |
| | | |
| | | var appendTransferredOptions = function appendTransferredOptions(_ref2) { |
| | | var from = _ref2.from, |
| | | to = _ref2.to; |
| | | transferredOptionsArray.push(typeof to === 'string' ? _defineProperty({}, to, from) : _defineProperty({}, to.key, to.value)); |
| | | }; |
| | | |
| | | var warnDeprecated = function warnDeprecated(_ref5) { |
| | | var currentValue = _ref5.value, |
| | | redirectTo = _ref5.redirectTo; |
| | | var deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, _this2._utils), value, |
| | | /* doNotNormalizeTrue */ |
| | | true); |
| | | |
| | | if (deprecatedResult === false) { |
| | | return; |
| | | } |
| | | |
| | | if (deprecatedResult === true) { |
| | | if (!_this2._hasDeprecationWarned(key)) { |
| | | _this2._utils.logger.warn(_this2._deprecatedHandler(key, redirectTo, _this2._utils)); |
| | | } |
| | | } else { |
| | | var _iteratorNormalCompletion3 = true; |
| | | var _didIteratorError3 = false; |
| | | var _iteratorError3 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator3 = deprecatedResult[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
| | | var deprecatedValue = _step3.value.value; |
| | | var pair = { |
| | | key: key, |
| | | value: deprecatedValue |
| | | }; |
| | | |
| | | if (!_this2._hasDeprecationWarned(pair)) { |
| | | var redirectToPair = typeof redirectTo === 'string' ? { |
| | | key: redirectTo, |
| | | value: deprecatedValue |
| | | } : redirectTo; |
| | | |
| | | _this2._utils.logger.warn(_this2._deprecatedHandler(pair, redirectToPair, _this2._utils)); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError3 = true; |
| | | _iteratorError3 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion3 && _iterator3.return != null) { |
| | | _iterator3.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError3) { |
| | | throw _iteratorError3; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var forwardResult = utils.normalizeForwardResult(schema.forward(value, _this2._utils), value); |
| | | forwardResult.forEach(appendTransferredOptions); |
| | | var redirectResult = utils.normalizeRedirectResult(schema.redirect(value, _this2._utils), value); |
| | | redirectResult.redirect.forEach(appendTransferredOptions); |
| | | |
| | | if ('remain' in redirectResult) { |
| | | var remainingValue = redirectResult.remain; |
| | | normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, _this2._utils) : remainingValue; |
| | | warnDeprecated({ |
| | | value: remainingValue |
| | | }); |
| | | } |
| | | |
| | | var _iteratorNormalCompletion4 = true; |
| | | var _didIteratorError4 = false; |
| | | var _iteratorError4 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator4 = redirectResult.redirect[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { |
| | | var _step4$value = _step4.value, |
| | | from = _step4$value.from, |
| | | to = _step4$value.to; |
| | | warnDeprecated({ |
| | | value: from, |
| | | redirectTo: to |
| | | }); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError4 = true; |
| | | _iteratorError4 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion4 && _iterator4.return != null) { |
| | | _iterator4.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError4) { |
| | | throw _iteratorError4; |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | for (var _iterator = knownOptionNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | _loop(); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = unknownOptionNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var key = _step2.value; |
| | | var value = options[key]; |
| | | |
| | | var unknownResult = this._unknownHandler(key, value, this._utils); |
| | | |
| | | if (unknownResult) { |
| | | for (var _i3 = 0, _Object$keys3 = Object.keys(unknownResult); _i3 < _Object$keys3.length; _i3++) { |
| | | var unknownKey = _Object$keys3[_i3]; |
| | | |
| | | var unknownOption = _defineProperty({}, unknownKey, unknownResult[unknownKey]); |
| | | |
| | | if (unknownKey in this._utils.schemas) { |
| | | transferredOptionsArray.push(unknownOption); |
| | | } else { |
| | | Object.assign(normalized, unknownOption); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return transferredOptionsArray; |
| | | } |
| | | }]); |
| | | |
| | | return Normalizer; |
| | | }(); |
| | | |
| | | exports.Normalizer = Normalizer; |
| | | }); |
| | | unwrapExports(normalize); |
| | | var normalize_1 = normalize.normalize; |
| | | var normalize_2 = normalize.Normalizer; |
| | | |
| | | var lib = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | |
| | | tslib_1.__exportStar(descriptors, exports); |
| | | |
| | | tslib_1.__exportStar(handlers, exports); |
| | | |
| | | tslib_1.__exportStar(schemas, exports); |
| | | |
| | | tslib_1.__exportStar(normalize, exports); |
| | | |
| | | tslib_1.__exportStar(schema, exports); |
| | | }); |
| | | unwrapExports(lib); |
| | | |
| | | var array$1 = []; |
| | | var charCodeCache$1 = []; |
| | | |
| | | var leven$1 = function leven(left, right) { |
| | | if (left === right) { |
| | | return 0; |
| | | } |
| | | |
| | | var swap = left; // Swapping the strings if `a` is longer than `b` so we know which one is the |
| | | // shortest & which one is the longest |
| | | |
| | | if (left.length > right.length) { |
| | | left = right; |
| | | right = swap; |
| | | } |
| | | |
| | | var leftLength = left.length; |
| | | var rightLength = right.length; // Performing suffix trimming: |
| | | // We can linearly drop suffix common to both strings since they |
| | | // don't increase distance at all |
| | | // Note: `~-` is the bitwise way to perform a `- 1` operation |
| | | |
| | | while (leftLength > 0 && left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength)) { |
| | | leftLength--; |
| | | rightLength--; |
| | | } // Performing prefix trimming |
| | | // We can linearly drop prefix common to both strings since they |
| | | // don't increase distance at all |
| | | |
| | | |
| | | var start = 0; |
| | | |
| | | while (start < leftLength && left.charCodeAt(start) === right.charCodeAt(start)) { |
| | | start++; |
| | | } |
| | | |
| | | leftLength -= start; |
| | | rightLength -= start; |
| | | |
| | | if (leftLength === 0) { |
| | | return rightLength; |
| | | } |
| | | |
| | | var bCharCode; |
| | | var result; |
| | | var temp; |
| | | var temp2; |
| | | var i = 0; |
| | | var j = 0; |
| | | |
| | | while (i < leftLength) { |
| | | charCodeCache$1[i] = left.charCodeAt(start + i); |
| | | array$1[i] = ++i; |
| | | } |
| | | |
| | | while (j < rightLength) { |
| | | bCharCode = right.charCodeAt(start + j); |
| | | temp = j++; |
| | | result = j; |
| | | |
| | | for (i = 0; i < leftLength; i++) { |
| | | temp2 = bCharCode === charCodeCache$1[i] ? temp : temp + 1; |
| | | temp = array$1[i]; // eslint-disable-next-line no-multi-assign |
| | | |
| | | result = array$1[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | }; |
| | | |
| | | var leven_1$1 = leven$1; // TODO: Remove this for the next major release |
| | | |
| | | var default_1 = leven$1; |
| | | leven_1$1.default = default_1; |
| | | |
| | | var cliDescriptor = { |
| | | key: function key(_key) { |
| | | return _key.length === 1 ? "-".concat(_key) : "--".concat(_key); |
| | | }, |
| | | value: function value(_value) { |
| | | return lib.apiDescriptor.value(_value); |
| | | }, |
| | | pair: function pair(_ref) { |
| | | var key = _ref.key, |
| | | value = _ref.value; |
| | | return value === false ? "--no-".concat(key) : value === true ? cliDescriptor.key(key) : value === "" ? "".concat(cliDescriptor.key(key), " without an argument") : "".concat(cliDescriptor.key(key), "=").concat(value); |
| | | } |
| | | }; |
| | | |
| | | var FlagSchema = |
| | | /*#__PURE__*/ |
| | | function (_vnopts$ChoiceSchema) { |
| | | _inherits(FlagSchema, _vnopts$ChoiceSchema); |
| | | |
| | | function FlagSchema(_ref2) { |
| | | var _this; |
| | | |
| | | var name = _ref2.name, |
| | | flags = _ref2.flags; |
| | | |
| | | _classCallCheck(this, FlagSchema); |
| | | |
| | | _this = _possibleConstructorReturn(this, _getPrototypeOf(FlagSchema).call(this, { |
| | | name: name, |
| | | choices: flags |
| | | })); |
| | | _this._flags = flags.slice().sort(); |
| | | return _this; |
| | | } |
| | | |
| | | _createClass(FlagSchema, [{ |
| | | key: "preprocess", |
| | | value: function preprocess(value, utils) { |
| | | if (typeof value === "string" && value.length !== 0 && this._flags.indexOf(value) === -1) { |
| | | var suggestion = this._flags.find(function (flag) { |
| | | return leven_1$1(flag, value) < 3; |
| | | }); |
| | | |
| | | if (suggestion) { |
| | | utils.logger.warn(["Unknown flag ".concat(chalk.yellow(utils.descriptor.value(value)), ","), "did you mean ".concat(chalk.blue(utils.descriptor.value(suggestion)), "?")].join(" ")); |
| | | return suggestion; |
| | | } |
| | | } |
| | | |
| | | return value; |
| | | } |
| | | }, { |
| | | key: "expected", |
| | | value: function expected() { |
| | | return "a flag"; |
| | | } |
| | | }]); |
| | | |
| | | return FlagSchema; |
| | | }(lib.ChoiceSchema); |
| | | |
| | | var hasDeprecationWarned; |
| | | |
| | | function normalizeOptions(options, optionInfos) { |
| | | var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, |
| | | logger = _ref3.logger, |
| | | _ref3$isCLI = _ref3.isCLI, |
| | | isCLI = _ref3$isCLI === void 0 ? false : _ref3$isCLI, |
| | | _ref3$passThrough = _ref3.passThrough, |
| | | passThrough = _ref3$passThrough === void 0 ? false : _ref3$passThrough; |
| | | |
| | | var unknown = !passThrough ? lib.levenUnknownHandler : Array.isArray(passThrough) ? function (key, value) { |
| | | return passThrough.indexOf(key) === -1 ? undefined : _defineProperty({}, key, value); |
| | | } : function (key, value) { |
| | | return _defineProperty({}, key, value); |
| | | }; |
| | | var descriptor = isCLI ? cliDescriptor : lib.apiDescriptor; |
| | | var schemas = optionInfosToSchemas(optionInfos, { |
| | | isCLI: isCLI |
| | | }); |
| | | var normalizer = new lib.Normalizer(schemas, { |
| | | logger: logger, |
| | | unknown: unknown, |
| | | descriptor: descriptor |
| | | }); |
| | | var shouldSuppressDuplicateDeprecationWarnings = logger !== false; |
| | | |
| | | if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) { |
| | | normalizer._hasDeprecationWarned = hasDeprecationWarned; |
| | | } |
| | | |
| | | var normalized = normalizer.normalize(options); |
| | | |
| | | if (shouldSuppressDuplicateDeprecationWarnings) { |
| | | hasDeprecationWarned = normalizer._hasDeprecationWarned; |
| | | } |
| | | |
| | | return normalized; |
| | | } |
| | | |
| | | function optionInfosToSchemas(optionInfos, _ref6) { |
| | | var isCLI = _ref6.isCLI; |
| | | var schemas = []; |
| | | |
| | | if (isCLI) { |
| | | schemas.push(lib.AnySchema.create({ |
| | | name: "_" |
| | | })); |
| | | } |
| | | |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = optionInfos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var optionInfo = _step.value; |
| | | schemas.push(optionInfoToSchema(optionInfo, { |
| | | isCLI: isCLI, |
| | | optionInfos: optionInfos |
| | | })); |
| | | |
| | | if (optionInfo.alias && isCLI) { |
| | | schemas.push(lib.AliasSchema.create({ |
| | | name: optionInfo.alias, |
| | | sourceName: optionInfo.name |
| | | })); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return schemas; |
| | | } |
| | | |
| | | function optionInfoToSchema(optionInfo, _ref7) { |
| | | var isCLI = _ref7.isCLI, |
| | | optionInfos = _ref7.optionInfos; |
| | | var SchemaConstructor; |
| | | var parameters = { |
| | | name: optionInfo.name |
| | | }; |
| | | var handlers = {}; |
| | | |
| | | switch (optionInfo.type) { |
| | | case "int": |
| | | SchemaConstructor = lib.IntegerSchema; |
| | | |
| | | if (isCLI) { |
| | | parameters.preprocess = function (value) { |
| | | return Number(value); |
| | | }; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "string": |
| | | SchemaConstructor = lib.StringSchema; |
| | | break; |
| | | |
| | | case "choice": |
| | | SchemaConstructor = lib.ChoiceSchema; |
| | | parameters.choices = optionInfo.choices.map(function (choiceInfo) { |
| | | return _typeof(choiceInfo) === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, { |
| | | redirect: { |
| | | to: { |
| | | key: optionInfo.name, |
| | | value: choiceInfo.redirect |
| | | } |
| | | } |
| | | }) : choiceInfo; |
| | | }); |
| | | break; |
| | | |
| | | case "boolean": |
| | | SchemaConstructor = lib.BooleanSchema; |
| | | break; |
| | | |
| | | case "flag": |
| | | SchemaConstructor = FlagSchema; |
| | | parameters.flags = optionInfos.map(function (optionInfo) { |
| | | return [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? "no-".concat(optionInfo.name) : []); |
| | | }).reduce(function (a, b) { |
| | | return a.concat(b); |
| | | }, []); |
| | | break; |
| | | |
| | | case "path": |
| | | SchemaConstructor = lib.StringSchema; |
| | | break; |
| | | |
| | | default: |
| | | throw new Error("Unexpected type ".concat(optionInfo.type)); |
| | | } |
| | | |
| | | if (optionInfo.exception) { |
| | | parameters.validate = function (value, schema, utils) { |
| | | return optionInfo.exception(value) || schema.validate(value, utils); |
| | | }; |
| | | } else { |
| | | parameters.validate = function (value, schema, utils) { |
| | | return value === undefined || schema.validate(value, utils); |
| | | }; |
| | | } |
| | | |
| | | if (optionInfo.redirect) { |
| | | handlers.redirect = function (value) { |
| | | return !value ? undefined : { |
| | | to: { |
| | | key: optionInfo.redirect.option, |
| | | value: optionInfo.redirect.value |
| | | } |
| | | }; |
| | | }; |
| | | } |
| | | |
| | | if (optionInfo.deprecated) { |
| | | handlers.deprecated = true; |
| | | } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2 |
| | | |
| | | |
| | | if (isCLI && !optionInfo.array) { |
| | | var originalPreprocess = parameters.preprocess || function (x) { |
| | | return x; |
| | | }; |
| | | |
| | | parameters.preprocess = function (value, schema, utils) { |
| | | return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils); |
| | | }; |
| | | } |
| | | |
| | | return optionInfo.array ? lib.ArraySchema.create(Object.assign(isCLI ? { |
| | | preprocess: function preprocess(v) { |
| | | return [].concat(v); |
| | | } |
| | | } : {}, handlers, { |
| | | valueSchema: SchemaConstructor.create(parameters) |
| | | })) : SchemaConstructor.create(Object.assign({}, parameters, handlers)); |
| | | } |
| | | |
| | | function normalizeApiOptions(options, optionInfos, opts) { |
| | | return normalizeOptions(options, optionInfos, opts); |
| | | } |
| | | |
| | | function normalizeCliOptions(options, optionInfos, opts) { |
| | | return normalizeOptions(options, optionInfos, Object.assign({ |
| | | isCLI: true |
| | | }, opts)); |
| | | } |
| | | |
| | | var optionsNormalizer = { |
| | | normalizeApiOptions: normalizeApiOptions, |
| | | normalizeCliOptions: normalizeCliOptions |
| | | }; |
| | | |
| | | var getLast = function getLast(arr) { |
| | | return arr.length > 0 ? arr[arr.length - 1] : null; |
| | | }; |
| | | |
| | | function locStart(node, opts) { |
| | | opts = opts || {}; // Handle nodes with decorators. They should start at the first decorator |
| | | |
| | | if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) { |
| | | return locStart(node.declaration.decorators[0]); |
| | | } |
| | | |
| | | if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) { |
| | | return locStart(node.decorators[0]); |
| | | } |
| | | |
| | | if (node.__location) { |
| | | return node.__location.startOffset; |
| | | } |
| | | |
| | | if (node.range) { |
| | | return node.range[0]; |
| | | } |
| | | |
| | | if (typeof node.start === "number") { |
| | | return node.start; |
| | | } |
| | | |
| | | if (node.loc) { |
| | | return node.loc.start; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function locEnd(node) { |
| | | var endNode = node.nodes && getLast(node.nodes); |
| | | |
| | | if (endNode && node.source && !node.source.end) { |
| | | node = endNode; |
| | | } |
| | | |
| | | if (node.__location) { |
| | | return node.__location.endOffset; |
| | | } |
| | | |
| | | var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null; |
| | | |
| | | if (node.typeAnnotation) { |
| | | return Math.max(loc, locEnd(node.typeAnnotation)); |
| | | } |
| | | |
| | | if (node.loc && !loc) { |
| | | return node.loc.end; |
| | | } |
| | | |
| | | return loc; |
| | | } |
| | | |
| | | var loc = { |
| | | locStart: locStart, |
| | | locEnd: locEnd |
| | | }; |
| | | |
| | | var jsTokens = createCommonjsModule(function (module, exports) { |
| | | // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell |
| | | // License: MIT. (See LICENSE.) |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); // This regex comes from regex.coffee, and is inserted here by generate-index.js |
| | | // (run `npm run build`). |
| | | |
| | | exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; |
| | | |
| | | exports.matchToToken = function (match) { |
| | | var token = { |
| | | type: "invalid", |
| | | value: match[0], |
| | | closed: undefined |
| | | }; |
| | | if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace"; |
| | | return token; |
| | | }; |
| | | }); |
| | | unwrapExports(jsTokens); |
| | | var jsTokens_1 = jsTokens.matchToToken; |
| | | |
| | | var ast = createCommonjsModule(function (module) { |
| | | /* |
| | | Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
| | | |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions are met: |
| | | |
| | | * Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' |
| | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| | | ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
| | | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| | | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| | | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| | | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | (function () { |
| | | |
| | | function isExpression(node) { |
| | | if (node == null) { |
| | | return false; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case 'ArrayExpression': |
| | | case 'AssignmentExpression': |
| | | case 'BinaryExpression': |
| | | case 'CallExpression': |
| | | case 'ConditionalExpression': |
| | | case 'FunctionExpression': |
| | | case 'Identifier': |
| | | case 'Literal': |
| | | case 'LogicalExpression': |
| | | case 'MemberExpression': |
| | | case 'NewExpression': |
| | | case 'ObjectExpression': |
| | | case 'SequenceExpression': |
| | | case 'ThisExpression': |
| | | case 'UnaryExpression': |
| | | case 'UpdateExpression': |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isIterationStatement(node) { |
| | | if (node == null) { |
| | | return false; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case 'DoWhileStatement': |
| | | case 'ForInStatement': |
| | | case 'ForStatement': |
| | | case 'WhileStatement': |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isStatement(node) { |
| | | if (node == null) { |
| | | return false; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case 'BlockStatement': |
| | | case 'BreakStatement': |
| | | case 'ContinueStatement': |
| | | case 'DebuggerStatement': |
| | | case 'DoWhileStatement': |
| | | case 'EmptyStatement': |
| | | case 'ExpressionStatement': |
| | | case 'ForInStatement': |
| | | case 'ForStatement': |
| | | case 'IfStatement': |
| | | case 'LabeledStatement': |
| | | case 'ReturnStatement': |
| | | case 'SwitchStatement': |
| | | case 'ThrowStatement': |
| | | case 'TryStatement': |
| | | case 'VariableDeclaration': |
| | | case 'WhileStatement': |
| | | case 'WithStatement': |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isSourceElement(node) { |
| | | return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; |
| | | } |
| | | |
| | | function trailingStatement(node) { |
| | | switch (node.type) { |
| | | case 'IfStatement': |
| | | if (node.alternate != null) { |
| | | return node.alternate; |
| | | } |
| | | |
| | | return node.consequent; |
| | | |
| | | case 'LabeledStatement': |
| | | case 'ForStatement': |
| | | case 'ForInStatement': |
| | | case 'WhileStatement': |
| | | case 'WithStatement': |
| | | return node.body; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function isProblematicIfStatement(node) { |
| | | var current; |
| | | |
| | | if (node.type !== 'IfStatement') { |
| | | return false; |
| | | } |
| | | |
| | | if (node.alternate == null) { |
| | | return false; |
| | | } |
| | | |
| | | current = node.consequent; |
| | | |
| | | do { |
| | | if (current.type === 'IfStatement') { |
| | | if (current.alternate == null) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | current = trailingStatement(current); |
| | | } while (current); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | module.exports = { |
| | | isExpression: isExpression, |
| | | isStatement: isStatement, |
| | | isIterationStatement: isIterationStatement, |
| | | isSourceElement: isSourceElement, |
| | | isProblematicIfStatement: isProblematicIfStatement, |
| | | trailingStatement: trailingStatement |
| | | }; |
| | | })(); |
| | | /* vim: set sw=4 ts=4 et tw=80 : */ |
| | | |
| | | }); |
| | | var ast_1 = ast.isExpression; |
| | | var ast_2 = ast.isStatement; |
| | | var ast_3 = ast.isIterationStatement; |
| | | var ast_4 = ast.isSourceElement; |
| | | var ast_5 = ast.isProblematicIfStatement; |
| | | var ast_6 = ast.trailingStatement; |
| | | |
| | | var code = createCommonjsModule(function (module) { |
| | | /* |
| | | Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com> |
| | | Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com> |
| | | |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions are met: |
| | | |
| | | * Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| | | ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
| | | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| | | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| | | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| | | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | (function () { |
| | | |
| | | var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`. |
| | | |
| | | ES5Regex = { |
| | | // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart: |
| | | NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, |
| | | // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart: |
| | | NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/ |
| | | }; |
| | | ES6Regex = { |
| | | // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart: |
| | | NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/, |
| | | // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart: |
| | | NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ |
| | | }; |
| | | |
| | | function isDecimalDigit(ch) { |
| | | return 0x30 <= ch && ch <= 0x39; // 0..9 |
| | | } |
| | | |
| | | function isHexDigit(ch) { |
| | | return 0x30 <= ch && ch <= 0x39 || // 0..9 |
| | | 0x61 <= ch && ch <= 0x66 || // a..f |
| | | 0x41 <= ch && ch <= 0x46; // A..F |
| | | } |
| | | |
| | | function isOctalDigit(ch) { |
| | | return ch >= 0x30 && ch <= 0x37; // 0..7 |
| | | } // 7.2 White Space |
| | | |
| | | |
| | | NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF]; |
| | | |
| | | function isWhiteSpace(ch) { |
| | | return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0; |
| | | } // 7.3 Line Terminators |
| | | |
| | | |
| | | function isLineTerminator(ch) { |
| | | return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; |
| | | } // 7.6 Identifier Names and Identifiers |
| | | |
| | | |
| | | function fromCodePoint(cp) { |
| | | if (cp <= 0xFFFF) { |
| | | return String.fromCharCode(cp); |
| | | } |
| | | |
| | | var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); |
| | | var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00); |
| | | return cu1 + cu2; |
| | | } |
| | | |
| | | IDENTIFIER_START = new Array(0x80); |
| | | |
| | | for (ch = 0; ch < 0x80; ++ch) { |
| | | IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z |
| | | ch >= 0x41 && ch <= 0x5A || // A..Z |
| | | ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) |
| | | } |
| | | |
| | | IDENTIFIER_PART = new Array(0x80); |
| | | |
| | | for (ch = 0; ch < 0x80; ++ch) { |
| | | IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z |
| | | ch >= 0x41 && ch <= 0x5A || // A..Z |
| | | ch >= 0x30 && ch <= 0x39 || // 0..9 |
| | | ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) |
| | | } |
| | | |
| | | function isIdentifierStartES5(ch) { |
| | | return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); |
| | | } |
| | | |
| | | function isIdentifierPartES5(ch) { |
| | | return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); |
| | | } |
| | | |
| | | function isIdentifierStartES6(ch) { |
| | | return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); |
| | | } |
| | | |
| | | function isIdentifierPartES6(ch) { |
| | | return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); |
| | | } |
| | | |
| | | module.exports = { |
| | | isDecimalDigit: isDecimalDigit, |
| | | isHexDigit: isHexDigit, |
| | | isOctalDigit: isOctalDigit, |
| | | isWhiteSpace: isWhiteSpace, |
| | | isLineTerminator: isLineTerminator, |
| | | isIdentifierStartES5: isIdentifierStartES5, |
| | | isIdentifierPartES5: isIdentifierPartES5, |
| | | isIdentifierStartES6: isIdentifierStartES6, |
| | | isIdentifierPartES6: isIdentifierPartES6 |
| | | }; |
| | | })(); |
| | | /* vim: set sw=4 ts=4 et tw=80 : */ |
| | | |
| | | }); |
| | | var code_1 = code.isDecimalDigit; |
| | | var code_2 = code.isHexDigit; |
| | | var code_3 = code.isOctalDigit; |
| | | var code_4 = code.isWhiteSpace; |
| | | var code_5 = code.isLineTerminator; |
| | | var code_6 = code.isIdentifierStartES5; |
| | | var code_7 = code.isIdentifierPartES5; |
| | | var code_8 = code.isIdentifierStartES6; |
| | | var code_9 = code.isIdentifierPartES6; |
| | | |
| | | var keyword = createCommonjsModule(function (module) { |
| | | /* |
| | | Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
| | | |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions are met: |
| | | |
| | | * Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| | | ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
| | | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| | | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| | | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| | | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | (function () { |
| | | |
| | | var code$1 = code; |
| | | |
| | | function isStrictModeReservedWordES6(id) { |
| | | switch (id) { |
| | | case 'implements': |
| | | case 'interface': |
| | | case 'package': |
| | | case 'private': |
| | | case 'protected': |
| | | case 'public': |
| | | case 'static': |
| | | case 'let': |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function isKeywordES5(id, strict) { |
| | | // yield should not be treated as keyword under non-strict mode. |
| | | if (!strict && id === 'yield') { |
| | | return false; |
| | | } |
| | | |
| | | return isKeywordES6(id, strict); |
| | | } |
| | | |
| | | function isKeywordES6(id, strict) { |
| | | if (strict && isStrictModeReservedWordES6(id)) { |
| | | return true; |
| | | } |
| | | |
| | | switch (id.length) { |
| | | case 2: |
| | | return id === 'if' || id === 'in' || id === 'do'; |
| | | |
| | | case 3: |
| | | return id === 'var' || id === 'for' || id === 'new' || id === 'try'; |
| | | |
| | | case 4: |
| | | return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum'; |
| | | |
| | | case 5: |
| | | return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super'; |
| | | |
| | | case 6: |
| | | return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import'; |
| | | |
| | | case 7: |
| | | return id === 'default' || id === 'finally' || id === 'extends'; |
| | | |
| | | case 8: |
| | | return id === 'function' || id === 'continue' || id === 'debugger'; |
| | | |
| | | case 10: |
| | | return id === 'instanceof'; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function isReservedWordES5(id, strict) { |
| | | return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); |
| | | } |
| | | |
| | | function isReservedWordES6(id, strict) { |
| | | return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); |
| | | } |
| | | |
| | | function isRestrictedWord(id) { |
| | | return id === 'eval' || id === 'arguments'; |
| | | } |
| | | |
| | | function isIdentifierNameES5(id) { |
| | | var i, iz, ch; |
| | | |
| | | if (id.length === 0) { |
| | | return false; |
| | | } |
| | | |
| | | ch = id.charCodeAt(0); |
| | | |
| | | if (!code$1.isIdentifierStartES5(ch)) { |
| | | return false; |
| | | } |
| | | |
| | | for (i = 1, iz = id.length; i < iz; ++i) { |
| | | ch = id.charCodeAt(i); |
| | | |
| | | if (!code$1.isIdentifierPartES5(ch)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function decodeUtf16(lead, trail) { |
| | | return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; |
| | | } |
| | | |
| | | function isIdentifierNameES6(id) { |
| | | var i, iz, ch, lowCh, check; |
| | | |
| | | if (id.length === 0) { |
| | | return false; |
| | | } |
| | | |
| | | check = code$1.isIdentifierStartES6; |
| | | |
| | | for (i = 0, iz = id.length; i < iz; ++i) { |
| | | ch = id.charCodeAt(i); |
| | | |
| | | if (0xD800 <= ch && ch <= 0xDBFF) { |
| | | ++i; |
| | | |
| | | if (i >= iz) { |
| | | return false; |
| | | } |
| | | |
| | | lowCh = id.charCodeAt(i); |
| | | |
| | | if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) { |
| | | return false; |
| | | } |
| | | |
| | | ch = decodeUtf16(ch, lowCh); |
| | | } |
| | | |
| | | if (!check(ch)) { |
| | | return false; |
| | | } |
| | | |
| | | check = code$1.isIdentifierPartES6; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function isIdentifierES5(id, strict) { |
| | | return isIdentifierNameES5(id) && !isReservedWordES5(id, strict); |
| | | } |
| | | |
| | | function isIdentifierES6(id, strict) { |
| | | return isIdentifierNameES6(id) && !isReservedWordES6(id, strict); |
| | | } |
| | | |
| | | module.exports = { |
| | | isKeywordES5: isKeywordES5, |
| | | isKeywordES6: isKeywordES6, |
| | | isReservedWordES5: isReservedWordES5, |
| | | isReservedWordES6: isReservedWordES6, |
| | | isRestrictedWord: isRestrictedWord, |
| | | isIdentifierNameES5: isIdentifierNameES5, |
| | | isIdentifierNameES6: isIdentifierNameES6, |
| | | isIdentifierES5: isIdentifierES5, |
| | | isIdentifierES6: isIdentifierES6 |
| | | }; |
| | | })(); |
| | | /* vim: set sw=4 ts=4 et tw=80 : */ |
| | | |
| | | }); |
| | | var keyword_1 = keyword.isKeywordES5; |
| | | var keyword_2 = keyword.isKeywordES6; |
| | | var keyword_3 = keyword.isReservedWordES5; |
| | | var keyword_4 = keyword.isReservedWordES6; |
| | | var keyword_5 = keyword.isRestrictedWord; |
| | | var keyword_6 = keyword.isIdentifierNameES5; |
| | | var keyword_7 = keyword.isIdentifierNameES6; |
| | | var keyword_8 = keyword.isIdentifierES5; |
| | | var keyword_9 = keyword.isIdentifierES6; |
| | | |
| | | var utils$1 = createCommonjsModule(function (module, exports) { |
| | | /* |
| | | Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
| | | |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions are met: |
| | | |
| | | * Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| | | ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
| | | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| | | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| | | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| | | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | (function () { |
| | | |
| | | exports.ast = ast; |
| | | exports.code = code; |
| | | exports.keyword = keyword; |
| | | })(); |
| | | /* vim: set sw=4 ts=4 et tw=80 : */ |
| | | |
| | | }); |
| | | var utils_1$1 = utils$1.ast; |
| | | var utils_2$1 = utils$1.code; |
| | | var utils_3$1 = utils$1.keyword; |
| | | |
| | | var lib$1 = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.shouldHighlight = shouldHighlight; |
| | | exports.getChalk = getChalk; |
| | | exports.default = highlight; |
| | | |
| | | function _jsTokens() { |
| | | var data = _interopRequireWildcard(jsTokens); |
| | | |
| | | _jsTokens = function _jsTokens() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _esutils() { |
| | | var data = _interopRequireDefault(utils$1); |
| | | |
| | | _esutils = function _esutils() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _chalk() { |
| | | var data = _interopRequireDefault(chalk); |
| | | |
| | | _chalk = function _chalk() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _interopRequireDefault(obj) { |
| | | return obj && obj.__esModule ? obj : { |
| | | default: obj |
| | | }; |
| | | } |
| | | |
| | | function _interopRequireWildcard(obj) { |
| | | if (obj && obj.__esModule) { |
| | | return obj; |
| | | } else { |
| | | var newObj = {}; |
| | | |
| | | if (obj != null) { |
| | | for (var key in obj) { |
| | | if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| | | var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; |
| | | |
| | | if (desc.get || desc.set) { |
| | | Object.defineProperty(newObj, key, desc); |
| | | } else { |
| | | newObj[key] = obj[key]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | newObj.default = obj; |
| | | return newObj; |
| | | } |
| | | } |
| | | |
| | | function getDefs(chalk) { |
| | | return { |
| | | keyword: chalk.cyan, |
| | | capitalized: chalk.yellow, |
| | | jsx_tag: chalk.yellow, |
| | | punctuator: chalk.yellow, |
| | | number: chalk.magenta, |
| | | string: chalk.green, |
| | | regex: chalk.magenta, |
| | | comment: chalk.grey, |
| | | invalid: chalk.white.bgRed.bold |
| | | }; |
| | | } |
| | | |
| | | var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; |
| | | var JSX_TAG = /^[a-z][\w-]*$/i; |
| | | var BRACKET = /^[()[\]{}]$/; |
| | | |
| | | function getTokenType(match) { |
| | | var _match$slice = match.slice(-2), |
| | | _match$slice2 = _slicedToArray(_match$slice, 2), |
| | | offset = _match$slice2[0], |
| | | text = _match$slice2[1]; |
| | | |
| | | var token = (0, _jsTokens().matchToToken)(match); |
| | | |
| | | if (token.type === "name") { |
| | | if (_esutils().default.keyword.isReservedWordES6(token.value)) { |
| | | return "keyword"; |
| | | } |
| | | |
| | | if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { |
| | | return "jsx_tag"; |
| | | } |
| | | |
| | | if (token.value[0] !== token.value[0].toLowerCase()) { |
| | | return "capitalized"; |
| | | } |
| | | } |
| | | |
| | | if (token.type === "punctuator" && BRACKET.test(token.value)) { |
| | | return "bracket"; |
| | | } |
| | | |
| | | if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { |
| | | return "punctuator"; |
| | | } |
| | | |
| | | return token.type; |
| | | } |
| | | |
| | | function highlightTokens(defs, text) { |
| | | return text.replace(_jsTokens().default, function () { |
| | | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| | | args[_key] = arguments[_key]; |
| | | } |
| | | |
| | | var type = getTokenType(args); |
| | | var colorize = defs[type]; |
| | | |
| | | if (colorize) { |
| | | return args[0].split(NEWLINE).map(function (str) { |
| | | return colorize(str); |
| | | }).join("\n"); |
| | | } else { |
| | | return args[0]; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function shouldHighlight(options) { |
| | | return _chalk().default.supportsColor || options.forceColor; |
| | | } |
| | | |
| | | function getChalk(options) { |
| | | var chalk = _chalk().default; |
| | | |
| | | if (options.forceColor) { |
| | | chalk = new (_chalk().default.constructor)({ |
| | | enabled: true, |
| | | level: 1 |
| | | }); |
| | | } |
| | | |
| | | return chalk; |
| | | } |
| | | |
| | | function highlight(code) { |
| | | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| | | |
| | | if (shouldHighlight(options)) { |
| | | var chalk = getChalk(options); |
| | | var defs = getDefs(chalk); |
| | | return highlightTokens(defs, code); |
| | | } else { |
| | | return code; |
| | | } |
| | | } |
| | | }); |
| | | unwrapExports(lib$1); |
| | | var lib_1 = lib$1.shouldHighlight; |
| | | var lib_2 = lib$1.getChalk; |
| | | |
| | | var lib$2 = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.codeFrameColumns = codeFrameColumns; |
| | | exports.default = _default; |
| | | |
| | | function _highlight() { |
| | | var data = _interopRequireWildcard(lib$1); |
| | | |
| | | _highlight = function _highlight() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _interopRequireWildcard(obj) { |
| | | if (obj && obj.__esModule) { |
| | | return obj; |
| | | } else { |
| | | var newObj = {}; |
| | | |
| | | if (obj != null) { |
| | | for (var key in obj) { |
| | | if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| | | var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; |
| | | |
| | | if (desc.get || desc.set) { |
| | | Object.defineProperty(newObj, key, desc); |
| | | } else { |
| | | newObj[key] = obj[key]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | newObj.default = obj; |
| | | return newObj; |
| | | } |
| | | } |
| | | |
| | | var deprecationWarningShown = false; |
| | | |
| | | function getDefs(chalk) { |
| | | return { |
| | | gutter: chalk.grey, |
| | | marker: chalk.red.bold, |
| | | message: chalk.red.bold |
| | | }; |
| | | } |
| | | |
| | | var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; |
| | | |
| | | function getMarkerLines(loc, source, opts) { |
| | | var startLoc = Object.assign({ |
| | | column: 0, |
| | | line: -1 |
| | | }, loc.start); |
| | | var endLoc = Object.assign({}, startLoc, loc.end); |
| | | |
| | | var _ref = opts || {}, |
| | | _ref$linesAbove = _ref.linesAbove, |
| | | linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove, |
| | | _ref$linesBelow = _ref.linesBelow, |
| | | linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow; |
| | | |
| | | var startLine = startLoc.line; |
| | | var startColumn = startLoc.column; |
| | | var endLine = endLoc.line; |
| | | var endColumn = endLoc.column; |
| | | var start = Math.max(startLine - (linesAbove + 1), 0); |
| | | var end = Math.min(source.length, endLine + linesBelow); |
| | | |
| | | if (startLine === -1) { |
| | | start = 0; |
| | | } |
| | | |
| | | if (endLine === -1) { |
| | | end = source.length; |
| | | } |
| | | |
| | | var lineDiff = endLine - startLine; |
| | | var markerLines = {}; |
| | | |
| | | if (lineDiff) { |
| | | for (var i = 0; i <= lineDiff; i++) { |
| | | var lineNumber = i + startLine; |
| | | |
| | | if (!startColumn) { |
| | | markerLines[lineNumber] = true; |
| | | } else if (i === 0) { |
| | | var sourceLength = source[lineNumber - 1].length; |
| | | markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; |
| | | } else if (i === lineDiff) { |
| | | markerLines[lineNumber] = [0, endColumn]; |
| | | } else { |
| | | var _sourceLength = source[lineNumber - i].length; |
| | | markerLines[lineNumber] = [0, _sourceLength]; |
| | | } |
| | | } |
| | | } else { |
| | | if (startColumn === endColumn) { |
| | | if (startColumn) { |
| | | markerLines[startLine] = [startColumn, 0]; |
| | | } else { |
| | | markerLines[startLine] = true; |
| | | } |
| | | } else { |
| | | markerLines[startLine] = [startColumn, endColumn - startColumn]; |
| | | } |
| | | } |
| | | |
| | | return { |
| | | start: start, |
| | | end: end, |
| | | markerLines: markerLines |
| | | }; |
| | | } |
| | | |
| | | function codeFrameColumns(rawLines, loc) { |
| | | var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
| | | var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts); |
| | | var chalk = (0, _highlight().getChalk)(opts); |
| | | var defs = getDefs(chalk); |
| | | |
| | | var maybeHighlight = function maybeHighlight(chalkFn, string) { |
| | | return highlighted ? chalkFn(string) : string; |
| | | }; |
| | | |
| | | var lines = rawLines.split(NEWLINE); |
| | | |
| | | var _getMarkerLines = getMarkerLines(loc, lines, opts), |
| | | start = _getMarkerLines.start, |
| | | end = _getMarkerLines.end, |
| | | markerLines = _getMarkerLines.markerLines; |
| | | |
| | | var hasColumns = loc.start && typeof loc.start.column === "number"; |
| | | var numberMaxWidth = String(end).length; |
| | | var highlightedLines = highlighted ? (0, _highlight().default)(rawLines, opts) : rawLines; |
| | | var frame = highlightedLines.split(NEWLINE).slice(start, end).map(function (line, index) { |
| | | var number = start + 1 + index; |
| | | var paddedNumber = " ".concat(number).slice(-numberMaxWidth); |
| | | var gutter = " ".concat(paddedNumber, " | "); |
| | | var hasMarker = markerLines[number]; |
| | | var lastMarkerLine = !markerLines[number + 1]; |
| | | |
| | | if (hasMarker) { |
| | | var markerLine = ""; |
| | | |
| | | if (Array.isArray(hasMarker)) { |
| | | var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); |
| | | var numberOfMarkers = hasMarker[1] || 1; |
| | | markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); |
| | | |
| | | if (lastMarkerLine && opts.message) { |
| | | markerLine += " " + maybeHighlight(defs.message, opts.message); |
| | | } |
| | | } |
| | | |
| | | return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); |
| | | } else { |
| | | return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line); |
| | | } |
| | | }).join("\n"); |
| | | |
| | | if (opts.message && !hasColumns) { |
| | | frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame); |
| | | } |
| | | |
| | | if (highlighted) { |
| | | return chalk.reset(frame); |
| | | } else { |
| | | return frame; |
| | | } |
| | | } |
| | | |
| | | function _default(rawLines, lineNumber, colNumber) { |
| | | var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
| | | |
| | | if (!deprecationWarningShown) { |
| | | deprecationWarningShown = true; |
| | | var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; |
| | | |
| | | if (process.emitWarning) { |
| | | process.emitWarning(message, "DeprecationWarning"); |
| | | } else { |
| | | var deprecationError = new Error(message); |
| | | deprecationError.name = "DeprecationWarning"; |
| | | console.warn(new Error(message)); |
| | | } |
| | | } |
| | | |
| | | colNumber = Math.max(colNumber, 0); |
| | | var location = { |
| | | start: { |
| | | column: colNumber, |
| | | line: lineNumber |
| | | } |
| | | }; |
| | | return codeFrameColumns(rawLines, location, opts); |
| | | } |
| | | }); |
| | | unwrapExports(lib$2); |
| | | var lib_1$1 = lib$2.codeFrameColumns; |
| | | |
| | | var ConfigError$1 = errors.ConfigError; |
| | | var locStart$1 = loc.locStart, |
| | | locEnd$1 = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent |
| | | // triggering the parsers getters. |
| | | |
| | | var ownNames = Object.getOwnPropertyNames; |
| | | var ownDescriptor = Object.getOwnPropertyDescriptor; |
| | | |
| | | function getParsers(options) { |
| | | var parsers = {}; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var plugin = _step.value; |
| | | |
| | | if (!plugin.parsers) { |
| | | continue; |
| | | } |
| | | |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var name = _step2.value; |
| | | Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name)); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return parsers; |
| | | } |
| | | |
| | | function resolveParser(opts, parsers) { |
| | | parsers = parsers || getParsers(opts); |
| | | |
| | | if (typeof opts.parser === "function") { |
| | | // Custom parser API always works with JavaScript. |
| | | return { |
| | | parse: opts.parser, |
| | | astFormat: "estree", |
| | | locStart: locStart$1, |
| | | locEnd: locEnd$1 |
| | | }; |
| | | } |
| | | |
| | | if (typeof opts.parser === "string") { |
| | | if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) { |
| | | return parsers[opts.parser]; |
| | | } |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | { |
| | | throw new ConfigError$1("Couldn't resolve parser \"".concat(opts.parser, "\". Parsers must be explicitly added to the standalone bundle.")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function parse(text, opts) { |
| | | var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call |
| | | // the parsers getters when actually calling the parser `parse` function. |
| | | |
| | | var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) { |
| | | return Object.defineProperty(object, parserName, { |
| | | enumerable: true, |
| | | get: function get() { |
| | | return parsers[parserName].parse; |
| | | } |
| | | }); |
| | | }, {}); |
| | | var parser = resolveParser(opts, parsers); |
| | | |
| | | try { |
| | | if (parser.preprocess) { |
| | | text = parser.preprocess(text, opts); |
| | | } |
| | | |
| | | return { |
| | | text: text, |
| | | ast: parser.parse(text, parsersForCustomParserApi, opts) |
| | | }; |
| | | } catch (error) { |
| | | var loc = error.loc; |
| | | |
| | | if (loc) { |
| | | var codeFrame = lib$2; |
| | | error.codeFrame = codeFrame.codeFrameColumns(text, loc, { |
| | | highlightCode: true |
| | | }); |
| | | error.message += "\n" + error.codeFrame; |
| | | throw error; |
| | | } |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | throw error.stack; |
| | | } |
| | | } |
| | | |
| | | var parser = { |
| | | parse: parse, |
| | | resolveParser: resolveParser |
| | | }; |
| | | |
| | | var UndefinedParserError$1 = errors.UndefinedParserError; |
| | | var getSupportInfo$1 = support.getSupportInfo; |
| | | var resolveParser$1 = parser.resolveParser; |
| | | var hiddenDefaults = { |
| | | astFormat: "estree", |
| | | printer: {}, |
| | | originalText: undefined, |
| | | locStart: null, |
| | | locEnd: null |
| | | }; // Copy options and fill in default values. |
| | | |
| | | function normalize$1(options, opts) { |
| | | opts = opts || {}; |
| | | var rawOptions = Object.assign({}, options); |
| | | var supportOptions = getSupportInfo$1(null, { |
| | | plugins: options.plugins, |
| | | showUnreleased: true, |
| | | showDeprecated: true |
| | | }).options; |
| | | var defaults = supportOptions.reduce(function (reduced, optionInfo) { |
| | | return optionInfo.default !== undefined ? Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.default)) : reduced; |
| | | }, Object.assign({}, hiddenDefaults)); |
| | | |
| | | if (!rawOptions.parser) { |
| | | if (!rawOptions.filepath) { |
| | | var logger = opts.logger || console; |
| | | logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred."); |
| | | rawOptions.parser = "babel"; |
| | | } else { |
| | | rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins); |
| | | |
| | | if (!rawOptions.parser) { |
| | | throw new UndefinedParserError$1("No parser could be inferred for file: ".concat(rawOptions.filepath)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var parser = resolveParser$1(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) { |
| | | return x.name === "parser"; |
| | | })], { |
| | | passThrough: true, |
| | | logger: false |
| | | })); |
| | | rawOptions.astFormat = parser.astFormat; |
| | | rawOptions.locEnd = parser.locEnd; |
| | | rawOptions.locStart = parser.locStart; |
| | | var plugin = getPlugin(rawOptions); |
| | | rawOptions.printer = plugin.printers[rawOptions.astFormat]; |
| | | var pluginDefaults = supportOptions.filter(function (optionInfo) { |
| | | return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined; |
| | | }).reduce(function (reduced, optionInfo) { |
| | | return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.pluginDefaults[plugin.name])); |
| | | }, {}); |
| | | var mixedDefaults = Object.assign({}, defaults, pluginDefaults); |
| | | Object.keys(mixedDefaults).forEach(function (k) { |
| | | if (rawOptions[k] == null) { |
| | | rawOptions[k] = mixedDefaults[k]; |
| | | } |
| | | }); |
| | | |
| | | if (rawOptions.parser === "json") { |
| | | rawOptions.trailingComma = "none"; |
| | | } |
| | | |
| | | return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({ |
| | | passThrough: Object.keys(hiddenDefaults) |
| | | }, opts)); |
| | | } |
| | | |
| | | function getPlugin(options) { |
| | | var astFormat = options.astFormat; |
| | | |
| | | if (!astFormat) { |
| | | throw new Error("getPlugin() requires astFormat to be set"); |
| | | } |
| | | |
| | | var printerPlugin = options.plugins.find(function (plugin) { |
| | | return plugin.printers && plugin.printers[astFormat]; |
| | | }); |
| | | |
| | | if (!printerPlugin) { |
| | | throw new Error("Couldn't find plugin for AST format \"".concat(astFormat, "\"")); |
| | | } |
| | | |
| | | return printerPlugin; |
| | | } |
| | | |
| | | function getInterpreter(filepath) { |
| | | if (typeof filepath !== "string") { |
| | | return ""; |
| | | } |
| | | |
| | | var fd; |
| | | |
| | | try { |
| | | fd = fs.openSync(filepath, "r"); |
| | | } catch (err) { |
| | | return ""; |
| | | } |
| | | |
| | | try { |
| | | var liner = new readlines(fd); |
| | | var firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node |
| | | |
| | | var m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/); |
| | | |
| | | if (m1) { |
| | | return m1[1]; |
| | | } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node |
| | | |
| | | |
| | | var m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/); |
| | | |
| | | if (m2) { |
| | | return m2[1]; |
| | | } |
| | | |
| | | return ""; |
| | | } catch (err) { |
| | | // There are some weird cases where paths are missing, causing Jest |
| | | // failures. It's unclear what these correspond to in the real world. |
| | | return ""; |
| | | } finally { |
| | | try { |
| | | // There are some weird cases where paths are missing, causing Jest |
| | | // failures. It's unclear what these correspond to in the real world. |
| | | fs.closeSync(fd); |
| | | } catch (err) {// nop |
| | | } |
| | | } |
| | | } |
| | | |
| | | function inferParser(filepath, plugins) { |
| | | var filepathParts = normalizePath(filepath).split("/"); |
| | | var filename = filepathParts[filepathParts.length - 1].toLowerCase(); // If the file has no extension, we can try to infer the language from the |
| | | // interpreter in the shebang line, if any; but since this requires FS access, |
| | | // do it last. |
| | | |
| | | var language = getSupportInfo$1(null, { |
| | | plugins: plugins |
| | | }).languages.find(function (language) { |
| | | return language.since !== null && (language.extensions && language.extensions.some(function (extension) { |
| | | return filename.endsWith(extension); |
| | | }) || language.filenames && language.filenames.find(function (name) { |
| | | return name.toLowerCase() === filename; |
| | | }) || filename.indexOf(".") === -1 && language.interpreters && language.interpreters.indexOf(getInterpreter(filepath)) !== -1); |
| | | }); |
| | | return language && language.parsers[0]; |
| | | } |
| | | |
| | | var options$1 = { |
| | | normalize: normalize$1, |
| | | hiddenDefaults: hiddenDefaults, |
| | | inferParser: inferParser |
| | | }; |
| | | |
| | | function massageAST(ast, options, parent) { |
| | | if (Array.isArray(ast)) { |
| | | return ast.map(function (e) { |
| | | return massageAST(e, options, parent); |
| | | }).filter(function (e) { |
| | | return e; |
| | | }); |
| | | } |
| | | |
| | | if (!ast || _typeof(ast) !== "object") { |
| | | return ast; |
| | | } |
| | | |
| | | var newObj = {}; |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(ast); _i < _Object$keys.length; _i++) { |
| | | var key = _Object$keys[_i]; |
| | | |
| | | if (typeof ast[key] !== "function") { |
| | | newObj[key] = massageAST(ast[key], options, ast); |
| | | } |
| | | } |
| | | |
| | | if (options.printer.massageAstNode) { |
| | | var result = options.printer.massageAstNode(ast, newObj, parent); |
| | | |
| | | if (result === null) { |
| | | return undefined; |
| | | } |
| | | |
| | | if (result) { |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | return newObj; |
| | | } |
| | | |
| | | var massageAst = massageAST; |
| | | |
| | | function assert() {} |
| | | |
| | | assert.ok = function () {}; |
| | | |
| | | assert.strictEqual = function () {}; |
| | | |
| | | /** |
| | | * @param {Doc[]} parts |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function concat(parts) { |
| | | // access the internals of a document directly. |
| | | // if(parts.length === 1) { |
| | | // // If it's a single document, no need to concat it. |
| | | // return parts[0]; |
| | | // } |
| | | |
| | | |
| | | return { |
| | | type: "concat", |
| | | parts: parts |
| | | }; |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function indent(contents) { |
| | | |
| | | return { |
| | | type: "indent", |
| | | contents: contents |
| | | }; |
| | | } |
| | | /** |
| | | * @param {number} n |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function align(n, contents) { |
| | | |
| | | return { |
| | | type: "align", |
| | | contents: contents, |
| | | n: n |
| | | }; |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @param {object} [opts] - TBD ??? |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function group(contents, opts) { |
| | | opts = opts || {}; |
| | | |
| | | return { |
| | | type: "group", |
| | | id: opts.id, |
| | | contents: contents, |
| | | break: !!opts.shouldBreak, |
| | | expandedStates: opts.expandedStates |
| | | }; |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function dedentToRoot(contents) { |
| | | return align(-Infinity, contents); |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function markAsRoot(contents) { |
| | | // @ts-ignore - TBD ???: |
| | | return align({ |
| | | type: "root" |
| | | }, contents); |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function dedent(contents) { |
| | | return align(-1, contents); |
| | | } |
| | | /** |
| | | * @param {Doc[]} states |
| | | * @param {object} [opts] - TBD ??? |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function conditionalGroup(states, opts) { |
| | | return group(states[0], Object.assign(opts || {}, { |
| | | expandedStates: states |
| | | })); |
| | | } |
| | | /** |
| | | * @param {Doc[]} parts |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function fill(parts) { |
| | | |
| | | return { |
| | | type: "fill", |
| | | parts: parts |
| | | }; |
| | | } |
| | | /** |
| | | * @param {Doc} [breakContents] |
| | | * @param {Doc} [flatContents] |
| | | * @param {object} [opts] - TBD ??? |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function ifBreak(breakContents, flatContents, opts) { |
| | | opts = opts || {}; |
| | | |
| | | return { |
| | | type: "if-break", |
| | | breakContents: breakContents, |
| | | flatContents: flatContents, |
| | | groupId: opts.groupId |
| | | }; |
| | | } |
| | | /** |
| | | * @param {Doc} contents |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function lineSuffix(contents) { |
| | | |
| | | return { |
| | | type: "line-suffix", |
| | | contents: contents |
| | | }; |
| | | } |
| | | |
| | | var lineSuffixBoundary = { |
| | | type: "line-suffix-boundary" |
| | | }; |
| | | var breakParent = { |
| | | type: "break-parent" |
| | | }; |
| | | var trim = { |
| | | type: "trim" |
| | | }; |
| | | var line = { |
| | | type: "line" |
| | | }; |
| | | var softline = { |
| | | type: "line", |
| | | soft: true |
| | | }; |
| | | var hardline = concat([{ |
| | | type: "line", |
| | | hard: true |
| | | }, breakParent]); |
| | | var literalline = concat([{ |
| | | type: "line", |
| | | hard: true, |
| | | literal: true |
| | | }, breakParent]); |
| | | var cursor = { |
| | | type: "cursor", |
| | | placeholder: Symbol("cursor") |
| | | }; |
| | | /** |
| | | * @param {Doc} sep |
| | | * @param {Doc[]} arr |
| | | * @returns Doc |
| | | */ |
| | | |
| | | function join(sep, arr) { |
| | | var res = []; |
| | | |
| | | for (var i = 0; i < arr.length; i++) { |
| | | if (i !== 0) { |
| | | res.push(sep); |
| | | } |
| | | |
| | | res.push(arr[i]); |
| | | } |
| | | |
| | | return concat(res); |
| | | } |
| | | /** |
| | | * @param {Doc} doc |
| | | * @param {number} size |
| | | * @param {number} tabWidth |
| | | */ |
| | | |
| | | |
| | | function addAlignmentToDoc(doc, size, tabWidth) { |
| | | var aligned = doc; |
| | | |
| | | if (size > 0) { |
| | | // Use indent to add tabs for all the levels of tabs we need |
| | | for (var i = 0; i < Math.floor(size / tabWidth); ++i) { |
| | | aligned = indent(aligned); |
| | | } // Use align for all the spaces that are needed |
| | | |
| | | |
| | | aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current |
| | | // indentation, so we use -Infinity to reset the indentation to 0 |
| | | |
| | | aligned = align(-Infinity, aligned); |
| | | } |
| | | |
| | | return aligned; |
| | | } |
| | | |
| | | var docBuilders = { |
| | | concat: concat, |
| | | join: join, |
| | | line: line, |
| | | softline: softline, |
| | | hardline: hardline, |
| | | literalline: literalline, |
| | | group: group, |
| | | conditionalGroup: conditionalGroup, |
| | | fill: fill, |
| | | lineSuffix: lineSuffix, |
| | | lineSuffixBoundary: lineSuffixBoundary, |
| | | cursor: cursor, |
| | | breakParent: breakParent, |
| | | ifBreak: ifBreak, |
| | | trim: trim, |
| | | indent: indent, |
| | | align: align, |
| | | addAlignmentToDoc: addAlignmentToDoc, |
| | | markAsRoot: markAsRoot, |
| | | dedentToRoot: dedentToRoot, |
| | | dedent: dedent |
| | | }; |
| | | |
| | | var ansiRegex = function ansiRegex(options) { |
| | | options = Object.assign({ |
| | | onlyFirst: false |
| | | }, options); |
| | | var pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|'); |
| | | return new RegExp(pattern, options.onlyFirst ? undefined : 'g'); |
| | | }; |
| | | |
| | | var stripAnsi = function stripAnsi(string) { |
| | | return typeof string === 'string' ? string.replace(ansiRegex(), '') : string; |
| | | }; |
| | | |
| | | var stripAnsi_1 = stripAnsi; |
| | | var default_1$1 = stripAnsi; |
| | | stripAnsi_1.default = default_1$1; |
| | | |
| | | /* eslint-disable yoda */ |
| | | |
| | | var isFullwidthCodePoint = function isFullwidthCodePoint(codePoint) { |
| | | if (Number.isNaN(codePoint)) { |
| | | return false; |
| | | } // Code points are derived from: |
| | | // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt |
| | | |
| | | |
| | | if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo |
| | | codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET |
| | | codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET |
| | | // CJK Radicals Supplement .. Enclosed CJK Letters and Months |
| | | 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A |
| | | 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals |
| | | 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A |
| | | 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables |
| | | 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs |
| | | 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms |
| | | 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants |
| | | 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms |
| | | 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement |
| | | 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement |
| | | 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane |
| | | 0x20000 <= codePoint && codePoint <= 0x3FFFD)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | var isFullwidthCodePoint_1 = isFullwidthCodePoint; |
| | | var default_1$2 = isFullwidthCodePoint; |
| | | isFullwidthCodePoint_1.default = default_1$2; |
| | | |
| | | var emojiRegex = function emojiRegex() { |
| | | // https://mths.be/emoji |
| | | return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; |
| | | }; |
| | | |
| | | var stringWidth = function stringWidth(string) { |
| | | string = string.replace(emojiRegex(), ' '); |
| | | |
| | | if (typeof string !== 'string' || string.length === 0) { |
| | | return 0; |
| | | } |
| | | |
| | | string = stripAnsi_1(string); |
| | | var width = 0; |
| | | |
| | | for (var i = 0; i < string.length; i++) { |
| | | var code = string.codePointAt(i); // Ignore control characters |
| | | |
| | | if (code <= 0x1F || code >= 0x7F && code <= 0x9F) { |
| | | continue; |
| | | } // Ignore combining characters |
| | | |
| | | |
| | | if (code >= 0x300 && code <= 0x36F) { |
| | | continue; |
| | | } // Surrogates |
| | | |
| | | |
| | | if (code > 0xFFFF) { |
| | | i++; |
| | | } |
| | | |
| | | width += isFullwidthCodePoint_1(code) ? 2 : 1; |
| | | } |
| | | |
| | | return width; |
| | | }; |
| | | |
| | | var stringWidth_1 = stringWidth; // TODO: remove this in the next major version |
| | | |
| | | var default_1$3 = stringWidth; |
| | | stringWidth_1.default = default_1$3; |
| | | |
| | | var notAsciiRegex = /[^\x20-\x7F]/; |
| | | |
| | | function isExportDeclaration(node) { |
| | | if (node) { |
| | | switch (node.type) { |
| | | case "ExportDefaultDeclaration": |
| | | case "ExportDefaultSpecifier": |
| | | case "DeclareExportDeclaration": |
| | | case "ExportNamedDeclaration": |
| | | case "ExportAllDeclaration": |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function getParentExportDeclaration(path) { |
| | | var parentNode = path.getParentNode(); |
| | | |
| | | if (path.getName() === "declaration" && isExportDeclaration(parentNode)) { |
| | | return parentNode; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function getPenultimate(arr) { |
| | | if (arr.length > 1) { |
| | | return arr[arr.length - 2]; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | /** |
| | | * @typedef {{backwards?: boolean}} SkipOptions |
| | | */ |
| | | |
| | | /** |
| | | * @param {string | RegExp} chars |
| | | * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false} |
| | | */ |
| | | |
| | | |
| | | function skip(chars) { |
| | | return function (text, index, opts) { |
| | | var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having |
| | | // to check for failures (did someone say monads?). |
| | | |
| | | if (index === false) { |
| | | return false; |
| | | } |
| | | |
| | | var length = text.length; |
| | | var cursor = index; |
| | | |
| | | while (cursor >= 0 && cursor < length) { |
| | | var c = text.charAt(cursor); |
| | | |
| | | if (chars instanceof RegExp) { |
| | | if (!chars.test(c)) { |
| | | return cursor; |
| | | } |
| | | } else if (chars.indexOf(c) === -1) { |
| | | return cursor; |
| | | } |
| | | |
| | | backwards ? cursor-- : cursor++; |
| | | } |
| | | |
| | | if (cursor === -1 || cursor === length) { |
| | | // If we reached the beginning or end of the file, return the |
| | | // out-of-bounds cursor. It's up to the caller to handle this |
| | | // correctly. We don't want to indicate `false` though if it |
| | | // actually skipped valid characters. |
| | | return cursor; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | } |
| | | /** |
| | | * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} |
| | | */ |
| | | |
| | | |
| | | var skipWhitespace = skip(/\s/); |
| | | /** |
| | | * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} |
| | | */ |
| | | |
| | | var skipSpaces = skip(" \t"); |
| | | /** |
| | | * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} |
| | | */ |
| | | |
| | | var skipToLineEnd = skip(",; \t"); |
| | | /** |
| | | * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} |
| | | */ |
| | | |
| | | var skipEverythingButNewLine = skip(/[^\r\n]/); |
| | | /** |
| | | * @param {string} text |
| | | * @param {number | false} index |
| | | * @returns {number | false} |
| | | */ |
| | | |
| | | function skipInlineComment(text, index) { |
| | | if (index === false) { |
| | | return false; |
| | | } |
| | | |
| | | if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") { |
| | | for (var i = index + 2; i < text.length; ++i) { |
| | | if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") { |
| | | return i + 2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return index; |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number | false} index |
| | | * @returns {number | false} |
| | | */ |
| | | |
| | | |
| | | function skipTrailingComment(text, index) { |
| | | if (index === false) { |
| | | return false; |
| | | } |
| | | |
| | | if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") { |
| | | return skipEverythingButNewLine(text, index); |
| | | } |
| | | |
| | | return index; |
| | | } // This one doesn't use the above helper function because it wants to |
| | | // test \r\n in order and `skip` doesn't support ordering and we only |
| | | // want to skip one newline. It's simple to implement. |
| | | |
| | | /** |
| | | * @param {string} text |
| | | * @param {number | false} index |
| | | * @param {SkipOptions=} opts |
| | | * @returns {number | false} |
| | | */ |
| | | |
| | | |
| | | function skipNewline(text, index, opts) { |
| | | var backwards = opts && opts.backwards; |
| | | |
| | | if (index === false) { |
| | | return false; |
| | | } |
| | | |
| | | var atIndex = text.charAt(index); |
| | | |
| | | if (backwards) { |
| | | if (text.charAt(index - 1) === "\r" && atIndex === "\n") { |
| | | return index - 2; |
| | | } |
| | | |
| | | if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { |
| | | return index - 1; |
| | | } |
| | | } else { |
| | | if (atIndex === "\r" && text.charAt(index + 1) === "\n") { |
| | | return index + 2; |
| | | } |
| | | |
| | | if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { |
| | | return index + 1; |
| | | } |
| | | } |
| | | |
| | | return index; |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number} index |
| | | * @param {SkipOptions=} opts |
| | | * @returns {boolean} |
| | | */ |
| | | |
| | | |
| | | function hasNewline(text, index, opts) { |
| | | opts = opts || {}; |
| | | var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); |
| | | var idx2 = skipNewline(text, idx, opts); |
| | | return idx !== idx2; |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number} start |
| | | * @param {number} end |
| | | * @returns {boolean} |
| | | */ |
| | | |
| | | |
| | | function hasNewlineInRange(text, start, end) { |
| | | for (var i = start; i < end; ++i) { |
| | | if (text.charAt(i) === "\n") { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty |
| | | |
| | | /** |
| | | * @template N |
| | | * @param {string} text |
| | | * @param {N} node |
| | | * @param {(node: N) => number} locStart |
| | | */ |
| | | |
| | | |
| | | function isPreviousLineEmpty(text, node, locStart) { |
| | | /** @type {number | false} */ |
| | | var idx = locStart(node) - 1; |
| | | idx = skipSpaces(text, idx, { |
| | | backwards: true |
| | | }); |
| | | idx = skipNewline(text, idx, { |
| | | backwards: true |
| | | }); |
| | | idx = skipSpaces(text, idx, { |
| | | backwards: true |
| | | }); |
| | | var idx2 = skipNewline(text, idx, { |
| | | backwards: true |
| | | }); |
| | | return idx !== idx2; |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number} index |
| | | * @returns {boolean} |
| | | */ |
| | | |
| | | |
| | | function isNextLineEmptyAfterIndex(text, index) { |
| | | /** @type {number | false} */ |
| | | var oldIdx = null; |
| | | /** @type {number | false} */ |
| | | |
| | | var idx = index; |
| | | |
| | | while (idx !== oldIdx) { |
| | | // We need to skip all the potential trailing inline comments |
| | | oldIdx = idx; |
| | | idx = skipToLineEnd(text, idx); |
| | | idx = skipInlineComment(text, idx); |
| | | idx = skipSpaces(text, idx); |
| | | } |
| | | |
| | | idx = skipTrailingComment(text, idx); |
| | | idx = skipNewline(text, idx); |
| | | return idx !== false && hasNewline(text, idx); |
| | | } |
| | | /** |
| | | * @template N |
| | | * @param {string} text |
| | | * @param {N} node |
| | | * @param {(node: N) => number} locEnd |
| | | * @returns {boolean} |
| | | */ |
| | | |
| | | |
| | | function isNextLineEmpty(text, node, locEnd) { |
| | | return isNextLineEmptyAfterIndex(text, locEnd(node)); |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number} idx |
| | | * @returns {number | false} |
| | | */ |
| | | |
| | | |
| | | function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) { |
| | | /** @type {number | false} */ |
| | | var oldIdx = null; |
| | | /** @type {number | false} */ |
| | | |
| | | var nextIdx = idx; |
| | | |
| | | while (nextIdx !== oldIdx) { |
| | | oldIdx = nextIdx; |
| | | nextIdx = skipSpaces(text, nextIdx); |
| | | nextIdx = skipInlineComment(text, nextIdx); |
| | | nextIdx = skipTrailingComment(text, nextIdx); |
| | | nextIdx = skipNewline(text, nextIdx); |
| | | } |
| | | |
| | | return nextIdx; |
| | | } |
| | | /** |
| | | * @template N |
| | | * @param {string} text |
| | | * @param {N} node |
| | | * @param {(node: N) => number} locEnd |
| | | * @returns {number | false} |
| | | */ |
| | | |
| | | |
| | | function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) { |
| | | return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node)); |
| | | } |
| | | /** |
| | | * @template N |
| | | * @param {string} text |
| | | * @param {N} node |
| | | * @param {(node: N) => number} locEnd |
| | | * @returns {string} |
| | | */ |
| | | |
| | | |
| | | function getNextNonSpaceNonCommentCharacter(text, node, locEnd) { |
| | | return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback? |
| | | getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd)); |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @param {number} index |
| | | * @param {SkipOptions=} opts |
| | | * @returns {boolean} |
| | | */ |
| | | |
| | | |
| | | function hasSpaces(text, index, opts) { |
| | | opts = opts || {}; |
| | | var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); |
| | | return idx !== index; |
| | | } |
| | | /** |
| | | * @param {{range?: [number, number], start?: number}} node |
| | | * @param {number} index |
| | | */ |
| | | |
| | | |
| | | function setLocStart(node, index) { |
| | | if (node.range) { |
| | | node.range[0] = index; |
| | | } else { |
| | | node.start = index; |
| | | } |
| | | } |
| | | /** |
| | | * @param {{range?: [number, number], end?: number}} node |
| | | * @param {number} index |
| | | */ |
| | | |
| | | |
| | | function setLocEnd(node, index) { |
| | | if (node.range) { |
| | | node.range[1] = index; |
| | | } else { |
| | | node.end = index; |
| | | } |
| | | } |
| | | |
| | | var PRECEDENCE = {}; |
| | | [["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) { |
| | | tier.forEach(function (op) { |
| | | PRECEDENCE[op] = i; |
| | | }); |
| | | }); |
| | | |
| | | function getPrecedence(op) { |
| | | return PRECEDENCE[op]; |
| | | } |
| | | |
| | | var equalityOperators = { |
| | | "==": true, |
| | | "!=": true, |
| | | "===": true, |
| | | "!==": true |
| | | }; |
| | | var multiplicativeOperators = { |
| | | "*": true, |
| | | "/": true, |
| | | "%": true |
| | | }; |
| | | var bitshiftOperators = { |
| | | ">>": true, |
| | | ">>>": true, |
| | | "<<": true |
| | | }; |
| | | |
| | | function shouldFlatten(parentOp, nodeOp) { |
| | | if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) { |
| | | return false; |
| | | } // ** is right-associative |
| | | // x ** y ** z --> x ** (y ** z) |
| | | |
| | | |
| | | if (parentOp === "**") { |
| | | return false; |
| | | } // x == y == z --> (x == y) == z |
| | | |
| | | |
| | | if (equalityOperators[parentOp] && equalityOperators[nodeOp]) { |
| | | return false; |
| | | } // x * y % z --> (x * y) % z |
| | | |
| | | |
| | | if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) { |
| | | return false; |
| | | } // x * y / z --> (x * y) / z |
| | | // x / y * z --> (x / y) * z |
| | | |
| | | |
| | | if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) { |
| | | return false; |
| | | } // x << y << z --> (x << y) << z |
| | | |
| | | |
| | | if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function isBitwiseOperator(operator) { |
| | | return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&"; |
| | | } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr |
| | | // holds) `function`, `class`, or `do {}`. Will be overzealous if there's |
| | | // already necessary grouping parentheses. |
| | | |
| | | |
| | | function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) { |
| | | node = getLeftMost(node); |
| | | |
| | | switch (node.type) { |
| | | case "FunctionExpression": |
| | | case "ClassExpression": |
| | | case "DoExpression": |
| | | return forbidFunctionClassAndDoExpr; |
| | | |
| | | case "ObjectExpression": |
| | | return true; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "TaggedTemplateExpression": |
| | | if (node.tag.type === "FunctionExpression") { |
| | | // IIFEs are always already parenthesized |
| | | return false; |
| | | } |
| | | |
| | | return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | if (node.callee.type === "FunctionExpression") { |
| | | // IIFEs are always already parenthesized |
| | | return false; |
| | | } |
| | | |
| | | return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "ConditionalExpression": |
| | | return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "UpdateExpression": |
| | | return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "BindExpression": |
| | | return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); |
| | | |
| | | case "SequenceExpression": |
| | | return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr); |
| | | |
| | | case "TSAsExpression": |
| | | return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr); |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function getLeftMost(node) { |
| | | if (node.left) { |
| | | return getLeftMost(node.left); |
| | | } |
| | | |
| | | return node; |
| | | } |
| | | /** |
| | | * @param {string} value |
| | | * @param {number} tabWidth |
| | | * @param {number=} startIndex |
| | | * @returns {number} |
| | | */ |
| | | |
| | | |
| | | function getAlignmentSize(value, tabWidth, startIndex) { |
| | | startIndex = startIndex || 0; |
| | | var size = 0; |
| | | |
| | | for (var i = startIndex; i < value.length; ++i) { |
| | | if (value[i] === "\t") { |
| | | // Tabs behave in a way that they are aligned to the nearest |
| | | // multiple of tabWidth: |
| | | // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4 |
| | | // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ... |
| | | size = size + tabWidth - size % tabWidth; |
| | | } else { |
| | | size++; |
| | | } |
| | | } |
| | | |
| | | return size; |
| | | } |
| | | /** |
| | | * @param {string} value |
| | | * @param {number} tabWidth |
| | | * @returns {number} |
| | | */ |
| | | |
| | | |
| | | function getIndentSize(value, tabWidth) { |
| | | var lastNewlineIndex = value.lastIndexOf("\n"); |
| | | |
| | | if (lastNewlineIndex === -1) { |
| | | return 0; |
| | | } |
| | | |
| | | return getAlignmentSize( // All the leading whitespaces |
| | | value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth); |
| | | } |
| | | /** |
| | | * @typedef {'"' | "'"} Quote |
| | | */ |
| | | |
| | | /** |
| | | * |
| | | * @param {string} raw |
| | | * @param {Quote} preferredQuote |
| | | * @returns {Quote} |
| | | */ |
| | | |
| | | |
| | | function getPreferredQuote(raw, preferredQuote) { |
| | | // `rawContent` is the string exactly like it appeared in the input source |
| | | // code, without its enclosing quotes. |
| | | var rawContent = raw.slice(1, -1); |
| | | /** @type {{ quote: '"', regex: RegExp }} */ |
| | | |
| | | var double = { |
| | | quote: '"', |
| | | regex: /"/g |
| | | }; |
| | | /** @type {{ quote: "'", regex: RegExp }} */ |
| | | |
| | | var single = { |
| | | quote: "'", |
| | | regex: /'/g |
| | | }; |
| | | var preferred = preferredQuote === "'" ? single : double; |
| | | var alternate = preferred === single ? double : single; |
| | | var result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing |
| | | // the string, we might want to enclose with the alternate quote instead, to |
| | | // minimize the number of escaped quotes. |
| | | |
| | | if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) { |
| | | var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length; |
| | | var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length; |
| | | result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | function printString(raw, options, isDirectiveLiteral) { |
| | | // `rawContent` is the string exactly like it appeared in the input source |
| | | // code, without its enclosing quotes. |
| | | var rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap |
| | | // the quotes on a DirectiveLiteral. |
| | | |
| | | var canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'"); |
| | | /** @type {Quote} */ |
| | | |
| | | var enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't |
| | | // change the escape sequences they use. |
| | | // See https://github.com/prettier/prettier/issues/1555 |
| | | // and https://tc39.github.io/ecma262/#directive-prologue |
| | | |
| | | if (isDirectiveLiteral) { |
| | | if (canChangeDirectiveQuotes) { |
| | | return enclosingQuote + rawContent + enclosingQuote; |
| | | } |
| | | |
| | | return raw; |
| | | } // It might sound unnecessary to use `makeString` even if the string already |
| | | // is enclosed with `enclosingQuote`, but it isn't. The string could contain |
| | | // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes |
| | | // sure that we consistently output the minimum amount of escaped quotes. |
| | | |
| | | |
| | | return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml)); |
| | | } |
| | | /** |
| | | * @param {string} rawContent |
| | | * @param {Quote} enclosingQuote |
| | | * @param {boolean=} unescapeUnnecessaryEscapes |
| | | * @returns {string} |
| | | */ |
| | | |
| | | |
| | | function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) { |
| | | var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double). |
| | | |
| | | var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to |
| | | // enclose `rawContent` with `enclosingQuote`. |
| | | |
| | | var newContent = rawContent.replace(regex, function (match, escaped, quote) { |
| | | // If we matched an escape, and the escaped character is a quote of the |
| | | // other type than we intend to enclose the string with, there's no need for |
| | | // it to be escaped, so return it _without_ the backslash. |
| | | if (escaped === otherQuote) { |
| | | return escaped; |
| | | } // If we matched an unescaped quote and it is of the _same_ type as we |
| | | // intend to enclose the string with, it must be escaped, so return it with |
| | | // a backslash. |
| | | |
| | | |
| | | if (quote === enclosingQuote) { |
| | | return "\\" + quote; |
| | | } |
| | | |
| | | if (quote) { |
| | | return quote; |
| | | } // Unescape any unnecessarily escaped character. |
| | | // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27 |
| | | |
| | | |
| | | return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped; |
| | | }); |
| | | return enclosingQuote + newContent + enclosingQuote; |
| | | } |
| | | |
| | | function printNumber(rawNumber) { |
| | | return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation. |
| | | .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0). |
| | | .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit. |
| | | .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes. |
| | | .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot. |
| | | .replace(/\.(?=e|$)/, ""); |
| | | } |
| | | /** |
| | | * @param {string} str |
| | | * @param {string} target |
| | | * @returns {number} |
| | | */ |
| | | |
| | | |
| | | function getMaxContinuousCount(str, target) { |
| | | var results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g")); |
| | | |
| | | if (results === null) { |
| | | return 0; |
| | | } |
| | | |
| | | return results.reduce(function (maxCount, result) { |
| | | return Math.max(maxCount, result.length / target.length); |
| | | }, 0); |
| | | } |
| | | |
| | | function getMinNotPresentContinuousCount(str, target) { |
| | | var matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g")); |
| | | |
| | | if (matches === null) { |
| | | return 0; |
| | | } |
| | | |
| | | var countPresent = new Map(); |
| | | var max = 0; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var match = _step.value; |
| | | var count = match.length / target.length; |
| | | countPresent.set(count, true); |
| | | |
| | | if (count > max) { |
| | | max = count; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (var i = 1; i < max; i++) { |
| | | if (!countPresent.get(i)) { |
| | | return i; |
| | | } |
| | | } |
| | | |
| | | return max + 1; |
| | | } |
| | | /** |
| | | * @param {string} text |
| | | * @returns {number} |
| | | */ |
| | | |
| | | |
| | | function getStringWidth(text) { |
| | | if (!text) { |
| | | return 0; |
| | | } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width` |
| | | |
| | | |
| | | if (!notAsciiRegex.test(text)) { |
| | | return text.length; |
| | | } |
| | | |
| | | return stringWidth_1(text); |
| | | } |
| | | |
| | | function hasIgnoreComment(path) { |
| | | var node = path.getValue(); |
| | | return hasNodeIgnoreComment(node); |
| | | } |
| | | |
| | | function hasNodeIgnoreComment(node) { |
| | | return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) { |
| | | return comment.value.trim() === "prettier-ignore"; |
| | | }); |
| | | } |
| | | |
| | | function matchAncestorTypes(path, types, index) { |
| | | index = index || 0; |
| | | types = types.slice(); |
| | | |
| | | while (types.length) { |
| | | var parent = path.getParentNode(index); |
| | | var type = types.shift(); |
| | | |
| | | if (!parent || parent.type !== type) { |
| | | return false; |
| | | } |
| | | |
| | | index++; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function addCommentHelper(node, comment) { |
| | | var comments = node.comments || (node.comments = []); |
| | | comments.push(comment); |
| | | comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment |
| | | // We already "print" it via the raw text, we don't need to re-print it as a |
| | | // comment |
| | | |
| | | if (node.type === "JSXText") { |
| | | comment.printed = true; |
| | | } |
| | | } |
| | | |
| | | function addLeadingComment(node, comment) { |
| | | comment.leading = true; |
| | | comment.trailing = false; |
| | | addCommentHelper(node, comment); |
| | | } |
| | | |
| | | function addDanglingComment(node, comment) { |
| | | comment.leading = false; |
| | | comment.trailing = false; |
| | | addCommentHelper(node, comment); |
| | | } |
| | | |
| | | function addTrailingComment(node, comment) { |
| | | comment.leading = false; |
| | | comment.trailing = true; |
| | | addCommentHelper(node, comment); |
| | | } |
| | | |
| | | function isWithinParentArrayProperty(path, propertyName) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (parent == null) { |
| | | return false; |
| | | } |
| | | |
| | | if (!Array.isArray(parent[propertyName])) { |
| | | return false; |
| | | } |
| | | |
| | | var key = path.getName(); |
| | | return parent[propertyName][key] === node; |
| | | } |
| | | |
| | | function replaceEndOfLineWith(text, replacement) { |
| | | var parts = []; |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var part = _step2.value; |
| | | |
| | | if (parts.length !== 0) { |
| | | parts.push(replacement); |
| | | } |
| | | |
| | | parts.push(part); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return parts; |
| | | } |
| | | |
| | | var util = { |
| | | replaceEndOfLineWith: replaceEndOfLineWith, |
| | | getStringWidth: getStringWidth, |
| | | getMaxContinuousCount: getMaxContinuousCount, |
| | | getMinNotPresentContinuousCount: getMinNotPresentContinuousCount, |
| | | getPrecedence: getPrecedence, |
| | | shouldFlatten: shouldFlatten, |
| | | isBitwiseOperator: isBitwiseOperator, |
| | | isExportDeclaration: isExportDeclaration, |
| | | getParentExportDeclaration: getParentExportDeclaration, |
| | | getPenultimate: getPenultimate, |
| | | getLast: getLast, |
| | | getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex, |
| | | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex, |
| | | getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter, |
| | | skip: skip, |
| | | skipWhitespace: skipWhitespace, |
| | | skipSpaces: skipSpaces, |
| | | skipToLineEnd: skipToLineEnd, |
| | | skipEverythingButNewLine: skipEverythingButNewLine, |
| | | skipInlineComment: skipInlineComment, |
| | | skipTrailingComment: skipTrailingComment, |
| | | skipNewline: skipNewline, |
| | | isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex, |
| | | isNextLineEmpty: isNextLineEmpty, |
| | | isPreviousLineEmpty: isPreviousLineEmpty, |
| | | hasNewline: hasNewline, |
| | | hasNewlineInRange: hasNewlineInRange, |
| | | hasSpaces: hasSpaces, |
| | | setLocStart: setLocStart, |
| | | setLocEnd: setLocEnd, |
| | | startsWithNoLookaheadToken: startsWithNoLookaheadToken, |
| | | getAlignmentSize: getAlignmentSize, |
| | | getIndentSize: getIndentSize, |
| | | getPreferredQuote: getPreferredQuote, |
| | | printString: printString, |
| | | printNumber: printNumber, |
| | | hasIgnoreComment: hasIgnoreComment, |
| | | hasNodeIgnoreComment: hasNodeIgnoreComment, |
| | | makeString: makeString, |
| | | matchAncestorTypes: matchAncestorTypes, |
| | | addLeadingComment: addLeadingComment, |
| | | addDanglingComment: addDanglingComment, |
| | | addTrailingComment: addTrailingComment, |
| | | isWithinParentArrayProperty: isWithinParentArrayProperty |
| | | }; |
| | | |
| | | function guessEndOfLine(text) { |
| | | var index = text.indexOf("\r"); |
| | | |
| | | if (index >= 0) { |
| | | return text.charAt(index + 1) === "\n" ? "crlf" : "cr"; |
| | | } |
| | | |
| | | return "lf"; |
| | | } |
| | | |
| | | function convertEndOfLineToChars(value) { |
| | | switch (value) { |
| | | case "cr": |
| | | return "\r"; |
| | | |
| | | case "crlf": |
| | | return "\r\n"; |
| | | |
| | | default: |
| | | return "\n"; |
| | | } |
| | | } |
| | | |
| | | var endOfLine = { |
| | | guessEndOfLine: guessEndOfLine, |
| | | convertEndOfLineToChars: convertEndOfLineToChars |
| | | }; |
| | | |
| | | var getStringWidth$1 = util.getStringWidth; |
| | | var convertEndOfLineToChars$1 = endOfLine.convertEndOfLineToChars; |
| | | var concat$1 = docBuilders.concat, |
| | | fill$1 = docBuilders.fill, |
| | | cursor$1 = docBuilders.cursor; |
| | | /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */ |
| | | |
| | | var groupModeMap; |
| | | var MODE_BREAK = 1; |
| | | var MODE_FLAT = 2; |
| | | |
| | | function rootIndent() { |
| | | return { |
| | | value: "", |
| | | length: 0, |
| | | queue: [] |
| | | }; |
| | | } |
| | | |
| | | function makeIndent(ind, options) { |
| | | return generateInd(ind, { |
| | | type: "indent" |
| | | }, options); |
| | | } |
| | | |
| | | function makeAlign(ind, n, options) { |
| | | return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, { |
| | | type: "dedent" |
| | | }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, { |
| | | root: ind |
| | | }) : typeof n === "string" ? generateInd(ind, { |
| | | type: "stringAlign", |
| | | n: n |
| | | }, options) : generateInd(ind, { |
| | | type: "numberAlign", |
| | | n: n |
| | | }, options); |
| | | } |
| | | |
| | | function generateInd(ind, newPart, options) { |
| | | var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart); |
| | | var value = ""; |
| | | var length = 0; |
| | | var lastTabs = 0; |
| | | var lastSpaces = 0; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var part = _step.value; |
| | | |
| | | switch (part.type) { |
| | | case "indent": |
| | | flush(); |
| | | |
| | | if (options.useTabs) { |
| | | addTabs(1); |
| | | } else { |
| | | addSpaces(options.tabWidth); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "stringAlign": |
| | | flush(); |
| | | value += part.n; |
| | | length += part.n.length; |
| | | break; |
| | | |
| | | case "numberAlign": |
| | | lastTabs += 1; |
| | | lastSpaces += part.n; |
| | | break; |
| | | |
| | | /* istanbul ignore next */ |
| | | |
| | | default: |
| | | throw new Error("Unexpected type '".concat(part.type, "'")); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | flushSpaces(); |
| | | return Object.assign({}, ind, { |
| | | value: value, |
| | | length: length, |
| | | queue: queue |
| | | }); |
| | | |
| | | function addTabs(count) { |
| | | value += "\t".repeat(count); |
| | | length += options.tabWidth * count; |
| | | } |
| | | |
| | | function addSpaces(count) { |
| | | value += " ".repeat(count); |
| | | length += count; |
| | | } |
| | | |
| | | function flush() { |
| | | if (options.useTabs) { |
| | | flushTabs(); |
| | | } else { |
| | | flushSpaces(); |
| | | } |
| | | } |
| | | |
| | | function flushTabs() { |
| | | if (lastTabs > 0) { |
| | | addTabs(lastTabs); |
| | | } |
| | | |
| | | resetLast(); |
| | | } |
| | | |
| | | function flushSpaces() { |
| | | if (lastSpaces > 0) { |
| | | addSpaces(lastSpaces); |
| | | } |
| | | |
| | | resetLast(); |
| | | } |
| | | |
| | | function resetLast() { |
| | | lastTabs = 0; |
| | | lastSpaces = 0; |
| | | } |
| | | } |
| | | |
| | | function trim$1(out) { |
| | | if (out.length === 0) { |
| | | return 0; |
| | | } |
| | | |
| | | var trimCount = 0; // Trim whitespace at the end of line |
| | | |
| | | while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) { |
| | | trimCount += out.pop().length; |
| | | } |
| | | |
| | | if (out.length && typeof out[out.length - 1] === "string") { |
| | | var trimmed = out[out.length - 1].replace(/[ \t]*$/, ""); |
| | | trimCount += out[out.length - 1].length - trimmed.length; |
| | | out[out.length - 1] = trimmed; |
| | | } |
| | | |
| | | return trimCount; |
| | | } |
| | | |
| | | function fits(next, restCommands, width, options, mustBeFlat) { |
| | | var restIdx = restCommands.length; |
| | | var cmds = [next]; // `out` is only used for width counting because `trim` requires to look |
| | | // backwards for space characters. |
| | | |
| | | var out = []; |
| | | |
| | | while (width >= 0) { |
| | | if (cmds.length === 0) { |
| | | if (restIdx === 0) { |
| | | return true; |
| | | } |
| | | |
| | | cmds.push(restCommands[restIdx - 1]); |
| | | restIdx--; |
| | | continue; |
| | | } |
| | | |
| | | var x = cmds.pop(); |
| | | var ind = x[0]; |
| | | var mode = x[1]; |
| | | var doc = x[2]; |
| | | |
| | | if (typeof doc === "string") { |
| | | out.push(doc); |
| | | width -= getStringWidth$1(doc); |
| | | } else { |
| | | switch (doc.type) { |
| | | case "concat": |
| | | for (var i = doc.parts.length - 1; i >= 0; i--) { |
| | | cmds.push([ind, mode, doc.parts[i]]); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "indent": |
| | | cmds.push([makeIndent(ind, options), mode, doc.contents]); |
| | | break; |
| | | |
| | | case "align": |
| | | cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]); |
| | | break; |
| | | |
| | | case "trim": |
| | | width += trim$1(out); |
| | | break; |
| | | |
| | | case "group": |
| | | if (mustBeFlat && doc.break) { |
| | | return false; |
| | | } |
| | | |
| | | cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]); |
| | | |
| | | if (doc.id) { |
| | | groupModeMap[doc.id] = cmds[cmds.length - 1][1]; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "fill": |
| | | for (var _i = doc.parts.length - 1; _i >= 0; _i--) { |
| | | cmds.push([ind, mode, doc.parts[_i]]); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "if-break": |
| | | { |
| | | var groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode; |
| | | |
| | | if (groupMode === MODE_BREAK) { |
| | | if (doc.breakContents) { |
| | | cmds.push([ind, mode, doc.breakContents]); |
| | | } |
| | | } |
| | | |
| | | if (groupMode === MODE_FLAT) { |
| | | if (doc.flatContents) { |
| | | cmds.push([ind, mode, doc.flatContents]); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "line": |
| | | switch (mode) { |
| | | // fallthrough |
| | | case MODE_FLAT: |
| | | if (!doc.hard) { |
| | | if (!doc.soft) { |
| | | out.push(" "); |
| | | width -= 1; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | return true; |
| | | |
| | | case MODE_BREAK: |
| | | return true; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function printDocToString(doc, options) { |
| | | groupModeMap = {}; |
| | | var width = options.printWidth; |
| | | var newLine = convertEndOfLineToChars$1(options.endOfLine); |
| | | var pos = 0; // cmds is basically a stack. We've turned a recursive call into a |
| | | // while loop which is much faster. The while loop below adds new |
| | | // cmds to the array instead of recursively calling `print`. |
| | | |
| | | var cmds = [[rootIndent(), MODE_BREAK, doc]]; |
| | | var out = []; |
| | | var shouldRemeasure = false; |
| | | var lineSuffix = []; |
| | | |
| | | while (cmds.length !== 0) { |
| | | var x = cmds.pop(); |
| | | var ind = x[0]; |
| | | var mode = x[1]; |
| | | var _doc = x[2]; |
| | | |
| | | if (typeof _doc === "string") { |
| | | out.push(_doc); |
| | | pos += getStringWidth$1(_doc); |
| | | } else { |
| | | switch (_doc.type) { |
| | | case "cursor": |
| | | out.push(cursor$1.placeholder); |
| | | break; |
| | | |
| | | case "concat": |
| | | for (var i = _doc.parts.length - 1; i >= 0; i--) { |
| | | cmds.push([ind, mode, _doc.parts[i]]); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "indent": |
| | | cmds.push([makeIndent(ind, options), mode, _doc.contents]); |
| | | break; |
| | | |
| | | case "align": |
| | | cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]); |
| | | break; |
| | | |
| | | case "trim": |
| | | pos -= trim$1(out); |
| | | break; |
| | | |
| | | case "group": |
| | | switch (mode) { |
| | | case MODE_FLAT: |
| | | if (!shouldRemeasure) { |
| | | cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]); |
| | | break; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case MODE_BREAK: |
| | | { |
| | | shouldRemeasure = false; |
| | | var next = [ind, MODE_FLAT, _doc.contents]; |
| | | var rem = width - pos; |
| | | |
| | | if (!_doc.break && fits(next, cmds, rem, options)) { |
| | | cmds.push(next); |
| | | } else { |
| | | // Expanded states are a rare case where a document |
| | | // can manually provide multiple representations of |
| | | // itself. It provides an array of documents |
| | | // going from the least expanded (most flattened) |
| | | // representation first to the most expanded. If a |
| | | // group has these, we need to manually go through |
| | | // these states and find the first one that fits. |
| | | if (_doc.expandedStates) { |
| | | var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1]; |
| | | |
| | | if (_doc.break) { |
| | | cmds.push([ind, MODE_BREAK, mostExpanded]); |
| | | break; |
| | | } else { |
| | | for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) { |
| | | if (_i2 >= _doc.expandedStates.length) { |
| | | cmds.push([ind, MODE_BREAK, mostExpanded]); |
| | | break; |
| | | } else { |
| | | var state = _doc.expandedStates[_i2]; |
| | | var cmd = [ind, MODE_FLAT, state]; |
| | | |
| | | if (fits(cmd, cmds, rem, options)) { |
| | | cmds.push(cmd); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | cmds.push([ind, MODE_BREAK, _doc.contents]); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (_doc.id) { |
| | | groupModeMap[_doc.id] = cmds[cmds.length - 1][1]; |
| | | } |
| | | |
| | | break; |
| | | // Fills each line with as much code as possible before moving to a new |
| | | // line with the same indentation. |
| | | // |
| | | // Expects doc.parts to be an array of alternating content and |
| | | // whitespace. The whitespace contains the linebreaks. |
| | | // |
| | | // For example: |
| | | // ["I", line, "love", line, "monkeys"] |
| | | // or |
| | | // [{ type: group, ... }, softline, { type: group, ... }] |
| | | // |
| | | // It uses this parts structure to handle three main layout cases: |
| | | // * The first two content items fit on the same line without |
| | | // breaking |
| | | // -> output the first content item and the whitespace "flat". |
| | | // * Only the first content item fits on the line without breaking |
| | | // -> output the first content item "flat" and the whitespace with |
| | | // "break". |
| | | // * Neither content item fits on the line without breaking |
| | | // -> output the first content item and the whitespace with "break". |
| | | |
| | | case "fill": |
| | | { |
| | | var _rem = width - pos; |
| | | |
| | | var parts = _doc.parts; |
| | | |
| | | if (parts.length === 0) { |
| | | break; |
| | | } |
| | | |
| | | var content = parts[0]; |
| | | var contentFlatCmd = [ind, MODE_FLAT, content]; |
| | | var contentBreakCmd = [ind, MODE_BREAK, content]; |
| | | var contentFits = fits(contentFlatCmd, [], _rem, options, true); |
| | | |
| | | if (parts.length === 1) { |
| | | if (contentFits) { |
| | | cmds.push(contentFlatCmd); |
| | | } else { |
| | | cmds.push(contentBreakCmd); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | var whitespace = parts[1]; |
| | | var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace]; |
| | | var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace]; |
| | | |
| | | if (parts.length === 2) { |
| | | if (contentFits) { |
| | | cmds.push(whitespaceFlatCmd); |
| | | cmds.push(contentFlatCmd); |
| | | } else { |
| | | cmds.push(whitespaceBreakCmd); |
| | | cmds.push(contentBreakCmd); |
| | | } |
| | | |
| | | break; |
| | | } // At this point we've handled the first pair (context, separator) |
| | | // and will create a new fill doc for the rest of the content. |
| | | // Ideally we wouldn't mutate the array here but coping all the |
| | | // elements to a new array would make this algorithm quadratic, |
| | | // which is unusable for large arrays (e.g. large texts in JSX). |
| | | |
| | | |
| | | parts.splice(0, 2); |
| | | var remainingCmd = [ind, mode, fill$1(parts)]; |
| | | var secondContent = parts[0]; |
| | | var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$1([content, whitespace, secondContent])]; |
| | | var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true); |
| | | |
| | | if (firstAndSecondContentFits) { |
| | | cmds.push(remainingCmd); |
| | | cmds.push(whitespaceFlatCmd); |
| | | cmds.push(contentFlatCmd); |
| | | } else if (contentFits) { |
| | | cmds.push(remainingCmd); |
| | | cmds.push(whitespaceBreakCmd); |
| | | cmds.push(contentFlatCmd); |
| | | } else { |
| | | cmds.push(remainingCmd); |
| | | cmds.push(whitespaceBreakCmd); |
| | | cmds.push(contentBreakCmd); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "if-break": |
| | | { |
| | | var groupMode = _doc.groupId ? groupModeMap[_doc.groupId] : mode; |
| | | |
| | | if (groupMode === MODE_BREAK) { |
| | | if (_doc.breakContents) { |
| | | cmds.push([ind, mode, _doc.breakContents]); |
| | | } |
| | | } |
| | | |
| | | if (groupMode === MODE_FLAT) { |
| | | if (_doc.flatContents) { |
| | | cmds.push([ind, mode, _doc.flatContents]); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "line-suffix": |
| | | lineSuffix.push([ind, mode, _doc.contents]); |
| | | break; |
| | | |
| | | case "line-suffix-boundary": |
| | | if (lineSuffix.length > 0) { |
| | | cmds.push([ind, mode, { |
| | | type: "line", |
| | | hard: true |
| | | }]); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "line": |
| | | switch (mode) { |
| | | case MODE_FLAT: |
| | | if (!_doc.hard) { |
| | | if (!_doc.soft) { |
| | | out.push(" "); |
| | | pos += 1; |
| | | } |
| | | |
| | | break; |
| | | } else { |
| | | // This line was forced into the output even if we |
| | | // were in flattened mode, so we need to tell the next |
| | | // group that no matter what, it needs to remeasure |
| | | // because the previous measurement didn't accurately |
| | | // capture the entire expression (this is necessary |
| | | // for nested groups) |
| | | shouldRemeasure = true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case MODE_BREAK: |
| | | if (lineSuffix.length) { |
| | | cmds.push([ind, mode, _doc]); |
| | | [].push.apply(cmds, lineSuffix.reverse()); |
| | | lineSuffix = []; |
| | | break; |
| | | } |
| | | |
| | | if (_doc.literal) { |
| | | if (ind.root) { |
| | | out.push(newLine, ind.root.value); |
| | | pos = ind.root.length; |
| | | } else { |
| | | out.push(newLine); |
| | | pos = 0; |
| | | } |
| | | } else { |
| | | pos -= trim$1(out); |
| | | out.push(newLine + ind.value); |
| | | pos = ind.length; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var cursorPlaceholderIndex = out.indexOf(cursor$1.placeholder); |
| | | |
| | | if (cursorPlaceholderIndex !== -1) { |
| | | var otherCursorPlaceholderIndex = out.indexOf(cursor$1.placeholder, cursorPlaceholderIndex + 1); |
| | | var beforeCursor = out.slice(0, cursorPlaceholderIndex).join(""); |
| | | var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join(""); |
| | | var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join(""); |
| | | return { |
| | | formatted: beforeCursor + aroundCursor + afterCursor, |
| | | cursorNodeStart: beforeCursor.length, |
| | | cursorNodeText: aroundCursor |
| | | }; |
| | | } |
| | | |
| | | return { |
| | | formatted: out.join("") |
| | | }; |
| | | } |
| | | |
| | | var docPrinter = { |
| | | printDocToString: printDocToString |
| | | }; |
| | | |
| | | var traverseDocOnExitStackMarker = {}; |
| | | |
| | | function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) { |
| | | var docsStack = [doc]; |
| | | |
| | | while (docsStack.length !== 0) { |
| | | var _doc = docsStack.pop(); |
| | | |
| | | if (_doc === traverseDocOnExitStackMarker) { |
| | | onExit(docsStack.pop()); |
| | | continue; |
| | | } |
| | | |
| | | var shouldRecurse = true; |
| | | |
| | | if (onEnter) { |
| | | if (onEnter(_doc) === false) { |
| | | shouldRecurse = false; |
| | | } |
| | | } |
| | | |
| | | if (onExit) { |
| | | docsStack.push(_doc); |
| | | docsStack.push(traverseDocOnExitStackMarker); |
| | | } |
| | | |
| | | if (shouldRecurse) { |
| | | // When there are multiple parts to process, |
| | | // the parts need to be pushed onto the stack in reverse order, |
| | | // so that they are processed in the original order |
| | | // when the stack is popped. |
| | | if (_doc.type === "concat" || _doc.type === "fill") { |
| | | for (var ic = _doc.parts.length, i = ic - 1; i >= 0; --i) { |
| | | docsStack.push(_doc.parts[i]); |
| | | } |
| | | } else if (_doc.type === "if-break") { |
| | | if (_doc.flatContents) { |
| | | docsStack.push(_doc.flatContents); |
| | | } |
| | | |
| | | if (_doc.breakContents) { |
| | | docsStack.push(_doc.breakContents); |
| | | } |
| | | } else if (_doc.type === "group" && _doc.expandedStates) { |
| | | if (shouldTraverseConditionalGroups) { |
| | | for (var _ic = _doc.expandedStates.length, _i = _ic - 1; _i >= 0; --_i) { |
| | | docsStack.push(_doc.expandedStates[_i]); |
| | | } |
| | | } else { |
| | | docsStack.push(_doc.contents); |
| | | } |
| | | } else if (_doc.contents) { |
| | | docsStack.push(_doc.contents); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | function mapDoc(doc, cb) { |
| | | if (doc.type === "concat" || doc.type === "fill") { |
| | | var parts = doc.parts.map(function (part) { |
| | | return mapDoc(part, cb); |
| | | }); |
| | | return cb(Object.assign({}, doc, { |
| | | parts: parts |
| | | })); |
| | | } else if (doc.type === "if-break") { |
| | | var breakContents = doc.breakContents && mapDoc(doc.breakContents, cb); |
| | | var flatContents = doc.flatContents && mapDoc(doc.flatContents, cb); |
| | | return cb(Object.assign({}, doc, { |
| | | breakContents: breakContents, |
| | | flatContents: flatContents |
| | | })); |
| | | } else if (doc.contents) { |
| | | var contents = mapDoc(doc.contents, cb); |
| | | return cb(Object.assign({}, doc, { |
| | | contents: contents |
| | | })); |
| | | } |
| | | |
| | | return cb(doc); |
| | | } |
| | | |
| | | function findInDoc(doc, fn, defaultValue) { |
| | | var result = defaultValue; |
| | | var hasStopped = false; |
| | | |
| | | function findInDocOnEnterFn(doc) { |
| | | var maybeResult = fn(doc); |
| | | |
| | | if (maybeResult !== undefined) { |
| | | hasStopped = true; |
| | | result = maybeResult; |
| | | } |
| | | |
| | | if (hasStopped) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | traverseDoc(doc, findInDocOnEnterFn); |
| | | return result; |
| | | } |
| | | |
| | | function isEmpty(n) { |
| | | return typeof n === "string" && n.length === 0; |
| | | } |
| | | |
| | | function isLineNextFn(doc) { |
| | | if (typeof doc === "string") { |
| | | return false; |
| | | } |
| | | |
| | | if (doc.type === "line") { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | function isLineNext(doc) { |
| | | return findInDoc(doc, isLineNextFn, false); |
| | | } |
| | | |
| | | function willBreakFn(doc) { |
| | | if (doc.type === "group" && doc.break) { |
| | | return true; |
| | | } |
| | | |
| | | if (doc.type === "line" && doc.hard) { |
| | | return true; |
| | | } |
| | | |
| | | if (doc.type === "break-parent") { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | function willBreak(doc) { |
| | | return findInDoc(doc, willBreakFn, false); |
| | | } |
| | | |
| | | function breakParentGroup(groupStack) { |
| | | if (groupStack.length > 0) { |
| | | var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because |
| | | // the user is expected to manually handle what breaks. |
| | | |
| | | if (!parentGroup.expandedStates) { |
| | | parentGroup.break = true; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function propagateBreaks(doc) { |
| | | var alreadyVisitedSet = new Set(); |
| | | var groupStack = []; |
| | | |
| | | function propagateBreaksOnEnterFn(doc) { |
| | | if (doc.type === "break-parent") { |
| | | breakParentGroup(groupStack); |
| | | } |
| | | |
| | | if (doc.type === "group") { |
| | | groupStack.push(doc); |
| | | |
| | | if (alreadyVisitedSet.has(doc)) { |
| | | return false; |
| | | } |
| | | |
| | | alreadyVisitedSet.add(doc); |
| | | } |
| | | } |
| | | |
| | | function propagateBreaksOnExitFn(doc) { |
| | | if (doc.type === "group") { |
| | | var group = groupStack.pop(); |
| | | |
| | | if (group.break) { |
| | | breakParentGroup(groupStack); |
| | | } |
| | | } |
| | | } |
| | | |
| | | traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn, |
| | | /* shouldTraverseConditionalGroups */ |
| | | true); |
| | | } |
| | | |
| | | function removeLinesFn(doc) { |
| | | // Force this doc into flat mode by statically converting all |
| | | // lines into spaces (or soft lines into nothing). Hard lines |
| | | // should still output because there's too great of a chance |
| | | // of breaking existing assumptions otherwise. |
| | | if (doc.type === "line" && !doc.hard) { |
| | | return doc.soft ? "" : " "; |
| | | } else if (doc.type === "if-break") { |
| | | return doc.flatContents || ""; |
| | | } |
| | | |
| | | return doc; |
| | | } |
| | | |
| | | function removeLines(doc) { |
| | | return mapDoc(doc, removeLinesFn); |
| | | } |
| | | |
| | | function stripTrailingHardline(doc) { |
| | | // HACK remove ending hardline, original PR: #1984 |
| | | if (doc.type === "concat" && doc.parts.length !== 0) { |
| | | var lastPart = doc.parts[doc.parts.length - 1]; |
| | | |
| | | if (lastPart.type === "concat") { |
| | | if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") { |
| | | return { |
| | | type: "concat", |
| | | parts: doc.parts.slice(0, -1) |
| | | }; |
| | | } |
| | | |
| | | return { |
| | | type: "concat", |
| | | parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart)) |
| | | }; |
| | | } |
| | | } |
| | | |
| | | return doc; |
| | | } |
| | | |
| | | var docUtils = { |
| | | isEmpty: isEmpty, |
| | | willBreak: willBreak, |
| | | isLineNext: isLineNext, |
| | | traverseDoc: traverseDoc, |
| | | findInDoc: findInDoc, |
| | | mapDoc: mapDoc, |
| | | propagateBreaks: propagateBreaks, |
| | | removeLines: removeLines, |
| | | stripTrailingHardline: stripTrailingHardline |
| | | }; |
| | | |
| | | function flattenDoc(doc) { |
| | | if (doc.type === "concat") { |
| | | var res = []; |
| | | |
| | | for (var i = 0; i < doc.parts.length; ++i) { |
| | | var doc2 = doc.parts[i]; |
| | | |
| | | if (typeof doc2 !== "string" && doc2.type === "concat") { |
| | | [].push.apply(res, flattenDoc(doc2).parts); |
| | | } else { |
| | | var flattened = flattenDoc(doc2); |
| | | |
| | | if (flattened !== "") { |
| | | res.push(flattened); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return Object.assign({}, doc, { |
| | | parts: res |
| | | }); |
| | | } else if (doc.type === "if-break") { |
| | | return Object.assign({}, doc, { |
| | | breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null, |
| | | flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null |
| | | }); |
| | | } else if (doc.type === "group") { |
| | | return Object.assign({}, doc, { |
| | | contents: flattenDoc(doc.contents), |
| | | expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates |
| | | }); |
| | | } else if (doc.contents) { |
| | | return Object.assign({}, doc, { |
| | | contents: flattenDoc(doc.contents) |
| | | }); |
| | | } |
| | | |
| | | return doc; |
| | | } |
| | | |
| | | function printDoc(doc) { |
| | | if (typeof doc === "string") { |
| | | return JSON.stringify(doc); |
| | | } |
| | | |
| | | if (doc.type === "line") { |
| | | if (doc.literal) { |
| | | return "literalline"; |
| | | } |
| | | |
| | | if (doc.hard) { |
| | | return "hardline"; |
| | | } |
| | | |
| | | if (doc.soft) { |
| | | return "softline"; |
| | | } |
| | | |
| | | return "line"; |
| | | } |
| | | |
| | | if (doc.type === "break-parent") { |
| | | return "breakParent"; |
| | | } |
| | | |
| | | if (doc.type === "trim") { |
| | | return "trim"; |
| | | } |
| | | |
| | | if (doc.type === "concat") { |
| | | return "[" + doc.parts.map(printDoc).join(", ") + "]"; |
| | | } |
| | | |
| | | if (doc.type === "indent") { |
| | | return "indent(" + printDoc(doc.contents) + ")"; |
| | | } |
| | | |
| | | if (doc.type === "align") { |
| | | return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")"; |
| | | } |
| | | |
| | | if (doc.type === "if-break") { |
| | | return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")"; |
| | | } |
| | | |
| | | if (doc.type === "group") { |
| | | if (doc.expandedStates) { |
| | | return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])"; |
| | | } |
| | | |
| | | return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")"; |
| | | } |
| | | |
| | | if (doc.type === "fill") { |
| | | return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")"; |
| | | } |
| | | |
| | | if (doc.type === "line-suffix") { |
| | | return "lineSuffix(" + printDoc(doc.contents) + ")"; |
| | | } |
| | | |
| | | if (doc.type === "line-suffix-boundary") { |
| | | return "lineSuffixBoundary"; |
| | | } |
| | | |
| | | throw new Error("Unknown doc type " + doc.type); |
| | | } |
| | | |
| | | var docDebug = { |
| | | printDocToDebug: function printDocToDebug(doc) { |
| | | return printDoc(flattenDoc(doc)); |
| | | } |
| | | }; |
| | | |
| | | var doc = { |
| | | builders: docBuilders, |
| | | printer: docPrinter, |
| | | utils: docUtils, |
| | | debug: docDebug |
| | | }; |
| | | |
| | | var mapDoc$1 = doc.utils.mapDoc; |
| | | |
| | | function isNextLineEmpty$1(text, node, options) { |
| | | return util.isNextLineEmpty(text, node, options.locEnd); |
| | | } |
| | | |
| | | function isPreviousLineEmpty$1(text, node, options) { |
| | | return util.isPreviousLineEmpty(text, node, options.locStart); |
| | | } |
| | | |
| | | function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) { |
| | | return util.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd); |
| | | } |
| | | |
| | | var utilShared = { |
| | | getMaxContinuousCount: util.getMaxContinuousCount, |
| | | getStringWidth: util.getStringWidth, |
| | | getAlignmentSize: util.getAlignmentSize, |
| | | getIndentSize: util.getIndentSize, |
| | | skip: util.skip, |
| | | skipWhitespace: util.skipWhitespace, |
| | | skipSpaces: util.skipSpaces, |
| | | skipNewline: util.skipNewline, |
| | | skipToLineEnd: util.skipToLineEnd, |
| | | skipEverythingButNewLine: util.skipEverythingButNewLine, |
| | | skipInlineComment: util.skipInlineComment, |
| | | skipTrailingComment: util.skipTrailingComment, |
| | | hasNewline: util.hasNewline, |
| | | hasNewlineInRange: util.hasNewlineInRange, |
| | | hasSpaces: util.hasSpaces, |
| | | isNextLineEmpty: isNextLineEmpty$1, |
| | | isNextLineEmptyAfterIndex: util.isNextLineEmptyAfterIndex, |
| | | isPreviousLineEmpty: isPreviousLineEmpty$1, |
| | | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1, |
| | | mapDoc: mapDoc$1, |
| | | // TODO: remove in 2.0, we already exposed it in docUtils |
| | | makeString: util.makeString, |
| | | addLeadingComment: util.addLeadingComment, |
| | | addDanglingComment: util.addDanglingComment, |
| | | addTrailingComment: util.addTrailingComment |
| | | }; |
| | | |
| | | var _require$$0$builders = doc.builders, |
| | | concat$2 = _require$$0$builders.concat, |
| | | hardline$1 = _require$$0$builders.hardline, |
| | | breakParent$1 = _require$$0$builders.breakParent, |
| | | indent$1 = _require$$0$builders.indent, |
| | | lineSuffix$1 = _require$$0$builders.lineSuffix, |
| | | join$1 = _require$$0$builders.join, |
| | | cursor$2 = _require$$0$builders.cursor; |
| | | var hasNewline$1 = util.hasNewline, |
| | | skipNewline$1 = util.skipNewline, |
| | | isPreviousLineEmpty$2 = util.isPreviousLineEmpty; |
| | | var addLeadingComment$1 = utilShared.addLeadingComment, |
| | | addDanglingComment$1 = utilShared.addDanglingComment, |
| | | addTrailingComment$1 = utilShared.addTrailingComment; |
| | | var childNodesCacheKey = Symbol("child-nodes"); |
| | | |
| | | function getSortedChildNodes(node, options, resultArray) { |
| | | if (!node) { |
| | | return; |
| | | } |
| | | |
| | | var printer = options.printer, |
| | | locStart = options.locStart, |
| | | locEnd = options.locEnd; |
| | | |
| | | if (resultArray) { |
| | | if (node && printer.canAttachComment && printer.canAttachComment(node)) { |
| | | // This reverse insertion sort almost always takes constant |
| | | // time because we almost always (maybe always?) append the |
| | | // nodes in order anyway. |
| | | var i; |
| | | |
| | | for (i = resultArray.length - 1; i >= 0; --i) { |
| | | if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | resultArray.splice(i + 1, 0, node); |
| | | return; |
| | | } |
| | | } else if (node[childNodesCacheKey]) { |
| | | return node[childNodesCacheKey]; |
| | | } |
| | | |
| | | var childNodes; |
| | | |
| | | if (printer.getCommentChildNodes) { |
| | | childNodes = printer.getCommentChildNodes(node); |
| | | } else if (node && _typeof(node) === "object") { |
| | | childNodes = Object.keys(node).filter(function (n) { |
| | | return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode"; |
| | | }).map(function (n) { |
| | | return node[n]; |
| | | }); |
| | | } |
| | | |
| | | if (!childNodes) { |
| | | return; |
| | | } |
| | | |
| | | if (!resultArray) { |
| | | Object.defineProperty(node, childNodesCacheKey, { |
| | | value: resultArray = [], |
| | | enumerable: false |
| | | }); |
| | | } |
| | | |
| | | childNodes.forEach(function (childNode) { |
| | | getSortedChildNodes(childNode, options, resultArray); |
| | | }); |
| | | return resultArray; |
| | | } // As efficiently as possible, decorate the comment object with |
| | | // .precedingNode, .enclosingNode, and/or .followingNode properties, at |
| | | // least one of which is guaranteed to be defined. |
| | | |
| | | |
| | | function decorateComment(node, comment, options) { |
| | | var locStart = options.locStart, |
| | | locEnd = options.locEnd; |
| | | var childNodes = getSortedChildNodes(node, options); |
| | | var precedingNode; |
| | | var followingNode; // Time to dust off the old binary search robes and wizard hat. |
| | | |
| | | var left = 0; |
| | | var right = childNodes.length; |
| | | |
| | | while (left < right) { |
| | | var middle = left + right >> 1; |
| | | var child = childNodes[middle]; |
| | | |
| | | if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) { |
| | | // The comment is completely contained by this child node. |
| | | comment.enclosingNode = child; |
| | | decorateComment(child, comment, options); |
| | | return; // Abandon the binary search at this level. |
| | | } |
| | | |
| | | if (locEnd(child) - locStart(comment) <= 0) { |
| | | // This child node falls completely before the comment. |
| | | // Because we will never consider this node or any nodes |
| | | // before it again, this node must be the closest preceding |
| | | // node we have encountered so far. |
| | | precedingNode = child; |
| | | left = middle + 1; |
| | | continue; |
| | | } |
| | | |
| | | if (locEnd(comment) - locStart(child) <= 0) { |
| | | // This child node falls completely after the comment. |
| | | // Because we will never consider this node or any nodes after |
| | | // it again, this node must be the closest following node we |
| | | // have encountered so far. |
| | | followingNode = child; |
| | | right = middle; |
| | | continue; |
| | | } |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | throw new Error("Comment location overlaps with node location"); |
| | | } // We don't want comments inside of different expressions inside of the same |
| | | // template literal to move to another expression. |
| | | |
| | | |
| | | if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") { |
| | | var quasis = comment.enclosingNode.quasis; |
| | | var commentIndex = findExpressionIndexForComment(quasis, comment, options); |
| | | |
| | | if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) { |
| | | precedingNode = null; |
| | | } |
| | | |
| | | if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) { |
| | | followingNode = null; |
| | | } |
| | | } |
| | | |
| | | if (precedingNode) { |
| | | comment.precedingNode = precedingNode; |
| | | } |
| | | |
| | | if (followingNode) { |
| | | comment.followingNode = followingNode; |
| | | } |
| | | } |
| | | |
| | | function attach(comments, ast, text, options) { |
| | | if (!Array.isArray(comments)) { |
| | | return; |
| | | } |
| | | |
| | | var tiesToBreak = []; |
| | | var locStart = options.locStart, |
| | | locEnd = options.locEnd; |
| | | comments.forEach(function (comment, i) { |
| | | if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") { |
| | | if (locStart(comment) - locStart(ast) <= 0) { |
| | | addLeadingComment$1(ast, comment); |
| | | return; |
| | | } |
| | | |
| | | if (locEnd(comment) - locEnd(ast) >= 0) { |
| | | addTrailingComment$1(ast, comment); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | decorateComment(ast, comment, options); |
| | | var precedingNode = comment.precedingNode, |
| | | enclosingNode = comment.enclosingNode, |
| | | followingNode = comment.followingNode; |
| | | var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () { |
| | | return false; |
| | | }; |
| | | var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () { |
| | | return false; |
| | | }; |
| | | var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () { |
| | | return false; |
| | | }; |
| | | var isLastComment = comments.length - 1 === i; |
| | | |
| | | if (hasNewline$1(text, locStart(comment), { |
| | | backwards: true |
| | | })) { |
| | | // If a comment exists on its own line, prefer a leading comment. |
| | | // We also need to check if it's the first line of the file. |
| | | if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) ; else if (followingNode) { |
| | | // Always a leading comment. |
| | | addLeadingComment$1(followingNode, comment); |
| | | } else if (precedingNode) { |
| | | addTrailingComment$1(precedingNode, comment); |
| | | } else if (enclosingNode) { |
| | | addDanglingComment$1(enclosingNode, comment); |
| | | } else { |
| | | // There are no nodes, let's attach it to the root of the ast |
| | | |
| | | /* istanbul ignore next */ |
| | | addDanglingComment$1(ast, comment); |
| | | } |
| | | } else if (hasNewline$1(text, locEnd(comment))) { |
| | | if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) ; else if (precedingNode) { |
| | | // There is content before this comment on the same line, but |
| | | // none after it, so prefer a trailing comment of the previous node. |
| | | addTrailingComment$1(precedingNode, comment); |
| | | } else if (followingNode) { |
| | | addLeadingComment$1(followingNode, comment); |
| | | } else if (enclosingNode) { |
| | | addDanglingComment$1(enclosingNode, comment); |
| | | } else { |
| | | // There are no nodes, let's attach it to the root of the ast |
| | | |
| | | /* istanbul ignore next */ |
| | | addDanglingComment$1(ast, comment); |
| | | } |
| | | } else { |
| | | if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) ; else if (precedingNode && followingNode) { |
| | | // Otherwise, text exists both before and after the comment on |
| | | // the same line. If there is both a preceding and following |
| | | // node, use a tie-breaking algorithm to determine if it should |
| | | // be attached to the next or previous node. In the last case, |
| | | // simply attach the right node; |
| | | var tieCount = tiesToBreak.length; |
| | | |
| | | if (tieCount > 0) { |
| | | var lastTie = tiesToBreak[tieCount - 1]; |
| | | |
| | | if (lastTie.followingNode !== comment.followingNode) { |
| | | breakTies(tiesToBreak, text, options); |
| | | } |
| | | } |
| | | |
| | | tiesToBreak.push(comment); |
| | | } else if (precedingNode) { |
| | | addTrailingComment$1(precedingNode, comment); |
| | | } else if (followingNode) { |
| | | addLeadingComment$1(followingNode, comment); |
| | | } else if (enclosingNode) { |
| | | addDanglingComment$1(enclosingNode, comment); |
| | | } else { |
| | | // There are no nodes, let's attach it to the root of the ast |
| | | |
| | | /* istanbul ignore next */ |
| | | addDanglingComment$1(ast, comment); |
| | | } |
| | | } |
| | | }); |
| | | breakTies(tiesToBreak, text, options); |
| | | comments.forEach(function (comment) { |
| | | // These node references were useful for breaking ties, but we |
| | | // don't need them anymore, and they create cycles in the AST that |
| | | // may lead to infinite recursion if we don't delete them here. |
| | | delete comment.precedingNode; |
| | | delete comment.enclosingNode; |
| | | delete comment.followingNode; |
| | | }); |
| | | } |
| | | |
| | | function breakTies(tiesToBreak, text, options) { |
| | | var tieCount = tiesToBreak.length; |
| | | |
| | | if (tieCount === 0) { |
| | | return; |
| | | } |
| | | |
| | | var _tiesToBreak$ = tiesToBreak[0], |
| | | precedingNode = _tiesToBreak$.precedingNode, |
| | | followingNode = _tiesToBreak$.followingNode; |
| | | var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps |
| | | // between the tied comments. In order to qualify as leading, a |
| | | // comment must be separated from followingNode by an unbroken series of |
| | | // gaps (or other comments). Gaps should only contain whitespace or open |
| | | // parentheses. |
| | | |
| | | var indexOfFirstLeadingComment; |
| | | |
| | | for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) { |
| | | var comment = tiesToBreak[indexOfFirstLeadingComment - 1]; |
| | | assert.strictEqual(comment.precedingNode, precedingNode); |
| | | assert.strictEqual(comment.followingNode, followingNode); |
| | | var gap = text.slice(options.locEnd(comment), gapEndPos); |
| | | |
| | | if (/^[\s(]*$/.test(gap)) { |
| | | gapEndPos = options.locStart(comment); |
| | | } else { |
| | | // The gap string contained something other than whitespace or open |
| | | // parentheses. |
| | | break; |
| | | } |
| | | } |
| | | |
| | | tiesToBreak.forEach(function (comment, i) { |
| | | if (i < indexOfFirstLeadingComment) { |
| | | addTrailingComment$1(precedingNode, comment); |
| | | } else { |
| | | addLeadingComment$1(followingNode, comment); |
| | | } |
| | | }); |
| | | tiesToBreak.length = 0; |
| | | } |
| | | |
| | | function printComment(commentPath, options) { |
| | | var comment = commentPath.getValue(); |
| | | comment.printed = true; |
| | | return options.printer.printComment(commentPath, options); |
| | | } |
| | | |
| | | function findExpressionIndexForComment(quasis, comment, options) { |
| | | var startPos = options.locStart(comment) - 1; |
| | | |
| | | for (var i = 1; i < quasis.length; ++i) { |
| | | if (startPos < getQuasiRange(quasis[i]).start) { |
| | | return i - 1; |
| | | } |
| | | } // We haven't found it, it probably means that some of the locations are off. |
| | | // Let's just return the first one. |
| | | |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | function getQuasiRange(expr) { |
| | | if (expr.start !== undefined) { |
| | | // Babel |
| | | return { |
| | | start: expr.start, |
| | | end: expr.end |
| | | }; |
| | | } // Flow |
| | | |
| | | |
| | | return { |
| | | start: expr.range[0], |
| | | end: expr.range[1] |
| | | }; |
| | | } |
| | | |
| | | function printLeadingComment(commentPath, print, options) { |
| | | var comment = commentPath.getValue(); |
| | | var contents = printComment(commentPath, options); |
| | | |
| | | if (!contents) { |
| | | return ""; |
| | | } |
| | | |
| | | var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the |
| | | // same line or not. |
| | | |
| | | if (isBlock) { |
| | | return concat$2([contents, hasNewline$1(options.originalText, options.locEnd(comment)) ? hardline$1 : " "]); |
| | | } |
| | | |
| | | return concat$2([contents, hardline$1]); |
| | | } |
| | | |
| | | function printTrailingComment(commentPath, print, options) { |
| | | var comment = commentPath.getValue(); |
| | | var contents = printComment(commentPath, options); |
| | | |
| | | if (!contents) { |
| | | return ""; |
| | | } |
| | | |
| | | var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break |
| | | // when the parentParentNode is a ClassDeclaration/-Expression |
| | | // And the parentNode is in the superClass property |
| | | |
| | | var parentNode = commentPath.getNode(1); |
| | | var parentParentNode = commentPath.getNode(2); |
| | | var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode; |
| | | |
| | | if (hasNewline$1(options.originalText, options.locStart(comment), { |
| | | backwards: true |
| | | })) { |
| | | // This allows comments at the end of nested structures: |
| | | // { |
| | | // x: 1, |
| | | // y: 2 |
| | | // // A comment |
| | | // } |
| | | // Those kinds of comments are almost always leading comments, but |
| | | // here it doesn't go "outside" the block and turns it into a |
| | | // trailing comment for `2`. We can simulate the above by checking |
| | | // if this a comment on its own line; normal trailing comments are |
| | | // always at the end of another expression. |
| | | var isLineBeforeEmpty = isPreviousLineEmpty$2(options.originalText, comment, options.locStart); |
| | | return lineSuffix$1(concat$2([hardline$1, isLineBeforeEmpty ? hardline$1 : "", contents])); |
| | | } else if (isBlock || isParentSuperClass) { |
| | | // Trailing block comments never need a newline |
| | | return concat$2([" ", contents]); |
| | | } |
| | | |
| | | return concat$2([lineSuffix$1(concat$2([" ", contents])), !isBlock ? breakParent$1 : ""]); |
| | | } |
| | | |
| | | function printDanglingComments(path, options, sameIndent, filter) { |
| | | var parts = []; |
| | | var node = path.getValue(); |
| | | |
| | | if (!node || !node.comments) { |
| | | return ""; |
| | | } |
| | | |
| | | path.each(function (commentPath) { |
| | | var comment = commentPath.getValue(); |
| | | |
| | | if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) { |
| | | parts.push(printComment(commentPath, options)); |
| | | } |
| | | }, "comments"); |
| | | |
| | | if (parts.length === 0) { |
| | | return ""; |
| | | } |
| | | |
| | | if (sameIndent) { |
| | | return join$1(hardline$1, parts); |
| | | } |
| | | |
| | | return indent$1(concat$2([hardline$1, join$1(hardline$1, parts)])); |
| | | } |
| | | |
| | | function prependCursorPlaceholder(path, options, printed) { |
| | | if (path.getNode() === options.cursorNode && path.getValue()) { |
| | | return concat$2([cursor$2, printed, cursor$2]); |
| | | } |
| | | |
| | | return printed; |
| | | } |
| | | |
| | | function printComments(path, print, options, needsSemi) { |
| | | var value = path.getValue(); |
| | | var printed = print(path); |
| | | var comments = value && value.comments; |
| | | |
| | | if (!comments || comments.length === 0) { |
| | | return prependCursorPlaceholder(path, options, printed); |
| | | } |
| | | |
| | | var leadingParts = []; |
| | | var trailingParts = [needsSemi ? ";" : "", printed]; |
| | | path.each(function (commentPath) { |
| | | var comment = commentPath.getValue(); |
| | | var leading = comment.leading, |
| | | trailing = comment.trailing; |
| | | |
| | | if (leading) { |
| | | var contents = printLeadingComment(commentPath, print, options); |
| | | |
| | | if (!contents) { |
| | | return; |
| | | } |
| | | |
| | | leadingParts.push(contents); |
| | | var text = options.originalText; |
| | | var index = skipNewline$1(text, options.locEnd(comment)); |
| | | |
| | | if (index !== false && hasNewline$1(text, index)) { |
| | | leadingParts.push(hardline$1); |
| | | } |
| | | } else if (trailing) { |
| | | trailingParts.push(printTrailingComment(commentPath, print, options)); |
| | | } |
| | | }, "comments"); |
| | | return prependCursorPlaceholder(path, options, concat$2(leadingParts.concat(trailingParts))); |
| | | } |
| | | |
| | | var comments = { |
| | | attach: attach, |
| | | printComments: printComments, |
| | | printDanglingComments: printDanglingComments, |
| | | getSortedChildNodes: getSortedChildNodes |
| | | }; |
| | | |
| | | function FastPath(value) { |
| | | assert.ok(this instanceof FastPath); |
| | | this.stack = [value]; |
| | | } // The name of the current property is always the penultimate element of |
| | | // this.stack, and always a String. |
| | | |
| | | |
| | | FastPath.prototype.getName = function getName() { |
| | | var s = this.stack; |
| | | var len = s.length; |
| | | |
| | | if (len > 1) { |
| | | return s[len - 2]; |
| | | } // Since the name is always a string, null is a safe sentinel value to |
| | | // return if we do not know the name of the (root) value. |
| | | |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | return null; |
| | | }; // The value of the current property is always the final element of |
| | | // this.stack. |
| | | |
| | | |
| | | FastPath.prototype.getValue = function getValue() { |
| | | var s = this.stack; |
| | | return s[s.length - 1]; |
| | | }; |
| | | |
| | | function getNodeHelper(path, count) { |
| | | var stackIndex = getNodeStackIndexHelper(path.stack, count); |
| | | return stackIndex === -1 ? null : path.stack[stackIndex]; |
| | | } |
| | | |
| | | function getNodeStackIndexHelper(stack, count) { |
| | | for (var i = stack.length - 1; i >= 0; i -= 2) { |
| | | var value = stack[i]; |
| | | |
| | | if (value && !Array.isArray(value) && --count < 0) { |
| | | return i; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | FastPath.prototype.getNode = function getNode(count) { |
| | | return getNodeHelper(this, ~~count); |
| | | }; |
| | | |
| | | FastPath.prototype.getParentNode = function getParentNode(count) { |
| | | return getNodeHelper(this, ~~count + 1); |
| | | }; // Temporarily push properties named by string arguments given after the |
| | | // callback function onto this.stack, then call the callback with a |
| | | // reference to this (modified) FastPath object. Note that the stack will |
| | | // be restored to its original state after the callback is finished, so it |
| | | // is probably a mistake to retain a reference to the path. |
| | | |
| | | |
| | | FastPath.prototype.call = function call(callback |
| | | /*, name1, name2, ... */ |
| | | ) { |
| | | var s = this.stack; |
| | | var origLen = s.length; |
| | | var value = s[origLen - 1]; |
| | | var argc = arguments.length; |
| | | |
| | | for (var i = 1; i < argc; ++i) { |
| | | var name = arguments[i]; |
| | | value = value[name]; |
| | | s.push(name, value); |
| | | } |
| | | |
| | | var result = callback(this); |
| | | s.length = origLen; |
| | | return result; |
| | | }; |
| | | |
| | | FastPath.prototype.callParent = function callParent(callback, count) { |
| | | var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1); |
| | | var parentValues = this.stack.splice(stackIndex + 1); |
| | | var result = callback(this); |
| | | Array.prototype.push.apply(this.stack, parentValues); |
| | | return result; |
| | | }; // Similar to FastPath.prototype.call, except that the value obtained by |
| | | // accessing this.getValue()[name1][name2]... should be array-like. The |
| | | // callback will be called with a reference to this path object for each |
| | | // element of the array. |
| | | |
| | | |
| | | FastPath.prototype.each = function each(callback |
| | | /*, name1, name2, ... */ |
| | | ) { |
| | | var s = this.stack; |
| | | var origLen = s.length; |
| | | var value = s[origLen - 1]; |
| | | var argc = arguments.length; |
| | | |
| | | for (var i = 1; i < argc; ++i) { |
| | | var name = arguments[i]; |
| | | value = value[name]; |
| | | s.push(name, value); |
| | | } |
| | | |
| | | for (var _i = 0; _i < value.length; ++_i) { |
| | | if (_i in value) { |
| | | s.push(_i, value[_i]); // If the callback needs to know the value of i, call |
| | | // path.getName(), assuming path is the parameter name. |
| | | |
| | | callback(this); |
| | | s.length -= 2; |
| | | } |
| | | } |
| | | |
| | | s.length = origLen; |
| | | }; // Similar to FastPath.prototype.each, except that the results of the |
| | | // callback function invocations are stored in an array and returned at |
| | | // the end of the iteration. |
| | | |
| | | |
| | | FastPath.prototype.map = function map(callback |
| | | /*, name1, name2, ... */ |
| | | ) { |
| | | var s = this.stack; |
| | | var origLen = s.length; |
| | | var value = s[origLen - 1]; |
| | | var argc = arguments.length; |
| | | |
| | | for (var i = 1; i < argc; ++i) { |
| | | var name = arguments[i]; |
| | | value = value[name]; |
| | | s.push(name, value); |
| | | } |
| | | |
| | | var result = new Array(value.length); |
| | | |
| | | for (var _i2 = 0; _i2 < value.length; ++_i2) { |
| | | if (_i2 in value) { |
| | | s.push(_i2, value[_i2]); |
| | | result[_i2] = callback(this, _i2); |
| | | s.length -= 2; |
| | | } |
| | | } |
| | | |
| | | s.length = origLen; |
| | | return result; |
| | | }; |
| | | |
| | | var fastPath = FastPath; |
| | | |
| | | var normalize$2 = options$1.normalize; |
| | | |
| | | function printSubtree(path, print, options, printAstToDoc) { |
| | | if (options.printer.embed) { |
| | | return options.printer.embed(path, print, function (text, partialNextOptions) { |
| | | return textToDoc(text, partialNextOptions, options, printAstToDoc); |
| | | }, options); |
| | | } |
| | | } |
| | | |
| | | function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) { |
| | | var nextOptions = normalize$2(Object.assign({}, parentOptions, partialNextOptions, { |
| | | parentParser: parentOptions.parser, |
| | | embeddedInHtml: !!(parentOptions.embeddedInHtml || parentOptions.parser === "html" || parentOptions.parser === "vue" || parentOptions.parser === "angular" || parentOptions.parser === "lwc"), |
| | | originalText: text |
| | | }), { |
| | | passThrough: true |
| | | }); |
| | | var result = parser.parse(text, nextOptions); |
| | | var ast = result.ast; |
| | | text = result.text; |
| | | var astComments = ast.comments; |
| | | delete ast.comments; |
| | | comments.attach(astComments, ast, text, nextOptions); |
| | | return printAstToDoc(ast, nextOptions); |
| | | } |
| | | |
| | | var multiparser = { |
| | | printSubtree: printSubtree |
| | | }; |
| | | |
| | | var doc$1 = doc; |
| | | var docBuilders$1 = doc$1.builders; |
| | | var concat$3 = docBuilders$1.concat; |
| | | var hardline$2 = docBuilders$1.hardline; |
| | | var addAlignmentToDoc$1 = docBuilders$1.addAlignmentToDoc; |
| | | var docUtils$1 = doc$1.utils; |
| | | /** |
| | | * Takes an abstract syntax tree (AST) and recursively converts it to a |
| | | * document (series of printing primitives). |
| | | * |
| | | * This is done by descending down the AST recursively. The recursion |
| | | * involves two functions that call each other: |
| | | * |
| | | * 1. printGenerically(), which is defined as an inner function here. |
| | | * It basically takes care of node caching. |
| | | * 2. callPluginPrintFunction(), which checks for some options, and |
| | | * ultimately calls the print() function provided by the plugin. |
| | | * |
| | | * The plugin function will call printGenerically() again for child nodes |
| | | * of the current node, which will do its housekeeping, then call the |
| | | * plugin function again, and so on. |
| | | * |
| | | * All the while, these functions pass a "path" variable around, which |
| | | * is a stack-like data structure (FastPath) that maintains the current |
| | | * state of the recursion. It is called "path", because it represents |
| | | * the path to the current node through the Abstract Syntax Tree. |
| | | */ |
| | | |
| | | function printAstToDoc(ast, options) { |
| | | var alignmentSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; |
| | | var printer = options.printer; |
| | | |
| | | if (printer.preprocess) { |
| | | ast = printer.preprocess(ast, options); |
| | | } |
| | | |
| | | var cache = new Map(); |
| | | |
| | | function printGenerically(path, args) { |
| | | var node = path.getValue(); |
| | | var shouldCache = node && _typeof(node) === "object" && args === undefined; |
| | | |
| | | if (shouldCache && cache.has(node)) { |
| | | return cache.get(node); |
| | | } // We let JSXElement print its comments itself because it adds () around |
| | | // UnionTypeAnnotation has to align the child without the comments |
| | | |
| | | |
| | | var res; |
| | | |
| | | if (printer.willPrintOwnComments && printer.willPrintOwnComments(path, options)) { |
| | | res = callPluginPrintFunction(path, options, printGenerically, args); |
| | | } else { |
| | | // printComments will call the plugin print function and check for |
| | | // comments to print |
| | | res = comments.printComments(path, function (p) { |
| | | return callPluginPrintFunction(p, options, printGenerically, args); |
| | | }, options, args && args.needsSemi); |
| | | } |
| | | |
| | | if (shouldCache) { |
| | | cache.set(node, res); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | var doc = printGenerically(new fastPath(ast)); |
| | | |
| | | if (alignmentSize > 0) { |
| | | // Add a hardline to make the indents take effect |
| | | // It should be removed in index.js format() |
| | | doc = addAlignmentToDoc$1(concat$3([hardline$2, doc]), alignmentSize, options.tabWidth); |
| | | } |
| | | |
| | | docUtils$1.propagateBreaks(doc); |
| | | return doc; |
| | | } |
| | | |
| | | function callPluginPrintFunction(path, options, printPath, args) { |
| | | assert.ok(path instanceof fastPath); |
| | | var node = path.getValue(); |
| | | var printer = options.printer; // Escape hatch |
| | | |
| | | if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) { |
| | | return options.originalText.slice(options.locStart(node), options.locEnd(node)); |
| | | } |
| | | |
| | | if (node) { |
| | | try { |
| | | // Potentially switch to a different parser |
| | | var sub = multiparser.printSubtree(path, printPath, options, printAstToDoc); |
| | | |
| | | if (sub) { |
| | | return sub; |
| | | } |
| | | } catch (error) { |
| | | /* istanbul ignore if */ |
| | | if (commonjsGlobal.PRETTIER_DEBUG) { |
| | | throw error; |
| | | } // Continue with current parser |
| | | |
| | | } |
| | | } |
| | | |
| | | return printer.print(path, options, printPath, args); |
| | | } |
| | | |
| | | var astToDoc = printAstToDoc; |
| | | |
| | | function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) { |
| | | var resultStartNode = startNodeAndParents.node; |
| | | var resultEndNode = endNodeAndParents.node; |
| | | |
| | | if (resultStartNode === resultEndNode) { |
| | | return { |
| | | startNode: resultStartNode, |
| | | endNode: resultEndNode |
| | | }; |
| | | } |
| | | |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var endParent = _step.value; |
| | | |
| | | if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) { |
| | | resultEndNode = endParent; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var startParent = _step2.value; |
| | | |
| | | if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) { |
| | | resultStartNode = startParent; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return { |
| | | startNode: resultStartNode, |
| | | endNode: resultEndNode |
| | | }; |
| | | } |
| | | |
| | | function findNodeAtOffset(node, offset, options, predicate, parentNodes) { |
| | | predicate = predicate || function () { |
| | | return true; |
| | | }; |
| | | |
| | | parentNodes = parentNodes || []; |
| | | var start = options.locStart(node, options.locStart); |
| | | var end = options.locEnd(node, options.locEnd); |
| | | |
| | | if (start <= offset && offset <= end) { |
| | | var _iteratorNormalCompletion3 = true; |
| | | var _didIteratorError3 = false; |
| | | var _iteratorError3 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
| | | var childNode = _step3.value; |
| | | var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes)); |
| | | |
| | | if (childResult) { |
| | | return childResult; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError3 = true; |
| | | _iteratorError3 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion3 && _iterator3.return != null) { |
| | | _iterator3.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError3) { |
| | | throw _iteratorError3; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (predicate(node)) { |
| | | return { |
| | | node: node, |
| | | parentNodes: parentNodes |
| | | }; |
| | | } |
| | | } |
| | | } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5 |
| | | |
| | | |
| | | function isSourceElement(opts, node) { |
| | | if (node == null) { |
| | | return false; |
| | | } // JS and JS like to avoid repetitions |
| | | |
| | | |
| | | var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015 |
| | | "ImportDeclaration", // Module |
| | | "ExportDefaultDeclaration", // Module |
| | | "ExportNamedDeclaration", // Module |
| | | "ExportAllDeclaration", // Module |
| | | "TypeAlias", // Flow |
| | | "InterfaceDeclaration", // Flow, TypeScript |
| | | "TypeAliasDeclaration", // TypeScript |
| | | "ExportAssignment", // TypeScript |
| | | "ExportDeclaration" // TypeScript |
| | | ]; |
| | | var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"]; |
| | | var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"]; |
| | | |
| | | switch (opts.parser) { |
| | | case "flow": |
| | | case "babel": |
| | | case "typescript": |
| | | return jsSourceElements.indexOf(node.type) > -1; |
| | | |
| | | case "json": |
| | | return jsonSourceElements.indexOf(node.type) > -1; |
| | | |
| | | case "graphql": |
| | | return graphqlSourceElements.indexOf(node.kind) > -1; |
| | | |
| | | case "vue": |
| | | return node.tag !== "root"; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function calculateRange(text, opts, ast) { |
| | | // Contract the range so that it has non-whitespace characters at its endpoints. |
| | | // This ensures we can format a range that doesn't end on a node. |
| | | var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd); |
| | | var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart); |
| | | var endNonWhitespace; |
| | | |
| | | for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) { |
| | | if (text[endNonWhitespace - 1].match(/\S/)) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) { |
| | | return isSourceElement(opts, node); |
| | | }); |
| | | var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) { |
| | | return isSourceElement(opts, node); |
| | | }); |
| | | |
| | | if (!startNodeAndParents || !endNodeAndParents) { |
| | | return { |
| | | rangeStart: 0, |
| | | rangeEnd: 0 |
| | | }; |
| | | } |
| | | |
| | | var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts); |
| | | var startNode = siblingAncestors.startNode, |
| | | endNode = siblingAncestors.endNode; |
| | | var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart)); |
| | | var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd)); |
| | | return { |
| | | rangeStart: rangeStart, |
| | | rangeEnd: rangeEnd |
| | | }; |
| | | } |
| | | |
| | | var rangeUtil = { |
| | | calculateRange: calculateRange, |
| | | findNodeAtOffset: findNodeAtOffset |
| | | }; |
| | | |
| | | var diff = getCjsExportFromNamespace(index_es6); |
| | | |
| | | var normalizeOptions$1 = options$1.normalize; |
| | | var guessEndOfLine$1 = endOfLine.guessEndOfLine, |
| | | convertEndOfLineToChars$2 = endOfLine.convertEndOfLineToChars; |
| | | var mapDoc$2 = doc.utils.mapDoc, |
| | | _printDocToString = doc.printer.printDocToString, |
| | | printDocToDebug = doc.debug.printDocToDebug; |
| | | var UTF8BOM = 0xfeff; |
| | | var CURSOR = Symbol("cursor"); |
| | | var PLACEHOLDERS = { |
| | | cursorOffset: "<<<PRETTIER_CURSOR>>>", |
| | | rangeStart: "<<<PRETTIER_RANGE_START>>>", |
| | | rangeEnd: "<<<PRETTIER_RANGE_END>>>" |
| | | }; |
| | | |
| | | function ensureAllCommentsPrinted(astComments) { |
| | | if (!astComments) { |
| | | return; |
| | | } |
| | | |
| | | for (var i = 0; i < astComments.length; ++i) { |
| | | if (astComments[i].value.trim() === "prettier-ignore") { |
| | | // If there's a prettier-ignore, we're not printing that sub-tree so we |
| | | // don't know if the comments was printed or not. |
| | | return; |
| | | } |
| | | } |
| | | |
| | | astComments.forEach(function (comment) { |
| | | if (!comment.printed) { |
| | | throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!'); |
| | | } |
| | | |
| | | delete comment.printed; |
| | | }); |
| | | } |
| | | |
| | | function attachComments(text, ast, opts) { |
| | | var astComments = ast.comments; |
| | | |
| | | if (astComments) { |
| | | delete ast.comments; |
| | | comments.attach(astComments, ast, text, opts); |
| | | } |
| | | |
| | | ast.tokens = []; |
| | | opts.originalText = opts.parser === "yaml" ? text : text.trimRight(); |
| | | return astComments; |
| | | } |
| | | |
| | | function coreFormat(text, opts, addAlignmentSize) { |
| | | if (!text || !text.trim().length) { |
| | | return { |
| | | formatted: "", |
| | | cursorOffset: 0 |
| | | }; |
| | | } |
| | | |
| | | addAlignmentSize = addAlignmentSize || 0; |
| | | var parsed = parser.parse(text, opts); |
| | | var ast = parsed.ast; |
| | | text = parsed.text; |
| | | |
| | | if (opts.cursorOffset >= 0) { |
| | | var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts); |
| | | |
| | | if (nodeResult && nodeResult.node) { |
| | | opts.cursorNode = nodeResult.node; |
| | | } |
| | | } |
| | | |
| | | var astComments = attachComments(text, ast, opts); |
| | | var doc = astToDoc(ast, opts, addAlignmentSize); |
| | | var eol = convertEndOfLineToChars$2(opts.endOfLine); |
| | | |
| | | var result = _printDocToString(opts.endOfLine === "lf" ? doc : mapDoc$2(doc, function (currentDoc) { |
| | | return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc; |
| | | }), opts); |
| | | |
| | | ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline |
| | | |
| | | if (addAlignmentSize > 0) { |
| | | var trimmed = result.formatted.trim(); |
| | | |
| | | if (result.cursorNodeStart !== undefined) { |
| | | result.cursorNodeStart -= result.formatted.indexOf(trimmed); |
| | | } |
| | | |
| | | result.formatted = trimmed + convertEndOfLineToChars$2(opts.endOfLine); |
| | | } |
| | | |
| | | if (opts.cursorOffset >= 0) { |
| | | var oldCursorNodeStart; |
| | | var oldCursorNodeText; |
| | | var cursorOffsetRelativeToOldCursorNode; |
| | | var newCursorNodeStart; |
| | | var newCursorNodeText; |
| | | |
| | | if (opts.cursorNode && result.cursorNodeText) { |
| | | oldCursorNodeStart = opts.locStart(opts.cursorNode); |
| | | oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode)); |
| | | cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart; |
| | | newCursorNodeStart = result.cursorNodeStart; |
| | | newCursorNodeText = result.cursorNodeText; |
| | | } else { |
| | | oldCursorNodeStart = 0; |
| | | oldCursorNodeText = text; |
| | | cursorOffsetRelativeToOldCursorNode = opts.cursorOffset; |
| | | newCursorNodeStart = 0; |
| | | newCursorNodeText = result.formatted; |
| | | } |
| | | |
| | | if (oldCursorNodeText === newCursorNodeText) { |
| | | return { |
| | | formatted: result.formatted, |
| | | cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode |
| | | }; |
| | | } // diff old and new cursor node texts, with a special cursor |
| | | // symbol inserted to find out where it moves to |
| | | |
| | | |
| | | var oldCursorNodeCharArray = oldCursorNodeText.split(""); |
| | | oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR); |
| | | var newCursorNodeCharArray = newCursorNodeText.split(""); |
| | | var cursorNodeDiff = diff.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray); |
| | | var cursorOffset = newCursorNodeStart; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var entry = _step.value; |
| | | |
| | | if (entry.removed) { |
| | | if (entry.value.indexOf(CURSOR) > -1) { |
| | | break; |
| | | } |
| | | } else { |
| | | cursorOffset += entry.count; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return { |
| | | formatted: result.formatted, |
| | | cursorOffset: cursorOffset |
| | | }; |
| | | } |
| | | |
| | | return { |
| | | formatted: result.formatted |
| | | }; |
| | | } |
| | | |
| | | function formatRange(text, opts) { |
| | | var parsed = parser.parse(text, opts); |
| | | var ast = parsed.ast; |
| | | text = parsed.text; |
| | | var range = rangeUtil.calculateRange(text, opts, ast); |
| | | var rangeStart = range.rangeStart; |
| | | var rangeEnd = range.rangeEnd; |
| | | var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line. |
| | | // This is so we can detect indentation correctly and restore it. |
| | | // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0 |
| | | |
| | | var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1); |
| | | var indentString = text.slice(rangeStart2, rangeStart); |
| | | var alignmentSize = util.getAlignmentSize(indentString, opts.tabWidth); |
| | | var rangeResult = coreFormat(rangeString, Object.assign({}, opts, { |
| | | rangeStart: 0, |
| | | rangeEnd: Infinity, |
| | | // track the cursor offset only if it's within our range |
| | | cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1 |
| | | }), alignmentSize); // Since the range contracts to avoid trailing whitespace, |
| | | // we need to remove the newline that was inserted by the `format` call. |
| | | |
| | | var rangeTrimmed = rangeResult.formatted.trimRight(); |
| | | var rangeLeft = text.slice(0, rangeStart); |
| | | var rangeRight = text.slice(rangeEnd); |
| | | var cursorOffset = opts.cursorOffset; |
| | | |
| | | if (opts.cursorOffset >= rangeEnd) { |
| | | // handle the case where the cursor was past the end of the range |
| | | cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length); |
| | | } else if (rangeResult.cursorOffset !== undefined) { |
| | | // handle the case where the cursor was in the range |
| | | cursorOffset = rangeResult.cursorOffset + rangeStart; |
| | | } // keep the cursor as it was if it was before the start of the range |
| | | |
| | | |
| | | var formatted; |
| | | |
| | | if (opts.endOfLine === "lf") { |
| | | formatted = rangeLeft + rangeTrimmed + rangeRight; |
| | | } else { |
| | | var eol = convertEndOfLineToChars$2(opts.endOfLine); |
| | | |
| | | if (cursorOffset >= 0) { |
| | | var parts = [rangeLeft, rangeTrimmed, rangeRight]; |
| | | var partIndex = 0; |
| | | var partOffset = cursorOffset; |
| | | |
| | | while (partIndex < parts.length) { |
| | | var part = parts[partIndex]; |
| | | |
| | | if (partOffset < part.length) { |
| | | parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset); |
| | | break; |
| | | } |
| | | |
| | | partIndex++; |
| | | partOffset -= part.length; |
| | | } |
| | | |
| | | var newRangeLeft = parts[0], |
| | | newRangeTrimmed = parts[1], |
| | | newRangeRight = parts[2]; |
| | | formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) { |
| | | cursorOffset = index; |
| | | return ""; |
| | | }); |
| | | } else { |
| | | formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol); |
| | | } |
| | | } |
| | | |
| | | return { |
| | | formatted: formatted, |
| | | cursorOffset: cursorOffset |
| | | }; |
| | | } |
| | | |
| | | function format(text, opts) { |
| | | var selectedParser = parser.resolveParser(opts); |
| | | var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text); |
| | | |
| | | if (opts.requirePragma && !hasPragma) { |
| | | return { |
| | | formatted: text |
| | | }; |
| | | } |
| | | |
| | | if (opts.endOfLine === "auto") { |
| | | opts.endOfLine = guessEndOfLine$1(text); |
| | | } |
| | | |
| | | var hasCursor = opts.cursorOffset >= 0; |
| | | var hasRangeStart = opts.rangeStart > 0; |
| | | var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing |
| | | |
| | | if (text.indexOf("\r") !== -1) { |
| | | var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) { |
| | | return opts[aKey] - opts[bKey]; |
| | | }); |
| | | |
| | | for (var i = offsetKeys.length - 1; i >= 0; i--) { |
| | | var key = offsetKeys[i]; |
| | | text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]); |
| | | } |
| | | |
| | | text = text.replace(/\r\n?/g, "\n"); |
| | | |
| | | var _loop = function _loop(_i) { |
| | | var key = offsetKeys[_i]; |
| | | text = text.replace(PLACEHOLDERS[key], function (_, index) { |
| | | opts[key] = index; |
| | | return ""; |
| | | }); |
| | | }; |
| | | |
| | | for (var _i = 0; _i < offsetKeys.length; _i++) { |
| | | _loop(_i); |
| | | } |
| | | } |
| | | |
| | | var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM; |
| | | |
| | | if (hasUnicodeBOM) { |
| | | text = text.substring(1); |
| | | |
| | | if (hasCursor) { |
| | | opts.cursorOffset++; |
| | | } |
| | | |
| | | if (hasRangeStart) { |
| | | opts.rangeStart++; |
| | | } |
| | | |
| | | if (hasRangeEnd) { |
| | | opts.rangeEnd++; |
| | | } |
| | | } |
| | | |
| | | if (!hasCursor) { |
| | | opts.cursorOffset = -1; |
| | | } |
| | | |
| | | if (opts.rangeStart < 0) { |
| | | opts.rangeStart = 0; |
| | | } |
| | | |
| | | if (opts.rangeEnd > text.length) { |
| | | opts.rangeEnd = text.length; |
| | | } |
| | | |
| | | var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts); |
| | | |
| | | if (hasUnicodeBOM) { |
| | | result.formatted = String.fromCharCode(UTF8BOM) + result.formatted; |
| | | |
| | | if (hasCursor) { |
| | | result.cursorOffset++; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | var core = { |
| | | formatWithCursor: function formatWithCursor(text, opts) { |
| | | opts = normalizeOptions$1(opts); |
| | | return format(text, opts); |
| | | }, |
| | | parse: function parse(text, opts, massage) { |
| | | opts = normalizeOptions$1(opts); |
| | | |
| | | if (text.indexOf("\r") !== -1) { |
| | | text = text.replace(/\r\n?/g, "\n"); |
| | | } |
| | | |
| | | var parsed = parser.parse(text, opts); |
| | | |
| | | if (massage) { |
| | | parsed.ast = massageAst(parsed.ast, opts); |
| | | } |
| | | |
| | | return parsed; |
| | | }, |
| | | formatAST: function formatAST(ast, opts) { |
| | | opts = normalizeOptions$1(opts); |
| | | var doc = astToDoc(ast, opts); |
| | | return _printDocToString(doc, opts); |
| | | }, |
| | | // Doesn't handle shebang for now |
| | | formatDoc: function formatDoc(doc, opts) { |
| | | var debug = printDocToDebug(doc); |
| | | opts = normalizeOptions$1(Object.assign({}, opts, { |
| | | parser: "babel" |
| | | })); |
| | | return format(debug, opts).formatted; |
| | | }, |
| | | printToDoc: function printToDoc(text, opts) { |
| | | opts = normalizeOptions$1(opts); |
| | | var parsed = parser.parse(text, opts); |
| | | var ast = parsed.ast; |
| | | text = parsed.text; |
| | | attachComments(text, ast, opts); |
| | | return astToDoc(ast, opts); |
| | | }, |
| | | printDocToString: function printDocToString(doc, opts) { |
| | | return _printDocToString(doc, normalizeOptions$1(opts)); |
| | | } |
| | | }; |
| | | |
| | | var index = [ |
| | | "a", |
| | | "abbr", |
| | | "acronym", |
| | | "address", |
| | | "applet", |
| | | "area", |
| | | "article", |
| | | "aside", |
| | | "audio", |
| | | "b", |
| | | "base", |
| | | "basefont", |
| | | "bdi", |
| | | "bdo", |
| | | "bgsound", |
| | | "big", |
| | | "blink", |
| | | "blockquote", |
| | | "body", |
| | | "br", |
| | | "button", |
| | | "canvas", |
| | | "caption", |
| | | "center", |
| | | "cite", |
| | | "code", |
| | | "col", |
| | | "colgroup", |
| | | "command", |
| | | "content", |
| | | "data", |
| | | "datalist", |
| | | "dd", |
| | | "del", |
| | | "details", |
| | | "dfn", |
| | | "dialog", |
| | | "dir", |
| | | "div", |
| | | "dl", |
| | | "dt", |
| | | "element", |
| | | "em", |
| | | "embed", |
| | | "fieldset", |
| | | "figcaption", |
| | | "figure", |
| | | "font", |
| | | "footer", |
| | | "form", |
| | | "frame", |
| | | "frameset", |
| | | "h1", |
| | | "h2", |
| | | "h3", |
| | | "h4", |
| | | "h5", |
| | | "h6", |
| | | "head", |
| | | "header", |
| | | "hgroup", |
| | | "hr", |
| | | "html", |
| | | "i", |
| | | "iframe", |
| | | "image", |
| | | "img", |
| | | "input", |
| | | "ins", |
| | | "isindex", |
| | | "kbd", |
| | | "keygen", |
| | | "label", |
| | | "legend", |
| | | "li", |
| | | "link", |
| | | "listing", |
| | | "main", |
| | | "map", |
| | | "mark", |
| | | "marquee", |
| | | "math", |
| | | "menu", |
| | | "menuitem", |
| | | "meta", |
| | | "meter", |
| | | "multicol", |
| | | "nav", |
| | | "nextid", |
| | | "nobr", |
| | | "noembed", |
| | | "noframes", |
| | | "noscript", |
| | | "object", |
| | | "ol", |
| | | "optgroup", |
| | | "option", |
| | | "output", |
| | | "p", |
| | | "param", |
| | | "picture", |
| | | "plaintext", |
| | | "pre", |
| | | "progress", |
| | | "q", |
| | | "rb", |
| | | "rbc", |
| | | "rp", |
| | | "rt", |
| | | "rtc", |
| | | "ruby", |
| | | "s", |
| | | "samp", |
| | | "script", |
| | | "section", |
| | | "select", |
| | | "shadow", |
| | | "slot", |
| | | "small", |
| | | "source", |
| | | "spacer", |
| | | "span", |
| | | "strike", |
| | | "strong", |
| | | "style", |
| | | "sub", |
| | | "summary", |
| | | "sup", |
| | | "svg", |
| | | "table", |
| | | "tbody", |
| | | "td", |
| | | "template", |
| | | "textarea", |
| | | "tfoot", |
| | | "th", |
| | | "thead", |
| | | "time", |
| | | "title", |
| | | "tr", |
| | | "track", |
| | | "tt", |
| | | "u", |
| | | "ul", |
| | | "var", |
| | | "video", |
| | | "wbr", |
| | | "xmp" |
| | | ]; |
| | | |
| | | var htmlTagNames = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | 'default': index |
| | | }); |
| | | |
| | | var htmlTagNames$1 = getCjsExportFromNamespace(htmlTagNames); |
| | | |
| | | function clean(ast, newObj, parent) { |
| | | ["raw", // front-matter |
| | | "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) { |
| | | delete newObj[name]; |
| | | }); |
| | | |
| | | if (ast.type === "yaml") { |
| | | delete newObj.value; |
| | | } // --insert-pragma |
| | | |
| | | |
| | | if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment |
| | | parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) { |
| | | /** |
| | | * something |
| | | * |
| | | * @format |
| | | */ |
| | | delete newObj.text; // standalone pragma |
| | | |
| | | if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") { |
| | | delete newObj.value; |
| | | } |
| | | |
| | | if (ast.type === "css-rule") { |
| | | delete newObj.params; |
| | | } |
| | | |
| | | if (ast.type === "selector-combinator") { |
| | | newObj.value = newObj.value.replace(/\s+/g, " "); |
| | | } |
| | | |
| | | if (ast.type === "media-feature") { |
| | | newObj.value = newObj.value.replace(/ /g, ""); |
| | | } |
| | | |
| | | if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].indexOf(newObj.value.replace().toLowerCase()) !== -1) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") { |
| | | newObj.value = newObj.value.toLowerCase(); |
| | | } |
| | | |
| | | if (ast.type === "css-decl") { |
| | | newObj.prop = newObj.prop.toLowerCase(); |
| | | } |
| | | |
| | | if (ast.type === "css-atrule" || ast.type === "css-import") { |
| | | newObj.name = newObj.name.toLowerCase(); |
| | | } |
| | | |
| | | if (ast.type === "value-number") { |
| | | newObj.unit = newObj.unit.toLowerCase(); |
| | | } |
| | | |
| | | if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) { |
| | | newObj.value = cleanCSSStrings(newObj.value); |
| | | } |
| | | |
| | | if (ast.type === "selector-attribute") { |
| | | newObj.attribute = newObj.attribute.trim(); |
| | | |
| | | if (newObj.namespace) { |
| | | if (typeof newObj.namespace === "string") { |
| | | newObj.namespace = newObj.namespace.trim(); |
| | | |
| | | if (newObj.namespace.length === 0) { |
| | | newObj.namespace = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (newObj.value) { |
| | | newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, ""); |
| | | delete newObj.quoted; |
| | | } |
| | | } |
| | | |
| | | if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) { |
| | | newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) { |
| | | var num = Number(numStr); |
| | | return isNaN(num) ? match : num + unit.toLowerCase(); |
| | | }); |
| | | } |
| | | |
| | | if (ast.type === "selector-tag") { |
| | | var lowercasedValue = ast.value.toLowerCase(); |
| | | |
| | | if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) { |
| | | newObj.value = lowercasedValue; |
| | | } |
| | | |
| | | if (["from", "to"].indexOf(lowercasedValue) !== -1) { |
| | | newObj.value = lowercasedValue; |
| | | } |
| | | } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func` |
| | | |
| | | |
| | | if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") { |
| | | delete newObj.value; |
| | | } // Workaround for SCSS nested properties |
| | | |
| | | |
| | | if (ast.type === "selector-unknown") { |
| | | delete newObj.value; |
| | | } |
| | | } |
| | | |
| | | function cleanCSSStrings(value) { |
| | | return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1"); |
| | | } |
| | | |
| | | var clean_1 = clean; |
| | | |
| | | var _require$$0$builders$1 = doc.builders, |
| | | hardline$3 = _require$$0$builders$1.hardline, |
| | | literalline$1 = _require$$0$builders$1.literalline, |
| | | concat$4 = _require$$0$builders$1.concat, |
| | | markAsRoot$1 = _require$$0$builders$1.markAsRoot, |
| | | mapDoc$3 = doc.utils.mapDoc; |
| | | |
| | | function embed(path, print, textToDoc |
| | | /*, options */ |
| | | ) { |
| | | var node = path.getValue(); |
| | | |
| | | if (node.type === "yaml") { |
| | | return markAsRoot$1(concat$4(["---", hardline$3, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, { |
| | | parser: "yaml" |
| | | })) : "", "---", hardline$3])); |
| | | } |
| | | |
| | | return null; |
| | | |
| | | function replaceNewlinesWithLiterallines(doc) { |
| | | return mapDoc$3(doc, function (currentDoc) { |
| | | return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$4(currentDoc.split(/(\n)/g).map(function (v, i) { |
| | | return i % 2 === 0 ? v : literalline$1; |
| | | })) : currentDoc; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | var embed_1 = embed; |
| | | |
| | | var detectNewline = createCommonjsModule(function (module) { |
| | | |
| | | module.exports = function (str) { |
| | | if (typeof str !== 'string') { |
| | | throw new TypeError('Expected a string'); |
| | | } |
| | | |
| | | var newlines = str.match(/(?:\r?\n)/g) || []; |
| | | |
| | | if (newlines.length === 0) { |
| | | return null; |
| | | } |
| | | |
| | | var crlf = newlines.filter(function (el) { |
| | | return el === '\r\n'; |
| | | }).length; |
| | | var lf = newlines.length - crlf; |
| | | return crlf > lf ? '\r\n' : '\n'; |
| | | }; |
| | | |
| | | module.exports.graceful = function (str) { |
| | | return module.exports(str) || '\n'; |
| | | }; |
| | | }); |
| | | var detectNewline_1 = detectNewline.graceful; |
| | | |
| | | var build = createCommonjsModule(function (module, exports) { |
| | | |
| | | Object.defineProperty(exports, '__esModule', { |
| | | value: true |
| | | }); |
| | | exports.extract = extract; |
| | | exports.strip = strip; |
| | | exports.parse = parse; |
| | | exports.parseWithComments = parseWithComments; |
| | | exports.print = print; |
| | | |
| | | function _os() { |
| | | var data = require$$0$1; |
| | | |
| | | _os = function _os() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _detectNewline() { |
| | | var data = _interopRequireDefault(detectNewline); |
| | | |
| | | _detectNewline = function _detectNewline() { |
| | | return data; |
| | | }; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | function _interopRequireDefault(obj) { |
| | | return obj && obj.__esModule ? obj : { |
| | | default: obj |
| | | }; |
| | | } |
| | | /** |
| | | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
| | | * |
| | | * This source code is licensed under the MIT license found in the |
| | | * LICENSE file in the root directory of this source tree. |
| | | */ |
| | | |
| | | |
| | | var commentEndRe = /\*\/$/; |
| | | var commentStartRe = /^\/\*\*/; |
| | | var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/; |
| | | var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g; |
| | | var ltrimNewlineRe = /^(\r?\n)+/; |
| | | var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g; |
| | | var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g; |
| | | var stringStartRe = /(\r?\n|^) *\* ?/g; |
| | | |
| | | function extract(contents) { |
| | | var match = contents.match(docblockRe); |
| | | return match ? match[0].trimLeft() : ''; |
| | | } |
| | | |
| | | function strip(contents) { |
| | | var match = contents.match(docblockRe); |
| | | return match && match[0] ? contents.substring(match[0].length) : contents; |
| | | } |
| | | |
| | | function parse(docblock) { |
| | | return parseWithComments(docblock).pragmas; |
| | | } |
| | | |
| | | function parseWithComments(docblock) { |
| | | var line = (0, _detectNewline().default)(docblock) || _os().EOL; |
| | | |
| | | docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives |
| | | |
| | | var prev = ''; |
| | | |
| | | while (prev !== docblock) { |
| | | prev = docblock; |
| | | docblock = docblock.replace(multilineRe, "".concat(line, "$1 $2").concat(line)); |
| | | } |
| | | |
| | | docblock = docblock.replace(ltrimNewlineRe, '').trimRight(); |
| | | var result = Object.create(null); |
| | | var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight(); |
| | | var match; |
| | | |
| | | while (match = propertyRe.exec(docblock)) { |
| | | // strip linecomments from pragmas |
| | | var nextPragma = match[2].replace(lineCommentRe, ''); |
| | | |
| | | if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) { |
| | | result[match[1]] = [].concat(result[match[1]], nextPragma); |
| | | } else { |
| | | result[match[1]] = nextPragma; |
| | | } |
| | | } |
| | | |
| | | return { |
| | | comments: comments, |
| | | pragmas: result |
| | | }; |
| | | } |
| | | |
| | | function print(_ref) { |
| | | var _ref$comments = _ref.comments, |
| | | comments = _ref$comments === void 0 ? '' : _ref$comments, |
| | | _ref$pragmas = _ref.pragmas, |
| | | pragmas = _ref$pragmas === void 0 ? {} : _ref$pragmas; |
| | | |
| | | var line = (0, _detectNewline().default)(comments) || _os().EOL; |
| | | |
| | | var head = '/**'; |
| | | var start = ' *'; |
| | | var tail = ' */'; |
| | | var keys = Object.keys(pragmas); |
| | | var printedObject = keys.map(function (key) { |
| | | return printKeyValues(key, pragmas[key]); |
| | | }).reduce(function (arr, next) { |
| | | return arr.concat(next); |
| | | }, []).map(function (keyValue) { |
| | | return start + ' ' + keyValue + line; |
| | | }).join(''); |
| | | |
| | | if (!comments) { |
| | | if (keys.length === 0) { |
| | | return ''; |
| | | } |
| | | |
| | | if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) { |
| | | var value = pragmas[keys[0]]; |
| | | return "".concat(head, " ").concat(printKeyValues(keys[0], value)[0]).concat(tail); |
| | | } |
| | | } |
| | | |
| | | var printedComments = comments.split(line).map(function (textLine) { |
| | | return "".concat(start, " ").concat(textLine); |
| | | }).join(line) + line; |
| | | return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail; |
| | | } |
| | | |
| | | function printKeyValues(key, valueOrArray) { |
| | | return [].concat(valueOrArray).map(function (value) { |
| | | return "@".concat(key, " ").concat(value).trim(); |
| | | }); |
| | | } |
| | | }); |
| | | unwrapExports(build); |
| | | var build_1 = build.extract; |
| | | var build_2 = build.strip; |
| | | var build_3 = build.parse; |
| | | var build_4 = build.parseWithComments; |
| | | var build_5 = build.print; |
| | | |
| | | function hasPragma(text) { |
| | | var pragmas = Object.keys(build.parse(build.extract(text))); |
| | | return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1; |
| | | } |
| | | |
| | | function insertPragma(text) { |
| | | var parsedDocblock = build.parseWithComments(build.extract(text)); |
| | | var pragmas = Object.assign({ |
| | | format: "" |
| | | }, parsedDocblock.pragmas); |
| | | var newDocblock = build.print({ |
| | | pragmas: pragmas, |
| | | comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines |
| | | |
| | | }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock) |
| | | |
| | | var strippedText = build.strip(text); |
| | | var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n"; |
| | | return newDocblock + separatingNewlines + strippedText; |
| | | } |
| | | |
| | | var pragma = { |
| | | hasPragma: hasPragma, |
| | | insertPragma: insertPragma |
| | | }; |
| | | |
| | | var DELIMITER_MAP = { |
| | | "---": "yaml", |
| | | "+++": "toml" |
| | | }; |
| | | |
| | | function parse$1(text) { |
| | | var delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp).join("|"); |
| | | var match = text.match( // trailing spaces after delimiters are allowed |
| | | new RegExp("^(".concat(delimiterRegex, ")[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)"))); |
| | | |
| | | if (match === null) { |
| | | return { |
| | | frontMatter: null, |
| | | content: text |
| | | }; |
| | | } |
| | | |
| | | var raw = match[0].replace(/\n$/, ""); |
| | | var delimiter = match[1]; |
| | | var value = match[2]; |
| | | return { |
| | | frontMatter: { |
| | | type: DELIMITER_MAP[delimiter], |
| | | value: value, |
| | | raw: raw |
| | | }, |
| | | content: match[0].replace(/[^\n]/g, " ") + text.slice(match[0].length) |
| | | }; |
| | | } |
| | | |
| | | var frontMatter = parse$1; |
| | | |
| | | function hasPragma$1(text) { |
| | | return pragma.hasPragma(frontMatter(text).content); |
| | | } |
| | | |
| | | function insertPragma$1(text) { |
| | | var _parseFrontMatter = frontMatter(text), |
| | | frontMatter$1 = _parseFrontMatter.frontMatter, |
| | | content = _parseFrontMatter.content; |
| | | |
| | | return (frontMatter$1 ? frontMatter$1.raw + "\n\n" : "") + pragma.insertPragma(content); |
| | | } |
| | | |
| | | var pragma$1 = { |
| | | hasPragma: hasPragma$1, |
| | | insertPragma: insertPragma$1 |
| | | }; |
| | | |
| | | var colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"]; |
| | | |
| | | function getAncestorCounter(path, typeOrTypes) { |
| | | var types = [].concat(typeOrTypes); |
| | | var counter = -1; |
| | | var ancestorNode; |
| | | |
| | | while (ancestorNode = path.getParentNode(++counter)) { |
| | | if (types.indexOf(ancestorNode.type) !== -1) { |
| | | return counter; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | function getAncestorNode(path, typeOrTypes) { |
| | | var counter = getAncestorCounter(path, typeOrTypes); |
| | | return counter === -1 ? null : path.getParentNode(counter); |
| | | } |
| | | |
| | | function getPropOfDeclNode(path) { |
| | | var declAncestorNode = getAncestorNode(path, "css-decl"); |
| | | return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase(); |
| | | } |
| | | |
| | | function isSCSS(parser, text) { |
| | | var hasExplicitParserChoice = parser === "less" || parser === "scss"; |
| | | var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/; |
| | | return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text); |
| | | } |
| | | |
| | | function isWideKeywords(value) { |
| | | return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | function isKeyframeAtRuleKeywords(path, value) { |
| | | var atRuleAncestorNode = getAncestorNode(path, "css-atrule"); |
| | | return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | function maybeToLowerCase(value) { |
| | | return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase(); |
| | | } |
| | | |
| | | function insideValueFunctionNode(path, functionName) { |
| | | var funcAncestorNode = getAncestorNode(path, "value-func"); |
| | | return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName; |
| | | } |
| | | |
| | | function insideICSSRuleNode(path) { |
| | | var ruleAncestorNode = getAncestorNode(path, "css-rule"); |
| | | return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export")); |
| | | } |
| | | |
| | | function insideAtRuleNode(path, atRuleNameOrAtRuleNames) { |
| | | var atRuleNames = [].concat(atRuleNameOrAtRuleNames); |
| | | var atRuleAncestorNode = getAncestorNode(path, "css-atrule"); |
| | | return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | function insideURLFunctionInImportAtRuleNode(path) { |
| | | var node = path.getValue(); |
| | | var atRuleAncestorNode = getAncestorNode(path, "css-atrule"); |
| | | return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2; |
| | | } |
| | | |
| | | function isURLFunctionNode(node) { |
| | | return node.type === "value-func" && node.value.toLowerCase() === "url"; |
| | | } |
| | | |
| | | function isLastNode(path, node) { |
| | | var parentNode = path.getParentNode(); |
| | | |
| | | if (!parentNode) { |
| | | return false; |
| | | } |
| | | |
| | | var nodes = parentNode.nodes; |
| | | return nodes && nodes.indexOf(node) === nodes.length - 1; |
| | | } |
| | | |
| | | function isHTMLTag(value) { |
| | | return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | function isDetachedRulesetDeclarationNode(node) { |
| | | // If a Less file ends up being parsed with the SCSS parser, Less |
| | | // variable declarations will be parsed as atrules with names ending |
| | | // with a colon, so keep the original case then. |
| | | if (!node.selector) { |
| | | return false; |
| | | } |
| | | |
| | | return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value); |
| | | } |
| | | |
| | | function isForKeywordNode(node) { |
| | | return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1; |
| | | } |
| | | |
| | | function isIfElseKeywordNode(node) { |
| | | return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1; |
| | | } |
| | | |
| | | function isEachKeywordNode(node) { |
| | | return node.type === "value-word" && node.value === "in"; |
| | | } |
| | | |
| | | function isMultiplicationNode(node) { |
| | | return node.type === "value-operator" && node.value === "*"; |
| | | } |
| | | |
| | | function isDivisionNode(node) { |
| | | return node.type === "value-operator" && node.value === "/"; |
| | | } |
| | | |
| | | function isAdditionNode(node) { |
| | | return node.type === "value-operator" && node.value === "+"; |
| | | } |
| | | |
| | | function isSubtractionNode(node) { |
| | | return node.type === "value-operator" && node.value === "-"; |
| | | } |
| | | |
| | | function isModuloNode(node) { |
| | | return node.type === "value-operator" && node.value === "%"; |
| | | } |
| | | |
| | | function isMathOperatorNode(node) { |
| | | return isMultiplicationNode(node) || isDivisionNode(node) || isAdditionNode(node) || isSubtractionNode(node) || isModuloNode(node); |
| | | } |
| | | |
| | | function isEqualityOperatorNode(node) { |
| | | return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1; |
| | | } |
| | | |
| | | function isRelationalOperatorNode(node) { |
| | | return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1; |
| | | } |
| | | |
| | | function isSCSSControlDirectiveNode(node) { |
| | | return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1; |
| | | } |
| | | |
| | | function isSCSSNestedPropertyNode(node) { |
| | | if (!node.selector) { |
| | | return false; |
| | | } |
| | | |
| | | return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":"); |
| | | } |
| | | |
| | | function isDetachedRulesetCallNode(node) { |
| | | return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params); |
| | | } |
| | | |
| | | function isTemplatePlaceholderNode(node) { |
| | | return node.name.startsWith("prettier-placeholder"); |
| | | } |
| | | |
| | | function isTemplatePropNode(node) { |
| | | return node.prop.startsWith("@prettier-placeholder"); |
| | | } |
| | | |
| | | function isPostcssSimpleVarNode(currentNode, nextNode) { |
| | | return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before; |
| | | } |
| | | |
| | | function hasComposesNode(node) { |
| | | return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes"; |
| | | } |
| | | |
| | | function hasParensAroundNode(node) { |
| | | return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null; |
| | | } |
| | | |
| | | function hasEmptyRawBefore(node) { |
| | | return node.raws && node.raws.before === ""; |
| | | } |
| | | |
| | | function isKeyValuePairNode(node) { |
| | | return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon"; |
| | | } |
| | | |
| | | function isKeyValuePairInParenGroupNode(node) { |
| | | return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode(node.groups[0]); |
| | | } |
| | | |
| | | function isSCSSMapItemNode(path) { |
| | | var node = path.getValue(); // Ignore empty item (i.e. `$key: ()`) |
| | | |
| | | if (node.groups.length === 0) { |
| | | return false; |
| | | } |
| | | |
| | | var parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`) |
| | | |
| | | if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) { |
| | | return false; |
| | | } |
| | | |
| | | var declNode = getAncestorNode(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`) |
| | | |
| | | if (declNode && declNode.prop && declNode.prop.startsWith("$")) { |
| | | return true; |
| | | } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`) |
| | | |
| | | |
| | | if (isKeyValuePairInParenGroupNode(parentParentNode)) { |
| | | return true; |
| | | } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`) |
| | | |
| | | |
| | | if (parentParentNode.type === "value-func") { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isInlineValueCommentNode(node) { |
| | | return node.type === "value-comment" && node.inline; |
| | | } |
| | | |
| | | function isHashNode(node) { |
| | | return node.type === "value-word" && node.value === "#"; |
| | | } |
| | | |
| | | function isLeftCurlyBraceNode(node) { |
| | | return node.type === "value-word" && node.value === "{"; |
| | | } |
| | | |
| | | function isRightCurlyBraceNode(node) { |
| | | return node.type === "value-word" && node.value === "}"; |
| | | } |
| | | |
| | | function isWordNode(node) { |
| | | return ["value-word", "value-atword"].indexOf(node.type) !== -1; |
| | | } |
| | | |
| | | function isColonNode(node) { |
| | | return node.type === "value-colon"; |
| | | } |
| | | |
| | | function isMediaAndSupportsKeywords(node) { |
| | | return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | function isColorAdjusterFuncNode(node) { |
| | | if (node.type !== "value-func") { |
| | | return false; |
| | | } |
| | | |
| | | return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1; |
| | | } |
| | | |
| | | var utils$2 = { |
| | | getAncestorCounter: getAncestorCounter, |
| | | getAncestorNode: getAncestorNode, |
| | | getPropOfDeclNode: getPropOfDeclNode, |
| | | maybeToLowerCase: maybeToLowerCase, |
| | | insideValueFunctionNode: insideValueFunctionNode, |
| | | insideICSSRuleNode: insideICSSRuleNode, |
| | | insideAtRuleNode: insideAtRuleNode, |
| | | insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode, |
| | | isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords, |
| | | isHTMLTag: isHTMLTag, |
| | | isWideKeywords: isWideKeywords, |
| | | isSCSS: isSCSS, |
| | | isLastNode: isLastNode, |
| | | isSCSSControlDirectiveNode: isSCSSControlDirectiveNode, |
| | | isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode, |
| | | isRelationalOperatorNode: isRelationalOperatorNode, |
| | | isEqualityOperatorNode: isEqualityOperatorNode, |
| | | isMultiplicationNode: isMultiplicationNode, |
| | | isDivisionNode: isDivisionNode, |
| | | isAdditionNode: isAdditionNode, |
| | | isSubtractionNode: isSubtractionNode, |
| | | isModuloNode: isModuloNode, |
| | | isMathOperatorNode: isMathOperatorNode, |
| | | isEachKeywordNode: isEachKeywordNode, |
| | | isForKeywordNode: isForKeywordNode, |
| | | isURLFunctionNode: isURLFunctionNode, |
| | | isIfElseKeywordNode: isIfElseKeywordNode, |
| | | hasComposesNode: hasComposesNode, |
| | | hasParensAroundNode: hasParensAroundNode, |
| | | hasEmptyRawBefore: hasEmptyRawBefore, |
| | | isSCSSNestedPropertyNode: isSCSSNestedPropertyNode, |
| | | isDetachedRulesetCallNode: isDetachedRulesetCallNode, |
| | | isTemplatePlaceholderNode: isTemplatePlaceholderNode, |
| | | isTemplatePropNode: isTemplatePropNode, |
| | | isPostcssSimpleVarNode: isPostcssSimpleVarNode, |
| | | isKeyValuePairNode: isKeyValuePairNode, |
| | | isKeyValuePairInParenGroupNode: isKeyValuePairInParenGroupNode, |
| | | isSCSSMapItemNode: isSCSSMapItemNode, |
| | | isInlineValueCommentNode: isInlineValueCommentNode, |
| | | isHashNode: isHashNode, |
| | | isLeftCurlyBraceNode: isLeftCurlyBraceNode, |
| | | isRightCurlyBraceNode: isRightCurlyBraceNode, |
| | | isWordNode: isWordNode, |
| | | isColonNode: isColonNode, |
| | | isMediaAndSupportsKeywords: isMediaAndSupportsKeywords, |
| | | isColorAdjusterFuncNode: isColorAdjusterFuncNode |
| | | }; |
| | | |
| | | var insertPragma$2 = pragma$1.insertPragma; |
| | | var printNumber$1 = util.printNumber, |
| | | printString$1 = util.printString, |
| | | hasIgnoreComment$1 = util.hasIgnoreComment, |
| | | hasNewline$2 = util.hasNewline; |
| | | var isNextLineEmpty$2 = utilShared.isNextLineEmpty; |
| | | var _require$$3$builders = doc.builders, |
| | | concat$5 = _require$$3$builders.concat, |
| | | join$2 = _require$$3$builders.join, |
| | | line$1 = _require$$3$builders.line, |
| | | hardline$4 = _require$$3$builders.hardline, |
| | | softline$1 = _require$$3$builders.softline, |
| | | group$1 = _require$$3$builders.group, |
| | | fill$2 = _require$$3$builders.fill, |
| | | indent$2 = _require$$3$builders.indent, |
| | | dedent$1 = _require$$3$builders.dedent, |
| | | ifBreak$1 = _require$$3$builders.ifBreak, |
| | | removeLines$1 = doc.utils.removeLines; |
| | | var getAncestorNode$1 = utils$2.getAncestorNode, |
| | | getPropOfDeclNode$1 = utils$2.getPropOfDeclNode, |
| | | maybeToLowerCase$1 = utils$2.maybeToLowerCase, |
| | | insideValueFunctionNode$1 = utils$2.insideValueFunctionNode, |
| | | insideICSSRuleNode$1 = utils$2.insideICSSRuleNode, |
| | | insideAtRuleNode$1 = utils$2.insideAtRuleNode, |
| | | insideURLFunctionInImportAtRuleNode$1 = utils$2.insideURLFunctionInImportAtRuleNode, |
| | | isKeyframeAtRuleKeywords$1 = utils$2.isKeyframeAtRuleKeywords, |
| | | isHTMLTag$1 = utils$2.isHTMLTag, |
| | | isWideKeywords$1 = utils$2.isWideKeywords, |
| | | isSCSS$1 = utils$2.isSCSS, |
| | | isLastNode$1 = utils$2.isLastNode, |
| | | isSCSSControlDirectiveNode$1 = utils$2.isSCSSControlDirectiveNode, |
| | | isDetachedRulesetDeclarationNode$1 = utils$2.isDetachedRulesetDeclarationNode, |
| | | isRelationalOperatorNode$1 = utils$2.isRelationalOperatorNode, |
| | | isEqualityOperatorNode$1 = utils$2.isEqualityOperatorNode, |
| | | isMultiplicationNode$1 = utils$2.isMultiplicationNode, |
| | | isDivisionNode$1 = utils$2.isDivisionNode, |
| | | isAdditionNode$1 = utils$2.isAdditionNode, |
| | | isSubtractionNode$1 = utils$2.isSubtractionNode, |
| | | isMathOperatorNode$1 = utils$2.isMathOperatorNode, |
| | | isEachKeywordNode$1 = utils$2.isEachKeywordNode, |
| | | isForKeywordNode$1 = utils$2.isForKeywordNode, |
| | | isURLFunctionNode$1 = utils$2.isURLFunctionNode, |
| | | isIfElseKeywordNode$1 = utils$2.isIfElseKeywordNode, |
| | | hasComposesNode$1 = utils$2.hasComposesNode, |
| | | hasParensAroundNode$1 = utils$2.hasParensAroundNode, |
| | | hasEmptyRawBefore$1 = utils$2.hasEmptyRawBefore, |
| | | isKeyValuePairNode$1 = utils$2.isKeyValuePairNode, |
| | | isDetachedRulesetCallNode$1 = utils$2.isDetachedRulesetCallNode, |
| | | isTemplatePlaceholderNode$1 = utils$2.isTemplatePlaceholderNode, |
| | | isTemplatePropNode$1 = utils$2.isTemplatePropNode, |
| | | isPostcssSimpleVarNode$1 = utils$2.isPostcssSimpleVarNode, |
| | | isSCSSMapItemNode$1 = utils$2.isSCSSMapItemNode, |
| | | isInlineValueCommentNode$1 = utils$2.isInlineValueCommentNode, |
| | | isHashNode$1 = utils$2.isHashNode, |
| | | isLeftCurlyBraceNode$1 = utils$2.isLeftCurlyBraceNode, |
| | | isRightCurlyBraceNode$1 = utils$2.isRightCurlyBraceNode, |
| | | isWordNode$1 = utils$2.isWordNode, |
| | | isColonNode$1 = utils$2.isColonNode, |
| | | isMediaAndSupportsKeywords$1 = utils$2.isMediaAndSupportsKeywords, |
| | | isColorAdjusterFuncNode$1 = utils$2.isColorAdjusterFuncNode; |
| | | |
| | | function shouldPrintComma(options) { |
| | | switch (options.trailingComma) { |
| | | case "all": |
| | | case "es5": |
| | | return true; |
| | | |
| | | case "none": |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function genericPrint(path, options, print) { |
| | | var node = path.getValue(); |
| | | /* istanbul ignore if */ |
| | | |
| | | if (!node) { |
| | | return ""; |
| | | } |
| | | |
| | | if (typeof node === "string") { |
| | | return node; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "yaml": |
| | | case "toml": |
| | | return concat$5([node.raw, hardline$4]); |
| | | |
| | | case "css-root": |
| | | { |
| | | var nodes = printNodeSequence(path, options, print); |
| | | |
| | | if (nodes.parts.length) { |
| | | return concat$5([nodes, hardline$4]); |
| | | } |
| | | |
| | | return nodes; |
| | | } |
| | | |
| | | case "css-comment": |
| | | { |
| | | if (node.raws.content) { |
| | | return node.raws.content; |
| | | } |
| | | |
| | | var text = options.originalText.slice(options.locStart(node), options.locEnd(node)); |
| | | var rawText = node.raws.text || node.text; // Workaround a bug where the location is off. |
| | | // https://github.com/postcss/postcss-scss/issues/63 |
| | | |
| | | if (text.indexOf(rawText) === -1) { |
| | | if (node.raws.inline) { |
| | | return concat$5(["// ", rawText]); |
| | | } |
| | | |
| | | return concat$5(["/* ", rawText, " */"]); |
| | | } |
| | | |
| | | return text; |
| | | } |
| | | |
| | | case "css-rule": |
| | | { |
| | | return concat$5([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$5([" {", node.nodes.length > 0 ? indent$2(concat$5([hardline$4, printNodeSequence(path, options, print)])) : "", hardline$4, "}", isDetachedRulesetDeclarationNode$1(node) ? ";" : ""]) : ";"]); |
| | | } |
| | | |
| | | case "css-decl": |
| | | { |
| | | var parentNode = path.getParentNode(); |
| | | return concat$5([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode$1(path) ? node.prop : maybeToLowerCase$1(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode$1(node) ? removeLines$1(path.call(print, "value")) : path.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$5([" {", indent$2(concat$5([softline$1, printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePropNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]); |
| | | } |
| | | |
| | | case "css-atrule": |
| | | { |
| | | var _parentNode = path.getParentNode(); |
| | | |
| | | return concat$5(["@", // If a Less file ends up being parsed with the SCSS parser, Less |
| | | // variable declarations will be parsed as at-rules with names ending |
| | | // with a colon, so keep the original case then. |
| | | isDetachedRulesetCallNode$1(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase$1(node.name), node.params ? concat$5([isDetachedRulesetCallNode$1(node) ? "" : isTemplatePlaceholderNode$1(node) && /^\s*\n/.test(node.raws.afterName) ? /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$5([hardline$4, hardline$4]) : hardline$4 : " ", path.call(print, "params")]) : "", node.selector ? indent$2(concat$5([" ", path.call(print, "selector")])) : "", node.value ? group$1(concat$5([" ", path.call(print, "value"), isSCSSControlDirectiveNode$1(node) ? hasParensAroundNode$1(node) ? " " : line$1 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$5([isSCSSControlDirectiveNode$1(node) ? "" : " ", "{", indent$2(concat$5([node.nodes.length > 0 ? softline$1 : "", printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePlaceholderNode$1(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]); |
| | | } |
| | | // postcss-media-query-parser |
| | | |
| | | case "media-query-list": |
| | | { |
| | | var parts = []; |
| | | path.each(function (childPath) { |
| | | var node = childPath.getValue(); |
| | | |
| | | if (node.type === "media-query" && node.value === "") { |
| | | return; |
| | | } |
| | | |
| | | parts.push(childPath.call(print)); |
| | | }, "nodes"); |
| | | return group$1(indent$2(join$2(line$1, parts))); |
| | | } |
| | | |
| | | case "media-query": |
| | | { |
| | | return concat$5([join$2(" ", path.map(print, "nodes")), isLastNode$1(path, node) ? "" : ","]); |
| | | } |
| | | |
| | | case "media-type": |
| | | { |
| | | return adjustNumbers(adjustStrings(node.value, options)); |
| | | } |
| | | |
| | | case "media-feature-expression": |
| | | { |
| | | if (!node.nodes) { |
| | | return node.value; |
| | | } |
| | | |
| | | return concat$5(["(", concat$5(path.map(print, "nodes")), ")"]); |
| | | } |
| | | |
| | | case "media-feature": |
| | | { |
| | | return maybeToLowerCase$1(adjustStrings(node.value.replace(/ +/g, " "), options)); |
| | | } |
| | | |
| | | case "media-colon": |
| | | { |
| | | return concat$5([node.value, " "]); |
| | | } |
| | | |
| | | case "media-value": |
| | | { |
| | | return adjustNumbers(adjustStrings(node.value, options)); |
| | | } |
| | | |
| | | case "media-keyword": |
| | | { |
| | | return adjustStrings(node.value, options); |
| | | } |
| | | |
| | | case "media-url": |
| | | { |
| | | return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options); |
| | | } |
| | | |
| | | case "media-unknown": |
| | | { |
| | | return node.value; |
| | | } |
| | | // postcss-selector-parser |
| | | |
| | | case "selector-root": |
| | | { |
| | | return group$1(concat$5([insideAtRuleNode$1(path, "custom-selector") ? concat$5([getAncestorNode$1(path, "css-atrule").customSelector, line$1]) : "", join$2(concat$5([",", insideAtRuleNode$1(path, ["extend", "custom-selector", "nest"]) ? line$1 : hardline$4]), path.map(print, "nodes"))])); |
| | | } |
| | | |
| | | case "selector-selector": |
| | | { |
| | | return group$1(indent$2(concat$5(path.map(print, "nodes")))); |
| | | } |
| | | |
| | | case "selector-comment": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | case "selector-string": |
| | | { |
| | | return adjustStrings(node.value, options); |
| | | } |
| | | |
| | | case "selector-tag": |
| | | { |
| | | var _parentNode2 = path.getParentNode(); |
| | | |
| | | var index = _parentNode2 && _parentNode2.nodes.indexOf(node); |
| | | |
| | | var prevNode = index && _parentNode2.nodes[index - 1]; |
| | | return concat$5([node.namespace ? concat$5([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isHTMLTag$1(node.value) || isKeyframeAtRuleKeywords$1(path, node.value) ? node.value.toLowerCase() : node.value)]); |
| | | } |
| | | |
| | | case "selector-id": |
| | | { |
| | | return concat$5(["#", node.value]); |
| | | } |
| | | |
| | | case "selector-class": |
| | | { |
| | | return concat$5([".", adjustNumbers(adjustStrings(node.value, options))]); |
| | | } |
| | | |
| | | case "selector-attribute": |
| | | { |
| | | return concat$5(["[", node.namespace ? concat$5([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"]); |
| | | } |
| | | |
| | | case "selector-combinator": |
| | | { |
| | | if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") { |
| | | var _parentNode3 = path.getParentNode(); |
| | | |
| | | var _leading = _parentNode3.type === "selector-selector" && _parentNode3.nodes[0] === node ? "" : line$1; |
| | | |
| | | return concat$5([_leading, node.value, isLastNode$1(path, node) ? "" : " "]); |
| | | } |
| | | |
| | | var leading = node.value.trim().startsWith("(") ? line$1 : ""; |
| | | var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$1; |
| | | return concat$5([leading, value]); |
| | | } |
| | | |
| | | case "selector-universal": |
| | | { |
| | | return concat$5([node.namespace ? concat$5([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]); |
| | | } |
| | | |
| | | case "selector-pseudo": |
| | | { |
| | | return concat$5([maybeToLowerCase$1(node.value), node.nodes && node.nodes.length > 0 ? concat$5(["(", join$2(", ", path.map(print, "nodes")), ")"]) : ""]); |
| | | } |
| | | |
| | | case "selector-nesting": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | case "selector-unknown": |
| | | { |
| | | var ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property |
| | | |
| | | if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) { |
| | | return adjustNumbers(adjustStrings(maybeToLowerCase$1(node.value), options)); |
| | | } |
| | | |
| | | return node.value; |
| | | } |
| | | // postcss-values-parser |
| | | |
| | | case "value-value": |
| | | case "value-root": |
| | | { |
| | | return path.call(print, "group"); |
| | | } |
| | | |
| | | case "value-comment": |
| | | { |
| | | return concat$5([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]); |
| | | } |
| | | |
| | | case "value-comma_group": |
| | | { |
| | | var _parentNode4 = path.getParentNode(); |
| | | |
| | | var parentParentNode = path.getParentNode(1); |
| | | var declAncestorProp = getPropOfDeclNode$1(path); |
| | | var isGridValue = declAncestorProp && _parentNode4.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template")); |
| | | var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule"); |
| | | var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode$1(atRuleAncestorNode); |
| | | var printed = path.map(print, "groups"); |
| | | var _parts = []; |
| | | var insideURLFunction = insideValueFunctionNode$1(path, "url"); |
| | | var insideSCSSInterpolationInString = false; |
| | | var didBreak = false; |
| | | |
| | | for (var i = 0; i < node.groups.length; ++i) { |
| | | _parts.push(printed[i]); // Ignore value inside `url()` |
| | | |
| | | |
| | | if (insideURLFunction) { |
| | | continue; |
| | | } |
| | | |
| | | var iPrevNode = node.groups[i - 1]; |
| | | var iNode = node.groups[i]; |
| | | var iNextNode = node.groups[i + 1]; |
| | | var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon) |
| | | |
| | | if (!iNextNode) { |
| | | continue; |
| | | } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`) |
| | | |
| | | |
| | | var isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{"); |
| | | var isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}"); |
| | | |
| | | if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) { |
| | | insideSCSSInterpolationInString = !insideSCSSInterpolationInString; |
| | | continue; |
| | | } |
| | | |
| | | if (insideSCSSInterpolationInString) { |
| | | continue; |
| | | } // Ignore colon (i.e. `:`) |
| | | |
| | | |
| | | if (isColonNode$1(iNode) || isColonNode$1(iNextNode)) { |
| | | continue; |
| | | } // Ignore `@` in Less (i.e. `@@var;`) |
| | | |
| | | |
| | | if (iNode.type === "value-atword" && iNode.value === "") { |
| | | continue; |
| | | } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`) |
| | | |
| | | |
| | | if (iNode.value === "~") { |
| | | continue; |
| | | } // Ignore escape `\` |
| | | |
| | | |
| | | if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") { |
| | | continue; |
| | | } // Ignore escaped `/` |
| | | |
| | | |
| | | if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") { |
| | | continue; |
| | | } // Ignore `\` (i.e. `$variable: \@small;`) |
| | | |
| | | |
| | | if (iNode.value === "\\") { |
| | | continue; |
| | | } // Ignore `$$` (i.e. `background-color: $$(style)Color;`) |
| | | |
| | | |
| | | if (isPostcssSimpleVarNode$1(iNode, iNextNode)) { |
| | | continue; |
| | | } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`) |
| | | |
| | | |
| | | if (isHashNode$1(iNode) || isLeftCurlyBraceNode$1(iNode) || isRightCurlyBraceNode$1(iNextNode) || isLeftCurlyBraceNode$1(iNextNode) && hasEmptyRawBefore$1(iNextNode) || isRightCurlyBraceNode$1(iNode) && hasEmptyRawBefore$1(iNextNode)) { |
| | | continue; |
| | | } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`) |
| | | |
| | | |
| | | if (iNode.value === "--" && isHashNode$1(iNextNode)) { |
| | | continue; |
| | | } // Formatting math operations |
| | | |
| | | |
| | | var isMathOperator = isMathOperatorNode$1(iNode); |
| | | var isNextMathOperator = isMathOperatorNode$1(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is |
| | | // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`) |
| | | // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`) |
| | | |
| | | if ((isMathOperator && isHashNode$1(iNextNode) || isNextMathOperator && isRightCurlyBraceNode$1(iNode)) && hasEmptyRawBefore$1(iNextNode)) { |
| | | continue; |
| | | } // Print spaces before and after addition and subtraction math operators as is in `calc` function |
| | | // due to the fact that it is not valid syntax |
| | | // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`) |
| | | |
| | | |
| | | if (insideValueFunctionNode$1(path, "calc") && (isAdditionNode$1(iNode) || isAdditionNode$1(iNextNode) || isSubtractionNode$1(iNode) || isSubtractionNode$1(iNextNode)) && hasEmptyRawBefore$1(iNextNode)) { |
| | | continue; |
| | | } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`) |
| | | // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is. |
| | | |
| | | |
| | | var isColorAdjusterNode = (isAdditionNode$1(iNode) || isSubtractionNode$1(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode$1(parentParentNode) && !hasEmptyRawBefore$1(iNextNode); |
| | | var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode$1(iNextNextNode) || iNode.type === "value-func" || isWordNode$1(iNode); |
| | | var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode$1(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode$1(iPrevNode); // Formatting `/`, `+`, `-` sign |
| | | |
| | | if (!(isMultiplicationNode$1(iNextNode) || isMultiplicationNode$1(iNode)) && !insideValueFunctionNode$1(path, "calc") && !isColorAdjusterNode && (isDivisionNode$1(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode$1(iNode) && !requireSpaceAfterOperator || isAdditionNode$1(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode$1(iNode) && !requireSpaceAfterOperator || isSubtractionNode$1(iNextNode) || isSubtractionNode$1(iNode)) && (hasEmptyRawBefore$1(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode$1(iPrevNode)))) { |
| | | continue; |
| | | } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`) |
| | | |
| | | |
| | | if (isInlineValueCommentNode$1(iNode)) { |
| | | _parts.push(hardline$4); |
| | | |
| | | continue; |
| | | } // Handle keywords in SCSS control directive |
| | | |
| | | |
| | | if (isControlDirective && (isEqualityOperatorNode$1(iNextNode) || isRelationalOperatorNode$1(iNextNode) || isIfElseKeywordNode$1(iNextNode) || isEachKeywordNode$1(iNode) || isForKeywordNode$1(iNode))) { |
| | | _parts.push(" "); |
| | | |
| | | continue; |
| | | } // At-rule `namespace` should be in one line |
| | | |
| | | |
| | | if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") { |
| | | _parts.push(" "); |
| | | |
| | | continue; |
| | | } // Formatting `grid` property |
| | | |
| | | |
| | | if (isGridValue) { |
| | | if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) { |
| | | _parts.push(hardline$4); |
| | | |
| | | didBreak = true; |
| | | } else { |
| | | _parts.push(" "); |
| | | } |
| | | |
| | | continue; |
| | | } // Add `space` before next math operation |
| | | // Note: `grip` property have `/` delimiter and it is not math operation, so |
| | | // `grid` property handles above |
| | | |
| | | |
| | | if (isNextMathOperator) { |
| | | _parts.push(" "); |
| | | |
| | | continue; |
| | | } // Be default all values go through `line` |
| | | |
| | | |
| | | _parts.push(line$1); |
| | | } |
| | | |
| | | if (didBreak) { |
| | | _parts.unshift(hardline$4); |
| | | } |
| | | |
| | | if (isControlDirective) { |
| | | return group$1(indent$2(concat$5(_parts))); |
| | | } // Indent is not needed for import url when url is very long |
| | | // and node has two groups |
| | | // when type is value-comma_group |
| | | // example @import url("verylongurl") projection,tv |
| | | |
| | | |
| | | if (insideURLFunctionInImportAtRuleNode$1(path)) { |
| | | return group$1(fill$2(_parts)); |
| | | } |
| | | |
| | | return group$1(indent$2(fill$2(_parts))); |
| | | } |
| | | |
| | | case "value-paren_group": |
| | | { |
| | | var _parentNode5 = path.getParentNode(); |
| | | |
| | | if (_parentNode5 && isURLFunctionNode$1(_parentNode5) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) { |
| | | return concat$5([node.open ? path.call(print, "open") : "", join$2(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]); |
| | | } |
| | | |
| | | if (!node.open) { |
| | | var _printed = path.map(print, "groups"); |
| | | |
| | | var res = []; |
| | | |
| | | for (var _i = 0; _i < _printed.length; _i++) { |
| | | if (_i !== 0) { |
| | | res.push(concat$5([",", line$1])); |
| | | } |
| | | |
| | | res.push(_printed[_i]); |
| | | } |
| | | |
| | | return group$1(indent$2(fill$2(res))); |
| | | } |
| | | |
| | | var isSCSSMapItem = isSCSSMapItemNode$1(path); |
| | | return group$1(concat$5([node.open ? path.call(print, "open") : "", indent$2(concat$5([softline$1, join$2(concat$5([",", line$1]), path.map(function (childPath) { |
| | | var node = childPath.getValue(); |
| | | var printed = print(childPath); // Key/Value pair in open paren already indented |
| | | |
| | | if (isKeyValuePairNode$1(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") { |
| | | printed.contents.contents.parts[1] = group$1(printed.contents.contents.parts[1]); |
| | | return group$1(dedent$1(printed)); |
| | | } |
| | | |
| | | return printed; |
| | | }, "groups"))])), ifBreak$1(isSCSS$1(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$1, node.close ? path.call(print, "close") : ""]), { |
| | | shouldBreak: isSCSSMapItem |
| | | }); |
| | | } |
| | | |
| | | case "value-func": |
| | | { |
| | | return concat$5([node.value, insideAtRuleNode$1(path, "supports") && isMediaAndSupportsKeywords$1(node) ? " " : "", path.call(print, "group")]); |
| | | } |
| | | |
| | | case "value-paren": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | case "value-number": |
| | | { |
| | | return concat$5([printCssNumber(node.value), maybeToLowerCase$1(node.unit)]); |
| | | } |
| | | |
| | | case "value-operator": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | case "value-word": |
| | | { |
| | | if (node.isColor && node.isHex || isWideKeywords$1(node.value)) { |
| | | return node.value.toLowerCase(); |
| | | } |
| | | |
| | | return node.value; |
| | | } |
| | | |
| | | case "value-colon": |
| | | { |
| | | return concat$5([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`) |
| | | insideValueFunctionNode$1(path, "url") ? "" : line$1]); |
| | | } |
| | | |
| | | case "value-comma": |
| | | { |
| | | return concat$5([node.value, " "]); |
| | | } |
| | | |
| | | case "value-string": |
| | | { |
| | | return printString$1(node.raws.quote + node.value + node.raws.quote, options); |
| | | } |
| | | |
| | | case "value-atword": |
| | | { |
| | | return concat$5(["@", node.value]); |
| | | } |
| | | |
| | | case "value-unicode-range": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | case "value-unknown": |
| | | { |
| | | return node.value; |
| | | } |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | throw new Error("Unknown postcss type ".concat(JSON.stringify(node.type))); |
| | | } |
| | | } |
| | | |
| | | function printNodeSequence(path, options, print) { |
| | | var node = path.getValue(); |
| | | var parts = []; |
| | | var i = 0; |
| | | path.map(function (pathChild) { |
| | | var prevNode = node.nodes[i - 1]; |
| | | |
| | | if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") { |
| | | var childNode = pathChild.getValue(); |
| | | parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode))); |
| | | } else { |
| | | parts.push(pathChild.call(print)); |
| | | } |
| | | |
| | | if (i !== node.nodes.length - 1) { |
| | | if (node.nodes[i + 1].type === "css-comment" && !hasNewline$2(options.originalText, options.locStart(node.nodes[i + 1]), { |
| | | backwards: true |
| | | }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") { |
| | | parts.push(" "); |
| | | } else { |
| | | parts.push(hardline$4); |
| | | |
| | | if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), options) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") { |
| | | parts.push(hardline$4); |
| | | } |
| | | } |
| | | } |
| | | |
| | | i++; |
| | | }, "nodes"); |
| | | return concat$5(parts); |
| | | } |
| | | |
| | | var STRING_REGEX$1 = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g; |
| | | var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g; |
| | | var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g; |
| | | var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g; |
| | | var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX$1.source + "|" + "(".concat(WORD_PART_REGEX.source, ")?") + "(".concat(NUMBER_REGEX.source, ")") + "(".concat(STANDARD_UNIT_REGEX.source, ")?"), "g"); |
| | | |
| | | function adjustStrings(value, options) { |
| | | return value.replace(STRING_REGEX$1, function (match) { |
| | | return printString$1(match, options); |
| | | }); |
| | | } |
| | | |
| | | function quoteAttributeValue(value, options) { |
| | | var quote = options.singleQuote ? "'" : '"'; |
| | | return value.includes('"') || value.includes("'") ? value : quote + value + quote; |
| | | } |
| | | |
| | | function adjustNumbers(value) { |
| | | return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) { |
| | | return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase$1(unit || "") : match; |
| | | }); |
| | | } |
| | | |
| | | function printCssNumber(rawNumber) { |
| | | return printNumber$1(rawNumber) // Remove trailing `.0`. |
| | | .replace(/\.0(?=$|e)/, ""); |
| | | } |
| | | |
| | | var printerPostcss = { |
| | | print: genericPrint, |
| | | embed: embed_1, |
| | | insertPragma: insertPragma$2, |
| | | hasPrettierIgnore: hasIgnoreComment$1, |
| | | massageAstNode: clean_1 |
| | | }; |
| | | |
| | | var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js |
| | | |
| | | var commonOptions = { |
| | | bracketSpacing: { |
| | | since: "0.0.0", |
| | | category: CATEGORY_COMMON, |
| | | type: "boolean", |
| | | default: true, |
| | | description: "Print spaces between brackets.", |
| | | oppositeDescription: "Do not print spaces between brackets." |
| | | }, |
| | | singleQuote: { |
| | | since: "0.0.0", |
| | | category: CATEGORY_COMMON, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Use single quotes instead of double quotes." |
| | | }, |
| | | proseWrap: { |
| | | since: "1.8.2", |
| | | category: CATEGORY_COMMON, |
| | | type: "choice", |
| | | default: [{ |
| | | since: "1.8.2", |
| | | value: true |
| | | }, { |
| | | since: "1.9.0", |
| | | value: "preserve" |
| | | }], |
| | | description: "How to wrap prose.", |
| | | choices: [{ |
| | | since: "1.9.0", |
| | | value: "always", |
| | | description: "Wrap prose if it exceeds the print width." |
| | | }, { |
| | | since: "1.9.0", |
| | | value: "never", |
| | | description: "Do not wrap prose." |
| | | }, { |
| | | since: "1.9.0", |
| | | value: "preserve", |
| | | description: "Wrap prose as-is." |
| | | }, { |
| | | value: false, |
| | | deprecated: "1.9.0", |
| | | redirect: "never" |
| | | }, { |
| | | value: true, |
| | | deprecated: "1.9.0", |
| | | redirect: "always" |
| | | }] |
| | | } |
| | | }; |
| | | |
| | | var options$2 = { |
| | | singleQuote: commonOptions.singleQuote |
| | | }; |
| | | |
| | | var createLanguage = function createLanguage(linguistData, transform) { |
| | | var language = {}; |
| | | |
| | | for (var key in linguistData) { |
| | | var newKey = key === "languageId" ? "linguistLanguageId" : key; |
| | | language[newKey] = linguistData[key]; |
| | | } |
| | | |
| | | return transform(language); |
| | | }; |
| | | |
| | | var name$1 = "CSS"; |
| | | var type = "markup"; |
| | | var tmScope = "source.css"; |
| | | var aceMode = "css"; |
| | | var codemirrorMode = "css"; |
| | | var codemirrorMimeType = "text/css"; |
| | | var color = "#563d7c"; |
| | | var extensions = [ |
| | | ".css" |
| | | ]; |
| | | var languageId = 50; |
| | | var CSS = { |
| | | name: name$1, |
| | | type: type, |
| | | tmScope: tmScope, |
| | | aceMode: aceMode, |
| | | codemirrorMode: codemirrorMode, |
| | | codemirrorMimeType: codemirrorMimeType, |
| | | color: color, |
| | | extensions: extensions, |
| | | languageId: languageId |
| | | }; |
| | | |
| | | var CSS$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$1, |
| | | type: type, |
| | | tmScope: tmScope, |
| | | aceMode: aceMode, |
| | | codemirrorMode: codemirrorMode, |
| | | codemirrorMimeType: codemirrorMimeType, |
| | | color: color, |
| | | extensions: extensions, |
| | | languageId: languageId, |
| | | 'default': CSS |
| | | }); |
| | | |
| | | var name$2 = "PostCSS"; |
| | | var type$1 = "markup"; |
| | | var tmScope$1 = "source.postcss"; |
| | | var group$2 = "CSS"; |
| | | var extensions$1 = [ |
| | | ".pcss" |
| | | ]; |
| | | var aceMode$1 = "text"; |
| | | var languageId$1 = 262764437; |
| | | var PostCSS = { |
| | | name: name$2, |
| | | type: type$1, |
| | | tmScope: tmScope$1, |
| | | group: group$2, |
| | | extensions: extensions$1, |
| | | aceMode: aceMode$1, |
| | | languageId: languageId$1 |
| | | }; |
| | | |
| | | var PostCSS$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$2, |
| | | type: type$1, |
| | | tmScope: tmScope$1, |
| | | group: group$2, |
| | | extensions: extensions$1, |
| | | aceMode: aceMode$1, |
| | | languageId: languageId$1, |
| | | 'default': PostCSS |
| | | }); |
| | | |
| | | var name$3 = "Less"; |
| | | var type$2 = "markup"; |
| | | var group$3 = "CSS"; |
| | | var extensions$2 = [ |
| | | ".less" |
| | | ]; |
| | | var tmScope$2 = "source.css.less"; |
| | | var aceMode$2 = "less"; |
| | | var codemirrorMode$1 = "css"; |
| | | var codemirrorMimeType$1 = "text/css"; |
| | | var languageId$2 = 198; |
| | | var Less = { |
| | | name: name$3, |
| | | type: type$2, |
| | | group: group$3, |
| | | extensions: extensions$2, |
| | | tmScope: tmScope$2, |
| | | aceMode: aceMode$2, |
| | | codemirrorMode: codemirrorMode$1, |
| | | codemirrorMimeType: codemirrorMimeType$1, |
| | | languageId: languageId$2 |
| | | }; |
| | | |
| | | var Less$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$3, |
| | | type: type$2, |
| | | group: group$3, |
| | | extensions: extensions$2, |
| | | tmScope: tmScope$2, |
| | | aceMode: aceMode$2, |
| | | codemirrorMode: codemirrorMode$1, |
| | | codemirrorMimeType: codemirrorMimeType$1, |
| | | languageId: languageId$2, |
| | | 'default': Less |
| | | }); |
| | | |
| | | var name$4 = "SCSS"; |
| | | var type$3 = "markup"; |
| | | var tmScope$3 = "source.css.scss"; |
| | | var group$4 = "CSS"; |
| | | var aceMode$3 = "scss"; |
| | | var codemirrorMode$2 = "css"; |
| | | var codemirrorMimeType$2 = "text/x-scss"; |
| | | var extensions$3 = [ |
| | | ".scss" |
| | | ]; |
| | | var languageId$3 = 329; |
| | | var SCSS = { |
| | | name: name$4, |
| | | type: type$3, |
| | | tmScope: tmScope$3, |
| | | group: group$4, |
| | | aceMode: aceMode$3, |
| | | codemirrorMode: codemirrorMode$2, |
| | | codemirrorMimeType: codemirrorMimeType$2, |
| | | extensions: extensions$3, |
| | | languageId: languageId$3 |
| | | }; |
| | | |
| | | var SCSS$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$4, |
| | | type: type$3, |
| | | tmScope: tmScope$3, |
| | | group: group$4, |
| | | aceMode: aceMode$3, |
| | | codemirrorMode: codemirrorMode$2, |
| | | codemirrorMimeType: codemirrorMimeType$2, |
| | | extensions: extensions$3, |
| | | languageId: languageId$3, |
| | | 'default': SCSS |
| | | }); |
| | | |
| | | var require$$0$2 = getCjsExportFromNamespace(CSS$1); |
| | | |
| | | var require$$1 = getCjsExportFromNamespace(PostCSS$1); |
| | | |
| | | var require$$2 = getCjsExportFromNamespace(Less$1); |
| | | |
| | | var require$$3 = getCjsExportFromNamespace(SCSS$1); |
| | | |
| | | var languages = [createLanguage(require$$0$2, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["css"], |
| | | vscodeLanguageIds: ["css"] |
| | | }); |
| | | }), createLanguage(require$$1, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["css"], |
| | | vscodeLanguageIds: ["postcss"], |
| | | extensions: data.extensions.concat(".postcss") |
| | | }); |
| | | }), createLanguage(require$$2, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["less"], |
| | | vscodeLanguageIds: ["less"] |
| | | }); |
| | | }), createLanguage(require$$3, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["scss"], |
| | | vscodeLanguageIds: ["scss"] |
| | | }); |
| | | })]; |
| | | var printers = { |
| | | postcss: printerPostcss |
| | | }; |
| | | var languageCss = { |
| | | languages: languages, |
| | | options: options$2, |
| | | printers: printers |
| | | }; |
| | | |
| | | function hasPragma$2(text) { |
| | | return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text); |
| | | } |
| | | |
| | | function insertPragma$3(text) { |
| | | return "# @format\n\n" + text; |
| | | } |
| | | |
| | | var pragma$2 = { |
| | | hasPragma: hasPragma$2, |
| | | insertPragma: insertPragma$3 |
| | | }; |
| | | |
| | | var _require$$0$builders$2 = doc.builders, |
| | | concat$6 = _require$$0$builders$2.concat, |
| | | join$3 = _require$$0$builders$2.join, |
| | | hardline$5 = _require$$0$builders$2.hardline, |
| | | line$2 = _require$$0$builders$2.line, |
| | | softline$2 = _require$$0$builders$2.softline, |
| | | group$5 = _require$$0$builders$2.group, |
| | | indent$3 = _require$$0$builders$2.indent, |
| | | ifBreak$2 = _require$$0$builders$2.ifBreak; |
| | | var hasIgnoreComment$2 = util.hasIgnoreComment; |
| | | var isNextLineEmpty$3 = utilShared.isNextLineEmpty; |
| | | var insertPragma$4 = pragma$2.insertPragma; |
| | | |
| | | function genericPrint$1(path, options, print) { |
| | | var n = path.getValue(); |
| | | |
| | | if (!n) { |
| | | return ""; |
| | | } |
| | | |
| | | if (typeof n === "string") { |
| | | return n; |
| | | } |
| | | |
| | | switch (n.kind) { |
| | | case "Document": |
| | | { |
| | | var parts = []; |
| | | path.map(function (pathChild, index) { |
| | | parts.push(concat$6([pathChild.call(print)])); |
| | | |
| | | if (index !== n.definitions.length - 1) { |
| | | parts.push(hardline$5); |
| | | |
| | | if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options)) { |
| | | parts.push(hardline$5); |
| | | } |
| | | } |
| | | }, "definitions"); |
| | | return concat$6([concat$6(parts), hardline$5]); |
| | | } |
| | | |
| | | case "OperationDefinition": |
| | | { |
| | | var hasOperation = options.originalText[options.locStart(n)] !== "{"; |
| | | var hasName = !!n.name; |
| | | return concat$6([hasOperation ? n.operation : "", hasOperation && hasName ? concat$6([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "variableDefinitions"))])), softline$2, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]); |
| | | } |
| | | |
| | | case "FragmentDefinition": |
| | | { |
| | | return concat$6(["fragment ", path.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "variableDefinitions"))])), softline$2, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]); |
| | | } |
| | | |
| | | case "SelectionSet": |
| | | { |
| | | return concat$6(["{", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (selectionsPath) { |
| | | return printSequence(selectionsPath, options, print); |
| | | }, "selections"))])), hardline$5, "}"]); |
| | | } |
| | | |
| | | case "Field": |
| | | { |
| | | return group$5(concat$6([n.alias ? concat$6([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) { |
| | | return printSequence(argsPath, options, print); |
| | | }, "arguments"))])), softline$2, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")])); |
| | | } |
| | | |
| | | case "Name": |
| | | { |
| | | return n.value; |
| | | } |
| | | |
| | | case "StringValue": |
| | | { |
| | | if (n.block) { |
| | | return concat$6(['"""', hardline$5, join$3(hardline$5, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$5, '"""']); |
| | | } |
| | | |
| | | return concat$6(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']); |
| | | } |
| | | |
| | | case "IntValue": |
| | | case "FloatValue": |
| | | case "EnumValue": |
| | | { |
| | | return n.value; |
| | | } |
| | | |
| | | case "BooleanValue": |
| | | { |
| | | return n.value ? "true" : "false"; |
| | | } |
| | | |
| | | case "NullValue": |
| | | { |
| | | return "null"; |
| | | } |
| | | |
| | | case "Variable": |
| | | { |
| | | return concat$6(["$", path.call(print, "name")]); |
| | | } |
| | | |
| | | case "ListValue": |
| | | { |
| | | return group$5(concat$6(["[", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "values"))])), softline$2, "]"])); |
| | | } |
| | | |
| | | case "ObjectValue": |
| | | { |
| | | return group$5(concat$6(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "fields"))])), softline$2, ifBreak$2("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"])); |
| | | } |
| | | |
| | | case "ObjectField": |
| | | case "Argument": |
| | | { |
| | | return concat$6([path.call(print, "name"), ": ", path.call(print, "value")]); |
| | | } |
| | | |
| | | case "Directive": |
| | | { |
| | | return concat$6(["@", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) { |
| | | return printSequence(argsPath, options, print); |
| | | }, "arguments"))])), softline$2, ")"])) : ""]); |
| | | } |
| | | |
| | | case "NamedType": |
| | | { |
| | | return path.call(print, "name"); |
| | | } |
| | | |
| | | case "VariableDefinition": |
| | | { |
| | | return concat$6([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "TypeExtensionDefinition": |
| | | { |
| | | return concat$6(["extend ", path.call(print, "definition")]); |
| | | } |
| | | |
| | | case "ObjectTypeExtension": |
| | | case "ObjectTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$6([" implements ", join$3(determineInterfaceSeparator(options.originalText.substr(options.locStart(n), options.locEnd(n))), path.map(print, "interfaces"))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) { |
| | | return printSequence(fieldsPath, options, print); |
| | | }, "fields"))])), hardline$5, "}"]) : ""]); |
| | | } |
| | | |
| | | case "FieldDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) { |
| | | return printSequence(argsPath, options, print); |
| | | }, "arguments"))])), softline$2, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "DirectiveDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) { |
| | | return printSequence(argsPath, options, print); |
| | | }, "arguments"))])), softline$2, ")"])) : "", concat$6([" on ", join$3(" | ", path.map(print, "locations"))])]); |
| | | } |
| | | |
| | | case "EnumTypeExtension": |
| | | case "EnumTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (valuesPath) { |
| | | return printSequence(valuesPath, options, print); |
| | | }, "values"))])), hardline$5, "}"]) : ""]); |
| | | } |
| | | |
| | | case "EnumValueDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", path.call(print, "name"), printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "InputValueDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? n.description.block ? hardline$5 : line$2 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "InputObjectTypeExtension": |
| | | case "InputObjectTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) { |
| | | return printSequence(fieldsPath, options, print); |
| | | }, "fields"))])), hardline$5, "}"]) : ""]); |
| | | } |
| | | |
| | | case "SchemaDefinition": |
| | | { |
| | | return concat$6(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (opsPath) { |
| | | return printSequence(opsPath, options, print); |
| | | }, "operationTypes"))])) : "", hardline$5, "}"]); |
| | | } |
| | | |
| | | case "OperationTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "operation"), ": ", path.call(print, "type")]); |
| | | } |
| | | |
| | | case "InterfaceTypeExtension": |
| | | case "InterfaceTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) { |
| | | return printSequence(fieldsPath, options, print); |
| | | }, "fields"))])), hardline$5, "}"]) : ""]); |
| | | } |
| | | |
| | | case "FragmentSpread": |
| | | { |
| | | return concat$6(["...", path.call(print, "name"), printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "InlineFragment": |
| | | { |
| | | return concat$6(["...", n.typeCondition ? concat$6([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]); |
| | | } |
| | | |
| | | case "UnionTypeExtension": |
| | | case "UnionTypeDefinition": |
| | | { |
| | | return group$5(concat$6([path.call(print, "description"), n.description ? hardline$5 : "", group$5(concat$6([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$6([" =", ifBreak$2("", " "), indent$3(concat$6([ifBreak$2(concat$6([line$2, " "])), join$3(concat$6([line$2, "| "]), path.map(print, "types"))]))]) : ""]))])); |
| | | } |
| | | |
| | | case "ScalarTypeExtension": |
| | | case "ScalarTypeDefinition": |
| | | { |
| | | return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]); |
| | | } |
| | | |
| | | case "NonNullType": |
| | | { |
| | | return concat$6([path.call(print, "type"), "!"]); |
| | | } |
| | | |
| | | case "ListType": |
| | | { |
| | | return concat$6(["[", path.call(print, "type"), "]"]); |
| | | } |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | throw new Error("unknown graphql type: " + JSON.stringify(n.kind)); |
| | | } |
| | | } |
| | | |
| | | function printDirectives(path, print, n) { |
| | | if (n.directives.length === 0) { |
| | | return ""; |
| | | } |
| | | |
| | | return concat$6([" ", group$5(indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", " "), softline$2]), path.map(print, "directives"))])))]); |
| | | } |
| | | |
| | | function printSequence(sequencePath, options, print) { |
| | | var count = sequencePath.getValue().length; |
| | | return sequencePath.map(function (path, i) { |
| | | var printed = print(path); |
| | | |
| | | if (isNextLineEmpty$3(options.originalText, path.getValue(), options) && i < count - 1) { |
| | | return concat$6([printed, hardline$5]); |
| | | } |
| | | |
| | | return printed; |
| | | }); |
| | | } |
| | | |
| | | function canAttachComment(node) { |
| | | return node.kind && node.kind !== "Comment"; |
| | | } |
| | | |
| | | function printComment$1(commentPath) { |
| | | var comment = commentPath.getValue(); |
| | | |
| | | if (comment.kind === "Comment") { |
| | | return "#" + comment.value.trimRight(); |
| | | } |
| | | |
| | | throw new Error("Not a comment: " + JSON.stringify(comment)); |
| | | } |
| | | |
| | | function determineInterfaceSeparator(originalSource) { |
| | | var start = originalSource.indexOf("implements"); |
| | | |
| | | if (start === -1) { |
| | | throw new Error("Must implement interfaces: " + originalSource); |
| | | } |
| | | |
| | | var end = originalSource.indexOf("{"); |
| | | |
| | | if (end === -1) { |
| | | end = originalSource.length; |
| | | } |
| | | |
| | | return originalSource.substr(start, end).includes("&") ? " & " : ", "; |
| | | } |
| | | |
| | | function clean$1(node, newNode |
| | | /*, parent*/ |
| | | ) { |
| | | delete newNode.loc; |
| | | delete newNode.comments; |
| | | } |
| | | |
| | | var printerGraphql = { |
| | | print: genericPrint$1, |
| | | massageAstNode: clean$1, |
| | | hasPrettierIgnore: hasIgnoreComment$2, |
| | | insertPragma: insertPragma$4, |
| | | printComment: printComment$1, |
| | | canAttachComment: canAttachComment |
| | | }; |
| | | |
| | | var options$3 = { |
| | | bracketSpacing: commonOptions.bracketSpacing |
| | | }; |
| | | |
| | | var name$5 = "GraphQL"; |
| | | var type$4 = "data"; |
| | | var extensions$4 = [ |
| | | ".graphql", |
| | | ".gql", |
| | | ".graphqls" |
| | | ]; |
| | | var tmScope$4 = "source.graphql"; |
| | | var aceMode$4 = "text"; |
| | | var languageId$4 = 139; |
| | | var GraphQL = { |
| | | name: name$5, |
| | | type: type$4, |
| | | extensions: extensions$4, |
| | | tmScope: tmScope$4, |
| | | aceMode: aceMode$4, |
| | | languageId: languageId$4 |
| | | }; |
| | | |
| | | var GraphQL$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$5, |
| | | type: type$4, |
| | | extensions: extensions$4, |
| | | tmScope: tmScope$4, |
| | | aceMode: aceMode$4, |
| | | languageId: languageId$4, |
| | | 'default': GraphQL |
| | | }); |
| | | |
| | | var require$$0$3 = getCjsExportFromNamespace(GraphQL$1); |
| | | |
| | | var languages$1 = [createLanguage(require$$0$3, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.5.0", |
| | | parsers: ["graphql"], |
| | | vscodeLanguageIds: ["graphql"] |
| | | }); |
| | | })]; |
| | | var printers$1 = { |
| | | graphql: printerGraphql |
| | | }; |
| | | var languageGraphql = { |
| | | languages: languages$1, |
| | | options: options$3, |
| | | printers: printers$1 |
| | | }; |
| | | |
| | | var _require$$0$builders$3 = doc.builders, |
| | | concat$7 = _require$$0$builders$3.concat, |
| | | join$4 = _require$$0$builders$3.join, |
| | | softline$3 = _require$$0$builders$3.softline, |
| | | hardline$6 = _require$$0$builders$3.hardline, |
| | | line$3 = _require$$0$builders$3.line, |
| | | group$6 = _require$$0$builders$3.group, |
| | | indent$4 = _require$$0$builders$3.indent, |
| | | ifBreak$3 = _require$$0$builders$3.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements |
| | | |
| | | var voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter: |
| | | // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts |
| | | |
| | | function printChildren(path, options, print) { |
| | | return concat$7(path.map(function (childPath, childIndex) { |
| | | var childNode = path.getValue(); |
| | | var isFirstNode = childIndex === 0; |
| | | var isLastNode = childIndex == path.getParentNode(0).children.length - 1; |
| | | var isLastNodeInMultiNodeList = isLastNode && !isFirstNode; |
| | | var isWhitespace = isWhitespaceNode(childNode); |
| | | |
| | | if (isWhitespace && isLastNodeInMultiNodeList) { |
| | | return print(childPath, options, print); |
| | | } else if (isFirstNode) { |
| | | return concat$7([softline$3, print(childPath, options, print)]); |
| | | } |
| | | |
| | | return print(childPath, options, print); |
| | | }, "children")); |
| | | } |
| | | |
| | | function print(path, options, print) { |
| | | var n = path.getValue(); |
| | | /* istanbul ignore if*/ |
| | | |
| | | if (!n) { |
| | | return ""; |
| | | } |
| | | |
| | | switch (n.type) { |
| | | case "Block": |
| | | case "Program": |
| | | case "Template": |
| | | { |
| | | return group$6(concat$7(path.map(print, "body").filter(function (text) { |
| | | return text !== ""; |
| | | }))); |
| | | } |
| | | |
| | | case "ElementNode": |
| | | { |
| | | var tagFirstChar = n.tag[0]; |
| | | var isLocal = n.tag.indexOf(".") !== -1; |
| | | var isGlimmerComponent = tagFirstChar.toUpperCase() === tagFirstChar || isLocal; |
| | | var hasChildren = n.children.length > 0; |
| | | var hasNonWhitespaceChildren = n.children.some(function (n) { |
| | | return !isWhitespaceNode(n); |
| | | }); |
| | | var isVoid = isGlimmerComponent && (!hasChildren || !hasNonWhitespaceChildren) || voidTags.indexOf(n.tag) !== -1; |
| | | var closeTagForNoBreak = isVoid ? concat$7([" />", softline$3]) : ">"; |
| | | var closeTagForBreak = isVoid ? "/>" : ">"; |
| | | |
| | | var _getParams = function _getParams(path, print) { |
| | | return indent$4(concat$7([n.attributes.length ? line$3 : "", join$4(line$3, path.map(print, "attributes")), n.modifiers.length ? line$3 : "", join$4(line$3, path.map(print, "modifiers")), n.comments.length ? line$3 : "", join$4(line$3, path.map(print, "comments"))])); |
| | | }; |
| | | |
| | | var nextNode = getNextNode(path); |
| | | return concat$7([group$6(concat$7(["<", n.tag, _getParams(path, print), n.blockParams.length ? " as |".concat(n.blockParams.join(" "), "|") : "", ifBreak$3(softline$3, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), !isVoid ? group$6(concat$7([hasNonWhitespaceChildren ? indent$4(printChildren(path, options, print)) : "", ifBreak$3(hasChildren ? hardline$6 : "", ""), concat$7(["</", n.tag, ">"])])) : "", nextNode && nextNode.type === "ElementNode" ? hardline$6 : ""]); |
| | | } |
| | | |
| | | case "BlockStatement": |
| | | { |
| | | var pp = path.getParentNode(1); |
| | | var isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if"; |
| | | var hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if"; |
| | | var indentElse = hasElseIf ? function (a) { |
| | | return a; |
| | | } : indent$4; |
| | | |
| | | if (n.inverse) { |
| | | return concat$7([isElseIf ? concat$7(["{{else ", printPathParams(path, print), "}}"]) : printOpenBlock(path, print), indent$4(concat$7([hardline$6, path.call(print, "program")])), n.inverse && !hasElseIf ? concat$7([hardline$6, "{{else}}"]) : "", n.inverse ? indentElse(concat$7([hardline$6, path.call(print, "inverse")])) : "", isElseIf ? "" : concat$7([hardline$6, printCloseBlock(path, print)])]); |
| | | } else if (isElseIf) { |
| | | return concat$7([concat$7(["{{else ", printPathParams(path, print), "}}"]), indent$4(concat$7([hardline$6, path.call(print, "program")]))]); |
| | | } |
| | | |
| | | var _hasNonWhitespaceChildren = n.program.body.some(function (n) { |
| | | return !isWhitespaceNode(n); |
| | | }); |
| | | |
| | | return concat$7([printOpenBlock(path, print), group$6(concat$7([indent$4(concat$7([softline$3, path.call(print, "program")])), _hasNonWhitespaceChildren ? hardline$6 : softline$3, printCloseBlock(path, print)]))]); |
| | | } |
| | | |
| | | case "ElementModifierStatement": |
| | | case "MustacheStatement": |
| | | { |
| | | var _pp = path.getParentNode(1); |
| | | |
| | | var isConcat = _pp && _pp.type === "ConcatStatement"; |
| | | return group$6(concat$7([n.escaped === false ? "{{{" : "{{", printPathParams(path, print, { |
| | | group: false |
| | | }), isConcat ? "" : softline$3, n.escaped === false ? "}}}" : "}}"])); |
| | | } |
| | | |
| | | case "SubExpression": |
| | | { |
| | | var params = getParams(path, print); |
| | | var printedParams = params.length > 0 ? indent$4(concat$7([line$3, group$6(join$4(line$3, params))])) : ""; |
| | | return group$6(concat$7(["(", printPath(path, print), printedParams, softline$3, ")"])); |
| | | } |
| | | |
| | | case "AttrNode": |
| | | { |
| | | var isText = n.value.type === "TextNode"; |
| | | |
| | | if (isText && n.value.loc.start.column === n.value.loc.end.column) { |
| | | return concat$7([n.name]); |
| | | } |
| | | |
| | | var value = path.call(print, "value"); |
| | | var quotedValue = isText ? printStringLiteral(value.parts.join(), options) : value; |
| | | return concat$7([n.name, "=", quotedValue]); |
| | | } |
| | | |
| | | case "ConcatStatement": |
| | | { |
| | | return concat$7(['"', group$6(indent$4(join$4(softline$3, path.map(function (partPath) { |
| | | return print(partPath); |
| | | }, "parts").filter(function (a) { |
| | | return a !== ""; |
| | | })))), '"']); |
| | | } |
| | | |
| | | case "Hash": |
| | | { |
| | | return concat$7([join$4(line$3, path.map(print, "pairs"))]); |
| | | } |
| | | |
| | | case "HashPair": |
| | | { |
| | | return concat$7([n.key, "=", path.call(print, "value")]); |
| | | } |
| | | |
| | | case "TextNode": |
| | | { |
| | | var maxLineBreaksToPreserve = 2; |
| | | var isFirstElement = !getPreviousNode(path); |
| | | var isLastElement = !getNextNode(path); |
| | | var isWhitespaceOnly = !/\S/.test(n.chars); |
| | | var lineBreaksCount = countNewLines(n.chars); |
| | | var hasBlockParent = path.getParentNode(0).type === "Block"; |
| | | var hasElementParent = path.getParentNode(0).type === "ElementNode"; |
| | | var hasTemplateParent = path.getParentNode(0).type === "Template"; |
| | | var leadingLineBreaksCount = countLeadingNewLines(n.chars); |
| | | var trailingLineBreaksCount = countTrailingNewLines(n.chars); |
| | | |
| | | if ((isFirstElement || isLastElement) && isWhitespaceOnly && (hasBlockParent || hasElementParent || hasTemplateParent)) { |
| | | return ""; |
| | | } |
| | | |
| | | if (isWhitespaceOnly && lineBreaksCount) { |
| | | leadingLineBreaksCount = Math.min(lineBreaksCount, maxLineBreaksToPreserve); |
| | | trailingLineBreaksCount = 0; |
| | | } else { |
| | | if (isNextNodeOfType(path, "ElementNode") || isNextNodeOfType(path, "BlockStatement")) { |
| | | trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1); |
| | | } |
| | | |
| | | if (isPreviousNodeOfSomeType(path, ["ElementNode"]) || isPreviousNodeOfSomeType(path, ["BlockStatement"])) { |
| | | leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1); |
| | | } |
| | | } |
| | | |
| | | var leadingSpace = ""; |
| | | var trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present, |
| | | // when next to mustache statement. |
| | | |
| | | var inAttrNode = path.stack.indexOf("attributes") >= 0; |
| | | |
| | | if (inAttrNode) { |
| | | var parentNode = path.getParentNode(0); |
| | | |
| | | var _isConcat = parentNode.type === "ConcatStatement"; |
| | | |
| | | if (_isConcat) { |
| | | var parts = parentNode.parts; |
| | | var partIndex = parts.indexOf(n); |
| | | |
| | | if (partIndex > 0) { |
| | | var partType = parts[partIndex - 1].type; |
| | | var isMustache = partType === "MustacheStatement"; |
| | | |
| | | if (isMustache) { |
| | | leadingSpace = " "; |
| | | } |
| | | } |
| | | |
| | | if (partIndex < parts.length - 1) { |
| | | var _partType = parts[partIndex + 1].type; |
| | | |
| | | var _isMustache = _partType === "MustacheStatement"; |
| | | |
| | | if (_isMustache) { |
| | | trailingSpace = " "; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | if (trailingLineBreaksCount === 0 && isNextNodeOfType(path, "MustacheStatement")) { |
| | | trailingSpace = " "; |
| | | } |
| | | |
| | | if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType(path, ["MustacheStatement"])) { |
| | | leadingSpace = " "; |
| | | } |
| | | |
| | | if (isFirstElement) { |
| | | leadingLineBreaksCount = 0; |
| | | leadingSpace = ""; |
| | | } |
| | | |
| | | if (isLastElement) { |
| | | trailingLineBreaksCount = 0; |
| | | trailingSpace = ""; |
| | | } |
| | | } |
| | | |
| | | return concat$7([].concat(_toConsumableArray(generateHardlines(leadingLineBreaksCount, maxLineBreaksToPreserve)), [n.chars.replace(/^[\s ]+/g, leadingSpace).replace(/[\s ]+$/, trailingSpace)], _toConsumableArray(generateHardlines(trailingLineBreaksCount, maxLineBreaksToPreserve))).filter(Boolean)); |
| | | } |
| | | |
| | | case "MustacheCommentStatement": |
| | | { |
| | | var dashes = n.value.indexOf("}}") > -1 ? "--" : ""; |
| | | return concat$7(["{{!", dashes, n.value, dashes, "}}"]); |
| | | } |
| | | |
| | | case "PathExpression": |
| | | { |
| | | return n.original; |
| | | } |
| | | |
| | | case "BooleanLiteral": |
| | | { |
| | | return String(n.value); |
| | | } |
| | | |
| | | case "CommentStatement": |
| | | { |
| | | return concat$7(["<!--", n.value, "-->"]); |
| | | } |
| | | |
| | | case "StringLiteral": |
| | | { |
| | | return printStringLiteral(n.value, options); |
| | | } |
| | | |
| | | case "NumberLiteral": |
| | | { |
| | | return String(n.value); |
| | | } |
| | | |
| | | case "UndefinedLiteral": |
| | | { |
| | | return "undefined"; |
| | | } |
| | | |
| | | case "NullLiteral": |
| | | { |
| | | return "null"; |
| | | } |
| | | |
| | | /* istanbul ignore next */ |
| | | |
| | | default: |
| | | throw new Error("unknown glimmer type: " + JSON.stringify(n.type)); |
| | | } |
| | | } |
| | | /** |
| | | * Prints a string literal with the correct surrounding quotes based on |
| | | * `options.singleQuote` and the number of escaped quotes contained in |
| | | * the string literal. This function is the glimmer equivalent of `printString` |
| | | * in `common/util`, but has differences because of the way escaped characters |
| | | * are treated in hbs string literals. |
| | | * @param {string} stringLiteral - the string literal value |
| | | * @param {object} options - the prettier options object |
| | | */ |
| | | |
| | | |
| | | function printStringLiteral(stringLiteral, options) { |
| | | var double = { |
| | | quote: '"', |
| | | regex: /"/g |
| | | }; |
| | | var single = { |
| | | quote: "'", |
| | | regex: /'/g |
| | | }; |
| | | var preferred = options.singleQuote ? single : double; |
| | | var alternate = preferred === single ? double : single; |
| | | var shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for |
| | | // enclosing the string, we might want to enclose with the alternate quote |
| | | // instead, to minimize the number of escaped quotes. |
| | | |
| | | if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) { |
| | | var numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length; |
| | | var numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length; |
| | | shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes; |
| | | } |
| | | |
| | | var enclosingQuote = shouldUseAlternateQuote ? alternate : preferred; |
| | | var escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, "\\".concat(enclosingQuote.quote)); |
| | | return "".concat(enclosingQuote.quote).concat(escapedStringLiteral).concat(enclosingQuote.quote); |
| | | } |
| | | |
| | | function printPath(path, print) { |
| | | return path.call(print, "path"); |
| | | } |
| | | |
| | | function getParams(path, print) { |
| | | var node = path.getValue(); |
| | | var parts = []; |
| | | |
| | | if (node.params.length > 0) { |
| | | parts = parts.concat(path.map(print, "params")); |
| | | } |
| | | |
| | | if (node.hash && node.hash.pairs.length > 0) { |
| | | parts.push(path.call(print, "hash")); |
| | | } |
| | | |
| | | return parts; |
| | | } |
| | | |
| | | function printPathParams(path, print, options) { |
| | | var parts = []; |
| | | options = Object.assign({ |
| | | group: true |
| | | }, options || {}); |
| | | parts.push(printPath(path, print)); |
| | | parts = parts.concat(getParams(path, print)); |
| | | |
| | | if (!options.group) { |
| | | return indent$4(join$4(line$3, parts)); |
| | | } |
| | | |
| | | return indent$4(group$6(join$4(line$3, parts))); |
| | | } |
| | | |
| | | function printBlockParams(path) { |
| | | var block = path.getValue(); |
| | | |
| | | if (!block.program || !block.program.blockParams.length) { |
| | | return ""; |
| | | } |
| | | |
| | | return concat$7([" as |", block.program.blockParams.join(" "), "|"]); |
| | | } |
| | | |
| | | function printOpenBlock(path, print) { |
| | | return group$6(concat$7(["{{#", printPathParams(path, print), printBlockParams(path), softline$3, "}}"])); |
| | | } |
| | | |
| | | function printCloseBlock(path, print) { |
| | | return concat$7(["{{/", path.call(print, "path"), "}}"]); |
| | | } |
| | | |
| | | function isWhitespaceNode(node) { |
| | | return node.type === "TextNode" && !/\S/.test(node.chars); |
| | | } |
| | | |
| | | function getPreviousNode(path) { |
| | | var node = path.getValue(); |
| | | var parentNode = path.getParentNode(0); |
| | | var children = parentNode.children || parentNode.body; |
| | | |
| | | if (children) { |
| | | var nodeIndex = children.indexOf(node); |
| | | |
| | | if (nodeIndex > 0) { |
| | | var previousNode = children[nodeIndex - 1]; |
| | | return previousNode; |
| | | } |
| | | } |
| | | } |
| | | |
| | | function getNextNode(path) { |
| | | var node = path.getValue(); |
| | | var parentNode = path.getParentNode(0); |
| | | var children = parentNode.children || parentNode.body; |
| | | |
| | | if (children) { |
| | | var nodeIndex = children.indexOf(node); |
| | | |
| | | if (nodeIndex < children.length) { |
| | | var nextNode = children[nodeIndex + 1]; |
| | | return nextNode; |
| | | } |
| | | } |
| | | } |
| | | |
| | | function isPreviousNodeOfSomeType(path, types) { |
| | | var previousNode = getPreviousNode(path); |
| | | |
| | | if (previousNode) { |
| | | return types.some(function (type) { |
| | | return previousNode.type === type; |
| | | }); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isNextNodeOfType(path, type) { |
| | | var nextNode = getNextNode(path); |
| | | return nextNode && nextNode.type === type; |
| | | } |
| | | |
| | | function clean$2(ast, newObj) { |
| | | delete newObj.loc; |
| | | delete newObj.selfClosing; // (Glimmer/HTML) ignore TextNode whitespace |
| | | |
| | | if (ast.type === "TextNode") { |
| | | if (ast.chars.replace(/\s+/, "") === "") { |
| | | return null; |
| | | } |
| | | |
| | | newObj.chars = ast.chars.replace(/^\s+/, "").replace(/\s+$/, ""); |
| | | } |
| | | } |
| | | |
| | | function countNewLines(string) { |
| | | /* istanbul ignore next */ |
| | | string = typeof string === "string" ? string : ""; |
| | | return string.split("\n").length - 1; |
| | | } |
| | | |
| | | function countLeadingNewLines(string) { |
| | | /* istanbul ignore next */ |
| | | string = typeof string === "string" ? string : ""; |
| | | var newLines = (string.match(/^([^\S\r\n]*[\r\n])+/g) || [])[0] || ""; |
| | | return countNewLines(newLines); |
| | | } |
| | | |
| | | function countTrailingNewLines(string) { |
| | | /* istanbul ignore next */ |
| | | string = typeof string === "string" ? string : ""; |
| | | var newLines = (string.match(/([\r\n][^\S\r\n]*)+$/g) || [])[0] || ""; |
| | | return countNewLines(newLines); |
| | | } |
| | | |
| | | function generateHardlines() { |
| | | var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; |
| | | var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
| | | return new Array(Math.min(number, max)).fill(hardline$6); |
| | | } |
| | | |
| | | var printerGlimmer = { |
| | | print: print, |
| | | massageAstNode: clean$2 |
| | | }; |
| | | |
| | | var name$6 = "Handlebars"; |
| | | var type$5 = "markup"; |
| | | var group$7 = "HTML"; |
| | | var aliases = [ |
| | | "hbs", |
| | | "htmlbars" |
| | | ]; |
| | | var extensions$5 = [ |
| | | ".handlebars", |
| | | ".hbs" |
| | | ]; |
| | | var tmScope$5 = "text.html.handlebars"; |
| | | var aceMode$5 = "handlebars"; |
| | | var languageId$5 = 155; |
| | | var Handlebars = { |
| | | name: name$6, |
| | | type: type$5, |
| | | group: group$7, |
| | | aliases: aliases, |
| | | extensions: extensions$5, |
| | | tmScope: tmScope$5, |
| | | aceMode: aceMode$5, |
| | | languageId: languageId$5 |
| | | }; |
| | | |
| | | var Handlebars$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$6, |
| | | type: type$5, |
| | | group: group$7, |
| | | aliases: aliases, |
| | | extensions: extensions$5, |
| | | tmScope: tmScope$5, |
| | | aceMode: aceMode$5, |
| | | languageId: languageId$5, |
| | | 'default': Handlebars |
| | | }); |
| | | |
| | | var require$$0$4 = getCjsExportFromNamespace(Handlebars$1); |
| | | |
| | | var languages$2 = [createLanguage(require$$0$4, function (data) { |
| | | return Object.assign(data, { |
| | | since: null, |
| | | // unreleased |
| | | parsers: ["glimmer"], |
| | | vscodeLanguageIds: ["handlebars"] |
| | | }); |
| | | })]; |
| | | var printers$2 = { |
| | | glimmer: printerGlimmer |
| | | }; |
| | | var languageHandlebars = { |
| | | languages: languages$2, |
| | | printers: printers$2 |
| | | }; |
| | | |
| | | var clean$3 = function clean(ast, newNode) { |
| | | delete newNode.sourceSpan; |
| | | delete newNode.startSourceSpan; |
| | | delete newNode.endSourceSpan; |
| | | delete newNode.nameSpan; |
| | | delete newNode.valueSpan; |
| | | |
| | | if (ast.type === "text" || ast.type === "comment") { |
| | | return null; |
| | | } // may be formatted by multiparser |
| | | |
| | | |
| | | if (ast.type === "yaml" || ast.type === "toml") { |
| | | return null; |
| | | } |
| | | |
| | | if (ast.type === "attribute") { |
| | | delete newNode.value; |
| | | } |
| | | |
| | | if (ast.type === "docType") { |
| | | delete newNode.value; |
| | | } |
| | | }; |
| | | |
| | | var json = { |
| | | "CSS_DISPLAY_TAGS": { |
| | | "area": "none", |
| | | "base": "none", |
| | | "basefont": "none", |
| | | "datalist": "none", |
| | | "head": "none", |
| | | "link": "none", |
| | | "meta": "none", |
| | | "noembed": "none", |
| | | "noframes": "none", |
| | | "param": "none", |
| | | "rp": "none", |
| | | "script": "block", |
| | | "source": "block", |
| | | "style": "none", |
| | | "template": "inline", |
| | | "track": "block", |
| | | "title": "none", |
| | | "html": "block", |
| | | "body": "block", |
| | | "address": "block", |
| | | "blockquote": "block", |
| | | "center": "block", |
| | | "div": "block", |
| | | "figure": "block", |
| | | "figcaption": "block", |
| | | "footer": "block", |
| | | "form": "block", |
| | | "header": "block", |
| | | "hr": "block", |
| | | "legend": "block", |
| | | "listing": "block", |
| | | "main": "block", |
| | | "p": "block", |
| | | "plaintext": "block", |
| | | "pre": "block", |
| | | "xmp": "block", |
| | | "slot": "contents", |
| | | "ruby": "ruby", |
| | | "rt": "ruby-text", |
| | | "article": "block", |
| | | "aside": "block", |
| | | "h1": "block", |
| | | "h2": "block", |
| | | "h3": "block", |
| | | "h4": "block", |
| | | "h5": "block", |
| | | "h6": "block", |
| | | "hgroup": "block", |
| | | "nav": "block", |
| | | "section": "block", |
| | | "dir": "block", |
| | | "dd": "block", |
| | | "dl": "block", |
| | | "dt": "block", |
| | | "ol": "block", |
| | | "ul": "block", |
| | | "li": "list-item", |
| | | "table": "table", |
| | | "caption": "table-caption", |
| | | "colgroup": "table-column-group", |
| | | "col": "table-column", |
| | | "thead": "table-header-group", |
| | | "tbody": "table-row-group", |
| | | "tfoot": "table-footer-group", |
| | | "tr": "table-row", |
| | | "td": "table-cell", |
| | | "th": "table-cell", |
| | | "fieldset": "block", |
| | | "button": "inline-block", |
| | | "video": "inline-block", |
| | | "audio": "inline-block" |
| | | }, |
| | | "CSS_DISPLAY_DEFAULT": "inline", |
| | | "CSS_WHITE_SPACE_TAGS": { |
| | | "listing": "pre", |
| | | "plaintext": "pre", |
| | | "pre": "pre", |
| | | "xmp": "pre", |
| | | "nobr": "nowrap", |
| | | "table": "initial", |
| | | "textarea": "pre-wrap" |
| | | }, |
| | | "CSS_WHITE_SPACE_DEFAULT": "normal" |
| | | }; |
| | | |
| | | var a = [ |
| | | "accesskey", |
| | | "charset", |
| | | "coords", |
| | | "download", |
| | | "href", |
| | | "hreflang", |
| | | "name", |
| | | "ping", |
| | | "referrerpolicy", |
| | | "rel", |
| | | "rev", |
| | | "shape", |
| | | "tabindex", |
| | | "target", |
| | | "type" |
| | | ]; |
| | | var abbr = [ |
| | | "title" |
| | | ]; |
| | | var applet = [ |
| | | "align", |
| | | "alt", |
| | | "archive", |
| | | "code", |
| | | "codebase", |
| | | "height", |
| | | "hspace", |
| | | "name", |
| | | "object", |
| | | "vspace", |
| | | "width" |
| | | ]; |
| | | var area = [ |
| | | "accesskey", |
| | | "alt", |
| | | "coords", |
| | | "download", |
| | | "href", |
| | | "hreflang", |
| | | "nohref", |
| | | "ping", |
| | | "referrerpolicy", |
| | | "rel", |
| | | "shape", |
| | | "tabindex", |
| | | "target", |
| | | "type" |
| | | ]; |
| | | var audio = [ |
| | | "autoplay", |
| | | "controls", |
| | | "crossorigin", |
| | | "loop", |
| | | "muted", |
| | | "preload", |
| | | "src" |
| | | ]; |
| | | var base = [ |
| | | "href", |
| | | "target" |
| | | ]; |
| | | var basefont = [ |
| | | "color", |
| | | "face", |
| | | "size" |
| | | ]; |
| | | var bdo = [ |
| | | "dir" |
| | | ]; |
| | | var blockquote = [ |
| | | "cite" |
| | | ]; |
| | | var body = [ |
| | | "alink", |
| | | "background", |
| | | "bgcolor", |
| | | "link", |
| | | "text", |
| | | "vlink" |
| | | ]; |
| | | var br = [ |
| | | "clear" |
| | | ]; |
| | | var button = [ |
| | | "accesskey", |
| | | "autofocus", |
| | | "disabled", |
| | | "form", |
| | | "formaction", |
| | | "formenctype", |
| | | "formmethod", |
| | | "formnovalidate", |
| | | "formtarget", |
| | | "name", |
| | | "tabindex", |
| | | "type", |
| | | "value" |
| | | ]; |
| | | var canvas = [ |
| | | "height", |
| | | "width" |
| | | ]; |
| | | var caption = [ |
| | | "align" |
| | | ]; |
| | | var col = [ |
| | | "align", |
| | | "char", |
| | | "charoff", |
| | | "span", |
| | | "valign", |
| | | "width" |
| | | ]; |
| | | var colgroup = [ |
| | | "align", |
| | | "char", |
| | | "charoff", |
| | | "span", |
| | | "valign", |
| | | "width" |
| | | ]; |
| | | var data = [ |
| | | "value" |
| | | ]; |
| | | var del = [ |
| | | "cite", |
| | | "datetime" |
| | | ]; |
| | | var details = [ |
| | | "open" |
| | | ]; |
| | | var dfn = [ |
| | | "title" |
| | | ]; |
| | | var dialog = [ |
| | | "open" |
| | | ]; |
| | | var dir = [ |
| | | "compact" |
| | | ]; |
| | | var div = [ |
| | | "align" |
| | | ]; |
| | | var dl = [ |
| | | "compact" |
| | | ]; |
| | | var embed$1 = [ |
| | | "height", |
| | | "src", |
| | | "type", |
| | | "width" |
| | | ]; |
| | | var fieldset = [ |
| | | "disabled", |
| | | "form", |
| | | "name" |
| | | ]; |
| | | var font = [ |
| | | "color", |
| | | "face", |
| | | "size" |
| | | ]; |
| | | var form = [ |
| | | "accept", |
| | | "accept-charset", |
| | | "action", |
| | | "autocomplete", |
| | | "enctype", |
| | | "method", |
| | | "name", |
| | | "novalidate", |
| | | "target" |
| | | ]; |
| | | var frame = [ |
| | | "frameborder", |
| | | "longdesc", |
| | | "marginheight", |
| | | "marginwidth", |
| | | "name", |
| | | "noresize", |
| | | "scrolling", |
| | | "src" |
| | | ]; |
| | | var frameset = [ |
| | | "cols", |
| | | "rows" |
| | | ]; |
| | | var h1 = [ |
| | | "align" |
| | | ]; |
| | | var h2 = [ |
| | | "align" |
| | | ]; |
| | | var h3 = [ |
| | | "align" |
| | | ]; |
| | | var h4 = [ |
| | | "align" |
| | | ]; |
| | | var h5 = [ |
| | | "align" |
| | | ]; |
| | | var h6 = [ |
| | | "align" |
| | | ]; |
| | | var head = [ |
| | | "profile" |
| | | ]; |
| | | var hr = [ |
| | | "align", |
| | | "noshade", |
| | | "size", |
| | | "width" |
| | | ]; |
| | | var html = [ |
| | | "manifest", |
| | | "version" |
| | | ]; |
| | | var iframe = [ |
| | | "align", |
| | | "allow", |
| | | "allowfullscreen", |
| | | "allowpaymentrequest", |
| | | "allowusermedia", |
| | | "frameborder", |
| | | "height", |
| | | "longdesc", |
| | | "marginheight", |
| | | "marginwidth", |
| | | "name", |
| | | "referrerpolicy", |
| | | "sandbox", |
| | | "scrolling", |
| | | "src", |
| | | "srcdoc", |
| | | "width" |
| | | ]; |
| | | var img = [ |
| | | "align", |
| | | "alt", |
| | | "border", |
| | | "crossorigin", |
| | | "decoding", |
| | | "height", |
| | | "hspace", |
| | | "ismap", |
| | | "longdesc", |
| | | "name", |
| | | "referrerpolicy", |
| | | "sizes", |
| | | "src", |
| | | "srcset", |
| | | "usemap", |
| | | "vspace", |
| | | "width" |
| | | ]; |
| | | var input = [ |
| | | "accept", |
| | | "accesskey", |
| | | "align", |
| | | "alt", |
| | | "autocomplete", |
| | | "autofocus", |
| | | "checked", |
| | | "dirname", |
| | | "disabled", |
| | | "form", |
| | | "formaction", |
| | | "formenctype", |
| | | "formmethod", |
| | | "formnovalidate", |
| | | "formtarget", |
| | | "height", |
| | | "ismap", |
| | | "list", |
| | | "max", |
| | | "maxlength", |
| | | "min", |
| | | "minlength", |
| | | "multiple", |
| | | "name", |
| | | "pattern", |
| | | "placeholder", |
| | | "readonly", |
| | | "required", |
| | | "size", |
| | | "src", |
| | | "step", |
| | | "tabindex", |
| | | "title", |
| | | "type", |
| | | "usemap", |
| | | "value", |
| | | "width" |
| | | ]; |
| | | var ins = [ |
| | | "cite", |
| | | "datetime" |
| | | ]; |
| | | var isindex = [ |
| | | "prompt" |
| | | ]; |
| | | var label = [ |
| | | "accesskey", |
| | | "for", |
| | | "form" |
| | | ]; |
| | | var legend = [ |
| | | "accesskey", |
| | | "align" |
| | | ]; |
| | | var li = [ |
| | | "type", |
| | | "value" |
| | | ]; |
| | | var link$1 = [ |
| | | "as", |
| | | "charset", |
| | | "color", |
| | | "crossorigin", |
| | | "href", |
| | | "hreflang", |
| | | "imagesizes", |
| | | "imagesrcset", |
| | | "integrity", |
| | | "media", |
| | | "nonce", |
| | | "referrerpolicy", |
| | | "rel", |
| | | "rev", |
| | | "sizes", |
| | | "target", |
| | | "title", |
| | | "type" |
| | | ]; |
| | | var map = [ |
| | | "name" |
| | | ]; |
| | | var menu = [ |
| | | "compact" |
| | | ]; |
| | | var meta = [ |
| | | "charset", |
| | | "content", |
| | | "http-equiv", |
| | | "name", |
| | | "scheme" |
| | | ]; |
| | | var meter = [ |
| | | "high", |
| | | "low", |
| | | "max", |
| | | "min", |
| | | "optimum", |
| | | "value" |
| | | ]; |
| | | var object = [ |
| | | "align", |
| | | "archive", |
| | | "border", |
| | | "classid", |
| | | "codebase", |
| | | "codetype", |
| | | "data", |
| | | "declare", |
| | | "form", |
| | | "height", |
| | | "hspace", |
| | | "name", |
| | | "standby", |
| | | "tabindex", |
| | | "type", |
| | | "typemustmatch", |
| | | "usemap", |
| | | "vspace", |
| | | "width" |
| | | ]; |
| | | var ol = [ |
| | | "compact", |
| | | "reversed", |
| | | "start", |
| | | "type" |
| | | ]; |
| | | var optgroup = [ |
| | | "disabled", |
| | | "label" |
| | | ]; |
| | | var option = [ |
| | | "disabled", |
| | | "label", |
| | | "selected", |
| | | "value" |
| | | ]; |
| | | var output = [ |
| | | "for", |
| | | "form", |
| | | "name" |
| | | ]; |
| | | var p = [ |
| | | "align" |
| | | ]; |
| | | var param = [ |
| | | "name", |
| | | "type", |
| | | "value", |
| | | "valuetype" |
| | | ]; |
| | | var pre = [ |
| | | "width" |
| | | ]; |
| | | var progress = [ |
| | | "max", |
| | | "value" |
| | | ]; |
| | | var q = [ |
| | | "cite" |
| | | ]; |
| | | var script = [ |
| | | "async", |
| | | "charset", |
| | | "crossorigin", |
| | | "defer", |
| | | "integrity", |
| | | "language", |
| | | "nomodule", |
| | | "nonce", |
| | | "referrerpolicy", |
| | | "src", |
| | | "type" |
| | | ]; |
| | | var select = [ |
| | | "autocomplete", |
| | | "autofocus", |
| | | "disabled", |
| | | "form", |
| | | "multiple", |
| | | "name", |
| | | "required", |
| | | "size", |
| | | "tabindex" |
| | | ]; |
| | | var slot = [ |
| | | "name" |
| | | ]; |
| | | var source = [ |
| | | "media", |
| | | "sizes", |
| | | "src", |
| | | "srcset", |
| | | "type" |
| | | ]; |
| | | var style = [ |
| | | "media", |
| | | "nonce", |
| | | "title", |
| | | "type" |
| | | ]; |
| | | var table = [ |
| | | "align", |
| | | "bgcolor", |
| | | "border", |
| | | "cellpadding", |
| | | "cellspacing", |
| | | "frame", |
| | | "rules", |
| | | "summary", |
| | | "width" |
| | | ]; |
| | | var tbody = [ |
| | | "align", |
| | | "char", |
| | | "charoff", |
| | | "valign" |
| | | ]; |
| | | var td = [ |
| | | "abbr", |
| | | "align", |
| | | "axis", |
| | | "bgcolor", |
| | | "char", |
| | | "charoff", |
| | | "colspan", |
| | | "headers", |
| | | "height", |
| | | "nowrap", |
| | | "rowspan", |
| | | "scope", |
| | | "valign", |
| | | "width" |
| | | ]; |
| | | var textarea = [ |
| | | "accesskey", |
| | | "autocomplete", |
| | | "autofocus", |
| | | "cols", |
| | | "dirname", |
| | | "disabled", |
| | | "form", |
| | | "maxlength", |
| | | "minlength", |
| | | "name", |
| | | "placeholder", |
| | | "readonly", |
| | | "required", |
| | | "rows", |
| | | "tabindex", |
| | | "wrap" |
| | | ]; |
| | | var tfoot = [ |
| | | "align", |
| | | "char", |
| | | "charoff", |
| | | "valign" |
| | | ]; |
| | | var th = [ |
| | | "abbr", |
| | | "align", |
| | | "axis", |
| | | "bgcolor", |
| | | "char", |
| | | "charoff", |
| | | "colspan", |
| | | "headers", |
| | | "height", |
| | | "nowrap", |
| | | "rowspan", |
| | | "scope", |
| | | "valign", |
| | | "width" |
| | | ]; |
| | | var thead = [ |
| | | "align", |
| | | "char", |
| | | "charoff", |
| | | "valign" |
| | | ]; |
| | | var time = [ |
| | | "datetime" |
| | | ]; |
| | | var tr = [ |
| | | "align", |
| | | "bgcolor", |
| | | "char", |
| | | "charoff", |
| | | "valign" |
| | | ]; |
| | | var track = [ |
| | | "default", |
| | | "kind", |
| | | "label", |
| | | "src", |
| | | "srclang" |
| | | ]; |
| | | var ul = [ |
| | | "compact", |
| | | "type" |
| | | ]; |
| | | var video = [ |
| | | "autoplay", |
| | | "controls", |
| | | "crossorigin", |
| | | "height", |
| | | "loop", |
| | | "muted", |
| | | "playsinline", |
| | | "poster", |
| | | "preload", |
| | | "src", |
| | | "width" |
| | | ]; |
| | | var index$1 = { |
| | | "*": [ |
| | | "accesskey", |
| | | "autocapitalize", |
| | | "autofocus", |
| | | "class", |
| | | "contenteditable", |
| | | "dir", |
| | | "draggable", |
| | | "enterkeyhint", |
| | | "hidden", |
| | | "id", |
| | | "inputmode", |
| | | "is", |
| | | "itemid", |
| | | "itemprop", |
| | | "itemref", |
| | | "itemscope", |
| | | "itemtype", |
| | | "lang", |
| | | "nonce", |
| | | "slot", |
| | | "spellcheck", |
| | | "style", |
| | | "tabindex", |
| | | "title", |
| | | "translate" |
| | | ], |
| | | a: a, |
| | | abbr: abbr, |
| | | applet: applet, |
| | | area: area, |
| | | audio: audio, |
| | | base: base, |
| | | basefont: basefont, |
| | | bdo: bdo, |
| | | blockquote: blockquote, |
| | | body: body, |
| | | br: br, |
| | | button: button, |
| | | canvas: canvas, |
| | | caption: caption, |
| | | col: col, |
| | | colgroup: colgroup, |
| | | data: data, |
| | | del: del, |
| | | details: details, |
| | | dfn: dfn, |
| | | dialog: dialog, |
| | | dir: dir, |
| | | div: div, |
| | | dl: dl, |
| | | embed: embed$1, |
| | | fieldset: fieldset, |
| | | font: font, |
| | | form: form, |
| | | frame: frame, |
| | | frameset: frameset, |
| | | h1: h1, |
| | | h2: h2, |
| | | h3: h3, |
| | | h4: h4, |
| | | h5: h5, |
| | | h6: h6, |
| | | head: head, |
| | | hr: hr, |
| | | html: html, |
| | | iframe: iframe, |
| | | img: img, |
| | | input: input, |
| | | ins: ins, |
| | | isindex: isindex, |
| | | label: label, |
| | | legend: legend, |
| | | li: li, |
| | | link: link$1, |
| | | map: map, |
| | | menu: menu, |
| | | meta: meta, |
| | | meter: meter, |
| | | object: object, |
| | | ol: ol, |
| | | optgroup: optgroup, |
| | | option: option, |
| | | output: output, |
| | | p: p, |
| | | param: param, |
| | | pre: pre, |
| | | progress: progress, |
| | | q: q, |
| | | script: script, |
| | | select: select, |
| | | slot: slot, |
| | | source: source, |
| | | style: style, |
| | | table: table, |
| | | tbody: tbody, |
| | | td: td, |
| | | textarea: textarea, |
| | | tfoot: tfoot, |
| | | th: th, |
| | | thead: thead, |
| | | time: time, |
| | | tr: tr, |
| | | track: track, |
| | | ul: ul, |
| | | video: video |
| | | }; |
| | | |
| | | var htmlElementAttributes = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | a: a, |
| | | abbr: abbr, |
| | | applet: applet, |
| | | area: area, |
| | | audio: audio, |
| | | base: base, |
| | | basefont: basefont, |
| | | bdo: bdo, |
| | | blockquote: blockquote, |
| | | body: body, |
| | | br: br, |
| | | button: button, |
| | | canvas: canvas, |
| | | caption: caption, |
| | | col: col, |
| | | colgroup: colgroup, |
| | | data: data, |
| | | del: del, |
| | | details: details, |
| | | dfn: dfn, |
| | | dialog: dialog, |
| | | dir: dir, |
| | | div: div, |
| | | dl: dl, |
| | | embed: embed$1, |
| | | fieldset: fieldset, |
| | | font: font, |
| | | form: form, |
| | | frame: frame, |
| | | frameset: frameset, |
| | | h1: h1, |
| | | h2: h2, |
| | | h3: h3, |
| | | h4: h4, |
| | | h5: h5, |
| | | h6: h6, |
| | | head: head, |
| | | hr: hr, |
| | | html: html, |
| | | iframe: iframe, |
| | | img: img, |
| | | input: input, |
| | | ins: ins, |
| | | isindex: isindex, |
| | | label: label, |
| | | legend: legend, |
| | | li: li, |
| | | link: link$1, |
| | | map: map, |
| | | menu: menu, |
| | | meta: meta, |
| | | meter: meter, |
| | | object: object, |
| | | ol: ol, |
| | | optgroup: optgroup, |
| | | option: option, |
| | | output: output, |
| | | p: p, |
| | | param: param, |
| | | pre: pre, |
| | | progress: progress, |
| | | q: q, |
| | | script: script, |
| | | select: select, |
| | | slot: slot, |
| | | source: source, |
| | | style: style, |
| | | table: table, |
| | | tbody: tbody, |
| | | td: td, |
| | | textarea: textarea, |
| | | tfoot: tfoot, |
| | | th: th, |
| | | thead: thead, |
| | | time: time, |
| | | tr: tr, |
| | | track: track, |
| | | ul: ul, |
| | | video: video, |
| | | 'default': index$1 |
| | | }); |
| | | |
| | | var htmlElementAttributes$1 = getCjsExportFromNamespace(htmlElementAttributes); |
| | | |
| | | var CSS_DISPLAY_TAGS = json.CSS_DISPLAY_TAGS, |
| | | CSS_DISPLAY_DEFAULT = json.CSS_DISPLAY_DEFAULT, |
| | | CSS_WHITE_SPACE_TAGS = json.CSS_WHITE_SPACE_TAGS, |
| | | CSS_WHITE_SPACE_DEFAULT = json.CSS_WHITE_SPACE_DEFAULT; |
| | | var HTML_TAGS = arrayToMap(htmlTagNames$1); |
| | | var HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap); |
| | | |
| | | function arrayToMap(array) { |
| | | var map = Object.create(null); |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var value = _step.value; |
| | | map[value] = true; |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | function mapObject(object, fn) { |
| | | var newObject = Object.create(null); |
| | | |
| | | for (var _i = 0, _Object$keys = Object.keys(object); _i < _Object$keys.length; _i++) { |
| | | var key = _Object$keys[_i]; |
| | | newObject[key] = fn(object[key], key); |
| | | } |
| | | |
| | | return newObject; |
| | | } |
| | | |
| | | function shouldPreserveContent(node, options) { |
| | | if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") { |
| | | return true; |
| | | } // unterminated node in ie conditional comment |
| | | // e.g. <!--[if lt IE 9]><html><![endif]--> |
| | | |
| | | |
| | | if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) { |
| | | return true; |
| | | } // incomplete html in ie conditional comment |
| | | // e.g. <!--[if lt IE 9]></div><![endif]--> |
| | | |
| | | |
| | | if (node.type === "ieConditionalComment" && !node.complete) { |
| | | return true; |
| | | } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block |
| | | // custom blocks can be written in other languages so we should preserve them to not break the code |
| | | |
| | | |
| | | if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && ["template", "style", "script", // vue parser can be used for vue dom template as well, so we should still format top-level <html> |
| | | "html"].indexOf(node.fullName) === -1) { |
| | | return true; |
| | | } // TODO: handle non-text children in <pre> |
| | | |
| | | |
| | | if (isPreLikeNode(node) && node.children.some(function (child) { |
| | | return child.type !== "text" && child.type !== "interpolation"; |
| | | })) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function hasPrettierIgnore(node) { |
| | | if (node.type === "attribute" || isTextLikeNode(node)) { |
| | | return false; |
| | | } |
| | | |
| | | if (!node.parent) { |
| | | return false; |
| | | } |
| | | |
| | | if (typeof node.index !== "number" || node.index === 0) { |
| | | return false; |
| | | } |
| | | |
| | | var prevNode = node.parent.children[node.index - 1]; |
| | | return isPrettierIgnore(prevNode); |
| | | } |
| | | |
| | | function isPrettierIgnore(node) { |
| | | return node.type === "comment" && node.value.trim() === "prettier-ignore"; |
| | | } |
| | | |
| | | function getPrettierIgnoreAttributeCommentData(value) { |
| | | var match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/); |
| | | |
| | | if (!match) { |
| | | return false; |
| | | } |
| | | |
| | | if (!match[1]) { |
| | | return true; |
| | | } |
| | | |
| | | return match[1].split(/\s+/); |
| | | } |
| | | /** there's no opening/closing tag or it's considered not breakable */ |
| | | |
| | | |
| | | function isTextLikeNode(node) { |
| | | return node.type === "text" || node.type === "comment"; |
| | | } |
| | | |
| | | function isScriptLikeTag(node) { |
| | | return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style"); |
| | | } |
| | | |
| | | function isFrontMatterNode(node) { |
| | | return node.type === "yaml" || node.type === "toml"; |
| | | } |
| | | |
| | | function canHaveInterpolation(node) { |
| | | return node.children && !isScriptLikeTag(node); |
| | | } |
| | | |
| | | function isWhitespaceSensitiveNode(node) { |
| | | return isScriptLikeTag(node) || node.type === "interpolation" || isIndentationSensitiveNode(node); |
| | | } |
| | | |
| | | function isIndentationSensitiveNode(node) { |
| | | return getNodeCssStyleWhiteSpace(node).startsWith("pre"); |
| | | } |
| | | |
| | | function isLeadingSpaceSensitiveNode(node) { |
| | | var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode(); |
| | | |
| | | if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) { |
| | | return node.type === "interpolation"; |
| | | } |
| | | |
| | | return isLeadingSpaceSensitive; |
| | | |
| | | function _isLeadingSpaceSensitiveNode() { |
| | | if (isFrontMatterNode(node)) { |
| | | return false; |
| | | } |
| | | |
| | | if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) { |
| | | return true; |
| | | } |
| | | |
| | | if (!node.parent || node.parent.cssDisplay === "none") { |
| | | return false; |
| | | } |
| | | |
| | | if (isPreLikeNode(node.parent)) { |
| | | return true; |
| | | } |
| | | |
| | | if (!node.prev && (node.parent.type === "root" || isScriptLikeTag(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) { |
| | | return false; |
| | | } |
| | | |
| | | if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | function isTrailingSpaceSensitiveNode(node) { |
| | | if (isFrontMatterNode(node)) { |
| | | return false; |
| | | } |
| | | |
| | | if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) { |
| | | return true; |
| | | } |
| | | |
| | | if (!node.parent || node.parent.cssDisplay === "none") { |
| | | return false; |
| | | } |
| | | |
| | | if (isPreLikeNode(node.parent)) { |
| | | return true; |
| | | } |
| | | |
| | | if (!node.next && (node.parent.type === "root" || isScriptLikeTag(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) { |
| | | return false; |
| | | } |
| | | |
| | | if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function isDanglingSpaceSensitiveNode(node) { |
| | | return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag(node); |
| | | } |
| | | |
| | | function forceNextEmptyLine(node) { |
| | | return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line; |
| | | } |
| | | /** firstChild leadingSpaces and lastChild trailingSpaces */ |
| | | |
| | | |
| | | function forceBreakContent(node) { |
| | | return forceBreakChildren(node) || node.type === "element" && node.children.length !== 0 && (["body", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) { |
| | | return hasNonTextChild(child); |
| | | })) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild)); |
| | | } |
| | | /** spaces between children */ |
| | | |
| | | |
| | | function forceBreakChildren(node) { |
| | | return node.type === "element" && node.children.length !== 0 && (["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell"); |
| | | } |
| | | |
| | | function preferHardlineAsLeadingSpaces(node) { |
| | | return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node); |
| | | } |
| | | |
| | | function preferHardlineAsTrailingSpaces(node) { |
| | | return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node); |
| | | } |
| | | |
| | | function hasSurroundingLineBreak(node) { |
| | | return hasLeadingLineBreak(node) && hasTrailingLineBreak(node); |
| | | } |
| | | |
| | | function hasLeadingLineBreak(node) { |
| | | return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line); |
| | | } |
| | | |
| | | function hasTrailingLineBreak(node) { |
| | | return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan.start.line > node.sourceSpan.end.line); |
| | | } |
| | | |
| | | function preferHardlineAsSurroundingSpaces(node) { |
| | | switch (node.type) { |
| | | case "ieConditionalComment": |
| | | case "comment": |
| | | case "directive": |
| | | return true; |
| | | |
| | | case "element": |
| | | return ["script", "select"].indexOf(node.name) !== -1; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function getLastDescendant(node) { |
| | | return node.lastChild ? getLastDescendant(node.lastChild) : node; |
| | | } |
| | | |
| | | function hasNonTextChild(node) { |
| | | return node.children && node.children.some(function (child) { |
| | | return child.type !== "text"; |
| | | }); |
| | | } |
| | | |
| | | function inferScriptParser(node) { |
| | | if (node.name === "script" && !node.attrMap.src) { |
| | | if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript") { |
| | | return "babel"; |
| | | } |
| | | |
| | | if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") { |
| | | return "typescript"; |
| | | } |
| | | |
| | | if (node.attrMap.type === "text/markdown") { |
| | | return "markdown"; |
| | | } |
| | | |
| | | if (node.attrMap.type.endsWith("json") || node.attrMap.type.endsWith("importmap")) { |
| | | return "json"; |
| | | } |
| | | } |
| | | |
| | | if (node.name === "style") { |
| | | if (!node.attrMap.lang || node.attrMap.lang === "postcss" || node.attrMap.lang === "css") { |
| | | return "css"; |
| | | } |
| | | |
| | | if (node.attrMap.lang === "scss") { |
| | | return "scss"; |
| | | } |
| | | |
| | | if (node.attrMap.lang === "less") { |
| | | return "less"; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function isBlockLikeCssDisplay(cssDisplay) { |
| | | return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table"); |
| | | } |
| | | |
| | | function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) { |
| | | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block"; |
| | | } |
| | | |
| | | function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) { |
| | | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block"; |
| | | } |
| | | |
| | | function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) { |
| | | return !isBlockLikeCssDisplay(cssDisplay); |
| | | } |
| | | |
| | | function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) { |
| | | return !isBlockLikeCssDisplay(cssDisplay); |
| | | } |
| | | |
| | | function isDanglingSpaceSensitiveCssDisplay(cssDisplay) { |
| | | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block"; |
| | | } |
| | | |
| | | function isPreLikeNode(node) { |
| | | return getNodeCssStyleWhiteSpace(node).startsWith("pre"); |
| | | } |
| | | |
| | | function countParents(path) { |
| | | var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { |
| | | return true; |
| | | }; |
| | | var counter = 0; |
| | | |
| | | for (var i = path.stack.length - 1; i >= 0; i--) { |
| | | var value = path.stack[i]; |
| | | |
| | | if (value && _typeof(value) === "object" && !Array.isArray(value) && predicate(value)) { |
| | | counter++; |
| | | } |
| | | } |
| | | |
| | | return counter; |
| | | } |
| | | |
| | | function hasParent(node, fn) { |
| | | var current = node; |
| | | |
| | | while (current) { |
| | | if (fn(current)) { |
| | | return true; |
| | | } |
| | | |
| | | current = current.parent; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function getNodeCssStyleDisplay(node, options) { |
| | | if (node.prev && node.prev.type === "comment") { |
| | | // <!-- display: block --> |
| | | var match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/); |
| | | |
| | | if (match) { |
| | | return match[1]; |
| | | } |
| | | } |
| | | |
| | | var isInSvgForeignObject = false; |
| | | |
| | | if (node.type === "element" && node.namespace === "svg") { |
| | | if (hasParent(node, function (parent) { |
| | | return parent.fullName === "svg:foreignObject"; |
| | | })) { |
| | | isInSvgForeignObject = true; |
| | | } else { |
| | | return node.name === "svg" ? "inline-block" : "block"; |
| | | } |
| | | } |
| | | |
| | | switch (options.htmlWhitespaceSensitivity) { |
| | | case "strict": |
| | | return "inline"; |
| | | |
| | | case "ignore": |
| | | return "block"; |
| | | |
| | | default: |
| | | return node.type === "element" && (!node.namespace || isInSvgForeignObject) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT; |
| | | } |
| | | } |
| | | |
| | | function getNodeCssStyleWhiteSpace(node) { |
| | | return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT; |
| | | } |
| | | |
| | | function getMinIndentation(text) { |
| | | var minIndentation = Infinity; |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var lineText = _step2.value; |
| | | |
| | | if (lineText.length === 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (/\S/.test(lineText[0])) { |
| | | return 0; |
| | | } |
| | | |
| | | var indentation = lineText.match(/^\s*/)[0].length; |
| | | |
| | | if (lineText.length === indentation) { |
| | | continue; |
| | | } |
| | | |
| | | if (indentation < minIndentation) { |
| | | minIndentation = indentation; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return minIndentation === Infinity ? 0 : minIndentation; |
| | | } |
| | | |
| | | function dedentString(text) { |
| | | var minIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getMinIndentation(text); |
| | | return minIndent === 0 ? text : text.split("\n").map(function (lineText) { |
| | | return lineText.slice(minIndent); |
| | | }).join("\n"); |
| | | } |
| | | |
| | | function normalizeParts(parts) { |
| | | var newParts = []; |
| | | var restParts = parts.slice(); |
| | | |
| | | while (restParts.length !== 0) { |
| | | var part = restParts.shift(); |
| | | |
| | | if (!part) { |
| | | continue; |
| | | } |
| | | |
| | | if (part.type === "concat") { |
| | | Array.prototype.unshift.apply(restParts, part.parts); |
| | | continue; |
| | | } |
| | | |
| | | if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") { |
| | | newParts.push(newParts.pop() + part); |
| | | continue; |
| | | } |
| | | |
| | | newParts.push(part); |
| | | } |
| | | |
| | | return newParts; |
| | | } |
| | | |
| | | function identity(x) { |
| | | return x; |
| | | } |
| | | |
| | | function shouldNotPrintClosingTag(node, options) { |
| | | return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore(node) || shouldPreserveContent(node.parent, options)); |
| | | } |
| | | |
| | | function countChars(text, char) { |
| | | var counter = 0; |
| | | |
| | | for (var i = 0; i < text.length; i++) { |
| | | if (text[i] === char) { |
| | | counter++; |
| | | } |
| | | } |
| | | |
| | | return counter; |
| | | } |
| | | |
| | | function unescapeQuoteEntities(text) { |
| | | return text.replace(/'/g, "'").replace(/"/g, '"'); |
| | | } |
| | | |
| | | var utils$3 = { |
| | | HTML_ELEMENT_ATTRIBUTES: HTML_ELEMENT_ATTRIBUTES, |
| | | HTML_TAGS: HTML_TAGS, |
| | | canHaveInterpolation: canHaveInterpolation, |
| | | countChars: countChars, |
| | | countParents: countParents, |
| | | dedentString: dedentString, |
| | | forceBreakChildren: forceBreakChildren, |
| | | forceBreakContent: forceBreakContent, |
| | | forceNextEmptyLine: forceNextEmptyLine, |
| | | getLastDescendant: getLastDescendant, |
| | | getNodeCssStyleDisplay: getNodeCssStyleDisplay, |
| | | getNodeCssStyleWhiteSpace: getNodeCssStyleWhiteSpace, |
| | | getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData, |
| | | hasPrettierIgnore: hasPrettierIgnore, |
| | | identity: identity, |
| | | inferScriptParser: inferScriptParser, |
| | | isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode, |
| | | isFrontMatterNode: isFrontMatterNode, |
| | | isIndentationSensitiveNode: isIndentationSensitiveNode, |
| | | isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode, |
| | | isPreLikeNode: isPreLikeNode, |
| | | isScriptLikeTag: isScriptLikeTag, |
| | | isTextLikeNode: isTextLikeNode, |
| | | isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode, |
| | | isWhitespaceSensitiveNode: isWhitespaceSensitiveNode, |
| | | normalizeParts: normalizeParts, |
| | | preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces, |
| | | preferHardlineAsTrailingSpaces: preferHardlineAsTrailingSpaces, |
| | | shouldNotPrintClosingTag: shouldNotPrintClosingTag, |
| | | shouldPreserveContent: shouldPreserveContent, |
| | | unescapeQuoteEntities: unescapeQuoteEntities |
| | | }; |
| | | |
| | | var canHaveInterpolation$1 = utils$3.canHaveInterpolation, |
| | | getNodeCssStyleDisplay$1 = utils$3.getNodeCssStyleDisplay, |
| | | isDanglingSpaceSensitiveNode$1 = utils$3.isDanglingSpaceSensitiveNode, |
| | | isIndentationSensitiveNode$1 = utils$3.isIndentationSensitiveNode, |
| | | isLeadingSpaceSensitiveNode$1 = utils$3.isLeadingSpaceSensitiveNode, |
| | | isTrailingSpaceSensitiveNode$1 = utils$3.isTrailingSpaceSensitiveNode, |
| | | isWhitespaceSensitiveNode$1 = utils$3.isWhitespaceSensitiveNode; |
| | | var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText]; |
| | | |
| | | function preprocess(ast, options) { |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = PREPROCESS_PIPELINE[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var fn = _step.value; |
| | | ast = fn(ast, options); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return ast; |
| | | } |
| | | |
| | | function removeIgnorableFirstLf(ast |
| | | /*, options */ |
| | | ) { |
| | | return ast.map(function (node) { |
| | | if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") { |
| | | var text = node.children[0]; |
| | | return node.clone({ |
| | | children: text.value.length === 1 ? node.children.slice(1) : [].concat(text.clone({ |
| | | value: text.value.slice(1) |
| | | }), node.children.slice(1)) |
| | | }); |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | } |
| | | |
| | | function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast |
| | | /*, options */ |
| | | ) { |
| | | /** |
| | | * <!--[if ...]><!--><target><!--<![endif]--> |
| | | */ |
| | | var isTarget = function isTarget(node) { |
| | | return node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset; |
| | | }; |
| | | |
| | | return ast.map(function (node) { |
| | | if (node.children) { |
| | | var isTargetResults = node.children.map(isTarget); |
| | | |
| | | if (isTargetResults.some(Boolean)) { |
| | | var newChildren = []; |
| | | |
| | | for (var i = 0; i < node.children.length; i++) { |
| | | var child = node.children[i]; |
| | | |
| | | if (isTargetResults[i + 1]) { |
| | | // ieConditionalStartComment |
| | | continue; |
| | | } |
| | | |
| | | if (isTargetResults[i]) { |
| | | var ieConditionalStartComment = child.prev; |
| | | var ieConditionalEndComment = child.firstChild; |
| | | var ParseSourceSpan = child.sourceSpan.constructor; |
| | | var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end); |
| | | var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end); |
| | | newChildren.push(child.clone({ |
| | | condition: ieConditionalStartComment.condition, |
| | | sourceSpan: sourceSpan, |
| | | startSourceSpan: startSourceSpan, |
| | | children: child.children.slice(1) |
| | | })); |
| | | continue; |
| | | } |
| | | |
| | | newChildren.push(child); |
| | | } |
| | | |
| | | return node.clone({ |
| | | children: newChildren |
| | | }); |
| | | } |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | } |
| | | |
| | | function mergeNodeIntoText(ast, shouldMerge, getValue) { |
| | | return ast.map(function (node) { |
| | | if (node.children) { |
| | | var shouldMergeResults = node.children.map(shouldMerge); |
| | | |
| | | if (shouldMergeResults.some(Boolean)) { |
| | | var newChildren = []; |
| | | |
| | | for (var i = 0; i < node.children.length; i++) { |
| | | var child = node.children[i]; |
| | | |
| | | if (child.type !== "text" && !shouldMergeResults[i]) { |
| | | newChildren.push(child); |
| | | continue; |
| | | } |
| | | |
| | | var newChild = child.type === "text" ? child : child.clone({ |
| | | type: "text", |
| | | value: getValue(child) |
| | | }); |
| | | |
| | | if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") { |
| | | newChildren.push(newChild); |
| | | continue; |
| | | } |
| | | |
| | | var lastChild = newChildren.pop(); |
| | | var ParseSourceSpan = lastChild.sourceSpan.constructor; |
| | | newChildren.push(lastChild.clone({ |
| | | value: lastChild.value + newChild.value, |
| | | sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end) |
| | | })); |
| | | } |
| | | |
| | | return node.clone({ |
| | | children: newChildren |
| | | }); |
| | | } |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | } |
| | | |
| | | function mergeCdataIntoText(ast |
| | | /*, options */ |
| | | ) { |
| | | return mergeNodeIntoText(ast, function (node) { |
| | | return node.type === "cdata"; |
| | | }, function (node) { |
| | | return "<![CDATA[".concat(node.value, "]]>"); |
| | | }); |
| | | } |
| | | |
| | | function mergeSimpleElementIntoText(ast |
| | | /*, options */ |
| | | ) { |
| | | var isSimpleElement = function isSimpleElement(node) { |
| | | return node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && // \xA0: non-breaking whitespace |
| | | !/[^\S\xA0]/.test(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text"; |
| | | }; |
| | | |
| | | return ast.map(function (node) { |
| | | if (node.children) { |
| | | var isSimpleElementResults = node.children.map(isSimpleElement); |
| | | |
| | | if (isSimpleElementResults.some(Boolean)) { |
| | | var newChildren = []; |
| | | |
| | | for (var i = 0; i < node.children.length; i++) { |
| | | var child = node.children[i]; |
| | | |
| | | if (isSimpleElementResults[i]) { |
| | | var lastChild = newChildren.pop(); |
| | | var nextChild = node.children[++i]; |
| | | var ParseSourceSpan = node.sourceSpan.constructor; |
| | | var isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive, |
| | | hasTrailingSpaces = nextChild.hasTrailingSpaces; |
| | | newChildren.push(lastChild.clone({ |
| | | value: lastChild.value + "<".concat(child.rawName, ">") + child.firstChild.value + "</".concat(child.rawName, ">") + nextChild.value, |
| | | sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end), |
| | | isTrailingSpaceSensitive: isTrailingSpaceSensitive, |
| | | hasTrailingSpaces: hasTrailingSpaces |
| | | })); |
| | | } else { |
| | | newChildren.push(child); |
| | | } |
| | | } |
| | | |
| | | return node.clone({ |
| | | children: newChildren |
| | | }); |
| | | } |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | } |
| | | |
| | | function extractInterpolation(ast, options) { |
| | | if (options.parser === "html") { |
| | | return ast; |
| | | } |
| | | |
| | | var interpolationRegex = /\{\{([\s\S]+?)\}\}/g; |
| | | return ast.map(function (node) { |
| | | if (!canHaveInterpolation$1(node)) { |
| | | return node; |
| | | } |
| | | |
| | | var newChildren = []; |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = node.children[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var child = _step2.value; |
| | | |
| | | if (child.type !== "text") { |
| | | newChildren.push(child); |
| | | continue; |
| | | } |
| | | |
| | | var ParseSourceSpan = child.sourceSpan.constructor; |
| | | var startSourceSpan = child.sourceSpan.start; |
| | | var endSourceSpan = null; |
| | | var components = child.value.split(interpolationRegex); |
| | | |
| | | for (var i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) { |
| | | var value = components[i]; |
| | | |
| | | if (i % 2 === 0) { |
| | | endSourceSpan = startSourceSpan.moveBy(value.length); |
| | | |
| | | if (value.length !== 0) { |
| | | newChildren.push({ |
| | | type: "text", |
| | | value: value, |
| | | sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan) |
| | | }); |
| | | } |
| | | |
| | | continue; |
| | | } |
| | | |
| | | endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}` |
| | | |
| | | newChildren.push({ |
| | | type: "interpolation", |
| | | sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan), |
| | | children: value.length === 0 ? [] : [{ |
| | | type: "text", |
| | | value: value, |
| | | sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2)) |
| | | }] |
| | | }); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return node.clone({ |
| | | children: newChildren |
| | | }); |
| | | }); |
| | | } |
| | | /** |
| | | * - add `hasLeadingSpaces` field |
| | | * - add `hasTrailingSpaces` field |
| | | * - add `hasDanglingSpaces` field for parent nodes |
| | | * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes |
| | | * - remove insensitive whitespaces |
| | | */ |
| | | |
| | | |
| | | function extractWhitespaces(ast |
| | | /*, options*/ |
| | | ) { |
| | | var TYPE_WHITESPACE = "whitespace"; |
| | | return ast.map(function (node) { |
| | | if (!node.children) { |
| | | return node; |
| | | } |
| | | |
| | | if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) { |
| | | return node.clone({ |
| | | children: [], |
| | | hasDanglingSpaces: node.children.length !== 0 |
| | | }); |
| | | } |
| | | |
| | | var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node); |
| | | var isIndentationSensitive = isIndentationSensitiveNode$1(node); |
| | | return node.clone({ |
| | | isWhitespaceSensitive: isWhitespaceSensitive, |
| | | isIndentationSensitive: isIndentationSensitive, |
| | | children: node.children // extract whitespace nodes |
| | | .reduce(function (newChildren, child) { |
| | | if (child.type !== "text" || isWhitespaceSensitive) { |
| | | return newChildren.concat(child); |
| | | } |
| | | |
| | | var localChildren = []; |
| | | |
| | | var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/), |
| | | _child$value$match2 = _slicedToArray(_child$value$match, 4), |
| | | leadingSpaces = _child$value$match2[1], |
| | | text = _child$value$match2[2], |
| | | trailingSpaces = _child$value$match2[3]; |
| | | |
| | | if (leadingSpaces) { |
| | | localChildren.push({ |
| | | type: TYPE_WHITESPACE |
| | | }); |
| | | } |
| | | |
| | | var ParseSourceSpan = child.sourceSpan.constructor; |
| | | |
| | | if (text) { |
| | | localChildren.push({ |
| | | type: "text", |
| | | value: text, |
| | | sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length)) |
| | | }); |
| | | } |
| | | |
| | | if (trailingSpaces) { |
| | | localChildren.push({ |
| | | type: TYPE_WHITESPACE |
| | | }); |
| | | } |
| | | |
| | | return newChildren.concat(localChildren); |
| | | }, []) // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes |
| | | .reduce(function (newChildren, child, i, children) { |
| | | if (child.type === TYPE_WHITESPACE) { |
| | | return newChildren; |
| | | } |
| | | |
| | | var hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE; |
| | | var hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE; |
| | | return newChildren.concat(Object.assign({}, child, { |
| | | hasLeadingSpaces: hasLeadingSpaces, |
| | | hasTrailingSpaces: hasTrailingSpaces |
| | | })); |
| | | }, []) |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function addIsSelfClosing(ast |
| | | /*, options */ |
| | | ) { |
| | | return ast.map(function (node) { |
| | | return Object.assign(node, { |
| | | isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing |
| | | node.startSourceSpan === node.endSourceSpan) |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function addHasHtmComponentClosingTag(ast, options) { |
| | | return ast.map(function (node) { |
| | | return node.type !== "element" ? node : Object.assign(node, { |
| | | hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset)) |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function addCssDisplay(ast, options) { |
| | | return ast.map(function (node) { |
| | | return Object.assign(node, { |
| | | cssDisplay: getNodeCssStyleDisplay$1(node, options) |
| | | }); |
| | | }); |
| | | } |
| | | /** |
| | | * - add `isLeadingSpaceSensitive` field |
| | | * - add `isTrailingSpaceSensitive` field |
| | | * - add `isDanglingSpaceSensitive` field for parent nodes |
| | | */ |
| | | |
| | | |
| | | function addIsSpaceSensitive(ast |
| | | /*, options */ |
| | | ) { |
| | | return ast.map(function (node) { |
| | | if (!node.children) { |
| | | return node; |
| | | } |
| | | |
| | | if (node.children.length === 0) { |
| | | return node.clone({ |
| | | isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node) |
| | | }); |
| | | } |
| | | |
| | | return node.clone({ |
| | | children: node.children.map(function (child) { |
| | | return Object.assign({}, child, { |
| | | isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child), |
| | | isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child) |
| | | }); |
| | | }).map(function (child, index, children) { |
| | | return Object.assign({}, child, { |
| | | isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive, |
| | | isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive |
| | | }); |
| | | }) |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | var preprocess_1 = preprocess; |
| | | |
| | | function hasPragma$3(text) { |
| | | return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text); |
| | | } |
| | | |
| | | function insertPragma$5(text) { |
| | | return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, ""); |
| | | } |
| | | |
| | | var pragma$3 = { |
| | | hasPragma: hasPragma$3, |
| | | insertPragma: insertPragma$5 |
| | | }; |
| | | |
| | | var _require$$0$builders$4 = doc.builders, |
| | | concat$8 = _require$$0$builders$4.concat, |
| | | group$8 = _require$$0$builders$4.group; |
| | | /** |
| | | * v-for="... in ..." |
| | | * v-for="... of ..." |
| | | * v-for="(..., ...) in ..." |
| | | * v-for="(..., ...) of ..." |
| | | */ |
| | | |
| | | function printVueFor(value, textToDoc) { |
| | | var _parseVueFor = parseVueFor(value), |
| | | left = _parseVueFor.left, |
| | | operator = _parseVueFor.operator, |
| | | right = _parseVueFor.right; |
| | | |
| | | return concat$8([group$8(textToDoc("function _(".concat(left, ") {}"), { |
| | | parser: "babel", |
| | | __isVueForBindingLeft: true |
| | | })), " ", operator, " ", textToDoc(right, { |
| | | parser: "__js_expression" |
| | | })]); |
| | | } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387 |
| | | |
| | | |
| | | function parseVueFor(value) { |
| | | var forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/; |
| | | var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/; |
| | | var stripParensRE = /^\(|\)$/g; |
| | | var inMatch = value.match(forAliasRE); |
| | | |
| | | if (!inMatch) { |
| | | return; |
| | | } |
| | | |
| | | var res = {}; |
| | | res.for = inMatch[3].trim(); |
| | | var alias = inMatch[1].trim().replace(stripParensRE, ""); |
| | | var iteratorMatch = alias.match(forIteratorRE); |
| | | |
| | | if (iteratorMatch) { |
| | | res.alias = alias.replace(forIteratorRE, ""); |
| | | res.iterator1 = iteratorMatch[1].trim(); |
| | | |
| | | if (iteratorMatch[2]) { |
| | | res.iterator2 = iteratorMatch[2].trim(); |
| | | } |
| | | } else { |
| | | res.alias = alias; |
| | | } |
| | | |
| | | return { |
| | | left: "".concat([res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")), |
| | | operator: inMatch[2], |
| | | right: res.for |
| | | }; |
| | | } |
| | | |
| | | function printVueSlotScope(value, textToDoc) { |
| | | return textToDoc("function _(".concat(value, ") {}"), { |
| | | parser: "babel", |
| | | __isVueSlotScope: true |
| | | }); |
| | | } |
| | | |
| | | function isVueEventBindingExpression(eventBindingValue) { |
| | | // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4 |
| | | // arrow function or anonymous function |
| | | var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b]) |
| | | |
| | | var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104 |
| | | |
| | | var value = eventBindingValue.trim(); |
| | | return fnExpRE.test(value) || simplePathRE.test(value); |
| | | } |
| | | |
| | | var syntaxVue = { |
| | | isVueEventBindingExpression: isVueEventBindingExpression, |
| | | printVueFor: printVueFor, |
| | | printVueSlotScope: printVueSlotScope |
| | | }; |
| | | |
| | | var parseSrcset = createCommonjsModule(function (module) { |
| | | /** |
| | | * Srcset Parser |
| | | * |
| | | * By Alex Bell | MIT License |
| | | * |
| | | * JS Parser for the string value that appears in markup <img srcset="here"> |
| | | * |
| | | * @returns Array [{url: _, d: _, w: _, h:_}, ...] |
| | | * |
| | | * Based super duper closely on the reference algorithm at: |
| | | * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute |
| | | * |
| | | * Most comments are copied in directly from the spec |
| | | * (except for comments in parens). |
| | | */ |
| | | (function (root, factory) { |
| | | if ( module.exports) { |
| | | // Node. Does not work with strict CommonJS, but |
| | | // only CommonJS-like environments that support module.exports, |
| | | // like Node. |
| | | module.exports = factory(); |
| | | } else { |
| | | // Browser globals (root is window) |
| | | root.parseSrcset = factory(); |
| | | } |
| | | })(commonjsGlobal, function () { |
| | | // 1. Let input be the value passed to this algorithm. |
| | | return function (input, options) { |
| | | var logger = options && options.logger || console; // UTILITY FUNCTIONS |
| | | // Manual is faster than RegEx |
| | | // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript |
| | | // http://jsperf.com/whitespace-character/5 |
| | | |
| | | function isSpace(c) { |
| | | return c === " " || // space |
| | | c === "\t" || // horizontal tab |
| | | c === "\n" || // new line |
| | | c === "\f" || // form feed |
| | | c === "\r"; // carriage return |
| | | } |
| | | |
| | | function collectCharacters(regEx) { |
| | | var chars, |
| | | match = regEx.exec(input.substring(pos)); |
| | | |
| | | if (match) { |
| | | chars = match[0]; |
| | | pos += chars.length; |
| | | return chars; |
| | | } |
| | | } |
| | | |
| | | var inputLength = input.length, |
| | | // (Don't use \s, to avoid matching non-breaking space) |
| | | regexLeadingSpaces = /^[ \t\n\r\u000c]+/, |
| | | regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/, |
| | | regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/, |
| | | regexTrailingCommas = /[,]+$/, |
| | | regexNonNegativeInteger = /^\d+$/, |
| | | // ( Positive or negative or unsigned integers or decimals, without or without exponents. |
| | | // Must include at least one digit. |
| | | // According to spec tests any decimal point must be followed by a digit. |
| | | // No leading plus sign is allowed.) |
| | | // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number |
| | | regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/, |
| | | url, |
| | | descriptors, |
| | | currentDescriptor, |
| | | state, |
| | | c, |
| | | // 2. Let position be a pointer into input, initially pointing at the start |
| | | // of the string. |
| | | pos = 0, |
| | | // 3. Let candidates be an initially empty source set. |
| | | candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space |
| | | // characters or U+002C COMMA characters. If any U+002C COMMA characters |
| | | // were collected, that is a parse error. |
| | | |
| | | while (true) { |
| | | collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps. |
| | | |
| | | if (pos >= inputLength) { |
| | | return candidates; // (we're done, this is the sole return path) |
| | | } // 6. Collect a sequence of characters that are not space characters, |
| | | // and let that be url. |
| | | |
| | | |
| | | url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list. |
| | | |
| | | descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps: |
| | | // (1). Remove all trailing U+002C COMMA characters from url. If this removed |
| | | // more than one character, that is a parse error. |
| | | |
| | | if (url.slice(-1) === ",") { |
| | | url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate). |
| | | |
| | | parseDescriptors(); // Otherwise, follow these substeps: |
| | | } else { |
| | | tokenize(); |
| | | } // (close else of step 8) |
| | | // 16. Return to the step labeled splitting loop. |
| | | |
| | | } // (Close of big while loop.) |
| | | |
| | | /** |
| | | * Tokenizes descriptor properties prior to parsing |
| | | * Returns undefined. |
| | | */ |
| | | |
| | | |
| | | function tokenize() { |
| | | // 8.1. Descriptor tokeniser: Skip whitespace |
| | | collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string. |
| | | |
| | | currentDescriptor = ""; // 8.3. Let state be in descriptor. |
| | | |
| | | state = "in descriptor"; |
| | | |
| | | while (true) { |
| | | // 8.4. Let c be the character at position. |
| | | c = input.charAt(pos); // Do the following depending on the value of state. |
| | | // For the purpose of this step, "EOF" is a special character representing |
| | | // that position is past the end of input. |
| | | // In descriptor |
| | | |
| | | if (state === "in descriptor") { |
| | | // Do the following, depending on the value of c: |
| | | // Space character |
| | | // If current descriptor is not empty, append current descriptor to |
| | | // descriptors and let current descriptor be the empty string. |
| | | // Set state to after descriptor. |
| | | if (isSpace(c)) { |
| | | if (currentDescriptor) { |
| | | descriptors.push(currentDescriptor); |
| | | currentDescriptor = ""; |
| | | state = "after descriptor"; |
| | | } // U+002C COMMA (,) |
| | | // Advance position to the next character in input. If current descriptor |
| | | // is not empty, append current descriptor to descriptors. Jump to the step |
| | | // labeled descriptor parser. |
| | | |
| | | } else if (c === ",") { |
| | | pos += 1; |
| | | |
| | | if (currentDescriptor) { |
| | | descriptors.push(currentDescriptor); |
| | | } |
| | | |
| | | parseDescriptors(); |
| | | return; // U+0028 LEFT PARENTHESIS (() |
| | | // Append c to current descriptor. Set state to in parens. |
| | | } else if (c === "(") { |
| | | currentDescriptor = currentDescriptor + c; |
| | | state = "in parens"; // EOF |
| | | // If current descriptor is not empty, append current descriptor to |
| | | // descriptors. Jump to the step labeled descriptor parser. |
| | | } else if (c === "") { |
| | | if (currentDescriptor) { |
| | | descriptors.push(currentDescriptor); |
| | | } |
| | | |
| | | parseDescriptors(); |
| | | return; // Anything else |
| | | // Append c to current descriptor. |
| | | } else { |
| | | currentDescriptor = currentDescriptor + c; |
| | | } // (end "in descriptor" |
| | | // In parens |
| | | |
| | | } else if (state === "in parens") { |
| | | // U+0029 RIGHT PARENTHESIS ()) |
| | | // Append c to current descriptor. Set state to in descriptor. |
| | | if (c === ")") { |
| | | currentDescriptor = currentDescriptor + c; |
| | | state = "in descriptor"; // EOF |
| | | // Append current descriptor to descriptors. Jump to the step labeled |
| | | // descriptor parser. |
| | | } else if (c === "") { |
| | | descriptors.push(currentDescriptor); |
| | | parseDescriptors(); |
| | | return; // Anything else |
| | | // Append c to current descriptor. |
| | | } else { |
| | | currentDescriptor = currentDescriptor + c; |
| | | } // After descriptor |
| | | |
| | | } else if (state === "after descriptor") { |
| | | // Do the following, depending on the value of c: |
| | | // Space character: Stay in this state. |
| | | if (isSpace(c)) ; else if (c === "") { |
| | | parseDescriptors(); |
| | | return; // Anything else |
| | | // Set state to in descriptor. Set position to the previous character in input. |
| | | } else { |
| | | state = "in descriptor"; |
| | | pos -= 1; |
| | | } |
| | | } // Advance position to the next character in input. |
| | | |
| | | |
| | | pos += 1; // Repeat this step. |
| | | } // (close while true loop) |
| | | |
| | | } |
| | | /** |
| | | * Adds descriptor properties to a candidate, pushes to the candidates array |
| | | * @return undefined |
| | | */ |
| | | // Declared outside of the while loop so that it's only created once. |
| | | |
| | | |
| | | function parseDescriptors() { |
| | | // 9. Descriptor parser: Let error be no. |
| | | var pError = false, |
| | | // 10. Let width be absent. |
| | | // 11. Let density be absent. |
| | | // 12. Let future-compat-h be absent. (We're implementing it now as h) |
| | | w, |
| | | d, |
| | | h, |
| | | i, |
| | | candidate = {}, |
| | | desc, |
| | | lastChar, |
| | | value, |
| | | intVal, |
| | | floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps |
| | | // from the following list: |
| | | |
| | | for (i = 0; i < descriptors.length; i++) { |
| | | desc = descriptors[i]; |
| | | lastChar = desc[desc.length - 1]; |
| | | value = desc.substring(0, desc.length - 1); |
| | | intVal = parseInt(value, 10); |
| | | floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by |
| | | // a U+0077 LATIN SMALL LETTER W character |
| | | |
| | | if (regexNonNegativeInteger.test(value) && lastChar === "w") { |
| | | // If width and density are not both absent, then let error be yes. |
| | | if (w || d) { |
| | | pError = true; |
| | | } // Apply the rules for parsing non-negative integers to the descriptor. |
| | | // If the result is zero, let error be yes. |
| | | // Otherwise, let width be the result. |
| | | |
| | | |
| | | if (intVal === 0) { |
| | | pError = true; |
| | | } else { |
| | | w = intVal; |
| | | } // If the descriptor consists of a valid floating-point number followed by |
| | | // a U+0078 LATIN SMALL LETTER X character |
| | | |
| | | } else if (regexFloatingPoint.test(value) && lastChar === "x") { |
| | | // If width, density and future-compat-h are not all absent, then let error |
| | | // be yes. |
| | | if (w || d || h) { |
| | | pError = true; |
| | | } // Apply the rules for parsing floating-point number values to the descriptor. |
| | | // If the result is less than zero, let error be yes. Otherwise, let density |
| | | // be the result. |
| | | |
| | | |
| | | if (floatVal < 0) { |
| | | pError = true; |
| | | } else { |
| | | d = floatVal; |
| | | } // If the descriptor consists of a valid non-negative integer followed by |
| | | // a U+0068 LATIN SMALL LETTER H character |
| | | |
| | | } else if (regexNonNegativeInteger.test(value) && lastChar === "h") { |
| | | // If height and density are not both absent, then let error be yes. |
| | | if (h || d) { |
| | | pError = true; |
| | | } // Apply the rules for parsing non-negative integers to the descriptor. |
| | | // If the result is zero, let error be yes. Otherwise, let future-compat-h |
| | | // be the result. |
| | | |
| | | |
| | | if (intVal === 0) { |
| | | pError = true; |
| | | } else { |
| | | h = intVal; |
| | | } // Anything else, Let error be yes. |
| | | |
| | | } else { |
| | | pError = true; |
| | | } |
| | | } // (close step 13 for loop) |
| | | // 15. If error is still no, then append a new image source to candidates whose |
| | | // URL is url, associated with a width width if not absent and a pixel |
| | | // density density if not absent. Otherwise, there is a parse error. |
| | | |
| | | |
| | | if (!pError) { |
| | | candidate.url = url; |
| | | |
| | | if (w) { |
| | | candidate.w = w; |
| | | } |
| | | |
| | | if (d) { |
| | | candidate.d = d; |
| | | } |
| | | |
| | | if (h) { |
| | | candidate.h = h; |
| | | } |
| | | |
| | | candidates.push(candidate); |
| | | } else if (logger && logger.error) { |
| | | logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'."); |
| | | } |
| | | } // (close parseDescriptors fn) |
| | | |
| | | }; |
| | | }); |
| | | }); |
| | | |
| | | var _require$$0$builders$5 = doc.builders, |
| | | concat$9 = _require$$0$builders$5.concat, |
| | | ifBreak$4 = _require$$0$builders$5.ifBreak, |
| | | join$5 = _require$$0$builders$5.join, |
| | | line$4 = _require$$0$builders$5.line; |
| | | |
| | | function printImgSrcset(value) { |
| | | var srcset = parseSrcset(value, { |
| | | logger: { |
| | | error: function error(message) { |
| | | throw new Error(message); |
| | | } |
| | | } |
| | | }); |
| | | var hasW = srcset.some(function (src) { |
| | | return src.w; |
| | | }); |
| | | var hasH = srcset.some(function (src) { |
| | | return src.h; |
| | | }); |
| | | var hasX = srcset.some(function (src) { |
| | | return src.d; |
| | | }); |
| | | |
| | | if (hasW + hasH + hasX !== 1) { |
| | | throw new Error("Mixed descriptor in srcset is not supported"); |
| | | } |
| | | |
| | | var key = hasW ? "w" : hasH ? "h" : "d"; |
| | | var unit = hasW ? "w" : hasH ? "h" : "x"; |
| | | |
| | | var getMax = function getMax(values) { |
| | | return Math.max.apply(Math, values); |
| | | }; |
| | | |
| | | var urls = srcset.map(function (src) { |
| | | return src.url; |
| | | }); |
| | | var maxUrlLength = getMax(urls.map(function (url) { |
| | | return url.length; |
| | | })); |
| | | var descriptors = srcset.map(function (src) { |
| | | return src[key]; |
| | | }).map(function (descriptor) { |
| | | return descriptor ? descriptor.toString() : ""; |
| | | }); |
| | | var descriptorLeftLengths = descriptors.map(function (descriptor) { |
| | | var index = descriptor.indexOf("."); |
| | | return index === -1 ? descriptor.length : index; |
| | | }); |
| | | var maxDescriptorLeftLength = getMax(descriptorLeftLengths); |
| | | return join$5(concat$9([",", line$4]), urls.map(function (url, index) { |
| | | var parts = [url]; |
| | | var descriptor = descriptors[index]; |
| | | |
| | | if (descriptor) { |
| | | var urlPadding = maxUrlLength - url.length + 1; |
| | | var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index]; |
| | | var alignment = " ".repeat(urlPadding + descriptorPadding); |
| | | parts.push(ifBreak$4(alignment, " "), descriptor + unit); |
| | | } |
| | | |
| | | return concat$9(parts); |
| | | })); |
| | | } |
| | | |
| | | var syntaxAttribute = { |
| | | printImgSrcset: printImgSrcset |
| | | }; |
| | | |
| | | var builders = doc.builders, |
| | | _require$$0$utils = doc.utils, |
| | | stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline, |
| | | mapDoc$4 = _require$$0$utils.mapDoc; |
| | | var breakParent$2 = builders.breakParent, |
| | | dedentToRoot$1 = builders.dedentToRoot, |
| | | fill$3 = builders.fill, |
| | | group$9 = builders.group, |
| | | hardline$7 = builders.hardline, |
| | | ifBreak$5 = builders.ifBreak, |
| | | indent$5 = builders.indent, |
| | | join$6 = builders.join, |
| | | line$5 = builders.line, |
| | | literalline$2 = builders.literalline, |
| | | markAsRoot$2 = builders.markAsRoot, |
| | | softline$4 = builders.softline; |
| | | var countChars$1 = utils$3.countChars, |
| | | countParents$1 = utils$3.countParents, |
| | | dedentString$1 = utils$3.dedentString, |
| | | forceBreakChildren$1 = utils$3.forceBreakChildren, |
| | | forceBreakContent$1 = utils$3.forceBreakContent, |
| | | forceNextEmptyLine$1 = utils$3.forceNextEmptyLine, |
| | | getLastDescendant$1 = utils$3.getLastDescendant, |
| | | getPrettierIgnoreAttributeCommentData$1 = utils$3.getPrettierIgnoreAttributeCommentData, |
| | | hasPrettierIgnore$1 = utils$3.hasPrettierIgnore, |
| | | inferScriptParser$1 = utils$3.inferScriptParser, |
| | | isScriptLikeTag$1 = utils$3.isScriptLikeTag, |
| | | isTextLikeNode$1 = utils$3.isTextLikeNode, |
| | | normalizeParts$1 = utils$3.normalizeParts, |
| | | preferHardlineAsLeadingSpaces$1 = utils$3.preferHardlineAsLeadingSpaces, |
| | | shouldNotPrintClosingTag$1 = utils$3.shouldNotPrintClosingTag, |
| | | shouldPreserveContent$1 = utils$3.shouldPreserveContent, |
| | | unescapeQuoteEntities$1 = utils$3.unescapeQuoteEntities; |
| | | var replaceEndOfLineWith$1 = util.replaceEndOfLineWith; |
| | | var insertPragma$6 = pragma$3.insertPragma; |
| | | var printVueFor$1 = syntaxVue.printVueFor, |
| | | printVueSlotScope$1 = syntaxVue.printVueSlotScope, |
| | | isVueEventBindingExpression$1 = syntaxVue.isVueEventBindingExpression; |
| | | var printImgSrcset$1 = syntaxAttribute.printImgSrcset; |
| | | |
| | | function concat$a(parts) { |
| | | var newParts = normalizeParts$1(parts); |
| | | return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts); |
| | | } |
| | | |
| | | function embed$2(path, print, textToDoc, options) { |
| | | var node = path.getValue(); |
| | | |
| | | switch (node.type) { |
| | | case "text": |
| | | { |
| | | if (isScriptLikeTag$1(node.parent)) { |
| | | var parser = inferScriptParser$1(node.parent); |
| | | |
| | | if (parser) { |
| | | var value = parser === "markdown" ? dedentString$1(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value; |
| | | return builders.concat([concat$a([breakParent$2, printOpeningTagPrefix(node, options), stripTrailingHardline$1(textToDoc(value, { |
| | | parser: parser |
| | | })), printClosingTagSuffix(node, options)])]); |
| | | } |
| | | } else if (node.parent.type === "interpolation") { |
| | | return concat$a([indent$5(concat$a([line$5, textToDoc(node.value, Object.assign({ |
| | | __isInHtmlInterpolation: true // to avoid unexpected `}}` |
| | | |
| | | }, options.parser === "angular" ? { |
| | | parser: "__ng_interpolation", |
| | | trailingComma: "none" |
| | | } : options.parser === "vue" ? { |
| | | parser: "__vue_expression" |
| | | } : { |
| | | parser: "__js_expression" |
| | | }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$5]); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "attribute": |
| | | { |
| | | if (!node.value) { |
| | | break; |
| | | } // lit-html: html`<my-element obj=${obj}></my-element>` |
| | | |
| | | |
| | | if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) { |
| | | return concat$a([node.rawName, "=", node.value]); |
| | | } // lwc: html`<my-element data-for={value}></my-element>` |
| | | |
| | | |
| | | if (options.parser === "lwc") { |
| | | var interpolationRegex = /^\{[\s\S]*\}$/; |
| | | |
| | | if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) { |
| | | return concat$a([node.rawName, "=", node.value]); |
| | | } |
| | | } |
| | | |
| | | var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) { |
| | | return (// strictly prefer single quote to avoid unnecessary html entity escape |
| | | textToDoc(code, Object.assign({ |
| | | __isInHtmlAttribute: true |
| | | }, opts)) |
| | | ); |
| | | }, options); |
| | | |
| | | if (embeddedAttributeValueDoc) { |
| | | return concat$a([node.rawName, '="', group$9(mapDoc$4(embeddedAttributeValueDoc, function (doc) { |
| | | return typeof doc === "string" ? doc.replace(/"/g, """) : doc; |
| | | })), '"']); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "yaml": |
| | | return markAsRoot$2(concat$a(["---", hardline$7, node.value.trim().length === 0 ? "" : textToDoc(node.value, { |
| | | parser: "yaml" |
| | | }), "---"])); |
| | | } |
| | | } |
| | | |
| | | function genericPrint$2(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | switch (node.type) { |
| | | case "root": |
| | | // use original concat to not break stripTrailingHardline |
| | | return builders.concat([group$9(printChildren$1(path, options, print)), hardline$7]); |
| | | |
| | | case "element": |
| | | case "ieConditionalComment": |
| | | { |
| | | /** |
| | | * do not break: |
| | | * |
| | | * <div>{{ |
| | | * ~ |
| | | * interpolation |
| | | * }}</div> |
| | | * ~ |
| | | * |
| | | * exception: break if the opening tag breaks |
| | | * |
| | | * <div |
| | | * long |
| | | * ~ |
| | | * >{{ |
| | | * interpolation |
| | | * }}</div |
| | | * ~ |
| | | * > |
| | | */ |
| | | var shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces; |
| | | var attrGroupId = Symbol("element-attr-group-id"); |
| | | return concat$a([group$9(concat$a([group$9(printOpeningTag(path, options, print), { |
| | | id: attrGroupId |
| | | }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$5 : "" : concat$a([forceBreakContent$1(node) ? breakParent$2 : "", function (childrenDoc) { |
| | | return shouldHugContent ? ifBreak$5(indent$5(childrenDoc), childrenDoc, { |
| | | groupId: attrGroupId |
| | | }) : isScriptLikeTag$1(node) && node.parent.type === "root" && options.parser === "vue" && !options.vueIndentScriptAndStyle ? childrenDoc : indent$5(childrenDoc); |
| | | }(concat$a([shouldHugContent ? ifBreak$5(softline$4, "", { |
| | | groupId: attrGroupId |
| | | }) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$5 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$1(softline$4) : softline$4, printChildren$1(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$5(softline$4, "", { |
| | | groupId: attrGroupId |
| | | }) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$5 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp("\\n\\s{".concat(options.tabWidth * countParents$1(path, function (n) { |
| | | return n.parent && n.parent.type !== "root"; |
| | | }), "}$")).test(node.lastChild.value) ? |
| | | /** |
| | | * <div> |
| | | * <pre> |
| | | * something |
| | | * </pre> |
| | | * ~ |
| | | * </div> |
| | | */ |
| | | "" : softline$4])])), printClosingTag(node, options)]); |
| | | } |
| | | |
| | | case "ieConditionalStartComment": |
| | | case "ieConditionalEndComment": |
| | | return concat$a([printOpeningTagStart(node), printClosingTagEnd(node)]); |
| | | |
| | | case "interpolation": |
| | | return concat$a([printOpeningTagStart(node, options), concat$a(path.map(print, "children")), printClosingTagEnd(node, options)]); |
| | | |
| | | case "text": |
| | | { |
| | | if (node.parent.type === "interpolation") { |
| | | // replace the trailing literalline with hardline for better readability |
| | | var trailingNewlineRegex = /\n[^\S\n]*?$/; |
| | | var hasTrailingNewline = trailingNewlineRegex.test(node.value); |
| | | var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value; |
| | | return concat$a([concat$a(replaceEndOfLineWith$1(value, literalline$2)), hasTrailingNewline ? hardline$7 : ""]); |
| | | } |
| | | |
| | | return fill$3(normalizeParts$1([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options)))); |
| | | } |
| | | |
| | | case "docType": |
| | | return concat$a([group$9(concat$a([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]); |
| | | |
| | | case "comment": |
| | | { |
| | | return concat$a([printOpeningTagPrefix(node, options), concat$a(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$2)), printClosingTagSuffix(node, options)]); |
| | | } |
| | | |
| | | case "attribute": |
| | | { |
| | | if (node.value === null) { |
| | | return node.rawName; |
| | | } |
| | | |
| | | var _value = unescapeQuoteEntities$1(node.value); |
| | | |
| | | var singleQuoteCount = countChars$1(_value, "'"); |
| | | var doubleQuoteCount = countChars$1(_value, '"'); |
| | | var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"'; |
| | | return concat$a([node.rawName, concat$a(["=", quote, concat$a(replaceEndOfLineWith$1(quote === '"' ? _value.replace(/"/g, """) : _value.replace(/'/g, "'"), literalline$2)), quote])]); |
| | | } |
| | | |
| | | case "yaml": |
| | | case "toml": |
| | | return concat$a(replaceEndOfLineWith$1(node.raw, literalline$2)); |
| | | |
| | | default: |
| | | throw new Error("Unexpected node type ".concat(node.type)); |
| | | } |
| | | } |
| | | |
| | | function printChildren$1(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | if (forceBreakChildren$1(node)) { |
| | | return concat$a([breakParent$2, concat$a(path.map(function (childPath) { |
| | | var childNode = childPath.getValue(); |
| | | var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode); |
| | | return concat$a([!prevBetweenLine ? "" : concat$a([prevBetweenLine, forceNextEmptyLine$1(childNode.prev) ? hardline$7 : ""]), printChild(childPath)]); |
| | | }, "children"))]); |
| | | } |
| | | |
| | | var groupIds = node.children.map(function () { |
| | | return Symbol(""); |
| | | }); |
| | | return concat$a(path.map(function (childPath, childIndex) { |
| | | var childNode = childPath.getValue(); |
| | | |
| | | if (isTextLikeNode$1(childNode)) { |
| | | if (childNode.prev && isTextLikeNode$1(childNode.prev)) { |
| | | var _prevBetweenLine = printBetweenLine(childNode.prev, childNode); |
| | | |
| | | if (_prevBetweenLine) { |
| | | if (forceNextEmptyLine$1(childNode.prev)) { |
| | | return concat$a([hardline$7, hardline$7, printChild(childPath)]); |
| | | } |
| | | |
| | | return concat$a([_prevBetweenLine, printChild(childPath)]); |
| | | } |
| | | } |
| | | |
| | | return printChild(childPath); |
| | | } |
| | | |
| | | var prevParts = []; |
| | | var leadingParts = []; |
| | | var trailingParts = []; |
| | | var nextParts = []; |
| | | var prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : ""; |
| | | var nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : ""; |
| | | |
| | | if (prevBetweenLine) { |
| | | if (forceNextEmptyLine$1(childNode.prev)) { |
| | | prevParts.push(hardline$7, hardline$7); |
| | | } else if (prevBetweenLine === hardline$7) { |
| | | prevParts.push(hardline$7); |
| | | } else { |
| | | if (isTextLikeNode$1(childNode.prev)) { |
| | | leadingParts.push(prevBetweenLine); |
| | | } else { |
| | | leadingParts.push(ifBreak$5("", softline$4, { |
| | | groupId: groupIds[childIndex - 1] |
| | | })); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nextBetweenLine) { |
| | | if (forceNextEmptyLine$1(childNode)) { |
| | | if (isTextLikeNode$1(childNode.next)) { |
| | | nextParts.push(hardline$7, hardline$7); |
| | | } |
| | | } else if (nextBetweenLine === hardline$7) { |
| | | if (isTextLikeNode$1(childNode.next)) { |
| | | nextParts.push(hardline$7); |
| | | } |
| | | } else { |
| | | trailingParts.push(nextBetweenLine); |
| | | } |
| | | } |
| | | |
| | | return concat$a([].concat(prevParts, group$9(concat$a([concat$a(leadingParts), group$9(concat$a([printChild(childPath), concat$a(trailingParts)]), { |
| | | id: groupIds[childIndex] |
| | | })])), nextParts)); |
| | | }, "children")); |
| | | |
| | | function printChild(childPath) { |
| | | var child = childPath.getValue(); |
| | | |
| | | if (hasPrettierIgnore$1(child)) { |
| | | return concat$a([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$1(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$2), printClosingTagSuffix(child, options))); |
| | | } |
| | | |
| | | if (shouldPreserveContent$1(child, options)) { |
| | | return concat$a([].concat(printOpeningTagPrefix(child, options), group$9(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$1(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$2), printClosingTag(child, options), printClosingTagSuffix(child, options))); |
| | | } |
| | | |
| | | return print(childPath); |
| | | } |
| | | |
| | | function printBetweenLine(prevNode, nextNode) { |
| | | return isTextLikeNode$1(prevNode) && isTextLikeNode$1(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces$1(nextNode) ? hardline$7 : line$5 : "" : preferHardlineAsLeadingSpaces$1(nextNode) ? hardline$7 : softline$4 : needsToBorrowNextOpeningTagStartMarker(prevNode) && ( |
| | | /** |
| | | * 123<a |
| | | * ~ |
| | | * ><b> |
| | | */ |
| | | nextNode.firstChild || |
| | | /** |
| | | * 123<!-- |
| | | * ~ |
| | | * --> |
| | | */ |
| | | nextNode.isSelfClosing || |
| | | /** |
| | | * 123<span |
| | | * ~ |
| | | * attr |
| | | */ |
| | | nextNode.type === "element" && nextNode.attrs.length !== 0) || |
| | | /** |
| | | * <img |
| | | * src="long" |
| | | * ~ |
| | | * />123 |
| | | */ |
| | | prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces$1(nextNode) || |
| | | /** |
| | | * Want to write us a letter? Use our<a |
| | | * ><b><a>mailing address</a></b></a |
| | | * ~ |
| | | * >. |
| | | */ |
| | | needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$7 : nextNode.hasLeadingSpaces ? line$5 : softline$4; |
| | | } |
| | | } |
| | | |
| | | function printOpeningTag(path, options, print) { |
| | | var node = path.getValue(); |
| | | var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0; |
| | | return concat$a([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ? |
| | | /** |
| | | * <br /> |
| | | * ^ |
| | | */ |
| | | " " : "" : concat$a([indent$5(concat$a([forceNotToBreakAttrContent ? " " : line$5, join$6(line$5, function (ignoreAttributeData) { |
| | | var hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? function () { |
| | | return ignoreAttributeData; |
| | | } : Array.isArray(ignoreAttributeData) ? function (attr) { |
| | | return ignoreAttributeData.indexOf(attr.rawName) !== -1; |
| | | } : function () { |
| | | return false; |
| | | }; |
| | | return path.map(function (attrPath) { |
| | | var attr = attrPath.getValue(); |
| | | return hasPrettierIgnoreAttribute(attr) ? concat$a(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$2)) : print(attrPath); |
| | | }, "attrs"); |
| | | }(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData$1(node.prev.value)))])), |
| | | /** |
| | | * 123<a |
| | | * attr |
| | | * ~ |
| | | * >456 |
| | | */ |
| | | node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) || |
| | | /** |
| | | * <span |
| | | * >123<meta |
| | | * ~ |
| | | * /></span> |
| | | */ |
| | | node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$5 : forceNotToBreakAttrContent ? "" : softline$4]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]); |
| | | } |
| | | |
| | | function printOpeningTagStart(node, options) { |
| | | return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$a([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]); |
| | | } |
| | | |
| | | function printOpeningTagEnd(node) { |
| | | return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node); |
| | | } |
| | | |
| | | function printClosingTag(node, options) { |
| | | return concat$a([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]); |
| | | } |
| | | |
| | | function printClosingTagStart(node, options) { |
| | | return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$a([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]); |
| | | } |
| | | |
| | | function printClosingTagEnd(node, options) { |
| | | return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$a([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]); |
| | | } |
| | | |
| | | function needsToBorrowNextOpeningTagStartMarker(node) { |
| | | /** |
| | | * 123<p |
| | | * ^^ |
| | | * > |
| | | */ |
| | | return node.next && !isTextLikeNode$1(node.next) && isTextLikeNode$1(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces; |
| | | } |
| | | |
| | | function needsToBorrowParentOpeningTagEndMarker(node) { |
| | | /** |
| | | * <p |
| | | * >123 |
| | | * ^ |
| | | * |
| | | * <p |
| | | * ><a |
| | | * ^ |
| | | */ |
| | | return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces; |
| | | } |
| | | |
| | | function needsToBorrowPrevClosingTagEndMarker(node) { |
| | | /** |
| | | * <p></p |
| | | * >123 |
| | | * ^ |
| | | * |
| | | * <p></p |
| | | * ><a |
| | | * ^ |
| | | */ |
| | | return node.prev && !isTextLikeNode$1(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces; |
| | | } |
| | | |
| | | function needsToBorrowLastChildClosingTagEndMarker(node) { |
| | | /** |
| | | * <p |
| | | * ><a></a |
| | | * ></p |
| | | * ^ |
| | | * > |
| | | */ |
| | | return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode$1(getLastDescendant$1(node.lastChild)); |
| | | } |
| | | |
| | | function needsToBorrowParentClosingTagStartMarker(node) { |
| | | /** |
| | | * <p> |
| | | * 123</p |
| | | * ^^^ |
| | | * > |
| | | * |
| | | * 123</b |
| | | * ></a |
| | | * ^^^ |
| | | * > |
| | | */ |
| | | return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode$1(getLastDescendant$1(node)); |
| | | } |
| | | |
| | | function printOpeningTagPrefix(node, options) { |
| | | return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : ""; |
| | | } |
| | | |
| | | function printClosingTagPrefix(node, options) { |
| | | return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : ""; |
| | | } |
| | | |
| | | function printClosingTagSuffix(node, options) { |
| | | return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : ""; |
| | | } |
| | | |
| | | function printOpeningTagStartMarker(node) { |
| | | switch (node.type) { |
| | | case "ieConditionalComment": |
| | | case "ieConditionalStartComment": |
| | | return "<!--[if ".concat(node.condition); |
| | | |
| | | case "ieConditionalEndComment": |
| | | return "<!--<!"; |
| | | |
| | | case "interpolation": |
| | | return "{{"; |
| | | |
| | | case "docType": |
| | | return "<!DOCTYPE"; |
| | | |
| | | case "element": |
| | | if (node.condition) { |
| | | return "<!--[if ".concat(node.condition, "]><!--><").concat(node.rawName); |
| | | } |
| | | |
| | | // fall through |
| | | |
| | | default: |
| | | return "<".concat(node.rawName); |
| | | } |
| | | } |
| | | |
| | | function printOpeningTagEndMarker(node) { |
| | | assert(!node.isSelfClosing); |
| | | |
| | | switch (node.type) { |
| | | case "ieConditionalComment": |
| | | return "]>"; |
| | | |
| | | case "element": |
| | | if (node.condition) { |
| | | return "><!--<![endif]-->"; |
| | | } |
| | | |
| | | // fall through |
| | | |
| | | default: |
| | | return ">"; |
| | | } |
| | | } |
| | | |
| | | function printClosingTagStartMarker(node, options) { |
| | | assert(!node.isSelfClosing); |
| | | |
| | | if (shouldNotPrintClosingTag$1(node, options)) { |
| | | return ""; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "ieConditionalComment": |
| | | return "<!"; |
| | | |
| | | case "element": |
| | | if (node.hasHtmComponentClosingTag) { |
| | | return "<//"; |
| | | } |
| | | |
| | | // fall through |
| | | |
| | | default: |
| | | return "</".concat(node.rawName); |
| | | } |
| | | } |
| | | |
| | | function printClosingTagEndMarker(node, options) { |
| | | if (shouldNotPrintClosingTag$1(node, options)) { |
| | | return ""; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "ieConditionalComment": |
| | | case "ieConditionalEndComment": |
| | | return "[endif]-->"; |
| | | |
| | | case "ieConditionalStartComment": |
| | | return "]><!-->"; |
| | | |
| | | case "interpolation": |
| | | return "}}"; |
| | | |
| | | case "element": |
| | | if (node.isSelfClosing) { |
| | | return "/>"; |
| | | } |
| | | |
| | | // fall through |
| | | |
| | | default: |
| | | return ">"; |
| | | } |
| | | } |
| | | |
| | | function getTextValueParts(node) { |
| | | var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value; |
| | | return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$1(value, literalline$2) : replaceEndOfLineWith$1(dedentString$1(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // https://infra.spec.whatwg.org/#ascii-whitespace |
| | | join$6(line$5, value.split(/[\t\n\f\r ]+/)).parts; |
| | | } |
| | | |
| | | function printEmbeddedAttributeValue(node, originalTextToDoc, options) { |
| | | var isKeyMatched = function isKeyMatched(patterns) { |
| | | return new RegExp(patterns.join("|")).test(node.fullName); |
| | | }; |
| | | |
| | | var getValue = function getValue() { |
| | | return unescapeQuoteEntities$1(node.value); |
| | | }; |
| | | |
| | | var shouldHug = false; |
| | | |
| | | var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) { |
| | | var rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root; |
| | | |
| | | if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) { |
| | | shouldHug = true; |
| | | } |
| | | }; |
| | | |
| | | var printHug = function printHug(doc) { |
| | | return group$9(doc); |
| | | }; |
| | | |
| | | var printExpand = function printExpand(doc) { |
| | | return group$9(concat$a([indent$5(concat$a([softline$4, doc])), softline$4])); |
| | | }; |
| | | |
| | | var printMaybeHug = function printMaybeHug(doc) { |
| | | return shouldHug ? printHug(doc) : printExpand(doc); |
| | | }; |
| | | |
| | | var textToDoc = function textToDoc(code, opts) { |
| | | return originalTextToDoc(code, Object.assign({ |
| | | __onHtmlBindingRoot: __onHtmlBindingRoot |
| | | }, opts)); |
| | | }; |
| | | |
| | | if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) { |
| | | return printExpand(printImgSrcset$1(getValue())); |
| | | } |
| | | |
| | | if (options.parser === "vue") { |
| | | if (node.fullName === "v-for") { |
| | | return printVueFor$1(getValue(), textToDoc); |
| | | } |
| | | |
| | | if (node.fullName === "slot-scope") { |
| | | return printVueSlotScope$1(getValue(), textToDoc); |
| | | } |
| | | /** |
| | | * @click="jsStatement" |
| | | * @click="jsExpression" |
| | | * v-on:click="jsStatement" |
| | | * v-on:click="jsExpression" |
| | | */ |
| | | |
| | | |
| | | var vueEventBindingPatterns = ["^@", "^v-on:"]; |
| | | /** |
| | | * :class="vueExpression" |
| | | * v-bind:id="vueExpression" |
| | | */ |
| | | |
| | | var vueExpressionBindingPatterns = ["^:", "^v-bind:"]; |
| | | /** |
| | | * v-if="jsExpression" |
| | | */ |
| | | |
| | | var jsExpressionBindingPatterns = ["^v-"]; |
| | | |
| | | if (isKeyMatched(vueEventBindingPatterns)) { |
| | | var value = getValue(); |
| | | return printMaybeHug(isVueEventBindingExpression$1(value) ? textToDoc(value, { |
| | | parser: "__js_expression" |
| | | }) : stripTrailingHardline$1(textToDoc(value, { |
| | | parser: "__vue_event_binding" |
| | | }))); |
| | | } |
| | | |
| | | if (isKeyMatched(vueExpressionBindingPatterns)) { |
| | | return printMaybeHug(textToDoc(getValue(), { |
| | | parser: "__vue_expression" |
| | | })); |
| | | } |
| | | |
| | | if (isKeyMatched(jsExpressionBindingPatterns)) { |
| | | return printMaybeHug(textToDoc(getValue(), { |
| | | parser: "__js_expression" |
| | | })); |
| | | } |
| | | } |
| | | |
| | | if (options.parser === "angular") { |
| | | var ngTextToDoc = function ngTextToDoc(code, opts) { |
| | | return (// angular does not allow trailing comma |
| | | textToDoc(code, Object.assign({ |
| | | trailingComma: "none" |
| | | }, opts)) |
| | | ); |
| | | }; |
| | | /** |
| | | * *directive="angularDirective" |
| | | */ |
| | | |
| | | |
| | | var ngDirectiveBindingPatterns = ["^\\*"]; |
| | | /** |
| | | * (click)="angularStatement" |
| | | * on-click="angularStatement" |
| | | */ |
| | | |
| | | var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"]; |
| | | /** |
| | | * [target]="angularExpression" |
| | | * bind-target="angularExpression" |
| | | * [(target)]="angularExpression" |
| | | * bindon-target="angularExpression" |
| | | */ |
| | | |
| | | var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"]; |
| | | /** |
| | | * i18n="longDescription" |
| | | * i18n-attr="longDescription" |
| | | */ |
| | | |
| | | var ngI18nPatterns = ["^i18n(-.+)?$"]; |
| | | |
| | | if (isKeyMatched(ngStatementBindingPatterns)) { |
| | | return printMaybeHug(ngTextToDoc(getValue(), { |
| | | parser: "__ng_action" |
| | | })); |
| | | } |
| | | |
| | | if (isKeyMatched(ngExpressionBindingPatterns)) { |
| | | return printMaybeHug(ngTextToDoc(getValue(), { |
| | | parser: "__ng_binding" |
| | | })); |
| | | } |
| | | |
| | | if (isKeyMatched(ngI18nPatterns)) { |
| | | return printExpand(fill$3(getTextValueParts(node, getValue()))); |
| | | } |
| | | |
| | | if (isKeyMatched(ngDirectiveBindingPatterns)) { |
| | | return printMaybeHug(ngTextToDoc(getValue(), { |
| | | parser: "__ng_directive" |
| | | })); |
| | | } |
| | | |
| | | var interpolationRegex = /\{\{([\s\S]+?)\}\}/g; |
| | | |
| | | var _value2 = getValue(); |
| | | |
| | | if (interpolationRegex.test(_value2)) { |
| | | var parts = []; |
| | | |
| | | _value2.split(interpolationRegex).forEach(function (part, index) { |
| | | if (index % 2 === 0) { |
| | | parts.push(concat$a(replaceEndOfLineWith$1(part, literalline$2))); |
| | | } else { |
| | | try { |
| | | parts.push(group$9(concat$a(["{{", indent$5(concat$a([line$5, ngTextToDoc(part, { |
| | | parser: "__ng_interpolation", |
| | | __isInHtmlInterpolation: true // to avoid unexpected `}}` |
| | | |
| | | })])), line$5, "}}"]))); |
| | | } catch (e) { |
| | | parts.push("{{", concat$a(replaceEndOfLineWith$1(part, literalline$2)), "}}"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return group$9(concat$a(parts)); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | var printerHtml = { |
| | | preprocess: preprocess_1, |
| | | print: genericPrint$2, |
| | | insertPragma: insertPragma$6, |
| | | massageAstNode: clean$3, |
| | | embed: embed$2 |
| | | }; |
| | | |
| | | var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js |
| | | |
| | | var options$4 = { |
| | | htmlWhitespaceSensitivity: { |
| | | since: "1.15.0", |
| | | category: CATEGORY_HTML, |
| | | type: "choice", |
| | | default: "css", |
| | | description: "How to handle whitespaces in HTML.", |
| | | choices: [{ |
| | | value: "css", |
| | | description: "Respect the default value of CSS display property." |
| | | }, { |
| | | value: "strict", |
| | | description: "Whitespaces are considered sensitive." |
| | | }, { |
| | | value: "ignore", |
| | | description: "Whitespaces are considered insensitive." |
| | | }] |
| | | }, |
| | | vueIndentScriptAndStyle: { |
| | | since: "1.19.0", |
| | | category: CATEGORY_HTML, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Indent script and style tags in Vue files." |
| | | } |
| | | }; |
| | | |
| | | var name$7 = "HTML"; |
| | | var type$6 = "markup"; |
| | | var tmScope$6 = "text.html.basic"; |
| | | var aceMode$6 = "html"; |
| | | var codemirrorMode$3 = "htmlmixed"; |
| | | var codemirrorMimeType$3 = "text/html"; |
| | | var color$1 = "#e34c26"; |
| | | var aliases$1 = [ |
| | | "xhtml" |
| | | ]; |
| | | var extensions$6 = [ |
| | | ".html", |
| | | ".htm", |
| | | ".html.hl", |
| | | ".inc", |
| | | ".st", |
| | | ".xht", |
| | | ".xhtml" |
| | | ]; |
| | | var languageId$6 = 146; |
| | | var HTML = { |
| | | name: name$7, |
| | | type: type$6, |
| | | tmScope: tmScope$6, |
| | | aceMode: aceMode$6, |
| | | codemirrorMode: codemirrorMode$3, |
| | | codemirrorMimeType: codemirrorMimeType$3, |
| | | color: color$1, |
| | | aliases: aliases$1, |
| | | extensions: extensions$6, |
| | | languageId: languageId$6 |
| | | }; |
| | | |
| | | var HTML$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$7, |
| | | type: type$6, |
| | | tmScope: tmScope$6, |
| | | aceMode: aceMode$6, |
| | | codemirrorMode: codemirrorMode$3, |
| | | codemirrorMimeType: codemirrorMimeType$3, |
| | | color: color$1, |
| | | aliases: aliases$1, |
| | | extensions: extensions$6, |
| | | languageId: languageId$6, |
| | | 'default': HTML |
| | | }); |
| | | |
| | | var name$8 = "Vue"; |
| | | var type$7 = "markup"; |
| | | var color$2 = "#2c3e50"; |
| | | var extensions$7 = [ |
| | | ".vue" |
| | | ]; |
| | | var tmScope$7 = "text.html.vue"; |
| | | var aceMode$7 = "html"; |
| | | var languageId$7 = 391; |
| | | var Vue = { |
| | | name: name$8, |
| | | type: type$7, |
| | | color: color$2, |
| | | extensions: extensions$7, |
| | | tmScope: tmScope$7, |
| | | aceMode: aceMode$7, |
| | | languageId: languageId$7 |
| | | }; |
| | | |
| | | var Vue$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$8, |
| | | type: type$7, |
| | | color: color$2, |
| | | extensions: extensions$7, |
| | | tmScope: tmScope$7, |
| | | aceMode: aceMode$7, |
| | | languageId: languageId$7, |
| | | 'default': Vue |
| | | }); |
| | | |
| | | var require$$0$5 = getCjsExportFromNamespace(HTML$1); |
| | | |
| | | var require$$1$1 = getCjsExportFromNamespace(Vue$1); |
| | | |
| | | var languages$3 = [createLanguage(require$$0$5, function (data) { |
| | | return Object.assign(data, { |
| | | name: "Angular", |
| | | since: "1.15.0", |
| | | parsers: ["angular"], |
| | | vscodeLanguageIds: ["html"], |
| | | extensions: [".component.html"], |
| | | filenames: [] |
| | | }); |
| | | }), createLanguage(require$$0$5, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.15.0", |
| | | parsers: ["html"], |
| | | vscodeLanguageIds: ["html"], |
| | | extensions: data.extensions.concat([".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML |
| | | ]) |
| | | }); |
| | | }), createLanguage(require$$0$5, function (data) { |
| | | return Object.assign(data, { |
| | | name: "Lightning Web Components", |
| | | since: "1.17.0", |
| | | parsers: ["lwc"], |
| | | vscodeLanguageIds: ["html"], |
| | | extensions: [], |
| | | filenames: [] |
| | | }); |
| | | }), createLanguage(require$$1$1, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.10.0", |
| | | parsers: ["vue"], |
| | | vscodeLanguageIds: ["vue"] |
| | | }); |
| | | })]; |
| | | var printers$3 = { |
| | | html: printerHtml |
| | | }; |
| | | var languageHtml = { |
| | | languages: languages$3, |
| | | printers: printers$3, |
| | | options: options$4 |
| | | }; |
| | | |
| | | var addLeadingComment$2 = utilShared.addLeadingComment, |
| | | addTrailingComment$2 = utilShared.addTrailingComment, |
| | | addDanglingComment$2 = utilShared.addDanglingComment; |
| | | |
| | | function handleOwnLineComment(comment, text, options, ast, isLastComment) { |
| | | var precedingNode = comment.precedingNode, |
| | | enclosingNode = comment.enclosingNode, |
| | | followingNode = comment.followingNode; |
| | | |
| | | if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleEndOfLineComment(comment, text, options, ast, isLastComment) { |
| | | var precedingNode = comment.precedingNode, |
| | | enclosingNode = comment.enclosingNode, |
| | | followingNode = comment.followingNode; |
| | | |
| | | if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleRemainingComment(comment, text, options, ast, isLastComment) { |
| | | var precedingNode = comment.precedingNode, |
| | | enclosingNode = comment.enclosingNode, |
| | | followingNode = comment.followingNode; |
| | | |
| | | if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function addBlockStatementFirstComment(node, comment) { |
| | | var body = node.body.filter(function (n) { |
| | | return n.type !== "EmptyStatement"; |
| | | }); |
| | | |
| | | if (body.length === 0) { |
| | | addDanglingComment$2(node, comment); |
| | | } else { |
| | | addLeadingComment$2(body[0], comment); |
| | | } |
| | | } |
| | | |
| | | function addBlockOrNotComment(node, comment) { |
| | | if (node.type === "BlockStatement") { |
| | | addBlockStatementFirstComment(node, comment); |
| | | } else { |
| | | addLeadingComment$2(node, comment); |
| | | } |
| | | } // There are often comments before the else clause of if statements like |
| | | // |
| | | // if (1) { ... } |
| | | // // comment |
| | | // else { ... } |
| | | // |
| | | // They are being attached as leading comments of the BlockExpression which |
| | | // is not well printed. What we want is to instead move the comment inside |
| | | // of the block and make it leadingComment of the first element of the block |
| | | // or dangling comment of the block if there is nothing inside |
| | | // |
| | | // if (1) { ... } |
| | | // else { |
| | | // // comment |
| | | // ... |
| | | // } |
| | | |
| | | |
| | | function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) { |
| | | if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) { |
| | | return false; |
| | | } // We unfortunately have no way using the AST or location of nodes to know |
| | | // if the comment is positioned before the condition parenthesis: |
| | | // if (a /* comment */) {} |
| | | // The only workaround I found is to look at the next character to see if |
| | | // it is a ). |
| | | |
| | | |
| | | var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd); |
| | | |
| | | if (nextCharacter === ")") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } // Comments before `else`: |
| | | // - treat as trailing comments of the consequent, if it's a BlockStatement |
| | | // - treat as a dangling comment otherwise |
| | | |
| | | |
| | | if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) { |
| | | if (precedingNode.type === "BlockStatement") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | } else { |
| | | addDanglingComment$2(enclosingNode, comment); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "BlockStatement") { |
| | | addBlockStatementFirstComment(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "IfStatement") { |
| | | addBlockOrNotComment(followingNode.consequent, comment); |
| | | return true; |
| | | } // For comments positioned after the condition parenthesis in an if statement |
| | | // before the consequent without brackets on, such as |
| | | // if (a) /* comment */ true, |
| | | // we look at the next character to see if the following node |
| | | // is the consequent for the if statement |
| | | |
| | | |
| | | if (enclosingNode.consequent === followingNode) { |
| | | addLeadingComment$2(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) { |
| | | if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) { |
| | | return false; |
| | | } // We unfortunately have no way using the AST or location of nodes to know |
| | | // if the comment is positioned before the condition parenthesis: |
| | | // while (a /* comment */) {} |
| | | // The only workaround I found is to look at the next character to see if |
| | | // it is a ). |
| | | |
| | | |
| | | var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd); |
| | | |
| | | if (nextCharacter === ")") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "BlockStatement") { |
| | | addBlockStatementFirstComment(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } // Same as IfStatement but for TryStatement |
| | | |
| | | |
| | | function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) { |
| | | if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) { |
| | | return false; |
| | | } |
| | | |
| | | if (enclosingNode.type === "CatchClause" && precedingNode) { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "BlockStatement") { |
| | | addBlockStatementFirstComment(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "TryStatement") { |
| | | addBlockOrNotComment(followingNode.finalizer, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (followingNode.type === "CatchClause") { |
| | | addBlockOrNotComment(followingNode.body, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleMemberExpressionComments(enclosingNode, followingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "MemberExpression" || enclosingNode.type === "OptionalMemberExpression") && followingNode && followingNode.type === "Identifier") { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) { |
| | | var isSameLineAsPrecedingNode = precedingNode && !util.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment)); |
| | | |
| | | if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) { |
| | | addLeadingComment$2(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") { |
| | | addTrailingComment$2(enclosingNode.value.left, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleClassComments(enclosingNode, precedingNode, followingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) { |
| | | if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | } else { |
| | | addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) { |
| | | // This is only needed for estree parsers (flow, typescript) to attach |
| | | // after a method name: |
| | | // obj = { fn /*comment*/() {} }; |
| | | if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) }; |
| | | // comment should be attached to value instead of key |
| | | util.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } // Print comments between decorators and class methods as a trailing comment |
| | | // on the decorator node instead of the method node |
| | | |
| | | |
| | | if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) { |
| | | if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") { |
| | | return false; |
| | | } |
| | | |
| | | if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleCommentAfterArrowParams(text, enclosingNode, comment, options) { |
| | | if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) { |
| | | return false; |
| | | } |
| | | |
| | | var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options); |
| | | |
| | | if (text.substr(index, 2) === "=>") { |
| | | addDanglingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleCommentInEmptyParens(text, enclosingNode, comment, options) { |
| | | if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") { |
| | | return false; |
| | | } // Only add dangling comments to fix the case when no params are present, |
| | | // i.e. a function without any argument. |
| | | |
| | | |
| | | if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "OptionalCallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) { |
| | | addDanglingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) { |
| | | addDanglingComment$2(enclosingNode.value, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) { |
| | | // Type definitions functions |
| | | if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } // Real functions |
| | | |
| | | |
| | | if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") { |
| | | var functionParamRightParenIndex = function () { |
| | | if (enclosingNode.params.length !== 0) { |
| | | return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util.getLast(enclosingNode.params))); |
| | | } |
| | | |
| | | var functionParamLeftParenIndex = util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id)); |
| | | return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1); |
| | | }(); |
| | | |
| | | if (options.locStart(comment) > functionParamRightParenIndex) { |
| | | addBlockStatementFirstComment(followingNode, comment); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleImportSpecifierComments(enclosingNode, comment) { |
| | | if (enclosingNode && enclosingNode.type === "ImportSpecifier") { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleLabeledStatementComments(enclosingNode, comment) { |
| | | if (enclosingNode && enclosingNode.type === "LabeledStatement") { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleBreakAndContinueStatementComments(enclosingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) { |
| | | addTrailingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleCallExpressionComments(precedingNode, enclosingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "CallExpression" || enclosingNode.type === "OptionalCallExpression") && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) { |
| | | addLeadingComment$2(enclosingNode.arguments[0], comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handlePropertyComments(enclosingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleOnlyComments(enclosingNode, ast, comment, isLastComment) { |
| | | // With Flow the enclosingNode is undefined so use the AST instead. |
| | | if (ast && ast.body && ast.body.length === 0) { |
| | | if (isLastComment) { |
| | | addDanglingComment$2(ast, comment); |
| | | } else { |
| | | addLeadingComment$2(ast, comment); |
| | | } |
| | | |
| | | return true; |
| | | } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) { |
| | | if (isLastComment) { |
| | | addDanglingComment$2(enclosingNode, comment); |
| | | } else { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleForComments(enclosingNode, precedingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) { |
| | | if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util.hasNewline(text, options.locEnd(comment))) { |
| | | addTrailingComment$2(precedingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleAssignmentPatternComments(enclosingNode, comment) { |
| | | if (enclosingNode && enclosingNode.type === "AssignmentPattern") { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleTypeAliasComments(enclosingNode, followingNode, comment) { |
| | | if (enclosingNode && enclosingNode.type === "TypeAlias") { |
| | | addLeadingComment$2(enclosingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) { |
| | | if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) { |
| | | addLeadingComment$2(followingNode, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) { |
| | | if (!enclosingNode || enclosingNode.type !== "TSMappedType") { |
| | | return false; |
| | | } |
| | | |
| | | if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) { |
| | | addLeadingComment$2(followingNode.name, comment); |
| | | return true; |
| | | } |
| | | |
| | | if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) { |
| | | addTrailingComment$2(precedingNode.constraint, comment); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isBlockComment(comment) { |
| | | return comment.type === "Block" || comment.type === "CommentBlock"; |
| | | } |
| | | |
| | | function hasLeadingComment(node) { |
| | | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { |
| | | return true; |
| | | }; |
| | | |
| | | if (node.leadingComments) { |
| | | return node.leadingComments.some(fn); |
| | | } |
| | | |
| | | if (node.comments) { |
| | | return node.comments.some(function (comment) { |
| | | return comment.leading && fn(comment); |
| | | }); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | var comments$1 = { |
| | | handleOwnLineComment: handleOwnLineComment, |
| | | handleEndOfLineComment: handleEndOfLineComment, |
| | | handleRemainingComment: handleRemainingComment, |
| | | hasLeadingComment: hasLeadingComment, |
| | | isBlockComment: isBlockComment |
| | | }; |
| | | |
| | | var isBlockComment$1 = comments$1.isBlockComment, |
| | | hasLeadingComment$1 = comments$1.hasLeadingComment; |
| | | var _require$$1$builders = doc.builders, |
| | | indent$6 = _require$$1$builders.indent, |
| | | join$7 = _require$$1$builders.join, |
| | | hardline$8 = _require$$1$builders.hardline, |
| | | softline$5 = _require$$1$builders.softline, |
| | | literalline$3 = _require$$1$builders.literalline, |
| | | concat$b = _require$$1$builders.concat, |
| | | group$a = _require$$1$builders.group, |
| | | dedentToRoot$2 = _require$$1$builders.dedentToRoot, |
| | | _require$$1$utils = doc.utils, |
| | | mapDoc$5 = _require$$1$utils.mapDoc, |
| | | stripTrailingHardline$2 = _require$$1$utils.stripTrailingHardline; |
| | | |
| | | function embed$3(path, print, textToDoc, options) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | var parentParent = path.getParentNode(1); |
| | | |
| | | switch (node.type) { |
| | | case "TemplateLiteral": |
| | | { |
| | | var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) { |
| | | return isIt(path); |
| | | }); |
| | | |
| | | if (isCss) { |
| | | // Get full template literal with expressions replaced by placeholders |
| | | var rawQuasis = node.quasis.map(function (q) { |
| | | return q.value.raw; |
| | | }); |
| | | var placeholderID = 0; |
| | | var text = rawQuasis.reduce(function (prevVal, currVal, idx) { |
| | | return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal; |
| | | }, ""); |
| | | var doc = textToDoc(text, { |
| | | parser: "css" |
| | | }); |
| | | return transformCssDoc(doc, path, print); |
| | | } |
| | | /* |
| | | * react-relay and graphql-tag |
| | | * graphql`...` |
| | | * graphql.experimental`...` |
| | | * gql`...` |
| | | * |
| | | * This intentionally excludes Relay Classic tags, as Prettier does not |
| | | * support Relay Classic formatting. |
| | | */ |
| | | |
| | | |
| | | if (isGraphQL(path)) { |
| | | var expressionDocs = node.expressions ? path.map(print, "expressions") : []; |
| | | var numQuasis = node.quasis.length; |
| | | |
| | | if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") { |
| | | return "``"; |
| | | } |
| | | |
| | | var parts = []; |
| | | |
| | | for (var i = 0; i < numQuasis; i++) { |
| | | var templateElement = node.quasis[i]; |
| | | var isFirst = i === 0; |
| | | var isLast = i === numQuasis - 1; |
| | | var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence |
| | | // (which would make the `cooked` value be `null` or `undefined`) |
| | | |
| | | if (typeof _text !== "string") { |
| | | return null; |
| | | } |
| | | |
| | | var lines = _text.split("\n"); |
| | | |
| | | var numLines = lines.length; |
| | | var expressionDoc = expressionDocs[i]; |
| | | var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === ""; |
| | | var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === ""; |
| | | var commentsAndWhitespaceOnly = lines.every(function (line) { |
| | | return /^\s*(?:#[^\r\n]*)?$/.test(line); |
| | | }); // Bail out if an interpolation occurs within a comment. |
| | | |
| | | if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) { |
| | | return null; |
| | | } |
| | | |
| | | var _doc = null; |
| | | |
| | | if (commentsAndWhitespaceOnly) { |
| | | _doc = printGraphqlComments(lines); |
| | | } else { |
| | | _doc = stripTrailingHardline$2(textToDoc(_text, { |
| | | parser: "graphql" |
| | | })); |
| | | } |
| | | |
| | | if (_doc) { |
| | | _doc = escapeTemplateCharacters(_doc, false); |
| | | |
| | | if (!isFirst && startsWithBlankLine) { |
| | | parts.push(""); |
| | | } |
| | | |
| | | parts.push(_doc); |
| | | |
| | | if (!isLast && endsWithBlankLine) { |
| | | parts.push(""); |
| | | } |
| | | } else if (!isFirst && !isLast && startsWithBlankLine) { |
| | | parts.push(""); |
| | | } |
| | | |
| | | if (expressionDoc) { |
| | | parts.push(concat$b(["${", expressionDoc, "}"])); |
| | | } |
| | | } |
| | | |
| | | return concat$b(["`", indent$6(concat$b([hardline$8, join$7(hardline$8, parts)])), hardline$8, "`"]); |
| | | } |
| | | |
| | | var htmlParser = isHtml(path) ? "html" : isAngularComponentTemplate(path) ? "angular" : undefined; |
| | | |
| | | if (htmlParser) { |
| | | return printHtmlTemplateLiteral(path, print, textToDoc, htmlParser, options.embeddedInHtml); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case "TemplateElement": |
| | | { |
| | | /** |
| | | * md`...` |
| | | * markdown`...` |
| | | */ |
| | | if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) { |
| | | var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) { |
| | | return "\\".repeat(backslashes.length / 2) + "`"; |
| | | }); |
| | | |
| | | var indentation = getIndentation(_text2); |
| | | var hasIndent = indentation !== ""; |
| | | return concat$b([hasIndent ? indent$6(concat$b([softline$5, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$b([literalline$3, dedentToRoot$2(printMarkdown(_text2))]), softline$5]); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | function printMarkdown(text) { |
| | | var doc = textToDoc(text, { |
| | | parser: "markdown", |
| | | __inJsTemplate: true |
| | | }); |
| | | return stripTrailingHardline$2(escapeTemplateCharacters(doc, true)); |
| | | } |
| | | } |
| | | |
| | | function getIndentation(str) { |
| | | var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m); |
| | | return firstMatchedIndent === null ? "" : firstMatchedIndent[1]; |
| | | } |
| | | |
| | | function uncook(cookedValue) { |
| | | return cookedValue.replace(/([\\`]|\$\{)/g, "\\$1"); |
| | | } |
| | | |
| | | function escapeTemplateCharacters(doc, raw) { |
| | | return mapDoc$5(doc, function (currentDoc) { |
| | | if (!currentDoc.parts) { |
| | | return currentDoc; |
| | | } |
| | | |
| | | var parts = []; |
| | | currentDoc.parts.forEach(function (part) { |
| | | if (typeof part === "string") { |
| | | parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : uncook(part)); |
| | | } else { |
| | | parts.push(part); |
| | | } |
| | | }); |
| | | return Object.assign({}, currentDoc, { |
| | | parts: parts |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function transformCssDoc(quasisDoc, path, print) { |
| | | var parentNode = path.getValue(); |
| | | var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim(); |
| | | |
| | | if (isEmpty) { |
| | | return "``"; |
| | | } |
| | | |
| | | var expressionDocs = parentNode.expressions ? path.map(print, "expressions") : []; |
| | | var newDoc = replacePlaceholders(quasisDoc, expressionDocs); |
| | | /* istanbul ignore if */ |
| | | |
| | | if (!newDoc) { |
| | | throw new Error("Couldn't insert all the expressions"); |
| | | } |
| | | |
| | | return concat$b(["`", indent$6(concat$b([hardline$8, stripTrailingHardline$2(newDoc)])), softline$5, "`"]); |
| | | } // Search all the placeholders in the quasisDoc tree |
| | | // and replace them with the expression docs one by one |
| | | // returns a new doc with all the placeholders replaced, |
| | | // or null if it couldn't replace any expression |
| | | |
| | | |
| | | function replacePlaceholders(quasisDoc, expressionDocs) { |
| | | if (!expressionDocs || !expressionDocs.length) { |
| | | return quasisDoc; |
| | | } |
| | | |
| | | var expressions = expressionDocs.slice(); |
| | | var replaceCounter = 0; |
| | | var newDoc = mapDoc$5(quasisDoc, function (doc) { |
| | | if (!doc || !doc.parts || !doc.parts.length) { |
| | | return doc; |
| | | } |
| | | |
| | | var parts = doc.parts; |
| | | var atIndex = parts.indexOf("@"); |
| | | var placeholderIndex = atIndex + 1; |
| | | |
| | | if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) { |
| | | // If placeholder is split, join it |
| | | var at = parts[atIndex]; |
| | | var placeholder = parts[placeholderIndex]; |
| | | var rest = parts.slice(placeholderIndex + 1); |
| | | parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest); |
| | | } |
| | | |
| | | var atPlaceholderIndex = parts.findIndex(function (part) { |
| | | return typeof part === "string" && part.startsWith("@prettier-placeholder"); |
| | | }); |
| | | |
| | | if (atPlaceholderIndex > -1) { |
| | | var _placeholder = parts[atPlaceholderIndex]; |
| | | |
| | | var _rest = parts.slice(atPlaceholderIndex + 1); |
| | | |
| | | var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/); |
| | | |
| | | var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like: |
| | | // animation: linear ${time}s ease-out; |
| | | |
| | | var suffix = placeholderMatch[2]; |
| | | var expression = expressions[placeholderID]; |
| | | replaceCounter++; |
| | | parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest); |
| | | } |
| | | |
| | | return Object.assign({}, doc, { |
| | | parts: parts |
| | | }); |
| | | }); |
| | | return expressions.length === replaceCounter ? newDoc : null; |
| | | } |
| | | |
| | | function printGraphqlComments(lines) { |
| | | var parts = []; |
| | | var seenComment = false; |
| | | lines.map(function (textLine) { |
| | | return textLine.trim(); |
| | | }).forEach(function (textLine, i, array) { |
| | | // Lines are either whitespace only, or a comment (with potential whitespace |
| | | // around it). Drop whitespace-only lines. |
| | | if (textLine === "") { |
| | | return; |
| | | } |
| | | |
| | | if (array[i - 1] === "" && seenComment) { |
| | | // If a non-first comment is preceded by a blank (whitespace only) line, |
| | | // add in a blank line. |
| | | parts.push(concat$b([hardline$8, textLine])); |
| | | } else { |
| | | parts.push(textLine); |
| | | } |
| | | |
| | | seenComment = true; |
| | | }); // If `lines` was whitespace only, return `null`. |
| | | |
| | | return parts.length === 0 ? null : join$7(hardline$8, parts); |
| | | } |
| | | /** |
| | | * Template literal in these contexts: |
| | | * <style jsx>{`div{color:red}`}</style> |
| | | * css`` |
| | | * css.global`` |
| | | * css.resolve`` |
| | | */ |
| | | |
| | | |
| | | function isStyledJsx(path) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | var parentParent = path.getParentNode(1); |
| | | return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) { |
| | | return attribute.name.name === "jsx"; |
| | | }) || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve"); |
| | | } |
| | | /** |
| | | * Angular Components can have: |
| | | * - Inline HTML template |
| | | * - Inline CSS styles |
| | | * |
| | | * ...which are both within template literals somewhere |
| | | * inside of the Component decorator factory. |
| | | * |
| | | * E.g. |
| | | * @Component({ |
| | | * template: `<div>...</div>`, |
| | | * styles: [`h1 { color: blue; }`] |
| | | * }) |
| | | */ |
| | | |
| | | |
| | | function isAngularComponentStyles(path) { |
| | | return isPathMatch(path, [function (node) { |
| | | return node.type === "TemplateLiteral"; |
| | | }, function (node, name) { |
| | | return node.type === "ArrayExpression" && name === "elements"; |
| | | }, function (node, name) { |
| | | return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value"; |
| | | }].concat(getAngularComponentObjectExpressionPredicates())); |
| | | } |
| | | |
| | | function isAngularComponentTemplate(path) { |
| | | return isPathMatch(path, [function (node) { |
| | | return node.type === "TemplateLiteral"; |
| | | }, function (node, name) { |
| | | return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value"; |
| | | }].concat(getAngularComponentObjectExpressionPredicates())); |
| | | } |
| | | |
| | | function getAngularComponentObjectExpressionPredicates() { |
| | | return [function (node, name) { |
| | | return node.type === "ObjectExpression" && name === "properties"; |
| | | }, function (node, name) { |
| | | return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments"; |
| | | }, function (node, name) { |
| | | return node.type === "Decorator" && name === "expression"; |
| | | }]; |
| | | } |
| | | /** |
| | | * styled-components template literals |
| | | */ |
| | | |
| | | |
| | | function isStyledComponents(path) { |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (!parent || parent.type !== "TaggedTemplateExpression") { |
| | | return false; |
| | | } |
| | | |
| | | var tag = parent.tag; |
| | | |
| | | switch (tag.type) { |
| | | case "MemberExpression": |
| | | return (// styled.foo`` |
| | | isStyledIdentifier(tag.object) || // Component.extend`` |
| | | isStyledExtend(tag) |
| | | ); |
| | | |
| | | case "CallExpression": |
| | | return (// styled(Component)`` |
| | | isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})`` |
| | | isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})`` |
| | | isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})`` |
| | | tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee)) |
| | | ); |
| | | |
| | | case "Identifier": |
| | | // css`` |
| | | return tag.name === "css"; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * JSX element with CSS prop |
| | | */ |
| | | |
| | | |
| | | function isCssProp(path) { |
| | | var parent = path.getParentNode(); |
| | | var parentParent = path.getParentNode(1); |
| | | return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css"; |
| | | } |
| | | |
| | | function isStyledIdentifier(node) { |
| | | return node.type === "Identifier" && node.name === "styled"; |
| | | } |
| | | |
| | | function isStyledExtend(node) { |
| | | return /^[A-Z]/.test(node.object.name) && node.property.name === "extend"; |
| | | } |
| | | /* |
| | | * react-relay and graphql-tag |
| | | * graphql`...` |
| | | * graphql.experimental`...` |
| | | * gql`...` |
| | | * GraphQL comment block |
| | | * |
| | | * This intentionally excludes Relay Classic tags, as Prettier does not |
| | | * support Relay Classic formatting. |
| | | */ |
| | | |
| | | |
| | | function isGraphQL(path) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql"); |
| | | } |
| | | |
| | | function hasLanguageComment(node, languageName) { |
| | | // This checks for a leading comment that is exactly `/* GraphQL */` |
| | | // In order to be in line with other implementations of this comment tag |
| | | // we will not trim the comment value and we will expect exactly one space on |
| | | // either side of the GraphQL string |
| | | // Also see ./clean.js |
| | | return hasLeadingComment$1(node, function (comment) { |
| | | return isBlockComment$1(comment) && comment.value === " ".concat(languageName, " "); |
| | | }); |
| | | } |
| | | |
| | | function isPathMatch(path, predicateStack) { |
| | | var stack = path.stack.slice(); |
| | | var name = null; |
| | | var node = stack.pop(); |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var predicate = _step.value; |
| | | |
| | | if (node === undefined) { |
| | | return false; |
| | | } // skip index/array |
| | | |
| | | |
| | | if (typeof name === "number") { |
| | | name = stack.pop(); |
| | | node = stack.pop(); |
| | | } |
| | | |
| | | if (!predicate(node, name)) { |
| | | return false; |
| | | } |
| | | |
| | | name = stack.pop(); |
| | | node = stack.pop(); |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | /** |
| | | * - html`...` |
| | | * - HTML comment block |
| | | */ |
| | | |
| | | |
| | | function isHtml(path) { |
| | | var node = path.getValue(); |
| | | return hasLanguageComment(node, "HTML") || isPathMatch(path, [function (node) { |
| | | return node.type === "TemplateLiteral"; |
| | | }, function (node, name) { |
| | | return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi"; |
| | | }]); |
| | | } // The counter is needed to distinguish nested embeds. |
| | | |
| | | |
| | | var htmlTemplateLiteralCounter = 0; |
| | | |
| | | function printHtmlTemplateLiteral(path, print, textToDoc, parser, escapeClosingScriptTag) { |
| | | var node = path.getValue(); |
| | | var counter = htmlTemplateLiteralCounter; |
| | | htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0; |
| | | |
| | | var composePlaceholder = function composePlaceholder(index) { |
| | | return "PRETTIER_HTML_PLACEHOLDER_".concat(index, "_").concat(counter, "_IN_JS"); |
| | | }; |
| | | |
| | | var text = node.quasis.map(function (quasi, index, quasis) { |
| | | return index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index); |
| | | }).join(""); |
| | | var expressionDocs = path.map(print, "expressions"); |
| | | |
| | | if (expressionDocs.length === 0 && text.trim().length === 0) { |
| | | return "``"; |
| | | } |
| | | |
| | | var placeholderRegex = RegExp(composePlaceholder("(\\d+)"), "g"); |
| | | var contentDoc = mapDoc$5(stripTrailingHardline$2(textToDoc(text, { |
| | | parser: parser |
| | | })), function (doc) { |
| | | if (typeof doc !== "string") { |
| | | return doc; |
| | | } |
| | | |
| | | var parts = []; |
| | | var components = doc.split(placeholderRegex); |
| | | |
| | | for (var i = 0; i < components.length; i++) { |
| | | var component = components[i]; |
| | | |
| | | if (i % 2 === 0) { |
| | | if (component) { |
| | | component = uncook(component); |
| | | |
| | | if (escapeClosingScriptTag) { |
| | | component = component.replace(/<\/(script)\b/gi, "<\\/$1"); |
| | | } |
| | | |
| | | parts.push(component); |
| | | } |
| | | |
| | | continue; |
| | | } |
| | | |
| | | var placeholderIndex = +component; |
| | | parts.push(concat$b(["${", group$a(expressionDocs[placeholderIndex]), "}"])); |
| | | } |
| | | |
| | | return concat$b(parts); |
| | | }); |
| | | return group$a(concat$b(["`", indent$6(concat$b([hardline$8, group$a(contentDoc)])), softline$5, "`"])); |
| | | } |
| | | |
| | | var embed_1$1 = embed$3; |
| | | |
| | | function clean$4(ast, newObj, parent) { |
| | | ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags", "errors"].forEach(function (name) { |
| | | delete newObj[name]; |
| | | }); |
| | | |
| | | if (ast.type === "BigIntLiteral") { |
| | | newObj.value = newObj.value.toLowerCase(); |
| | | } // We remove extra `;` and add them when needed |
| | | |
| | | |
| | | if (ast.type === "EmptyStatement") { |
| | | return null; |
| | | } // We move text around, including whitespaces and add {" "} |
| | | |
| | | |
| | | if (ast.type === "JSXText") { |
| | | return null; |
| | | } |
| | | |
| | | if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") { |
| | | return null; |
| | | } // We remove unneeded parens around same-operator LogicalExpressions |
| | | |
| | | |
| | | if (isUnbalancedLogicalTree(newObj)) { |
| | | return rebalanceLogicalTree(newObj); |
| | | } // (TypeScript) Ignore `static` in `constructor(static p) {}` |
| | | // and `export` in `constructor(export p) {}` |
| | | |
| | | |
| | | if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) { |
| | | return { |
| | | type: "Identifier", |
| | | name: ast.parameter.name, |
| | | typeAnnotation: newObj.parameter.typeAnnotation, |
| | | decorators: newObj.decorators |
| | | }; |
| | | } // (TypeScript) ignore empty `specifiers` array |
| | | |
| | | |
| | | if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) { |
| | | delete newObj.specifiers; |
| | | } // We convert <div></div> to <div /> |
| | | |
| | | |
| | | if (ast.type === "JSXOpeningElement") { |
| | | delete newObj.selfClosing; |
| | | } |
| | | |
| | | if (ast.type === "JSXElement") { |
| | | delete newObj.closingElement; |
| | | } // We change {'key': value} into {key: value} |
| | | |
| | | |
| | | if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && _typeof(ast.key) === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) { |
| | | delete newObj.key; |
| | | } |
| | | |
| | | if (ast.type === "OptionalMemberExpression" && ast.optional === false) { |
| | | newObj.type = "MemberExpression"; |
| | | delete newObj.optional; |
| | | } // Remove raw and cooked values from TemplateElement when it's CSS |
| | | // styled-jsx |
| | | |
| | | |
| | | if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) { |
| | | return attr.name.name === "jsx"; |
| | | })) { |
| | | var templateLiterals = newObj.children.filter(function (child) { |
| | | return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral"; |
| | | }).map(function (container) { |
| | | return container.expression; |
| | | }); |
| | | var quasis = templateLiterals.reduce(function (quasis, templateLiteral) { |
| | | return quasis.concat(templateLiteral.quasis); |
| | | }, []); |
| | | quasis.forEach(function (q) { |
| | | return delete q.value; |
| | | }); |
| | | } // CSS template literals in css prop |
| | | |
| | | |
| | | if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") { |
| | | newObj.value.expression.quasis.forEach(function (q) { |
| | | return delete q.value; |
| | | }); |
| | | } // Angular Components: Inline HTML template and Inline CSS styles |
| | | |
| | | |
| | | var expression = ast.expression || ast.callee; |
| | | |
| | | if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) { |
| | | var astProps = ast.expression.arguments[0].properties; |
| | | newObj.expression.arguments[0].properties.forEach(function (prop, index) { |
| | | var templateLiteral = null; |
| | | |
| | | switch (astProps[index].key.name) { |
| | | case "styles": |
| | | if (prop.value.type === "ArrayExpression") { |
| | | templateLiteral = prop.value.elements[0]; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "template": |
| | | if (prop.value.type === "TemplateLiteral") { |
| | | templateLiteral = prop.value; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | if (templateLiteral) { |
| | | templateLiteral.quasis.forEach(function (q) { |
| | | return delete q.value; |
| | | }); |
| | | } |
| | | }); |
| | | } // styled-components, graphql, markdown |
| | | |
| | | |
| | | if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) { |
| | | newObj.quasi.quasis.forEach(function (quasi) { |
| | | return delete quasi.value; |
| | | }); |
| | | } |
| | | |
| | | if (ast.type === "TemplateLiteral") { |
| | | // This checks for a leading comment that is exactly `/* GraphQL */` |
| | | // In order to be in line with other implementations of this comment tag |
| | | // we will not trim the comment value and we will expect exactly one space on |
| | | // either side of the GraphQL string |
| | | // Also see ./embed.js |
| | | var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) { |
| | | return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) { |
| | | return comment.value === " ".concat(languageName, " "); |
| | | }); |
| | | }); |
| | | |
| | | if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") { |
| | | newObj.quasis.forEach(function (quasi) { |
| | | return delete quasi.value; |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function isUnbalancedLogicalTree(newObj) { |
| | | return newObj.type === "LogicalExpression" && newObj.right.type === "LogicalExpression" && newObj.operator === newObj.right.operator; |
| | | } |
| | | |
| | | function rebalanceLogicalTree(newObj) { |
| | | if (isUnbalancedLogicalTree(newObj)) { |
| | | return rebalanceLogicalTree({ |
| | | type: "LogicalExpression", |
| | | operator: newObj.operator, |
| | | left: rebalanceLogicalTree({ |
| | | type: "LogicalExpression", |
| | | operator: newObj.operator, |
| | | left: newObj.left, |
| | | right: newObj.right.left, |
| | | loc: {} |
| | | }), |
| | | right: newObj.right.right, |
| | | loc: {} |
| | | }); |
| | | } |
| | | |
| | | return newObj; |
| | | } |
| | | |
| | | var clean_1$1 = clean$4; |
| | | |
| | | var getLast$1 = util.getLast, |
| | | hasNewline$3 = util.hasNewline, |
| | | hasNewlineInRange$1 = util.hasNewlineInRange, |
| | | hasIgnoreComment$3 = util.hasIgnoreComment, |
| | | hasNodeIgnoreComment$1 = util.hasNodeIgnoreComment, |
| | | skipWhitespace$1 = util.skipWhitespace; |
| | | var isIdentifierName = utils$1.keyword.isIdentifierNameES5; // We match any whitespace except line terminators because |
| | | // Flow annotation comments cannot be split across lines. For example: |
| | | // |
| | | // (this /* |
| | | // : any */).foo = 5; |
| | | // |
| | | // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so |
| | | // removing the newline would create a type annotation that the user did not intend |
| | | // to create. |
| | | |
| | | var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)"; |
| | | var FLOW_SHORTHAND_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*:")); |
| | | var FLOW_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*::")); |
| | | |
| | | function hasFlowShorthandAnnotationComment(node) { |
| | | // https://flow.org/en/docs/types/comments/ |
| | | // Syntax example: const r = new (window.Request /*: Class<Request> */)(""); |
| | | return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION); |
| | | } |
| | | |
| | | function hasFlowAnnotationComment(comments) { |
| | | return comments && comments[0].value.match(FLOW_ANNOTATION); |
| | | } |
| | | |
| | | function hasNode(node, fn) { |
| | | if (!node || _typeof(node) !== "object") { |
| | | return false; |
| | | } |
| | | |
| | | if (Array.isArray(node)) { |
| | | return node.some(function (value) { |
| | | return hasNode(value, fn); |
| | | }); |
| | | } |
| | | |
| | | var result = fn(node); |
| | | return typeof result === "boolean" ? result : Object.keys(node).some(function (key) { |
| | | return hasNode(node[key], fn); |
| | | }); |
| | | } |
| | | |
| | | function hasNakedLeftSide(node) { |
| | | return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression"; |
| | | } |
| | | |
| | | function getLeftSide(node) { |
| | | if (node.expressions) { |
| | | return node.expressions[0]; |
| | | } |
| | | |
| | | return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression; |
| | | } |
| | | |
| | | function getLeftSidePathName(path, node) { |
| | | if (node.expressions) { |
| | | return ["expressions", 0]; |
| | | } |
| | | |
| | | if (node.left) { |
| | | return ["left"]; |
| | | } |
| | | |
| | | if (node.test) { |
| | | return ["test"]; |
| | | } |
| | | |
| | | if (node.object) { |
| | | return ["object"]; |
| | | } |
| | | |
| | | if (node.callee) { |
| | | return ["callee"]; |
| | | } |
| | | |
| | | if (node.tag) { |
| | | return ["tag"]; |
| | | } |
| | | |
| | | if (node.argument) { |
| | | return ["argument"]; |
| | | } |
| | | |
| | | if (node.expression) { |
| | | return ["expression"]; |
| | | } |
| | | |
| | | throw new Error("Unexpected node has no left side", node); |
| | | } |
| | | |
| | | function isLiteral(node) { |
| | | return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText"; |
| | | } |
| | | |
| | | function isNumericLiteral(node) { |
| | | return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number"; |
| | | } |
| | | |
| | | function isStringLiteral(node) { |
| | | return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string"; |
| | | } |
| | | |
| | | function isObjectType(n) { |
| | | return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral"; |
| | | } |
| | | |
| | | function isFunctionOrArrowExpression(node) { |
| | | return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"; |
| | | } |
| | | |
| | | function isFunctionOrArrowExpressionWithBody(node) { |
| | | return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement"; |
| | | } |
| | | |
| | | function isTemplateLiteral(node) { |
| | | return node.type === "TemplateLiteral"; |
| | | } // `inject` is used in AngularJS 1.x, `async` in Angular 2+ |
| | | // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall- |
| | | |
| | | |
| | | function isAngularTestWrapper(node) { |
| | | return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync"); |
| | | } |
| | | |
| | | function isJSXNode(node) { |
| | | return node.type === "JSXElement" || node.type === "JSXFragment"; |
| | | } |
| | | |
| | | function isTheOnlyJSXElementInMarkdown(options, path) { |
| | | if (options.parentParser !== "markdown" && options.parentParser !== "mdx") { |
| | | return false; |
| | | } |
| | | |
| | | var node = path.getNode(); |
| | | |
| | | if (!node.expression || !isJSXNode(node.expression)) { |
| | | return false; |
| | | } |
| | | |
| | | var parent = path.getParentNode(); |
| | | return parent.type === "Program" && parent.body.length == 1; |
| | | } // Detect an expression node representing `{" "}` |
| | | |
| | | |
| | | function isJSXWhitespaceExpression(node) { |
| | | return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments; |
| | | } |
| | | |
| | | function isMemberExpressionChain(node) { |
| | | if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") { |
| | | return false; |
| | | } |
| | | |
| | | if (node.object.type === "Identifier") { |
| | | return true; |
| | | } |
| | | |
| | | return isMemberExpressionChain(node.object); |
| | | } |
| | | |
| | | function isGetterOrSetter(node) { |
| | | return node.kind === "get" || node.kind === "set"; |
| | | } |
| | | |
| | | function sameLocStart(nodeA, nodeB, options) { |
| | | return options.locStart(nodeA) === options.locStart(nodeB); |
| | | } // TODO: This is a bad hack and we need a better way to distinguish between |
| | | // arrow functions and otherwise |
| | | |
| | | |
| | | function isFunctionNotation(node, options) { |
| | | return isGetterOrSetter(node) || sameLocStart(node, node.value, options); |
| | | } // Hack to differentiate between the following two which have the same ast |
| | | // type T = { method: () => void }; |
| | | // type T = { method(): void }; |
| | | |
| | | |
| | | function isObjectTypePropertyAFunction(node, options) { |
| | | return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options); |
| | | } // Hack to differentiate between the following two which have the same ast |
| | | // declare function f(a): void; |
| | | // var f: (a) => void; |
| | | |
| | | |
| | | function isTypeAnnotationAFunction(node, options) { |
| | | return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options); |
| | | } |
| | | |
| | | function isBinaryish(node) { |
| | | return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression"; |
| | | } |
| | | |
| | | function isMemberish(node) { |
| | | return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object; |
| | | } |
| | | |
| | | function isSimpleFlowType(node) { |
| | | var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"]; |
| | | return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters); |
| | | } |
| | | |
| | | var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; |
| | | |
| | | function isSkipOrOnlyBlock(node) { |
| | | return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip"); |
| | | } |
| | | |
| | | function isUnitTestSetUp(n) { |
| | | var unitTestSetUpRe = /^(before|after)(Each|All)$/; |
| | | return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1; |
| | | } // eg; `describe("some string", (done) => {})` |
| | | |
| | | |
| | | function isTestCall(n, parent) { |
| | | if (n.type !== "CallExpression") { |
| | | return false; |
| | | } |
| | | |
| | | if (n.arguments.length === 1) { |
| | | if (isAngularTestWrapper(n) && parent && isTestCall(parent)) { |
| | | return isFunctionOrArrowExpression(n.arguments[0]); |
| | | } |
| | | |
| | | if (isUnitTestSetUp(n)) { |
| | | return isAngularTestWrapper(n.arguments[0]); |
| | | } |
| | | } else if (n.arguments.length === 2 || n.arguments.length === 3) { |
| | | if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) { |
| | | // it("name", () => { ... }, 2500) |
| | | if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) { |
| | | return false; |
| | | } |
| | | |
| | | return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]); |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function hasLeadingComment$2(node) { |
| | | return node.comments && node.comments.some(function (comment) { |
| | | return comment.leading; |
| | | }); |
| | | } |
| | | |
| | | function hasTrailingComment(node) { |
| | | return node.comments && node.comments.some(function (comment) { |
| | | return comment.trailing; |
| | | }); |
| | | } |
| | | |
| | | function isCallOrOptionalCallExpression(node) { |
| | | return node.type === "CallExpression" || node.type === "OptionalCallExpression"; |
| | | } |
| | | |
| | | function hasDanglingComments(node) { |
| | | return node.comments && node.comments.some(function (comment) { |
| | | return !comment.leading && !comment.trailing; |
| | | }); |
| | | } |
| | | /** identify if an angular expression seems to have side effects */ |
| | | |
| | | |
| | | function hasNgSideEffect(path) { |
| | | return hasNode(path.getValue(), function (node) { |
| | | switch (node.type) { |
| | | case undefined: |
| | | return false; |
| | | |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | case "AssignmentExpression": |
| | | return true; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function isNgForOf(node, index, parentNode) { |
| | | return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null; |
| | | } |
| | | /** @param node {import("estree").TemplateLiteral} */ |
| | | |
| | | |
| | | function isSimpleTemplateLiteral(node) { |
| | | if (node.expressions.length === 0) { |
| | | return false; |
| | | } |
| | | |
| | | return node.expressions.every(function (expr) { |
| | | // Disallow comments since printDocToString can't print them here |
| | | if (expr.comments) { |
| | | return false; |
| | | } // Allow `x` and `this` |
| | | |
| | | |
| | | if (expr.type === "Identifier" || expr.type === "ThisExpression") { |
| | | return true; |
| | | } // Allow `a.b.c`, `a.b[c]`, and `this.x.y` |
| | | |
| | | |
| | | if (expr.type === "MemberExpression" || expr.type === "OptionalMemberExpression") { |
| | | var head = expr; |
| | | |
| | | while (head.type === "MemberExpression" || head.type === "OptionalMemberExpression") { |
| | | if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") { |
| | | return false; |
| | | } |
| | | |
| | | head = head.object; |
| | | |
| | | if (head.comments) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (head.type === "Identifier" || head.type === "ThisExpression") { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | return false; |
| | | }); |
| | | } |
| | | |
| | | function getFlowVariance(path) { |
| | | if (!path.variance) { |
| | | return null; |
| | | } // Babel 7.0 currently uses variance node type, and flow should |
| | | // follow suit soon: |
| | | // https://github.com/babel/babel/issues/4722 |
| | | |
| | | |
| | | var variance = path.variance.kind || path.variance; |
| | | |
| | | switch (variance) { |
| | | case "plus": |
| | | return "+"; |
| | | |
| | | case "minus": |
| | | return "-"; |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | return variance; |
| | | } |
| | | } |
| | | |
| | | function classPropMayCauseASIProblems(path) { |
| | | var node = path.getNode(); |
| | | |
| | | if (node.type !== "ClassProperty") { |
| | | return false; |
| | | } |
| | | |
| | | var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today |
| | | // so isn't properly tested yet. |
| | | |
| | | if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | function classChildNeedsASIProtection(node) { |
| | | if (!node) { |
| | | return; |
| | | } |
| | | |
| | | if (node.static || node.accessibility // TypeScript |
| | | ) { |
| | | return false; |
| | | } |
| | | |
| | | if (!node.computed) { |
| | | var name = node.key && node.key.name; |
| | | |
| | | if (name === "in" || name === "instanceof") { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "ClassProperty": |
| | | case "TSAbstractClassProperty": |
| | | return node.computed; |
| | | |
| | | case "MethodDefinition": // Flow |
| | | |
| | | case "TSAbstractMethodDefinition": // TypeScript |
| | | |
| | | case "ClassMethod": |
| | | case "ClassPrivateMethod": |
| | | { |
| | | // Babel |
| | | var isAsync = node.value ? node.value.async : node.async; |
| | | var isGenerator = node.value ? node.value.generator : node.generator; |
| | | |
| | | if (isAsync || node.kind === "get" || node.kind === "set") { |
| | | return false; |
| | | } |
| | | |
| | | if (node.computed || isGenerator) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | case "TSIndexSignature": |
| | | return true; |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function getTypeScriptMappedTypeModifier(tokenNode, keyword) { |
| | | if (tokenNode === "+") { |
| | | return "+" + keyword; |
| | | } else if (tokenNode === "-") { |
| | | return "-" + keyword; |
| | | } |
| | | |
| | | return keyword; |
| | | } |
| | | |
| | | function hasNewlineBetweenOrAfterDecorators(node, options) { |
| | | return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$1(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$1(node.decorators))); |
| | | } // Only space, newline, carriage return, and tab are treated as whitespace |
| | | // inside JSX. |
| | | |
| | | |
| | | var jsxWhitespaceChars = " \n\r\t"; |
| | | var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); |
| | | var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]"); // Meaningful if it contains non-whitespace characters, |
| | | // or it contains whitespace without a new line. |
| | | |
| | | function isMeaningfulJSXText(node) { |
| | | return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node))); |
| | | } |
| | | |
| | | function hasJsxIgnoreComment(path) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) { |
| | | return false; |
| | | } // Lookup the previous sibling, ignoring any empty JSXText elements |
| | | |
| | | |
| | | var index = parent.children.indexOf(node); |
| | | var prevSibling = null; |
| | | |
| | | for (var i = index; i > 0; i--) { |
| | | var candidate = parent.children[i - 1]; |
| | | |
| | | if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) { |
| | | continue; |
| | | } |
| | | |
| | | prevSibling = candidate; |
| | | break; |
| | | } |
| | | |
| | | return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) { |
| | | return comment.value.trim() === "prettier-ignore"; |
| | | }); |
| | | } |
| | | |
| | | function isEmptyJSXElement(node) { |
| | | if (node.children.length === 0) { |
| | | return true; |
| | | } |
| | | |
| | | if (node.children.length > 1) { |
| | | return false; |
| | | } // if there is one text child and does not contain any meaningful text |
| | | // we can treat the element as empty. |
| | | |
| | | |
| | | var child = node.children[0]; |
| | | return isLiteral(child) && !isMeaningfulJSXText(child); |
| | | } |
| | | |
| | | function hasPrettierIgnore$2(path) { |
| | | return hasIgnoreComment$3(path) || hasJsxIgnoreComment(path); |
| | | } |
| | | |
| | | function isLastStatement(path) { |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (!parent) { |
| | | return true; |
| | | } |
| | | |
| | | var node = path.getValue(); |
| | | var body = (parent.body || parent.consequent).filter(function (stmt) { |
| | | return stmt.type !== "EmptyStatement"; |
| | | }); |
| | | return body && body[body.length - 1] === node; |
| | | } |
| | | |
| | | function isFlowAnnotationComment(text, typeAnnotation, options) { |
| | | var start = options.locStart(typeAnnotation); |
| | | var end = skipWhitespace$1(text, options.locEnd(typeAnnotation)); |
| | | return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/"; |
| | | } |
| | | |
| | | function hasLeadingOwnLineComment(text, node, options) { |
| | | if (isJSXNode(node)) { |
| | | return hasNodeIgnoreComment$1(node); |
| | | } |
| | | |
| | | var res = node.comments && node.comments.some(function (comment) { |
| | | return comment.leading && hasNewline$3(text, options.locEnd(comment)); |
| | | }); |
| | | return res; |
| | | } // This recurses the return argument, looking for the first token |
| | | // (the leftmost leaf node) and, if it (or its parents) has any |
| | | // leadingComments, returns true (so it can be wrapped in parens). |
| | | |
| | | |
| | | function returnArgumentHasLeadingComment(options, argument) { |
| | | if (hasLeadingOwnLineComment(options.originalText, argument, options)) { |
| | | return true; |
| | | } |
| | | |
| | | if (hasNakedLeftSide(argument)) { |
| | | var leftMost = argument; |
| | | var newLeftMost; |
| | | |
| | | while (newLeftMost = getLeftSide(leftMost)) { |
| | | leftMost = newLeftMost; |
| | | |
| | | if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isStringPropSafeToCoerceToIdentifier(node, options) { |
| | | return isStringLiteral(node.key) && isIdentifierName(node.key.value) && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty"); |
| | | } |
| | | |
| | | function isJestEachTemplateLiteral(node, parentNode) { |
| | | /** |
| | | * describe.each`table`(name, fn) |
| | | * describe.only.each`table`(name, fn) |
| | | * describe.skip.each`table`(name, fn) |
| | | * test.each`table`(name, fn) |
| | | * test.only.each`table`(name, fn) |
| | | * test.skip.each`table`(name, fn) |
| | | * |
| | | * Ref: https://github.com/facebook/jest/pull/6102 |
| | | */ |
| | | var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/; |
| | | return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name)); |
| | | } |
| | | |
| | | function templateLiteralHasNewLines(template) { |
| | | return template.quasis.some(function (quasi) { |
| | | return quasi.value.raw.includes("\n"); |
| | | }); |
| | | } |
| | | |
| | | function isTemplateOnItsOwnLine(n, text, options) { |
| | | return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(text, options.locStart(n), { |
| | | backwards: true |
| | | }); |
| | | } |
| | | |
| | | function needsHardlineAfterDanglingComment(node) { |
| | | if (!node.comments) { |
| | | return false; |
| | | } |
| | | |
| | | var lastDanglingComment = getLast$1(node.comments.filter(function (comment) { |
| | | return !comment.leading && !comment.trailing; |
| | | })); |
| | | return lastDanglingComment && !comments$1.isBlockComment(lastDanglingComment); |
| | | } // If we have nested conditional expressions, we want to print them in JSX mode |
| | | // if there's at least one JSXElement somewhere in the tree. |
| | | // |
| | | // A conditional expression chain like this should be printed in normal mode, |
| | | // because there aren't JSXElements anywhere in it: |
| | | // |
| | | // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown"; |
| | | // |
| | | // But a conditional expression chain like this should be printed in JSX mode, |
| | | // because there is a JSXElement in the last ConditionalExpression: |
| | | // |
| | | // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>; |
| | | // |
| | | // This type of ConditionalExpression chain is structured like this in the AST: |
| | | // |
| | | // ConditionalExpression { |
| | | // test: ..., |
| | | // consequent: ..., |
| | | // alternate: ConditionalExpression { |
| | | // test: ..., |
| | | // consequent: ..., |
| | | // alternate: ConditionalExpression { |
| | | // test: ..., |
| | | // consequent: ..., |
| | | // alternate: ..., |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // We want to traverse over that shape and convert it into a flat structure so |
| | | // that we can find if there's a JSXElement somewhere inside. |
| | | |
| | | |
| | | function getConditionalChainContents(node) { |
| | | // Given this code: |
| | | // |
| | | // // Using a ConditionalExpression as the consequent is uncommon, but should |
| | | // // be handled. |
| | | // A ? B : C ? D : E ? F ? G : H : I |
| | | // |
| | | // which has this AST: |
| | | // |
| | | // ConditionalExpression { |
| | | // test: Identifier(A), |
| | | // consequent: Identifier(B), |
| | | // alternate: ConditionalExpression { |
| | | // test: Identifier(C), |
| | | // consequent: Identifier(D), |
| | | // alternate: ConditionalExpression { |
| | | // test: Identifier(E), |
| | | // consequent: ConditionalExpression { |
| | | // test: Identifier(F), |
| | | // consequent: Identifier(G), |
| | | // alternate: Identifier(H), |
| | | // }, |
| | | // alternate: Identifier(I), |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // we should return this Array: |
| | | // |
| | | // [ |
| | | // Identifier(A), |
| | | // Identifier(B), |
| | | // Identifier(C), |
| | | // Identifier(D), |
| | | // Identifier(E), |
| | | // Identifier(F), |
| | | // Identifier(G), |
| | | // Identifier(H), |
| | | // Identifier(I) |
| | | // ]; |
| | | // |
| | | // This loses the information about whether each node was the test, |
| | | // consequent, or alternate, but we don't care about that here- we are only |
| | | // flattening this structure to find if there's any JSXElements inside. |
| | | var nonConditionalExpressions = []; |
| | | |
| | | function recurse(node) { |
| | | if (node.type === "ConditionalExpression") { |
| | | recurse(node.test); |
| | | recurse(node.consequent); |
| | | recurse(node.alternate); |
| | | } else { |
| | | nonConditionalExpressions.push(node); |
| | | } |
| | | } |
| | | |
| | | recurse(node); |
| | | return nonConditionalExpressions; |
| | | } |
| | | |
| | | function conditionalExpressionChainContainsJSX(node) { |
| | | return Boolean(getConditionalChainContents(node).find(isJSXNode)); |
| | | } // Logic to check for args with multiple anonymous functions. For instance, |
| | | // the following call should be split on multiple lines for readability: |
| | | // source.pipe(map((x) => x + x), filter((x) => x % 2 === 0)) |
| | | |
| | | |
| | | function isFunctionCompositionArgs(args) { |
| | | if (args.length <= 1) { |
| | | return false; |
| | | } |
| | | |
| | | var count = 0; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var arg = _step.value; |
| | | |
| | | if (isFunctionOrArrowExpression(arg)) { |
| | | count += 1; |
| | | |
| | | if (count > 1) { |
| | | return true; |
| | | } |
| | | } else if (isCallOrOptionalCallExpression(arg)) { |
| | | var _iteratorNormalCompletion2 = true; |
| | | var _didIteratorError2 = false; |
| | | var _iteratorError2 = undefined; |
| | | |
| | | try { |
| | | for (var _iterator2 = arg.arguments[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
| | | var childArg = _step2.value; |
| | | |
| | | if (isFunctionOrArrowExpression(childArg)) { |
| | | return true; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError2 = true; |
| | | _iteratorError2 = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion2 && _iterator2.return != null) { |
| | | _iterator2.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError2) { |
| | | throw _iteratorError2; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } // Logic to determine if a call is a “long curried function call”. |
| | | // See https://github.com/prettier/prettier/issues/1420. |
| | | // |
| | | // `connect(a, b, c)(d)` |
| | | // In the above call expression, the second call is the parent node and the |
| | | // first call is the current node. |
| | | |
| | | |
| | | function isLongCurriedCallExpression(path) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | return isCallOrOptionalCallExpression(node) && isCallOrOptionalCallExpression(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0; |
| | | } |
| | | |
| | | function rawText(node) { |
| | | return node.extra ? node.extra.raw : node.raw; |
| | | } |
| | | |
| | | function identity$1(x) { |
| | | return x; |
| | | } |
| | | |
| | | function isTSXFile(options) { |
| | | return options.filepath && /\.tsx$/i.test(options.filepath); |
| | | } |
| | | |
| | | var utils$4 = { |
| | | classChildNeedsASIProtection: classChildNeedsASIProtection, |
| | | classPropMayCauseASIProblems: classPropMayCauseASIProblems, |
| | | conditionalExpressionChainContainsJSX: conditionalExpressionChainContainsJSX, |
| | | getFlowVariance: getFlowVariance, |
| | | getLeftSidePathName: getLeftSidePathName, |
| | | getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier, |
| | | hasDanglingComments: hasDanglingComments, |
| | | hasFlowAnnotationComment: hasFlowAnnotationComment, |
| | | hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment, |
| | | hasLeadingComment: hasLeadingComment$2, |
| | | hasLeadingOwnLineComment: hasLeadingOwnLineComment, |
| | | hasNakedLeftSide: hasNakedLeftSide, |
| | | hasNewlineBetweenOrAfterDecorators: hasNewlineBetweenOrAfterDecorators, |
| | | hasNgSideEffect: hasNgSideEffect, |
| | | hasNode: hasNode, |
| | | hasPrettierIgnore: hasPrettierIgnore$2, |
| | | hasTrailingComment: hasTrailingComment, |
| | | identity: identity$1, |
| | | isBinaryish: isBinaryish, |
| | | isCallOrOptionalCallExpression: isCallOrOptionalCallExpression, |
| | | isEmptyJSXElement: isEmptyJSXElement, |
| | | isFlowAnnotationComment: isFlowAnnotationComment, |
| | | isFunctionCompositionArgs: isFunctionCompositionArgs, |
| | | isFunctionNotation: isFunctionNotation, |
| | | isFunctionOrArrowExpression: isFunctionOrArrowExpression, |
| | | isGetterOrSetter: isGetterOrSetter, |
| | | isJestEachTemplateLiteral: isJestEachTemplateLiteral, |
| | | isJSXNode: isJSXNode, |
| | | isJSXWhitespaceExpression: isJSXWhitespaceExpression, |
| | | isLastStatement: isLastStatement, |
| | | isLiteral: isLiteral, |
| | | isLongCurriedCallExpression: isLongCurriedCallExpression, |
| | | isMeaningfulJSXText: isMeaningfulJSXText, |
| | | isMemberExpressionChain: isMemberExpressionChain, |
| | | isMemberish: isMemberish, |
| | | isNgForOf: isNgForOf, |
| | | isNumericLiteral: isNumericLiteral, |
| | | isObjectType: isObjectType, |
| | | isObjectTypePropertyAFunction: isObjectTypePropertyAFunction, |
| | | isSimpleFlowType: isSimpleFlowType, |
| | | isSimpleTemplateLiteral: isSimpleTemplateLiteral, |
| | | isStringLiteral: isStringLiteral, |
| | | isStringPropSafeToCoerceToIdentifier: isStringPropSafeToCoerceToIdentifier, |
| | | isTemplateOnItsOwnLine: isTemplateOnItsOwnLine, |
| | | isTestCall: isTestCall, |
| | | isTheOnlyJSXElementInMarkdown: isTheOnlyJSXElementInMarkdown, |
| | | isTSXFile: isTSXFile, |
| | | isTypeAnnotationAFunction: isTypeAnnotationAFunction, |
| | | matchJsxWhitespaceRegex: matchJsxWhitespaceRegex, |
| | | needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment, |
| | | rawText: rawText, |
| | | returnArgumentHasLeadingComment: returnArgumentHasLeadingComment |
| | | }; |
| | | |
| | | var getLeftSidePathName$1 = utils$4.getLeftSidePathName, |
| | | hasFlowShorthandAnnotationComment$1 = utils$4.hasFlowShorthandAnnotationComment, |
| | | hasNakedLeftSide$1 = utils$4.hasNakedLeftSide, |
| | | hasNode$1 = utils$4.hasNode; |
| | | |
| | | function hasClosureCompilerTypeCastComment(text, path) { |
| | | // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts |
| | | // Syntax example: var x = /** @type {string} */ (fruit); |
| | | var n = path.getValue(); |
| | | return isParenthesized(n) && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x); |
| | | |
| | | function hasAncestorTypeCastComment(index) { |
| | | var ancestor = path.getParentNode(index); |
| | | return ancestor && !isParenthesized(ancestor) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false; |
| | | } |
| | | |
| | | function hasTypeCastComment(node) { |
| | | return node.comments && node.comments.some(function (comment) { |
| | | return comment.leading && comments$1.isBlockComment(comment) && isTypeCastComment(comment.value); |
| | | }); |
| | | } |
| | | |
| | | function isParenthesized(node) { |
| | | // Closure typecast comments only really make sense when _not_ using |
| | | // typescript or flow parsers, so we take advantage of the babel parser's |
| | | // parenthesized expressions. |
| | | return node.extra && node.extra.parenthesized; |
| | | } |
| | | |
| | | function isTypeCastComment(comment) { |
| | | var cleaned = comment.trim().split("\n").map(function (line) { |
| | | return line.replace(/^[\s*]+/, ""); |
| | | }).join(" ").trim(); |
| | | |
| | | if (!/^@type\s*\{[^]+\}$/.test(cleaned)) { |
| | | return false; |
| | | } |
| | | |
| | | var isCompletelyClosed = false; |
| | | var unpairedBracketCount = 0; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = cleaned[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var char = _step.value; |
| | | |
| | | if (char === "{") { |
| | | if (isCompletelyClosed) { |
| | | return false; |
| | | } |
| | | |
| | | unpairedBracketCount++; |
| | | } else if (char === "}") { |
| | | if (unpairedBracketCount === 0) { |
| | | return false; |
| | | } |
| | | |
| | | unpairedBracketCount--; |
| | | |
| | | if (unpairedBracketCount === 0) { |
| | | isCompletelyClosed = true; |
| | | } |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return unpairedBracketCount === 0; |
| | | } |
| | | } |
| | | |
| | | function needsParens(path, options) { |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (!parent) { |
| | | return false; |
| | | } |
| | | |
| | | var name = path.getName(); |
| | | var node = path.getNode(); // If the value of this path is some child of a Node and not a Node |
| | | // itself, then it doesn't need parentheses. Only Node objects (in |
| | | // fact, only Expression nodes) need parentheses. |
| | | |
| | | if (path.getValue() !== node) { |
| | | return false; |
| | | } // to avoid unexpected `}}` in HTML interpolations |
| | | |
| | | |
| | | if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) { |
| | | return true; |
| | | } // Only statements don't need parentheses. |
| | | |
| | | |
| | | if (isStatement(node)) { |
| | | return false; |
| | | } // Closure compiler requires that type casted expressions to be surrounded by |
| | | // parentheses. |
| | | |
| | | |
| | | if (hasClosureCompilerTypeCastComment(options.originalText, path)) { |
| | | return true; |
| | | } |
| | | |
| | | if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow |
| | | // parser. The Flow parser turns Flow comments into type annotation nodes in its |
| | | // AST, which we handle separately. |
| | | options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) { |
| | | return true; |
| | | } // Identifiers never need parentheses. |
| | | |
| | | |
| | | if (node.type === "Identifier") { |
| | | // ...unless those identifiers are embed placeholders. They might be substituted by complex |
| | | // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS): |
| | | // let tpl = html`<script> f((${expr}) / 2); </script>`; |
| | | // If the inner JS formatter removes the parens, the expression might change its meaning: |
| | | // f((a + b) / 2) vs f(a + b / 2) |
| | | if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | if (parent.type === "ParenthesizedExpression") { |
| | | return false; |
| | | } // Add parens around the extends clause of a class. It is needed for almost |
| | | // all expressions. |
| | | |
| | | |
| | | if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression")) { |
| | | return true; |
| | | } // `export default function` or `export default class` can't be followed by |
| | | // anything after. So an expression like `export default (function(){}).toString()` |
| | | // needs to be followed by a parentheses |
| | | |
| | | |
| | | if (parent.type === "ExportDefaultDeclaration") { |
| | | return shouldWrapFunctionForExportDefault(path, options); |
| | | } |
| | | |
| | | if (parent.type === "Decorator" && parent.expression === node) { |
| | | var hasCallExpression = false; |
| | | var hasMemberExpression = false; |
| | | var current = node; |
| | | |
| | | while (current) { |
| | | switch (current.type) { |
| | | case "MemberExpression": |
| | | hasMemberExpression = true; |
| | | current = current.object; |
| | | break; |
| | | |
| | | case "CallExpression": |
| | | if ( |
| | | /** @(x().y) */ |
| | | hasMemberExpression || |
| | | /** @(x().y()) */ |
| | | hasCallExpression) { |
| | | return true; |
| | | } |
| | | |
| | | hasCallExpression = true; |
| | | current = current.callee; |
| | | break; |
| | | |
| | | case "Identifier": |
| | | return false; |
| | | |
| | | default: |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway |
| | | util.startsWithNoLookaheadToken(node, |
| | | /* forbidFunctionClassAndDoExpr */ |
| | | false) || parent.type === "ExpressionStatement" && util.startsWithNoLookaheadToken(node, |
| | | /* forbidFunctionClassAndDoExpr */ |
| | | true)) { |
| | | return true; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "SpreadElement": |
| | | case "SpreadProperty": |
| | | return parent.type === "MemberExpression" && name === "object" && parent.object === node; |
| | | |
| | | case "UpdateExpression": |
| | | if (parent.type === "UnaryExpression") { |
| | | return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-"); |
| | | } |
| | | |
| | | // else fallthrough |
| | | |
| | | case "UnaryExpression": |
| | | switch (parent.type) { |
| | | case "UnaryExpression": |
| | | return node.operator === parent.operator && (node.operator === "+" || node.operator === "-"); |
| | | |
| | | case "BindExpression": |
| | | return true; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return name === "object"; |
| | | |
| | | case "TaggedTemplateExpression": |
| | | return true; |
| | | |
| | | case "NewExpression": |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | return name === "callee"; |
| | | |
| | | case "BinaryExpression": |
| | | return parent.operator === "**" && name === "left"; |
| | | |
| | | case "TSNonNullExpression": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "BinaryExpression": |
| | | { |
| | | if (parent.type === "UpdateExpression") { |
| | | return true; |
| | | } |
| | | |
| | | var isLeftOfAForStatement = function isLeftOfAForStatement(node) { |
| | | var i = 0; |
| | | |
| | | while (node) { |
| | | var _parent = path.getParentNode(i++); |
| | | |
| | | if (!_parent) { |
| | | return false; |
| | | } |
| | | |
| | | if (_parent.type === "ForStatement" && _parent.init === node) { |
| | | return true; |
| | | } |
| | | |
| | | node = _parent; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | if (node.operator === "in" && isLeftOfAForStatement(node)) { |
| | | return true; |
| | | } |
| | | } |
| | | // fallthrough |
| | | |
| | | case "TSTypeAssertion": |
| | | case "TSAsExpression": |
| | | case "LogicalExpression": |
| | | switch (parent.type) { |
| | | case "ConditionalExpression": |
| | | return node.type === "TSAsExpression"; |
| | | |
| | | case "CallExpression": |
| | | case "NewExpression": |
| | | case "OptionalCallExpression": |
| | | return name === "callee"; |
| | | |
| | | case "ClassExpression": |
| | | case "ClassDeclaration": |
| | | return name === "superClass" && parent.superClass === node; |
| | | |
| | | case "TSTypeAssertion": |
| | | case "TaggedTemplateExpression": |
| | | case "UnaryExpression": |
| | | case "JSXSpreadAttribute": |
| | | case "SpreadElement": |
| | | case "SpreadProperty": |
| | | case "BindExpression": |
| | | case "AwaitExpression": |
| | | case "TSAsExpression": |
| | | case "TSNonNullExpression": |
| | | case "UpdateExpression": |
| | | return true; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return name === "object"; |
| | | |
| | | case "AssignmentExpression": |
| | | return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression"); |
| | | |
| | | case "LogicalExpression": |
| | | if (node.type === "LogicalExpression") { |
| | | return parent.operator !== node.operator; |
| | | } |
| | | |
| | | // else fallthrough |
| | | |
| | | case "BinaryExpression": |
| | | { |
| | | if (!node.operator && node.type !== "TSTypeAssertion") { |
| | | return true; |
| | | } |
| | | |
| | | var po = parent.operator; |
| | | var pp = util.getPrecedence(po); |
| | | var no = node.operator; |
| | | var np = util.getPrecedence(no); |
| | | |
| | | if (pp > np) { |
| | | return true; |
| | | } |
| | | |
| | | if (pp === np && name === "right") { |
| | | assert.strictEqual(parent.right, node); |
| | | return true; |
| | | } |
| | | |
| | | if (pp === np && !util.shouldFlatten(po, no)) { |
| | | return true; |
| | | } |
| | | |
| | | if (pp < np && no === "%") { |
| | | return po === "+" || po === "-"; |
| | | } // Add parenthesis when working with bitwise operators |
| | | // It's not strictly needed but helps with code understanding |
| | | |
| | | |
| | | if (util.isBitwiseOperator(po)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "SequenceExpression": |
| | | switch (parent.type) { |
| | | case "ReturnStatement": |
| | | return false; |
| | | |
| | | case "ForStatement": |
| | | // Although parentheses wouldn't hurt around sequence |
| | | // expressions in the head of for loops, traditional style |
| | | // dictates that e.g. i++, j++ should not be wrapped with |
| | | // parentheses. |
| | | return false; |
| | | |
| | | case "ExpressionStatement": |
| | | return name !== "expression"; |
| | | |
| | | case "ArrowFunctionExpression": |
| | | // We do need parentheses, but SequenceExpressions are handled |
| | | // specially when printing bodies of arrow functions. |
| | | return name !== "body"; |
| | | |
| | | default: |
| | | // Otherwise err on the side of overparenthesization, adding |
| | | // explicit exceptions above if this proves overzealous. |
| | | return true; |
| | | } |
| | | |
| | | case "YieldExpression": |
| | | if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") { |
| | | return true; |
| | | } |
| | | |
| | | // else fallthrough |
| | | |
| | | case "AwaitExpression": |
| | | switch (parent.type) { |
| | | case "TaggedTemplateExpression": |
| | | case "UnaryExpression": |
| | | case "BinaryExpression": |
| | | case "LogicalExpression": |
| | | case "SpreadElement": |
| | | case "SpreadProperty": |
| | | case "TSAsExpression": |
| | | case "TSNonNullExpression": |
| | | case "BindExpression": |
| | | return true; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return name === "object"; |
| | | |
| | | case "NewExpression": |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | return name === "callee"; |
| | | |
| | | case "ConditionalExpression": |
| | | return parent.test === node; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "TSConditionalType": |
| | | if (parent.type === "TSConditionalType" && node === parent.extendsType) { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "TSFunctionType": |
| | | case "TSConstructorType": |
| | | if (parent.type === "TSConditionalType" && node === parent.checkType) { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "TSUnionType": |
| | | case "TSIntersectionType": |
| | | if (parent.type === "TSUnionType" || parent.type === "TSIntersectionType") { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "TSTypeOperator": |
| | | case "TSInferType": |
| | | return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || parent.type === "TSIndexedAccessType" && node === parent.objectType || parent.type === "TSTypeOperator"; |
| | | |
| | | case "ArrayTypeAnnotation": |
| | | return parent.type === "NullableTypeAnnotation"; |
| | | |
| | | case "IntersectionTypeAnnotation": |
| | | case "UnionTypeAnnotation": |
| | | return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation"; |
| | | |
| | | case "NullableTypeAnnotation": |
| | | return parent.type === "ArrayTypeAnnotation"; |
| | | |
| | | case "FunctionTypeAnnotation": |
| | | { |
| | | var ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent; |
| | | return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses |
| | | // are really needed, but since ??T doesn't make sense this check |
| | | // will almost never be true. |
| | | ancestor.type === "NullableTypeAnnotation"; |
| | | } |
| | | |
| | | case "StringLiteral": |
| | | case "NumericLiteral": |
| | | case "Literal": |
| | | if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2 |
| | | // See corresponding workaround in printer.js case: "Literal" |
| | | options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) { |
| | | // To avoid becoming a directive |
| | | var grandParent = path.getParentNode(1); |
| | | return grandParent.type === "Program" || grandParent.type === "BlockStatement"; |
| | | } |
| | | |
| | | return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node; |
| | | |
| | | case "AssignmentExpression": |
| | | { |
| | | var _grandParent = path.getParentNode(1); |
| | | |
| | | if (parent.type === "ArrowFunctionExpression" && parent.body === node) { |
| | | return true; |
| | | } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) { |
| | | return false; |
| | | } else if (parent.type === "TSPropertySignature" && parent.name === node) { |
| | | return false; |
| | | } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) { |
| | | return false; |
| | | } else if (parent.type === "ExpressionStatement") { |
| | | return node.left.type === "ObjectPattern"; |
| | | } else if (parent.type === "TSPropertySignature" && parent.key === node) { |
| | | return false; |
| | | } else if (parent.type === "AssignmentExpression") { |
| | | return false; |
| | | } else if (parent.type === "SequenceExpression" && _grandParent && _grandParent.type === "ForStatement" && (_grandParent.init === parent || _grandParent.update === parent)) { |
| | | return false; |
| | | } else if (parent.type === "Property" && parent.value === node) { |
| | | return false; |
| | | } else if (parent.type === "NGChainedExpression") { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | case "ConditionalExpression": |
| | | switch (parent.type) { |
| | | case "TaggedTemplateExpression": |
| | | case "UnaryExpression": |
| | | case "SpreadElement": |
| | | case "SpreadProperty": |
| | | case "BinaryExpression": |
| | | case "LogicalExpression": |
| | | case "NGPipeExpression": |
| | | case "ExportDefaultDeclaration": |
| | | case "AwaitExpression": |
| | | case "JSXSpreadAttribute": |
| | | case "TSTypeAssertion": |
| | | case "TypeCastExpression": |
| | | case "TSAsExpression": |
| | | case "TSNonNullExpression": |
| | | return true; |
| | | |
| | | case "NewExpression": |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | return name === "callee"; |
| | | |
| | | case "ConditionalExpression": |
| | | return name === "test" && parent.test === node; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return name === "object"; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "FunctionExpression": |
| | | switch (parent.type) { |
| | | case "NewExpression": |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | // Not always necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses. |
| | | // Is necessary if it is `expression` of `ExpressionStatement`. |
| | | return name === "callee"; |
| | | |
| | | case "TaggedTemplateExpression": |
| | | return true; |
| | | // This is basically a kind of IIFE. |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "ArrowFunctionExpression": |
| | | switch (parent.type) { |
| | | case "NewExpression": |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | return name === "callee"; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | return name === "object"; |
| | | |
| | | case "TSAsExpression": |
| | | case "BindExpression": |
| | | case "TaggedTemplateExpression": |
| | | case "UnaryExpression": |
| | | case "LogicalExpression": |
| | | case "BinaryExpression": |
| | | case "AwaitExpression": |
| | | case "TSTypeAssertion": |
| | | return true; |
| | | |
| | | case "ConditionalExpression": |
| | | return name === "test"; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "ClassExpression": |
| | | switch (parent.type) { |
| | | case "NewExpression": |
| | | return name === "callee" && parent.callee === node; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | case "OptionalMemberExpression": |
| | | case "OptionalCallExpression": |
| | | if ((parent.type === "MemberExpression" && name === "object" || parent.type === "CallExpression" && name === "callee") && // workaround for https://github.com/facebook/flow/issues/8159 |
| | | !(options.parser === "flow" && parent.range[0] === node.range[0])) { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "CallExpression": |
| | | case "MemberExpression": |
| | | case "TaggedTemplateExpression": |
| | | case "TSNonNullExpression": |
| | | if ((parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee") { |
| | | var object = node; |
| | | |
| | | while (object) { |
| | | switch (object.type) { |
| | | case "CallExpression": |
| | | case "OptionalCallExpression": |
| | | return true; |
| | | |
| | | case "MemberExpression": |
| | | case "OptionalMemberExpression": |
| | | case "BindExpression": |
| | | object = object.object; |
| | | break; |
| | | // tagged templates are basically member expressions from a grammar perspective |
| | | // see https://tc39.github.io/ecma262/#prod-MemberExpression |
| | | |
| | | case "TaggedTemplateExpression": |
| | | object = object.tag; |
| | | break; |
| | | |
| | | case "TSNonNullExpression": |
| | | object = object.expression; |
| | | break; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | |
| | | case "BindExpression": |
| | | return (parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && name === "object"; |
| | | |
| | | case "NGPipeExpression": |
| | | if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | |
| | | case "JSXFragment": |
| | | case "JSXElement": |
| | | return name === "callee" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "CallExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && parent.type !== "ObjectProperty" && parent.type !== "OptionalCallExpression" && parent.type !== "Property" && parent.type !== "ReturnStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator"; |
| | | |
| | | case "TypeAnnotation": |
| | | return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isStatement(node) { |
| | | return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement"; |
| | | } |
| | | |
| | | function includesFunctionTypeInObjectType(node) { |
| | | return hasNode$1(node, function (n1) { |
| | | return n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, function (n2) { |
| | | return n2.type === "FunctionTypeAnnotation" || undefined; |
| | | }) || undefined; |
| | | }); |
| | | } |
| | | |
| | | function endsWithRightBracket(node) { |
| | | switch (node.type) { |
| | | case "ObjectExpression": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function isFollowedByRightBracket(path) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | var name = path.getName(); |
| | | |
| | | switch (parent.type) { |
| | | case "NGPipeExpression": |
| | | if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) { |
| | | return path.callParent(isFollowedByRightBracket); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "ObjectProperty": |
| | | if (name === "value") { |
| | | var parentParent = path.getParentNode(1); |
| | | return parentParent.properties[parentParent.properties.length - 1] === parent; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "BinaryExpression": |
| | | case "LogicalExpression": |
| | | if (name === "right") { |
| | | return path.callParent(isFollowedByRightBracket); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "ConditionalExpression": |
| | | if (name === "alternate") { |
| | | return path.callParent(isFollowedByRightBracket); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "UnaryExpression": |
| | | if (parent.prefix) { |
| | | return path.callParent(isFollowedByRightBracket); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function shouldWrapFunctionForExportDefault(path, options) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (node.type === "FunctionExpression" || node.type === "ClassExpression") { |
| | | return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped |
| | | // (e.g. `export default (function() {})();`) |
| | | // in this case we don't need to add extra parens |
| | | !needsParens(path, options); |
| | | } |
| | | |
| | | if (!hasNakedLeftSide$1(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) { |
| | | return false; |
| | | } |
| | | |
| | | return path.call.apply(path, [function (childPath) { |
| | | return shouldWrapFunctionForExportDefault(childPath, options); |
| | | }].concat(getLeftSidePathName$1(path, node))); |
| | | } |
| | | |
| | | var needsParens_1 = needsParens; |
| | | |
| | | var _require$$0$builders$6 = doc.builders, |
| | | concat$c = _require$$0$builders$6.concat, |
| | | join$8 = _require$$0$builders$6.join, |
| | | line$6 = _require$$0$builders$6.line; |
| | | |
| | | function printHtmlBinding(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | if (options.__onHtmlBindingRoot && path.getName() === null) { |
| | | options.__onHtmlBindingRoot(node); |
| | | } |
| | | |
| | | if (node.type !== "File") { |
| | | return; |
| | | } |
| | | |
| | | if (options.__isVueForBindingLeft) { |
| | | return path.call(function (functionDeclarationPath) { |
| | | var _functionDeclarationP = functionDeclarationPath.getValue(), |
| | | params = _functionDeclarationP.params; |
| | | |
| | | return concat$c([params.length > 1 ? "(" : "", join$8(concat$c([",", line$6]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]); |
| | | }, "program", "body", 0); |
| | | } |
| | | |
| | | if (options.__isVueSlotScope) { |
| | | return path.call(function (functionDeclarationPath) { |
| | | return join$8(concat$c([",", line$6]), functionDeclarationPath.map(print, "params")); |
| | | }, "program", "body", 0); |
| | | } |
| | | } // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression() |
| | | |
| | | |
| | | function isVueEventBindingExpression$2(node) { |
| | | switch (node.type) { |
| | | case "MemberExpression": |
| | | switch (node.property.type) { |
| | | case "Identifier": |
| | | case "NumericLiteral": |
| | | case "StringLiteral": |
| | | return isVueEventBindingExpression$2(node.object); |
| | | } |
| | | |
| | | return false; |
| | | |
| | | case "Identifier": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | var htmlBinding = { |
| | | isVueEventBindingExpression: isVueEventBindingExpression$2, |
| | | printHtmlBinding: printHtmlBinding |
| | | }; |
| | | |
| | | function preprocess$1(ast, options) { |
| | | switch (options.parser) { |
| | | case "json": |
| | | case "json5": |
| | | case "json-stringify": |
| | | case "__js_expression": |
| | | case "__vue_expression": |
| | | return Object.assign({}, ast, { |
| | | type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot", |
| | | node: ast, |
| | | comments: [] |
| | | }); |
| | | |
| | | default: |
| | | return ast; |
| | | } |
| | | } |
| | | |
| | | var preprocess_1$1 = preprocess$1; |
| | | |
| | | var getParentExportDeclaration$1 = util.getParentExportDeclaration, |
| | | isExportDeclaration$1 = util.isExportDeclaration, |
| | | shouldFlatten$1 = util.shouldFlatten, |
| | | getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter, |
| | | hasNewline$4 = util.hasNewline, |
| | | hasNewlineInRange$2 = util.hasNewlineInRange, |
| | | getLast$2 = util.getLast, |
| | | getStringWidth$2 = util.getStringWidth, |
| | | printString$2 = util.printString, |
| | | printNumber$2 = util.printNumber, |
| | | hasIgnoreComment$4 = util.hasIgnoreComment, |
| | | hasNodeIgnoreComment$2 = util.hasNodeIgnoreComment, |
| | | getPenultimate$1 = util.getPenultimate, |
| | | startsWithNoLookaheadToken$1 = util.startsWithNoLookaheadToken, |
| | | getIndentSize$1 = util.getIndentSize, |
| | | matchAncestorTypes$1 = util.matchAncestorTypes, |
| | | getPreferredQuote$1 = util.getPreferredQuote; |
| | | var isNextLineEmpty$4 = utilShared.isNextLineEmpty, |
| | | isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex, |
| | | getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex; |
| | | var insertPragma$7 = pragma.insertPragma; |
| | | var printHtmlBinding$1 = htmlBinding.printHtmlBinding, |
| | | isVueEventBindingExpression$3 = htmlBinding.isVueEventBindingExpression; |
| | | var classChildNeedsASIProtection$1 = utils$4.classChildNeedsASIProtection, |
| | | classPropMayCauseASIProblems$1 = utils$4.classPropMayCauseASIProblems, |
| | | conditionalExpressionChainContainsJSX$1 = utils$4.conditionalExpressionChainContainsJSX, |
| | | getFlowVariance$1 = utils$4.getFlowVariance, |
| | | getLeftSidePathName$2 = utils$4.getLeftSidePathName, |
| | | getTypeScriptMappedTypeModifier$1 = utils$4.getTypeScriptMappedTypeModifier, |
| | | hasDanglingComments$1 = utils$4.hasDanglingComments, |
| | | hasFlowAnnotationComment$1 = utils$4.hasFlowAnnotationComment, |
| | | hasFlowShorthandAnnotationComment$2 = utils$4.hasFlowShorthandAnnotationComment, |
| | | hasLeadingComment$3 = utils$4.hasLeadingComment, |
| | | hasLeadingOwnLineComment$1 = utils$4.hasLeadingOwnLineComment, |
| | | hasNakedLeftSide$2 = utils$4.hasNakedLeftSide, |
| | | hasNewlineBetweenOrAfterDecorators$1 = utils$4.hasNewlineBetweenOrAfterDecorators, |
| | | hasNgSideEffect$1 = utils$4.hasNgSideEffect, |
| | | hasPrettierIgnore$3 = utils$4.hasPrettierIgnore, |
| | | hasTrailingComment$1 = utils$4.hasTrailingComment, |
| | | identity$2 = utils$4.identity, |
| | | isBinaryish$1 = utils$4.isBinaryish, |
| | | isCallOrOptionalCallExpression$1 = utils$4.isCallOrOptionalCallExpression, |
| | | isEmptyJSXElement$1 = utils$4.isEmptyJSXElement, |
| | | isFlowAnnotationComment$1 = utils$4.isFlowAnnotationComment, |
| | | isFunctionCompositionArgs$1 = utils$4.isFunctionCompositionArgs, |
| | | isFunctionNotation$1 = utils$4.isFunctionNotation, |
| | | isFunctionOrArrowExpression$1 = utils$4.isFunctionOrArrowExpression, |
| | | isGetterOrSetter$1 = utils$4.isGetterOrSetter, |
| | | isJestEachTemplateLiteral$1 = utils$4.isJestEachTemplateLiteral, |
| | | isJSXNode$1 = utils$4.isJSXNode, |
| | | isJSXWhitespaceExpression$1 = utils$4.isJSXWhitespaceExpression, |
| | | isLastStatement$1 = utils$4.isLastStatement, |
| | | isLiteral$1 = utils$4.isLiteral, |
| | | isLongCurriedCallExpression$1 = utils$4.isLongCurriedCallExpression, |
| | | isMeaningfulJSXText$1 = utils$4.isMeaningfulJSXText, |
| | | isMemberExpressionChain$1 = utils$4.isMemberExpressionChain, |
| | | isMemberish$1 = utils$4.isMemberish, |
| | | isNgForOf$1 = utils$4.isNgForOf, |
| | | isNumericLiteral$1 = utils$4.isNumericLiteral, |
| | | isObjectType$1 = utils$4.isObjectType, |
| | | isObjectTypePropertyAFunction$1 = utils$4.isObjectTypePropertyAFunction, |
| | | isSimpleFlowType$1 = utils$4.isSimpleFlowType, |
| | | isSimpleTemplateLiteral$1 = utils$4.isSimpleTemplateLiteral, |
| | | isStringLiteral$1 = utils$4.isStringLiteral, |
| | | isStringPropSafeToCoerceToIdentifier$1 = utils$4.isStringPropSafeToCoerceToIdentifier, |
| | | isTemplateOnItsOwnLine$1 = utils$4.isTemplateOnItsOwnLine, |
| | | isTestCall$1 = utils$4.isTestCall, |
| | | isTheOnlyJSXElementInMarkdown$1 = utils$4.isTheOnlyJSXElementInMarkdown, |
| | | isTSXFile$1 = utils$4.isTSXFile, |
| | | isTypeAnnotationAFunction$1 = utils$4.isTypeAnnotationAFunction, |
| | | matchJsxWhitespaceRegex$1 = utils$4.matchJsxWhitespaceRegex, |
| | | needsHardlineAfterDanglingComment$1 = utils$4.needsHardlineAfterDanglingComment, |
| | | rawText$1 = utils$4.rawText, |
| | | returnArgumentHasLeadingComment$1 = utils$4.returnArgumentHasLeadingComment; |
| | | var needsQuoteProps = new WeakMap(); |
| | | var _require$$5$builders = doc.builders, |
| | | concat$d = _require$$5$builders.concat, |
| | | join$9 = _require$$5$builders.join, |
| | | line$7 = _require$$5$builders.line, |
| | | hardline$9 = _require$$5$builders.hardline, |
| | | softline$6 = _require$$5$builders.softline, |
| | | literalline$4 = _require$$5$builders.literalline, |
| | | group$b = _require$$5$builders.group, |
| | | indent$7 = _require$$5$builders.indent, |
| | | align$1 = _require$$5$builders.align, |
| | | conditionalGroup$1 = _require$$5$builders.conditionalGroup, |
| | | fill$4 = _require$$5$builders.fill, |
| | | ifBreak$6 = _require$$5$builders.ifBreak, |
| | | breakParent$3 = _require$$5$builders.breakParent, |
| | | lineSuffixBoundary$1 = _require$$5$builders.lineSuffixBoundary, |
| | | addAlignmentToDoc$2 = _require$$5$builders.addAlignmentToDoc, |
| | | dedent$2 = _require$$5$builders.dedent, |
| | | _require$$5$utils = doc.utils, |
| | | willBreak$1 = _require$$5$utils.willBreak, |
| | | isLineNext$1 = _require$$5$utils.isLineNext, |
| | | isEmpty$1 = _require$$5$utils.isEmpty, |
| | | removeLines$2 = _require$$5$utils.removeLines, |
| | | printDocToString$1 = doc.printer.printDocToString; |
| | | var uid = 0; |
| | | |
| | | function shouldPrintComma$1(options, level) { |
| | | level = level || "es5"; |
| | | |
| | | switch (options.trailingComma) { |
| | | case "all": |
| | | if (level === "all") { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "es5": |
| | | if (level === "es5") { |
| | | return true; |
| | | } |
| | | |
| | | // fallthrough |
| | | |
| | | case "none": |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function genericPrint$3(path, options, printPath, args) { |
| | | var node = path.getValue(); |
| | | var needsParens = false; |
| | | var linesWithoutParens = printPathNoParens(path, options, printPath, args); |
| | | |
| | | if (!node || isEmpty$1(linesWithoutParens)) { |
| | | return linesWithoutParens; |
| | | } |
| | | |
| | | var parentExportDecl = getParentExportDeclaration$1(path); |
| | | var decorators = []; |
| | | |
| | | if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") ; else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator |
| | | // was written before the export, the export will be responsible |
| | | // for printing the decorators. |
| | | !(parentExportDecl && options.locStart(parentExportDecl, { |
| | | ignoreDecorators: true |
| | | }) > options.locStart(node.decorators[0]))) { |
| | | var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators$1(node, options); |
| | | var separator = shouldBreak ? hardline$9 : line$7; |
| | | path.each(function (decoratorPath) { |
| | | var decorator = decoratorPath.getValue(); |
| | | |
| | | if (decorator.expression) { |
| | | decorator = decorator.expression; |
| | | } else { |
| | | decorator = decorator.callee; |
| | | } |
| | | |
| | | decorators.push(printPath(decoratorPath), separator); |
| | | }, "decorators"); |
| | | |
| | | if (parentExportDecl) { |
| | | decorators.unshift(hardline$9); |
| | | } |
| | | } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 && // Only print decorators here if they were written before the export, |
| | | // otherwise they are printed by the node.declaration |
| | | options.locStart(node, { |
| | | ignoreDecorators: true |
| | | }) > options.locStart(node.declaration.decorators[0])) { |
| | | // Export declarations are responsible for printing any decorators |
| | | // that logically apply to node.declaration. |
| | | path.each(function (decoratorPath) { |
| | | var decorator = decoratorPath.getValue(); |
| | | var prefix = decorator.type === "Decorator" ? "" : "@"; |
| | | decorators.push(prefix, printPath(decoratorPath), hardline$9); |
| | | }, "declaration", "decorators"); |
| | | } else { |
| | | // Nodes with decorators can't have parentheses, so we can avoid |
| | | // computing pathNeedsParens() except in this case. |
| | | needsParens = needsParens_1(path, options); |
| | | } |
| | | |
| | | var parts = []; |
| | | |
| | | if (needsParens) { |
| | | parts.unshift("("); |
| | | } |
| | | |
| | | parts.push(linesWithoutParens); |
| | | |
| | | if (needsParens) { |
| | | var _node = path.getValue(); |
| | | |
| | | if (hasFlowShorthandAnnotationComment$2(_node)) { |
| | | parts.push(" /*"); |
| | | parts.push(_node.trailingComments[0].value.trimLeft()); |
| | | parts.push("*/"); |
| | | _node.trailingComments[0].printed = true; |
| | | } |
| | | |
| | | parts.push(")"); |
| | | } |
| | | |
| | | if (decorators.length > 0) { |
| | | return group$b(concat$d(decorators.concat(parts))); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printDecorators(path, options, print) { |
| | | var node = path.getValue(); |
| | | return group$b(concat$d([join$9(line$7, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators$1(node, options) ? hardline$9 : line$7])); |
| | | } |
| | | /** |
| | | * The following is the shared logic for |
| | | * ternary operators, namely ConditionalExpression |
| | | * and TSConditionalType |
| | | * @typedef {Object} OperatorOptions |
| | | * @property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`. |
| | | * @property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print after the conditional expression. |
| | | * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode. |
| | | * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType". |
| | | * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent". |
| | | * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate". |
| | | * @property {string} testNodePropertyName - The property at which the test node can be found on the main node, eg "test". |
| | | * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks. |
| | | * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node. |
| | | * @param {Options} options - Prettier options |
| | | * @param {Function} print - Print function to call recursively |
| | | * @param {OperatorOptions} operatorOptions |
| | | * @returns Doc |
| | | */ |
| | | |
| | | |
| | | function printTernaryOperator(path, options, print, operatorOptions) { |
| | | var node = path.getValue(); |
| | | var testNode = node[operatorOptions.testNodePropertyName]; |
| | | var consequentNode = node[operatorOptions.consequentNodePropertyName]; |
| | | var alternateNode = node[operatorOptions.alternateNodePropertyName]; |
| | | var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode". |
| | | // See tests/jsx/conditional-expression.js for more info. |
| | | |
| | | var jsxMode = false; |
| | | var parent = path.getParentNode(); |
| | | var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost |
| | | // ConditionalExpression parent. We'll use these to determine if we should |
| | | // print in JSX mode. |
| | | |
| | | var currentParent; |
| | | var previousParent; |
| | | var i = 0; |
| | | |
| | | do { |
| | | previousParent = currentParent || node; |
| | | currentParent = path.getParentNode(i); |
| | | i++; |
| | | } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType); |
| | | |
| | | var firstNonConditionalParent = currentParent || parent; |
| | | var lastConditionalParent = previousParent; |
| | | |
| | | if (operatorOptions.shouldCheckJsx && (isJSXNode$1(testNode) || isJSXNode$1(consequentNode) || isJSXNode$1(alternateNode) || conditionalExpressionChainContainsJSX$1(lastConditionalParent))) { |
| | | jsxMode = true; |
| | | forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in |
| | | // parens when using ?: within JSX, because the parens are analogous to |
| | | // curly braces in an if statement. |
| | | |
| | | var wrap = function wrap(doc) { |
| | | return concat$d([ifBreak$6("(", ""), indent$7(concat$d([softline$6, doc])), softline$6, ifBreak$6(")", "")]); |
| | | }; // The only things we don't wrap are: |
| | | // * Nested conditional expressions in alternates |
| | | // * null |
| | | |
| | | |
| | | var isNull = function isNull(node) { |
| | | return node.type === "NullLiteral" || node.type === "Literal" && node.value === null; |
| | | }; |
| | | |
| | | parts.push(" ? ", isNull(consequentNode) ? path.call(print, operatorOptions.consequentNodePropertyName) : wrap(path.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNull(alternateNode) ? path.call(print, operatorOptions.alternateNodePropertyName) : wrap(path.call(print, operatorOptions.alternateNodePropertyName))); |
| | | } else { |
| | | // normal mode |
| | | var part = concat$d([line$7, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", "(") : "", align$1(2, path.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", ")") : "", line$7, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path.call(print, operatorOptions.alternateNodePropertyName))]); |
| | | parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node ? part : options.useTabs ? dedent$2(indent$7(part)) : align$1(Math.max(0, options.tabWidth - 2), part)); |
| | | } // We want a whole chain of ConditionalExpressions to all |
| | | // break if any of them break. That means we should only group around the |
| | | // outer-most ConditionalExpression. |
| | | |
| | | |
| | | var maybeGroup = function maybeGroup(doc) { |
| | | return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$b(doc) : doc : group$b(doc); |
| | | }; // Break the closing paren to keep the chain right after it: |
| | | // (a |
| | | // ? b |
| | | // : c |
| | | // ).call() |
| | | |
| | | |
| | | var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression" || parent.type === "NGPipeExpression" && parent.left === node && operatorOptions.breakNested) && !parent.computed; |
| | | return maybeGroup(concat$d([].concat(function (testDoc) { |
| | | return ( |
| | | /** |
| | | * a |
| | | * ? b |
| | | * : multiline |
| | | * test |
| | | * node |
| | | * ^^ align(2) |
| | | * ? d |
| | | * : e |
| | | */ |
| | | parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc |
| | | ); |
| | | }(concat$d(operatorOptions.beforeParts())), forceNoIndent ? concat$d(parts) : indent$7(concat$d(parts)), operatorOptions.afterParts(breakClosingParen)))); |
| | | } |
| | | |
| | | function printPathNoParens(path, options, print, args) { |
| | | var n = path.getValue(); |
| | | var semi = options.semi ? ";" : ""; |
| | | |
| | | if (!n) { |
| | | return ""; |
| | | } |
| | | |
| | | if (typeof n === "string") { |
| | | return n; |
| | | } |
| | | |
| | | var htmlBinding = printHtmlBinding$1(path, options, print); |
| | | |
| | | if (htmlBinding) { |
| | | return htmlBinding; |
| | | } |
| | | |
| | | var parts = []; |
| | | |
| | | switch (n.type) { |
| | | case "JsExpressionRoot": |
| | | return path.call(print, "node"); |
| | | |
| | | case "JsonRoot": |
| | | return concat$d([path.call(print, "node"), hardline$9]); |
| | | |
| | | case "File": |
| | | // Print @babel/parser's InterpreterDirective here so that |
| | | // leading comments on the `Program` node get printed after the hashbang. |
| | | if (n.program && n.program.interpreter) { |
| | | parts.push(path.call(function (programPath) { |
| | | return programPath.call(print, "interpreter"); |
| | | }, "program")); |
| | | } |
| | | |
| | | parts.push(path.call(print, "program")); |
| | | return concat$d(parts); |
| | | |
| | | case "Program": |
| | | // Babel 6 |
| | | if (n.directives) { |
| | | path.each(function (childPath) { |
| | | parts.push(print(childPath), semi, hardline$9); |
| | | |
| | | if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) { |
| | | parts.push(hardline$9); |
| | | } |
| | | }, "directives"); |
| | | } |
| | | |
| | | parts.push(path.call(function (bodyPath) { |
| | | return printStatementSequence(bodyPath, options, print); |
| | | }, "body")); |
| | | parts.push(comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true)); // Only force a trailing newline if there were any contents. |
| | | |
| | | if (n.body.length || n.comments) { |
| | | parts.push(hardline$9); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | // Babel extension. |
| | | |
| | | case "EmptyStatement": |
| | | return ""; |
| | | |
| | | case "ExpressionStatement": |
| | | // Detect Flow-parsed directives |
| | | if (n.directive) { |
| | | return concat$d([nodeStr(n.expression, options, true), semi]); |
| | | } |
| | | |
| | | if (options.parser === "__vue_event_binding") { |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) { |
| | | return concat$d([path.call(print, "expression"), isVueEventBindingExpression$3(n.expression) ? ";" : ""]); |
| | | } |
| | | } // Do not append semicolon after the only JSX element in a program |
| | | |
| | | |
| | | return concat$d([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown$1(options, path) ? "" : semi]); |
| | | // Babel extension. |
| | | |
| | | case "ParenthesizedExpression": |
| | | return concat$d(["(", path.call(print, "expression"), ")"]); |
| | | |
| | | case "AssignmentExpression": |
| | | return printAssignment(n.left, path.call(print, "left"), concat$d([" ", n.operator]), n.right, path.call(print, "right"), options); |
| | | |
| | | case "BinaryExpression": |
| | | case "LogicalExpression": |
| | | case "NGPipeExpression": |
| | | { |
| | | var _parent = path.getParentNode(); |
| | | |
| | | var parentParent = path.getParentNode(1); |
| | | var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "SwitchStatement" || _parent.type === "DoWhileStatement"); |
| | | |
| | | var _parts = printBinaryishExpressions(path, print, options, |
| | | /* isNested */ |
| | | false, isInsideParenthesis); // if ( |
| | | // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft |
| | | // ) { |
| | | // |
| | | // looks super weird, we want to break the children if the parent breaks |
| | | // |
| | | // if ( |
| | | // this.hasPlugin("dynamicImports") && |
| | | // this.lookahead().type === tt.parenLeft |
| | | // ) { |
| | | |
| | | |
| | | if (isInsideParenthesis) { |
| | | return concat$d(_parts); |
| | | } // Break between the parens in |
| | | // unaries or in a member or specific call expression, i.e. |
| | | // |
| | | // ( |
| | | // a && |
| | | // b && |
| | | // c |
| | | // ).call() |
| | | |
| | | |
| | | if ((_parent.type === "CallExpression" || _parent.type === "OptionalCallExpression") && _parent.callee === n || _parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) { |
| | | return group$b(concat$d([indent$7(concat$d([softline$6, concat$d(_parts)])), softline$6])); |
| | | } // Avoid indenting sub-expressions in some cases where the first sub-expression is already |
| | | // indented accordingly. We should indent sub-expressions where the first case isn't indented. |
| | | |
| | | |
| | | var shouldNotIndent = _parent.type === "ReturnStatement" || _parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.type !== "NGPipeExpression" && (_parent.type === "NGRoot" && options.parser === "__ng_binding" || _parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === _parent.body && _parent.type === "ArrowFunctionExpression" || n !== _parent.body && _parent.type === "ForStatement" || _parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "CallExpression" && parentParent.type !== "OptionalCallExpression"; |
| | | var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property"; |
| | | var samePrecedenceSubExpression = isBinaryish$1(n.left) && shouldFlatten$1(n.operator, n.left.operator); |
| | | |
| | | if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) { |
| | | return group$b(concat$d(_parts)); |
| | | } |
| | | |
| | | if (_parts.length === 0) { |
| | | return ""; |
| | | } // If the right part is a JSX node, we include it in a separate group to |
| | | // prevent it breaking the whole chain, so we can print the expression like: |
| | | // |
| | | // foo && bar && ( |
| | | // <Foo> |
| | | // <Bar /> |
| | | // </Foo> |
| | | // ) |
| | | |
| | | |
| | | var hasJSX = isJSXNode$1(n.right); |
| | | var rest = concat$d(hasJSX ? _parts.slice(1, -1) : _parts.slice(1)); |
| | | var groupId = Symbol("logicalChain-" + ++uid); |
| | | var chain = group$b(concat$d([// Don't include the initial expression in the indentation |
| | | // level. The first item is guaranteed to be the first |
| | | // left-most expression. |
| | | _parts.length > 0 ? _parts[0] : "", indent$7(rest)]), { |
| | | id: groupId |
| | | }); |
| | | |
| | | if (!hasJSX) { |
| | | return chain; |
| | | } |
| | | |
| | | var jsxPart = getLast$2(_parts); |
| | | return group$b(concat$d([chain, ifBreak$6(indent$7(jsxPart), jsxPart, { |
| | | groupId: groupId |
| | | })])); |
| | | } |
| | | |
| | | case "AssignmentPattern": |
| | | return concat$d([path.call(print, "left"), " = ", path.call(print, "right")]); |
| | | |
| | | case "TSTypeAssertion": |
| | | { |
| | | var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression"); |
| | | var castGroup = group$b(concat$d(["<", indent$7(concat$d([softline$6, path.call(print, "typeAnnotation")])), softline$6, ">"])); |
| | | var exprContents = concat$d([ifBreak$6("("), indent$7(concat$d([softline$6, path.call(print, "expression")])), softline$6, ifBreak$6(")")]); |
| | | |
| | | if (shouldBreakAfterCast) { |
| | | return conditionalGroup$1([concat$d([castGroup, path.call(print, "expression")]), concat$d([castGroup, group$b(exprContents, { |
| | | shouldBreak: true |
| | | })]), concat$d([castGroup, path.call(print, "expression")])]); |
| | | } |
| | | |
| | | return group$b(concat$d([castGroup, path.call(print, "expression")])); |
| | | } |
| | | |
| | | case "OptionalMemberExpression": |
| | | case "MemberExpression": |
| | | { |
| | | var _parent2 = path.getParentNode(); |
| | | |
| | | var firstNonMemberParent; |
| | | var i = 0; |
| | | |
| | | do { |
| | | firstNonMemberParent = path.getParentNode(i); |
| | | i++; |
| | | } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression")); |
| | | |
| | | var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent2.type !== "MemberExpression" && _parent2.type !== "OptionalMemberExpression"; |
| | | return concat$d([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$b(indent$7(concat$d([softline$6, printMemberLookup(path, options, print)])))]); |
| | | } |
| | | |
| | | case "MetaProperty": |
| | | return concat$d([path.call(print, "meta"), ".", path.call(print, "property")]); |
| | | |
| | | case "BindExpression": |
| | | if (n.object) { |
| | | parts.push(path.call(print, "object")); |
| | | } |
| | | |
| | | parts.push(group$b(indent$7(concat$d([softline$6, printBindExpressionCallee(path, options, print)])))); |
| | | return concat$d(parts); |
| | | |
| | | case "Identifier": |
| | | { |
| | | return concat$d([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]); |
| | | } |
| | | |
| | | case "V8IntrinsicIdentifier": |
| | | return concat$d(["%", n.name]); |
| | | |
| | | case "SpreadElement": |
| | | case "SpreadElementPattern": |
| | | case "RestProperty": |
| | | case "SpreadProperty": |
| | | case "SpreadPropertyPattern": |
| | | case "RestElement": |
| | | case "ObjectTypeSpreadProperty": |
| | | return concat$d(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]); |
| | | |
| | | case "FunctionDeclaration": |
| | | case "FunctionExpression": |
| | | parts.push(printFunctionDeclaration(path, print, options)); |
| | | |
| | | if (!n.body) { |
| | | parts.push(semi); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "ArrowFunctionExpression": |
| | | { |
| | | if (n.async) { |
| | | parts.push("async "); |
| | | } |
| | | |
| | | if (shouldPrintParamsWithoutParens(path, options)) { |
| | | parts.push(path.call(print, "params", 0)); |
| | | } else { |
| | | parts.push(group$b(concat$d([printFunctionParams(path, print, options, |
| | | /* expandLast */ |
| | | args && (args.expandLastArg || args.expandFirstArg), |
| | | /* printTypeParams */ |
| | | true), printReturnType(path, print, options)]))); |
| | | } |
| | | |
| | | var dangling = comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true, function (comment) { |
| | | var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options); |
| | | return options.originalText.substr(nextCharacter, 2) === "=>"; |
| | | }); |
| | | |
| | | if (dangling) { |
| | | parts.push(" ", dangling); |
| | | } |
| | | |
| | | parts.push(" =>"); |
| | | var body = path.call(function (bodyPath) { |
| | | return print(bodyPath, args); |
| | | }, "body"); // We want to always keep these types of nodes on the same line |
| | | // as the arrow. |
| | | |
| | | if (!hasLeadingOwnLineComment$1(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode$1(n.body) || isTemplateOnItsOwnLine$1(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) { |
| | | return group$b(concat$d([concat$d(parts), " ", body])); |
| | | } // We handle sequence expressions as the body of arrows specially, |
| | | // so that the required parentheses end up on their own lines. |
| | | |
| | | |
| | | if (n.body.type === "SequenceExpression") { |
| | | return group$b(concat$d([concat$d(parts), group$b(concat$d([" (", indent$7(concat$d([softline$6, body])), softline$6, ")"]))])); |
| | | } // if the arrow function is expanded as last argument, we are adding a |
| | | // level of indentation and need to add a softline to align the closing ) |
| | | // with the opening (, or if it's inside a JSXExpression (e.g. an attribute) |
| | | // we should align the expression's closing } with the line with the opening {. |
| | | |
| | | |
| | | var shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length); |
| | | var printTrailingComma = args && args.expandLastArg && shouldPrintComma$1(options, "all"); // In order to avoid confusion between |
| | | // a => a ? a : a |
| | | // a <= a ? a : a |
| | | |
| | | var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body, |
| | | /* forbidFunctionAndClass */ |
| | | false); |
| | | return group$b(concat$d([concat$d(parts), group$b(concat$d([indent$7(concat$d([line$7, shouldAddParens ? ifBreak$6("", "(") : "", body, shouldAddParens ? ifBreak$6("", ")") : ""])), shouldAddSoftLine ? concat$d([ifBreak$6(printTrailingComma ? "," : ""), softline$6]) : ""]))])); |
| | | } |
| | | |
| | | case "YieldExpression": |
| | | parts.push("yield"); |
| | | |
| | | if (n.delegate) { |
| | | parts.push("*"); |
| | | } |
| | | |
| | | if (n.argument) { |
| | | parts.push(" ", path.call(print, "argument")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "AwaitExpression": |
| | | { |
| | | parts.push("await ", path.call(print, "argument")); |
| | | |
| | | var _parent3 = path.getParentNode(); |
| | | |
| | | if ((_parent3.type === "CallExpression" || _parent3.type === "OptionalCallExpression") && _parent3.callee === n || (_parent3.type === "MemberExpression" || _parent3.type === "OptionalMemberExpression") && _parent3.object === n) { |
| | | return group$b(concat$d([indent$7(concat$d([softline$6, concat$d(parts)])), softline$6])); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "ImportSpecifier": |
| | | if (n.importKind) { |
| | | parts.push(path.call(print, "importKind"), " "); |
| | | } |
| | | |
| | | parts.push(path.call(print, "imported")); |
| | | |
| | | if (n.local && n.local.name !== n.imported.name) { |
| | | parts.push(" as ", path.call(print, "local")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "ExportSpecifier": |
| | | parts.push(path.call(print, "local")); |
| | | |
| | | if (n.exported && n.exported.name !== n.local.name) { |
| | | parts.push(" as ", path.call(print, "exported")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "ImportNamespaceSpecifier": |
| | | parts.push("* as "); |
| | | parts.push(path.call(print, "local")); |
| | | return concat$d(parts); |
| | | |
| | | case "ImportDefaultSpecifier": |
| | | return path.call(print, "local"); |
| | | |
| | | case "TSExportAssignment": |
| | | return concat$d(["export = ", path.call(print, "expression"), semi]); |
| | | |
| | | case "ExportDefaultDeclaration": |
| | | case "ExportNamedDeclaration": |
| | | return printExportDeclaration(path, options, print); |
| | | |
| | | case "ExportAllDeclaration": |
| | | parts.push("export "); |
| | | |
| | | if (n.exportKind === "type") { |
| | | parts.push("type "); |
| | | } |
| | | |
| | | parts.push("* from ", path.call(print, "source"), semi); |
| | | return concat$d(parts); |
| | | |
| | | case "ExportNamespaceSpecifier": |
| | | case "ExportDefaultSpecifier": |
| | | return path.call(print, "exported"); |
| | | |
| | | case "ImportDeclaration": |
| | | { |
| | | parts.push("import "); |
| | | |
| | | if (n.importKind && n.importKind !== "value") { |
| | | parts.push(n.importKind + " "); |
| | | } |
| | | |
| | | var standalones = []; |
| | | var grouped = []; |
| | | |
| | | if (n.specifiers && n.specifiers.length > 0) { |
| | | path.each(function (specifierPath) { |
| | | var value = specifierPath.getValue(); |
| | | |
| | | if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") { |
| | | standalones.push(print(specifierPath)); |
| | | } else { |
| | | grouped.push(print(specifierPath)); |
| | | } |
| | | }, "specifiers"); |
| | | |
| | | if (standalones.length > 0) { |
| | | parts.push(join$9(", ", standalones)); |
| | | } |
| | | |
| | | if (standalones.length > 0 && grouped.length > 0) { |
| | | parts.push(", "); |
| | | } |
| | | |
| | | if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) { |
| | | return node.comments; |
| | | })) { |
| | | parts.push(concat$d(["{", options.bracketSpacing ? " " : "", concat$d(grouped), options.bracketSpacing ? " " : "", "}"])); |
| | | } else if (grouped.length >= 1) { |
| | | parts.push(group$b(concat$d(["{", indent$7(concat$d([options.bracketSpacing ? line$7 : softline$6, join$9(concat$d([",", line$7]), grouped)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$7 : softline$6, "}"]))); |
| | | } |
| | | |
| | | parts.push(" from "); |
| | | } else if (n.importKind && n.importKind === "type" || // import {} from 'x' |
| | | /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) { |
| | | parts.push("{} from "); |
| | | } |
| | | |
| | | parts.push(path.call(print, "source"), semi); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "Import": |
| | | return "import"; |
| | | |
| | | case "TSModuleBlock": |
| | | case "BlockStatement": |
| | | { |
| | | var naked = path.call(function (bodyPath) { |
| | | return printStatementSequence(bodyPath, options, print); |
| | | }, "body"); |
| | | var hasContent = n.body.find(function (node) { |
| | | return node.type !== "EmptyStatement"; |
| | | }); |
| | | var hasDirectives = n.directives && n.directives.length > 0; |
| | | |
| | | var _parent4 = path.getParentNode(); |
| | | |
| | | var _parentParent = path.getParentNode(1); |
| | | |
| | | if (!hasContent && !hasDirectives && !hasDanglingComments$1(n) && (_parent4.type === "ArrowFunctionExpression" || _parent4.type === "FunctionExpression" || _parent4.type === "FunctionDeclaration" || _parent4.type === "ObjectMethod" || _parent4.type === "ClassMethod" || _parent4.type === "ClassPrivateMethod" || _parent4.type === "ForStatement" || _parent4.type === "WhileStatement" || _parent4.type === "DoWhileStatement" || _parent4.type === "DoExpression" || _parent4.type === "CatchClause" && !_parentParent.finalizer || _parent4.type === "TSModuleDeclaration")) { |
| | | return "{}"; |
| | | } |
| | | |
| | | parts.push("{"); // Babel 6 |
| | | |
| | | if (hasDirectives) { |
| | | path.each(function (childPath) { |
| | | parts.push(indent$7(concat$d([hardline$9, print(childPath), semi]))); |
| | | |
| | | if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) { |
| | | parts.push(hardline$9); |
| | | } |
| | | }, "directives"); |
| | | } |
| | | |
| | | if (hasContent) { |
| | | parts.push(indent$7(concat$d([hardline$9, naked]))); |
| | | } |
| | | |
| | | parts.push(comments.printDanglingComments(path, options)); |
| | | parts.push(hardline$9, "}"); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "ReturnStatement": |
| | | parts.push("return"); |
| | | |
| | | if (n.argument) { |
| | | if (returnArgumentHasLeadingComment$1(options, n.argument)) { |
| | | parts.push(concat$d([" (", indent$7(concat$d([hardline$9, path.call(print, "argument")])), hardline$9, ")"])); |
| | | } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") { |
| | | parts.push(group$b(concat$d([ifBreak$6(" (", " "), indent$7(concat$d([softline$6, path.call(print, "argument")])), softline$6, ifBreak$6(")")]))); |
| | | } else { |
| | | parts.push(" ", path.call(print, "argument")); |
| | | } |
| | | } |
| | | |
| | | if (hasDanglingComments$1(n)) { |
| | | parts.push(" ", comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true)); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | return concat$d(parts); |
| | | |
| | | case "NewExpression": |
| | | case "OptionalCallExpression": |
| | | case "CallExpression": |
| | | { |
| | | var isNew = n.type === "NewExpression"; |
| | | var optional = printOptionalToken(path); |
| | | |
| | | if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style |
| | | // define calls, as a unit. |
| | | // e.g. `define(["some/lib", (lib) => {` |
| | | !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments |
| | | n.arguments.length === 1 && isTemplateOnItsOwnLine$1(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line |
| | | // e.g. `it('long name', () => {` |
| | | !isNew && isTestCall$1(n, path.getParentNode())) { |
| | | return concat$d([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$d(["(", join$9(", ", path.map(print, "arguments")), ")"])]); |
| | | } // Inline Flow annotation comments following Identifiers in Call nodes need to |
| | | // stay with the Identifier. For example: |
| | | // |
| | | // foo /*:: <SomeGeneric> */(bar); |
| | | // |
| | | // Here, we ensure that such comments stay between the Identifier and the Callee. |
| | | |
| | | |
| | | var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment$1(n.callee.trailingComments); |
| | | |
| | | if (isIdentifierWithFlowAnnotation) { |
| | | n.callee.trailingComments[0].printed = true; |
| | | } // We detect calls on member lookups and possibly print them in a |
| | | // special chain format. See `printMemberChain` for more info. |
| | | |
| | | |
| | | if (!isNew && isMemberish$1(n.callee)) { |
| | | return printMemberChain(path, options, print); |
| | | } |
| | | |
| | | var contents = concat$d([isNew ? "new " : "", path.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? "/*:: ".concat(n.callee.trailingComments[0].value.substring(2).trim(), " */") : "", printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]); // We group here when the callee is itself a call expression. |
| | | // See `isLongCurriedCallExpression` for more info. |
| | | |
| | | if (isCallOrOptionalCallExpression$1(n.callee)) { |
| | | return group$b(contents); |
| | | } |
| | | |
| | | return contents; |
| | | } |
| | | |
| | | case "TSInterfaceDeclaration": |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " "); |
| | | |
| | | if (n.extends && n.extends.length) { |
| | | parts.push(group$b(indent$7(concat$d([softline$6, "extends ", (n.extends.length === 1 ? identity$2 : indent$7)(join$9(concat$d([",", line$7]), path.map(print, "extends"))), " "])))); |
| | | } |
| | | |
| | | parts.push(path.call(print, "body")); |
| | | return concat$d(parts); |
| | | |
| | | case "ObjectTypeInternalSlot": |
| | | return concat$d([n.static ? "static " : "", "[[", path.call(print, "id"), "]]", printOptionalToken(path), n.method ? "" : ": ", path.call(print, "value")]); |
| | | |
| | | case "ObjectExpression": |
| | | case "ObjectPattern": |
| | | case "ObjectTypeAnnotation": |
| | | case "TSInterfaceBody": |
| | | case "TSTypeLiteral": |
| | | { |
| | | var propertiesField; |
| | | |
| | | if (n.type === "TSTypeLiteral") { |
| | | propertiesField = "members"; |
| | | } else if (n.type === "TSInterfaceBody") { |
| | | propertiesField = "body"; |
| | | } else { |
| | | propertiesField = "properties"; |
| | | } |
| | | |
| | | var isTypeAnnotation = n.type === "ObjectTypeAnnotation"; |
| | | var fields = []; |
| | | |
| | | if (isTypeAnnotation) { |
| | | fields.push("indexers", "callProperties", "internalSlots"); |
| | | } |
| | | |
| | | fields.push(propertiesField); |
| | | var firstProperty = fields.map(function (field) { |
| | | return n[field][0]; |
| | | }).sort(function (a, b) { |
| | | return options.locStart(a) - options.locStart(b); |
| | | })[0]; |
| | | |
| | | var _parent5 = path.getParentNode(0); |
| | | |
| | | var isFlowInterfaceLikeBody = isTypeAnnotation && _parent5 && (_parent5.type === "InterfaceDeclaration" || _parent5.type === "DeclareInterface" || _parent5.type === "DeclareClass") && path.getName() === "body"; |
| | | var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent5.type !== "FunctionDeclaration" && _parent5.type !== "FunctionExpression" && _parent5.type !== "ArrowFunctionExpression" && _parent5.type !== "ObjectMethod" && _parent5.type !== "ClassMethod" && _parent5.type !== "ClassPrivateMethod" && _parent5.type !== "AssignmentPattern" && _parent5.type !== "CatchClause" && n.properties.some(function (property) { |
| | | return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern"); |
| | | }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$2(options.originalText, options.locStart(n), options.locStart(firstProperty)); |
| | | var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ","; |
| | | var leftBrace = n.exact ? "{|" : "{"; |
| | | var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be |
| | | // interleaved in the source code. So we need to reorder them before |
| | | // printing them. |
| | | |
| | | var propsAndLoc = []; |
| | | fields.forEach(function (field) { |
| | | path.each(function (childPath) { |
| | | var node = childPath.getValue(); |
| | | propsAndLoc.push({ |
| | | node: node, |
| | | printed: print(childPath), |
| | | loc: options.locStart(node) |
| | | }); |
| | | }, field); |
| | | }); |
| | | var separatorParts = []; |
| | | var props = propsAndLoc.sort(function (a, b) { |
| | | return a.loc - b.loc; |
| | | }).map(function (prop) { |
| | | var result = concat$d(separatorParts.concat(group$b(prop.printed))); |
| | | separatorParts = [separator, line$7]; |
| | | |
| | | if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$2(prop.node)) { |
| | | separatorParts.shift(); |
| | | } |
| | | |
| | | if (isNextLineEmpty$4(options.originalText, prop.node, options)) { |
| | | separatorParts.push(hardline$9); |
| | | } |
| | | |
| | | return result; |
| | | }); |
| | | |
| | | if (n.inexact) { |
| | | props.push(concat$d(separatorParts.concat(group$b("...")))); |
| | | } |
| | | |
| | | var lastElem = getLast$2(n[propertiesField]); |
| | | var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$2(lastElem) || n.inexact)); |
| | | var content; |
| | | |
| | | if (props.length === 0) { |
| | | if (!hasDanglingComments$1(n)) { |
| | | return concat$d([leftBrace, rightBrace, printTypeAnnotation(path, options, print)]); |
| | | } |
| | | |
| | | content = group$b(concat$d([leftBrace, comments.printDanglingComments(path, options), softline$6, rightBrace, printOptionalToken(path), printTypeAnnotation(path, options, print)])); |
| | | } else { |
| | | content = concat$d([leftBrace, indent$7(concat$d([options.bracketSpacing ? line$7 : softline$6, concat$d(props)])), ifBreak$6(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$1(options)) ? separator : ""), concat$d([options.bracketSpacing ? line$7 : softline$6, rightBrace]), printOptionalToken(path), printTypeAnnotation(path, options, print)]); |
| | | } // If we inline the object as first argument of the parent, we don't want |
| | | // to create another group so that the object breaks before the return |
| | | // type |
| | | |
| | | |
| | | var parentParentParent = path.getParentNode(2); |
| | | |
| | | if (n.type === "ObjectPattern" && _parent5 && shouldHugArguments(_parent5) && !n.decorators && _parent5.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) { |
| | | return content; |
| | | } |
| | | |
| | | return group$b(content, { |
| | | shouldBreak: shouldBreak |
| | | }); |
| | | } |
| | | // Babel 6 |
| | | |
| | | case "ObjectProperty": // Non-standard AST node type. |
| | | |
| | | case "Property": |
| | | if (n.method || n.kind === "get" || n.kind === "set") { |
| | | return printMethod(path, options, print); |
| | | } |
| | | |
| | | if (n.shorthand) { |
| | | parts.push(path.call(print, "value")); |
| | | } else { |
| | | parts.push(printAssignment(n.key, printPropertyKey(path, options, print), ":", n.value, path.call(print, "value"), options)); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | // Babel 6 |
| | | |
| | | case "ClassMethod": |
| | | case "ClassPrivateMethod": |
| | | case "MethodDefinition": |
| | | case "TSAbstractMethodDefinition": |
| | | if (n.decorators && n.decorators.length !== 0) { |
| | | parts.push(printDecorators(path, options, print)); |
| | | } |
| | | |
| | | if (n.accessibility) { |
| | | parts.push(n.accessibility + " "); |
| | | } |
| | | |
| | | if (n.static) { |
| | | parts.push("static "); |
| | | } |
| | | |
| | | if (n.type === "TSAbstractMethodDefinition") { |
| | | parts.push("abstract "); |
| | | } |
| | | |
| | | parts.push(printMethod(path, options, print)); |
| | | return concat$d(parts); |
| | | |
| | | case "ObjectMethod": |
| | | return printMethod(path, options, print); |
| | | |
| | | case "Decorator": |
| | | return concat$d(["@", path.call(print, "expression"), path.call(print, "callee")]); |
| | | |
| | | case "ArrayExpression": |
| | | case "ArrayPattern": |
| | | if (n.elements.length === 0) { |
| | | if (!hasDanglingComments$1(n)) { |
| | | parts.push("[]"); |
| | | } else { |
| | | parts.push(group$b(concat$d(["[", comments.printDanglingComments(path, options), softline$6, "]"]))); |
| | | } |
| | | } else { |
| | | var _lastElem = getLast$2(n.elements); |
| | | |
| | | var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which |
| | | // changes its length based on the number of commas. The algorithm |
| | | // is that if the last argument is null, we need to force insert |
| | | // a comma to ensure JavaScript recognizes it. |
| | | // [,].length === 1 |
| | | // [1,].length === 1 |
| | | // [1,,].length === 2 |
| | | // |
| | | // Note that getLast returns null if the array is empty, but |
| | | // we already check for an empty array just above so we are safe |
| | | |
| | | var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null; |
| | | |
| | | var _shouldBreak = n.elements.length > 1 && n.elements.every(function (element, i, elements) { |
| | | var elementType = element && element.type; |
| | | |
| | | if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") { |
| | | return false; |
| | | } |
| | | |
| | | var nextElement = elements[i + 1]; |
| | | |
| | | if (nextElement && elementType !== nextElement.type) { |
| | | return false; |
| | | } |
| | | |
| | | var itemsKey = elementType === "ArrayExpression" ? "elements" : "properties"; |
| | | return element[itemsKey] && element[itemsKey].length > 1; |
| | | }); |
| | | |
| | | parts.push(group$b(concat$d(["[", indent$7(concat$d([softline$6, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$6(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma$1(options) ? "," : ""), comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), softline$6, "]"]), { |
| | | shouldBreak: _shouldBreak |
| | | })); |
| | | } |
| | | |
| | | parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print)); |
| | | return concat$d(parts); |
| | | |
| | | case "SequenceExpression": |
| | | { |
| | | var _parent6 = path.getParentNode(0); |
| | | |
| | | if (_parent6.type === "ExpressionStatement" || _parent6.type === "ForStatement") { |
| | | // For ExpressionStatements and for-loop heads, which are among |
| | | // the few places a SequenceExpression appears unparenthesized, we want |
| | | // to indent expressions after the first. |
| | | var _parts2 = []; |
| | | path.each(function (p) { |
| | | if (p.getName() === 0) { |
| | | _parts2.push(print(p)); |
| | | } else { |
| | | _parts2.push(",", indent$7(concat$d([line$7, print(p)]))); |
| | | } |
| | | }, "expressions"); |
| | | return group$b(concat$d(_parts2)); |
| | | } |
| | | |
| | | return group$b(concat$d([join$9(concat$d([",", line$7]), path.map(print, "expressions"))])); |
| | | } |
| | | |
| | | case "ThisExpression": |
| | | return "this"; |
| | | |
| | | case "Super": |
| | | return "super"; |
| | | |
| | | case "NullLiteral": |
| | | // Babel 6 Literal split |
| | | return "null"; |
| | | |
| | | case "RegExpLiteral": |
| | | // Babel 6 Literal split |
| | | return printRegex(n); |
| | | |
| | | case "NumericLiteral": |
| | | // Babel 6 Literal split |
| | | return printNumber$2(n.extra.raw); |
| | | |
| | | case "BigIntLiteral": |
| | | // babel: n.extra.raw, typescript: n.raw, flow: n.bigint |
| | | return (n.bigint || (n.extra ? n.extra.raw : n.raw)).toLowerCase(); |
| | | |
| | | case "BooleanLiteral": // Babel 6 Literal split |
| | | |
| | | case "StringLiteral": // Babel 6 Literal split |
| | | |
| | | case "Literal": |
| | | { |
| | | if (n.regex) { |
| | | return printRegex(n.regex); |
| | | } |
| | | |
| | | if (typeof n.value === "number") { |
| | | return printNumber$2(n.raw); |
| | | } |
| | | |
| | | if (typeof n.value !== "string") { |
| | | return "" + n.value; |
| | | } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2 |
| | | // See corresponding workaround in needs-parens.js |
| | | |
| | | |
| | | var grandParent = path.getParentNode(1); |
| | | var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement"); |
| | | return nodeStr(n, options, isTypeScriptDirective); |
| | | } |
| | | |
| | | case "Directive": |
| | | return path.call(print, "value"); |
| | | // Babel 6 |
| | | |
| | | case "DirectiveLiteral": |
| | | return nodeStr(n, options); |
| | | |
| | | case "UnaryExpression": |
| | | parts.push(n.operator); |
| | | |
| | | if (/[a-z]$/.test(n.operator)) { |
| | | parts.push(" "); |
| | | } |
| | | |
| | | if (n.argument.comments && n.argument.comments.length > 0) { |
| | | parts.push(group$b(concat$d(["(", indent$7(concat$d([softline$6, path.call(print, "argument")])), softline$6, ")"]))); |
| | | } else { |
| | | parts.push(path.call(print, "argument")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "UpdateExpression": |
| | | parts.push(path.call(print, "argument"), n.operator); |
| | | |
| | | if (n.prefix) { |
| | | parts.reverse(); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "ConditionalExpression": |
| | | return printTernaryOperator(path, options, print, { |
| | | beforeParts: function beforeParts() { |
| | | return [path.call(print, "test")]; |
| | | }, |
| | | afterParts: function afterParts(breakClosingParen) { |
| | | return [breakClosingParen ? softline$6 : ""]; |
| | | }, |
| | | shouldCheckJsx: true, |
| | | conditionalNodeType: "ConditionalExpression", |
| | | consequentNodePropertyName: "consequent", |
| | | alternateNodePropertyName: "alternate", |
| | | testNodePropertyName: "test", |
| | | breakNested: true |
| | | }); |
| | | |
| | | case "VariableDeclaration": |
| | | { |
| | | var printed = path.map(function (childPath) { |
| | | return print(childPath); |
| | | }, "declarations"); // We generally want to terminate all variable declarations with a |
| | | // semicolon, except when they in the () part of for loops. |
| | | |
| | | var parentNode = path.getParentNode(); |
| | | var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement"; |
| | | var hasValue = n.declarations.some(function (decl) { |
| | | return decl.init; |
| | | }); |
| | | var firstVariable; |
| | | |
| | | if (printed.length === 1 && !n.declarations[0].comments) { |
| | | firstVariable = printed[0]; |
| | | } else if (printed.length > 0) { |
| | | // Indent first var to comply with eslint one-var rule |
| | | firstVariable = indent$7(printed[0]); |
| | | } |
| | | |
| | | parts = [n.declare ? "declare " : "", n.kind, firstVariable ? concat$d([" ", firstVariable]) : "", indent$7(concat$d(printed.slice(1).map(function (p) { |
| | | return concat$d([",", hasValue && !isParentForLoop ? hardline$9 : line$7, p]); |
| | | })))]; |
| | | |
| | | if (!(isParentForLoop && parentNode.body !== n)) { |
| | | parts.push(semi); |
| | | } |
| | | |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "TSTypeAliasDeclaration": |
| | | { |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path.call(print, "typeAnnotation"), options); |
| | | |
| | | parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed, semi); |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "VariableDeclarator": |
| | | return printAssignment(n.id, path.call(print, "id"), " =", n.init, n.init && path.call(print, "init"), options); |
| | | |
| | | case "WithStatement": |
| | | return group$b(concat$d(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))])); |
| | | |
| | | case "IfStatement": |
| | | { |
| | | var con = adjustClause(n.consequent, path.call(print, "consequent")); |
| | | var opening = group$b(concat$d(["if (", group$b(concat$d([indent$7(concat$d([softline$6, path.call(print, "test")])), softline$6])), ")", con])); |
| | | parts.push(opening); |
| | | |
| | | if (n.alternate) { |
| | | var commentOnOwnLine = hasTrailingComment$1(n.consequent) && n.consequent.comments.some(function (comment) { |
| | | return comment.trailing && !comments$1.isBlockComment(comment); |
| | | }) || needsHardlineAfterDanglingComment$1(n); |
| | | var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine; |
| | | parts.push(elseOnSameLine ? " " : hardline$9); |
| | | |
| | | if (hasDanglingComments$1(n)) { |
| | | parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$9 : " "); |
| | | } |
| | | |
| | | parts.push("else", group$b(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement"))); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "ForStatement": |
| | | { |
| | | var _body = adjustClause(n.body, path.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent. |
| | | // Any comment positioned between the for statement and the parentheses |
| | | // is going to be printed before the statement. |
| | | |
| | | |
| | | var _dangling = comments.printDanglingComments(path, options, |
| | | /* sameLine */ |
| | | true); |
| | | |
| | | var printedComments = _dangling ? concat$d([_dangling, softline$6]) : ""; |
| | | |
| | | if (!n.init && !n.test && !n.update) { |
| | | return concat$d([printedComments, group$b(concat$d(["for (;;)", _body]))]); |
| | | } |
| | | |
| | | return concat$d([printedComments, group$b(concat$d(["for (", group$b(concat$d([indent$7(concat$d([softline$6, path.call(print, "init"), ";", line$7, path.call(print, "test"), ";", line$7, path.call(print, "update")])), softline$6])), ")", _body]))]); |
| | | } |
| | | |
| | | case "WhileStatement": |
| | | return group$b(concat$d(["while (", group$b(concat$d([indent$7(concat$d([softline$6, path.call(print, "test")])), softline$6])), ")", adjustClause(n.body, path.call(print, "body"))])); |
| | | |
| | | case "ForInStatement": |
| | | // Note: esprima can't actually parse "for each (". |
| | | return group$b(concat$d([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))])); |
| | | |
| | | case "ForOfStatement": |
| | | case "ForAwaitStatement": |
| | | { |
| | | // Babel 7 removed ForAwaitStatement in favor of ForOfStatement |
| | | // with `"await": true`: |
| | | // https://github.com/estree/estree/pull/138 |
| | | var isAwait = n.type === "ForAwaitStatement" || n.await; |
| | | return group$b(concat$d(["for", isAwait ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))])); |
| | | } |
| | | |
| | | case "DoWhileStatement": |
| | | { |
| | | var clause = adjustClause(n.body, path.call(print, "body")); |
| | | var doBody = group$b(concat$d(["do", clause])); |
| | | parts = [doBody]; |
| | | |
| | | if (n.body.type === "BlockStatement") { |
| | | parts.push(" "); |
| | | } else { |
| | | parts.push(hardline$9); |
| | | } |
| | | |
| | | parts.push("while ("); |
| | | parts.push(group$b(concat$d([indent$7(concat$d([softline$6, path.call(print, "test")])), softline$6])), ")", semi); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "DoExpression": |
| | | return concat$d(["do ", path.call(print, "body")]); |
| | | |
| | | case "BreakStatement": |
| | | parts.push("break"); |
| | | |
| | | if (n.label) { |
| | | parts.push(" ", path.call(print, "label")); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | return concat$d(parts); |
| | | |
| | | case "ContinueStatement": |
| | | parts.push("continue"); |
| | | |
| | | if (n.label) { |
| | | parts.push(" ", path.call(print, "label")); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | return concat$d(parts); |
| | | |
| | | case "LabeledStatement": |
| | | if (n.body.type === "EmptyStatement") { |
| | | return concat$d([path.call(print, "label"), ":;"]); |
| | | } |
| | | |
| | | return concat$d([path.call(print, "label"), ": ", path.call(print, "body")]); |
| | | |
| | | case "TryStatement": |
| | | return concat$d(["try ", path.call(print, "block"), n.handler ? concat$d([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$d([" finally ", path.call(print, "finalizer")]) : ""]); |
| | | |
| | | case "CatchClause": |
| | | if (n.param) { |
| | | var hasComments = n.param.comments && n.param.comments.some(function (comment) { |
| | | return !comments$1.isBlockComment(comment) || comment.leading && hasNewline$4(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$4(options.originalText, options.locStart(comment), { |
| | | backwards: true |
| | | }); |
| | | }); |
| | | var param = path.call(print, "param"); |
| | | return concat$d(["catch ", hasComments ? concat$d(["(", indent$7(concat$d([softline$6, param])), softline$6, ") "]) : concat$d(["(", param, ") "]), path.call(print, "body")]); |
| | | } |
| | | |
| | | return concat$d(["catch ", path.call(print, "body")]); |
| | | |
| | | case "ThrowStatement": |
| | | return concat$d(["throw ", path.call(print, "argument"), semi]); |
| | | // Note: ignoring n.lexical because it has no printing consequences. |
| | | |
| | | case "SwitchStatement": |
| | | return concat$d([group$b(concat$d(["switch (", indent$7(concat$d([softline$6, path.call(print, "discriminant")])), softline$6, ")"])), " {", n.cases.length > 0 ? indent$7(concat$d([hardline$9, join$9(hardline$9, path.map(function (casePath) { |
| | | var caseNode = casePath.getValue(); |
| | | return concat$d([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$4(options.originalText, caseNode, options) ? hardline$9 : ""]); |
| | | }, "cases"))])) : "", hardline$9, "}"]); |
| | | |
| | | case "SwitchCase": |
| | | { |
| | | if (n.test) { |
| | | parts.push("case ", path.call(print, "test"), ":"); |
| | | } else { |
| | | parts.push("default:"); |
| | | } |
| | | |
| | | var consequent = n.consequent.filter(function (node) { |
| | | return node.type !== "EmptyStatement"; |
| | | }); |
| | | |
| | | if (consequent.length > 0) { |
| | | var cons = path.call(function (consequentPath) { |
| | | return printStatementSequence(consequentPath, options, print); |
| | | }, "consequent"); |
| | | parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$d([" ", cons]) : indent$7(concat$d([hardline$9, cons]))); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | // JSX extensions below. |
| | | |
| | | case "DebuggerStatement": |
| | | return concat$d(["debugger", semi]); |
| | | |
| | | case "JSXAttribute": |
| | | parts.push(path.call(print, "name")); |
| | | |
| | | if (n.value) { |
| | | var res; |
| | | |
| | | if (isStringLiteral$1(n.value)) { |
| | | var raw = rawText$1(n.value); // Unescape all quotes so we get an accurate preferred quote |
| | | |
| | | var final = raw.replace(/'/g, "'").replace(/"/g, '"'); |
| | | var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"'); |
| | | |
| | | var _escape = quote === "'" ? "'" : """; |
| | | |
| | | final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape); |
| | | res = concat$d([quote, final, quote]); |
| | | } else { |
| | | res = path.call(print, "value"); |
| | | } |
| | | |
| | | parts.push("=", res); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "JSXIdentifier": |
| | | return "" + n.name; |
| | | |
| | | case "JSXNamespacedName": |
| | | return join$9(":", [path.call(print, "namespace"), path.call(print, "name")]); |
| | | |
| | | case "JSXMemberExpression": |
| | | return join$9(".", [path.call(print, "object"), path.call(print, "property")]); |
| | | |
| | | case "TSQualifiedName": |
| | | return join$9(".", [path.call(print, "left"), path.call(print, "right")]); |
| | | |
| | | case "JSXSpreadAttribute": |
| | | case "JSXSpreadChild": |
| | | { |
| | | return concat$d(["{", path.call(function (p) { |
| | | var printed = concat$d(["...", print(p)]); |
| | | var n = p.getValue(); |
| | | |
| | | if (!n.comments || !n.comments.length) { |
| | | return printed; |
| | | } |
| | | |
| | | return concat$d([indent$7(concat$d([softline$6, comments.printComments(p, function () { |
| | | return printed; |
| | | }, options)])), softline$6]); |
| | | }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]); |
| | | } |
| | | |
| | | case "JSXExpressionContainer": |
| | | { |
| | | var _parent7 = path.getParentNode(0); |
| | | |
| | | var preventInline = _parent7.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0; |
| | | |
| | | var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode$1(_parent7) && (n.expression.type === "ConditionalExpression" || isBinaryish$1(n.expression))); |
| | | |
| | | if (_shouldInline) { |
| | | return group$b(concat$d(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"])); |
| | | } |
| | | |
| | | return group$b(concat$d(["{", indent$7(concat$d([softline$6, path.call(print, "expression")])), softline$6, lineSuffixBoundary$1, "}"])); |
| | | } |
| | | |
| | | case "JSXFragment": |
| | | case "JSXElement": |
| | | { |
| | | var elem = comments.printComments(path, function () { |
| | | return printJSXElement(path, options, print); |
| | | }, options); |
| | | return maybeWrapJSXElementInParens(path, elem, options); |
| | | } |
| | | |
| | | case "JSXOpeningElement": |
| | | { |
| | | var _n = path.getValue(); |
| | | |
| | | var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0 || _n.typeParameters && _n.typeParameters.comments && _n.typeParameters.comments.length > 0; // Don't break self-closing elements with no attributes and no comments |
| | | |
| | | if (_n.selfClosing && !_n.attributes.length && !nameHasComments) { |
| | | return concat$d(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]); |
| | | } // don't break up opening elements with a single long text attribute |
| | | |
| | | |
| | | if (_n.attributes && _n.attributes.length === 1 && _n.attributes[0].value && isStringLiteral$1(_n.attributes[0].value) && !_n.attributes[0].value.value.includes("\n") && // We should break for the following cases: |
| | | // <div |
| | | // // comment |
| | | // attr="value" |
| | | // > |
| | | // <div |
| | | // attr="value" |
| | | // // comment |
| | | // > |
| | | !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) { |
| | | return group$b(concat$d(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$d(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"])); |
| | | } |
| | | |
| | | var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment$1(getLast$2(_n.attributes)); |
| | | var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be |
| | | // kept unbroken regardless of `jsxBracketSameLine` |
| | | !_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases: |
| | | // <div |
| | | // // comment |
| | | // > |
| | | // <div |
| | | // attr // comment |
| | | // > |
| | | !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a |
| | | // string literal with newlines |
| | | |
| | | var _shouldBreak2 = _n.attributes && _n.attributes.some(function (attr) { |
| | | return attr.value && isStringLiteral$1(attr.value) && attr.value.value.includes("\n"); |
| | | }); |
| | | |
| | | return group$b(concat$d(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$d([indent$7(concat$d(path.map(function (attr) { |
| | | return concat$d([line$7, print(attr)]); |
| | | }, "attributes"))), _n.selfClosing ? line$7 : bracketSameLine ? ">" : softline$6]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), { |
| | | shouldBreak: _shouldBreak2 |
| | | }); |
| | | } |
| | | |
| | | case "JSXClosingElement": |
| | | return concat$d(["</", path.call(print, "name"), ">"]); |
| | | |
| | | case "JSXOpeningFragment": |
| | | case "JSXClosingFragment": |
| | | { |
| | | var hasComment = n.comments && n.comments.length; |
| | | var hasOwnLineComment = hasComment && !n.comments.every(comments$1.isBlockComment); |
| | | var isOpeningFragment = n.type === "JSXOpeningFragment"; |
| | | return concat$d([isOpeningFragment ? "<" : "</", indent$7(concat$d([hasOwnLineComment ? hardline$9 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$9 : "", ">"]); |
| | | } |
| | | |
| | | case "JSXText": |
| | | /* istanbul ignore next */ |
| | | throw new Error("JSXTest should be handled by JSXElement"); |
| | | |
| | | case "JSXEmptyExpression": |
| | | { |
| | | var requiresHardline = n.comments && !n.comments.every(comments$1.isBlockComment); |
| | | return concat$d([comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | !requiresHardline), requiresHardline ? hardline$9 : ""]); |
| | | } |
| | | |
| | | case "ClassBody": |
| | | if (!n.comments && n.body.length === 0) { |
| | | return "{}"; |
| | | } |
| | | |
| | | return concat$d(["{", n.body.length > 0 ? indent$7(concat$d([hardline$9, path.call(function (bodyPath) { |
| | | return printStatementSequence(bodyPath, options, print); |
| | | }, "body")])) : comments.printDanglingComments(path, options), hardline$9, "}"]); |
| | | |
| | | case "ClassProperty": |
| | | case "TSAbstractClassProperty": |
| | | case "ClassPrivateProperty": |
| | | { |
| | | if (n.decorators && n.decorators.length !== 0) { |
| | | parts.push(printDecorators(path, options, print)); |
| | | } |
| | | |
| | | if (n.accessibility) { |
| | | parts.push(n.accessibility + " "); |
| | | } |
| | | |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | if (n.static) { |
| | | parts.push("static "); |
| | | } |
| | | |
| | | if (n.type === "TSAbstractClassProperty") { |
| | | parts.push("abstract "); |
| | | } |
| | | |
| | | if (n.readonly) { |
| | | parts.push("readonly "); |
| | | } |
| | | |
| | | var variance = getFlowVariance$1(n); |
| | | |
| | | if (variance) { |
| | | parts.push(variance); |
| | | } |
| | | |
| | | parts.push(printPropertyKey(path, options, print), printOptionalToken(path), printTypeAnnotation(path, options, print)); |
| | | |
| | | if (n.value) { |
| | | parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options)); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "ClassDeclaration": |
| | | case "ClassExpression": |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | parts.push(concat$d(printClass(path, options, print))); |
| | | return concat$d(parts); |
| | | |
| | | case "TSInterfaceHeritage": |
| | | parts.push(path.call(print, "expression")); |
| | | |
| | | if (n.typeParameters) { |
| | | parts.push(path.call(print, "typeParameters")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "TemplateElement": |
| | | return join$9(literalline$4, n.value.raw.split(/\r?\n/g)); |
| | | |
| | | case "TemplateLiteral": |
| | | { |
| | | var expressions = path.map(print, "expressions"); |
| | | |
| | | var _parentNode = path.getParentNode(); |
| | | |
| | | if (isJestEachTemplateLiteral$1(n, _parentNode)) { |
| | | var _printed2 = printJestEachTemplateLiteral(n, expressions, options); |
| | | |
| | | if (_printed2) { |
| | | return _printed2; |
| | | } |
| | | } |
| | | |
| | | var isSimple = isSimpleTemplateLiteral$1(n); |
| | | |
| | | if (isSimple) { |
| | | expressions = expressions.map(function (doc) { |
| | | return printDocToString$1(doc, Object.assign({}, options, { |
| | | printWidth: Infinity |
| | | })).formatted; |
| | | }); |
| | | } |
| | | |
| | | parts.push(lineSuffixBoundary$1, "`"); |
| | | path.each(function (childPath) { |
| | | var i = childPath.getName(); |
| | | parts.push(print(childPath)); |
| | | |
| | | if (i < expressions.length) { |
| | | // For a template literal of the following form: |
| | | // `someQuery { |
| | | // ${call({ |
| | | // a, |
| | | // b, |
| | | // })} |
| | | // }` |
| | | // the expression is on its own line (there is a \n in the previous |
| | | // quasi literal), therefore we want to indent the JavaScript |
| | | // expression inside at the beginning of ${ instead of the beginning |
| | | // of the `. |
| | | var tabWidth = options.tabWidth; |
| | | var quasi = childPath.getValue(); |
| | | var indentSize = getIndentSize$1(quasi.value.raw, tabWidth); |
| | | var _printed3 = expressions[i]; |
| | | |
| | | if (!isSimple) { |
| | | // Breaks at the template element boundaries (${ and }) are preferred to breaking |
| | | // in the middle of a MemberExpression |
| | | if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression") { |
| | | _printed3 = concat$d([indent$7(concat$d([softline$6, _printed3])), softline$6]); |
| | | } |
| | | } |
| | | |
| | | var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed3) : addAlignmentToDoc$2(_printed3, indentSize, tabWidth); |
| | | parts.push(group$b(concat$d(["${", aligned, lineSuffixBoundary$1, "}"]))); |
| | | } |
| | | }, "quasis"); |
| | | parts.push("`"); |
| | | return concat$d(parts); |
| | | } |
| | | // These types are unprintable because they serve as abstract |
| | | // supertypes for other (printable) types. |
| | | |
| | | case "TaggedTemplateExpression": |
| | | return concat$d([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]); |
| | | |
| | | case "Node": |
| | | case "Printable": |
| | | case "SourceLocation": |
| | | case "Position": |
| | | case "Statement": |
| | | case "Function": |
| | | case "Pattern": |
| | | case "Expression": |
| | | case "Declaration": |
| | | case "Specifier": |
| | | case "NamedSpecifier": |
| | | case "Comment": |
| | | case "MemberTypeAnnotation": // Flow |
| | | |
| | | case "Type": |
| | | /* istanbul ignore next */ |
| | | throw new Error("unprintable type: " + JSON.stringify(n.type)); |
| | | // Type Annotations for Facebook Flow, typically stripped out or |
| | | // transformed away before printing. |
| | | |
| | | case "TypeAnnotation": |
| | | case "TSTypeAnnotation": |
| | | if (n.typeAnnotation) { |
| | | return path.call(print, "typeAnnotation"); |
| | | } |
| | | /* istanbul ignore next */ |
| | | |
| | | |
| | | return ""; |
| | | |
| | | case "TSTupleType": |
| | | case "TupleTypeAnnotation": |
| | | { |
| | | var typesField = n.type === "TSTupleType" ? "elementTypes" : "types"; |
| | | return group$b(concat$d(["[", indent$7(concat$d([softline$6, printArrayItems(path, options, typesField, print)])), ifBreak$6(shouldPrintComma$1(options, "all") ? "," : ""), comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), softline$6, "]"])); |
| | | } |
| | | |
| | | case "ExistsTypeAnnotation": |
| | | return "*"; |
| | | |
| | | case "EmptyTypeAnnotation": |
| | | return "empty"; |
| | | |
| | | case "AnyTypeAnnotation": |
| | | return "any"; |
| | | |
| | | case "MixedTypeAnnotation": |
| | | return "mixed"; |
| | | |
| | | case "ArrayTypeAnnotation": |
| | | return concat$d([path.call(print, "elementType"), "[]"]); |
| | | |
| | | case "BooleanTypeAnnotation": |
| | | return "boolean"; |
| | | |
| | | case "BooleanLiteralTypeAnnotation": |
| | | return "" + n.value; |
| | | |
| | | case "DeclareClass": |
| | | return printFlowDeclaration(path, printClass(path, options, print)); |
| | | |
| | | case "TSDeclareFunction": |
| | | // For TypeScript the TSDeclareFunction node shares the AST |
| | | // structure with FunctionDeclaration |
| | | return concat$d([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]); |
| | | |
| | | case "DeclareFunction": |
| | | return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]); |
| | | |
| | | case "DeclareModule": |
| | | return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]); |
| | | |
| | | case "DeclareModuleExports": |
| | | return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]); |
| | | |
| | | case "DeclareVariable": |
| | | return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]); |
| | | |
| | | case "DeclareExportAllDeclaration": |
| | | return concat$d(["declare export * from ", path.call(print, "source")]); |
| | | |
| | | case "DeclareExportDeclaration": |
| | | return concat$d(["declare ", printExportDeclaration(path, options, print)]); |
| | | |
| | | case "DeclareOpaqueType": |
| | | case "OpaqueType": |
| | | { |
| | | parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters")); |
| | | |
| | | if (n.supertype) { |
| | | parts.push(": ", path.call(print, "supertype")); |
| | | } |
| | | |
| | | if (n.impltype) { |
| | | parts.push(" = ", path.call(print, "impltype")); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | |
| | | if (n.type === "DeclareOpaqueType") { |
| | | return printFlowDeclaration(path, parts); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "EnumDeclaration": |
| | | return concat$d(["enum ", path.call(print, "id"), " ", path.call(print, "body")]); |
| | | |
| | | case "EnumBooleanBody": |
| | | case "EnumNumberBody": |
| | | case "EnumStringBody": |
| | | case "EnumSymbolBody": |
| | | { |
| | | if (n.type === "EnumSymbolBody" || n.explicitType) { |
| | | var type = null; |
| | | |
| | | switch (n.type) { |
| | | case "EnumBooleanBody": |
| | | type = "boolean"; |
| | | break; |
| | | |
| | | case "EnumNumberBody": |
| | | type = "number"; |
| | | break; |
| | | |
| | | case "EnumStringBody": |
| | | type = "string"; |
| | | break; |
| | | |
| | | case "EnumSymbolBody": |
| | | type = "symbol"; |
| | | break; |
| | | } |
| | | |
| | | parts.push("of ", type, " "); |
| | | } |
| | | |
| | | if (n.members.length === 0) { |
| | | parts.push(group$b(concat$d(["{", comments.printDanglingComments(path, options), softline$6, "}"]))); |
| | | } else { |
| | | parts.push(group$b(concat$d(["{", indent$7(concat$d([hardline$9, printArrayItems(path, options, "members", print), shouldPrintComma$1(options) ? "," : ""])), comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), hardline$9, "}"]))); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "EnumBooleanMember": |
| | | case "EnumNumberMember": |
| | | case "EnumStringMember": |
| | | return concat$d([path.call(print, "id"), " = ", _typeof(n.init) === "object" ? path.call(print, "init") : String(n.init)]); |
| | | |
| | | case "EnumDefaultedMember": |
| | | return path.call(print, "id"); |
| | | |
| | | case "FunctionTypeAnnotation": |
| | | case "TSFunctionType": |
| | | { |
| | | // FunctionTypeAnnotation is ambiguous: |
| | | // declare function foo(a: B): void; OR |
| | | // var A: (a: B) => void; |
| | | var _parent8 = path.getParentNode(0); |
| | | |
| | | var _parentParent2 = path.getParentNode(1); |
| | | |
| | | var _parentParentParent = path.getParentNode(2); |
| | | |
| | | var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent8.type === "ObjectTypeProperty" || _parent8.type === "ObjectTypeInternalSlot") && !getFlowVariance$1(_parent8) && !_parent8.optional && options.locStart(_parent8) === options.locStart(n) || _parent8.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction"); |
| | | var needsColon = isArrowFunctionTypeAnnotation && (_parent8.type === "TypeAnnotation" || _parent8.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are |
| | | // printing ":" as part of the expression and it would put parenthesis |
| | | // around :( |
| | | |
| | | var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent8.type === "TypeAnnotation" || _parent8.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression"; |
| | | |
| | | if (isObjectTypePropertyAFunction$1(_parent8, options)) { |
| | | isArrowFunctionTypeAnnotation = true; |
| | | needsColon = true; |
| | | } |
| | | |
| | | if (needsParens) { |
| | | parts.push("("); |
| | | } |
| | | |
| | | parts.push(printFunctionParams(path, print, options, |
| | | /* expandArg */ |
| | | false, |
| | | /* printTypeParams */ |
| | | true)); // The returnType is not wrapped in a TypeAnnotation, so the colon |
| | | // needs to be added separately. |
| | | |
| | | if (n.returnType || n.predicate || n.typeAnnotation) { |
| | | parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation")); |
| | | } |
| | | |
| | | if (needsParens) { |
| | | parts.push(")"); |
| | | } |
| | | |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "TSRestType": |
| | | return concat$d(["...", path.call(print, "typeAnnotation")]); |
| | | |
| | | case "TSOptionalType": |
| | | return concat$d([path.call(print, "typeAnnotation"), "?"]); |
| | | |
| | | case "FunctionTypeParam": |
| | | return concat$d([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]); |
| | | |
| | | case "GenericTypeAnnotation": |
| | | return concat$d([path.call(print, "id"), path.call(print, "typeParameters")]); |
| | | |
| | | case "DeclareInterface": |
| | | case "InterfaceDeclaration": |
| | | case "InterfaceTypeAnnotation": |
| | | { |
| | | if (n.type === "DeclareInterface" || n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | parts.push("interface"); |
| | | |
| | | if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") { |
| | | parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters")); |
| | | } |
| | | |
| | | if (n["extends"].length > 0) { |
| | | parts.push(group$b(indent$7(concat$d([line$7, "extends ", (n.extends.length === 1 ? identity$2 : indent$7)(join$9(concat$d([",", line$7]), path.map(print, "extends")))])))); |
| | | } |
| | | |
| | | parts.push(" ", path.call(print, "body")); |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "ClassImplements": |
| | | case "InterfaceExtends": |
| | | return concat$d([path.call(print, "id"), path.call(print, "typeParameters")]); |
| | | |
| | | case "TSClassImplements": |
| | | return concat$d([path.call(print, "expression"), path.call(print, "typeParameters")]); |
| | | |
| | | case "TSIntersectionType": |
| | | case "IntersectionTypeAnnotation": |
| | | { |
| | | var types = path.map(print, "types"); |
| | | var result = []; |
| | | var wasIndented = false; |
| | | |
| | | for (var _i = 0; _i < types.length; ++_i) { |
| | | if (_i === 0) { |
| | | result.push(types[_i]); |
| | | } else if (isObjectType$1(n.types[_i - 1]) && isObjectType$1(n.types[_i])) { |
| | | // If both are objects, don't indent |
| | | result.push(concat$d([" & ", wasIndented ? indent$7(types[_i]) : types[_i]])); |
| | | } else if (!isObjectType$1(n.types[_i - 1]) && !isObjectType$1(n.types[_i])) { |
| | | // If no object is involved, go to the next line if it breaks |
| | | result.push(indent$7(concat$d([" &", line$7, types[_i]]))); |
| | | } else { |
| | | // If you go from object to non-object or vis-versa, then inline it |
| | | if (_i > 1) { |
| | | wasIndented = true; |
| | | } |
| | | |
| | | result.push(" & ", _i > 1 ? indent$7(types[_i]) : types[_i]); |
| | | } |
| | | } |
| | | |
| | | return group$b(concat$d(result)); |
| | | } |
| | | |
| | | case "TSUnionType": |
| | | case "UnionTypeAnnotation": |
| | | { |
| | | // single-line variation |
| | | // A | B | C |
| | | // multi-line variation |
| | | // | A |
| | | // | B |
| | | // | C |
| | | var _parent9 = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation |
| | | |
| | | |
| | | var shouldIndent = _parent9.type !== "TypeParameterInstantiation" && _parent9.type !== "TSTypeParameterInstantiation" && _parent9.type !== "GenericTypeAnnotation" && _parent9.type !== "TSTypeReference" && _parent9.type !== "TSTypeAssertion" && _parent9.type !== "TupleTypeAnnotation" && _parent9.type !== "TSTupleType" && !(_parent9.type === "FunctionTypeParam" && !_parent9.name) && !((_parent9.type === "TypeAlias" || _parent9.type === "VariableDeclarator" || _parent9.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, n, options)); // { |
| | | // a: string |
| | | // } | null | void |
| | | // should be inlined and not be printed in the multi-line variant |
| | | |
| | | var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like |
| | | // | child1 |
| | | // // comment |
| | | // | child2 |
| | | |
| | | var _printed4 = path.map(function (typePath) { |
| | | var printedType = typePath.call(print); |
| | | |
| | | if (!shouldHug) { |
| | | printedType = align$1(2, printedType); |
| | | } |
| | | |
| | | return comments.printComments(typePath, function () { |
| | | return printedType; |
| | | }, options); |
| | | }, "types"); |
| | | |
| | | if (shouldHug) { |
| | | return join$9(" | ", _printed4); |
| | | } |
| | | |
| | | var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, n, options); |
| | | var code = concat$d([ifBreak$6(concat$d([shouldAddStartLine ? line$7 : "", "| "])), join$9(concat$d([line$7, "| "]), _printed4)]); |
| | | |
| | | if (needsParens_1(path, options)) { |
| | | return group$b(concat$d([indent$7(code), softline$6])); |
| | | } |
| | | |
| | | if (_parent9.type === "TupleTypeAnnotation" && _parent9.types.length > 1 || _parent9.type === "TSTupleType" && _parent9.elementTypes.length > 1) { |
| | | return group$b(concat$d([indent$7(concat$d([ifBreak$6(concat$d(["(", softline$6])), code])), softline$6, ifBreak$6(")")])); |
| | | } |
| | | |
| | | return group$b(shouldIndent ? indent$7(code) : code); |
| | | } |
| | | |
| | | case "NullableTypeAnnotation": |
| | | return concat$d(["?", path.call(print, "typeAnnotation")]); |
| | | |
| | | case "TSNullKeyword": |
| | | case "NullLiteralTypeAnnotation": |
| | | return "null"; |
| | | |
| | | case "ThisTypeAnnotation": |
| | | return "this"; |
| | | |
| | | case "NumberTypeAnnotation": |
| | | return "number"; |
| | | |
| | | case "ObjectTypeCallProperty": |
| | | if (n.static) { |
| | | parts.push("static "); |
| | | } |
| | | |
| | | parts.push(path.call(print, "value")); |
| | | return concat$d(parts); |
| | | |
| | | case "ObjectTypeIndexer": |
| | | { |
| | | var _variance = getFlowVariance$1(n); |
| | | |
| | | return concat$d([_variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]); |
| | | } |
| | | |
| | | case "ObjectTypeProperty": |
| | | { |
| | | var _variance2 = getFlowVariance$1(n); |
| | | |
| | | var modifier = ""; |
| | | |
| | | if (n.proto) { |
| | | modifier = "proto "; |
| | | } else if (n.static) { |
| | | modifier = "static "; |
| | | } |
| | | |
| | | return concat$d([modifier, isGetterOrSetter$1(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation$1(n, options) ? "" : ": ", path.call(print, "value")]); |
| | | } |
| | | |
| | | case "QualifiedTypeIdentifier": |
| | | return concat$d([path.call(print, "qualification"), ".", path.call(print, "id")]); |
| | | |
| | | case "StringLiteralTypeAnnotation": |
| | | return nodeStr(n, options); |
| | | |
| | | case "NumberLiteralTypeAnnotation": |
| | | assert.strictEqual(_typeof(n.value), "number"); |
| | | |
| | | if (n.extra != null) { |
| | | return printNumber$2(n.extra.raw); |
| | | } |
| | | |
| | | return printNumber$2(n.raw); |
| | | |
| | | case "StringTypeAnnotation": |
| | | return "string"; |
| | | |
| | | case "DeclareTypeAlias": |
| | | case "TypeAlias": |
| | | { |
| | | if (n.type === "DeclareTypeAlias" || n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | var _printed5 = printAssignmentRight(n.id, n.right, path.call(print, "right"), options); |
| | | |
| | | parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed5, semi); |
| | | return group$b(concat$d(parts)); |
| | | } |
| | | |
| | | case "TypeCastExpression": |
| | | { |
| | | var value = path.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/. |
| | | // Unfortunately, its parser doesn't differentiate between comment annotations and regular |
| | | // annotations when producing an AST. So to preserve parentheses around type casts that use |
| | | // the comment syntax, we need to hackily read the source itself to see if the code contains |
| | | // a type annotation comment. |
| | | // |
| | | // Note that we're able to use the normal whitespace regex here because the Flow parser has |
| | | // already deemed this AST node to be a type cast. Only the Babel parser needs the |
| | | // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is |
| | | // implemented differently. |
| | | |
| | | var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/); |
| | | return concat$d(["(", path.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]); |
| | | } |
| | | |
| | | case "TypeParameterDeclaration": |
| | | case "TypeParameterInstantiation": |
| | | { |
| | | var _value = path.getValue(); |
| | | |
| | | var commentStart = _value.range ? options.originalText.substring(0, _value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here |
| | | // because we know for sure that this is a type definition. |
| | | |
| | | var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/); |
| | | |
| | | if (_commentSyntax) { |
| | | return concat$d(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]); |
| | | } |
| | | |
| | | return printTypeParameters(path, options, print, "params"); |
| | | } |
| | | |
| | | case "TSTypeParameterDeclaration": |
| | | case "TSTypeParameterInstantiation": |
| | | return printTypeParameters(path, options, print, "params"); |
| | | |
| | | case "TSTypeParameter": |
| | | case "TypeParameter": |
| | | { |
| | | var _parent10 = path.getParentNode(); |
| | | |
| | | if (_parent10.type === "TSMappedType") { |
| | | parts.push("[", path.call(print, "name")); |
| | | |
| | | if (n.constraint) { |
| | | parts.push(" in ", path.call(print, "constraint")); |
| | | } |
| | | |
| | | parts.push("]"); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | var _variance3 = getFlowVariance$1(n); |
| | | |
| | | if (_variance3) { |
| | | parts.push(_variance3); |
| | | } |
| | | |
| | | parts.push(path.call(print, "name")); |
| | | |
| | | if (n.bound) { |
| | | parts.push(": "); |
| | | parts.push(path.call(print, "bound")); |
| | | } |
| | | |
| | | if (n.constraint) { |
| | | parts.push(" extends ", path.call(print, "constraint")); |
| | | } |
| | | |
| | | if (n["default"]) { |
| | | parts.push(" = ", path.call(print, "default")); |
| | | } // Keep comma if the file extension is .tsx and |
| | | // has one type parameter that isn't extend with any types. |
| | | // Because, otherwise formatted result will be invalid as tsx. |
| | | |
| | | |
| | | var _grandParent = path.getNode(2); |
| | | |
| | | if (_parent10.params && _parent10.params.length === 1 && isTSXFile$1(options) && !n.constraint && _grandParent.type === "ArrowFunctionExpression") { |
| | | parts.push(","); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "TypeofTypeAnnotation": |
| | | return concat$d(["typeof ", path.call(print, "argument")]); |
| | | |
| | | case "VoidTypeAnnotation": |
| | | return "void"; |
| | | |
| | | case "InferredPredicate": |
| | | return "%checks"; |
| | | // Unhandled types below. If encountered, nodes of these types should |
| | | // be either left alone or desugared into AST types that are fully |
| | | // supported by the pretty-printer. |
| | | |
| | | case "DeclaredPredicate": |
| | | return concat$d(["%checks(", path.call(print, "value"), ")"]); |
| | | |
| | | case "TSAbstractKeyword": |
| | | return "abstract"; |
| | | |
| | | case "TSAnyKeyword": |
| | | return "any"; |
| | | |
| | | case "TSAsyncKeyword": |
| | | return "async"; |
| | | |
| | | case "TSBooleanKeyword": |
| | | return "boolean"; |
| | | |
| | | case "TSBigIntKeyword": |
| | | return "bigint"; |
| | | |
| | | case "TSConstKeyword": |
| | | return "const"; |
| | | |
| | | case "TSDeclareKeyword": |
| | | return "declare"; |
| | | |
| | | case "TSExportKeyword": |
| | | return "export"; |
| | | |
| | | case "TSNeverKeyword": |
| | | return "never"; |
| | | |
| | | case "TSNumberKeyword": |
| | | return "number"; |
| | | |
| | | case "TSObjectKeyword": |
| | | return "object"; |
| | | |
| | | case "TSProtectedKeyword": |
| | | return "protected"; |
| | | |
| | | case "TSPrivateKeyword": |
| | | return "private"; |
| | | |
| | | case "TSPublicKeyword": |
| | | return "public"; |
| | | |
| | | case "TSReadonlyKeyword": |
| | | return "readonly"; |
| | | |
| | | case "TSSymbolKeyword": |
| | | return "symbol"; |
| | | |
| | | case "TSStaticKeyword": |
| | | return "static"; |
| | | |
| | | case "TSStringKeyword": |
| | | return "string"; |
| | | |
| | | case "TSUndefinedKeyword": |
| | | return "undefined"; |
| | | |
| | | case "TSUnknownKeyword": |
| | | return "unknown"; |
| | | |
| | | case "TSVoidKeyword": |
| | | return "void"; |
| | | |
| | | case "TSAsExpression": |
| | | return concat$d([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]); |
| | | |
| | | case "TSArrayType": |
| | | return concat$d([path.call(print, "elementType"), "[]"]); |
| | | |
| | | case "TSPropertySignature": |
| | | { |
| | | if (n.export) { |
| | | parts.push("export "); |
| | | } |
| | | |
| | | if (n.accessibility) { |
| | | parts.push(n.accessibility + " "); |
| | | } |
| | | |
| | | if (n.static) { |
| | | parts.push("static "); |
| | | } |
| | | |
| | | if (n.readonly) { |
| | | parts.push("readonly "); |
| | | } |
| | | |
| | | parts.push(printPropertyKey(path, options, print), printOptionalToken(path)); |
| | | |
| | | if (n.typeAnnotation) { |
| | | parts.push(": "); |
| | | parts.push(path.call(print, "typeAnnotation")); |
| | | } // This isn't valid semantically, but it's in the AST so we can print it. |
| | | |
| | | |
| | | if (n.initializer) { |
| | | parts.push(" = ", path.call(print, "initializer")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "TSParameterProperty": |
| | | if (n.accessibility) { |
| | | parts.push(n.accessibility + " "); |
| | | } |
| | | |
| | | if (n.export) { |
| | | parts.push("export "); |
| | | } |
| | | |
| | | if (n.static) { |
| | | parts.push("static "); |
| | | } |
| | | |
| | | if (n.readonly) { |
| | | parts.push("readonly "); |
| | | } |
| | | |
| | | parts.push(path.call(print, "parameter")); |
| | | return concat$d(parts); |
| | | |
| | | case "TSTypeReference": |
| | | return concat$d([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]); |
| | | |
| | | case "TSTypeQuery": |
| | | return concat$d(["typeof ", path.call(print, "exprName")]); |
| | | |
| | | case "TSIndexSignature": |
| | | { |
| | | var _parent11 = path.getParentNode(); |
| | | |
| | | return concat$d([n.export ? "export " : "", n.accessibility ? concat$d([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? concat$d(path.map(print, "parameters")) : "", "]: ", path.call(print, "typeAnnotation"), _parent11.type === "ClassBody" ? semi : ""]); |
| | | } |
| | | |
| | | case "TSTypePredicate": |
| | | return concat$d([n.asserts ? "asserts " : "", path.call(print, "parameterName"), n.typeAnnotation ? concat$d([" is ", path.call(print, "typeAnnotation")]) : ""]); |
| | | |
| | | case "TSNonNullExpression": |
| | | return concat$d([path.call(print, "expression"), "!"]); |
| | | |
| | | case "TSThisType": |
| | | return "this"; |
| | | |
| | | case "TSImportType": |
| | | return concat$d([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, "parameter"), ")", !n.qualifier ? "" : concat$d([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]); |
| | | |
| | | case "TSLiteralType": |
| | | return path.call(print, "literal"); |
| | | |
| | | case "TSIndexedAccessType": |
| | | return concat$d([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]); |
| | | |
| | | case "TSConstructSignatureDeclaration": |
| | | case "TSCallSignatureDeclaration": |
| | | case "TSConstructorType": |
| | | { |
| | | if (n.type !== "TSCallSignatureDeclaration") { |
| | | parts.push("new "); |
| | | } |
| | | |
| | | parts.push(group$b(printFunctionParams(path, print, options, |
| | | /* expandArg */ |
| | | false, |
| | | /* printTypeParams */ |
| | | true))); |
| | | |
| | | if (n.returnType) { |
| | | var isType = n.type === "TSConstructorType"; |
| | | parts.push(isType ? " => " : ": ", path.call(print, "returnType")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "TSTypeOperator": |
| | | return concat$d([n.operator, " ", path.call(print, "typeAnnotation")]); |
| | | |
| | | case "TSMappedType": |
| | | { |
| | | var _shouldBreak3 = hasNewlineInRange$2(options.originalText, options.locStart(n), options.locEnd(n)); |
| | | |
| | | return group$b(concat$d(["{", indent$7(concat$d([options.bracketSpacing ? line$7 : softline$6, n.readonly ? concat$d([getTypeScriptMappedTypeModifier$1(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier$1(n.optional, "?") : "", ": ", path.call(print, "typeAnnotation"), ifBreak$6(semi, "")])), comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), options.bracketSpacing ? line$7 : softline$6, "}"]), { |
| | | shouldBreak: _shouldBreak3 |
| | | }); |
| | | } |
| | | |
| | | case "TSMethodSignature": |
| | | parts.push(n.accessibility ? concat$d([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path), printFunctionParams(path, print, options, |
| | | /* expandArg */ |
| | | false, |
| | | /* printTypeParams */ |
| | | true)); |
| | | |
| | | if (n.returnType) { |
| | | parts.push(": ", path.call(print, "returnType")); |
| | | } |
| | | |
| | | return group$b(concat$d(parts)); |
| | | |
| | | case "TSNamespaceExportDeclaration": |
| | | parts.push("export as namespace ", path.call(print, "id")); |
| | | |
| | | if (options.semi) { |
| | | parts.push(";"); |
| | | } |
| | | |
| | | return group$b(concat$d(parts)); |
| | | |
| | | case "TSEnumDeclaration": |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | if (n.modifiers) { |
| | | parts.push(printTypeScriptModifiers(path, options, print)); |
| | | } |
| | | |
| | | if (n.const) { |
| | | parts.push("const "); |
| | | } |
| | | |
| | | parts.push("enum ", path.call(print, "id"), " "); |
| | | |
| | | if (n.members.length === 0) { |
| | | parts.push(group$b(concat$d(["{", comments.printDanglingComments(path, options), softline$6, "}"]))); |
| | | } else { |
| | | parts.push(group$b(concat$d(["{", indent$7(concat$d([hardline$9, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), hardline$9, "}"]))); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "TSEnumMember": |
| | | parts.push(path.call(print, "id")); |
| | | |
| | | if (n.initializer) { |
| | | parts.push(" = ", path.call(print, "initializer")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "TSImportEqualsDeclaration": |
| | | if (n.isExport) { |
| | | parts.push("export "); |
| | | } |
| | | |
| | | parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference")); |
| | | |
| | | if (options.semi) { |
| | | parts.push(";"); |
| | | } |
| | | |
| | | return group$b(concat$d(parts)); |
| | | |
| | | case "TSExternalModuleReference": |
| | | return concat$d(["require(", path.call(print, "expression"), ")"]); |
| | | |
| | | case "TSModuleDeclaration": |
| | | { |
| | | var _parent12 = path.getParentNode(); |
| | | |
| | | var isExternalModule = isLiteral$1(n.id); |
| | | var parentIsDeclaration = _parent12.type === "TSModuleDeclaration"; |
| | | var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration"; |
| | | |
| | | if (parentIsDeclaration) { |
| | | parts.push("."); |
| | | } else { |
| | | if (n.declare) { |
| | | parts.push("declare "); |
| | | } |
| | | |
| | | parts.push(printTypeScriptModifiers(path, options, print)); |
| | | var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this: |
| | | // (declare)? global { ... } |
| | | |
| | | var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId); |
| | | |
| | | if (!isGlobalDeclaration) { |
| | | parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace "); |
| | | } |
| | | } |
| | | |
| | | parts.push(path.call(print, "id")); |
| | | |
| | | if (bodyIsDeclaration) { |
| | | parts.push(path.call(print, "body")); |
| | | } else if (n.body) { |
| | | parts.push(" ", group$b(path.call(print, "body"))); |
| | | } else { |
| | | parts.push(semi); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | case "PrivateName": |
| | | return concat$d(["#", path.call(print, "id")]); |
| | | |
| | | case "TSConditionalType": |
| | | return printTernaryOperator(path, options, print, { |
| | | beforeParts: function beforeParts() { |
| | | return [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")]; |
| | | }, |
| | | afterParts: function afterParts() { |
| | | return []; |
| | | }, |
| | | shouldCheckJsx: false, |
| | | conditionalNodeType: "TSConditionalType", |
| | | consequentNodePropertyName: "trueType", |
| | | alternateNodePropertyName: "falseType", |
| | | testNodePropertyName: "checkType", |
| | | breakNested: true |
| | | }); |
| | | |
| | | case "TSInferType": |
| | | return concat$d(["infer", " ", path.call(print, "typeParameter")]); |
| | | |
| | | case "InterpreterDirective": |
| | | parts.push("#!", n.value, hardline$9); |
| | | |
| | | if (isNextLineEmpty$4(options.originalText, n, options)) { |
| | | parts.push(hardline$9); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | |
| | | case "NGRoot": |
| | | return concat$d([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$d([" //", n.node.comments[0].value.trimRight()]))); |
| | | |
| | | case "NGChainedExpression": |
| | | return group$b(join$9(concat$d([";", line$7]), path.map(function (childPath) { |
| | | return hasNgSideEffect$1(childPath) ? print(childPath) : concat$d(["(", print(childPath), ")"]); |
| | | }, "expressions"))); |
| | | |
| | | case "NGEmptyExpression": |
| | | return ""; |
| | | |
| | | case "NGQuotedExpression": |
| | | return concat$d([n.prefix, ":", n.value]); |
| | | |
| | | case "NGMicrosyntax": |
| | | return concat$d(path.map(function (childPath, index) { |
| | | return concat$d([index === 0 ? "" : isNgForOf$1(childPath.getValue(), index, n) ? " " : concat$d([";", line$7]), print(childPath)]); |
| | | }, "body")); |
| | | |
| | | case "NGMicrosyntaxKey": |
| | | return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name); |
| | | |
| | | case "NGMicrosyntaxExpression": |
| | | return concat$d([path.call(print, "expression"), n.alias === null ? "" : concat$d([" as ", path.call(print, "alias")])]); |
| | | |
| | | case "NGMicrosyntaxKeyedExpression": |
| | | { |
| | | var index = path.getName(); |
| | | |
| | | var _parentNode2 = path.getParentNode(); |
| | | |
| | | var shouldNotPrintColon = isNgForOf$1(n, index, _parentNode2) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && _parentNode2.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && _parentNode2.body[index - 1].key.name === "then") && _parentNode2.body[0].type === "NGMicrosyntaxExpression"; |
| | | return concat$d([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]); |
| | | } |
| | | |
| | | case "NGMicrosyntaxLet": |
| | | return concat$d(["let ", path.call(print, "key"), n.value === null ? "" : concat$d([" = ", path.call(print, "value")])]); |
| | | |
| | | case "NGMicrosyntaxAs": |
| | | return concat$d([path.call(print, "key"), " as ", path.call(print, "alias")]); |
| | | |
| | | case "ArgumentPlaceholder": |
| | | return "?"; |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | throw new Error("unknown type: " + JSON.stringify(n.type)); |
| | | } |
| | | } |
| | | |
| | | function printStatementSequence(path, options, print) { |
| | | var printed = []; |
| | | var bodyNode = path.getNode(); |
| | | var isClass = bodyNode.type === "ClassBody"; |
| | | path.map(function (stmtPath, i) { |
| | | var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy |
| | | // "statements," it's safer simply to skip them. |
| | | |
| | | /* istanbul ignore if */ |
| | | |
| | | if (!stmt) { |
| | | return; |
| | | } // Skip printing EmptyStatement nodes to avoid leaving stray |
| | | // semicolons lying around. |
| | | |
| | | |
| | | if (stmt.type === "EmptyStatement") { |
| | | return; |
| | | } |
| | | |
| | | var stmtPrinted = print(stmtPath); |
| | | var text = options.originalText; |
| | | var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI |
| | | // don't prepend the only JSX element in a program with semicolon |
| | | |
| | | if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown$1(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) { |
| | | if (stmt.comments && stmt.comments.some(function (comment) { |
| | | return comment.leading; |
| | | })) { |
| | | parts.push(print(stmtPath, { |
| | | needsSemi: true |
| | | })); |
| | | } else { |
| | | parts.push(";", stmtPrinted); |
| | | } |
| | | } else { |
| | | parts.push(stmtPrinted); |
| | | } |
| | | |
| | | if (!options.semi && isClass) { |
| | | if (classPropMayCauseASIProblems$1(stmtPath)) { |
| | | parts.push(";"); |
| | | } else if (stmt.type === "ClassProperty") { |
| | | var nextChild = bodyNode.body[i + 1]; |
| | | |
| | | if (classChildNeedsASIProtection$1(nextChild)) { |
| | | parts.push(";"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (isNextLineEmpty$4(text, stmt, options) && !isLastStatement$1(stmtPath)) { |
| | | parts.push(hardline$9); |
| | | } |
| | | |
| | | printed.push(concat$d(parts)); |
| | | }); |
| | | return join$9(hardline$9, printed); |
| | | } |
| | | |
| | | function printPropertyKey(path, options, print) { |
| | | var node = path.getNode(); |
| | | |
| | | if (node.computed) { |
| | | return concat$d(["[", path.call(print, "key"), "]"]); |
| | | } |
| | | |
| | | var parent = path.getParentNode(); |
| | | var key = node.key; |
| | | |
| | | if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) { |
| | | var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) { |
| | | return !prop.computed && prop.key && isStringLiteral$1(prop.key) && !isStringPropSafeToCoerceToIdentifier$1(prop, options); |
| | | }); |
| | | needsQuoteProps.set(parent, objectHasStringProp); |
| | | } |
| | | |
| | | if (key.type === "Identifier" && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) { |
| | | // a -> "a" |
| | | var prop = printString$2(JSON.stringify(key.name), options); |
| | | return path.call(function (keyPath) { |
| | | return comments.printComments(keyPath, function () { |
| | | return prop; |
| | | }, options); |
| | | }, "key"); |
| | | } |
| | | |
| | | if (isStringPropSafeToCoerceToIdentifier$1(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) { |
| | | // 'a' -> a |
| | | return path.call(function (keyPath) { |
| | | return comments.printComments(keyPath, function () { |
| | | return key.value; |
| | | }, options); |
| | | }, "key"); |
| | | } |
| | | |
| | | return path.call(print, "key"); |
| | | } |
| | | |
| | | function printMethod(path, options, print) { |
| | | var node = path.getNode(); |
| | | var kind = node.kind; |
| | | var value = node.value || node; |
| | | var parts = []; |
| | | |
| | | if (!kind || kind === "init" || kind === "method" || kind === "constructor") { |
| | | if (value.async) { |
| | | parts.push("async "); |
| | | } |
| | | |
| | | if (value.generator) { |
| | | parts.push("*"); |
| | | } |
| | | } else { |
| | | assert.ok(kind === "get" || kind === "set"); |
| | | parts.push(kind, " "); |
| | | } |
| | | |
| | | parts.push(printPropertyKey(path, options, print), node.optional || node.key.optional ? "?" : "", node === value ? printMethodInternal(path, options, print) : path.call(function (path) { |
| | | return printMethodInternal(path, options, print); |
| | | }, "value")); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printMethodInternal(path, options, print) { |
| | | var parts = [printFunctionTypeParameters(path, options, print), group$b(concat$d([printFunctionParams(path, print, options), printReturnType(path, print, options)]))]; |
| | | |
| | | if (path.getNode().body) { |
| | | parts.push(" ", path.call(print, "body")); |
| | | } else { |
| | | parts.push(options.semi ? ";" : ""); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function couldGroupArg(arg) { |
| | | return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords |
| | | // https://github.com/prettier/prettier/issues/4070 |
| | | // export class Thing implements OtherThing { |
| | | // do: (type: Type) => Provider<Prop> = memoize( |
| | | // (type: ObjectType): Provider<Opts> => {} |
| | | // ); |
| | | // } |
| | | // https://github.com/prettier/prettier/issues/6099 |
| | | // app.get("/", (req, res): void => { |
| | | // res.send("Hello World!"); |
| | | // }); |
| | | !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode$1(arg.body)); |
| | | } |
| | | |
| | | function shouldGroupLastArg(args) { |
| | | var lastArg = getLast$2(args); |
| | | var penultimateArg = getPenultimate$1(args); |
| | | return !hasLeadingComment$3(lastArg) && !hasTrailingComment$1(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type, |
| | | // disable last element expansion. |
| | | !penultimateArg || penultimateArg.type !== lastArg.type); |
| | | } |
| | | |
| | | function shouldGroupFirstArg(args) { |
| | | if (args.length !== 2) { |
| | | return false; |
| | | } |
| | | |
| | | var firstArg = args[0]; |
| | | var secondArg = args[1]; |
| | | return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg); |
| | | } |
| | | |
| | | function printJestEachTemplateLiteral(node, expressions, options) { |
| | | /** |
| | | * a | b | expected |
| | | * ${1} | ${1} | ${2} |
| | | * ${1} | ${2} | ${3} |
| | | * ${2} | ${1} | ${3} |
| | | */ |
| | | var headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/); |
| | | |
| | | if (headerNames.length > 1 || headerNames.some(function (headerName) { |
| | | return headerName.length !== 0; |
| | | })) { |
| | | var parts = []; |
| | | var stringifiedExpressions = expressions.map(function (doc) { |
| | | return "${" + printDocToString$1(doc, Object.assign({}, options, { |
| | | printWidth: Infinity, |
| | | endOfLine: "lf" |
| | | })).formatted + "}"; |
| | | }); |
| | | var tableBody = [{ |
| | | hasLineBreak: false, |
| | | cells: [] |
| | | }]; |
| | | |
| | | for (var i = 1; i < node.quasis.length; i++) { |
| | | var row = tableBody[tableBody.length - 1]; |
| | | var correspondingExpression = stringifiedExpressions[i - 1]; |
| | | row.cells.push(correspondingExpression); |
| | | |
| | | if (correspondingExpression.indexOf("\n") !== -1) { |
| | | row.hasLineBreak = true; |
| | | } |
| | | |
| | | if (node.quasis[i].value.raw.indexOf("\n") !== -1) { |
| | | tableBody.push({ |
| | | hasLineBreak: false, |
| | | cells: [] |
| | | }); |
| | | } |
| | | } |
| | | |
| | | var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) { |
| | | return Math.max(maxColumnCount, row.cells.length); |
| | | }, headerNames.length); |
| | | var maxColumnWidths = Array.from(new Array(maxColumnCount), function () { |
| | | return 0; |
| | | }); |
| | | var table = [{ |
| | | cells: headerNames |
| | | }].concat(tableBody.filter(function (row) { |
| | | return row.cells.length !== 0; |
| | | })); |
| | | table.filter(function (row) { |
| | | return !row.hasLineBreak; |
| | | }).forEach(function (row) { |
| | | row.cells.forEach(function (cell, index) { |
| | | maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell)); |
| | | }); |
| | | }); |
| | | parts.push(lineSuffixBoundary$1, "`", indent$7(concat$d([hardline$9, join$9(hardline$9, table.map(function (row) { |
| | | return join$9(" | ", row.cells.map(function (cell, index) { |
| | | return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell)); |
| | | })); |
| | | }))])), hardline$9, "`"); |
| | | return concat$d(parts); |
| | | } |
| | | } |
| | | |
| | | function printArgumentsList(path, options, print) { |
| | | var node = path.getValue(); |
| | | var args = node.arguments; |
| | | |
| | | if (args.length === 0) { |
| | | return concat$d(["(", comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true), ")"]); |
| | | } // useEffect(() => { ... }, [foo, bar, baz]) |
| | | |
| | | |
| | | if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) { |
| | | return arg.comments; |
| | | })) { |
| | | return concat$d(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]); |
| | | } // func( |
| | | // ({ |
| | | // a, |
| | | // b |
| | | // }) => {} |
| | | // ); |
| | | |
| | | |
| | | function shouldBreakForArrowFunctionInArguments(arg, argPath) { |
| | | if (!arg || arg.type !== "ArrowFunctionExpression" || !arg.body || arg.body.type !== "BlockStatement" || !arg.params || arg.params.length < 1) { |
| | | return false; |
| | | } |
| | | |
| | | var shouldBreak = false; |
| | | argPath.each(function (paramPath) { |
| | | var printed = concat$d([print(paramPath)]); |
| | | shouldBreak = shouldBreak || willBreak$1(printed); |
| | | }, "params"); |
| | | return shouldBreak; |
| | | } |
| | | |
| | | var anyArgEmptyLine = false; |
| | | var shouldBreakForArrowFunction = false; |
| | | var hasEmptyLineFollowingFirstArg = false; |
| | | var lastArgIndex = args.length - 1; |
| | | var printedArguments = path.map(function (argPath, index) { |
| | | var arg = argPath.getNode(); |
| | | var parts = [print(argPath)]; |
| | | |
| | | if (index === lastArgIndex) ; else if (isNextLineEmpty$4(options.originalText, arg, options)) { |
| | | if (index === 0) { |
| | | hasEmptyLineFollowingFirstArg = true; |
| | | } |
| | | |
| | | anyArgEmptyLine = true; |
| | | parts.push(",", hardline$9, hardline$9); |
| | | } else { |
| | | parts.push(",", line$7); |
| | | } |
| | | |
| | | shouldBreakForArrowFunction = shouldBreakForArrowFunctionInArguments(arg, argPath); |
| | | return concat$d(parts); |
| | | }, "arguments"); |
| | | var maybeTrailingComma = // Dynamic imports cannot have trailing commas |
| | | !(node.callee && node.callee.type === "Import") && shouldPrintComma$1(options, "all") ? "," : ""; |
| | | |
| | | function allArgsBrokenOut() { |
| | | return group$b(concat$d(["(", indent$7(concat$d([line$7, concat$d(printedArguments)])), maybeTrailingComma, line$7, ")"]), { |
| | | shouldBreak: true |
| | | }); |
| | | } |
| | | |
| | | if (isFunctionCompositionArgs$1(args)) { |
| | | return allArgsBrokenOut(); |
| | | } |
| | | |
| | | var shouldGroupFirst = shouldGroupFirstArg(args); |
| | | var shouldGroupLast = shouldGroupLastArg(args); |
| | | |
| | | if (shouldGroupFirst || shouldGroupLast) { |
| | | var shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine || shouldBreakForArrowFunction; // We want to print the last argument with a special flag |
| | | |
| | | var printedExpanded; |
| | | var i = 0; |
| | | path.each(function (argPath) { |
| | | if (shouldGroupFirst && i === 0) { |
| | | printedExpanded = [concat$d([argPath.call(function (p) { |
| | | return print(p, { |
| | | expandFirstArg: true |
| | | }); |
| | | }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$9 : line$7, hasEmptyLineFollowingFirstArg ? hardline$9 : ""])].concat(printedArguments.slice(1)); |
| | | } |
| | | |
| | | if (shouldGroupLast && i === args.length - 1) { |
| | | printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) { |
| | | return print(p, { |
| | | expandLastArg: true |
| | | }); |
| | | })); |
| | | } |
| | | |
| | | i++; |
| | | }, "arguments"); |
| | | var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1); |
| | | var simpleConcat = concat$d(["(", concat$d(printedExpanded), ")"]); |
| | | return concat$d([somePrintedArgumentsWillBreak ? breakParent$3 : "", conditionalGroup$1([!somePrintedArgumentsWillBreak && !node.typeArguments && !node.typeParameters ? simpleConcat : ifBreak$6(allArgsBrokenOut(), simpleConcat), shouldGroupFirst ? concat$d(["(", group$b(printedExpanded[0], { |
| | | shouldBreak: true |
| | | }), concat$d(printedExpanded.slice(1)), ")"]) : concat$d(["(", concat$d(printedArguments.slice(0, -1)), group$b(getLast$2(printedExpanded), { |
| | | shouldBreak: true |
| | | }), ")"]), allArgsBrokenOut()], { |
| | | shouldBreak: shouldBreak |
| | | })]); |
| | | } |
| | | |
| | | var contents = concat$d(["(", indent$7(concat$d([softline$6, concat$d(printedArguments)])), ifBreak$6(maybeTrailingComma), softline$6, ")"]); |
| | | |
| | | if (isLongCurriedCallExpression$1(path)) { |
| | | // By not wrapping the arguments in a group, the printer prioritizes |
| | | // breaking up these arguments rather than the args of the parent call. |
| | | return contents; |
| | | } |
| | | |
| | | return group$b(contents, { |
| | | shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine |
| | | }); |
| | | } |
| | | |
| | | function printTypeAnnotation(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | if (!node.typeAnnotation) { |
| | | return ""; |
| | | } |
| | | |
| | | var parentNode = path.getParentNode(); |
| | | var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite; |
| | | var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node; |
| | | |
| | | if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation, options)) { |
| | | return concat$d([" /*: ", path.call(print, "typeAnnotation"), " */"]); |
| | | } |
| | | |
| | | return concat$d([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]); |
| | | } |
| | | |
| | | function printFunctionTypeParameters(path, options, print) { |
| | | var fun = path.getValue(); |
| | | |
| | | if (fun.typeArguments) { |
| | | return path.call(print, "typeArguments"); |
| | | } |
| | | |
| | | if (fun.typeParameters) { |
| | | return path.call(print, "typeParameters"); |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | function printFunctionParams(path, print, options, expandArg, printTypeParams) { |
| | | var fun = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | var paramsField = fun.parameters ? "parameters" : "params"; |
| | | var isParametersInTestCall = isTestCall$1(parent); |
| | | var shouldHugParameters = shouldHugArguments(fun); |
| | | var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) { |
| | | return n.comments; |
| | | })); |
| | | var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : ""; |
| | | var printed = []; |
| | | |
| | | if (fun[paramsField]) { |
| | | var lastArgIndex = fun[paramsField].length - 1; |
| | | printed = path.map(function (childPath, index) { |
| | | var parts = []; |
| | | var param = childPath.getValue(); |
| | | parts.push(print(childPath)); |
| | | |
| | | if (index === lastArgIndex) { |
| | | if (fun.rest) { |
| | | parts.push(",", line$7); |
| | | } |
| | | } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) { |
| | | parts.push(", "); |
| | | } else if (isNextLineEmpty$4(options.originalText, param, options)) { |
| | | parts.push(",", hardline$9, hardline$9); |
| | | } else { |
| | | parts.push(",", line$7); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | }, paramsField); |
| | | } |
| | | |
| | | if (fun.rest) { |
| | | printed.push(concat$d(["...", path.call(print, "rest")])); |
| | | } |
| | | |
| | | if (printed.length === 0) { |
| | | return concat$d([typeParams, "(", comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true, function (comment) { |
| | | return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")"; |
| | | }), ")"]); |
| | | } |
| | | |
| | | var lastParam = getLast$2(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the |
| | | // params of the first/last argument, we don't want the arguments to break and instead |
| | | // want the whole expression to be on a new line. |
| | | // |
| | | // Good: Bad: |
| | | // verylongcall( verylongcall(( |
| | | // (a, b) => { a, |
| | | // } b, |
| | | // }) ) => { |
| | | // }) |
| | | |
| | | if (shouldExpandParameters) { |
| | | return group$b(concat$d([removeLines$2(typeParams), "(", concat$d(printed.map(removeLines$2)), ")"])); |
| | | } // Single object destructuring should hug |
| | | // |
| | | // function({ |
| | | // a, |
| | | // b, |
| | | // c |
| | | // }) {} |
| | | |
| | | |
| | | var hasNotParameterDecorator = fun[paramsField].every(function (param) { |
| | | return !param.decorators; |
| | | }); |
| | | |
| | | if (shouldHugParameters && hasNotParameterDecorator) { |
| | | return concat$d([typeParams, "(", concat$d(printed), ")"]); |
| | | } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})` |
| | | |
| | | |
| | | if (isParametersInTestCall) { |
| | | return concat$d([typeParams, "(", concat$d(printed), ")"]); |
| | | } |
| | | |
| | | var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent, options) || isTypeAnnotationAFunction$1(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType$1(fun[paramsField][0].typeAnnotation) && !fun.rest; |
| | | |
| | | if (isFlowShorthandWithOneArg) { |
| | | if (options.arrowParens === "always") { |
| | | return concat$d(["(", concat$d(printed), ")"]); |
| | | } |
| | | |
| | | return concat$d(printed); |
| | | } |
| | | |
| | | var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest; |
| | | return concat$d([typeParams, "(", indent$7(concat$d([softline$6, concat$d(printed)])), ifBreak$6(canHaveTrailingComma && shouldPrintComma$1(options, "all") ? "," : ""), softline$6, ")"]); |
| | | } |
| | | |
| | | function shouldPrintParamsWithoutParens(path, options) { |
| | | if (options.arrowParens === "always") { |
| | | return false; |
| | | } |
| | | |
| | | if (options.arrowParens === "avoid") { |
| | | var node = path.getValue(); |
| | | return canPrintParamsWithoutParens(node); |
| | | } // Fallback default; should be unreachable |
| | | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function canPrintParamsWithoutParens(node) { |
| | | return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments$1(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType; |
| | | } |
| | | |
| | | function printFunctionDeclaration(path, print, options) { |
| | | var n = path.getValue(); |
| | | var parts = []; |
| | | |
| | | if (n.async) { |
| | | parts.push("async "); |
| | | } |
| | | |
| | | parts.push("function"); |
| | | |
| | | if (n.generator) { |
| | | parts.push("*"); |
| | | } |
| | | |
| | | if (n.id) { |
| | | parts.push(" ", path.call(print, "id")); |
| | | } |
| | | |
| | | parts.push(printFunctionTypeParameters(path, options, print), group$b(concat$d([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body")); |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printReturnType(path, print, options) { |
| | | var n = path.getValue(); |
| | | var returnType = path.call(print, "returnType"); |
| | | |
| | | if (n.returnType && isFlowAnnotationComment$1(options.originalText, n.returnType, options)) { |
| | | return concat$d([" /*: ", returnType, " */"]); |
| | | } |
| | | |
| | | var parts = [returnType]; // prepend colon to TypeScript type annotation |
| | | |
| | | if (n.returnType && n.returnType.typeAnnotation) { |
| | | parts.unshift(": "); |
| | | } |
| | | |
| | | if (n.predicate) { |
| | | // The return type will already add the colon, but otherwise we |
| | | // need to do it ourselves |
| | | parts.push(n.returnType ? " " : ": ", path.call(print, "predicate")); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printExportDeclaration(path, options, print) { |
| | | var decl = path.getValue(); |
| | | var semi = options.semi ? ";" : ""; |
| | | var parts = ["export "]; |
| | | var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration"; |
| | | |
| | | if (isDefault) { |
| | | parts.push("default "); |
| | | } |
| | | |
| | | parts.push(comments.printDanglingComments(path, options, |
| | | /* sameIndent */ |
| | | true)); |
| | | |
| | | if (needsHardlineAfterDanglingComment$1(decl)) { |
| | | parts.push(hardline$9); |
| | | } |
| | | |
| | | if (decl.declaration) { |
| | | parts.push(path.call(print, "declaration")); |
| | | |
| | | if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") { |
| | | parts.push(semi); |
| | | } |
| | | } else { |
| | | if (decl.specifiers && decl.specifiers.length > 0) { |
| | | var specifiers = []; |
| | | var defaultSpecifiers = []; |
| | | var namespaceSpecifiers = []; |
| | | path.each(function (specifierPath) { |
| | | var specifierType = path.getValue().type; |
| | | |
| | | if (specifierType === "ExportSpecifier") { |
| | | specifiers.push(print(specifierPath)); |
| | | } else if (specifierType === "ExportDefaultSpecifier") { |
| | | defaultSpecifiers.push(print(specifierPath)); |
| | | } else if (specifierType === "ExportNamespaceSpecifier") { |
| | | namespaceSpecifiers.push(concat$d(["* as ", print(specifierPath)])); |
| | | } |
| | | }, "specifiers"); |
| | | var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0; |
| | | var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0); |
| | | var canBreak = specifiers.length > 1 || defaultSpecifiers.length > 0 || decl.specifiers && decl.specifiers.some(function (node) { |
| | | return node.comments; |
| | | }); |
| | | var printed = ""; |
| | | |
| | | if (specifiers.length !== 0) { |
| | | if (canBreak) { |
| | | printed = group$b(concat$d(["{", indent$7(concat$d([options.bracketSpacing ? line$7 : softline$6, join$9(concat$d([",", line$7]), specifiers)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$7 : softline$6, "}"])); |
| | | } else { |
| | | printed = concat$d(["{", options.bracketSpacing ? " " : "", concat$d(specifiers), options.bracketSpacing ? " " : "", "}"]); |
| | | } |
| | | } |
| | | |
| | | parts.push(decl.exportKind === "type" ? "type " : "", concat$d(defaultSpecifiers), concat$d([isDefaultFollowed ? ", " : ""]), concat$d(namespaceSpecifiers), concat$d([isNamespaceFollowed ? ", " : ""]), printed); |
| | | } else { |
| | | parts.push("{}"); |
| | | } |
| | | |
| | | if (decl.source) { |
| | | parts.push(" from ", path.call(print, "source")); |
| | | } |
| | | |
| | | parts.push(semi); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printFlowDeclaration(path, parts) { |
| | | var parentExportDecl = getParentExportDeclaration$1(path); |
| | | |
| | | if (parentExportDecl) { |
| | | assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration"); |
| | | } else { |
| | | // If the parent node has type DeclareExportDeclaration, then it |
| | | // will be responsible for printing the "declare" token. Otherwise |
| | | // it needs to be printed with this non-exported declaration node. |
| | | parts.unshift("declare "); |
| | | } |
| | | |
| | | return concat$d(parts); |
| | | } |
| | | |
| | | function printTypeScriptModifiers(path, options, print) { |
| | | var n = path.getValue(); |
| | | |
| | | if (!n.modifiers || !n.modifiers.length) { |
| | | return ""; |
| | | } |
| | | |
| | | return concat$d([join$9(" ", path.map(print, "modifiers")), " "]); |
| | | } |
| | | |
| | | function printTypeParameters(path, options, print, paramsKey) { |
| | | var n = path.getValue(); |
| | | |
| | | if (!n[paramsKey]) { |
| | | return ""; |
| | | } // for TypeParameterDeclaration typeParameters is a single node |
| | | |
| | | |
| | | if (!Array.isArray(n[paramsKey])) { |
| | | return path.call(print, paramsKey); |
| | | } |
| | | |
| | | var grandparent = path.getNode(2); |
| | | var greatGreatGrandParent = path.getNode(4); |
| | | var isParameterInTestCall = grandparent != null && isTestCall$1(grandparent); |
| | | var shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation" || // See https://github.com/prettier/prettier/pull/6467 for the context. |
| | | greatGreatGrandParent && greatGreatGrandParent.type === "VariableDeclarator" && grandparent && grandparent.type === "TSTypeAnnotation" && n[paramsKey][0].type !== "TSUnionType" && n[paramsKey][0].type !== "UnionTypeAnnotation" && n[paramsKey][0].type !== "TSConditionalType" && n[paramsKey][0].type !== "TSMappedType"); |
| | | |
| | | if (shouldInline) { |
| | | return concat$d(["<", join$9(", ", path.map(print, paramsKey)), ">"]); |
| | | } |
| | | |
| | | return group$b(concat$d(["<", indent$7(concat$d([softline$6, join$9(concat$d([",", line$7]), path.map(print, paramsKey))])), ifBreak$6(options.parser !== "typescript" && shouldPrintComma$1(options, "all") ? "," : ""), softline$6, ">"])); |
| | | } |
| | | |
| | | function printClass(path, options, print) { |
| | | var n = path.getValue(); |
| | | var parts = []; |
| | | |
| | | if (n.abstract) { |
| | | parts.push("abstract "); |
| | | } |
| | | |
| | | parts.push("class"); |
| | | |
| | | if (n.id) { |
| | | parts.push(" ", path.call(print, "id")); |
| | | } |
| | | |
| | | parts.push(path.call(print, "typeParameters")); |
| | | var partsGroup = []; |
| | | |
| | | if (n.superClass) { |
| | | var printed = concat$d(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line |
| | | // If there is only on extends and there are not comments |
| | | |
| | | if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) { |
| | | parts.push(concat$d([" ", path.call(function (superClass) { |
| | | return comments.printComments(superClass, function () { |
| | | return printed; |
| | | }, options); |
| | | }, "superClass")])); |
| | | } else { |
| | | partsGroup.push(group$b(concat$d([line$7, path.call(function (superClass) { |
| | | return comments.printComments(superClass, function () { |
| | | return printed; |
| | | }, options); |
| | | }, "superClass")]))); |
| | | } |
| | | } else if (n.extends && n.extends.length > 0) { |
| | | parts.push(" extends ", join$9(", ", path.map(print, "extends"))); |
| | | } |
| | | |
| | | if (n["mixins"] && n["mixins"].length > 0) { |
| | | partsGroup.push(line$7, "mixins ", group$b(indent$7(join$9(concat$d([",", line$7]), path.map(print, "mixins"))))); |
| | | } |
| | | |
| | | if (n["implements"] && n["implements"].length > 0) { |
| | | partsGroup.push(line$7, "implements", group$b(indent$7(concat$d([line$7, join$9(concat$d([",", line$7]), path.map(print, "implements"))])))); |
| | | } |
| | | |
| | | if (partsGroup.length > 0) { |
| | | parts.push(group$b(indent$7(concat$d(partsGroup)))); |
| | | } |
| | | |
| | | if (n.body && n.body.comments && hasLeadingOwnLineComment$1(options.originalText, n.body, options)) { |
| | | parts.push(hardline$9); |
| | | } else { |
| | | parts.push(" "); |
| | | } |
| | | |
| | | parts.push(path.call(print, "body")); |
| | | return parts; |
| | | } |
| | | |
| | | function printOptionalToken(path) { |
| | | var node = path.getValue(); |
| | | |
| | | if (!node.optional || // It's an optional computed method parsed by typescript-estree. |
| | | // "?" is printed in `printMethod`. |
| | | node.type === "Identifier" && node === path.getParentNode().key) { |
| | | return ""; |
| | | } |
| | | |
| | | if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) { |
| | | return "?."; |
| | | } |
| | | |
| | | return "?"; |
| | | } |
| | | |
| | | function printMemberLookup(path, options, print) { |
| | | var property = path.call(print, "property"); |
| | | var n = path.getValue(); |
| | | var optional = printOptionalToken(path); |
| | | |
| | | if (!n.computed) { |
| | | return concat$d([optional, ".", property]); |
| | | } |
| | | |
| | | if (!n.property || isNumericLiteral$1(n.property)) { |
| | | return concat$d([optional, "[", property, "]"]); |
| | | } |
| | | |
| | | return group$b(concat$d([optional, "[", indent$7(concat$d([softline$6, property])), softline$6, "]"])); |
| | | } |
| | | |
| | | function printBindExpressionCallee(path, options, print) { |
| | | return concat$d(["::", path.call(print, "callee")]); |
| | | } // We detect calls on member expressions specially to format a |
| | | // common pattern better. The pattern we are looking for is this: |
| | | // |
| | | // arr |
| | | // .map(x => x + 1) |
| | | // .filter(x => x > 10) |
| | | // .some(x => x % 2) |
| | | // |
| | | // The way it is structured in the AST is via a nested sequence of |
| | | // MemberExpression and CallExpression. We need to traverse the AST |
| | | // and make groups out of it to print it in the desired way. |
| | | |
| | | |
| | | function printMemberChain(path, options, print) { |
| | | // The first phase is to linearize the AST by traversing it down. |
| | | // |
| | | // a().b() |
| | | // has the following AST structure: |
| | | // CallExpression(MemberExpression(CallExpression(Identifier))) |
| | | // and we transform it into |
| | | // [Identifier, CallExpression, MemberExpression, CallExpression] |
| | | var printedNodes = []; // Here we try to retain one typed empty line after each call expression or |
| | | // the first group whether it is in parentheses or not |
| | | |
| | | function shouldInsertEmptyLineAfter(node) { |
| | | var originalText = options.originalText; |
| | | var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options); |
| | | var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty |
| | | // line after that parenthesis |
| | | |
| | | if (nextChar == ")") { |
| | | return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options); |
| | | } |
| | | |
| | | return isNextLineEmpty$4(originalText, node, options); |
| | | } |
| | | |
| | | function rec(path) { |
| | | var node = path.getValue(); |
| | | |
| | | if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish$1(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) { |
| | | printedNodes.unshift({ |
| | | node: node, |
| | | printed: concat$d([comments.printComments(path, function () { |
| | | return concat$d([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]); |
| | | }, options), shouldInsertEmptyLineAfter(node) ? hardline$9 : ""]) |
| | | }); |
| | | path.call(function (callee) { |
| | | return rec(callee); |
| | | }, "callee"); |
| | | } else if (isMemberish$1(node)) { |
| | | printedNodes.unshift({ |
| | | node: node, |
| | | needsParens: needsParens_1(path, options), |
| | | printed: comments.printComments(path, function () { |
| | | return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print); |
| | | }, options) |
| | | }); |
| | | path.call(function (object) { |
| | | return rec(object); |
| | | }, "object"); |
| | | } else if (node.type === "TSNonNullExpression") { |
| | | printedNodes.unshift({ |
| | | node: node, |
| | | printed: comments.printComments(path, function () { |
| | | return "!"; |
| | | }, options) |
| | | }); |
| | | path.call(function (expression) { |
| | | return rec(expression); |
| | | }, "expression"); |
| | | } else { |
| | | printedNodes.unshift({ |
| | | node: node, |
| | | printed: path.call(print) |
| | | }); |
| | | } |
| | | } // Note: the comments of the root node have already been printed, so we |
| | | // need to extract this first call without printing them as they would |
| | | // if handled inside of the recursive call. |
| | | |
| | | |
| | | var node = path.getValue(); |
| | | printedNodes.unshift({ |
| | | node: node, |
| | | printed: concat$d([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]) |
| | | }); |
| | | path.call(function (callee) { |
| | | return rec(callee); |
| | | }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out |
| | | // of it. |
| | | // |
| | | // a().b.c().d().e |
| | | // will be grouped as |
| | | // [ |
| | | // [Identifier, CallExpression], |
| | | // [MemberExpression, MemberExpression, CallExpression], |
| | | // [MemberExpression, CallExpression], |
| | | // [MemberExpression], |
| | | // ] |
| | | // so that we can print it as |
| | | // a() |
| | | // .b.c() |
| | | // .d() |
| | | // .e |
| | | // The first group is the first node followed by |
| | | // - as many CallExpression as possible |
| | | // < fn()()() >.something() |
| | | // - as many array accessors as possible |
| | | // < fn()[0][1][2] >.something() |
| | | // - then, as many MemberExpression as possible but the last one |
| | | // < this.items >.something() |
| | | |
| | | var groups = []; |
| | | var currentGroup = [printedNodes[0]]; |
| | | var i = 1; |
| | | |
| | | for (; i < printedNodes.length; ++i) { |
| | | if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) { |
| | | currentGroup.push(printedNodes[i]); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") { |
| | | for (; i + 1 < printedNodes.length; ++i) { |
| | | if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) { |
| | | currentGroup.push(printedNodes[i]); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | groups.push(currentGroup); |
| | | currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by |
| | | // a sequence of CallExpression. To compute it, we keep adding things to the |
| | | // group until we has seen a CallExpression in the past and reach a |
| | | // MemberExpression |
| | | |
| | | var hasSeenCallExpression = false; |
| | | |
| | | for (; i < printedNodes.length; ++i) { |
| | | if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) { |
| | | // [0] should be appended at the end of the group instead of the |
| | | // beginning of the next one |
| | | if (printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) { |
| | | currentGroup.push(printedNodes[i]); |
| | | continue; |
| | | } |
| | | |
| | | groups.push(currentGroup); |
| | | currentGroup = []; |
| | | hasSeenCallExpression = false; |
| | | } |
| | | |
| | | if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") { |
| | | hasSeenCallExpression = true; |
| | | } |
| | | |
| | | currentGroup.push(printedNodes[i]); |
| | | |
| | | if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) { |
| | | return comment.trailing; |
| | | })) { |
| | | groups.push(currentGroup); |
| | | currentGroup = []; |
| | | hasSeenCallExpression = false; |
| | | } |
| | | } |
| | | |
| | | if (currentGroup.length > 0) { |
| | | groups.push(currentGroup); |
| | | } // There are cases like Object.keys(), Observable.of(), _.values() where |
| | | // they are the subject of all the chained calls and therefore should |
| | | // be kept on the same line: |
| | | // |
| | | // Object.keys(items) |
| | | // .filter(x => x) |
| | | // .map(x => x) |
| | | // |
| | | // In order to detect those cases, we use an heuristic: if the first |
| | | // node is an identifier with the name starting with a capital |
| | | // letter or just a sequence of _$. The rationale is that they are |
| | | // likely to be factories. |
| | | |
| | | |
| | | function isFactory(name) { |
| | | return /^[A-Z]|^[_$]+$/.test(name); |
| | | } // In case the Identifier is shorter than tab width, we can keep the |
| | | // first call in a single line, if it's an ExpressionStatement. |
| | | // |
| | | // d3.scaleLinear() |
| | | // .domain([0, 100]) |
| | | // .range([0, width]); |
| | | // |
| | | |
| | | |
| | | function isShort(name) { |
| | | return name.length <= options.tabWidth; |
| | | } |
| | | |
| | | function shouldNotWrap(groups) { |
| | | var parent = path.getParentNode(); |
| | | var isExpression = parent && parent.type === "ExpressionStatement"; |
| | | var hasComputed = groups[1].length && groups[1][0].node.computed; |
| | | |
| | | if (groups[0].length === 1) { |
| | | var firstNode = groups[0][0].node; |
| | | return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed); |
| | | } |
| | | |
| | | var lastNode = getLast$2(groups[0]).node; |
| | | return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed); |
| | | } |
| | | |
| | | var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups); |
| | | |
| | | function printGroup(printedGroup) { |
| | | var printed = printedGroup.map(function (tuple) { |
| | | return tuple.printed; |
| | | }); // Checks if the last node (i.e. the parent node) needs parens and print |
| | | // accordingly |
| | | |
| | | if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) { |
| | | return concat$d(["("].concat(_toConsumableArray(printed), [")"])); |
| | | } |
| | | |
| | | return concat$d(printed); |
| | | } |
| | | |
| | | function printIndentedGroup(groups) { |
| | | if (groups.length === 0) { |
| | | return ""; |
| | | } |
| | | |
| | | return indent$7(group$b(concat$d([hardline$9, join$9(hardline$9, groups.map(printGroup))]))); |
| | | } |
| | | |
| | | var printedGroups = groups.map(printGroup); |
| | | var oneLine = concat$d(printedGroups); |
| | | var cutoff = shouldMerge ? 3 : 2; |
| | | var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) { |
| | | return res.concat(group); |
| | | }, []); |
| | | var hasComment = flatGroups.slice(1, -1).some(function (node) { |
| | | return hasLeadingComment$3(node.node); |
| | | }) || flatGroups.slice(0, -1).some(function (node) { |
| | | return hasTrailingComment$1(node.node); |
| | | }) || groups[cutoff] && hasLeadingComment$3(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just |
| | | // render everything concatenated together. |
| | | |
| | | if (groups.length <= cutoff && !hasComment) { |
| | | if (isLongCurriedCallExpression$1(path)) { |
| | | return oneLine; |
| | | } |
| | | |
| | | return group$b(oneLine); |
| | | } // Find out the last node in the first group and check if it has an |
| | | // empty line after |
| | | |
| | | |
| | | var lastNodeBeforeIndent = getLast$2(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node; |
| | | var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent); |
| | | var expanded = concat$d([printGroup(groups[0]), shouldMerge ? concat$d(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$9 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]); |
| | | var callExpressions = printedNodes.map(function (_ref) { |
| | | var node = _ref.node; |
| | | return node; |
| | | }).filter(isCallOrOptionalCallExpression$1); // We don't want to print in one line if there's: |
| | | // * A comment. |
| | | // * 3 or more chained calls. |
| | | // * Any group but the last one has a hard line. |
| | | // If the last group is a function it's okay to inline if it fits. |
| | | |
| | | if (hasComment || callExpressions.length >= 3 || printedGroups.slice(0, -1).some(willBreak$1) || |
| | | /** |
| | | * scopes.filter(scope => scope.value !== '').map((scope, i) => { |
| | | * // multi line content |
| | | * }) |
| | | */ |
| | | function (lastGroupDoc, lastGroupNode) { |
| | | return isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$1(lastGroupDoc); |
| | | }(getLast$2(printedGroups), getLast$2(getLast$2(groups)).node) && callExpressions.slice(0, -1).some(function (n) { |
| | | return n.arguments.some(isFunctionOrArrowExpression$1); |
| | | })) { |
| | | return group$b(expanded); |
| | | } |
| | | |
| | | return concat$d([// We only need to check `oneLine` because if `expanded` is chosen |
| | | // that means that the parent group has already been broken |
| | | // naturally |
| | | willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$3 : "", conditionalGroup$1([oneLine, expanded])]); |
| | | } |
| | | |
| | | function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) { |
| | | if (isFacebookTranslationTag) { |
| | | return ""; |
| | | } |
| | | |
| | | if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) { |
| | | return child.length === 1 ? softline$6 : hardline$9; |
| | | } |
| | | |
| | | return softline$6; |
| | | } |
| | | |
| | | function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) { |
| | | if (isFacebookTranslationTag) { |
| | | return hardline$9; |
| | | } |
| | | |
| | | if (child.length === 1) { |
| | | return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$9 : softline$6; |
| | | } |
| | | |
| | | return hardline$9; |
| | | } // JSX Children are strange, mostly for two reasons: |
| | | // 1. JSX reads newlines into string values, instead of skipping them like JS |
| | | // 2. up to one whitespace between elements within a line is significant, |
| | | // but not between lines. |
| | | // |
| | | // Leading, trailing, and lone whitespace all need to |
| | | // turn themselves into the rather ugly `{' '}` when breaking. |
| | | // |
| | | // We print JSX using the `fill` doc primitive. |
| | | // This requires that we give it an array of alternating |
| | | // content and whitespace elements. |
| | | // To ensure this we add dummy `""` content elements as needed. |
| | | |
| | | |
| | | function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) { |
| | | var n = path.getValue(); |
| | | var children = []; // using `map` instead of `each` because it provides `i` |
| | | |
| | | path.map(function (childPath, i) { |
| | | var child = childPath.getValue(); |
| | | |
| | | if (isLiteral$1(child)) { |
| | | var text = rawText$1(child); // Contains a non-whitespace character |
| | | |
| | | if (isMeaningfulJSXText$1(child)) { |
| | | var words = text.split(matchJsxWhitespaceRegex$1); // Starts with whitespace |
| | | |
| | | if (words[0] === "") { |
| | | children.push(""); |
| | | words.shift(); |
| | | |
| | | if (/\n/.test(words[0])) { |
| | | var next = n.children[i + 1]; |
| | | children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next)); |
| | | } else { |
| | | children.push(jsxWhitespace); |
| | | } |
| | | |
| | | words.shift(); |
| | | } |
| | | |
| | | var endWhitespace; // Ends with whitespace |
| | | |
| | | if (getLast$2(words) === "") { |
| | | words.pop(); |
| | | endWhitespace = words.pop(); |
| | | } // This was whitespace only without a new line. |
| | | |
| | | |
| | | if (words.length === 0) { |
| | | return; |
| | | } |
| | | |
| | | words.forEach(function (word, i) { |
| | | if (i % 2 === 1) { |
| | | children.push(line$7); |
| | | } else { |
| | | children.push(word); |
| | | } |
| | | }); |
| | | |
| | | if (endWhitespace !== undefined) { |
| | | if (/\n/.test(endWhitespace)) { |
| | | var _next = n.children[i + 1]; |
| | | children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$2(children), child, _next)); |
| | | } else { |
| | | children.push(jsxWhitespace); |
| | | } |
| | | } else { |
| | | var _next2 = n.children[i + 1]; |
| | | children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$2(children), child, _next2)); |
| | | } |
| | | } else if (/\n/.test(text)) { |
| | | // Keep (up to one) blank line between tags/expressions/text. |
| | | // Note: We don't keep blank lines between text elements. |
| | | if (text.match(/\n/g).length > 1) { |
| | | children.push(""); |
| | | children.push(hardline$9); |
| | | } |
| | | } else { |
| | | children.push(""); |
| | | children.push(jsxWhitespace); |
| | | } |
| | | } else { |
| | | var printedChild = print(childPath); |
| | | children.push(printedChild); |
| | | var _next3 = n.children[i + 1]; |
| | | |
| | | var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText$1(_next3); |
| | | |
| | | if (directlyFollowedByMeaningfulText) { |
| | | var firstWord = rawText$1(_next3).trim().split(matchJsxWhitespaceRegex$1)[0]; |
| | | children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3)); |
| | | } else { |
| | | children.push(hardline$9); |
| | | } |
| | | } |
| | | }, "children"); |
| | | return children; |
| | | } // JSX expands children from the inside-out, instead of the outside-in. |
| | | // This is both to break children before attributes, |
| | | // and to ensure that when children break, their parents do as well. |
| | | // |
| | | // Any element that is written without any newlines and fits on a single line |
| | | // is left that way. |
| | | // Not only that, any user-written-line containing multiple JSX siblings |
| | | // should also be kept on one line if possible, |
| | | // so each user-written-line is wrapped in its own group. |
| | | // |
| | | // Elements that contain newlines or don't fit on a single line (recursively) |
| | | // are fully-split, using hardline and shouldBreak: true. |
| | | // |
| | | // To support that case properly, all leading and trailing spaces |
| | | // are stripped from the list of children, and replaced with a single hardline. |
| | | |
| | | |
| | | function printJSXElement(path, options, print) { |
| | | var n = path.getValue(); |
| | | |
| | | if (n.type === "JSXElement" && isEmptyJSXElement$1(n)) { |
| | | return concat$d([path.call(print, "openingElement"), path.call(print, "closingElement")]); |
| | | } |
| | | |
| | | var openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment"); |
| | | var closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment"); |
| | | |
| | | if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) { |
| | | return concat$d([openingLines, concat$d(path.map(print, "children")), closingLines]); |
| | | } // Convert `{" "}` to text nodes containing a space. |
| | | // This makes it easy to turn them into `jsxWhitespace` which |
| | | // can then print as either a space or `{" "}` when breaking. |
| | | |
| | | |
| | | n.children = n.children.map(function (child) { |
| | | if (isJSXWhitespaceExpression$1(child)) { |
| | | return { |
| | | type: "JSXText", |
| | | value: " ", |
| | | raw: " " |
| | | }; |
| | | } |
| | | |
| | | return child; |
| | | }); |
| | | var containsTag = n.children.filter(isJSXNode$1).length > 0; |
| | | var containsMultipleExpressions = n.children.filter(function (child) { |
| | | return child.type === "JSXExpressionContainer"; |
| | | }).length > 1; |
| | | var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true. |
| | | |
| | | var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions; |
| | | var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}'; |
| | | var jsxWhitespace = ifBreak$6(concat$d([rawJsxWhitespace, softline$6]), " "); |
| | | var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt"; |
| | | var children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag); |
| | | var containsText = n.children.filter(function (child) { |
| | | return isMeaningfulJSXText$1(child); |
| | | }).length > 0; // We can end up we multiple whitespace elements with empty string |
| | | // content between them. |
| | | // We need to remove empty whitespace and softlines before JSX whitespace |
| | | // to get the correct output. |
| | | |
| | | for (var i = children.length - 2; i >= 0; i--) { |
| | | var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === ""; |
| | | var isPairOfHardlines = children[i] === hardline$9 && children[i + 1] === "" && children[i + 2] === hardline$9; |
| | | var isLineFollowedByJSXWhitespace = (children[i] === softline$6 || children[i] === hardline$9) && children[i + 1] === "" && children[i + 2] === jsxWhitespace; |
| | | var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$6 || children[i + 2] === hardline$9); |
| | | var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace; |
| | | var isPairOfHardOrSoftLines = children[i] === softline$6 && children[i + 1] === "" && children[i + 2] === hardline$9 || children[i] === hardline$9 && children[i + 1] === "" && children[i + 2] === softline$6; |
| | | |
| | | if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) { |
| | | children.splice(i, 2); |
| | | } else if (isJSXWhitespaceFollowedByLine) { |
| | | children.splice(i + 1, 2); |
| | | } |
| | | } // Trim trailing lines (or empty strings) |
| | | |
| | | |
| | | while (children.length && (isLineNext$1(getLast$2(children)) || isEmpty$1(getLast$2(children)))) { |
| | | children.pop(); |
| | | } // Trim leading lines (or empty strings) |
| | | |
| | | |
| | | while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) { |
| | | children.shift(); |
| | | children.shift(); |
| | | } // Tweak how we format children if outputting this element over multiple lines. |
| | | // Also detect whether we will force this element to output over multiple lines. |
| | | |
| | | |
| | | var multilineChildren = []; |
| | | children.forEach(function (child, i) { |
| | | // There are a number of situations where we need to ensure we display |
| | | // whitespace as `{" "}` when outputting this element over multiple lines. |
| | | if (child === jsxWhitespace) { |
| | | if (i === 1 && children[i - 1] === "") { |
| | | if (children.length === 2) { |
| | | // Solitary whitespace |
| | | multilineChildren.push(rawJsxWhitespace); |
| | | return; |
| | | } // Leading whitespace |
| | | |
| | | |
| | | multilineChildren.push(concat$d([rawJsxWhitespace, hardline$9])); |
| | | return; |
| | | } else if (i === children.length - 1) { |
| | | // Trailing whitespace |
| | | multilineChildren.push(rawJsxWhitespace); |
| | | return; |
| | | } else if (children[i - 1] === "" && children[i - 2] === hardline$9) { |
| | | // Whitespace after line break |
| | | multilineChildren.push(rawJsxWhitespace); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | multilineChildren.push(child); |
| | | |
| | | if (willBreak$1(child)) { |
| | | forcedBreak = true; |
| | | } |
| | | }); // If there is text we use `fill` to fit as much onto each line as possible. |
| | | // When there is no text (just tags and expressions) we use `group` |
| | | // to output each on a separate line. |
| | | |
| | | var content = containsText ? fill$4(multilineChildren) : group$b(concat$d(multilineChildren), { |
| | | shouldBreak: true |
| | | }); |
| | | var multiLineElem = group$b(concat$d([openingLines, indent$7(concat$d([hardline$9, content])), hardline$9, closingLines])); |
| | | |
| | | if (forcedBreak) { |
| | | return multiLineElem; |
| | | } |
| | | |
| | | return conditionalGroup$1([group$b(concat$d([openingLines, concat$d(children), closingLines])), multiLineElem]); |
| | | } |
| | | |
| | | function maybeWrapJSXElementInParens(path, elem, options) { |
| | | var parent = path.getParentNode(); |
| | | |
| | | if (!parent) { |
| | | return elem; |
| | | } |
| | | |
| | | var NO_WRAP_PARENTS = { |
| | | ArrayExpression: true, |
| | | JSXAttribute: true, |
| | | JSXElement: true, |
| | | JSXExpressionContainer: true, |
| | | JSXFragment: true, |
| | | ExpressionStatement: true, |
| | | CallExpression: true, |
| | | OptionalCallExpression: true, |
| | | ConditionalExpression: true, |
| | | JsExpressionRoot: true |
| | | }; |
| | | |
| | | if (NO_WRAP_PARENTS[parent.type]) { |
| | | return elem; |
| | | } |
| | | |
| | | var shouldBreak = matchAncestorTypes$1(path, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]) || matchAncestorTypes$1(path, ["ArrowFunctionExpression", "OptionalCallExpression", "JSXExpressionContainer"]); |
| | | var needsParens = needsParens_1(path, options); |
| | | return group$b(concat$d([needsParens ? "" : ifBreak$6("("), indent$7(concat$d([softline$6, elem])), softline$6, needsParens ? "" : ifBreak$6(")")]), { |
| | | shouldBreak: shouldBreak |
| | | }); |
| | | } |
| | | |
| | | function shouldInlineLogicalExpression(node) { |
| | | if (node.type !== "LogicalExpression") { |
| | | return false; |
| | | } |
| | | |
| | | if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) { |
| | | return true; |
| | | } |
| | | |
| | | if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) { |
| | | return true; |
| | | } |
| | | |
| | | if (isJSXNode$1(node.right)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } // For binary expressions to be consistent, we need to group |
| | | // subsequent operators with the same precedence level under a single |
| | | // group. Otherwise they will be nested such that some of them break |
| | | // onto new lines but not all. Operators with the same precedence |
| | | // level should either all break or not. Because we group them by |
| | | // precedence level and the AST is structured based on precedence |
| | | // level, things are naturally broken up correctly, i.e. `&&` is |
| | | // broken before `+`. |
| | | |
| | | |
| | | function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) { |
| | | var parts = []; |
| | | var node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same. |
| | | |
| | | if (isBinaryish$1(node)) { |
| | | // Put all operators with the same precedence level in the same |
| | | // group. The reason we only need to do this with the `left` |
| | | // expression is because given an expression like `1 + 2 - 3`, it |
| | | // is always parsed like `((1 + 2) - 3)`, meaning the `left` side |
| | | // is where the rest of the expression will exist. Binary |
| | | // expressions on the right side mean they have a difference |
| | | // precedence level and should be treated as a separate group, so |
| | | // print them normally. (This doesn't hold for the `**` operator, |
| | | // which is unique in that it is right-associative.) |
| | | if (shouldFlatten$1(node.operator, node.left.operator)) { |
| | | // Flatten them out by recursively calling this function. |
| | | parts = parts.concat(path.call(function (left) { |
| | | return printBinaryishExpressions(left, print, options, |
| | | /* isNested */ |
| | | true, isInsideParenthesis); |
| | | }, "left")); |
| | | } else { |
| | | parts.push(path.call(print, "left")); |
| | | } |
| | | |
| | | var shouldInline = shouldInlineLogicalExpression(node); |
| | | var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$1(options.originalText, node.right, options); |
| | | var operator = node.type === "NGPipeExpression" ? "|" : node.operator; |
| | | var rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$b(indent$7(concat$d([softline$6, ": ", join$9(concat$d([softline$6, ":", ifBreak$6(" ")]), path.map(print, "arguments").map(function (arg) { |
| | | return align$1(2, group$b(arg)); |
| | | }))]))) : ""; |
| | | var right = shouldInline ? concat$d([operator, " ", path.call(print, "right"), rightSuffix]) : concat$d([lineBeforeOperator ? softline$6 : "", operator, lineBeforeOperator ? " " : line$7, path.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group |
| | | // in order to avoid having a small right part like -1 be on its own line. |
| | | |
| | | var parent = path.getParentNode(); |
| | | var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type; |
| | | parts.push(" ", shouldGroup ? group$b(right) : right); // The root comments are already printed, but we need to manually print |
| | | // the other ones since we don't call the normal print on BinaryExpression, |
| | | // only for the left and right parts |
| | | |
| | | if (isNested && node.comments) { |
| | | parts = comments.printComments(path, function () { |
| | | return concat$d(parts); |
| | | }, options); |
| | | } |
| | | } else { |
| | | // Our stopping case. Simply print the node normally. |
| | | parts.push(path.call(print)); |
| | | } |
| | | |
| | | return parts; |
| | | } |
| | | |
| | | function printAssignmentRight(leftNode, rightNode, printedRight, options) { |
| | | if (hasLeadingOwnLineComment$1(options.originalText, rightNode, options)) { |
| | | return indent$7(concat$d([hardline$9, printedRight])); |
| | | } |
| | | |
| | | var canBreak = isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish$1(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral$1(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral$1(rightNode) || isMemberExpressionChain$1(rightNode)) && // do not put values on a separate line from the key in json |
| | | options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression"; |
| | | |
| | | if (canBreak) { |
| | | return group$b(indent$7(concat$d([line$7, printedRight]))); |
| | | } |
| | | |
| | | return concat$d([" ", printedRight]); |
| | | } |
| | | |
| | | function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) { |
| | | if (!rightNode) { |
| | | return printedLeft; |
| | | } |
| | | |
| | | var printed = printAssignmentRight(leftNode, rightNode, printedRight, options); |
| | | return group$b(concat$d([printedLeft, operator, printed])); |
| | | } |
| | | |
| | | function adjustClause(node, clause, forceSpace) { |
| | | if (node.type === "EmptyStatement") { |
| | | return ";"; |
| | | } |
| | | |
| | | if (node.type === "BlockStatement" || forceSpace) { |
| | | return concat$d([" ", clause]); |
| | | } |
| | | |
| | | return indent$7(concat$d([line$7, clause])); |
| | | } |
| | | |
| | | function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) { |
| | | var raw = rawText$1(node); |
| | | var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral"; |
| | | return printString$2(raw, options, isDirectiveLiteral); |
| | | } |
| | | |
| | | function printRegex(node) { |
| | | var flags = node.flags.split("").sort().join(""); |
| | | return "/".concat(node.pattern, "/").concat(flags); |
| | | } |
| | | |
| | | function exprNeedsASIProtection(path, options) { |
| | | var node = path.getValue(); |
| | | var maybeASIProblem = needsParens_1(path, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode$1(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex; |
| | | |
| | | if (maybeASIProblem) { |
| | | return true; |
| | | } |
| | | |
| | | if (!hasNakedLeftSide$2(node)) { |
| | | return false; |
| | | } |
| | | |
| | | return path.call.apply(path, [function (childPath) { |
| | | return exprNeedsASIProtection(childPath, options); |
| | | }].concat(getLeftSidePathName$2(path, node))); |
| | | } |
| | | |
| | | function stmtNeedsASIProtection(path, options) { |
| | | var node = path.getNode(); |
| | | |
| | | if (node.type !== "ExpressionStatement") { |
| | | return false; |
| | | } |
| | | |
| | | return path.call(function (childPath) { |
| | | return exprNeedsASIProtection(childPath, options); |
| | | }, "expression"); |
| | | } |
| | | |
| | | function shouldHugType(node) { |
| | | if (isSimpleFlowType$1(node) || isObjectType$1(node)) { |
| | | return true; |
| | | } |
| | | |
| | | if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") { |
| | | var voidCount = node.types.filter(function (n) { |
| | | return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword"; |
| | | }).length; |
| | | var objectCount = node.types.filter(function (n) { |
| | | return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}> |
| | | n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference"; |
| | | }).length; |
| | | |
| | | if (node.types.length - 1 === voidCount && objectCount > 0) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function shouldHugArguments(fun) { |
| | | return fun && fun.params && fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "ArrayPattern" || fun.params[0].type === "Identifier" && fun.params[0].typeAnnotation && (fun.params[0].typeAnnotation.type === "TypeAnnotation" || fun.params[0].typeAnnotation.type === "TSTypeAnnotation") && isObjectType$1(fun.params[0].typeAnnotation.typeAnnotation) || fun.params[0].type === "FunctionTypeParam" && isObjectType$1(fun.params[0].typeAnnotation) || fun.params[0].type === "AssignmentPattern" && (fun.params[0].left.type === "ObjectPattern" || fun.params[0].left.type === "ArrayPattern") && (fun.params[0].right.type === "Identifier" || fun.params[0].right.type === "ObjectExpression" && fun.params[0].right.properties.length === 0 || fun.params[0].right.type === "ArrayExpression" && fun.params[0].right.elements.length === 0)) && !fun.rest; |
| | | } |
| | | |
| | | function printArrayItems(path, options, printPath, print) { |
| | | var printedElements = []; |
| | | var separatorParts = []; |
| | | path.each(function (childPath) { |
| | | printedElements.push(concat$d(separatorParts)); |
| | | printedElements.push(group$b(print(childPath))); |
| | | separatorParts = [",", line$7]; |
| | | |
| | | if (childPath.getValue() && isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) { |
| | | separatorParts.push(softline$6); |
| | | } |
| | | }, printPath); |
| | | return concat$d(printedElements); |
| | | } |
| | | |
| | | function willPrintOwnComments(path |
| | | /*, options */ |
| | | ) { |
| | | var node = path.getValue(); |
| | | var parent = path.getParentNode(); |
| | | return (node && (isJSXNode$1(node) || hasFlowShorthandAnnotationComment$2(node) || parent && (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && (hasFlowAnnotationComment$1(node.leadingComments) || hasFlowAnnotationComment$1(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && !hasIgnoreComment$4(path); |
| | | } |
| | | |
| | | function canAttachComment$1(node) { |
| | | return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"; |
| | | } |
| | | |
| | | function printComment$2(commentPath, options) { |
| | | var comment = commentPath.getValue(); |
| | | |
| | | switch (comment.type) { |
| | | case "CommentBlock": |
| | | case "Block": |
| | | { |
| | | if (isIndentableBlockComment(comment)) { |
| | | var printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment |
| | | // printed as a `lineSuffix` which causes the comments to be |
| | | // interleaved. See https://github.com/prettier/prettier/issues/4412 |
| | | |
| | | if (comment.trailing && !hasNewline$4(options.originalText, options.locStart(comment), { |
| | | backwards: true |
| | | })) { |
| | | return concat$d([hardline$9, printed]); |
| | | } |
| | | |
| | | return printed; |
| | | } |
| | | |
| | | var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/"; |
| | | return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/"); |
| | | } |
| | | |
| | | case "CommentLine": |
| | | case "Line": |
| | | // Print shebangs with the proper comment characters |
| | | if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) { |
| | | return "#!" + comment.value.trimRight(); |
| | | } |
| | | |
| | | return "//" + comment.value.trimRight(); |
| | | |
| | | default: |
| | | throw new Error("Not a comment: " + JSON.stringify(comment)); |
| | | } |
| | | } |
| | | |
| | | function isIndentableBlockComment(comment) { |
| | | // If the comment has multiple lines and every line starts with a star |
| | | // we can fix the indentation of each line. The stars in the `/*` and |
| | | // `*/` delimiters are not included in the comment value, so add them |
| | | // back first. |
| | | var lines = "*".concat(comment.value, "*").split("\n"); |
| | | return lines.length > 1 && lines.every(function (line) { |
| | | return line.trim()[0] === "*"; |
| | | }); |
| | | } |
| | | |
| | | function printIndentableBlockComment(comment) { |
| | | var lines = comment.value.split("\n"); |
| | | return concat$d(["/*", join$9(hardline$9, lines.map(function (line, index) { |
| | | return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft()); |
| | | })), "*/"]); |
| | | } |
| | | |
| | | var printerEstree = { |
| | | preprocess: preprocess_1$1, |
| | | print: genericPrint$3, |
| | | embed: embed_1$1, |
| | | insertPragma: insertPragma$7, |
| | | massageAstNode: clean_1$1, |
| | | hasPrettierIgnore: hasPrettierIgnore$3, |
| | | willPrintOwnComments: willPrintOwnComments, |
| | | canAttachComment: canAttachComment$1, |
| | | printComment: printComment$2, |
| | | isBlockComment: comments$1.isBlockComment, |
| | | handleComments: { |
| | | ownLine: comments$1.handleOwnLineComment, |
| | | endOfLine: comments$1.handleEndOfLineComment, |
| | | remaining: comments$1.handleRemainingComment |
| | | } |
| | | }; |
| | | |
| | | var _require$$0$builders$7 = doc.builders, |
| | | concat$e = _require$$0$builders$7.concat, |
| | | hardline$a = _require$$0$builders$7.hardline, |
| | | indent$8 = _require$$0$builders$7.indent, |
| | | join$a = _require$$0$builders$7.join; |
| | | |
| | | function genericPrint$4(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | switch (node.type) { |
| | | case "JsonRoot": |
| | | return concat$e([path.call(print, "node"), hardline$a]); |
| | | |
| | | case "ArrayExpression": |
| | | return node.elements.length === 0 ? "[]" : concat$e(["[", indent$8(concat$e([hardline$a, join$a(concat$e([",", hardline$a]), path.map(print, "elements"))])), hardline$a, "]"]); |
| | | |
| | | case "ObjectExpression": |
| | | return node.properties.length === 0 ? "{}" : concat$e(["{", indent$8(concat$e([hardline$a, join$a(concat$e([",", hardline$a]), path.map(print, "properties"))])), hardline$a, "}"]); |
| | | |
| | | case "ObjectProperty": |
| | | return concat$e([path.call(print, "key"), ": ", path.call(print, "value")]); |
| | | |
| | | case "UnaryExpression": |
| | | return concat$e([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]); |
| | | |
| | | case "NullLiteral": |
| | | return "null"; |
| | | |
| | | case "BooleanLiteral": |
| | | return node.value ? "true" : "false"; |
| | | |
| | | case "StringLiteral": |
| | | case "NumericLiteral": |
| | | return JSON.stringify(node.value); |
| | | |
| | | case "Identifier": |
| | | return JSON.stringify(node.name); |
| | | |
| | | default: |
| | | /* istanbul ignore next */ |
| | | throw new Error("unknown type: " + JSON.stringify(node.type)); |
| | | } |
| | | } |
| | | |
| | | function clean$5(node, newNode |
| | | /*, parent*/ |
| | | ) { |
| | | delete newNode.start; |
| | | delete newNode.end; |
| | | delete newNode.extra; |
| | | delete newNode.loc; |
| | | delete newNode.comments; |
| | | delete newNode.errors; |
| | | |
| | | if (node.type === "Identifier") { |
| | | return { |
| | | type: "StringLiteral", |
| | | value: node.name |
| | | }; |
| | | } |
| | | |
| | | if (node.type === "UnaryExpression" && node.operator === "+") { |
| | | return newNode.argument; |
| | | } |
| | | } |
| | | |
| | | var printerEstreeJson = { |
| | | preprocess: preprocess_1$1, |
| | | print: genericPrint$4, |
| | | massageAstNode: clean$5 |
| | | }; |
| | | |
| | | var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js |
| | | |
| | | var options$5 = { |
| | | arrowParens: { |
| | | since: "1.9.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "choice", |
| | | default: "avoid", |
| | | description: "Include parentheses around a sole arrow function parameter.", |
| | | choices: [{ |
| | | value: "avoid", |
| | | description: "Omit parens when possible. Example: `x => x`" |
| | | }, { |
| | | value: "always", |
| | | description: "Always include parens. Example: `(x) => x`" |
| | | }] |
| | | }, |
| | | bracketSpacing: commonOptions.bracketSpacing, |
| | | jsxBracketSameLine: { |
| | | since: "0.17.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Put > on the last line instead of at a new line." |
| | | }, |
| | | semi: { |
| | | since: "1.0.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "boolean", |
| | | default: true, |
| | | description: "Print semicolons.", |
| | | oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them." |
| | | }, |
| | | singleQuote: commonOptions.singleQuote, |
| | | jsxSingleQuote: { |
| | | since: "1.15.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "boolean", |
| | | default: false, |
| | | description: "Use single quotes in JSX." |
| | | }, |
| | | quoteProps: { |
| | | since: "1.17.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "choice", |
| | | default: "as-needed", |
| | | description: "Change when properties in objects are quoted.", |
| | | choices: [{ |
| | | value: "as-needed", |
| | | description: "Only add quotes around object properties where required." |
| | | }, { |
| | | value: "consistent", |
| | | description: "If at least one property in an object requires quotes, quote all properties." |
| | | }, { |
| | | value: "preserve", |
| | | description: "Respect the input use of quotes in object properties." |
| | | }] |
| | | }, |
| | | trailingComma: { |
| | | since: "0.0.0", |
| | | category: CATEGORY_JAVASCRIPT, |
| | | type: "choice", |
| | | default: [{ |
| | | since: "0.0.0", |
| | | value: false |
| | | }, { |
| | | since: "0.19.0", |
| | | value: "none" |
| | | }], |
| | | description: "Print trailing commas wherever possible when multi-line.", |
| | | choices: [{ |
| | | value: "none", |
| | | description: "No trailing commas." |
| | | }, { |
| | | value: "es5", |
| | | description: "Trailing commas where valid in ES5 (objects, arrays, etc.)" |
| | | }, { |
| | | value: "all", |
| | | description: "Trailing commas wherever possible (including function arguments)." |
| | | }, { |
| | | value: true, |
| | | deprecated: "0.19.0", |
| | | redirect: "es5" |
| | | }, { |
| | | value: false, |
| | | deprecated: "0.19.0", |
| | | redirect: "none" |
| | | }] |
| | | } |
| | | }; |
| | | |
| | | var name$9 = "JavaScript"; |
| | | var type$8 = "programming"; |
| | | var tmScope$8 = "source.js"; |
| | | var aceMode$8 = "javascript"; |
| | | var codemirrorMode$4 = "javascript"; |
| | | var codemirrorMimeType$4 = "text/javascript"; |
| | | var color$3 = "#f1e05a"; |
| | | var aliases$2 = [ |
| | | "js", |
| | | "node" |
| | | ]; |
| | | var extensions$8 = [ |
| | | ".js", |
| | | "._js", |
| | | ".bones", |
| | | ".es", |
| | | ".es6", |
| | | ".frag", |
| | | ".gs", |
| | | ".jake", |
| | | ".jsb", |
| | | ".jscad", |
| | | ".jsfl", |
| | | ".jsm", |
| | | ".jss", |
| | | ".mjs", |
| | | ".njs", |
| | | ".pac", |
| | | ".sjs", |
| | | ".ssjs", |
| | | ".xsjs", |
| | | ".xsjslib" |
| | | ]; |
| | | var filenames = [ |
| | | "Jakefile" |
| | | ]; |
| | | var interpreters = [ |
| | | "chakra", |
| | | "d8", |
| | | "js", |
| | | "node", |
| | | "rhino", |
| | | "v8", |
| | | "v8-shell" |
| | | ]; |
| | | var languageId$8 = 183; |
| | | var JavaScript = { |
| | | name: name$9, |
| | | type: type$8, |
| | | tmScope: tmScope$8, |
| | | aceMode: aceMode$8, |
| | | codemirrorMode: codemirrorMode$4, |
| | | codemirrorMimeType: codemirrorMimeType$4, |
| | | color: color$3, |
| | | aliases: aliases$2, |
| | | extensions: extensions$8, |
| | | filenames: filenames, |
| | | interpreters: interpreters, |
| | | languageId: languageId$8 |
| | | }; |
| | | |
| | | var JavaScript$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$9, |
| | | type: type$8, |
| | | tmScope: tmScope$8, |
| | | aceMode: aceMode$8, |
| | | codemirrorMode: codemirrorMode$4, |
| | | codemirrorMimeType: codemirrorMimeType$4, |
| | | color: color$3, |
| | | aliases: aliases$2, |
| | | extensions: extensions$8, |
| | | filenames: filenames, |
| | | interpreters: interpreters, |
| | | languageId: languageId$8, |
| | | 'default': JavaScript |
| | | }); |
| | | |
| | | var name$a = "JSX"; |
| | | var type$9 = "programming"; |
| | | var group$c = "JavaScript"; |
| | | var extensions$9 = [ |
| | | ".jsx" |
| | | ]; |
| | | var tmScope$9 = "source.js.jsx"; |
| | | var aceMode$9 = "javascript"; |
| | | var codemirrorMode$5 = "jsx"; |
| | | var codemirrorMimeType$5 = "text/jsx"; |
| | | var languageId$9 = 178; |
| | | var JSX = { |
| | | name: name$a, |
| | | type: type$9, |
| | | group: group$c, |
| | | extensions: extensions$9, |
| | | tmScope: tmScope$9, |
| | | aceMode: aceMode$9, |
| | | codemirrorMode: codemirrorMode$5, |
| | | codemirrorMimeType: codemirrorMimeType$5, |
| | | languageId: languageId$9 |
| | | }; |
| | | |
| | | var JSX$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$a, |
| | | type: type$9, |
| | | group: group$c, |
| | | extensions: extensions$9, |
| | | tmScope: tmScope$9, |
| | | aceMode: aceMode$9, |
| | | codemirrorMode: codemirrorMode$5, |
| | | codemirrorMimeType: codemirrorMimeType$5, |
| | | languageId: languageId$9, |
| | | 'default': JSX |
| | | }); |
| | | |
| | | var name$b = "TypeScript"; |
| | | var type$a = "programming"; |
| | | var color$4 = "#2b7489"; |
| | | var aliases$3 = [ |
| | | "ts" |
| | | ]; |
| | | var interpreters$1 = [ |
| | | "deno", |
| | | "ts-node" |
| | | ]; |
| | | var extensions$a = [ |
| | | ".ts" |
| | | ]; |
| | | var tmScope$a = "source.ts"; |
| | | var aceMode$a = "typescript"; |
| | | var codemirrorMode$6 = "javascript"; |
| | | var codemirrorMimeType$6 = "application/typescript"; |
| | | var languageId$a = 378; |
| | | var TypeScript = { |
| | | name: name$b, |
| | | type: type$a, |
| | | color: color$4, |
| | | aliases: aliases$3, |
| | | interpreters: interpreters$1, |
| | | extensions: extensions$a, |
| | | tmScope: tmScope$a, |
| | | aceMode: aceMode$a, |
| | | codemirrorMode: codemirrorMode$6, |
| | | codemirrorMimeType: codemirrorMimeType$6, |
| | | languageId: languageId$a |
| | | }; |
| | | |
| | | var TypeScript$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$b, |
| | | type: type$a, |
| | | color: color$4, |
| | | aliases: aliases$3, |
| | | interpreters: interpreters$1, |
| | | extensions: extensions$a, |
| | | tmScope: tmScope$a, |
| | | aceMode: aceMode$a, |
| | | codemirrorMode: codemirrorMode$6, |
| | | codemirrorMimeType: codemirrorMimeType$6, |
| | | languageId: languageId$a, |
| | | 'default': TypeScript |
| | | }); |
| | | |
| | | var name$c = "TSX"; |
| | | var type$b = "programming"; |
| | | var group$d = "TypeScript"; |
| | | var extensions$b = [ |
| | | ".tsx" |
| | | ]; |
| | | var tmScope$b = "source.tsx"; |
| | | var aceMode$b = "javascript"; |
| | | var codemirrorMode$7 = "jsx"; |
| | | var codemirrorMimeType$7 = "text/jsx"; |
| | | var languageId$b = 94901924; |
| | | var TSX = { |
| | | name: name$c, |
| | | type: type$b, |
| | | group: group$d, |
| | | extensions: extensions$b, |
| | | tmScope: tmScope$b, |
| | | aceMode: aceMode$b, |
| | | codemirrorMode: codemirrorMode$7, |
| | | codemirrorMimeType: codemirrorMimeType$7, |
| | | languageId: languageId$b |
| | | }; |
| | | |
| | | var TSX$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$c, |
| | | type: type$b, |
| | | group: group$d, |
| | | extensions: extensions$b, |
| | | tmScope: tmScope$b, |
| | | aceMode: aceMode$b, |
| | | codemirrorMode: codemirrorMode$7, |
| | | codemirrorMimeType: codemirrorMimeType$7, |
| | | languageId: languageId$b, |
| | | 'default': TSX |
| | | }); |
| | | |
| | | var name$d = "JSON"; |
| | | var type$c = "data"; |
| | | var tmScope$c = "source.json"; |
| | | var aceMode$c = "json"; |
| | | var codemirrorMode$8 = "javascript"; |
| | | var codemirrorMimeType$8 = "application/json"; |
| | | var searchable = false; |
| | | var extensions$c = [ |
| | | ".json", |
| | | ".avsc", |
| | | ".geojson", |
| | | ".gltf", |
| | | ".har", |
| | | ".ice", |
| | | ".JSON-tmLanguage", |
| | | ".jsonl", |
| | | ".mcmeta", |
| | | ".tfstate", |
| | | ".tfstate.backup", |
| | | ".topojson", |
| | | ".webapp", |
| | | ".webmanifest", |
| | | ".yy", |
| | | ".yyp" |
| | | ]; |
| | | var filenames$1 = [ |
| | | ".arcconfig", |
| | | ".htmlhintrc", |
| | | ".tern-config", |
| | | ".tern-project", |
| | | ".watchmanconfig", |
| | | "composer.lock", |
| | | "mcmod.info" |
| | | ]; |
| | | var languageId$c = 174; |
| | | var _JSON = { |
| | | name: name$d, |
| | | type: type$c, |
| | | tmScope: tmScope$c, |
| | | aceMode: aceMode$c, |
| | | codemirrorMode: codemirrorMode$8, |
| | | codemirrorMimeType: codemirrorMimeType$8, |
| | | searchable: searchable, |
| | | extensions: extensions$c, |
| | | filenames: filenames$1, |
| | | languageId: languageId$c |
| | | }; |
| | | |
| | | var _JSON$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$d, |
| | | type: type$c, |
| | | tmScope: tmScope$c, |
| | | aceMode: aceMode$c, |
| | | codemirrorMode: codemirrorMode$8, |
| | | codemirrorMimeType: codemirrorMimeType$8, |
| | | searchable: searchable, |
| | | extensions: extensions$c, |
| | | filenames: filenames$1, |
| | | languageId: languageId$c, |
| | | 'default': _JSON |
| | | }); |
| | | |
| | | var name$e = "JSON with Comments"; |
| | | var type$d = "data"; |
| | | var group$e = "JSON"; |
| | | var tmScope$d = "source.js"; |
| | | var aceMode$d = "javascript"; |
| | | var codemirrorMode$9 = "javascript"; |
| | | var codemirrorMimeType$9 = "text/javascript"; |
| | | var aliases$4 = [ |
| | | "jsonc" |
| | | ]; |
| | | var extensions$d = [ |
| | | ".sublime-build", |
| | | ".sublime-commands", |
| | | ".sublime-completions", |
| | | ".sublime-keymap", |
| | | ".sublime-macro", |
| | | ".sublime-menu", |
| | | ".sublime-mousemap", |
| | | ".sublime-project", |
| | | ".sublime-settings", |
| | | ".sublime-theme", |
| | | ".sublime-workspace", |
| | | ".sublime_metrics", |
| | | ".sublime_session" |
| | | ]; |
| | | var filenames$2 = [ |
| | | ".babelrc", |
| | | ".eslintrc.json", |
| | | ".jscsrc", |
| | | ".jshintrc", |
| | | ".jslintrc", |
| | | "jsconfig.json", |
| | | "language-configuration.json", |
| | | "tsconfig.json" |
| | | ]; |
| | | var languageId$d = 423; |
| | | var JSON_with_Comments = { |
| | | name: name$e, |
| | | type: type$d, |
| | | group: group$e, |
| | | tmScope: tmScope$d, |
| | | aceMode: aceMode$d, |
| | | codemirrorMode: codemirrorMode$9, |
| | | codemirrorMimeType: codemirrorMimeType$9, |
| | | aliases: aliases$4, |
| | | extensions: extensions$d, |
| | | filenames: filenames$2, |
| | | languageId: languageId$d |
| | | }; |
| | | |
| | | var JSON_with_Comments$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$e, |
| | | type: type$d, |
| | | group: group$e, |
| | | tmScope: tmScope$d, |
| | | aceMode: aceMode$d, |
| | | codemirrorMode: codemirrorMode$9, |
| | | codemirrorMimeType: codemirrorMimeType$9, |
| | | aliases: aliases$4, |
| | | extensions: extensions$d, |
| | | filenames: filenames$2, |
| | | languageId: languageId$d, |
| | | 'default': JSON_with_Comments |
| | | }); |
| | | |
| | | var name$f = "JSON5"; |
| | | var type$e = "data"; |
| | | var extensions$e = [ |
| | | ".json5" |
| | | ]; |
| | | var tmScope$e = "source.js"; |
| | | var aceMode$e = "javascript"; |
| | | var codemirrorMode$a = "javascript"; |
| | | var codemirrorMimeType$a = "application/json"; |
| | | var languageId$e = 175; |
| | | var JSON5 = { |
| | | name: name$f, |
| | | type: type$e, |
| | | extensions: extensions$e, |
| | | tmScope: tmScope$e, |
| | | aceMode: aceMode$e, |
| | | codemirrorMode: codemirrorMode$a, |
| | | codemirrorMimeType: codemirrorMimeType$a, |
| | | languageId: languageId$e |
| | | }; |
| | | |
| | | var JSON5$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$f, |
| | | type: type$e, |
| | | extensions: extensions$e, |
| | | tmScope: tmScope$e, |
| | | aceMode: aceMode$e, |
| | | codemirrorMode: codemirrorMode$a, |
| | | codemirrorMimeType: codemirrorMimeType$a, |
| | | languageId: languageId$e, |
| | | 'default': JSON5 |
| | | }); |
| | | |
| | | var require$$0$6 = getCjsExportFromNamespace(JavaScript$1); |
| | | |
| | | var require$$1$2 = getCjsExportFromNamespace(JSX$1); |
| | | |
| | | var require$$2$1 = getCjsExportFromNamespace(TypeScript$1); |
| | | |
| | | var require$$3$1 = getCjsExportFromNamespace(TSX$1); |
| | | |
| | | var require$$4 = getCjsExportFromNamespace(_JSON$1); |
| | | |
| | | var require$$5 = getCjsExportFromNamespace(JSON_with_Comments$1); |
| | | |
| | | var require$$6 = getCjsExportFromNamespace(JSON5$1); |
| | | |
| | | var languages$4 = [createLanguage(require$$0$6, function (data) { |
| | | return Object.assign(data, { |
| | | since: "0.0.0", |
| | | parsers: ["babel", "flow"], |
| | | vscodeLanguageIds: ["javascript", "mongo"], |
| | | interpreters: data.interpreters.concat(["nodejs"]) |
| | | }); |
| | | }), createLanguage(require$$0$6, function (data) { |
| | | return Object.assign(data, { |
| | | name: "Flow", |
| | | since: "0.0.0", |
| | | parsers: ["babel", "flow"], |
| | | vscodeLanguageIds: ["javascript"], |
| | | aliases: [], |
| | | filenames: [], |
| | | extensions: [".js.flow"] |
| | | }); |
| | | }), createLanguage(require$$1$2, function (data) { |
| | | return Object.assign(data, { |
| | | since: "0.0.0", |
| | | parsers: ["babel", "flow"], |
| | | vscodeLanguageIds: ["javascriptreact"] |
| | | }); |
| | | }), createLanguage(require$$2$1, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["typescript"], |
| | | vscodeLanguageIds: ["typescript"] |
| | | }); |
| | | }), createLanguage(require$$3$1, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.4.0", |
| | | parsers: ["typescript"], |
| | | vscodeLanguageIds: ["typescriptreact"] |
| | | }); |
| | | }), createLanguage(require$$4, function (data) { |
| | | return Object.assign(data, { |
| | | name: "JSON.stringify", |
| | | since: "1.13.0", |
| | | parsers: ["json-stringify"], |
| | | vscodeLanguageIds: ["json"], |
| | | extensions: [], |
| | | // .json file defaults to json instead of json-stringify |
| | | filenames: ["package.json", "package-lock.json", "composer.json"] |
| | | }); |
| | | }), createLanguage(require$$4, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.5.0", |
| | | parsers: ["json"], |
| | | vscodeLanguageIds: ["json"], |
| | | filenames: data.filenames.concat([".prettierrc"]) |
| | | }); |
| | | }), createLanguage(require$$5, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.5.0", |
| | | parsers: ["json"], |
| | | vscodeLanguageIds: ["jsonc"], |
| | | filenames: data.filenames.concat([".eslintrc"]) |
| | | }); |
| | | }), createLanguage(require$$6, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.13.0", |
| | | parsers: ["json5"], |
| | | vscodeLanguageIds: ["json5"] |
| | | }); |
| | | })]; |
| | | var printers$4 = { |
| | | estree: printerEstree, |
| | | "estree-json": printerEstreeJson |
| | | }; |
| | | var languageJs = { |
| | | languages: languages$4, |
| | | options: options$5, |
| | | printers: printers$4 |
| | | }; |
| | | |
| | | var json$1 = { |
| | | "cjkPattern": "[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]", |
| | | "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]", |
| | | "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]" |
| | | }; |
| | | |
| | | var cjkPattern = json$1.cjkPattern, |
| | | kPattern = json$1.kPattern, |
| | | punctuationPattern = json$1.punctuationPattern; |
| | | var getLast$3 = util.getLast; |
| | | var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"]; |
| | | var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]); |
| | | var kRegex = new RegExp(kPattern); |
| | | var punctuationRegex = new RegExp(punctuationPattern); |
| | | /** |
| | | * split text into whitespaces and words |
| | | * @param {string} text |
| | | * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} |
| | | */ |
| | | |
| | | function splitText(text, options) { |
| | | var KIND_NON_CJK = "non-cjk"; |
| | | var KIND_CJ_LETTER = "cj-letter"; |
| | | var KIND_K_LETTER = "k-letter"; |
| | | var KIND_CJK_PUNCTUATION = "cjk-punctuation"; |
| | | var nodes = []; |
| | | (options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")\n(").concat(cjkPattern, ")"), "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) { |
| | | // whitespace |
| | | if (index % 2 === 1) { |
| | | nodes.push({ |
| | | type: "whitespace", |
| | | value: /\n/.test(token) ? "\n" : " " |
| | | }); |
| | | return; |
| | | } // word separated by whitespace |
| | | |
| | | |
| | | if ((index === 0 || index === tokens.length - 1) && token === "") { |
| | | return; |
| | | } |
| | | |
| | | token.split(new RegExp("(".concat(cjkPattern, ")"))).forEach(function (innerToken, innerIndex, innerTokens) { |
| | | if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") { |
| | | return; |
| | | } // non-CJK word |
| | | |
| | | |
| | | if (innerIndex % 2 === 0) { |
| | | if (innerToken !== "") { |
| | | appendNode({ |
| | | type: "word", |
| | | value: innerToken, |
| | | kind: KIND_NON_CJK, |
| | | hasLeadingPunctuation: punctuationRegex.test(innerToken[0]), |
| | | hasTrailingPunctuation: punctuationRegex.test(getLast$3(innerToken)) |
| | | }); |
| | | } |
| | | |
| | | return; |
| | | } // CJK character |
| | | |
| | | |
| | | appendNode(punctuationRegex.test(innerToken) ? { |
| | | type: "word", |
| | | value: innerToken, |
| | | kind: KIND_CJK_PUNCTUATION, |
| | | hasLeadingPunctuation: true, |
| | | hasTrailingPunctuation: true |
| | | } : { |
| | | type: "word", |
| | | value: innerToken, |
| | | kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER, |
| | | hasLeadingPunctuation: false, |
| | | hasTrailingPunctuation: false |
| | | }); |
| | | }); |
| | | }); |
| | | return nodes; |
| | | |
| | | function appendNode(node) { |
| | | var lastNode = getLast$3(nodes); |
| | | |
| | | if (lastNode && lastNode.type === "word") { |
| | | if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) { |
| | | nodes.push({ |
| | | type: "whitespace", |
| | | value: " " |
| | | }); |
| | | } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace |
| | | ![lastNode.value, node.value].some(function (value) { |
| | | return /\u3000/.test(value); |
| | | })) { |
| | | nodes.push({ |
| | | type: "whitespace", |
| | | value: "" |
| | | }); |
| | | } |
| | | } |
| | | |
| | | nodes.push(node); |
| | | |
| | | function isBetween(kind1, kind2) { |
| | | return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | function getOrderedListItemInfo(orderListItem, originalText) { |
| | | var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/), |
| | | _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4), |
| | | numberText = _originalText$slice$m2[1], |
| | | marker = _originalText$slice$m2[2], |
| | | leadingSpaces = _originalText$slice$m2[3]; |
| | | |
| | | return { |
| | | numberText: numberText, |
| | | marker: marker, |
| | | leadingSpaces: leadingSpaces |
| | | }; |
| | | } // workaround for https://github.com/remarkjs/remark/issues/351 |
| | | // leading and trailing newlines are stripped by remark |
| | | |
| | | |
| | | function getFencedCodeBlockValue(node, originalText) { |
| | | var text = originalText.slice(node.position.start.offset, node.position.end.offset); |
| | | var leadingSpaceCount = text.match(/^\s*/)[0].length; |
| | | var replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}")); |
| | | var lineContents = text.split("\n"); |
| | | var markerStyle = text[leadingSpaceCount]; // ` or ~ |
| | | |
| | | var marker = text.slice(leadingSpaceCount).match(new RegExp("^[".concat(markerStyle, "]+")))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces |
| | | // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence |
| | | |
| | | var hasEndMarker = new RegExp("^\\s{0,3}".concat(marker)).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1))); |
| | | return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) { |
| | | return x.slice(getIndent(i + 1)).replace(replaceRegex, ""); |
| | | }).join("\n"); |
| | | |
| | | function getIndent(lineIndex) { |
| | | return node.position.indent[lineIndex - 1] - 1; |
| | | } |
| | | } |
| | | |
| | | function mapAst(ast, handler) { |
| | | return function preorder(node, index, parentStack) { |
| | | parentStack = parentStack || []; |
| | | var newNode = handler(node, index, parentStack); |
| | | |
| | | if (Array.isArray(newNode)) { |
| | | return newNode; |
| | | } |
| | | |
| | | newNode = Object.assign({}, newNode); |
| | | |
| | | if (newNode.children) { |
| | | newNode.children = newNode.children.reduce(function (nodes, child, index) { |
| | | var newNodes = preorder(child, index, [newNode].concat(parentStack)); |
| | | |
| | | if (!Array.isArray(newNodes)) { |
| | | newNodes = [newNodes]; |
| | | } |
| | | |
| | | nodes.push.apply(nodes, newNodes); |
| | | return nodes; |
| | | }, []); |
| | | } |
| | | |
| | | return newNode; |
| | | }(ast, null, null); |
| | | } |
| | | |
| | | var utils$5 = { |
| | | mapAst: mapAst, |
| | | splitText: splitText, |
| | | punctuationPattern: punctuationPattern, |
| | | getFencedCodeBlockValue: getFencedCodeBlockValue, |
| | | getOrderedListItemInfo: getOrderedListItemInfo, |
| | | INLINE_NODE_TYPES: INLINE_NODE_TYPES, |
| | | INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES |
| | | }; |
| | | |
| | | var _require$$0$builders$8 = doc.builders, |
| | | hardline$b = _require$$0$builders$8.hardline, |
| | | literalline$5 = _require$$0$builders$8.literalline, |
| | | concat$f = _require$$0$builders$8.concat, |
| | | markAsRoot$3 = _require$$0$builders$8.markAsRoot, |
| | | mapDoc$6 = doc.utils.mapDoc; |
| | | var getFencedCodeBlockValue$1 = utils$5.getFencedCodeBlockValue; |
| | | |
| | | function embed$4(path, print, textToDoc, options) { |
| | | var node = path.getValue(); |
| | | |
| | | if (node.type === "code" && node.lang !== null) { |
| | | // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk) |
| | | var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/); |
| | | var lang = langMatch ? langMatch[0] : ""; |
| | | var parser = getParserName(lang); |
| | | |
| | | if (parser) { |
| | | var styleUnit = options.__inJsTemplate ? "~" : "`"; |
| | | var style = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1)); |
| | | var doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), { |
| | | parser: parser |
| | | }); |
| | | return markAsRoot$3(concat$f([style, node.lang, hardline$b, replaceNewlinesWithLiterallines(doc), style])); |
| | | } |
| | | } |
| | | |
| | | if (node.type === "yaml") { |
| | | return markAsRoot$3(concat$f(["---", hardline$b, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, { |
| | | parser: "yaml" |
| | | })) : "", "---"])); |
| | | } // MDX |
| | | |
| | | |
| | | switch (node.type) { |
| | | case "importExport": |
| | | return textToDoc(node.value, { |
| | | parser: "babel" |
| | | }); |
| | | |
| | | case "jsx": |
| | | return textToDoc(node.value, { |
| | | parser: "__js_expression" |
| | | }); |
| | | } |
| | | |
| | | return null; |
| | | |
| | | function getParserName(lang) { |
| | | var supportInfo = support.getSupportInfo(null, { |
| | | plugins: options.plugins |
| | | }); |
| | | var language = supportInfo.languages.find(function (language) { |
| | | return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) { |
| | | return ext.substring(1) === lang; |
| | | }); |
| | | }); |
| | | |
| | | if (language) { |
| | | return language.parsers[0]; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | function replaceNewlinesWithLiterallines(doc) { |
| | | return mapDoc$6(doc, function (currentDoc) { |
| | | return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$f(currentDoc.split(/(\n)/g).map(function (v, i) { |
| | | return i % 2 === 0 ? v : literalline$5; |
| | | })) : currentDoc; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | var embed_1$2 = embed$4; |
| | | |
| | | var pragmas = ["format", "prettier"]; |
| | | |
| | | function startWithPragma(text) { |
| | | var pragma = "@(".concat(pragmas.join("|"), ")"); |
| | | var regex = new RegExp(["<!--\\s*".concat(pragma, "\\s*-->"), "<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*".concat(pragma, "[^\\S\n]*($|\n)[\\s\\S]*\n.*-->")].join("|"), "m"); |
| | | var matched = text.match(regex); |
| | | return matched && matched.index === 0; |
| | | } |
| | | |
| | | var pragma$4 = { |
| | | startWithPragma: startWithPragma, |
| | | hasPragma: function hasPragma(text) { |
| | | return startWithPragma(frontMatter(text).content.trimLeft()); |
| | | }, |
| | | insertPragma: function insertPragma(text) { |
| | | var extracted = frontMatter(text); |
| | | var pragma = "<!-- @".concat(pragmas[0], " -->"); |
| | | return extracted.frontMatter ? "".concat(extracted.frontMatter.raw, "\n\n").concat(pragma, "\n\n").concat(extracted.content) : "".concat(pragma, "\n\n").concat(extracted.content); |
| | | } |
| | | }; |
| | | |
| | | var getOrderedListItemInfo$1 = utils$5.getOrderedListItemInfo, |
| | | mapAst$1 = utils$5.mapAst, |
| | | splitText$1 = utils$5.splitText; // 0x0 ~ 0x10ffff |
| | | // eslint-disable-next-line no-control-regex |
| | | |
| | | var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/; |
| | | |
| | | function preprocess$2(ast, options) { |
| | | ast = restoreUnescapedCharacter(ast, options); |
| | | ast = mergeContinuousTexts(ast); |
| | | ast = transformInlineCode(ast); |
| | | ast = transformIndentedCodeblockAndMarkItsParentList(ast, options); |
| | | ast = markAlignedList(ast, options); |
| | | ast = splitTextIntoSentences(ast, options); |
| | | ast = transformImportExport(ast); |
| | | ast = mergeContinuousImportExport(ast); |
| | | return ast; |
| | | } |
| | | |
| | | function transformImportExport(ast) { |
| | | return mapAst$1(ast, function (node) { |
| | | if (node.type !== "import" && node.type !== "export") { |
| | | return node; |
| | | } |
| | | |
| | | return Object.assign({}, node, { |
| | | type: "importExport" |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function transformInlineCode(ast) { |
| | | return mapAst$1(ast, function (node) { |
| | | if (node.type !== "inlineCode") { |
| | | return node; |
| | | } |
| | | |
| | | return Object.assign({}, node, { |
| | | value: node.value.replace(/\s+/g, " ") |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function restoreUnescapedCharacter(ast, options) { |
| | | return mapAst$1(ast, function (node) { |
| | | return node.type !== "text" ? node : Object.assign({}, node, { |
| | | value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer |
| | | isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function mergeContinuousImportExport(ast) { |
| | | return mergeChildren(ast, function (prevNode, node) { |
| | | return prevNode.type === "importExport" && node.type === "importExport"; |
| | | }, function (prevNode, node) { |
| | | return { |
| | | type: "importExport", |
| | | value: prevNode.value + "\n\n" + node.value, |
| | | position: { |
| | | start: prevNode.position.start, |
| | | end: node.position.end |
| | | } |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | function mergeChildren(ast, shouldMerge, mergeNode) { |
| | | return mapAst$1(ast, function (node) { |
| | | if (!node.children) { |
| | | return node; |
| | | } |
| | | |
| | | var children = node.children.reduce(function (current, child) { |
| | | var lastChild = current[current.length - 1]; |
| | | |
| | | if (lastChild && shouldMerge(lastChild, child)) { |
| | | current.splice(-1, 1, mergeNode(lastChild, child)); |
| | | } else { |
| | | current.push(child); |
| | | } |
| | | |
| | | return current; |
| | | }, []); |
| | | return Object.assign({}, node, { |
| | | children: children |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function mergeContinuousTexts(ast) { |
| | | return mergeChildren(ast, function (prevNode, node) { |
| | | return prevNode.type === "text" && node.type === "text"; |
| | | }, function (prevNode, node) { |
| | | return { |
| | | type: "text", |
| | | value: prevNode.value + node.value, |
| | | position: { |
| | | start: prevNode.position.start, |
| | | end: node.position.end |
| | | } |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | function splitTextIntoSentences(ast, options) { |
| | | return mapAst$1(ast, function (node, index, _ref) { |
| | | var _ref2 = _slicedToArray(_ref, 1), |
| | | parentNode = _ref2[0]; |
| | | |
| | | if (node.type !== "text") { |
| | | return node; |
| | | } |
| | | |
| | | var value = node.value; |
| | | |
| | | if (parentNode.type === "paragraph") { |
| | | if (index === 0) { |
| | | value = value.trimLeft(); |
| | | } |
| | | |
| | | if (index === parentNode.children.length - 1) { |
| | | value = value.trimRight(); |
| | | } |
| | | } |
| | | |
| | | return { |
| | | type: "sentence", |
| | | position: node.position, |
| | | children: splitText$1(value, options) |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | function transformIndentedCodeblockAndMarkItsParentList(ast, options) { |
| | | return mapAst$1(ast, function (node, index, parentStack) { |
| | | if (node.type === "code") { |
| | | // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it |
| | | var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset)); |
| | | node.isIndented = isIndented; |
| | | |
| | | if (isIndented) { |
| | | for (var i = 0; i < parentStack.length; i++) { |
| | | var parent = parentStack[i]; // no need to check checked items |
| | | |
| | | if (parent.hasIndentedCodeblock) { |
| | | break; |
| | | } |
| | | |
| | | if (parent.type === "list") { |
| | | parent.hasIndentedCodeblock = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | } |
| | | |
| | | function markAlignedList(ast, options) { |
| | | return mapAst$1(ast, function (node, index, parentStack) { |
| | | if (node.type === "list" && node.children.length !== 0) { |
| | | // if one of its parents is not aligned, it's not possible to be aligned in sub-lists |
| | | for (var i = 0; i < parentStack.length; i++) { |
| | | var parent = parentStack[i]; |
| | | |
| | | if (parent.type === "list" && !parent.isAligned) { |
| | | node.isAligned = false; |
| | | return node; |
| | | } |
| | | } |
| | | |
| | | node.isAligned = isAligned(node); |
| | | } |
| | | |
| | | return node; |
| | | }); |
| | | |
| | | function getListItemStart(listItem) { |
| | | return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1; |
| | | } |
| | | |
| | | function isAligned(list) { |
| | | if (!list.ordered) { |
| | | /** |
| | | * - 123 |
| | | * - 123 |
| | | */ |
| | | return true; |
| | | } |
| | | |
| | | var _list$children = _slicedToArray(list.children, 2), |
| | | firstItem = _list$children[0], |
| | | secondItem = _list$children[1]; |
| | | |
| | | var firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText); |
| | | |
| | | if (firstInfo.leadingSpaces.length > 1) { |
| | | /** |
| | | * 1. 123 |
| | | * |
| | | * 1. 123 |
| | | * 1. 123 |
| | | */ |
| | | return true; |
| | | } |
| | | |
| | | var firstStart = getListItemStart(firstItem); |
| | | |
| | | if (firstStart === -1) { |
| | | /** |
| | | * 1. |
| | | * |
| | | * 1. |
| | | * 1. |
| | | */ |
| | | return false; |
| | | } |
| | | |
| | | if (list.children.length === 1) { |
| | | /** |
| | | * aligned: |
| | | * |
| | | * 11. 123 |
| | | * |
| | | * not aligned: |
| | | * |
| | | * 1. 123 |
| | | */ |
| | | return firstStart % options.tabWidth === 0; |
| | | } |
| | | |
| | | var secondStart = getListItemStart(secondItem); |
| | | |
| | | if (firstStart !== secondStart) { |
| | | /** |
| | | * 11. 123 |
| | | * 1. 123 |
| | | * |
| | | * 1. 123 |
| | | * 11. 123 |
| | | */ |
| | | return false; |
| | | } |
| | | |
| | | if (firstStart % options.tabWidth === 0) { |
| | | /** |
| | | * 11. 123 |
| | | * 12. 123 |
| | | */ |
| | | return true; |
| | | } |
| | | /** |
| | | * aligned: |
| | | * |
| | | * 11. 123 |
| | | * 1. 123 |
| | | * |
| | | * not aligned: |
| | | * |
| | | * 1. 123 |
| | | * 2. 123 |
| | | */ |
| | | |
| | | |
| | | var secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText); |
| | | return secondInfo.leadingSpaces.length > 1; |
| | | } |
| | | } |
| | | |
| | | var preprocess_1$2 = preprocess$2; |
| | | |
| | | var _require$$0$builders$9 = doc.builders, |
| | | breakParent$4 = _require$$0$builders$9.breakParent, |
| | | concat$g = _require$$0$builders$9.concat, |
| | | join$b = _require$$0$builders$9.join, |
| | | line$8 = _require$$0$builders$9.line, |
| | | literalline$6 = _require$$0$builders$9.literalline, |
| | | markAsRoot$4 = _require$$0$builders$9.markAsRoot, |
| | | hardline$c = _require$$0$builders$9.hardline, |
| | | softline$7 = _require$$0$builders$9.softline, |
| | | ifBreak$7 = _require$$0$builders$9.ifBreak, |
| | | fill$5 = _require$$0$builders$9.fill, |
| | | align$2 = _require$$0$builders$9.align, |
| | | indent$9 = _require$$0$builders$9.indent, |
| | | group$f = _require$$0$builders$9.group, |
| | | mapDoc$7 = doc.utils.mapDoc, |
| | | printDocToString$2 = doc.printer.printDocToString; |
| | | var getFencedCodeBlockValue$2 = utils$5.getFencedCodeBlockValue, |
| | | getOrderedListItemInfo$2 = utils$5.getOrderedListItemInfo, |
| | | splitText$2 = utils$5.splitText, |
| | | punctuationPattern$1 = utils$5.punctuationPattern, |
| | | INLINE_NODE_TYPES$1 = utils$5.INLINE_NODE_TYPES, |
| | | INLINE_NODE_WRAPPER_TYPES$1 = utils$5.INLINE_NODE_WRAPPER_TYPES; |
| | | var replaceEndOfLineWith$2 = util.replaceEndOfLineWith; |
| | | var TRAILING_HARDLINE_NODES = ["importExport"]; |
| | | var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"]; |
| | | var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition", "jsx"]; |
| | | |
| | | function genericPrint$5(path, options, print) { |
| | | var node = path.getValue(); |
| | | |
| | | if (shouldRemainTheSameContent(path)) { |
| | | return concat$g(splitText$2(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) { |
| | | return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options); |
| | | })); |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "root": |
| | | if (node.children.length === 0) { |
| | | return ""; |
| | | } |
| | | |
| | | return concat$g([normalizeDoc(printRoot(path, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$c : ""]); |
| | | |
| | | case "paragraph": |
| | | return printChildren$2(path, options, print, { |
| | | postprocessor: fill$5 |
| | | }); |
| | | |
| | | case "sentence": |
| | | return printChildren$2(path, options, print); |
| | | |
| | | case "word": |
| | | return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math) |
| | | .replace(new RegExp(["(^|".concat(punctuationPattern$1, ")(_+)"), "(_+)(".concat(punctuationPattern$1, "|$)")].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) { |
| | | return (underscore1 ? "".concat(text1).concat(underscore1) : "".concat(underscore2).concat(text2)).replace(/_/g, "\\_"); |
| | | }); |
| | | // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis |
| | | |
| | | case "whitespace": |
| | | { |
| | | var parentNode = path.getParentNode(); |
| | | var index = parentNode.children.indexOf(node); |
| | | var nextNode = parentNode.children[index + 1]; |
| | | var proseWrap = // leading char that may cause different syntax |
| | | nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap; |
| | | return printLine(path, node.value, { |
| | | proseWrap: proseWrap |
| | | }); |
| | | } |
| | | |
| | | case "emphasis": |
| | | { |
| | | var _parentNode = path.getParentNode(); |
| | | |
| | | var _index = _parentNode.children.indexOf(node); |
| | | |
| | | var prevNode = _parentNode.children[_index - 1]; |
| | | var _nextNode = _parentNode.children[_index + 1]; |
| | | var hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not |
| | | prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util.getLast(prevNode.children).type === "word" && !util.getLast(prevNode.children).hasTrailingPunctuation || _nextNode && _nextNode.type === "sentence" && _nextNode.children.length > 0 && _nextNode.children[0].type === "word" && !_nextNode.children[0].hasLeadingPunctuation; |
| | | var style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_"; |
| | | return concat$g([style, printChildren$2(path, options, print), style]); |
| | | } |
| | | |
| | | case "strong": |
| | | return concat$g(["**", printChildren$2(path, options, print), "**"]); |
| | | |
| | | case "delete": |
| | | return concat$g(["~~", printChildren$2(path, options, print), "~~"]); |
| | | |
| | | case "inlineCode": |
| | | { |
| | | var backtickCount = util.getMinNotPresentContinuousCount(node.value, "`"); |
| | | |
| | | var _style = "`".repeat(backtickCount || 1); |
| | | |
| | | var gap = backtickCount ? " " : ""; |
| | | return concat$g([_style, gap, node.value, gap, _style]); |
| | | } |
| | | |
| | | case "link": |
| | | switch (options.originalText[node.position.start.offset]) { |
| | | case "<": |
| | | { |
| | | var mailto = "mailto:"; |
| | | var url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" } |
| | | node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url; |
| | | return concat$g(["<", url, ">"]); |
| | | } |
| | | |
| | | case "[": |
| | | return concat$g(["[", printChildren$2(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]); |
| | | |
| | | default: |
| | | return options.originalText.slice(node.position.start.offset, node.position.end.offset); |
| | | } |
| | | |
| | | case "image": |
| | | return concat$g([""), printTitle(node.title, options), ")"]); |
| | | |
| | | case "blockquote": |
| | | return concat$g(["> ", align$2("> ", printChildren$2(path, options, print))]); |
| | | |
| | | case "heading": |
| | | return concat$g(["#".repeat(node.depth) + " ", printChildren$2(path, options, print)]); |
| | | |
| | | case "code": |
| | | { |
| | | if (node.isIndented) { |
| | | // indented code block |
| | | var alignment = " ".repeat(4); |
| | | return align$2(alignment, concat$g([alignment, concat$g(replaceEndOfLineWith$2(node.value, hardline$c))])); |
| | | } // fenced code block |
| | | |
| | | |
| | | var styleUnit = options.__inJsTemplate ? "~" : "`"; |
| | | |
| | | var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1)); |
| | | |
| | | return concat$g([_style2, node.lang || "", hardline$c, concat$g(replaceEndOfLineWith$2(getFencedCodeBlockValue$2(node, options.originalText), hardline$c)), hardline$c, _style2]); |
| | | } |
| | | |
| | | case "yaml": |
| | | case "toml": |
| | | return options.originalText.slice(node.position.start.offset, node.position.end.offset); |
| | | |
| | | case "html": |
| | | { |
| | | var _parentNode2 = path.getParentNode(); |
| | | |
| | | var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value; |
| | | var isHtmlComment = /^<!--[\s\S]*-->$/.test(value); |
| | | return concat$g(replaceEndOfLineWith$2(value, isHtmlComment ? hardline$c : markAsRoot$4(literalline$6))); |
| | | } |
| | | |
| | | case "list": |
| | | { |
| | | var nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode()); |
| | | var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo$2(node.children[1], options.originalText).numberText === 1; |
| | | return printChildren$2(path, options, print, { |
| | | processor: function processor(childPath, index) { |
| | | var prefix = getPrefix(); |
| | | return concat$g([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]); |
| | | |
| | | function getPrefix() { |
| | | var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* "; |
| | | return node.isAligned || |
| | | /* workaround for https://github.com/remarkjs/remark/issues/315 */ |
| | | node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | case "thematicBreak": |
| | | { |
| | | var counter = getAncestorCounter$1(path, "list"); |
| | | |
| | | if (counter === -1) { |
| | | return "---"; |
| | | } |
| | | |
| | | var _nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1)); |
| | | |
| | | return _nthSiblingIndex % 2 === 0 ? "***" : "---"; |
| | | } |
| | | |
| | | case "linkReference": |
| | | return concat$g(["[", printChildren$2(path, options, print), "]", node.referenceType === "full" ? concat$g(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]); |
| | | |
| | | case "imageReference": |
| | | switch (node.referenceType) { |
| | | case "full": |
| | | return concat$g(["![", node.alt || "", "][", node.identifier, "]"]); |
| | | |
| | | default: |
| | | return concat$g(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]); |
| | | } |
| | | |
| | | case "definition": |
| | | { |
| | | var lineOrSpace = options.proseWrap === "always" ? line$8 : " "; |
| | | return group$f(concat$g([concat$g(["[", node.identifier, "]:"]), indent$9(concat$g([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$g([lineOrSpace, printTitle(node.title, options, false)])]))])); |
| | | } |
| | | |
| | | case "footnote": |
| | | return concat$g(["[^", printChildren$2(path, options, print), "]"]); |
| | | |
| | | case "footnoteReference": |
| | | return concat$g(["[^", node.identifier, "]"]); |
| | | |
| | | case "footnoteDefinition": |
| | | { |
| | | var _nextNode2 = path.getParentNode().children[path.getName() + 1]; |
| | | var shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line); |
| | | return concat$g(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$2(path, options, print) : group$f(concat$g([align$2(" ".repeat(options.tabWidth), printChildren$2(path, options, print, { |
| | | processor: function processor(childPath, index) { |
| | | return index === 0 ? group$f(concat$g([softline$7, softline$7, childPath.call(print)])) : childPath.call(print); |
| | | } |
| | | })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$7 : ""]))]); |
| | | } |
| | | |
| | | case "table": |
| | | return printTable(path, options, print); |
| | | |
| | | case "tableCell": |
| | | return printChildren$2(path, options, print); |
| | | |
| | | case "break": |
| | | return /\s/.test(options.originalText[node.position.start.offset]) ? concat$g([" ", markAsRoot$4(literalline$6)]) : concat$g(["\\", hardline$c]); |
| | | |
| | | case "liquidNode": |
| | | return concat$g(replaceEndOfLineWith$2(node.value, hardline$c)); |
| | | // MDX |
| | | |
| | | case "importExport": |
| | | case "jsx": |
| | | return node.value; |
| | | // fallback to the original text if multiparser failed |
| | | |
| | | case "math": |
| | | return concat$g(["$$", hardline$c, node.value ? concat$g([concat$g(replaceEndOfLineWith$2(node.value, hardline$c)), hardline$c]) : "", "$$"]); |
| | | |
| | | case "inlineMath": |
| | | { |
| | | // remark-math trims content but we don't want to remove whitespaces |
| | | // since it's very possible that it's recognized as math accidentally |
| | | return options.originalText.slice(options.locStart(node), options.locEnd(node)); |
| | | } |
| | | |
| | | case "tableRow": // handled in "table" |
| | | |
| | | case "listItem": // handled in "list" |
| | | |
| | | default: |
| | | throw new Error("Unknown markdown type ".concat(JSON.stringify(node.type))); |
| | | } |
| | | } |
| | | |
| | | function printListItem(path, options, print, listPrefix) { |
| | | var node = path.getValue(); |
| | | var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] "; |
| | | return concat$g([prefix, printChildren$2(path, options, print, { |
| | | processor: function processor(childPath, index) { |
| | | if (index === 0 && childPath.getValue().type !== "list") { |
| | | return align$2(" ".repeat(prefix.length), childPath.call(print)); |
| | | } |
| | | |
| | | var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block |
| | | ); |
| | | return concat$g([alignment, align$2(alignment, childPath.call(print))]); |
| | | } |
| | | })]); |
| | | } |
| | | |
| | | function alignListPrefix(prefix, options) { |
| | | var additionalSpaces = getAdditionalSpaces(); |
| | | return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block |
| | | ); |
| | | |
| | | function getAdditionalSpaces() { |
| | | var restSpaces = prefix.length % options.tabWidth; |
| | | return restSpaces === 0 ? 0 : options.tabWidth - restSpaces; |
| | | } |
| | | } |
| | | |
| | | function getNthListSiblingIndex(node, parentNode) { |
| | | return getNthSiblingIndex(node, parentNode, function (siblingNode) { |
| | | return siblingNode.ordered === node.ordered; |
| | | }); |
| | | } |
| | | |
| | | function getNthSiblingIndex(node, parentNode, condition) { |
| | | condition = condition || function () { |
| | | return true; |
| | | }; |
| | | |
| | | var index = -1; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var childNode = _step.value; |
| | | |
| | | if (childNode.type === node.type && condition(childNode)) { |
| | | index++; |
| | | } else { |
| | | index = -1; |
| | | } |
| | | |
| | | if (childNode === node) { |
| | | return index; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | function getAncestorCounter$1(path, typeOrTypes) { |
| | | var types = [].concat(typeOrTypes); |
| | | var counter = -1; |
| | | var ancestorNode; |
| | | |
| | | while (ancestorNode = path.getParentNode(++counter)) { |
| | | if (types.indexOf(ancestorNode.type) !== -1) { |
| | | return counter; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | function getAncestorNode$2(path, typeOrTypes) { |
| | | var counter = getAncestorCounter$1(path, typeOrTypes); |
| | | return counter === -1 ? null : path.getParentNode(counter); |
| | | } |
| | | |
| | | function printLine(path, value, options) { |
| | | if (options.proseWrap === "preserve" && value === "\n") { |
| | | return hardline$c; |
| | | } |
| | | |
| | | var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES); |
| | | return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$7 : ""; |
| | | } |
| | | |
| | | function printTable(path, options, print) { |
| | | var hardlineWithoutBreakParent = hardline$c.parts[0]; |
| | | var node = path.getValue(); |
| | | var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } } |
| | | |
| | | path.map(function (rowPath) { |
| | | var rowContents = []; |
| | | rowPath.map(function (cellPath) { |
| | | rowContents.push(printDocToString$2(cellPath.call(print), options).formatted); |
| | | }, "children"); |
| | | contents.push(rowContents); |
| | | }, "children"); // Get the width of each column |
| | | |
| | | var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) { |
| | | return currentWidths.map(function (width, columnIndex) { |
| | | return Math.max(width, util.getStringWidth(rowContents[columnIndex])); |
| | | }); |
| | | }, contents[0].map(function () { |
| | | return 3; |
| | | }) // minimum width = 3 (---, :--, :-:, --:) |
| | | ); |
| | | var alignedTable = join$b(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$b(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) { |
| | | return printRow(rowContents); |
| | | }))]); |
| | | |
| | | if (options.proseWrap !== "never") { |
| | | return concat$g([breakParent$4, alignedTable]); |
| | | } // Only if the --prose-wrap never is set and it exceeds the print width. |
| | | |
| | | |
| | | var compactTable = join$b(hardlineWithoutBreakParent, [printRow(contents[0], |
| | | /* isCompact */ |
| | | true), printSeparator( |
| | | /* isCompact */ |
| | | true), join$b(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) { |
| | | return printRow(rowContents, |
| | | /* isCompact */ |
| | | true); |
| | | }))]); |
| | | return concat$g([breakParent$4, group$f(ifBreak$7(compactTable, alignedTable))]); |
| | | |
| | | function printSeparator(isCompact) { |
| | | return concat$g(["| ", join$b(" | ", columnMaxWidths.map(function (width, index) { |
| | | var spaces = isCompact ? 3 : width; |
| | | |
| | | switch (node.align[index]) { |
| | | case "left": |
| | | return ":" + "-".repeat(spaces - 1); |
| | | |
| | | case "right": |
| | | return "-".repeat(spaces - 1) + ":"; |
| | | |
| | | case "center": |
| | | return ":" + "-".repeat(spaces - 2) + ":"; |
| | | |
| | | default: |
| | | return "-".repeat(spaces); |
| | | } |
| | | })), " |"]); |
| | | } |
| | | |
| | | function printRow(rowContents, isCompact) { |
| | | return concat$g(["| ", join$b(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) { |
| | | switch (node.align[columnIndex]) { |
| | | case "right": |
| | | return alignRight(rowContent, columnMaxWidths[columnIndex]); |
| | | |
| | | case "center": |
| | | return alignCenter(rowContent, columnMaxWidths[columnIndex]); |
| | | |
| | | default: |
| | | return alignLeft(rowContent, columnMaxWidths[columnIndex]); |
| | | } |
| | | })), " |"]); |
| | | } |
| | | |
| | | function alignLeft(text, width) { |
| | | var spaces = width - util.getStringWidth(text); |
| | | return concat$g([text, " ".repeat(spaces)]); |
| | | } |
| | | |
| | | function alignRight(text, width) { |
| | | var spaces = width - util.getStringWidth(text); |
| | | return concat$g([" ".repeat(spaces), text]); |
| | | } |
| | | |
| | | function alignCenter(text, width) { |
| | | var spaces = width - util.getStringWidth(text); |
| | | var left = Math.floor(spaces / 2); |
| | | var right = spaces - left; |
| | | return concat$g([" ".repeat(left), text, " ".repeat(right)]); |
| | | } |
| | | } |
| | | |
| | | function printRoot(path, options, print) { |
| | | /** @typedef {{ index: number, offset: number }} IgnorePosition */ |
| | | |
| | | /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */ |
| | | var ignoreRanges = []; |
| | | /** @type {IgnorePosition | null} */ |
| | | |
| | | var ignoreStart = null; |
| | | var children = path.getValue().children; |
| | | children.forEach(function (childNode, index) { |
| | | switch (isPrettierIgnore$1(childNode)) { |
| | | case "start": |
| | | if (ignoreStart === null) { |
| | | ignoreStart = { |
| | | index: index, |
| | | offset: childNode.position.end.offset |
| | | }; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "end": |
| | | if (ignoreStart !== null) { |
| | | ignoreRanges.push({ |
| | | start: ignoreStart, |
| | | end: { |
| | | index: index, |
| | | offset: childNode.position.start.offset |
| | | } |
| | | }); |
| | | ignoreStart = null; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | }); |
| | | return printChildren$2(path, options, print, { |
| | | processor: function processor(childPath, index) { |
| | | if (ignoreRanges.length !== 0) { |
| | | var ignoreRange = ignoreRanges[0]; |
| | | |
| | | if (index === ignoreRange.start.index) { |
| | | return concat$g([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]); |
| | | } |
| | | |
| | | if (ignoreRange.start.index < index && index < ignoreRange.end.index) { |
| | | return false; |
| | | } |
| | | |
| | | if (index === ignoreRange.end.index) { |
| | | ignoreRanges.shift(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return childPath.call(print); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function printChildren$2(path, options, print, events) { |
| | | events = events || {}; |
| | | var postprocessor = events.postprocessor || concat$g; |
| | | |
| | | var processor = events.processor || function (childPath) { |
| | | return childPath.call(print); |
| | | }; |
| | | |
| | | var node = path.getValue(); |
| | | var parts = []; |
| | | var lastChildNode; |
| | | path.map(function (childPath, index) { |
| | | var childNode = childPath.getValue(); |
| | | var result = processor(childPath, index); |
| | | |
| | | if (result !== false) { |
| | | var data = { |
| | | parts: parts, |
| | | prevNode: lastChildNode, |
| | | parentNode: node, |
| | | options: options |
| | | }; |
| | | |
| | | if (!shouldNotPrePrintHardline(childNode, data)) { |
| | | parts.push(hardline$c); |
| | | |
| | | if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) { |
| | | if (shouldPrePrintTripleHardline(childNode, data)) { |
| | | parts.push(hardline$c); |
| | | } |
| | | } else { |
| | | if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) { |
| | | parts.push(hardline$c); |
| | | } |
| | | |
| | | if (shouldPrePrintTripleHardline(childNode, data)) { |
| | | parts.push(hardline$c); |
| | | } |
| | | } |
| | | } |
| | | |
| | | parts.push(result); |
| | | lastChildNode = childNode; |
| | | } |
| | | }, "children"); |
| | | return postprocessor(parts); |
| | | } |
| | | |
| | | function getLastDescendantNode(node) { |
| | | var current = node; |
| | | |
| | | while (current.children && current.children.length !== 0) { |
| | | current = current.children[current.children.length - 1]; |
| | | } |
| | | |
| | | return current; |
| | | } |
| | | /** @return {false | 'next' | 'start' | 'end'} */ |
| | | |
| | | |
| | | function isPrettierIgnore$1(node) { |
| | | if (node.type !== "html") { |
| | | return false; |
| | | } |
| | | |
| | | var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/); |
| | | return match === null ? false : match[1] ? match[1] : "next"; |
| | | } |
| | | |
| | | function isInlineNode(node) { |
| | | return node && INLINE_NODE_TYPES$1.indexOf(node.type) !== -1; |
| | | } |
| | | |
| | | function isEndsWithHardLine(node) { |
| | | return node && /\n+$/.test(node.value); |
| | | } |
| | | |
| | | function last(nodes) { |
| | | return nodes && nodes[nodes.length - 1]; |
| | | } |
| | | |
| | | function shouldNotPrePrintHardline(node, _ref) { |
| | | var parentNode = _ref.parentNode, |
| | | parts = _ref.parts, |
| | | prevNode = _ref.prevNode; |
| | | var isFirstNode = parts.length === 0; |
| | | var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES$1.indexOf(parentNode.type) !== -1; |
| | | var isAfterHardlineNode = prevNode && (isEndsWithHardLine(prevNode) || isEndsWithHardLine(last(prevNode.children))); |
| | | return isFirstNode || isInlineNode(node) || isInlineHTML || isAfterHardlineNode; |
| | | } |
| | | |
| | | function shouldPrePrintDoubleHardline(node, _ref2) { |
| | | var parentNode = _ref2.parentNode, |
| | | prevNode = _ref2.prevNode; |
| | | var prevNodeType = prevNode && prevNode.type; |
| | | var nodeType = node.type; |
| | | var isSequence = prevNodeType === nodeType; |
| | | var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(nodeType) !== -1; |
| | | var isInTightListItem = parentNode.type === "listItem" && !parentNode.loose; |
| | | var isPrevNodeLooseListItem = prevNodeType === "listItem" && prevNode.loose; |
| | | var isPrevNodePrettierIgnore = isPrettierIgnore$1(prevNode) === "next"; |
| | | var isBlockHtmlWithoutBlankLineBetweenPrevHtml = nodeType === "html" && prevNodeType === "html" && prevNode.position.end.line + 1 === node.position.start.line; |
| | | var isJsxInlineSibling = prevNodeType === "jsx" && isInlineNode(node) || nodeType === "jsx" && isInlineNode(prevNode); |
| | | return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isJsxInlineSibling); |
| | | } |
| | | |
| | | function shouldPrePrintTripleHardline(node, data) { |
| | | var isPrevNodeList = data.prevNode && data.prevNode.type === "list"; |
| | | var isIndentedCode = node.type === "code" && node.isIndented; |
| | | return isPrevNodeList && isIndentedCode; |
| | | } |
| | | |
| | | function shouldRemainTheSameContent(path) { |
| | | var ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]); |
| | | return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full"); |
| | | } |
| | | |
| | | function normalizeDoc(doc) { |
| | | return mapDoc$7(doc, function (currentDoc) { |
| | | if (!currentDoc.parts) { |
| | | return currentDoc; |
| | | } |
| | | |
| | | if (currentDoc.type === "concat" && currentDoc.parts.length === 1) { |
| | | return currentDoc.parts[0]; |
| | | } |
| | | |
| | | var parts = []; |
| | | currentDoc.parts.forEach(function (part) { |
| | | if (part.type === "concat") { |
| | | parts.push.apply(parts, part.parts); |
| | | } else if (part !== "") { |
| | | parts.push(part); |
| | | } |
| | | }); |
| | | return Object.assign({}, currentDoc, { |
| | | parts: normalizeParts$2(parts) |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function printUrl(url, dangerousCharOrChars) { |
| | | var dangerousChars = [" "].concat(dangerousCharOrChars || []); |
| | | return new RegExp(dangerousChars.map(function (x) { |
| | | return "\\".concat(x); |
| | | }).join("|")).test(url) ? "<".concat(url, ">") : url; |
| | | } |
| | | |
| | | function printTitle(title, options, printSpace) { |
| | | if (printSpace == null) { |
| | | printSpace = true; |
| | | } |
| | | |
| | | if (!title) { |
| | | return ""; |
| | | } |
| | | |
| | | if (printSpace) { |
| | | return " " + printTitle(title, options, false); |
| | | } |
| | | |
| | | if (title.includes('"') && title.includes("'") && !title.includes(")")) { |
| | | return "(".concat(title, ")"); // avoid escaped quotes |
| | | } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split |
| | | |
| | | |
| | | var singleCount = title.split("'").length - 1; |
| | | var doubleCount = title.split('"').length - 1; |
| | | var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"'; |
| | | title = title.replace(new RegExp("(".concat(quote, ")"), "g"), "\\$1"); |
| | | return "".concat(quote).concat(title).concat(quote); |
| | | } |
| | | |
| | | function normalizeParts$2(parts) { |
| | | return parts.reduce(function (current, part) { |
| | | var lastPart = util.getLast(current); |
| | | |
| | | if (typeof lastPart === "string" && typeof part === "string") { |
| | | current.splice(-1, 1, lastPart + part); |
| | | } else { |
| | | current.push(part); |
| | | } |
| | | |
| | | return current; |
| | | }, []); |
| | | } |
| | | |
| | | function clamp(value, min, max) { |
| | | return value < min ? min : value > max ? max : value; |
| | | } |
| | | |
| | | function clean$6(ast, newObj, parent) { |
| | | delete newObj.position; |
| | | delete newObj.raw; // front-matter |
| | | // for codeblock |
| | | |
| | | if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") { |
| | | delete newObj.value; |
| | | } |
| | | |
| | | if (ast.type === "list") { |
| | | delete newObj.isAligned; |
| | | } // texts can be splitted or merged |
| | | |
| | | |
| | | if (ast.type === "text") { |
| | | return null; |
| | | } |
| | | |
| | | if (ast.type === "inlineCode") { |
| | | newObj.value = ast.value.replace(/[ \t\n]+/g, " "); |
| | | } // for insert pragma |
| | | |
| | | |
| | | if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$4.startWithPragma(ast.value)) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | function hasPrettierIgnore$4(path) { |
| | | var index = +path.getName(); |
| | | |
| | | if (index === 0) { |
| | | return false; |
| | | } |
| | | |
| | | var prevNode = path.getParentNode().children[index - 1]; |
| | | return isPrettierIgnore$1(prevNode) === "next"; |
| | | } |
| | | |
| | | var printerMarkdown = { |
| | | preprocess: preprocess_1$2, |
| | | print: genericPrint$5, |
| | | embed: embed_1$2, |
| | | massageAstNode: clean$6, |
| | | hasPrettierIgnore: hasPrettierIgnore$4, |
| | | insertPragma: pragma$4.insertPragma |
| | | }; |
| | | |
| | | var options$6 = { |
| | | proseWrap: commonOptions.proseWrap, |
| | | singleQuote: commonOptions.singleQuote |
| | | }; |
| | | |
| | | var name$g = "Markdown"; |
| | | var type$f = "prose"; |
| | | var aliases$5 = [ |
| | | "pandoc" |
| | | ]; |
| | | var aceMode$f = "markdown"; |
| | | var codemirrorMode$b = "gfm"; |
| | | var codemirrorMimeType$b = "text/x-gfm"; |
| | | var wrap = true; |
| | | var extensions$f = [ |
| | | ".md", |
| | | ".markdown", |
| | | ".mdown", |
| | | ".mdwn", |
| | | ".mdx", |
| | | ".mkd", |
| | | ".mkdn", |
| | | ".mkdown", |
| | | ".ronn", |
| | | ".workbook" |
| | | ]; |
| | | var filenames$3 = [ |
| | | "contents.lr" |
| | | ]; |
| | | var tmScope$f = "source.gfm"; |
| | | var languageId$f = 222; |
| | | var Markdown = { |
| | | name: name$g, |
| | | type: type$f, |
| | | aliases: aliases$5, |
| | | aceMode: aceMode$f, |
| | | codemirrorMode: codemirrorMode$b, |
| | | codemirrorMimeType: codemirrorMimeType$b, |
| | | wrap: wrap, |
| | | extensions: extensions$f, |
| | | filenames: filenames$3, |
| | | tmScope: tmScope$f, |
| | | languageId: languageId$f |
| | | }; |
| | | |
| | | var Markdown$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$g, |
| | | type: type$f, |
| | | aliases: aliases$5, |
| | | aceMode: aceMode$f, |
| | | codemirrorMode: codemirrorMode$b, |
| | | codemirrorMimeType: codemirrorMimeType$b, |
| | | wrap: wrap, |
| | | extensions: extensions$f, |
| | | filenames: filenames$3, |
| | | tmScope: tmScope$f, |
| | | languageId: languageId$f, |
| | | 'default': Markdown |
| | | }); |
| | | |
| | | var require$$0$7 = getCjsExportFromNamespace(Markdown$1); |
| | | |
| | | var languages$5 = [createLanguage(require$$0$7, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.8.0", |
| | | parsers: ["remark"], |
| | | vscodeLanguageIds: ["markdown"], |
| | | filenames: data.filenames.concat(["README"]), |
| | | extensions: data.extensions.filter(function (extension) { |
| | | return extension !== ".mdx"; |
| | | }) |
| | | }); |
| | | }), createLanguage(require$$0$7, function (data) { |
| | | return Object.assign(data, { |
| | | name: "MDX", |
| | | since: "1.15.0", |
| | | parsers: ["mdx"], |
| | | vscodeLanguageIds: ["mdx"], |
| | | filenames: [], |
| | | extensions: [".mdx"] |
| | | }); |
| | | })]; |
| | | var printers$5 = { |
| | | mdast: printerMarkdown |
| | | }; |
| | | var languageMarkdown = { |
| | | languages: languages$5, |
| | | options: options$6, |
| | | printers: printers$5 |
| | | }; |
| | | |
| | | function isPragma(text) { |
| | | return /^\s*@(prettier|format)\s*$/.test(text); |
| | | } |
| | | |
| | | function hasPragma$4(text) { |
| | | return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text); |
| | | } |
| | | |
| | | function insertPragma$8(text) { |
| | | return "# @format\n\n".concat(text); |
| | | } |
| | | |
| | | var pragma$5 = { |
| | | isPragma: isPragma, |
| | | hasPragma: hasPragma$4, |
| | | insertPragma: insertPragma$8 |
| | | }; |
| | | |
| | | var getLast$4 = util.getLast; |
| | | |
| | | function getAncestorCount(path, filter) { |
| | | var counter = 0; |
| | | var pathStackLength = path.stack.length - 1; |
| | | |
| | | for (var i = 0; i < pathStackLength; i++) { |
| | | var value = path.stack[i]; |
| | | |
| | | if (isNode(value) && filter(value)) { |
| | | counter++; |
| | | } |
| | | } |
| | | |
| | | return counter; |
| | | } |
| | | /** |
| | | * @param {any} value |
| | | * @param {string[]=} types |
| | | */ |
| | | |
| | | |
| | | function isNode(value, types) { |
| | | return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1); |
| | | } |
| | | |
| | | function mapNode(node, callback, parent) { |
| | | return callback("children" in node ? Object.assign({}, node, { |
| | | children: node.children.map(function (childNode) { |
| | | return mapNode(childNode, callback, node); |
| | | }) |
| | | }) : node, parent); |
| | | } |
| | | |
| | | function defineShortcut(x, key, getter) { |
| | | Object.defineProperty(x, key, { |
| | | get: getter, |
| | | enumerable: false |
| | | }); |
| | | } |
| | | |
| | | function isNextLineEmpty$5(node, text) { |
| | | var newlineCount = 0; |
| | | var textLength = text.length; |
| | | |
| | | for (var i = node.position.end.offset - 1; i < textLength; i++) { |
| | | var char = text[i]; |
| | | |
| | | if (char === "\n") { |
| | | newlineCount++; |
| | | } |
| | | |
| | | if (newlineCount === 1 && /\S/.test(char)) { |
| | | return false; |
| | | } |
| | | |
| | | if (newlineCount === 2) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function isLastDescendantNode(path) { |
| | | var node = path.getValue(); |
| | | |
| | | switch (node.type) { |
| | | case "tag": |
| | | case "anchor": |
| | | case "comment": |
| | | return false; |
| | | } |
| | | |
| | | var pathStackLength = path.stack.length; |
| | | |
| | | for (var i = 1; i < pathStackLength; i++) { |
| | | var item = path.stack[i]; |
| | | var parentItem = path.stack[i - 1]; |
| | | |
| | | if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function getLastDescendantNode$1(node) { |
| | | return "children" in node && node.children.length !== 0 ? getLastDescendantNode$1(getLast$4(node.children)) : node; |
| | | } |
| | | |
| | | function isPrettierIgnore$2(comment) { |
| | | return comment.value.trim() === "prettier-ignore"; |
| | | } |
| | | |
| | | function hasPrettierIgnore$5(path) { |
| | | var node = path.getValue(); |
| | | |
| | | if (node.type === "documentBody") { |
| | | var document = path.getParentNode(); |
| | | return hasEndComments(document.head) && isPrettierIgnore$2(getLast$4(document.head.endComments)); |
| | | } |
| | | |
| | | return hasLeadingComments(node) && isPrettierIgnore$2(getLast$4(node.leadingComments)); |
| | | } |
| | | |
| | | function isEmptyNode(node) { |
| | | return (!node.children || node.children.length === 0) && !hasComments(node); |
| | | } |
| | | |
| | | function hasComments(node) { |
| | | return hasLeadingComments(node) || hasMiddleComments(node) || hasIndicatorComment(node) || hasTrailingComment$2(node) || hasEndComments(node); |
| | | } |
| | | |
| | | function hasLeadingComments(node) { |
| | | return node && node.leadingComments && node.leadingComments.length !== 0; |
| | | } |
| | | |
| | | function hasMiddleComments(node) { |
| | | return node && node.middleComments && node.middleComments.length !== 0; |
| | | } |
| | | |
| | | function hasIndicatorComment(node) { |
| | | return node && node.indicatorComment; |
| | | } |
| | | |
| | | function hasTrailingComment$2(node) { |
| | | return node && node.trailingComment; |
| | | } |
| | | |
| | | function hasEndComments(node) { |
| | | return node && node.endComments && node.endComments.length !== 0; |
| | | } |
| | | /** |
| | | * " a b c d e f " -> [" a b", "c d", "e f "] |
| | | */ |
| | | |
| | | |
| | | function splitWithSingleSpace(text) { |
| | | var parts = []; |
| | | var lastPart = undefined; |
| | | var _iteratorNormalCompletion = true; |
| | | var _didIteratorError = false; |
| | | var _iteratorError = undefined; |
| | | |
| | | try { |
| | | for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| | | var part = _step.value; |
| | | |
| | | if (part !== " ") { |
| | | if (lastPart === " ") { |
| | | parts.push(part); |
| | | } else { |
| | | parts.push((parts.pop() || "") + part); |
| | | } |
| | | } else if (lastPart === undefined) { |
| | | parts.unshift(""); |
| | | } |
| | | |
| | | lastPart = part; |
| | | } |
| | | } catch (err) { |
| | | _didIteratorError = true; |
| | | _iteratorError = err; |
| | | } finally { |
| | | try { |
| | | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| | | _iterator.return(); |
| | | } |
| | | } finally { |
| | | if (_didIteratorError) { |
| | | throw _iteratorError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (lastPart === " ") { |
| | | parts.push((parts.pop() || "") + " "); |
| | | } |
| | | |
| | | if (parts[0] === "") { |
| | | parts.shift(); |
| | | parts.unshift(" " + (parts.shift() || "")); |
| | | } |
| | | |
| | | return parts; |
| | | } |
| | | |
| | | function getFlowScalarLineContents(nodeType, content, options) { |
| | | var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) { |
| | | return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft(); |
| | | }); |
| | | |
| | | if (options.proseWrap === "preserve") { |
| | | return rawLineContents.map(function (lineContent) { |
| | | return lineContent.length === 0 ? [] : [lineContent]; |
| | | }); |
| | | } |
| | | |
| | | return rawLineContents.map(function (lineContent) { |
| | | return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent); |
| | | }).reduce(function (reduced, lineContentWords, index) { |
| | | return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved |
| | | nodeType === "quoteDouble" && getLast$4(getLast$4(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]); |
| | | }, []).map(function (lineContentWords) { |
| | | return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords; |
| | | }); |
| | | } |
| | | |
| | | function getBlockValueLineContents(node, _ref) { |
| | | var parentIndent = _ref.parentIndent, |
| | | isLastDescendant = _ref.isLastDescendant, |
| | | options = _ref.options; |
| | | var content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|` |
| | | .match(/^[^\n]*?\n([\s\S]*)$/)[1]; |
| | | var leadingSpaceCount = node.indent === null ? function (match) { |
| | | return match ? match[1].length : Infinity; |
| | | }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent; |
| | | var rawLineContents = content.split("\n").map(function (lineContent) { |
| | | return lineContent.slice(leadingSpaceCount); |
| | | }); |
| | | |
| | | if (options.proseWrap === "preserve" || node.type === "blockLiteral") { |
| | | return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) { |
| | | return lineContent.length === 0 ? [] : [lineContent]; |
| | | })); |
| | | } |
| | | |
| | | return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) { |
| | | return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent); |
| | | }).reduce(function (reduced, lineContentWords, index) { |
| | | return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$4(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]); |
| | | }, []).map(function (lineContentWords) { |
| | | return lineContentWords.reduce(function (reduced, word) { |
| | | return (// disallow trailing spaces |
| | | reduced.length !== 0 && /\s$/.test(getLast$4(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word) |
| | | ); |
| | | }, []); |
| | | }).map(function (lineContentWords) { |
| | | return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords; |
| | | })); |
| | | |
| | | function removeUnnecessaryTrailingNewlines(lineContents) { |
| | | if (node.chomping === "keep") { |
| | | return getLast$4(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents; |
| | | } |
| | | |
| | | var trailingNewlineCount = 0; |
| | | |
| | | for (var i = lineContents.length - 1; i >= 0; i--) { |
| | | if (lineContents[i].length === 0) { |
| | | trailingNewlineCount++; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line |
| | | lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount); |
| | | } |
| | | } |
| | | |
| | | var utils$6 = { |
| | | getLast: getLast$4, |
| | | getAncestorCount: getAncestorCount, |
| | | isNode: isNode, |
| | | isEmptyNode: isEmptyNode, |
| | | mapNode: mapNode, |
| | | defineShortcut: defineShortcut, |
| | | isNextLineEmpty: isNextLineEmpty$5, |
| | | isLastDescendantNode: isLastDescendantNode, |
| | | getBlockValueLineContents: getBlockValueLineContents, |
| | | getFlowScalarLineContents: getFlowScalarLineContents, |
| | | getLastDescendantNode: getLastDescendantNode$1, |
| | | hasPrettierIgnore: hasPrettierIgnore$5, |
| | | hasLeadingComments: hasLeadingComments, |
| | | hasMiddleComments: hasMiddleComments, |
| | | hasIndicatorComment: hasIndicatorComment, |
| | | hasTrailingComment: hasTrailingComment$2, |
| | | hasEndComments: hasEndComments |
| | | }; |
| | | |
| | | var insertPragma$9 = pragma$5.insertPragma, |
| | | isPragma$1 = pragma$5.isPragma; |
| | | var getAncestorCount$1 = utils$6.getAncestorCount, |
| | | getBlockValueLineContents$1 = utils$6.getBlockValueLineContents, |
| | | getFlowScalarLineContents$1 = utils$6.getFlowScalarLineContents, |
| | | getLast$5 = utils$6.getLast, |
| | | getLastDescendantNode$2 = utils$6.getLastDescendantNode, |
| | | hasLeadingComments$1 = utils$6.hasLeadingComments, |
| | | hasMiddleComments$1 = utils$6.hasMiddleComments, |
| | | hasIndicatorComment$1 = utils$6.hasIndicatorComment, |
| | | hasTrailingComment$3 = utils$6.hasTrailingComment, |
| | | hasEndComments$1 = utils$6.hasEndComments, |
| | | hasPrettierIgnore$6 = utils$6.hasPrettierIgnore, |
| | | isLastDescendantNode$1 = utils$6.isLastDescendantNode, |
| | | isNextLineEmpty$6 = utils$6.isNextLineEmpty, |
| | | isNode$1 = utils$6.isNode, |
| | | isEmptyNode$1 = utils$6.isEmptyNode, |
| | | defineShortcut$1 = utils$6.defineShortcut, |
| | | mapNode$1 = utils$6.mapNode; |
| | | var docBuilders$2 = doc.builders; |
| | | var conditionalGroup$2 = docBuilders$2.conditionalGroup, |
| | | breakParent$5 = docBuilders$2.breakParent, |
| | | concat$h = docBuilders$2.concat, |
| | | dedent$3 = docBuilders$2.dedent, |
| | | dedentToRoot$3 = docBuilders$2.dedentToRoot, |
| | | fill$6 = docBuilders$2.fill, |
| | | group$g = docBuilders$2.group, |
| | | hardline$d = docBuilders$2.hardline, |
| | | ifBreak$8 = docBuilders$2.ifBreak, |
| | | join$c = docBuilders$2.join, |
| | | line$9 = docBuilders$2.line, |
| | | lineSuffix$2 = docBuilders$2.lineSuffix, |
| | | literalline$7 = docBuilders$2.literalline, |
| | | markAsRoot$5 = docBuilders$2.markAsRoot, |
| | | softline$8 = docBuilders$2.softline; |
| | | var replaceEndOfLineWith$3 = util.replaceEndOfLineWith; |
| | | |
| | | function preprocess$3(ast) { |
| | | return mapNode$1(ast, defineShortcuts); |
| | | } |
| | | |
| | | function defineShortcuts(node) { |
| | | switch (node.type) { |
| | | case "document": |
| | | defineShortcut$1(node, "head", function () { |
| | | return node.children[0]; |
| | | }); |
| | | defineShortcut$1(node, "body", function () { |
| | | return node.children[1]; |
| | | }); |
| | | break; |
| | | |
| | | case "documentBody": |
| | | case "sequenceItem": |
| | | case "flowSequenceItem": |
| | | case "mappingKey": |
| | | case "mappingValue": |
| | | defineShortcut$1(node, "content", function () { |
| | | return node.children[0]; |
| | | }); |
| | | break; |
| | | |
| | | case "mappingItem": |
| | | case "flowMappingItem": |
| | | defineShortcut$1(node, "key", function () { |
| | | return node.children[0]; |
| | | }); |
| | | defineShortcut$1(node, "value", function () { |
| | | return node.children[1]; |
| | | }); |
| | | break; |
| | | } |
| | | |
| | | return node; |
| | | } |
| | | |
| | | function genericPrint$6(path, options, print) { |
| | | var node = path.getValue(); |
| | | var parentNode = path.getParentNode(); |
| | | var tag = !node.tag ? "" : path.call(print, "tag"); |
| | | var anchor = !node.anchor ? "" : path.call(print, "anchor"); |
| | | var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode$1(path) ? printNextEmptyLine(path, options.originalText) : ""; |
| | | return concat$h([node.type !== "mappingValue" && hasLeadingComments$1(node) ? concat$h([join$c(hardline$d, path.map(print, "leadingComments")), hardline$d]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments$1(node) ? hardline$d : " " : "", hasMiddleComments$1(node) ? concat$h([node.middleComments.length === 1 ? "" : hardline$d, join$c(hardline$d, path.map(print, "middleComments")), hardline$d]) : "", hasPrettierIgnore$6(path) ? concat$h(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$g(_print(node, parentNode, path, options, print)), hasTrailingComment$3(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$h([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode$1(node) ? "" : breakParent$5, path.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments$1(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$h([hardline$d, join$c(hardline$d, path.map(print, "endComments"))])) : ""]); |
| | | } |
| | | |
| | | function _print(node, parentNode, path, options, print) { |
| | | switch (node.type) { |
| | | case "root": |
| | | return concat$h([join$c(hardline$d, path.map(function (childPath, index) { |
| | | var document = node.children[index]; |
| | | var nextDocument = node.children[index + 1]; |
| | | return concat$h([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$h([hardline$d, "...", hasTrailingComment$3(document) ? concat$h([" ", path.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$3(nextDocument.head) ? "" : concat$h([hardline$d, "---"])]); |
| | | }, "children")), node.children.length === 0 || function (lastDescendantNode) { |
| | | return isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep"; |
| | | }(getLastDescendantNode$2(node)) ? "" : hardline$d]); |
| | | |
| | | case "document": |
| | | { |
| | | var nextDocument = parentNode.children[path.getName() + 1]; |
| | | return join$c(hardline$d, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$c(hardline$d, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$h(["---", hasTrailingComment$3(node.head) ? concat$h([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean)); |
| | | } |
| | | |
| | | case "documentHead": |
| | | return join$c(hardline$d, [].concat(path.map(print, "children"), path.map(print, "endComments"))); |
| | | |
| | | case "documentBody": |
| | | { |
| | | var children = join$c(hardline$d, path.map(print, "children")).parts; |
| | | var endComments = join$c(hardline$d, path.map(print, "endComments")).parts; |
| | | var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) { |
| | | return isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true) |
| | | "" : // an extra newline for better readability |
| | | concat$h([hardline$d, hardline$d]) : hardline$d; |
| | | }(getLastDescendantNode$2(node)); |
| | | return concat$h([].concat(children, separator, endComments)); |
| | | } |
| | | |
| | | case "directive": |
| | | return concat$h(["%", join$c(" ", [node.name].concat(node.parameters))]); |
| | | |
| | | case "comment": |
| | | return concat$h(["#", node.value]); |
| | | |
| | | case "alias": |
| | | return concat$h(["*", node.value]); |
| | | |
| | | case "tag": |
| | | return options.originalText.slice(node.position.start.offset, node.position.end.offset); |
| | | |
| | | case "anchor": |
| | | return concat$h(["&", node.value]); |
| | | |
| | | case "plain": |
| | | return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options); |
| | | |
| | | case "quoteDouble": |
| | | case "quoteSingle": |
| | | { |
| | | var singleQuote = "'"; |
| | | var doubleQuote = '"'; |
| | | var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1); |
| | | |
| | | if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) { |
| | | // only quoteDouble can use escape chars |
| | | // and quoteSingle do not need to escape backslashes |
| | | var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote; |
| | | return concat$h([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]); |
| | | } else if (raw.includes(doubleQuote)) { |
| | | return concat$h([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble |
| | | .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]); |
| | | } |
| | | |
| | | if (raw.includes(singleQuote)) { |
| | | return concat$h([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle |
| | | raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]); |
| | | } |
| | | |
| | | var quote = options.singleQuote ? singleQuote : doubleQuote; |
| | | return concat$h([quote, printFlowScalarContent(node.type, raw, options), quote]); |
| | | } |
| | | |
| | | case "blockFolded": |
| | | case "blockLiteral": |
| | | { |
| | | var parentIndent = getAncestorCount$1(path, function (ancestorNode) { |
| | | return isNode$1(ancestorNode, ["sequence", "mapping"]); |
| | | }); |
| | | var isLastDescendant = isLastDescendantNode$1(path); |
| | | return concat$h([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment$1(node) ? concat$h([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$3 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$h(getBlockValueLineContents$1(node, { |
| | | parentIndent: parentIndent, |
| | | isLastDescendant: isLastDescendant, |
| | | options: options |
| | | }).reduce(function (reduced, lineWords, index, lineContents) { |
| | | return reduced.concat(index === 0 ? hardline$d : "", fill$6(join$c(line$9, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$d : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$d) : dedentToRoot$3(literalline$7) : ""); |
| | | }, []))))]); |
| | | } |
| | | |
| | | case "sequence": |
| | | return join$c(hardline$d, path.map(print, "children")); |
| | | |
| | | case "sequenceItem": |
| | | return concat$h(["- ", align$3(2, !node.content ? "" : path.call(print, "content"))]); |
| | | |
| | | case "mappingKey": |
| | | return !node.content ? "" : path.call(print, "content"); |
| | | |
| | | case "mappingValue": |
| | | return !node.content ? "" : path.call(print, "content"); |
| | | |
| | | case "mapping": |
| | | return join$c(hardline$d, path.map(print, "children")); |
| | | |
| | | case "mappingItem": |
| | | case "flowMappingItem": |
| | | { |
| | | var isEmptyMappingKey = isEmptyNode$1(node.key); |
| | | var isEmptyMappingValue = isEmptyNode$1(node.value); |
| | | |
| | | if (isEmptyMappingKey && isEmptyMappingValue) { |
| | | return concat$h([": "]); |
| | | } |
| | | |
| | | var key = path.call(print, "key"); |
| | | var value = path.call(print, "value"); |
| | | |
| | | if (isEmptyMappingValue) { |
| | | return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$3(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$h([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$h(["? ", align$3(2, key)]); |
| | | } |
| | | |
| | | if (isEmptyMappingKey) { |
| | | return concat$h([": ", align$3(2, value)]); |
| | | } |
| | | |
| | | var groupId = Symbol("mappingKey"); |
| | | var forceExplicitKey = hasLeadingComments$1(node.value) || !isInlineNode$1(node.key.content); |
| | | return forceExplicitKey ? concat$h(["? ", align$3(2, key), hardline$d, join$c("", path.map(print, "value", "leadingComments").map(function (comment) { |
| | | return concat$h([comment, hardline$d]); |
| | | })), ": ", align$3(2, value)]) : // force singleline |
| | | isSingleLineNode(node.key.content) && !hasLeadingComments$1(node.key.content) && !hasMiddleComments$1(node.key.content) && !hasTrailingComment$3(node.key.content) && !hasEndComments$1(node.key) && !hasLeadingComments$1(node.value.content) && !hasMiddleComments$1(node.value.content) && !hasEndComments$1(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$h([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$h([group$g(concat$h([ifBreak$8("? "), group$g(align$3(2, key), { |
| | | id: groupId |
| | | })])), ifBreak$8(concat$h([hardline$d, ": ", align$3(2, value)]), indent(concat$h([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments$1(node.value.content) || hasEndComments$1(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$3(node.key.content) && isInlineNode$1(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$d : !node.value.content ? "" : line$9, value])), { |
| | | groupId: groupId |
| | | })])]); |
| | | } |
| | | |
| | | case "flowMapping": |
| | | case "flowSequence": |
| | | { |
| | | var openMarker = node.type === "flowMapping" ? "{" : "["; |
| | | var closeMarker = node.type === "flowMapping" ? "}" : "]"; |
| | | var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$9 : softline$8; |
| | | |
| | | var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) { |
| | | return lastItem.type === "flowMappingItem" && isEmptyNode$1(lastItem.key) && isEmptyNode$1(lastItem.value); |
| | | }(getLast$5(node.children)); |
| | | |
| | | return concat$h([openMarker, indent(concat$h([bracketSpacing, concat$h(path.map(function (childPath, index) { |
| | | return concat$h([print(childPath), index === node.children.length - 1 ? "" : concat$h([",", line$9, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]); |
| | | }, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]); |
| | | } |
| | | |
| | | case "flowSequenceItem": |
| | | return path.call(print, "content"); |
| | | // istanbul ignore next |
| | | |
| | | default: |
| | | throw new Error("Unexpected node type ".concat(node.type)); |
| | | } |
| | | |
| | | function indent(doc) { |
| | | return docBuilders$2.align(" ".repeat(options.tabWidth), doc); |
| | | } |
| | | } |
| | | |
| | | function align$3(n, doc) { |
| | | return typeof n === "number" && n > 0 ? docBuilders$2.align(" ".repeat(n), doc) : docBuilders$2.align(n, doc); |
| | | } |
| | | |
| | | function isInlineNode$1(node) { |
| | | if (!node) { |
| | | return true; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "plain": |
| | | case "quoteDouble": |
| | | case "quoteSingle": |
| | | case "alias": |
| | | case "flowMapping": |
| | | case "flowSequence": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function isSingleLineNode(node) { |
| | | if (!node) { |
| | | return true; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "plain": |
| | | case "quoteDouble": |
| | | case "quoteSingle": |
| | | return node.position.start.line === node.position.end.line; |
| | | |
| | | case "alias": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function shouldPrintDocumentBody(document) { |
| | | return document.body.children.length !== 0 || hasEndComments$1(document.body); |
| | | } |
| | | |
| | | function shouldPrintDocumentEndMarker(document, nextDocument) { |
| | | return ( |
| | | /** |
| | | *... # trailingComment |
| | | */ |
| | | hasTrailingComment$3(document) || nextDocument && ( |
| | | /** |
| | | * ... |
| | | * %DIRECTIVE |
| | | * --- |
| | | */ |
| | | nextDocument.head.children.length !== 0 || |
| | | /** |
| | | * ... |
| | | * # endComment |
| | | * --- |
| | | */ |
| | | hasEndComments$1(nextDocument.head)) |
| | | ); |
| | | } |
| | | |
| | | function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) { |
| | | if ( |
| | | /** |
| | | * --- |
| | | * preserve the first document head end marker |
| | | */ |
| | | root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) || |
| | | /** |
| | | * %DIRECTIVE |
| | | * --- |
| | | */ |
| | | document.head.children.length !== 0 || |
| | | /** |
| | | * # end comment |
| | | * --- |
| | | */ |
| | | hasEndComments$1(document.head) || |
| | | /** |
| | | * --- # trailing comment |
| | | */ |
| | | hasTrailingComment$3(document.head)) { |
| | | return "head"; |
| | | } |
| | | |
| | | if (shouldPrintDocumentEndMarker(document, nextDocument)) { |
| | | return false; |
| | | } |
| | | |
| | | return nextDocument ? "root" : false; |
| | | } |
| | | |
| | | function isAbsolutelyPrintedAsSingleLineNode(node, options) { |
| | | if (!node) { |
| | | return true; |
| | | } |
| | | |
| | | switch (node.type) { |
| | | case "plain": |
| | | case "quoteSingle": |
| | | case "quoteDouble": |
| | | break; |
| | | |
| | | case "alias": |
| | | return true; |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | |
| | | if (options.proseWrap === "preserve") { |
| | | return node.position.start.line === node.position.end.line; |
| | | } |
| | | |
| | | if ( // backslash-newline |
| | | /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) { |
| | | return false; |
| | | } |
| | | |
| | | switch (options.proseWrap) { |
| | | case "never": |
| | | return node.value.indexOf("\n") === -1; |
| | | |
| | | case "always": |
| | | return !/[\n ]/.test(node.value); |
| | | // istanbul ignore next |
| | | |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | function needsSpaceInFrontOfMappingValue(node) { |
| | | return node.key.content && node.key.content.type === "alias"; |
| | | } |
| | | |
| | | function printNextEmptyLine(path, originalText) { |
| | | var node = path.getValue(); |
| | | var root = path.stack[0]; |
| | | root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || []; |
| | | |
| | | if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) { |
| | | if (isNextLineEmpty$6(node, originalText)) { |
| | | root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true; |
| | | return softline$8; |
| | | } |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | function printFlowScalarContent(nodeType, content, options) { |
| | | var lineContents = getFlowScalarLineContents$1(nodeType, content, options); |
| | | return join$c(hardline$d, lineContents.map(function (lineContentWords) { |
| | | return fill$6(join$c(line$9, lineContentWords).parts); |
| | | })); |
| | | } |
| | | |
| | | function clean$7(node, newNode |
| | | /*, parent */ |
| | | ) { |
| | | if (isNode$1(newNode)) { |
| | | delete newNode.position; |
| | | |
| | | switch (newNode.type) { |
| | | case "comment": |
| | | // insert pragma |
| | | if (isPragma$1(newNode.value)) { |
| | | return null; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "quoteDouble": |
| | | case "quoteSingle": |
| | | newNode.type = "quote"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var printerYaml = { |
| | | preprocess: preprocess$3, |
| | | print: genericPrint$6, |
| | | massageAstNode: clean$7, |
| | | insertPragma: insertPragma$9 |
| | | }; |
| | | |
| | | var options$7 = { |
| | | bracketSpacing: commonOptions.bracketSpacing, |
| | | singleQuote: commonOptions.singleQuote, |
| | | proseWrap: commonOptions.proseWrap |
| | | }; |
| | | |
| | | var name$h = "YAML"; |
| | | var type$g = "data"; |
| | | var tmScope$g = "source.yaml"; |
| | | var aliases$6 = [ |
| | | "yml" |
| | | ]; |
| | | var extensions$g = [ |
| | | ".yml", |
| | | ".mir", |
| | | ".reek", |
| | | ".rviz", |
| | | ".sublime-syntax", |
| | | ".syntax", |
| | | ".yaml", |
| | | ".yaml-tmlanguage", |
| | | ".yml.mysql" |
| | | ]; |
| | | var filenames$4 = [ |
| | | ".clang-format", |
| | | ".clang-tidy", |
| | | ".gemrc", |
| | | "glide.lock" |
| | | ]; |
| | | var aceMode$g = "yaml"; |
| | | var codemirrorMode$c = "yaml"; |
| | | var codemirrorMimeType$c = "text/x-yaml"; |
| | | var languageId$g = 407; |
| | | var YAML = { |
| | | name: name$h, |
| | | type: type$g, |
| | | tmScope: tmScope$g, |
| | | aliases: aliases$6, |
| | | extensions: extensions$g, |
| | | filenames: filenames$4, |
| | | aceMode: aceMode$g, |
| | | codemirrorMode: codemirrorMode$c, |
| | | codemirrorMimeType: codemirrorMimeType$c, |
| | | languageId: languageId$g |
| | | }; |
| | | |
| | | var YAML$1 = /*#__PURE__*/Object.freeze({ |
| | | __proto__: null, |
| | | name: name$h, |
| | | type: type$g, |
| | | tmScope: tmScope$g, |
| | | aliases: aliases$6, |
| | | extensions: extensions$g, |
| | | filenames: filenames$4, |
| | | aceMode: aceMode$g, |
| | | codemirrorMode: codemirrorMode$c, |
| | | codemirrorMimeType: codemirrorMimeType$c, |
| | | languageId: languageId$g, |
| | | 'default': YAML |
| | | }); |
| | | |
| | | var require$$0$8 = getCjsExportFromNamespace(YAML$1); |
| | | |
| | | var languages$6 = [createLanguage(require$$0$8, function (data) { |
| | | return Object.assign(data, { |
| | | since: "1.14.0", |
| | | parsers: ["yaml"], |
| | | vscodeLanguageIds: ["yaml"] |
| | | }); |
| | | })]; |
| | | var languageYaml = { |
| | | languages: languages$6, |
| | | printers: { |
| | | yaml: printerYaml |
| | | }, |
| | | options: options$7 |
| | | }; |
| | | |
| | | var version$2 = require$$0.version; |
| | | var getSupportInfo$2 = support.getSupportInfo; |
| | | var internalPlugins = [languageCss, languageGraphql, languageHandlebars, languageHtml, languageJs, languageMarkdown, languageYaml]; |
| | | |
| | | var isArray$1 = Array.isArray || function (arr) { |
| | | return Object.prototype.toString.call(arr) === "[object Array]"; |
| | | }; // Luckily `opts` is always the 2nd argument |
| | | |
| | | |
| | | function withPlugins(fn) { |
| | | return function () { |
| | | var args = Array.from(arguments); |
| | | var plugins = args[1] && args[1].plugins || []; |
| | | |
| | | if (!isArray$1(plugins)) { |
| | | plugins = Object.values(plugins); |
| | | } |
| | | |
| | | args[1] = Object.assign({}, args[1], { |
| | | plugins: internalPlugins.concat(plugins) |
| | | }); |
| | | return fn.apply(null, args); |
| | | }; |
| | | } |
| | | |
| | | var formatWithCursor = withPlugins(core.formatWithCursor); |
| | | var standalone = { |
| | | formatWithCursor: formatWithCursor, |
| | | format: function format(text, opts) { |
| | | return formatWithCursor(text, opts).formatted; |
| | | }, |
| | | check: function check(text, opts) { |
| | | var formatted = formatWithCursor(text, opts).formatted; |
| | | return formatted === text; |
| | | }, |
| | | doc: doc, |
| | | getSupportInfo: withPlugins(getSupportInfo$2), |
| | | version: version$2, |
| | | util: utilShared, |
| | | __debug: { |
| | | parse: withPlugins(core.parse), |
| | | formatAST: withPlugins(core.formatAST), |
| | | formatDoc: withPlugins(core.formatDoc), |
| | | printToDoc: withPlugins(core.printToDoc), |
| | | printDocToString: withPlugins(core.printDocToString) |
| | | } |
| | | }; |
| | | |
| | | var standalone$1 = standalone; |
| | | |
| | | return standalone$1; |
| | | |
| | | }))); |
| | | `.concat(r)}n.exports={isPragma:t,hasPragma:s,insertPragma:i}}}),Qd=Z({"src/language-yaml/loc.js"(e,n){"use strict";ae();function t(i){return i.position.start.offset}function s(i){return i.position.end.offset}n.exports={locStart:t,locEnd:s}}}),Zd=Z({"src/language-yaml/embed.js"(e,n){"use strict";ae();function t(s,i,r,u){if(s.getValue().type==="root"&&u.filepath&&/(?:[/\\]|^)\.(?:prettier|stylelint)rc$/.test(u.filepath))return r(u.originalText,Object.assign(Object.assign({},u),{},{parser:"json"}))}n.exports=t}}),jt=Z({"src/language-yaml/utils.js"(e,n){"use strict";ae();var{getLast:t,isNonEmptyArray:s}=Ge();function i(E,D){let d=0,y=E.stack.length-1;for(let o=0;o<y;o++){let x=E.stack[o];r(x)&&D(x)&&d++}return d}function r(E,D){return E&&typeof E.type=="string"&&(!D||D.includes(E.type))}function u(E,D,d){return D("children"in E?Object.assign(Object.assign({},E),{},{children:E.children.map(y=>u(y,D,E))}):E,d)}function a(E,D,d){Object.defineProperty(E,D,{get:d,enumerable:!1})}function c(E,D){let d=0,y=D.length;for(let o=E.position.end.offset-1;o<y;o++){let x=D[o];if(x===` |
| | | `&&d++,d===1&&/\S/.test(x))return!1;if(d===2)return!0}return!1}function l(E){switch(E.getValue().type){case"tag":case"anchor":case"comment":return!1}let d=E.stack.length;for(let y=1;y<d;y++){let o=E.stack[y],x=E.stack[y-1];if(Array.isArray(x)&&typeof o=="number"&&o!==x.length-1)return!1}return!0}function C(E){return s(E.children)?C(t(E.children)):E}function m(E){return E.value.trim()==="prettier-ignore"}function g(E){let D=E.getValue();if(D.type==="documentBody"){let d=E.getParentNode();return b(d.head)&&m(t(d.head.endComments))}return h(D)&&m(t(D.leadingComments))}function p(E){return!s(E.children)&&!f(E)}function f(E){return h(E)||N(E)||T(E)||A(E)||b(E)}function h(E){return E&&s(E.leadingComments)}function N(E){return E&&s(E.middleComments)}function T(E){return E&&E.indicatorComment}function A(E){return E&&E.trailingComment}function b(E){return E&&s(E.endComments)}function v(E){let D=[],d;for(let y of E.split(/( +)/))y!==" "?d===" "?D.push(y):D.push((D.pop()||"")+y):d===void 0&&D.unshift(""),d=y;return d===" "&&D.push((D.pop()||"")+" "),D[0]===""&&(D.shift(),D.unshift(" "+(D.shift()||""))),D}function B(E,D,d){let y=D.split(` |
| | | `).map((o,x,F)=>x===0&&x===F.length-1?o:x!==0&&x!==F.length-1?o.trim():x===0?o.trimEnd():o.trimStart());return d.proseWrap==="preserve"?y.map(o=>o.length===0?[]:[o]):y.map(o=>o.length===0?[]:v(o)).reduce((o,x,F)=>F!==0&&y[F-1].length>0&&x.length>0&&!(E==="quoteDouble"&&t(t(o)).endsWith("\\"))?[...o.slice(0,-1),[...t(o),...x]]:[...o,x],[]).map(o=>d.proseWrap==="never"?[o.join(" ")]:o)}function w(E,D){let{parentIndent:d,isLastDescendant:y,options:o}=D,x=E.position.start.line===E.position.end.line?"":o.originalText.slice(E.position.start.offset,E.position.end.offset).match(/^[^\n]*\n(.*)$/s)[1],F;if(E.indent===null){let _=x.match(/^(?<leadingSpace> *)[^\n\r ]/m);F=_?_.groups.leadingSpace.length:Number.POSITIVE_INFINITY}else F=E.indent-1+d;let S=x.split(` |
| | | `).map(_=>_.slice(F));if(o.proseWrap==="preserve"||E.type==="blockLiteral")return k(S.map(_=>_.length===0?[]:[_]));return k(S.map(_=>_.length===0?[]:v(_)).reduce((_,O,R)=>R!==0&&S[R-1].length>0&&O.length>0&&!/^\s/.test(O[0])&&!/^\s|\s$/.test(t(_))?[..._.slice(0,-1),[...t(_),...O]]:[..._,O],[]).map(_=>_.reduce((O,R)=>O.length>0&&/\s$/.test(t(O))?[...O.slice(0,-1),t(O)+" "+R]:[...O,R],[])).map(_=>o.proseWrap==="never"?[_.join(" ")]:_));function k(_){if(E.chomping==="keep")return t(_).length===0?_.slice(0,-1):_;let O=0;for(let R=_.length-1;R>=0&&_[R].length===0;R--)O++;return O===0?_:O>=2&&!y?_.slice(0,-(O-1)):_.slice(0,-O)}}function I(E){if(!E)return!0;switch(E.type){case"plain":case"quoteDouble":case"quoteSingle":case"alias":case"flowMapping":case"flowSequence":return!0;default:return!1}}n.exports={getLast:t,getAncestorCount:i,isNode:r,isEmptyNode:p,isInlineNode:I,mapNode:u,defineShortcut:a,isNextLineEmpty:c,isLastDescendantNode:l,getBlockValueLineContents:w,getFlowScalarLineContents:B,getLastDescendantNode:C,hasPrettierIgnore:g,hasLeadingComments:h,hasMiddleComments:N,hasIndicatorComment:T,hasTrailingComment:A,hasEndComments:b}}}),eg=Z({"src/language-yaml/print-preprocess.js"(e,n){"use strict";ae();var{defineShortcut:t,mapNode:s}=jt();function i(u){return s(u,r)}function r(u){switch(u.type){case"document":t(u,"head",()=>u.children[0]),t(u,"body",()=>u.children[1]);break;case"documentBody":case"sequenceItem":case"flowSequenceItem":case"mappingKey":case"mappingValue":t(u,"content",()=>u.children[0]);break;case"mappingItem":case"flowMappingItem":t(u,"key",()=>u.children[0]),t(u,"value",()=>u.children[1]);break}return u}n.exports=i}}),kr=Z({"src/language-yaml/print/misc.js"(e,n){"use strict";ae();var{builders:{softline:t,align:s}}=Le(),{hasEndComments:i,isNextLineEmpty:r,isNode:u}=jt(),a=new WeakMap;function c(m,g){let p=m.getValue(),f=m.stack[0],h;return a.has(f)?h=a.get(f):(h=new Set,a.set(f,h)),!h.has(p.position.end.line)&&(h.add(p.position.end.line),r(p,g)&&!l(m.getParentNode()))?t:""}function l(m){return i(m)&&!u(m,["documentHead","documentBody","flowMapping","flowSequence"])}function C(m,g){return s(" ".repeat(m),g)}n.exports={alignWithSpaces:C,shouldPrintEndComments:l,printNextEmptyLine:c}}}),tg=Z({"src/language-yaml/print/flow-mapping-sequence.js"(e,n){"use strict";ae();var{builders:{ifBreak:t,line:s,softline:i,hardline:r,join:u}}=Le(),{isEmptyNode:a,getLast:c,hasEndComments:l}=jt(),{printNextEmptyLine:C,alignWithSpaces:m}=kr();function g(f,h,N){let T=f.getValue(),A=T.type==="flowMapping",b=A?"{":"[",v=A?"}":"]",B=i;A&&T.children.length>0&&N.bracketSpacing&&(B=s);let w=c(T.children),I=w&&w.type==="flowMappingItem"&&a(w.key)&&a(w.value);return[b,m(N.tabWidth,[B,p(f,h,N),N.trailingComma==="none"?"":t(","),l(T)?[r,u(r,f.map(h,"endComments"))]:""]),I?"":B,v]}function p(f,h,N){let T=f.getValue();return f.map((b,v)=>[h(),v===T.children.length-1?"":[",",s,T.children[v].position.start.line!==T.children[v+1].position.start.line?C(b,N.originalText):""]],"children")}n.exports={printFlowMapping:g,printFlowSequence:g}}}),rg=Z({"src/language-yaml/print/mapping-item.js"(e,n){"use strict";ae();var{builders:{conditionalGroup:t,group:s,hardline:i,ifBreak:r,join:u,line:a}}=Le(),{hasLeadingComments:c,hasMiddleComments:l,hasTrailingComment:C,hasEndComments:m,isNode:g,isEmptyNode:p,isInlineNode:f}=jt(),{alignWithSpaces:h}=kr();function N(v,B,w,I,E){let{key:D,value:d}=v,y=p(D),o=p(d);if(y&&o)return": ";let x=I("key"),F=A(v)?" ":"";if(o)return v.type==="flowMappingItem"&&B.type==="flowMapping"?x:v.type==="mappingItem"&&T(D.content,E)&&!C(D.content)&&(!B.tag||B.tag.value!=="tag:yaml.org,2002:set")?[x,F,":"]:["? ",h(2,x)];let S=I("value");if(y)return[": ",h(2,S)];if(c(d)||!f(D.content))return["? ",h(2,x),i,u("",w.map(I,"value","leadingComments").map(H=>[H,i])),": ",h(2,S)];if(b(D.content)&&!c(D.content)&&!l(D.content)&&!C(D.content)&&!m(D)&&!c(d.content)&&!l(d.content)&&!m(d)&&T(d.content,E))return[x,F,": ",S];let k=Symbol("mappingKey"),_=s([r("? "),s(h(2,x),{id:k})]),O=[i,": ",h(2,S)],R=[F,":"];c(d.content)||m(d)&&d.content&&!g(d.content,["mapping","sequence"])||B.type==="mapping"&&C(D.content)&&f(d.content)||g(d.content,["mapping","sequence"])&&d.content.tag===null&&d.content.anchor===null?R.push(i):d.content&&R.push(a),R.push(S);let M=h(E.tabWidth,R);return T(D.content,E)&&!c(D.content)&&!l(D.content)&&!m(D)?t([[x,M]]):t([[_,r(O,M,{groupId:k})]])}function T(v,B){if(!v)return!0;switch(v.type){case"plain":case"quoteSingle":case"quoteDouble":break;case"alias":return!0;default:return!1}if(B.proseWrap==="preserve")return v.position.start.line===v.position.end.line;if(/\\$/m.test(B.originalText.slice(v.position.start.offset,v.position.end.offset)))return!1;switch(B.proseWrap){case"never":return!v.value.includes(` |
| | | `);case"always":return!/[\n ]/.test(v.value);default:return!1}}function A(v){return v.key.content&&v.key.content.type==="alias"}function b(v){if(!v)return!0;switch(v.type){case"plain":case"quoteDouble":case"quoteSingle":return v.position.start.line===v.position.end.line;case"alias":return!0;default:return!1}}n.exports=N}}),ng=Z({"src/language-yaml/print/block.js"(e,n){"use strict";ae();var{builders:{dedent:t,dedentToRoot:s,fill:i,hardline:r,join:u,line:a,literalline:c,markAsRoot:l},utils:{getDocParts:C}}=Le(),{getAncestorCount:m,getBlockValueLineContents:g,hasIndicatorComment:p,isLastDescendantNode:f,isNode:h}=jt(),{alignWithSpaces:N}=kr();function T(A,b,v){let B=A.getValue(),w=m(A,y=>h(y,["sequence","mapping"])),I=f(A),E=[B.type==="blockFolded"?">":"|"];B.indent!==null&&E.push(B.indent.toString()),B.chomping!=="clip"&&E.push(B.chomping==="keep"?"+":"-"),p(B)&&E.push(" ",b("indicatorComment"));let D=g(B,{parentIndent:w,isLastDescendant:I,options:v}),d=[];for(let[y,o]of D.entries())y===0&&d.push(r),d.push(i(C(u(a,o)))),y!==D.length-1?d.push(o.length===0?r:l(c)):B.chomping==="keep"&&I&&d.push(s(o.length===0?r:c));return B.indent===null?E.push(t(N(v.tabWidth,d))):E.push(s(N(B.indent-1+w,d))),E}n.exports=T}}),ug=Z({"src/language-yaml/printer-yaml.js"(e,n){"use strict";ae();var{builders:{breakParent:t,fill:s,group:i,hardline:r,join:u,line:a,lineSuffix:c,literalline:l},utils:{getDocParts:C,replaceTextEndOfLine:m}}=Le(),{isPreviousLineEmpty:g}=Ge(),{insertPragma:p,isPragma:f}=Yd(),{locStart:h}=Qd(),N=Zd(),{getFlowScalarLineContents:T,getLastDescendantNode:A,hasLeadingComments:b,hasMiddleComments:v,hasTrailingComment:B,hasEndComments:w,hasPrettierIgnore:I,isLastDescendantNode:E,isNode:D,isInlineNode:d}=jt(),y=eg(),{alignWithSpaces:o,printNextEmptyLine:x,shouldPrintEndComments:F}=kr(),{printFlowMapping:S,printFlowSequence:k}=tg(),_=rg(),O=ng();function R(W,ee,U){let ne=W.getValue(),se=[];ne.type!=="mappingValue"&&b(ne)&&se.push([u(r,W.map(U,"leadingComments")),r]);let{tag:V,anchor:oe}=ne;V&&se.push(U("tag")),V&&oe&&se.push(" "),oe&&se.push(U("anchor"));let K="";D(ne,["mapping","sequence","comment","directive","mappingItem","sequenceItem"])&&!E(W)&&(K=x(W,ee.originalText)),(V||oe)&&(D(ne,["sequence","mapping"])&&!v(ne)?se.push(r):se.push(" ")),v(ne)&&se.push([ne.middleComments.length===1?"":r,u(r,W.map(U,"middleComments")),r]);let Ee=W.getParentNode();return I(W)?se.push(m(ee.originalText.slice(ne.position.start.offset,ne.position.end.offset).trimEnd(),l)):se.push(i(M(ne,Ee,W,ee,U))),B(ne)&&!D(ne,["document","documentHead"])&&se.push(c([ne.type==="mappingValue"&&!ne.content?"":" ",Ee.type==="mappingKey"&&W.getParentNode(2).type==="mapping"&&d(ne)?"":t,U("trailingComment")])),F(ne)&&se.push(o(ne.type==="sequenceItem"?2:0,[r,u(r,W.map(q=>[g(ee.originalText,q.getValue(),h)?r:"",U()],"endComments"))])),se.push(K),se}function M(W,ee,U,ne,se){switch(W.type){case"root":{let{children:V}=W,oe=[];U.each((Ee,q)=>{let le=V[q],ue=V[q+1];q!==0&&oe.push(r),oe.push(se()),P(le,ue)?(oe.push(r,"..."),B(le)&&oe.push(" ",se("trailingComment"))):ue&&!B(ue.head)&&oe.push(r,"---")},"children");let K=A(W);return(!D(K,["blockLiteral","blockFolded"])||K.chomping!=="keep")&&oe.push(r),oe}case"document":{let V=ee.children[U.getName()+1],oe=[];return G(W,V,ee,ne)==="head"&&((W.head.children.length>0||W.head.endComments.length>0)&&oe.push(se("head")),B(W.head)?oe.push(["---"," ",se(["head","trailingComment"])]):oe.push("---")),H(W)&&oe.push(se("body")),u(r,oe)}case"documentHead":return u(r,[...U.map(se,"children"),...U.map(se,"endComments")]);case"documentBody":{let{children:V,endComments:oe}=W,K="";if(V.length>0&&oe.length>0){let Ee=A(W);D(Ee,["blockFolded","blockLiteral"])?Ee.chomping!=="keep"&&(K=[r,r]):K=r}return[u(r,U.map(se,"children")),K,u(r,U.map(se,"endComments"))]}case"directive":return["%",u(" ",[W.name,...W.parameters])];case"comment":return["#",W.value];case"alias":return["*",W.value];case"tag":return ne.originalText.slice(W.position.start.offset,W.position.end.offset);case"anchor":return["&",W.value];case"plain":return re(W.type,ne.originalText.slice(W.position.start.offset,W.position.end.offset),ne);case"quoteDouble":case"quoteSingle":{let V="'",oe='"',K=ne.originalText.slice(W.position.start.offset+1,W.position.end.offset-1);if(W.type==="quoteSingle"&&K.includes("\\")||W.type==="quoteDouble"&&/\\[^"]/.test(K)){let q=W.type==="quoteDouble"?oe:V;return[q,re(W.type,K,ne),q]}if(K.includes(oe))return[V,re(W.type,W.type==="quoteDouble"?K.replace(/\\"/g,oe).replace(/'/g,V.repeat(2)):K,ne),V];if(K.includes(V))return[oe,re(W.type,W.type==="quoteSingle"?K.replace(/''/g,V):K,ne),oe];let Ee=ne.singleQuote?V:oe;return[Ee,re(W.type,K,ne),Ee]}case"blockFolded":case"blockLiteral":return O(U,se,ne);case"mapping":case"sequence":return u(r,U.map(se,"children"));case"sequenceItem":return["- ",o(2,W.content?se("content"):"")];case"mappingKey":case"mappingValue":return W.content?se("content"):"";case"mappingItem":case"flowMappingItem":return _(W,ee,U,se,ne);case"flowMapping":return S(U,se,ne);case"flowSequence":return k(U,se,ne);case"flowSequenceItem":return se("content");default:throw new Error("Unexpected node type ".concat(W.type))}}function H(W){return W.body.children.length>0||w(W.body)}function P(W,ee){return B(W)||ee&&(ee.head.children.length>0||w(ee.head))}function G(W,ee,U,ne){return U.children[0]===W&&/---(?:\s|$)/.test(ne.originalText.slice(h(W),h(W)+4))||W.head.children.length>0||w(W.head)||B(W.head)?"head":P(W,ee)?!1:ee?"root":!1}function re(W,ee,U){let ne=T(W,ee,U);return u(r,ne.map(se=>s(C(u(a,se)))))}function $(W,ee){if(D(ee))switch(delete ee.position,ee.type){case"comment":if(f(ee.value))return null;break;case"quoteDouble":case"quoteSingle":ee.type="quote";break}}n.exports={preprocess:y,embed:N,print:R,massageAstNode:$,insertPragma:p}}}),sg=Z({"src/language-yaml/options.js"(e,n){"use strict";ae();var t=Lt();n.exports={bracketSpacing:t.bracketSpacing,singleQuote:t.singleQuote,proseWrap:t.proseWrap}}}),ag=Z({"src/language-yaml/parsers.js"(){ae()}}),ig=Z({"node_modules/linguist-languages/data/YAML.json"(e,n){n.exports={name:"YAML",type:"data",color:"#cb171e",tmScope:"source.yaml",aliases:["yml"],extensions:[".yml",".mir",".reek",".rviz",".sublime-syntax",".syntax",".yaml",".yaml-tmlanguage",".yaml.sed",".yml.mysql"],filenames:[".clang-format",".clang-tidy",".gemrc","glide.lock","yarn.lock"],aceMode:"yaml",codemirrorMode:"yaml",codemirrorMimeType:"text/x-yaml",languageId:407}}}),og=Z({"src/language-yaml/index.js"(e,n){"use strict";ae();var t=bt(),s=ug(),i=sg(),r=ag(),u=[t(ig(),a=>({since:"1.14.0",parsers:["yaml"],vscodeLanguageIds:["yaml","ansible","home-assistant"],filenames:[...a.filenames.filter(c=>c!=="yarn.lock"),".prettierrc",".stylelintrc"]}))];n.exports={languages:u,printers:{yaml:s},options:i,parsers:r}}}),cg=Z({"src/languages.js"(e,n){"use strict";ae(),n.exports=[$m(),id(),dd(),Fd(),wd(),Kd(),og()]}});ae();var{version:lg}=gi(),_t=om(),{getSupportInfo:pg}=Mn(),fg=cm(),Dg=cg(),mg=Le();function St(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];let r=s[n]||{},u=r.plugins||[];return s[n]=Object.assign(Object.assign({},r),{},{plugins:[...Dg,...Array.isArray(u)?u:Object.values(u)]}),e(...s)}}var Sn=St(_t.formatWithCursor);yo.exports={formatWithCursor:Sn,format(e,n){return Sn(e,n).formatted},check(e,n){let{formatted:t}=Sn(e,n);return t===e},doc:mg,getSupportInfo:St(pg,0),version:lg,util:fg,__debug:{parse:St(_t.parse),formatAST:St(_t.formatAST),formatDoc:St(_t.formatDoc),printToDoc:St(_t.printToDoc),printDocToString:St(_t.printDocToString)}}});"use strict";return dg();}); |