browser.js 2.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. "use strict";
  3. exports.__esModule = true;
  4. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  5. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7. require("./plugins/flow");
  8. var _acornJsxInject = require("acorn-jsx/inject");
  9. var _acornJsxInject2 = _interopRequireDefault(_acornJsxInject);
  10. var _srcIndex = require("./src/index");
  11. var acorn = _interopRequireWildcard(_srcIndex);
  12. _defaults(exports, _interopRequireWildcard(_srcIndex));
  13. (0, _acornJsxInject2["default"])(acorn);
  14. },{"./plugins/flow":2,"./src/index":5,"acorn-jsx/inject":174}],2:[function(require,module,exports){
  15. "use strict";
  16. var acorn = require("../src/index");
  17. var pp = acorn.Parser.prototype;
  18. var tt = acorn.tokTypes;
  19. pp.isRelational = function (op) {
  20. return this.type === tt.relational && this.value === op;
  21. };
  22. pp.expectRelational = function (op) {
  23. if (this.isRelational(op)) {
  24. this.next();
  25. } else {
  26. this.unexpected();
  27. }
  28. };
  29. pp.flow_parseDeclareClass = function (node) {
  30. this.next();
  31. this.flow_parseInterfaceish(node, true);
  32. return this.finishNode(node, "DeclareClass");
  33. };
  34. pp.flow_parseDeclareFunction = function (node) {
  35. this.next();
  36. var id = node.id = this.parseIdent();
  37. var typeNode = this.startNode();
  38. var typeContainer = this.startNode();
  39. if (this.isRelational("<")) {
  40. typeNode.typeParameters = this.flow_parseTypeParameterDeclaration();
  41. } else {
  42. typeNode.typeParameters = null;
  43. }
  44. this.expect(tt.parenL);
  45. var tmp = this.flow_parseFunctionTypeParams();
  46. typeNode.params = tmp.params;
  47. typeNode.rest = tmp.rest;
  48. this.expect(tt.parenR);
  49. this.expect(tt.colon);
  50. typeNode.returnType = this.flow_parseType();
  51. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  52. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  53. this.finishNode(id, id.type);
  54. this.semicolon();
  55. return this.finishNode(node, "DeclareFunction");
  56. };
  57. pp.flow_parseDeclare = function (node) {
  58. if (this.type === tt._class) {
  59. return this.flow_parseDeclareClass(node);
  60. } else if (this.type === tt._function) {
  61. return this.flow_parseDeclareFunction(node);
  62. } else if (this.type === tt._var) {
  63. return this.flow_parseDeclareVariable(node);
  64. } else if (this.isContextual("module")) {
  65. return this.flow_parseDeclareModule(node);
  66. } else {
  67. this.unexpected();
  68. }
  69. };
  70. pp.flow_parseDeclareVariable = function (node) {
  71. this.next();
  72. node.id = this.flow_parseTypeAnnotatableIdentifier();
  73. this.semicolon();
  74. return this.finishNode(node, "DeclareVariable");
  75. };
  76. pp.flow_parseDeclareModule = function (node) {
  77. this.next();
  78. if (this.type === tt.string) {
  79. node.id = this.parseExprAtom();
  80. } else {
  81. node.id = this.parseIdent();
  82. }
  83. var bodyNode = node.body = this.startNode();
  84. var body = bodyNode.body = [];
  85. this.expect(tt.braceL);
  86. while (this.type !== tt.braceR) {
  87. var node2 = this.startNode();
  88. // todo: declare check
  89. this.next();
  90. body.push(this.flow_parseDeclare(node2));
  91. }
  92. this.expect(tt.braceR);
  93. this.finishNode(bodyNode, "BlockStatement");
  94. return this.finishNode(node, "DeclareModule");
  95. };
  96. // Interfaces
  97. pp.flow_parseInterfaceish = function (node, allowStatic) {
  98. node.id = this.parseIdent();
  99. if (this.isRelational("<")) {
  100. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  101. } else {
  102. node.typeParameters = null;
  103. }
  104. node["extends"] = [];
  105. if (this.eat(tt._extends)) {
  106. do {
  107. node["extends"].push(this.flow_parseInterfaceExtends());
  108. } while (this.eat(tt.comma));
  109. }
  110. node.body = this.flow_parseObjectType(allowStatic);
  111. };
  112. pp.flow_parseInterfaceExtends = function () {
  113. var node = this.startNode();
  114. node.id = this.parseIdent();
  115. if (this.isRelational("<")) {
  116. node.typeParameters = this.flow_parseTypeParameterInstantiation();
  117. } else {
  118. node.typeParameters = null;
  119. }
  120. return this.finishNode(node, "InterfaceExtends");
  121. };
  122. pp.flow_parseInterface = function (node) {
  123. this.flow_parseInterfaceish(node, false);
  124. return this.finishNode(node, "InterfaceDeclaration");
  125. };
  126. // Type aliases
  127. pp.flow_parseTypeAlias = function (node) {
  128. node.id = this.parseIdent();
  129. if (this.isRelational("<")) {
  130. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  131. } else {
  132. node.typeParameters = null;
  133. }
  134. var oldInType = this.inType;
  135. this.inType = true;
  136. this.expect(tt.eq);
  137. node.right = this.flow_parseType();
  138. this.inType = oldInType;
  139. this.semicolon();
  140. return this.finishNode(node, "TypeAlias");
  141. };
  142. // Type annotations
  143. pp.flow_parseTypeParameterDeclaration = function () {
  144. var node = this.startNode();
  145. node.params = [];
  146. this.expectRelational("<");
  147. while (!this.isRelational(">")) {
  148. node.params.push(this.flow_parseTypeAnnotatableIdentifier());
  149. if (!this.isRelational(">")) {
  150. this.expect(tt.comma);
  151. }
  152. }
  153. this.expectRelational(">");
  154. return this.finishNode(node, "TypeParameterDeclaration");
  155. };
  156. pp.flow_parseTypeParameterInstantiation = function () {
  157. var node = this.startNode(),
  158. oldInType = this.inType;
  159. node.params = [];
  160. this.inType = true;
  161. this.expectRelational("<");
  162. while (!this.isRelational(">")) {
  163. node.params.push(this.flow_parseType());
  164. if (!this.isRelational(">")) {
  165. this.expect(tt.comma);
  166. }
  167. }
  168. this.expectRelational(">");
  169. this.inType = oldInType;
  170. return this.finishNode(node, "TypeParameterInstantiation");
  171. };
  172. pp.flow_parseObjectPropertyKey = function () {
  173. return this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);
  174. };
  175. pp.flow_parseObjectTypeIndexer = function (node, isStatic) {
  176. node["static"] = isStatic;
  177. this.expect(tt.bracketL);
  178. node.id = this.flow_parseObjectPropertyKey();
  179. this.expect(tt.colon);
  180. node.key = this.flow_parseType();
  181. this.expect(tt.bracketR);
  182. this.expect(tt.colon);
  183. node.value = this.flow_parseType();
  184. this.flow_objectTypeSemicolon();
  185. return this.finishNode(node, "ObjectTypeIndexer");
  186. };
  187. pp.flow_parseObjectTypeMethodish = function (node) {
  188. node.params = [];
  189. node.rest = null;
  190. node.typeParameters = null;
  191. if (this.isRelational("<")) {
  192. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  193. }
  194. this.expect(tt.parenL);
  195. while (this.type === tt.name) {
  196. node.params.push(this.flow_parseFunctionTypeParam());
  197. if (this.type !== tt.parenR) {
  198. this.expect(tt.comma);
  199. }
  200. }
  201. if (this.eat(tt.ellipsis)) {
  202. node.rest = this.flow_parseFunctionTypeParam();
  203. }
  204. this.expect(tt.parenR);
  205. this.expect(tt.colon);
  206. node.returnType = this.flow_parseType();
  207. return this.finishNode(node, "FunctionTypeAnnotation");
  208. };
  209. pp.flow_parseObjectTypeMethod = function (start, isStatic, key) {
  210. var node = this.startNodeAt(start);
  211. node.value = this.flow_parseObjectTypeMethodish(this.startNodeAt(start));
  212. node["static"] = isStatic;
  213. node.key = key;
  214. node.optional = false;
  215. this.flow_objectTypeSemicolon();
  216. return this.finishNode(node, "ObjectTypeProperty");
  217. };
  218. pp.flow_parseObjectTypeCallProperty = function (node, isStatic) {
  219. var valueNode = this.startNode();
  220. node["static"] = isStatic;
  221. node.value = this.flow_parseObjectTypeMethodish(valueNode);
  222. this.flow_objectTypeSemicolon();
  223. return this.finishNode(node, "ObjectTypeCallProperty");
  224. };
  225. pp.flow_parseObjectType = function (allowStatic) {
  226. var nodeStart = this.startNode();
  227. var node;
  228. var optional = false;
  229. var property;
  230. var propertyKey;
  231. var propertyTypeAnnotation;
  232. var token;
  233. var isStatic;
  234. nodeStart.callProperties = [];
  235. nodeStart.properties = [];
  236. nodeStart.indexers = [];
  237. this.expect(tt.braceL);
  238. while (this.type !== tt.braceR) {
  239. var start = this.markPosition();
  240. node = this.startNode();
  241. if (allowStatic && this.isContextual("static")) {
  242. this.next();
  243. isStatic = true;
  244. }
  245. if (this.type === tt.bracketL) {
  246. nodeStart.indexers.push(this.flow_parseObjectTypeIndexer(node, isStatic));
  247. } else if (this.type === tt.parenL || this.isRelational("<")) {
  248. nodeStart.callProperties.push(this.flow_parseObjectTypeCallProperty(node, allowStatic));
  249. } else {
  250. if (isStatic && this.type === tt.colon) {
  251. propertyKey = this.parseIdent();
  252. } else {
  253. propertyKey = this.flow_parseObjectPropertyKey();
  254. }
  255. if (this.isRelational("<") || this.type === tt.parenL) {
  256. // This is a method property
  257. nodeStart.properties.push(this.flow_parseObjectTypeMethod(start, isStatic, propertyKey));
  258. } else {
  259. if (this.eat(tt.question)) {
  260. optional = true;
  261. }
  262. this.expect(tt.colon);
  263. node.key = propertyKey;
  264. node.value = this.flow_parseType();
  265. node.optional = optional;
  266. node["static"] = isStatic;
  267. this.flow_objectTypeSemicolon();
  268. nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty"));
  269. }
  270. }
  271. }
  272. this.expect(tt.braceR);
  273. return this.finishNode(nodeStart, "ObjectTypeAnnotation");
  274. };
  275. pp.flow_objectTypeSemicolon = function () {
  276. if (!this.eat(tt.semi) && !this.eat(tt.comma) && this.type !== tt.braceR) {
  277. this.unexpected();
  278. }
  279. };
  280. pp.flow_parseGenericType = function (start, id) {
  281. var node = this.startNodeAt(start);
  282. node.typeParameters = null;
  283. node.id = id;
  284. while (this.eat(tt.dot)) {
  285. var node2 = this.startNodeAt(start);
  286. node2.qualification = node.id;
  287. node2.id = this.parseIdent();
  288. node.id = this.finishNode(node2, "QualifiedTypeIdentifier");
  289. }
  290. if (this.isRelational("<")) {
  291. node.typeParameters = this.flow_parseTypeParameterInstantiation();
  292. }
  293. return this.finishNode(node, "GenericTypeAnnotation");
  294. };
  295. pp.flow_parseVoidType = function () {
  296. var node = this.startNode();
  297. this.expect(tt._void);
  298. return this.finishNode(node, "VoidTypeAnnotation");
  299. };
  300. pp.flow_parseTypeofType = function () {
  301. var node = this.startNode();
  302. this.expect(tt._typeof);
  303. node.argument = this.flow_parsePrimaryType();
  304. return this.finishNode(node, "TypeofTypeAnnotation");
  305. };
  306. pp.flow_parseTupleType = function () {
  307. var node = this.startNode();
  308. node.types = [];
  309. this.expect(tt.bracketL);
  310. // We allow trailing commas
  311. while (this.pos < this.input.length && this.type !== tt.bracketR) {
  312. node.types.push(this.flow_parseType());
  313. if (this.type === tt.bracketR) break;
  314. this.expect(tt.comma);
  315. }
  316. this.expect(tt.bracketR);
  317. return this.finishNode(node, "TupleTypeAnnotation");
  318. };
  319. pp.flow_parseFunctionTypeParam = function () {
  320. var optional = false;
  321. var node = this.startNode();
  322. node.name = this.parseIdent();
  323. if (this.eat(tt.question)) {
  324. optional = true;
  325. }
  326. this.expect(tt.colon);
  327. node.optional = optional;
  328. node.typeAnnotation = this.flow_parseType();
  329. return this.finishNode(node, "FunctionTypeParam");
  330. };
  331. pp.flow_parseFunctionTypeParams = function () {
  332. var ret = { params: [], rest: null };
  333. while (this.type === tt.name) {
  334. ret.params.push(this.flow_parseFunctionTypeParam());
  335. if (this.type !== tt.parenR) {
  336. this.expect(tt.comma);
  337. }
  338. }
  339. if (this.eat(tt.ellipsis)) {
  340. ret.rest = this.flow_parseFunctionTypeParam();
  341. }
  342. return ret;
  343. };
  344. pp.flow_identToTypeAnnotation = function (start, node, id) {
  345. switch (id.name) {
  346. case "any":
  347. return this.finishNode(node, "AnyTypeAnnotation");
  348. case "bool":
  349. case "boolean":
  350. return this.finishNode(node, "BooleanTypeAnnotation");
  351. case "number":
  352. return this.finishNode(node, "NumberTypeAnnotation");
  353. case "string":
  354. return this.finishNode(node, "StringTypeAnnotation");
  355. default:
  356. return this.flow_parseGenericType(start, id);
  357. }
  358. };
  359. // The parsing of types roughly parallels the parsing of expressions, and
  360. // primary types are kind of like primary expressions...they're the
  361. // primitives with which other types are constructed.
  362. pp.flow_parsePrimaryType = function () {
  363. var typeIdentifier = null;
  364. var params = null;
  365. var returnType = null;
  366. var start = this.markPosition();
  367. var node = this.startNode();
  368. var rest = null;
  369. var tmp;
  370. var typeParameters;
  371. var token;
  372. var type;
  373. var isGroupedType = false;
  374. switch (this.type) {
  375. case tt.name:
  376. return this.flow_identToTypeAnnotation(start, node, this.parseIdent());
  377. case tt.braceL:
  378. return this.flow_parseObjectType();
  379. case tt.bracketL:
  380. return this.flow_parseTupleType();
  381. case tt.relational:
  382. if (this.value === "<") {
  383. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  384. this.expect(tt.parenL);
  385. tmp = this.flow_parseFunctionTypeParams();
  386. node.params = tmp.params;
  387. node.rest = tmp.rest;
  388. this.expect(tt.parenR);
  389. this.expect(tt.arrow);
  390. node.returnType = this.flow_parseType();
  391. return this.finishNode(node, "FunctionTypeAnnotation");
  392. }
  393. case tt.parenL:
  394. this.next();
  395. // Check to see if this is actually a grouped type
  396. if (this.type !== tt.parenR && this.type !== tt.ellipsis) {
  397. if (this.type === tt.name) {
  398. var token = this.lookahead().type;
  399. isGroupedType = token !== tt.question && token !== tt.colon;
  400. } else {
  401. isGroupedType = true;
  402. }
  403. }
  404. if (isGroupedType) {
  405. type = this.flow_parseType();
  406. this.expect(tt.parenR);
  407. // If we see a => next then someone was probably confused about
  408. // function types, so we can provide a better error message
  409. if (this.eat(tt.arrow)) {
  410. this.raise(node, "Unexpected token =>. It looks like " + "you are trying to write a function type, but you ended up " + "writing a grouped type followed by an =>, which is a syntax " + "error. Remember, function type parameters are named so function " + "types look like (name1: type1, name2: type2) => returnType. You " + "probably wrote (type1) => returnType");
  411. }
  412. return type;
  413. }
  414. tmp = this.flow_parseFunctionTypeParams();
  415. node.params = tmp.params;
  416. node.rest = tmp.rest;
  417. this.expect(tt.parenR);
  418. this.expect(tt.arrow);
  419. node.returnType = this.flow_parseType();
  420. node.typeParameters = null;
  421. return this.finishNode(node, "FunctionTypeAnnotation");
  422. case tt.string:
  423. node.value = this.value;
  424. node.raw = this.input.slice(this.start, this.end);
  425. this.next();
  426. return this.finishNode(node, "StringLiteralTypeAnnotation");
  427. default:
  428. if (this.type.keyword) {
  429. switch (this.type.keyword) {
  430. case "void":
  431. return this.flow_parseVoidType();
  432. case "typeof":
  433. return this.flow_parseTypeofType();
  434. }
  435. }
  436. }
  437. this.unexpected();
  438. };
  439. pp.flow_parsePostfixType = function () {
  440. var node = this.startNode();
  441. var type = node.elementType = this.flow_parsePrimaryType();
  442. if (this.type === tt.bracketL) {
  443. this.expect(tt.bracketL);
  444. this.expect(tt.bracketR);
  445. return this.finishNode(node, "ArrayTypeAnnotation");
  446. }
  447. return type;
  448. };
  449. pp.flow_parsePrefixType = function () {
  450. var node = this.startNode();
  451. if (this.eat(tt.question)) {
  452. node.typeAnnotation = this.flow_parsePrefixType();
  453. return this.finishNode(node, "NullableTypeAnnotation");
  454. }
  455. return this.flow_parsePostfixType();
  456. };
  457. pp.flow_parseIntersectionType = function () {
  458. var node = this.startNode();
  459. var type = this.flow_parsePrefixType();
  460. node.types = [type];
  461. while (this.eat(tt.bitwiseAND)) {
  462. node.types.push(this.flow_parsePrefixType());
  463. }
  464. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  465. };
  466. pp.flow_parseUnionType = function () {
  467. var node = this.startNode();
  468. var type = this.flow_parseIntersectionType();
  469. node.types = [type];
  470. while (this.eat(tt.bitwiseOR)) {
  471. node.types.push(this.flow_parseIntersectionType());
  472. }
  473. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  474. };
  475. pp.flow_parseType = function () {
  476. var oldInType = this.inType;
  477. this.inType = true;
  478. var type = this.flow_parseUnionType();
  479. this.inType = oldInType;
  480. return type;
  481. };
  482. pp.flow_parseTypeAnnotation = function () {
  483. var node = this.startNode();
  484. var oldInType = this.inType;
  485. this.inType = true;
  486. this.expect(tt.colon);
  487. node.typeAnnotation = this.flow_parseType();
  488. this.inType = oldInType;
  489. return this.finishNode(node, "TypeAnnotation");
  490. };
  491. pp.flow_parseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) {
  492. var node = this.startNode();
  493. var ident = this.parseIdent();
  494. var isOptionalParam = false;
  495. if (canBeOptionalParam && this.eat(tt.question)) {
  496. this.expect(tt.question);
  497. isOptionalParam = true;
  498. }
  499. if (requireTypeAnnotation || this.type === tt.colon) {
  500. ident.typeAnnotation = this.flow_parseTypeAnnotation();
  501. this.finishNode(ident, ident.type);
  502. }
  503. if (isOptionalParam) {
  504. ident.optional = true;
  505. this.finishNode(ident, ident.type);
  506. }
  507. return ident;
  508. };
  509. acorn.plugins.flow = function (instance) {
  510. // function name(): string {}
  511. instance.extend("parseFunctionBody", function (inner) {
  512. return function (node, allowExpression) {
  513. if (this.type === tt.colon) {
  514. node.returnType = this.flow_parseTypeAnnotation();
  515. }
  516. return inner.call(this, node, allowExpression);
  517. };
  518. });
  519. instance.extend("parseStatement", function (inner) {
  520. return function (declaration, topLevel) {
  521. // strict mode handling of `interface` since it's a reserved word
  522. if (this.strict && this.type === tt.name && this.value === "interface") {
  523. var node = this.startNode();
  524. this.next();
  525. return this.flow_parseInterface(node);
  526. } else {
  527. return inner.call(this, declaration, topLevel);
  528. }
  529. };
  530. });
  531. instance.extend("parseExpressionStatement", function (inner) {
  532. return function (node, expr) {
  533. if (expr.type === "Identifier") {
  534. if (expr.name === "declare") {
  535. if (this.type === tt._class || this.type === tt.name || this.type === tt._function || this.type === tt._var) {
  536. return this.flow_parseDeclare(node);
  537. }
  538. } else if (this.type === tt.name) {
  539. if (expr.name === "interface") {
  540. return this.flow_parseInterface(node);
  541. } else if (expr.name === "type") {
  542. return this.flow_parseTypeAlias(node);
  543. }
  544. }
  545. }
  546. return inner.call(this, node, expr);
  547. };
  548. });
  549. instance.extend("shouldParseExportDeclaration", function (inner) {
  550. return function () {
  551. return this.isContextual("type") || inner.call(this);
  552. };
  553. });
  554. instance.extend("parseParenItem", function (inner) {
  555. return function (node, start) {
  556. if (this.type === tt.colon) {
  557. var typeCastNode = this.startNodeAt(start);
  558. typeCastNode.expression = node;
  559. typeCastNode.typeAnnotation = this.flow_parseTypeAnnotation();
  560. return this.finishNode(typeCastNode, "TypeCastExpression");
  561. } else {
  562. return node;
  563. }
  564. };
  565. });
  566. instance.extend("parseClassId", function (inner) {
  567. return function (node, isStatement) {
  568. inner.call(this, node, isStatement);
  569. if (this.isRelational("<")) {
  570. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  571. }
  572. };
  573. });
  574. instance.extend("readToken", function (inner) {
  575. return function (code) {
  576. if (this.inType && (code === 62 || code === 60)) {
  577. return this.finishOp(tt.relational, 1);
  578. } else {
  579. return inner.call(this, code);
  580. }
  581. };
  582. });
  583. instance.extend("jsx_readToken", function (inner) {
  584. return function () {
  585. if (!this.inType) return inner.call(this);
  586. };
  587. });
  588. instance.extend("parseParenArrowList", function (inner) {
  589. return function (start, exprList, isAsync) {
  590. for (var i = 0; i < exprList.length; i++) {
  591. var listItem = exprList[i];
  592. if (listItem.type === "TypeCastExpression") {
  593. var expr = listItem.expression;
  594. expr.typeAnnotation = listItem.typeAnnotation;
  595. exprList[i] = expr;
  596. }
  597. }
  598. return inner.call(this, start, exprList, isAsync);
  599. };
  600. });
  601. instance.extend("parseClassProperty", function (inner) {
  602. return function (node) {
  603. if (this.type === tt.colon) {
  604. node.typeAnnotation = this.flow_parseTypeAnnotation();
  605. }
  606. return inner.call(this, node);
  607. };
  608. });
  609. instance.extend("isClassProperty", function (inner) {
  610. return function () {
  611. return this.type === tt.colon || inner.call(this);
  612. };
  613. });
  614. instance.extend("parseClassMethod", function (inner) {
  615. return function (classBody, method, isGenerator, isAsync) {
  616. var typeParameters;
  617. if (this.isRelational("<")) {
  618. typeParameters = this.flow_parseTypeParameterDeclaration();
  619. }
  620. method.value = this.parseMethod(isGenerator, isAsync);
  621. method.value.typeParameters = typeParameters;
  622. classBody.body.push(this.finishNode(method, "MethodDefinition"));
  623. };
  624. });
  625. instance.extend("parseClassSuper", function (inner) {
  626. return function (node, isStatement) {
  627. inner.call(this, node, isStatement);
  628. if (node.superClass && this.isRelational("<")) {
  629. node.superTypeParameters = this.flow_parseTypeParameterInstantiation();
  630. }
  631. if (this.isContextual("implements")) {
  632. this.next();
  633. var implemented = node["implements"] = [];
  634. do {
  635. var node = this.startNode();
  636. node.id = this.parseIdent();
  637. if (this.isRelational("<")) {
  638. node.typeParameters = this.flow_parseTypeParameterInstantiation();
  639. } else {
  640. node.typeParameters = null;
  641. }
  642. implemented.push(this.finishNode(node, "ClassImplements"));
  643. } while (this.eat(tt.comma));
  644. }
  645. };
  646. });
  647. instance.extend("parseObjPropValue", function (inner) {
  648. return function (prop) {
  649. var typeParameters;
  650. if (this.isRelational("<")) {
  651. typeParameters = this.flow_parseTypeParameterDeclaration();
  652. if (this.type !== tt.parenL) this.unexpected();
  653. }
  654. inner.apply(this, arguments);
  655. prop.value.typeParameters = typeParameters;
  656. };
  657. });
  658. instance.extend("parseAssignableListItemTypes", function (inner) {
  659. return function (param) {
  660. if (this.eat(tt.question)) {
  661. param.optional = true;
  662. }
  663. if (this.type === tt.colon) {
  664. param.typeAnnotation = this.flow_parseTypeAnnotation();
  665. }
  666. this.finishNode(param, param.type);
  667. return param;
  668. };
  669. });
  670. instance.extend("parseImportSpecifiers", function (inner) {
  671. return function (node) {
  672. node.isType = false;
  673. if (this.isContextual("type")) {
  674. var start = this.markPosition();
  675. var typeId = this.parseIdent();
  676. if (this.type === tt.name && this.value !== "from" || this.type === tt.braceL || this.type === tt.star) {
  677. node.isType = true;
  678. } else {
  679. node.specifiers.push(this.parseImportSpecifierDefault(typeId, start));
  680. if (this.isContextual("from")) return;
  681. this.eat(tt.comma);
  682. }
  683. }
  684. inner.call(this, node);
  685. };
  686. });
  687. // function foo<T>() {}
  688. instance.extend("parseFunctionParams", function (inner) {
  689. return function (node) {
  690. if (this.isRelational("<")) {
  691. node.typeParameters = this.flow_parseTypeParameterDeclaration();
  692. }
  693. inner.call(this, node);
  694. };
  695. });
  696. // var foo: string = bar
  697. instance.extend("parseVarHead", function (inner) {
  698. return function (decl) {
  699. inner.call(this, decl);
  700. if (this.type === tt.colon) {
  701. decl.id.typeAnnotation = this.flow_parseTypeAnnotation();
  702. this.finishNode(decl.id, decl.id.type);
  703. }
  704. };
  705. });
  706. };
  707. },{"../src/index":5}],3:[function(require,module,exports){
  708. // A recursive descent parser operates by defining functions for all
  709. // syntactic elements, and recursively calling those, each function
  710. // advancing the input stream and returning an AST node. Precedence
  711. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  712. // instead of `(!x)[1]` is handled by the fact that the parser
  713. // function that parses unary prefix operators is called first, and
  714. // in turn calls the function that parses `[]` subscripts — that
  715. // way, it'll receive the node for `x[1]` already parsed, and wraps
  716. // *that* in the unary operator node.
  717. //
  718. // Acorn uses an [operator precedence parser][opp] to handle binary
  719. // operator precedence, because it is much more compact than using
  720. // the technique outlined above, which uses different, nesting
  721. // functions to specify precedence, for all of the ten binary
  722. // precedence levels that JavaScript defines.
  723. //
  724. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  725. "use strict";
  726. var _tokentype = require("./tokentype");
  727. var _state = require("./state");
  728. var _identifier = require("./identifier");
  729. var _util = require("./util");
  730. var pp = _state.Parser.prototype;
  731. // Check if property name clashes with already added.
  732. // Object/class getters and setters are not allowed to clash —
  733. // either with each other or with an init property — and in
  734. // strict mode, init properties are also not allowed to be repeated.
  735. pp.checkPropClash = function (prop, propHash) {
  736. if (this.options.ecmaVersion >= 6) return;
  737. var key = prop.key,
  738. name = undefined;
  739. switch (key.type) {
  740. case "Identifier":
  741. name = key.name;break;
  742. case "Literal":
  743. name = String(key.value);break;
  744. default:
  745. return;
  746. }
  747. var kind = prop.kind || "init",
  748. other = undefined;
  749. if ((0, _util.has)(propHash, name)) {
  750. other = propHash[name];
  751. var isGetSet = kind !== "init";
  752. if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");
  753. } else {
  754. other = propHash[name] = {
  755. init: false,
  756. get: false,
  757. set: false
  758. };
  759. }
  760. other[kind] = true;
  761. };
  762. // ### Expression parsing
  763. // These nest, from the most general expression type at the top to
  764. // 'atomic', nondivisible expression types at the bottom. Most of
  765. // the functions will simply let the function(s) below them parse,
  766. // and, *if* the syntactic construct they handle is present, wrap
  767. // the AST node that the inner parser gave them in another node.
  768. // Parse a full expression. The optional arguments are used to
  769. // forbid the `in` operator (in for loops initalization expressions)
  770. // and provide reference for storing '=' operator inside shorthand
  771. // property assignment in contexts where both object expression
  772. // and object pattern might appear (so it's possible to raise
  773. // delayed syntax error at correct position).
  774. pp.parseExpression = function (noIn, refShorthandDefaultPos) {
  775. var start = this.markPosition();
  776. var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);
  777. if (this.type === _tokentype.types.comma) {
  778. var node = this.startNodeAt(start);
  779. node.expressions = [expr];
  780. while (this.eat(_tokentype.types.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));
  781. return this.finishNode(node, "SequenceExpression");
  782. }
  783. return expr;
  784. };
  785. // Parse an assignment expression. This includes applications of
  786. // operators like `+=`.
  787. pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {
  788. if (this.type == _tokentype.types._yield && this.inGenerator) return this.parseYield();
  789. var failOnShorthandAssign = undefined;
  790. if (!refShorthandDefaultPos) {
  791. refShorthandDefaultPos = { start: 0 };
  792. failOnShorthandAssign = true;
  793. } else {
  794. failOnShorthandAssign = false;
  795. }
  796. var start = this.markPosition();
  797. if (this.type == _tokentype.types.parenL || this.type == _tokentype.types.name) this.potentialArrowAt = this.start;
  798. var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);
  799. if (afterLeftParse) left = afterLeftParse.call(this, left, start);
  800. if (this.type.isAssign) {
  801. var node = this.startNodeAt(start);
  802. node.operator = this.value;
  803. node.left = this.type === _tokentype.types.eq ? this.toAssignable(left) : left;
  804. refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly
  805. this.checkLVal(left);
  806. if (left.parenthesizedExpression) {
  807. var errorMsg = undefined;
  808. if (left.type === "ObjectPattern") {
  809. errorMsg = "`({a}) = 0` use `({a} = 0)`";
  810. } else if (left.type === "ArrayPattern") {
  811. errorMsg = "`([a]) = 0` use `([a] = 0)`";
  812. }
  813. if (errorMsg) {
  814. this.raise(left.start, "You're trying to assign to a parenthesized expression, eg. instead of " + errorMsg);
  815. }
  816. }
  817. this.next();
  818. node.right = this.parseMaybeAssign(noIn);
  819. return this.finishNode(node, "AssignmentExpression");
  820. } else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
  821. this.unexpected(refShorthandDefaultPos.start);
  822. }
  823. return left;
  824. };
  825. // Parse a ternary conditional (`?:`) operator.
  826. pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {
  827. var start = this.markPosition();
  828. var expr = this.parseExprOps(noIn, refShorthandDefaultPos);
  829. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  830. if (this.eat(_tokentype.types.question)) {
  831. var node = this.startNodeAt(start);
  832. node.test = expr;
  833. node.consequent = this.parseMaybeAssign();
  834. this.expect(_tokentype.types.colon);
  835. node.alternate = this.parseMaybeAssign(noIn);
  836. return this.finishNode(node, "ConditionalExpression");
  837. }
  838. return expr;
  839. };
  840. // Start the precedence parser.
  841. pp.parseExprOps = function (noIn, refShorthandDefaultPos) {
  842. var start = this.markPosition();
  843. var expr = this.parseMaybeUnary(refShorthandDefaultPos);
  844. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  845. return this.parseExprOp(expr, start, -1, noIn);
  846. };
  847. // Parse binary operators with the operator precedence parsing
  848. // algorithm. `left` is the left-hand side of the operator.
  849. // `minPrec` provides context that allows the function to stop and
  850. // defer further parser to one of its callers when it encounters an
  851. // operator that has a lower precedence than the set it is parsing.
  852. pp.parseExprOp = function (left, leftStart, minPrec, noIn) {
  853. var prec = this.type.binop;
  854. if (prec != null && (!noIn || this.type !== _tokentype.types._in)) {
  855. if (prec > minPrec) {
  856. var node = this.startNodeAt(leftStart);
  857. node.left = left;
  858. node.operator = this.value;
  859. var op = this.type;
  860. this.next();
  861. var _start = this.markPosition();
  862. node.right = this.parseExprOp(this.parseMaybeUnary(), _start, op.rightAssociative ? prec - 1 : prec, noIn);
  863. this.finishNode(node, op === _tokentype.types.logicalOR || op === _tokentype.types.logicalAND ? "LogicalExpression" : "BinaryExpression");
  864. return this.parseExprOp(node, leftStart, minPrec, noIn);
  865. }
  866. }
  867. return left;
  868. };
  869. // Parse unary operators, both prefix and postfix.
  870. pp.parseMaybeUnary = function (refShorthandDefaultPos) {
  871. if (this.type.prefix) {
  872. var node = this.startNode(),
  873. update = this.type === _tokentype.types.incDec;
  874. node.operator = this.value;
  875. node.prefix = true;
  876. this.next();
  877. node.argument = this.parseMaybeUnary();
  878. if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
  879. if (update) this.checkLVal(node.argument);else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") this.raise(node.start, "Deleting local variable in strict mode");
  880. return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  881. }
  882. var start = this.markPosition();
  883. var expr = this.parseExprSubscripts(refShorthandDefaultPos);
  884. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  885. while (this.type.postfix && !this.canInsertSemicolon()) {
  886. var node = this.startNodeAt(start);
  887. node.operator = this.value;
  888. node.prefix = false;
  889. node.argument = expr;
  890. this.checkLVal(expr);
  891. this.next();
  892. expr = this.finishNode(node, "UpdateExpression");
  893. }
  894. return expr;
  895. };
  896. // Parse call, dot, and `[]`-subscript expressions.
  897. pp.parseExprSubscripts = function (refShorthandDefaultPos) {
  898. var start = this.markPosition();
  899. var expr = this.parseExprAtom(refShorthandDefaultPos);
  900. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  901. return this.parseSubscripts(expr, start);
  902. };
  903. pp.parseSubscripts = function (base, start, noCalls) {
  904. if (!noCalls && this.eat(_tokentype.types.doubleColon)) {
  905. var node = this.startNodeAt(start);
  906. node.object = base;
  907. node.callee = this.parseNoCallExpr();
  908. return this.parseSubscripts(this.finishNode(node, "BindExpression"), start, noCalls);
  909. } else if (this.eat(_tokentype.types.dot)) {
  910. var node = this.startNodeAt(start);
  911. node.object = base;
  912. node.property = this.parseIdent(true);
  913. node.computed = false;
  914. return this.parseSubscripts(this.finishNode(node, "MemberExpression"), start, noCalls);
  915. } else if (this.eat(_tokentype.types.bracketL)) {
  916. var node = this.startNodeAt(start);
  917. node.object = base;
  918. node.property = this.parseExpression();
  919. node.computed = true;
  920. this.expect(_tokentype.types.bracketR);
  921. return this.parseSubscripts(this.finishNode(node, "MemberExpression"), start, noCalls);
  922. } else if (!noCalls && this.eat(_tokentype.types.parenL)) {
  923. var node = this.startNodeAt(start);
  924. node.callee = base;
  925. node.arguments = this.parseExprList(_tokentype.types.parenR, this.options.features["es7.trailingFunctionCommas"]);
  926. return this.parseSubscripts(this.finishNode(node, "CallExpression"), start, noCalls);
  927. } else if (this.type === _tokentype.types.backQuote) {
  928. var node = this.startNodeAt(start);
  929. node.tag = base;
  930. node.quasi = this.parseTemplate();
  931. return this.parseSubscripts(this.finishNode(node, "TaggedTemplateExpression"), start, noCalls);
  932. }return base;
  933. };
  934. // Parse a no-call expression (like argument of `new` or `::` operators).
  935. pp.parseNoCallExpr = function () {
  936. var start = this.markPosition();
  937. return this.parseSubscripts(this.parseExprAtom(), start, true);
  938. };
  939. // Parse an atomic expression — either a single token that is an
  940. // expression, an expression started by a keyword like `function` or
  941. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  942. // or `{}`.
  943. pp.parseExprAtom = function (refShorthandDefaultPos) {
  944. var node = undefined,
  945. canBeArrow = this.potentialArrowAt == this.start;
  946. switch (this.type) {
  947. case _tokentype.types._this:
  948. case _tokentype.types._super:
  949. var type = this.type === _tokentype.types._this ? "ThisExpression" : "Super";
  950. node = this.startNode();
  951. this.next();
  952. return this.finishNode(node, type);
  953. case _tokentype.types._yield:
  954. if (this.inGenerator) this.unexpected();
  955. case _tokentype.types._do:
  956. if (this.options.features["es7.doExpressions"]) {
  957. var _node = this.startNode();
  958. this.next();
  959. _node.body = this.parseBlock();
  960. return this.finishNode(_node, "DoExpression");
  961. }
  962. case _tokentype.types.name:
  963. var start = this.markPosition();
  964. node = this.startNode();
  965. var id = this.parseIdent(this.type !== _tokentype.types.name);
  966. //
  967. if (this.options.features["es7.asyncFunctions"]) {
  968. // async functions!
  969. if (id.name === "async") {
  970. // arrow functions
  971. if (this.type === _tokentype.types.parenL) {
  972. var expr = this.parseParenAndDistinguishExpression(start, true, true);
  973. if (expr && expr.type === "ArrowFunctionExpression") {
  974. return expr;
  975. } else {
  976. node.callee = id;
  977. if (!expr) {
  978. node.arguments = [];
  979. } else if (expr.type === "SequenceExpression") {
  980. node.arguments = expr.expressions;
  981. } else {
  982. node.arguments = [expr];
  983. }
  984. return this.parseSubscripts(this.finishNode(node, "CallExpression"), start);
  985. }
  986. } else if (this.type === _tokentype.types.name) {
  987. id = this.parseIdent();
  988. this.expect(_tokentype.types.arrow);
  989. return this.parseArrowExpression(node, [id], true);
  990. }
  991. // normal functions
  992. if (this.type === _tokentype.types._function && !this.canInsertSemicolon()) {
  993. this.next();
  994. return this.parseFunction(node, false, false, true);
  995. }
  996. } else if (id.name === "await") {
  997. if (this.inAsync) return this.parseAwait(node);
  998. }
  999. }
  1000. //
  1001. if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) return this.parseArrowExpression(this.startNodeAt(start), [id]);
  1002. return id;
  1003. case _tokentype.types.regexp:
  1004. var value = this.value;
  1005. node = this.parseLiteral(value.value);
  1006. node.regex = { pattern: value.pattern, flags: value.flags };
  1007. return node;
  1008. case _tokentype.types.num:case _tokentype.types.string:
  1009. return this.parseLiteral(this.value);
  1010. case _tokentype.types._null:case _tokentype.types._true:case _tokentype.types._false:
  1011. node = this.startNode();
  1012. node.value = this.type === _tokentype.types._null ? null : this.type === _tokentype.types._true;
  1013. node.raw = this.type.keyword;
  1014. this.next();
  1015. return this.finishNode(node, "Literal");
  1016. case _tokentype.types.parenL:
  1017. return this.parseParenAndDistinguishExpression(null, null, canBeArrow);
  1018. case _tokentype.types.bracketL:
  1019. node = this.startNode();
  1020. this.next();
  1021. // check whether this is array comprehension or regular array
  1022. if ((this.options.ecmaVersion >= 7 || this.options.features["es7.comprehensions"]) && this.type === _tokentype.types._for) {
  1023. return this.parseComprehension(node, false);
  1024. }
  1025. node.elements = this.parseExprList(_tokentype.types.bracketR, true, true, refShorthandDefaultPos);
  1026. return this.finishNode(node, "ArrayExpression");
  1027. case _tokentype.types.braceL:
  1028. return this.parseObj(false, refShorthandDefaultPos);
  1029. case _tokentype.types._function:
  1030. node = this.startNode();
  1031. this.next();
  1032. return this.parseFunction(node, false);
  1033. case _tokentype.types.at:
  1034. this.parseDecorators();
  1035. case _tokentype.types._class:
  1036. node = this.startNode();
  1037. this.takeDecorators(node);
  1038. return this.parseClass(node, false);
  1039. case _tokentype.types._new:
  1040. return this.parseNew();
  1041. case _tokentype.types.backQuote:
  1042. return this.parseTemplate();
  1043. case _tokentype.types.doubleColon:
  1044. node = this.startNode();
  1045. this.next();
  1046. node.object = null;
  1047. var callee = node.callee = this.parseNoCallExpr();
  1048. if (callee.type !== "MemberExpression") this.raise(callee.start, "Binding should be performed on object property.");
  1049. return this.finishNode(node, "BindExpression");
  1050. default:
  1051. this.unexpected();
  1052. }
  1053. };
  1054. pp.parseLiteral = function (value) {
  1055. var node = this.startNode();
  1056. node.value = value;
  1057. node.raw = this.input.slice(this.start, this.end);
  1058. this.next();
  1059. return this.finishNode(node, "Literal");
  1060. };
  1061. pp.parseParenExpression = function () {
  1062. this.expect(_tokentype.types.parenL);
  1063. var val = this.parseExpression();
  1064. this.expect(_tokentype.types.parenR);
  1065. return val;
  1066. };
  1067. pp.parseParenAndDistinguishExpression = function (start, isAsync, canBeArrow) {
  1068. start = start || this.markPosition();
  1069. var val = undefined;
  1070. if (this.options.ecmaVersion >= 6) {
  1071. this.next();
  1072. if ((this.options.features["es7.comprehensions"] || this.options.ecmaVersion >= 7) && this.type === _tokentype.types._for) {
  1073. return this.parseComprehension(this.startNodeAt(start), true);
  1074. }
  1075. var innerStart = this.markPosition(),
  1076. exprList = [],
  1077. first = true;
  1078. var refShorthandDefaultPos = { start: 0 },
  1079. spreadStart = undefined,
  1080. innerParenStart = undefined;
  1081. while (this.type !== _tokentype.types.parenR) {
  1082. first ? first = false : this.expect(_tokentype.types.comma);
  1083. if (this.type === _tokentype.types.ellipsis) {
  1084. var spreadNodeStart = this.markPosition();
  1085. spreadStart = this.start;
  1086. exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStart));
  1087. break;
  1088. } else {
  1089. if (this.type === _tokentype.types.parenL && !innerParenStart) {
  1090. innerParenStart = this.start;
  1091. }
  1092. exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));
  1093. }
  1094. }
  1095. var innerEnd = this.markPosition();
  1096. this.expect(_tokentype.types.parenR);
  1097. if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) {
  1098. if (innerParenStart) this.unexpected(innerParenStart);
  1099. return this.parseParenArrowList(start, exprList, isAsync);
  1100. }
  1101. if (!exprList.length) {
  1102. if (isAsync) {
  1103. return;
  1104. } else {
  1105. this.unexpected(this.lastTokStart);
  1106. }
  1107. }
  1108. if (spreadStart) this.unexpected(spreadStart);
  1109. if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
  1110. if (exprList.length > 1) {
  1111. val = this.startNodeAt(innerStart);
  1112. val.expressions = exprList;
  1113. this.finishNodeAt(val, "SequenceExpression", innerEnd);
  1114. } else {
  1115. val = exprList[0];
  1116. }
  1117. } else {
  1118. val = this.parseParenExpression();
  1119. }
  1120. if (this.options.preserveParens) {
  1121. var par = this.startNodeAt(start);
  1122. par.expression = val;
  1123. return this.finishNode(par, "ParenthesizedExpression");
  1124. } else {
  1125. val.parenthesizedExpression = true;
  1126. return val;
  1127. }
  1128. };
  1129. pp.parseParenArrowList = function (start, exprList, isAsync) {
  1130. return this.parseArrowExpression(this.startNodeAt(start), exprList, isAsync);
  1131. };
  1132. pp.parseParenItem = function (node, start) {
  1133. return node;
  1134. };
  1135. // New's precedence is slightly tricky. It must allow its argument
  1136. // to be a `[]` or dot subscript expression, but not a call — at
  1137. // least, not without wrapping it in parentheses. Thus, it uses the
  1138. var empty = [];
  1139. pp.parseNew = function () {
  1140. var node = this.startNode();
  1141. var meta = this.parseIdent(true);
  1142. if (this.options.ecmaVersion >= 6 && this.eat(_tokentype.types.dot)) {
  1143. node.meta = meta;
  1144. node.property = this.parseIdent(true);
  1145. if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");
  1146. return this.finishNode(node, "MetaProperty");
  1147. }
  1148. node.callee = this.parseNoCallExpr();
  1149. if (this.eat(_tokentype.types.parenL)) node.arguments = this.parseExprList(_tokentype.types.parenR, this.options.features["es7.trailingFunctionCommas"]);else node.arguments = empty;
  1150. return this.finishNode(node, "NewExpression");
  1151. };
  1152. // Parse template expression.
  1153. pp.parseTemplateElement = function () {
  1154. var elem = this.startNode();
  1155. elem.value = {
  1156. raw: this.input.slice(this.start, this.end),
  1157. cooked: this.value
  1158. };
  1159. this.next();
  1160. elem.tail = this.type === _tokentype.types.backQuote;
  1161. return this.finishNode(elem, "TemplateElement");
  1162. };
  1163. pp.parseTemplate = function () {
  1164. var node = this.startNode();
  1165. this.next();
  1166. node.expressions = [];
  1167. var curElt = this.parseTemplateElement();
  1168. node.quasis = [curElt];
  1169. while (!curElt.tail) {
  1170. this.expect(_tokentype.types.dollarBraceL);
  1171. node.expressions.push(this.parseExpression());
  1172. this.expect(_tokentype.types.braceR);
  1173. node.quasis.push(curElt = this.parseTemplateElement());
  1174. }
  1175. this.next();
  1176. return this.finishNode(node, "TemplateLiteral");
  1177. };
  1178. // Parse an object literal or binding pattern.
  1179. pp.parseObj = function (isPattern, refShorthandDefaultPos) {
  1180. var node = this.startNode(),
  1181. first = true,
  1182. propHash = {};
  1183. node.properties = [];
  1184. var decorators = [];
  1185. this.next();
  1186. while (!this.eat(_tokentype.types.braceR)) {
  1187. if (!first) {
  1188. this.expect(_tokentype.types.comma);
  1189. if (this.afterTrailingComma(_tokentype.types.braceR)) break;
  1190. } else first = false;
  1191. while (this.type === _tokentype.types.at) {
  1192. decorators.push(this.parseDecorator());
  1193. }
  1194. var prop = this.startNode(),
  1195. isGenerator = false,
  1196. isAsync = false,
  1197. _start2 = undefined;
  1198. if (decorators.length) {
  1199. prop.decorators = decorators;
  1200. decorators = [];
  1201. }
  1202. if (this.options.features["es7.objectRestSpread"] && this.type === _tokentype.types.ellipsis) {
  1203. prop = this.parseSpread();
  1204. prop.type = "SpreadProperty";
  1205. node.properties.push(prop);
  1206. continue;
  1207. }
  1208. if (this.options.ecmaVersion >= 6) {
  1209. prop.method = false;
  1210. prop.shorthand = false;
  1211. if (isPattern || refShorthandDefaultPos) _start2 = this.markPosition();
  1212. if (!isPattern) isGenerator = this.eat(_tokentype.types.star);
  1213. }
  1214. if (this.options.features["es7.asyncFunctions"] && this.isContextual("async")) {
  1215. if (isGenerator || isPattern) this.unexpected();
  1216. var asyncId = this.parseIdent();
  1217. if (this.type === _tokentype.types.colon || this.type === _tokentype.types.parenL) {
  1218. prop.key = asyncId;
  1219. } else {
  1220. isAsync = true;
  1221. this.parsePropertyName(prop);
  1222. }
  1223. } else {
  1224. this.parsePropertyName(prop);
  1225. }
  1226. this.parseObjPropValue(prop, _start2, isGenerator, isAsync, isPattern, refShorthandDefaultPos);
  1227. this.checkPropClash(prop, propHash);
  1228. node.properties.push(this.finishNode(prop, "Property"));
  1229. }
  1230. if (decorators.length) {
  1231. this.raise(this.start, "You have trailing decorators with no property");
  1232. }
  1233. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
  1234. };
  1235. pp.parseObjPropValue = function (prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos) {
  1236. if (this.eat(_tokentype.types.colon)) {
  1237. prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos);
  1238. prop.kind = "init";
  1239. } else if (this.options.ecmaVersion >= 6 && this.type === _tokentype.types.parenL) {
  1240. if (isPattern) this.unexpected();
  1241. prop.kind = "init";
  1242. prop.method = true;
  1243. prop.value = this.parseMethod(isGenerator, isAsync);
  1244. } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type != _tokentype.types.comma && this.type != _tokentype.types.braceR)) {
  1245. if (isGenerator || isAsync || isPattern) this.unexpected();
  1246. prop.kind = prop.key.name;
  1247. this.parsePropertyName(prop);
  1248. prop.value = this.parseMethod(false);
  1249. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  1250. prop.kind = "init";
  1251. if (isPattern) {
  1252. if (this.isKeyword(prop.key.name) || this.strict && (_identifier.reservedWords.strictBind(prop.key.name) || _identifier.reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name);
  1253. prop.value = this.parseMaybeDefault(start, prop.key);
  1254. } else if (this.type === _tokentype.types.eq && refShorthandDefaultPos) {
  1255. if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;
  1256. prop.value = this.parseMaybeDefault(start, prop.key);
  1257. } else {
  1258. prop.value = prop.key;
  1259. }
  1260. prop.shorthand = true;
  1261. } else this.unexpected();
  1262. };
  1263. pp.parsePropertyName = function (prop) {
  1264. if (this.options.ecmaVersion >= 6) {
  1265. if (this.eat(_tokentype.types.bracketL)) {
  1266. prop.computed = true;
  1267. prop.key = this.parseMaybeAssign();
  1268. this.expect(_tokentype.types.bracketR);
  1269. return;
  1270. } else {
  1271. prop.computed = false;
  1272. }
  1273. }
  1274. prop.key = this.type === _tokentype.types.num || this.type === _tokentype.types.string ? this.parseExprAtom() : this.parseIdent(true);
  1275. };
  1276. // Initialize empty function node.
  1277. pp.initFunction = function (node, isAsync) {
  1278. node.id = null;
  1279. if (this.options.ecmaVersion >= 6) {
  1280. node.generator = false;
  1281. node.expression = false;
  1282. }
  1283. if (this.options.features["es7.asyncFunctions"]) {
  1284. node.async = !!isAsync;
  1285. }
  1286. };
  1287. // Parse object or class method.
  1288. pp.parseMethod = function (isGenerator, isAsync) {
  1289. var node = this.startNode();
  1290. this.initFunction(node, isAsync);
  1291. this.expect(_tokentype.types.parenL);
  1292. node.params = this.parseBindingList(_tokentype.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]);
  1293. if (this.options.ecmaVersion >= 6) {
  1294. node.generator = isGenerator;
  1295. }
  1296. this.parseFunctionBody(node);
  1297. return this.finishNode(node, "FunctionExpression");
  1298. };
  1299. // Parse arrow function expression with given parameters.
  1300. pp.parseArrowExpression = function (node, params, isAsync) {
  1301. this.initFunction(node, isAsync);
  1302. node.params = this.toAssignableList(params, true);
  1303. this.parseFunctionBody(node, true);
  1304. return this.finishNode(node, "ArrowFunctionExpression");
  1305. };
  1306. // Parse function body and check parameters.
  1307. pp.parseFunctionBody = function (node, allowExpression) {
  1308. var isExpression = allowExpression && this.type !== _tokentype.types.braceL;
  1309. var oldInAsync = this.inAsync;
  1310. this.inAsync = node.async;
  1311. if (isExpression) {
  1312. node.body = this.parseMaybeAssign();
  1313. node.expression = true;
  1314. } else {
  1315. // Start a new scope with regard to labels and the `inFunction`
  1316. // flag (restore them to their old value afterwards).
  1317. var oldInFunc = this.inFunction,
  1318. oldInGen = this.inGenerator,
  1319. oldLabels = this.labels;
  1320. this.inFunction = true;this.inGenerator = node.generator;this.labels = [];
  1321. node.body = this.parseBlock(true);
  1322. node.expression = false;
  1323. this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;
  1324. }
  1325. this.inAsync = oldInAsync;
  1326. // If this is a strict mode function, verify that argument names
  1327. // are not repeated, and it does not try to bind the words `eval`
  1328. // or `arguments`.
  1329. if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
  1330. var nameHash = {},
  1331. oldStrict = this.strict;
  1332. this.strict = true;
  1333. if (node.id) this.checkLVal(node.id, true);
  1334. for (var i = 0; i < node.params.length; i++) {
  1335. this.checkLVal(node.params[i], true, nameHash);
  1336. }this.strict = oldStrict;
  1337. }
  1338. };
  1339. // Parses a comma-separated list of expressions, and returns them as
  1340. // an array. `close` is the token type that ends the list, and
  1341. // `allowEmpty` can be turned on to allow subsequent commas with
  1342. // nothing in between them to be parsed as `null` (which is needed
  1343. // for array literals).
  1344. pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {
  1345. var elts = [],
  1346. first = true;
  1347. while (!this.eat(close)) {
  1348. if (!first) {
  1349. this.expect(_tokentype.types.comma);
  1350. if (allowTrailingComma && this.afterTrailingComma(close)) break;
  1351. } else first = false;
  1352. if (allowEmpty && this.type === _tokentype.types.comma) {
  1353. elts.push(null);
  1354. } else {
  1355. if (this.type === _tokentype.types.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));
  1356. }
  1357. }
  1358. return elts;
  1359. };
  1360. // Parse the next token as an identifier. If `liberal` is true (used
  1361. // when parsing properties), it will also convert keywords into
  1362. // identifiers.
  1363. pp.parseIdent = function (liberal) {
  1364. var node = this.startNode();
  1365. if (liberal && this.options.allowReserved == "never") liberal = false;
  1366. if (this.type === _tokentype.types.name) {
  1367. if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && _identifier.reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") == -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved");
  1368. node.name = this.value;
  1369. } else if (liberal && this.type.keyword) {
  1370. node.name = this.type.keyword;
  1371. } else {
  1372. this.unexpected();
  1373. }
  1374. this.next();
  1375. return this.finishNode(node, "Identifier");
  1376. };
  1377. // Parses await expression inside async function.
  1378. pp.parseAwait = function (node) {
  1379. if (this.eat(_tokentype.types.semi) || this.canInsertSemicolon()) {
  1380. this.unexpected();
  1381. }
  1382. node.all = this.eat(_tokentype.types.star);
  1383. node.argument = this.parseMaybeUnary();
  1384. return this.finishNode(node, "AwaitExpression");
  1385. };
  1386. // Parses yield expression inside generator.
  1387. pp.parseYield = function () {
  1388. var node = this.startNode();
  1389. this.next();
  1390. if (this.type == _tokentype.types.semi || this.canInsertSemicolon() || this.type != _tokentype.types.star && !this.type.startsExpr) {
  1391. node.delegate = false;
  1392. node.argument = null;
  1393. } else {
  1394. node.delegate = this.eat(_tokentype.types.star);
  1395. node.argument = this.parseMaybeAssign();
  1396. }
  1397. return this.finishNode(node, "YieldExpression");
  1398. };
  1399. // Parses array and generator comprehensions.
  1400. pp.parseComprehension = function (node, isGenerator) {
  1401. node.blocks = [];
  1402. while (this.type === _tokentype.types._for) {
  1403. var block = this.startNode();
  1404. this.next();
  1405. this.expect(_tokentype.types.parenL);
  1406. block.left = this.parseBindingAtom();
  1407. this.checkLVal(block.left, true);
  1408. this.expectContextual("of");
  1409. block.right = this.parseExpression();
  1410. this.expect(_tokentype.types.parenR);
  1411. node.blocks.push(this.finishNode(block, "ComprehensionBlock"));
  1412. }
  1413. node.filter = this.eat(_tokentype.types._if) ? this.parseParenExpression() : null;
  1414. node.body = this.parseExpression();
  1415. this.expect(isGenerator ? _tokentype.types.parenR : _tokentype.types.bracketR);
  1416. node.generator = isGenerator;
  1417. return this.finishNode(node, "ComprehensionExpression");
  1418. };
  1419. },{"./identifier":4,"./state":12,"./tokentype":16,"./util":17}],4:[function(require,module,exports){
  1420. "use strict";
  1421. exports.__esModule = true;
  1422. // Test whether a given character code starts an identifier.
  1423. exports.isIdentifierStart = isIdentifierStart;
  1424. // Test whether a given character is part of an identifier.
  1425. exports.isIdentifierChar = isIdentifierChar;
  1426. // This is a trick taken from Esprima. It turns out that, on
  1427. // non-Chrome browsers, to check whether a string is in a set, a
  1428. // predicate containing a big ugly `switch` statement is faster than
  1429. // a regular expression, and on Chrome the two are about on par.
  1430. // This function uses `eval` (non-lexical) to produce such a
  1431. // predicate from a space-separated string of words.
  1432. //
  1433. // It starts by sorting the words by length.
  1434. function makePredicate(words) {
  1435. words = words.split(" ");
  1436. return function (str) {
  1437. return words.indexOf(str) >= 0;
  1438. };
  1439. }
  1440. // Reserved word lists for various dialects of the language
  1441. var reservedWords = {
  1442. 3: makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),
  1443. 5: makePredicate("class enum extends super const export import"),
  1444. 6: makePredicate("enum await"),
  1445. strict: makePredicate("implements interface let package private protected public static yield"),
  1446. strictBind: makePredicate("eval arguments")
  1447. };
  1448. exports.reservedWords = reservedWords;
  1449. // And the keywords
  1450. var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
  1451. var keywords = {
  1452. 5: makePredicate(ecma5AndLessKeywords),
  1453. 6: makePredicate(ecma5AndLessKeywords + " let const class extends export import yield super")
  1454. };
  1455. exports.keywords = keywords;
  1456. // ## Character categories
  1457. // Big ugly regular expressions that match characters in the
  1458. // whitespace, identifier, and identifier-start categories. These
  1459. // are only applied when a character is found to actually have a
  1460. // code point above 128.
  1461. // Generated by `tools/generate-identifier-regex.js`.
  1462. var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
  1463. var nonASCIIidentifierChars = "‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";
  1464. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  1465. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  1466. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  1467. // These are a run-length and offset encoded representation of the
  1468. // >0xffff code points that are a valid part of identifiers. The
  1469. // offset starts at 0x10000, and each pair of numbers represents an
  1470. // offset to the next range, and then a size of the range. They were
  1471. // generated by tools/generate-identifier-regex.js
  1472. var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 99, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 98, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 955, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 38, 17, 2, 24, 133, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 32, 4, 287, 47, 21, 1, 2, 0, 185, 46, 82, 47, 21, 0, 60, 42, 502, 63, 32, 0, 449, 56, 1288, 920, 104, 110, 2962, 1070, 13266, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 16481, 1, 3071, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 1340, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 16355, 541];
  1473. var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 16, 9, 83, 11, 168, 11, 6, 9, 8, 2, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 316, 19, 13, 9, 214, 6, 3, 8, 112, 16, 16, 9, 82, 12, 9, 9, 535, 9, 20855, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 4305, 6, 792618, 239];
  1474. // This has a complexity linear to the value of the code. The
  1475. // assumption is that looking up astral identifier characters is
  1476. // rare.
  1477. function isInAstralSet(code, set) {
  1478. var pos = 65536;
  1479. for (var i = 0; i < set.length; i += 2) {
  1480. pos += set[i];
  1481. if (pos > code) return false;
  1482. pos += set[i + 1];
  1483. if (pos >= code) return true;
  1484. }
  1485. }
  1486. function isIdentifierStart(code, astral) {
  1487. if (code < 65) return code === 36;
  1488. if (code < 91) return true;
  1489. if (code < 97) return code === 95;
  1490. if (code < 123) return true;
  1491. if (code <= 65535) return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
  1492. if (astral === false) return false;
  1493. return isInAstralSet(code, astralIdentifierStartCodes);
  1494. }
  1495. function isIdentifierChar(code, astral) {
  1496. if (code < 48) return code === 36;
  1497. if (code < 58) return true;
  1498. if (code < 65) return false;
  1499. if (code < 91) return true;
  1500. if (code < 97) return code === 95;
  1501. if (code < 123) return true;
  1502. if (code <= 65535) return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
  1503. if (astral === false) return false;
  1504. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  1505. }
  1506. },{}],5:[function(require,module,exports){
  1507. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  1508. //
  1509. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  1510. // various contributors and released under an MIT license.
  1511. //
  1512. // Git repositories for Acorn are available at
  1513. //
  1514. // http://marijnhaverbeke.nl/git/acorn
  1515. // https://github.com/marijnh/acorn.git
  1516. //
  1517. // Please use the [github bug tracker][ghbt] to report issues.
  1518. //
  1519. // [ghbt]: https://github.com/marijnh/acorn/issues
  1520. //
  1521. // This file defines the main parser interface. The library also comes
  1522. // with a [error-tolerant parser][dammit] and an
  1523. // [abstract syntax tree walker][walk], defined in other files.
  1524. //
  1525. // [dammit]: acorn_loose.js
  1526. // [walk]: util/walk.js
  1527. "use strict";
  1528. exports.__esModule = true;
  1529. // The main exported interface (under `self.acorn` when in the
  1530. // browser) is a `parse` function that takes a code string and
  1531. // returns an abstract syntax tree as specified by [Mozilla parser
  1532. // API][api].
  1533. //
  1534. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  1535. exports.parse = parse;
  1536. // This function tries to parse a single expression at a given
  1537. // offset in a string. Useful for parsing mixed-language formats
  1538. // that embed JavaScript expressions.
  1539. exports.parseExpressionAt = parseExpressionAt;
  1540. // Acorn is organized as a tokenizer and a recursive-descent parser.
  1541. // The `tokenize` export provides an interface to the tokenizer.
  1542. // Because the tokenizer is optimized for being efficiently used by
  1543. // the Acorn parser itself, this interface is somewhat crude and not
  1544. // very modular.
  1545. exports.tokenizer = tokenizer;
  1546. var _state = require("./state");
  1547. var _options = require("./options");
  1548. require("./parseutil");
  1549. require("./statement");
  1550. require("./lval");
  1551. require("./expression");
  1552. require("./lookahead");
  1553. exports.Parser = _state.Parser;
  1554. exports.plugins = _state.plugins;
  1555. exports.defaultOptions = _options.defaultOptions;
  1556. var _location = require("./location");
  1557. exports.SourceLocation = _location.SourceLocation;
  1558. exports.getLineInfo = _location.getLineInfo;
  1559. var _node = require("./node");
  1560. exports.Node = _node.Node;
  1561. var _tokentype = require("./tokentype");
  1562. exports.TokenType = _tokentype.TokenType;
  1563. exports.tokTypes = _tokentype.types;
  1564. var _tokencontext = require("./tokencontext");
  1565. exports.TokContext = _tokencontext.TokContext;
  1566. exports.tokContexts = _tokencontext.types;
  1567. var _identifier = require("./identifier");
  1568. exports.isIdentifierChar = _identifier.isIdentifierChar;
  1569. exports.isIdentifierStart = _identifier.isIdentifierStart;
  1570. var _tokenize = require("./tokenize");
  1571. exports.Token = _tokenize.Token;
  1572. var _whitespace = require("./whitespace");
  1573. exports.isNewLine = _whitespace.isNewLine;
  1574. exports.lineBreak = _whitespace.lineBreak;
  1575. exports.lineBreakG = _whitespace.lineBreakG;
  1576. var version = "1.0.0";exports.version = version;
  1577. function parse(input, options) {
  1578. var p = parser(options, input);
  1579. var startPos = p.options.locations ? [p.pos, p.curPosition()] : p.pos;
  1580. p.nextToken();
  1581. return p.parseTopLevel(p.options.program || p.startNodeAt(startPos));
  1582. }
  1583. function parseExpressionAt(input, pos, options) {
  1584. var p = parser(options, input, pos);
  1585. p.nextToken();
  1586. return p.parseExpression();
  1587. }
  1588. function tokenizer(input, options) {
  1589. return parser(options, input);
  1590. }
  1591. function parser(options, input) {
  1592. return new _state.Parser((0, _options.getOptions)(options), String(input));
  1593. }
  1594. },{"./expression":3,"./identifier":4,"./location":6,"./lookahead":7,"./lval":8,"./node":9,"./options":10,"./parseutil":11,"./state":12,"./statement":13,"./tokencontext":14,"./tokenize":15,"./tokentype":16,"./whitespace":18}],6:[function(require,module,exports){
  1595. "use strict";
  1596. exports.__esModule = true;
  1597. // The `getLineInfo` function is mostly useful when the
  1598. // `locations` option is off (for performance reasons) and you
  1599. // want to find the line/column position for a given character
  1600. // offset. `input` should be the code string that the offset refers
  1601. // into.
  1602. exports.getLineInfo = getLineInfo;
  1603. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1604. var _state = require("./state");
  1605. var _whitespace = require("./whitespace");
  1606. // These are used when `options.locations` is on, for the
  1607. // `startLoc` and `endLoc` properties.
  1608. var Position = (function () {
  1609. function Position(line, col) {
  1610. _classCallCheck(this, Position);
  1611. this.line = line;
  1612. this.column = col;
  1613. }
  1614. Position.prototype.offset = function offset(n) {
  1615. return new Position(this.line, this.column + n);
  1616. };
  1617. return Position;
  1618. })();
  1619. exports.Position = Position;
  1620. var SourceLocation = function SourceLocation(p, start, end) {
  1621. _classCallCheck(this, SourceLocation);
  1622. this.start = start;
  1623. this.end = end;
  1624. if (p.sourceFile !== null) this.source = p.sourceFile;
  1625. };
  1626. exports.SourceLocation = SourceLocation;
  1627. function getLineInfo(input, offset) {
  1628. for (var line = 1, cur = 0;;) {
  1629. _whitespace.lineBreakG.lastIndex = cur;
  1630. var match = _whitespace.lineBreakG.exec(input);
  1631. if (match && match.index < offset) {
  1632. ++line;
  1633. cur = match.index + match[0].length;
  1634. } else {
  1635. return new Position(line, offset - cur);
  1636. }
  1637. }
  1638. }
  1639. var pp = _state.Parser.prototype;
  1640. // This function is used to raise exceptions on parse errors. It
  1641. // takes an offset integer (into the current `input`) to indicate
  1642. // the location of the error, attaches the position to the end
  1643. // of the error message, and then raises a `SyntaxError` with that
  1644. // message.
  1645. pp.raise = function (pos, message) {
  1646. var loc = getLineInfo(this.input, pos);
  1647. message += " (" + loc.line + ":" + loc.column + ")";
  1648. var err = new SyntaxError(message);
  1649. err.pos = pos;err.loc = loc;err.raisedAt = this.pos;
  1650. throw err;
  1651. };
  1652. pp.curPosition = function () {
  1653. return new Position(this.curLine, this.pos - this.lineStart);
  1654. };
  1655. pp.markPosition = function () {
  1656. return this.options.locations ? [this.start, this.startLoc] : this.start;
  1657. };
  1658. },{"./state":12,"./whitespace":18}],7:[function(require,module,exports){
  1659. "use strict";
  1660. var _state = require("./state");
  1661. var pp = _state.Parser.prototype;
  1662. var STATE_KEYS = ["lastTokStartLoc", "lastTokEndLoc", "lastTokStart", "lastTokEnd", "lineStart", "startLoc", "endLoc", "start", "pos", "end", "type", "value", "exprAllowed", "potentialArrowAt", "currLine", "input"];
  1663. pp.getState = function () {
  1664. var state = {};
  1665. for (var i = 0; i < STATE_KEYS.length; i++) {
  1666. var key = STATE_KEYS[i];
  1667. state[key] = this[key];
  1668. }
  1669. state.context = this.context.slice();
  1670. return state;
  1671. };
  1672. pp.lookahead = function () {
  1673. var old = this.getState();
  1674. this.isLookahead = true;
  1675. this.next();
  1676. this.isLookahead = false;
  1677. var curr = this.getState();
  1678. for (var key in old) this[key] = old[key];
  1679. return curr;
  1680. };
  1681. },{"./state":12}],8:[function(require,module,exports){
  1682. "use strict";
  1683. var _tokentype = require("./tokentype");
  1684. var _state = require("./state");
  1685. var _identifier = require("./identifier");
  1686. var _util = require("./util");
  1687. var pp = _state.Parser.prototype;
  1688. // Convert existing expression atom to assignable pattern
  1689. // if possible.
  1690. pp.toAssignable = function (node, isBinding) {
  1691. if (this.options.ecmaVersion >= 6 && node) {
  1692. switch (node.type) {
  1693. case "Identifier":
  1694. case "ObjectPattern":
  1695. case "ArrayPattern":
  1696. case "AssignmentPattern":
  1697. break;
  1698. case "ObjectExpression":
  1699. node.type = "ObjectPattern";
  1700. for (var i = 0; i < node.properties.length; i++) {
  1701. var prop = node.properties[i];
  1702. if (prop.type === "SpreadProperty") continue;
  1703. if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");
  1704. this.toAssignable(prop.value, isBinding);
  1705. }
  1706. break;
  1707. case "ArrayExpression":
  1708. node.type = "ArrayPattern";
  1709. this.toAssignableList(node.elements, isBinding);
  1710. break;
  1711. case "AssignmentExpression":
  1712. if (node.operator === "=") {
  1713. node.type = "AssignmentPattern";
  1714. } else {
  1715. this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
  1716. }
  1717. break;
  1718. case "MemberExpression":
  1719. if (!isBinding) break;
  1720. default:
  1721. this.raise(node.start, "Assigning to rvalue");
  1722. }
  1723. }
  1724. return node;
  1725. };
  1726. // Convert list of expression atoms to binding list.
  1727. pp.toAssignableList = function (exprList, isBinding) {
  1728. var end = exprList.length;
  1729. if (end) {
  1730. var last = exprList[end - 1];
  1731. if (last && last.type == "RestElement") {
  1732. --end;
  1733. } else if (last && last.type == "SpreadElement") {
  1734. last.type = "RestElement";
  1735. var arg = last.argument;
  1736. this.toAssignable(arg, isBinding);
  1737. if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);
  1738. --end;
  1739. }
  1740. }
  1741. for (var i = 0; i < end; i++) {
  1742. var elt = exprList[i];
  1743. if (elt) this.toAssignable(elt, isBinding);
  1744. }
  1745. return exprList;
  1746. };
  1747. // Parses spread element.
  1748. pp.parseSpread = function (refShorthandDefaultPos) {
  1749. var node = this.startNode();
  1750. this.next();
  1751. node.argument = this.parseMaybeAssign(refShorthandDefaultPos);
  1752. return this.finishNode(node, "SpreadElement");
  1753. };
  1754. pp.parseRest = function () {
  1755. var node = this.startNode();
  1756. this.next();
  1757. node.argument = this.type === _tokentype.types.name || this.type === _tokentype.types.bracketL ? this.parseBindingAtom() : this.unexpected();
  1758. return this.finishNode(node, "RestElement");
  1759. };
  1760. // Parses lvalue (assignable) atom.
  1761. pp.parseBindingAtom = function () {
  1762. if (this.options.ecmaVersion < 6) return this.parseIdent();
  1763. switch (this.type) {
  1764. case _tokentype.types.name:
  1765. return this.parseIdent();
  1766. case _tokentype.types.bracketL:
  1767. var node = this.startNode();
  1768. this.next();
  1769. node.elements = this.parseBindingList(_tokentype.types.bracketR, true, true);
  1770. return this.finishNode(node, "ArrayPattern");
  1771. case _tokentype.types.braceL:
  1772. return this.parseObj(true);
  1773. default:
  1774. this.unexpected();
  1775. }
  1776. };
  1777. pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
  1778. var elts = [],
  1779. first = true;
  1780. while (!this.eat(close)) {
  1781. if (first) first = false;else this.expect(_tokentype.types.comma);
  1782. if (allowEmpty && this.type === _tokentype.types.comma) {
  1783. elts.push(null);
  1784. } else if (allowTrailingComma && this.afterTrailingComma(close)) {
  1785. break;
  1786. } else if (this.type === _tokentype.types.ellipsis) {
  1787. elts.push(this.parseAssignableListItemTypes(this.parseRest()));
  1788. this.expect(close);
  1789. break;
  1790. } else {
  1791. var left = this.parseMaybeDefault();
  1792. this.parseAssignableListItemTypes(left);
  1793. elts.push(this.parseMaybeDefault(null, left));
  1794. }
  1795. }
  1796. return elts;
  1797. };
  1798. pp.parseAssignableListItemTypes = function (param) {
  1799. return param;
  1800. };
  1801. // Parses assignment pattern around given atom if possible.
  1802. pp.parseMaybeDefault = function (startPos, left) {
  1803. startPos = startPos || this.markPosition();
  1804. left = left || this.parseBindingAtom();
  1805. if (!this.eat(_tokentype.types.eq)) return left;
  1806. var node = this.startNodeAt(startPos);
  1807. node.operator = "=";
  1808. node.left = left;
  1809. node.right = this.parseMaybeAssign();
  1810. return this.finishNode(node, "AssignmentPattern");
  1811. };
  1812. // Verify that a node is an lval — something that can be assigned
  1813. // to.
  1814. pp.checkLVal = function (expr, isBinding, checkClashes) {
  1815. switch (expr.type) {
  1816. case "Identifier":
  1817. if (this.strict && (_identifier.reservedWords.strictBind(expr.name) || _identifier.reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
  1818. if (checkClashes) {
  1819. if ((0, _util.has)(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");
  1820. checkClashes[expr.name] = true;
  1821. }
  1822. break;
  1823. case "MemberExpression":
  1824. if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");
  1825. break;
  1826. case "ObjectPattern":
  1827. for (var i = 0; i < expr.properties.length; i++) {
  1828. var prop = expr.properties[i];
  1829. if (prop.type === "Property") prop = prop.value;
  1830. this.checkLVal(prop, isBinding, checkClashes);
  1831. }
  1832. break;
  1833. case "ArrayPattern":
  1834. for (var i = 0; i < expr.elements.length; i++) {
  1835. var elem = expr.elements[i];
  1836. if (elem) this.checkLVal(elem, isBinding, checkClashes);
  1837. }
  1838. break;
  1839. case "AssignmentPattern":
  1840. this.checkLVal(expr.left, isBinding, checkClashes);
  1841. break;
  1842. case "SpreadProperty":
  1843. case "RestElement":
  1844. this.checkLVal(expr.argument, isBinding, checkClashes);
  1845. break;
  1846. default:
  1847. this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");
  1848. }
  1849. };
  1850. },{"./identifier":4,"./state":12,"./tokentype":16,"./util":17}],9:[function(require,module,exports){
  1851. "use strict";
  1852. exports.__esModule = true;
  1853. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1854. var _state = require("./state");
  1855. var _location = require("./location");
  1856. // Start an AST node, attaching a start offset.
  1857. var pp = _state.Parser.prototype;
  1858. var Node = function Node() {
  1859. _classCallCheck(this, Node);
  1860. };
  1861. exports.Node = Node;
  1862. pp.startNode = function () {
  1863. var node = new Node();
  1864. node.start = this.start;
  1865. if (this.options.locations) node.loc = new _location.SourceLocation(this, this.startLoc);
  1866. if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
  1867. if (this.options.ranges) node.range = [this.start, 0];
  1868. return node;
  1869. };
  1870. pp.startNodeAt = function (pos) {
  1871. var node = new Node(),
  1872. start = pos;
  1873. if (this.options.locations) {
  1874. node.loc = new _location.SourceLocation(this, start[1]);
  1875. start = pos[0];
  1876. }
  1877. node.start = start;
  1878. if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
  1879. if (this.options.ranges) node.range = [start, 0];
  1880. return node;
  1881. };
  1882. // Finish an AST node, adding `type` and `end` properties.
  1883. pp.finishNode = function (node, type) {
  1884. node.type = type;
  1885. node.end = this.lastTokEnd;
  1886. if (this.options.locations) node.loc.end = this.lastTokEndLoc;
  1887. if (this.options.ranges) node.range[1] = this.lastTokEnd;
  1888. return node;
  1889. };
  1890. // Finish node at given position
  1891. pp.finishNodeAt = function (node, type, pos) {
  1892. if (this.options.locations) {
  1893. node.loc.end = pos[1];pos = pos[0];
  1894. }
  1895. node.type = type;
  1896. node.end = pos;
  1897. if (this.options.ranges) node.range[1] = pos;
  1898. return node;
  1899. };
  1900. },{"./location":6,"./state":12}],10:[function(require,module,exports){
  1901. "use strict";
  1902. exports.__esModule = true;
  1903. // Interpret and default an options object
  1904. exports.getOptions = getOptions;
  1905. var _util = require("./util");
  1906. var _location = require("./location");
  1907. // A second optional argument can be given to further configure
  1908. // the parser process. These options are recognized:
  1909. var defaultOptions = {
  1910. // `ecmaVersion` indicates the ECMAScript version to parse. Must
  1911. // be either 3, or 5, or 6. This influences support for strict
  1912. // mode, the set of reserved words, support for getters and
  1913. // setters and other features.
  1914. ecmaVersion: 5,
  1915. // Source type ("script" or "module") for different semantics
  1916. sourceType: "script",
  1917. // `onInsertedSemicolon` can be a callback that will be called
  1918. // when a semicolon is automatically inserted. It will be passed
  1919. // th position of the comma as an offset, and if `locations` is
  1920. // enabled, it is given the location as a `{line, column}` object
  1921. // as second argument.
  1922. onInsertedSemicolon: null,
  1923. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  1924. // trailing commas.
  1925. onTrailingComma: null,
  1926. // By default, reserved words are not enforced. Disable
  1927. // `allowReserved` to enforce them. When this option has the
  1928. // value "never", reserved words and keywords can also not be
  1929. // used as property names.
  1930. allowReserved: true,
  1931. // When enabled, a return at the top level is not considered an
  1932. // error.
  1933. allowReturnOutsideFunction: false,
  1934. // When enabled, import/export statements are not constrained to
  1935. // appearing at the top of the program.
  1936. allowImportExportEverywhere: false,
  1937. // When enabled, hashbang directive in the beginning of file
  1938. // is allowed and treated as a line comment.
  1939. allowHashBang: false,
  1940. // When `locations` is on, `loc` properties holding objects with
  1941. // `start` and `end` properties in `{line, column}` form (with
  1942. // line being 1-based and column 0-based) will be attached to the
  1943. // nodes.
  1944. locations: false,
  1945. // A function can be passed as `onToken` option, which will
  1946. // cause Acorn to call that function with object in the same
  1947. // format as tokenize() returns. Note that you are not
  1948. // allowed to call the parser from the callback—that will
  1949. // corrupt its internal state.
  1950. onToken: null,
  1951. // A function can be passed as `onComment` option, which will
  1952. // cause Acorn to call that function with `(block, text, start,
  1953. // end)` parameters whenever a comment is skipped. `block` is a
  1954. // boolean indicating whether this is a block (`/* */`) comment,
  1955. // `text` is the content of the comment, and `start` and `end` are
  1956. // character offsets that denote the start and end of the comment.
  1957. // When the `locations` option is on, two more parameters are
  1958. // passed, the full `{line, column}` locations of the start and
  1959. // end of the comments. Note that you are not allowed to call the
  1960. // parser from the callback—that will corrupt its internal state.
  1961. onComment: null,
  1962. // Nodes have their start and end characters offsets recorded in
  1963. // `start` and `end` properties (directly on the node, rather than
  1964. // the `loc` object, which holds line/column data. To also add a
  1965. // [semi-standardized][range] `range` property holding a `[start,
  1966. // end]` array with the same numbers, set the `ranges` option to
  1967. // `true`.
  1968. //
  1969. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  1970. ranges: false,
  1971. // It is possible to parse multiple files into a single AST by
  1972. // passing the tree produced by parsing the first file as
  1973. // `program` option in subsequent parses. This will add the
  1974. // toplevel forms of the parsed file to the `Program` (top) node
  1975. // of an existing parse tree.
  1976. program: null,
  1977. // When `locations` is on, you can pass this to record the source
  1978. // file in every node's `loc` object.
  1979. sourceFile: null,
  1980. // This value, if given, is stored in every node, whether
  1981. // `locations` is on or off.
  1982. directSourceFile: null,
  1983. // When enabled, parenthesized expressions are represented by
  1984. // (non-standard) ParenthesizedExpression nodes
  1985. preserveParens: false,
  1986. plugins: {},
  1987. // Babel-specific options
  1988. features: {},
  1989. strictMode: null
  1990. };exports.defaultOptions = defaultOptions;
  1991. function getOptions(opts) {
  1992. var options = {};
  1993. for (var opt in defaultOptions) {
  1994. options[opt] = opts && (0, _util.has)(opts, opt) ? opts[opt] : defaultOptions[opt];
  1995. }if ((0, _util.isArray)(options.onToken)) {
  1996. (function () {
  1997. var tokens = options.onToken;
  1998. options.onToken = function (token) {
  1999. return tokens.push(token);
  2000. };
  2001. })();
  2002. }
  2003. if ((0, _util.isArray)(options.onComment)) options.onComment = pushComment(options, options.onComment);
  2004. return options;
  2005. }
  2006. function pushComment(options, array) {
  2007. return function (block, text, start, end, startLoc, endLoc) {
  2008. var comment = {
  2009. type: block ? "Block" : "Line",
  2010. value: text,
  2011. start: start,
  2012. end: end
  2013. };
  2014. if (options.locations) comment.loc = new _location.SourceLocation(this, startLoc, endLoc);
  2015. if (options.ranges) comment.range = [start, end];
  2016. array.push(comment);
  2017. };
  2018. }
  2019. },{"./location":6,"./util":17}],11:[function(require,module,exports){
  2020. "use strict";
  2021. var _tokentype = require("./tokentype");
  2022. var _state = require("./state");
  2023. var _whitespace = require("./whitespace");
  2024. var pp = _state.Parser.prototype;
  2025. // ## Parser utilities
  2026. // Test whether a statement node is the string literal `"use strict"`.
  2027. pp.isUseStrict = function (stmt) {
  2028. return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
  2029. };
  2030. // Predicate that tests whether the next token is of the given
  2031. // type, and if yes, consumes it as a side effect.
  2032. pp.eat = function (type) {
  2033. if (this.type === type) {
  2034. this.next();
  2035. return true;
  2036. } else {
  2037. return false;
  2038. }
  2039. };
  2040. // Tests whether parsed token is a contextual keyword.
  2041. pp.isContextual = function (name) {
  2042. return this.type === _tokentype.types.name && this.value === name;
  2043. };
  2044. // Consumes contextual keyword if possible.
  2045. pp.eatContextual = function (name) {
  2046. return this.value === name && this.eat(_tokentype.types.name);
  2047. };
  2048. // Asserts that following token is given contextual keyword.
  2049. pp.expectContextual = function (name) {
  2050. if (!this.eatContextual(name)) this.unexpected();
  2051. };
  2052. // Test whether a semicolon can be inserted at the current position.
  2053. pp.canInsertSemicolon = function () {
  2054. return this.type === _tokentype.types.eof || this.type === _tokentype.types.braceR || _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  2055. };
  2056. pp.insertSemicolon = function () {
  2057. if (this.canInsertSemicolon()) {
  2058. if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
  2059. return true;
  2060. }
  2061. };
  2062. // Consume a semicolon, or, failing that, see if we are allowed to
  2063. // pretend that there is a semicolon at this position.
  2064. pp.semicolon = function () {
  2065. if (!this.eat(_tokentype.types.semi) && !this.insertSemicolon()) this.unexpected();
  2066. };
  2067. pp.afterTrailingComma = function (tokType) {
  2068. if (this.type == tokType) {
  2069. if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
  2070. this.next();
  2071. return true;
  2072. }
  2073. };
  2074. // Expect a token of a given type. If found, consume it, otherwise,
  2075. // raise an unexpected token error.
  2076. pp.expect = function (type) {
  2077. this.eat(type) || this.unexpected();
  2078. };
  2079. // Raise an unexpected token error.
  2080. pp.unexpected = function (pos) {
  2081. this.raise(pos != null ? pos : this.start, "Unexpected token");
  2082. };
  2083. },{"./state":12,"./tokentype":16,"./whitespace":18}],12:[function(require,module,exports){
  2084. "use strict";
  2085. exports.__esModule = true;
  2086. exports.Parser = Parser;
  2087. var _identifier = require("./identifier");
  2088. var _tokentype = require("./tokentype");
  2089. function Parser(options, input, startPos) {
  2090. this.options = options;
  2091. this.loadPlugins(this.options.plugins);
  2092. this.sourceFile = this.options.sourceFile || null;
  2093. this.isKeyword = _identifier.keywords[this.options.ecmaVersion >= 6 ? 6 : 5];
  2094. this.isReservedWord = _identifier.reservedWords[this.options.ecmaVersion];
  2095. this.input = input;
  2096. // Set up token state
  2097. // The current position of the tokenizer in the input.
  2098. if (startPos) {
  2099. this.pos = startPos;
  2100. this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));
  2101. this.curLine = this.input.slice(0, this.lineStart).split(_tokentype.lineBreak).length;
  2102. } else {
  2103. this.pos = this.lineStart = 0;
  2104. this.curLine = 1;
  2105. }
  2106. // Properties of the current token:
  2107. // Its type
  2108. this.type = _tokentype.types.eof;
  2109. // For tokens that include more information than their type, the value
  2110. this.value = null;
  2111. // Its start and end offset
  2112. this.start = this.end = this.pos;
  2113. // And, if locations are used, the {line, column} object
  2114. // corresponding to those offsets
  2115. this.startLoc = this.endLoc = null;
  2116. // Position information for the previous token
  2117. this.lastTokEndLoc = this.lastTokStartLoc = null;
  2118. this.lastTokStart = this.lastTokEnd = this.pos;
  2119. // The context stack is used to superficially track syntactic
  2120. // context to predict whether a regular expression is allowed in a
  2121. // given position.
  2122. this.context = this.initialContext();
  2123. this.exprAllowed = true;
  2124. // Figure out if it's a module code.
  2125. this.inModule = this.options.sourceType === "module";
  2126. this.strict = this.options.strictMode === false ? false : this.inModule;
  2127. // Used to signify the start of a potential arrow function
  2128. this.potentialArrowAt = -1;
  2129. // Flags to track whether we are in a function, a generator.
  2130. this.inFunction = this.inGenerator = false;
  2131. // Labels in scope.
  2132. this.labels = [];
  2133. this.decorators = [];
  2134. // If enabled, skip leading hashbang line.
  2135. if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);
  2136. }
  2137. Parser.prototype.extend = function (name, f) {
  2138. this[name] = f(this[name]);
  2139. };
  2140. // Registered plugins
  2141. var plugins = {};
  2142. exports.plugins = plugins;
  2143. Parser.prototype.loadPlugins = function (plugins) {
  2144. for (var _name in plugins) {
  2145. var plugin = exports.plugins[_name];
  2146. if (!plugin) throw new Error("Plugin '" + _name + "' not found");
  2147. plugin(this, plugins[_name]);
  2148. }
  2149. };
  2150. },{"./identifier":4,"./tokentype":16}],13:[function(require,module,exports){
  2151. "use strict";
  2152. var _tokentype = require("./tokentype");
  2153. var _state = require("./state");
  2154. var _whitespace = require("./whitespace");
  2155. var pp = _state.Parser.prototype;
  2156. // ### Statement parsing
  2157. // Parse a program. Initializes the parser, reads any number of
  2158. // statements, and wraps them in a Program node. Optionally takes a
  2159. // `program` argument. If present, the statements will be appended
  2160. // to its body instead of creating a new node.
  2161. pp.parseTopLevel = function (node) {
  2162. var first = true;
  2163. if (!node.body) node.body = [];
  2164. while (this.type !== _tokentype.types.eof) {
  2165. var stmt = this.parseStatement(true, true);
  2166. node.body.push(stmt);
  2167. if (first && this.isUseStrict(stmt)) this.setStrict(true);
  2168. first = false;
  2169. }
  2170. this.next();
  2171. if (this.options.ecmaVersion >= 6) {
  2172. node.sourceType = this.options.sourceType;
  2173. }
  2174. return this.finishNode(node, "Program");
  2175. };
  2176. var loopLabel = { kind: "loop" },
  2177. switchLabel = { kind: "switch" };
  2178. // Parse a single statement.
  2179. //
  2180. // If expecting a statement and finding a slash operator, parse a
  2181. // regular expression literal. This is to handle cases like
  2182. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  2183. // does not help.
  2184. pp.parseStatement = function (declaration, topLevel) {
  2185. if (this.type === _tokentype.types.at) {
  2186. this.parseDecorators(true);
  2187. }
  2188. var starttype = this.type,
  2189. node = this.startNode();
  2190. // Most types of statements are recognized by the keyword they
  2191. // start with. Many are trivial to parse, some require a bit of
  2192. // complexity.
  2193. switch (starttype) {
  2194. case _tokentype.types._break:case _tokentype.types._continue:
  2195. return this.parseBreakContinueStatement(node, starttype.keyword);
  2196. case _tokentype.types._debugger:
  2197. return this.parseDebuggerStatement(node);
  2198. case _tokentype.types._do:
  2199. return this.parseDoStatement(node);
  2200. case _tokentype.types._for:
  2201. return this.parseForStatement(node);
  2202. case _tokentype.types._function:
  2203. if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();
  2204. return this.parseFunctionStatement(node);
  2205. case _tokentype.types._class:
  2206. if (!declaration) this.unexpected();
  2207. this.takeDecorators(node);
  2208. return this.parseClass(node, true);
  2209. case _tokentype.types._if:
  2210. return this.parseIfStatement(node);
  2211. case _tokentype.types._return:
  2212. return this.parseReturnStatement(node);
  2213. case _tokentype.types._switch:
  2214. return this.parseSwitchStatement(node);
  2215. case _tokentype.types._throw:
  2216. return this.parseThrowStatement(node);
  2217. case _tokentype.types._try:
  2218. return this.parseTryStatement(node);
  2219. case _tokentype.types._let:case _tokentype.types._const:
  2220. if (!declaration) this.unexpected(); // NOTE: falls through to _var
  2221. case _tokentype.types._var:
  2222. return this.parseVarStatement(node, starttype);
  2223. case _tokentype.types._while:
  2224. return this.parseWhileStatement(node);
  2225. case _tokentype.types._with:
  2226. return this.parseWithStatement(node);
  2227. case _tokentype.types.braceL:
  2228. return this.parseBlock();
  2229. case _tokentype.types.semi:
  2230. return this.parseEmptyStatement(node);
  2231. case _tokentype.types._export:
  2232. case _tokentype.types._import:
  2233. if (!this.options.allowImportExportEverywhere) {
  2234. if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");
  2235. if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
  2236. }
  2237. return starttype === _tokentype.types._import ? this.parseImport(node) : this.parseExport(node);
  2238. case _tokentype.types.name:
  2239. if (this.options.features["es7.asyncFunctions"] && this.value === "async" && this.lookahead().type === _tokentype.types._function) {
  2240. this.next();
  2241. this.expect(_tokentype.types._function);
  2242. return this.parseFunction(node, true, false, true);
  2243. }
  2244. // If the statement does not start with a statement keyword or a
  2245. // brace, it's an ExpressionStatement or LabeledStatement. We
  2246. // simply start parsing an expression, and afterwards, if the
  2247. // next token is a colon and the expression was a simple
  2248. // Identifier node, we switch to interpreting it as a label.
  2249. default:
  2250. var maybeName = this.value,
  2251. expr = this.parseExpression();
  2252. if (starttype === _tokentype.types.name && expr.type === "Identifier" && this.eat(_tokentype.types.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);
  2253. }
  2254. };
  2255. pp.takeDecorators = function (node) {
  2256. if (this.decorators.length) {
  2257. node.decorators = this.decorators;
  2258. this.decorators = [];
  2259. }
  2260. };
  2261. pp.parseDecorators = function (allowExport) {
  2262. while (this.type === _tokentype.types.at) {
  2263. this.decorators.push(this.parseDecorator());
  2264. }
  2265. if (allowExport && this.type === _tokentype.types._export) {
  2266. return;
  2267. }
  2268. if (this.type !== _tokentype.types._class) {
  2269. this.raise(this.start, "Leading decorators must be attached to a class declaration");
  2270. }
  2271. };
  2272. pp.parseDecorator = function (allowExport) {
  2273. if (!this.options.features["es7.decorators"]) {
  2274. this.unexpected();
  2275. }
  2276. var node = this.startNode();
  2277. this.next();
  2278. node.expression = this.parseMaybeAssign();
  2279. return this.finishNode(node, "Decorator");
  2280. };
  2281. pp.parseBreakContinueStatement = function (node, keyword) {
  2282. var isBreak = keyword == "break";
  2283. this.next();
  2284. if (this.eat(_tokentype.types.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== _tokentype.types.name) this.unexpected();else {
  2285. node.label = this.parseIdent();
  2286. this.semicolon();
  2287. }
  2288. // Verify that there is an actual destination to break or
  2289. // continue to.
  2290. for (var i = 0; i < this.labels.length; ++i) {
  2291. var lab = this.labels[i];
  2292. if (node.label == null || lab.name === node.label.name) {
  2293. if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
  2294. if (node.label && isBreak) break;
  2295. }
  2296. }
  2297. if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);
  2298. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  2299. };
  2300. pp.parseDebuggerStatement = function (node) {
  2301. this.next();
  2302. this.semicolon();
  2303. return this.finishNode(node, "DebuggerStatement");
  2304. };
  2305. pp.parseDoStatement = function (node) {
  2306. var start = this.markPosition();
  2307. this.next();
  2308. this.labels.push(loopLabel);
  2309. node.body = this.parseStatement(false);
  2310. this.labels.pop();
  2311. if (this.options.features["es7.doExpressions"] && this.type !== _tokentype.types._while) {
  2312. var container = this.startNodeAt(start);
  2313. container.expression = this.finishNode(node, "DoExpression");
  2314. this.semicolon();
  2315. return this.finishNode(container, "ExpressionStatement");
  2316. }
  2317. this.expect(_tokentype.types._while);
  2318. node.test = this.parseParenExpression();
  2319. if (this.options.ecmaVersion >= 6) this.eat(_tokentype.types.semi);else this.semicolon();
  2320. return this.finishNode(node, "DoWhileStatement");
  2321. };
  2322. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  2323. // loop is non-trivial. Basically, we have to parse the init `var`
  2324. // statement or expression, disallowing the `in` operator (see
  2325. // the second parameter to `parseExpression`), and then check
  2326. // whether the next token is `in` or `of`. When there is no init
  2327. // part (semicolon immediately after the opening parenthesis), it
  2328. // is a regular `for` loop.
  2329. pp.parseForStatement = function (node) {
  2330. this.next();
  2331. this.labels.push(loopLabel);
  2332. this.expect(_tokentype.types.parenL);
  2333. if (this.type === _tokentype.types.semi) return this.parseFor(node, null);
  2334. if (this.type === _tokentype.types._var || this.type === _tokentype.types._let || this.type === _tokentype.types._const) {
  2335. var _init = this.startNode(),
  2336. varKind = this.type;
  2337. this.next();
  2338. this.parseVar(_init, true, varKind);
  2339. this.finishNode(_init, "VariableDeclaration");
  2340. if ((this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== _tokentype.types._var && _init.declarations[0].init)) return this.parseForIn(node, _init);
  2341. return this.parseFor(node, _init);
  2342. }
  2343. var refShorthandDefaultPos = { start: 0 };
  2344. var init = this.parseExpression(true, refShorthandDefaultPos);
  2345. if (this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
  2346. this.toAssignable(init);
  2347. this.checkLVal(init);
  2348. return this.parseForIn(node, init);
  2349. } else if (refShorthandDefaultPos.start) {
  2350. this.unexpected(refShorthandDefaultPos.start);
  2351. }
  2352. return this.parseFor(node, init);
  2353. };
  2354. pp.parseFunctionStatement = function (node) {
  2355. this.next();
  2356. return this.parseFunction(node, true);
  2357. };
  2358. pp.parseIfStatement = function (node) {
  2359. this.next();
  2360. node.test = this.parseParenExpression();
  2361. node.consequent = this.parseStatement(false);
  2362. node.alternate = this.eat(_tokentype.types._else) ? this.parseStatement(false) : null;
  2363. return this.finishNode(node, "IfStatement");
  2364. };
  2365. pp.parseReturnStatement = function (node) {
  2366. if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");
  2367. this.next();
  2368. // In `return` (and `break`/`continue`), the keywords with
  2369. // optional arguments, we eagerly look for a semicolon or the
  2370. // possibility to insert one.
  2371. if (this.eat(_tokentype.types.semi) || this.insertSemicolon()) node.argument = null;else {
  2372. node.argument = this.parseExpression();this.semicolon();
  2373. }
  2374. return this.finishNode(node, "ReturnStatement");
  2375. };
  2376. pp.parseSwitchStatement = function (node) {
  2377. this.next();
  2378. node.discriminant = this.parseParenExpression();
  2379. node.cases = [];
  2380. this.expect(_tokentype.types.braceL);
  2381. this.labels.push(switchLabel);
  2382. // Statements under must be grouped (by label) in SwitchCase
  2383. // nodes. `cur` is used to keep the node that we are currently
  2384. // adding statements to.
  2385. for (var cur, sawDefault; this.type != _tokentype.types.braceR;) {
  2386. if (this.type === _tokentype.types._case || this.type === _tokentype.types._default) {
  2387. var isCase = this.type === _tokentype.types._case;
  2388. if (cur) this.finishNode(cur, "SwitchCase");
  2389. node.cases.push(cur = this.startNode());
  2390. cur.consequent = [];
  2391. this.next();
  2392. if (isCase) {
  2393. cur.test = this.parseExpression();
  2394. } else {
  2395. if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");
  2396. sawDefault = true;
  2397. cur.test = null;
  2398. }
  2399. this.expect(_tokentype.types.colon);
  2400. } else {
  2401. if (!cur) this.unexpected();
  2402. cur.consequent.push(this.parseStatement(true));
  2403. }
  2404. }
  2405. if (cur) this.finishNode(cur, "SwitchCase");
  2406. this.next(); // Closing brace
  2407. this.labels.pop();
  2408. return this.finishNode(node, "SwitchStatement");
  2409. };
  2410. pp.parseThrowStatement = function (node) {
  2411. this.next();
  2412. if (_whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");
  2413. node.argument = this.parseExpression();
  2414. this.semicolon();
  2415. return this.finishNode(node, "ThrowStatement");
  2416. };
  2417. // Reused empty array added for node fields that are always empty.
  2418. var empty = [];
  2419. pp.parseTryStatement = function (node) {
  2420. this.next();
  2421. node.block = this.parseBlock();
  2422. node.handler = null;
  2423. if (this.type === _tokentype.types._catch) {
  2424. var clause = this.startNode();
  2425. this.next();
  2426. this.expect(_tokentype.types.parenL);
  2427. clause.param = this.parseBindingAtom();
  2428. this.checkLVal(clause.param, true);
  2429. this.expect(_tokentype.types.parenR);
  2430. clause.guard = null;
  2431. clause.body = this.parseBlock();
  2432. node.handler = this.finishNode(clause, "CatchClause");
  2433. }
  2434. node.guardedHandlers = empty;
  2435. node.finalizer = this.eat(_tokentype.types._finally) ? this.parseBlock() : null;
  2436. if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");
  2437. return this.finishNode(node, "TryStatement");
  2438. };
  2439. pp.parseVarStatement = function (node, kind) {
  2440. this.next();
  2441. this.parseVar(node, false, kind);
  2442. this.semicolon();
  2443. return this.finishNode(node, "VariableDeclaration");
  2444. };
  2445. pp.parseWhileStatement = function (node) {
  2446. this.next();
  2447. node.test = this.parseParenExpression();
  2448. this.labels.push(loopLabel);
  2449. node.body = this.parseStatement(false);
  2450. this.labels.pop();
  2451. return this.finishNode(node, "WhileStatement");
  2452. };
  2453. pp.parseWithStatement = function (node) {
  2454. if (this.strict) this.raise(this.start, "'with' in strict mode");
  2455. this.next();
  2456. node.object = this.parseParenExpression();
  2457. node.body = this.parseStatement(false);
  2458. return this.finishNode(node, "WithStatement");
  2459. };
  2460. pp.parseEmptyStatement = function (node) {
  2461. this.next();
  2462. return this.finishNode(node, "EmptyStatement");
  2463. };
  2464. pp.parseLabeledStatement = function (node, maybeName, expr) {
  2465. for (var i = 0; i < this.labels.length; ++i) {
  2466. if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");
  2467. }var kind = this.type.isLoop ? "loop" : this.type === _tokentype.types._switch ? "switch" : null;
  2468. this.labels.push({ name: maybeName, kind: kind });
  2469. node.body = this.parseStatement(true);
  2470. this.labels.pop();
  2471. node.label = expr;
  2472. return this.finishNode(node, "LabeledStatement");
  2473. };
  2474. pp.parseExpressionStatement = function (node, expr) {
  2475. node.expression = expr;
  2476. this.semicolon();
  2477. return this.finishNode(node, "ExpressionStatement");
  2478. };
  2479. // Parse a semicolon-enclosed block of statements, handling `"use
  2480. // strict"` declarations when `allowStrict` is true (used for
  2481. // function bodies).
  2482. pp.parseBlock = function (allowStrict) {
  2483. var node = this.startNode(),
  2484. first = true,
  2485. oldStrict = undefined;
  2486. node.body = [];
  2487. this.expect(_tokentype.types.braceL);
  2488. while (!this.eat(_tokentype.types.braceR)) {
  2489. var stmt = this.parseStatement(true);
  2490. node.body.push(stmt);
  2491. if (first && allowStrict && this.isUseStrict(stmt)) {
  2492. oldStrict = this.strict;
  2493. this.setStrict(this.strict = true);
  2494. }
  2495. first = false;
  2496. }
  2497. if (oldStrict === false) this.setStrict(false);
  2498. return this.finishNode(node, "BlockStatement");
  2499. };
  2500. // Parse a regular `for` loop. The disambiguation code in
  2501. // `parseStatement` will already have parsed the init statement or
  2502. // expression.
  2503. pp.parseFor = function (node, init) {
  2504. node.init = init;
  2505. this.expect(_tokentype.types.semi);
  2506. node.test = this.type === _tokentype.types.semi ? null : this.parseExpression();
  2507. this.expect(_tokentype.types.semi);
  2508. node.update = this.type === _tokentype.types.parenR ? null : this.parseExpression();
  2509. this.expect(_tokentype.types.parenR);
  2510. node.body = this.parseStatement(false);
  2511. this.labels.pop();
  2512. return this.finishNode(node, "ForStatement");
  2513. };
  2514. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  2515. // same from parser's perspective.
  2516. pp.parseForIn = function (node, init) {
  2517. var type = this.type === _tokentype.types._in ? "ForInStatement" : "ForOfStatement";
  2518. this.next();
  2519. node.left = init;
  2520. node.right = this.parseExpression();
  2521. this.expect(_tokentype.types.parenR);
  2522. node.body = this.parseStatement(false);
  2523. this.labels.pop();
  2524. return this.finishNode(node, type);
  2525. };
  2526. // Parse a list of variable declarations.
  2527. pp.parseVar = function (node, isFor, kind) {
  2528. node.declarations = [];
  2529. node.kind = kind.keyword;
  2530. for (;;) {
  2531. var decl = this.startNode();
  2532. this.parseVarHead(decl);
  2533. if (this.eat(_tokentype.types.eq)) {
  2534. decl.init = this.parseMaybeAssign(isFor);
  2535. } else if (kind === _tokentype.types._const && !(this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  2536. this.unexpected();
  2537. } else if (decl.id.type != "Identifier" && !(isFor && (this.type === _tokentype.types._in || this.isContextual("of")))) {
  2538. this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
  2539. } else {
  2540. decl.init = null;
  2541. }
  2542. node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
  2543. if (!this.eat(_tokentype.types.comma)) break;
  2544. }
  2545. return node;
  2546. };
  2547. pp.parseVarHead = function (decl) {
  2548. decl.id = this.parseBindingAtom();
  2549. this.checkLVal(decl.id, true);
  2550. };
  2551. // Parse a function declaration or literal (depending on the
  2552. // `isStatement` parameter).
  2553. pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync) {
  2554. this.initFunction(node, isAsync);
  2555. if (this.options.ecmaVersion >= 6) node.generator = this.eat(_tokentype.types.star);
  2556. if (isStatement || this.type === _tokentype.types.name) node.id = this.parseIdent();
  2557. this.parseFunctionParams(node);
  2558. this.parseFunctionBody(node, allowExpressionBody);
  2559. return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
  2560. };
  2561. pp.parseFunctionParams = function (node) {
  2562. this.expect(_tokentype.types.parenL);
  2563. node.params = this.parseBindingList(_tokentype.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]);
  2564. };
  2565. // Parse a class declaration or literal (depending on the
  2566. // `isStatement` parameter).
  2567. pp.parseClass = function (node, isStatement) {
  2568. this.next();
  2569. this.parseClassId(node, isStatement);
  2570. this.parseClassSuper(node);
  2571. var classBody = this.startNode();
  2572. classBody.body = [];
  2573. this.expect(_tokentype.types.braceL);
  2574. var decorators = [];
  2575. while (!this.eat(_tokentype.types.braceR)) {
  2576. if (this.eat(_tokentype.types.semi)) continue;
  2577. if (this.type === _tokentype.types.at) {
  2578. decorators.push(this.parseDecorator());
  2579. continue;
  2580. }
  2581. var method = this.startNode();
  2582. if (decorators.length) {
  2583. method.decorators = decorators;
  2584. decorators = [];
  2585. }
  2586. var isGenerator = this.eat(_tokentype.types.star),
  2587. isAsync = false;
  2588. this.parsePropertyName(method);
  2589. if (this.type !== _tokentype.types.parenL && !method.computed && method.key.type === "Identifier" && method.key.name === "static") {
  2590. if (isGenerator) this.unexpected();
  2591. method["static"] = true;
  2592. isGenerator = this.eat(_tokentype.types.star);
  2593. this.parsePropertyName(method);
  2594. } else {
  2595. method["static"] = false;
  2596. }
  2597. if (!isGenerator && method.key.type === "Identifier" && !method.computed && this.isClassProperty()) {
  2598. classBody.body.push(this.parseClassProperty(method));
  2599. continue;
  2600. }
  2601. if (this.options.features["es7.asyncFunctions"] && this.type !== _tokentype.types.parenL && !method.computed && method.key.type === "Identifier" && method.key.name === "async") {
  2602. isAsync = true;
  2603. this.parsePropertyName(method);
  2604. }
  2605. method.kind = "method";
  2606. if (!method.computed && !isGenerator && !isAsync) {
  2607. if (method.key.type === "Identifier") {
  2608. if (this.type !== _tokentype.types.parenL && (method.key.name === "get" || method.key.name === "set")) {
  2609. method.kind = method.key.name;
  2610. this.parsePropertyName(method);
  2611. } else if (!method["static"] && method.key.name === "constructor") {
  2612. method.kind = "constructor";
  2613. }
  2614. } else if (!method["static"] && method.key.type === "Literal" && method.key.value === "constructor") {
  2615. method.kind = "constructor";
  2616. }
  2617. }
  2618. if (method.kind === "constructor" && method.decorators) {
  2619. this.raise(method.start, "You can't attach decorators to a class constructor");
  2620. }
  2621. this.parseClassMethod(classBody, method, isGenerator, isAsync);
  2622. }
  2623. if (decorators.length) {
  2624. this.raise(this.start, "You have trailing decorators with no method");
  2625. }
  2626. node.body = this.finishNode(classBody, "ClassBody");
  2627. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  2628. };
  2629. pp.isClassProperty = function () {
  2630. return this.type === _tokentype.types.eq || (this.type === _tokentype.types.semi || this.canInsertSemicolon());
  2631. };
  2632. pp.parseClassProperty = function (node) {
  2633. if (this.type === _tokentype.types.eq) {
  2634. if (!this.options.features["es7.classProperties"]) this.unexpected();
  2635. this.next();
  2636. node.value = this.parseMaybeAssign();
  2637. } else {
  2638. node.value = null;
  2639. }
  2640. this.semicolon();
  2641. return this.finishNode(node, "ClassProperty");
  2642. };
  2643. pp.parseClassMethod = function (classBody, method, isGenerator, isAsync) {
  2644. method.value = this.parseMethod(isGenerator, isAsync);
  2645. classBody.body.push(this.finishNode(method, "MethodDefinition"));
  2646. };
  2647. pp.parseClassId = function (node, isStatement) {
  2648. node.id = this.type === _tokentype.types.name ? this.parseIdent() : isStatement ? this.unexpected() : null;
  2649. };
  2650. pp.parseClassSuper = function (node) {
  2651. node.superClass = this.eat(_tokentype.types._extends) ? this.parseExprSubscripts() : null;
  2652. };
  2653. // Parses module export declaration.
  2654. pp.parseExport = function (node) {
  2655. this.next();
  2656. // export * from '...'
  2657. if (this.type === _tokentype.types.star) {
  2658. var specifier = this.startNode();
  2659. this.next();
  2660. if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) {
  2661. specifier.exported = this.parseIdent();
  2662. node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")];
  2663. this.parseExportSpecifiersMaybe(node);
  2664. this.parseExportFrom(node);
  2665. } else {
  2666. this.parseExportFrom(node);
  2667. return this.finishNode(node, "ExportAllDeclaration");
  2668. }
  2669. } else if (this.isExportDefaultSpecifier()) {
  2670. var specifier = this.startNode();
  2671. specifier.exported = this.parseIdent(true);
  2672. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  2673. if (this.type === _tokentype.types.comma && this.lookahead().type === _tokentype.types.star) {
  2674. this.expect(_tokentype.types.comma);
  2675. var _specifier = this.startNode();
  2676. this.expect(_tokentype.types.star);
  2677. this.expectContextual("as");
  2678. _specifier.exported = this.parseIdent();
  2679. node.specifiers.push(this.finishNode(_specifier, "ExportNamespaceSpecifier"));
  2680. } else {
  2681. this.parseExportSpecifiersMaybe(node);
  2682. }
  2683. this.parseExportFrom(node);
  2684. } else if (this.eat(_tokentype.types._default)) {
  2685. // export default ...
  2686. var _expr = this.parseMaybeAssign();
  2687. var needsSemi = true;
  2688. if (_expr.type == "FunctionExpression" || _expr.type == "ClassExpression") {
  2689. needsSemi = false;
  2690. if (_expr.id) {
  2691. _expr.type = _expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";
  2692. }
  2693. }
  2694. node.declaration = _expr;
  2695. if (needsSemi) this.semicolon();
  2696. this.checkExport(node);
  2697. return this.finishNode(node, "ExportDefaultDeclaration");
  2698. } else if (this.type.keyword || this.shouldParseExportDeclaration()) {
  2699. node.declaration = this.parseStatement(true);
  2700. node.specifiers = [];
  2701. node.source = null;
  2702. } else {
  2703. // export { x, y as z } [from '...']
  2704. node.declaration = null;
  2705. node.specifiers = this.parseExportSpecifiers();
  2706. if (this.eatContextual("from")) {
  2707. node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
  2708. } else {
  2709. node.source = null;
  2710. }
  2711. this.semicolon();
  2712. }
  2713. this.checkExport(node);
  2714. return this.finishNode(node, "ExportNamedDeclaration");
  2715. };
  2716. pp.isExportDefaultSpecifier = function () {
  2717. if (this.type === _tokentype.types.name) {
  2718. return this.value !== "type" && this.value !== "async";
  2719. }
  2720. if (this.type !== _tokentype.types._default) {
  2721. return false;
  2722. }
  2723. var lookahead = this.lookahead();
  2724. return lookahead.type === _tokentype.types.comma || lookahead.type === _tokentype.types.name && lookahead.value === "from";
  2725. };
  2726. pp.parseExportSpecifiersMaybe = function (node) {
  2727. if (this.eat(_tokentype.types.comma)) {
  2728. node.specifiers = node.specifiers.concat(this.parseExportSpecifiers());
  2729. }
  2730. };
  2731. pp.parseExportFrom = function (node) {
  2732. this.expectContextual("from");
  2733. node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
  2734. this.semicolon();
  2735. this.checkExport(node);
  2736. };
  2737. pp.shouldParseExportDeclaration = function () {
  2738. return this.options.features["es7.asyncFunctions"] && this.isContextual("async");
  2739. };
  2740. pp.checkExport = function (node) {
  2741. if (this.decorators.length) {
  2742. var isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression");
  2743. if (!node.declaration || !isClass) {
  2744. this.raise(node.start, "You can only use decorators on an export when exporting a class");
  2745. }
  2746. this.takeDecorators(node.declaration);
  2747. }
  2748. };
  2749. // Parses a comma-separated list of module exports.
  2750. pp.parseExportSpecifiers = function () {
  2751. var nodes = [],
  2752. first = true;
  2753. // export { x, y as z } [from '...']
  2754. this.expect(_tokentype.types.braceL);
  2755. while (!this.eat(_tokentype.types.braceR)) {
  2756. if (!first) {
  2757. this.expect(_tokentype.types.comma);
  2758. if (this.afterTrailingComma(_tokentype.types.braceR)) break;
  2759. } else first = false;
  2760. var node = this.startNode();
  2761. node.local = this.parseIdent(this.type === _tokentype.types._default);
  2762. node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
  2763. nodes.push(this.finishNode(node, "ExportSpecifier"));
  2764. }
  2765. return nodes;
  2766. };
  2767. // Parses import declaration.
  2768. pp.parseImport = function (node) {
  2769. this.next();
  2770. // import '...'
  2771. if (this.type === _tokentype.types.string) {
  2772. node.specifiers = empty;
  2773. node.source = this.parseExprAtom();
  2774. } else {
  2775. node.specifiers = [];
  2776. this.parseImportSpecifiers(node);
  2777. this.expectContextual("from");
  2778. node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
  2779. }
  2780. this.semicolon();
  2781. return this.finishNode(node, "ImportDeclaration");
  2782. };
  2783. // Parses a comma-separated list of module imports.
  2784. pp.parseImportSpecifiers = function (node) {
  2785. var first = true;
  2786. if (this.type === _tokentype.types.name) {
  2787. // import defaultObj, { x, y as z } from '...'
  2788. var start = this.markPosition();
  2789. node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdent(), start));
  2790. if (!this.eat(_tokentype.types.comma)) return;
  2791. }
  2792. if (this.type === _tokentype.types.star) {
  2793. var specifier = this.startNode();
  2794. this.next();
  2795. this.expectContextual("as");
  2796. specifier.local = this.parseIdent();
  2797. this.checkLVal(specifier.local, true);
  2798. node.specifiers.push(this.finishNode(specifier, "ImportNamespaceSpecifier"));
  2799. return;
  2800. }
  2801. this.expect(_tokentype.types.braceL);
  2802. while (!this.eat(_tokentype.types.braceR)) {
  2803. if (!first) {
  2804. this.expect(_tokentype.types.comma);
  2805. if (this.afterTrailingComma(_tokentype.types.braceR)) break;
  2806. } else first = false;
  2807. var specifier = this.startNode();
  2808. specifier.imported = this.parseIdent(true);
  2809. specifier.local = this.eatContextual("as") ? this.parseIdent() : specifier.imported;
  2810. this.checkLVal(specifier.local, true);
  2811. node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
  2812. }
  2813. };
  2814. pp.parseImportSpecifierDefault = function (id, start) {
  2815. var node = this.startNodeAt(start);
  2816. node.local = id;
  2817. this.checkLVal(node.local, true);
  2818. return this.finishNode(node, "ImportDefaultSpecifier");
  2819. };
  2820. },{"./state":12,"./tokentype":16,"./whitespace":18}],14:[function(require,module,exports){
  2821. // The algorithm used to determine whether a regexp can appear at a
  2822. // given point in the program is loosely based on sweet.js' approach.
  2823. // See https://github.com/mozilla/sweet.js/wiki/design
  2824. "use strict";
  2825. exports.__esModule = true;
  2826. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2827. var _state = require("./state");
  2828. var _tokentype = require("./tokentype");
  2829. var _whitespace = require("./whitespace");
  2830. var TokContext = function TokContext(token, isExpr, preserveSpace, override) {
  2831. _classCallCheck(this, TokContext);
  2832. this.token = token;
  2833. this.isExpr = isExpr;
  2834. this.preserveSpace = preserveSpace;
  2835. this.override = override;
  2836. };
  2837. exports.TokContext = TokContext;
  2838. var types = {
  2839. b_stat: new TokContext("{", false),
  2840. b_expr: new TokContext("{", true),
  2841. b_tmpl: new TokContext("${", true),
  2842. p_stat: new TokContext("(", false),
  2843. p_expr: new TokContext("(", true),
  2844. q_tmpl: new TokContext("`", true, true, function (p) {
  2845. return p.readTmplToken();
  2846. }),
  2847. f_expr: new TokContext("function", true)
  2848. };
  2849. exports.types = types;
  2850. var pp = _state.Parser.prototype;
  2851. pp.initialContext = function () {
  2852. return [types.b_stat];
  2853. };
  2854. pp.braceIsBlock = function (prevType) {
  2855. var parent = undefined;
  2856. if (prevType === _tokentype.types.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;
  2857. if (prevType === _tokentype.types._return) return _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  2858. if (prevType === _tokentype.types._else || prevType === _tokentype.types.semi || prevType === _tokentype.types.eof) return true;
  2859. if (prevType == _tokentype.types.braceL) return this.curContext() === types.b_stat;
  2860. return !this.exprAllowed;
  2861. };
  2862. pp.updateContext = function (prevType) {
  2863. var update = undefined,
  2864. type = this.type;
  2865. if (type.keyword && prevType == _tokentype.types.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;
  2866. };
  2867. // Token-specific context update code
  2868. _tokentype.types.parenR.updateContext = _tokentype.types.braceR.updateContext = function () {
  2869. if (this.context.length == 1) {
  2870. this.exprAllowed = true;
  2871. return;
  2872. }
  2873. var out = this.context.pop();
  2874. if (out === types.b_stat && this.curContext() === types.f_expr) {
  2875. this.context.pop();
  2876. this.exprAllowed = false;
  2877. } else if (out === types.b_tmpl) {
  2878. this.exprAllowed = true;
  2879. } else {
  2880. this.exprAllowed = !out.isExpr;
  2881. }
  2882. };
  2883. _tokentype.types.braceL.updateContext = function (prevType) {
  2884. this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
  2885. this.exprAllowed = true;
  2886. };
  2887. _tokentype.types.dollarBraceL.updateContext = function () {
  2888. this.context.push(types.b_tmpl);
  2889. this.exprAllowed = true;
  2890. };
  2891. _tokentype.types.parenL.updateContext = function (prevType) {
  2892. var statementParens = prevType === _tokentype.types._if || prevType === _tokentype.types._for || prevType === _tokentype.types._with || prevType === _tokentype.types._while;
  2893. this.context.push(statementParens ? types.p_stat : types.p_expr);
  2894. this.exprAllowed = true;
  2895. };
  2896. _tokentype.types.incDec.updateContext = function () {};
  2897. _tokentype.types._function.updateContext = function () {
  2898. if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);
  2899. this.exprAllowed = false;
  2900. };
  2901. _tokentype.types.backQuote.updateContext = function () {
  2902. if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);
  2903. this.exprAllowed = false;
  2904. };
  2905. // tokExprAllowed stays unchanged
  2906. },{"./state":12,"./tokentype":16,"./whitespace":18}],15:[function(require,module,exports){
  2907. "use strict";
  2908. exports.__esModule = true;
  2909. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2910. var _identifier = require("./identifier");
  2911. var _tokentype = require("./tokentype");
  2912. var _state = require("./state");
  2913. var _location = require("./location");
  2914. var _whitespace = require("./whitespace");
  2915. // Object type used to represent tokens. Note that normally, tokens
  2916. // simply exist as properties on the parser object. This is only
  2917. // used for the onToken callback and the external tokenizer.
  2918. var Token = function Token(p) {
  2919. _classCallCheck(this, Token);
  2920. this.type = p.type;
  2921. this.value = p.value;
  2922. this.start = p.start;
  2923. this.end = p.end;
  2924. if (p.options.locations) this.loc = new _location.SourceLocation(p, p.startLoc, p.endLoc);
  2925. if (p.options.ranges) this.range = [p.start, p.end];
  2926. };
  2927. exports.Token = Token;
  2928. // ## Tokenizer
  2929. var pp = _state.Parser.prototype;
  2930. // Move to the next token
  2931. pp.next = function () {
  2932. if (this.options.onToken && !this.isLookahead) this.options.onToken(new Token(this));
  2933. this.lastTokEnd = this.end;
  2934. this.lastTokStart = this.start;
  2935. this.lastTokEndLoc = this.endLoc;
  2936. this.lastTokStartLoc = this.startLoc;
  2937. this.nextToken();
  2938. };
  2939. pp.getToken = function () {
  2940. this.next();
  2941. return new Token(this);
  2942. };
  2943. // If we're in an ES6 environment, make parsers iterable
  2944. if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {
  2945. var self = this;
  2946. return { next: function next() {
  2947. var token = self.getToken();
  2948. return {
  2949. done: token.type === _tokentype.types.eof,
  2950. value: token
  2951. };
  2952. } };
  2953. };
  2954. // Toggle strict mode. Re-reads the next number or string to please
  2955. // pedantic tests (`"use strict"; 010;` should fail).
  2956. pp.setStrict = function (strict) {
  2957. this.strict = strict;
  2958. if (this.type !== _tokentype.types.num && this.type !== _tokentype.types.string) return;
  2959. this.pos = this.start;
  2960. if (this.options.locations) {
  2961. while (this.pos < this.lineStart) {
  2962. this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
  2963. --this.curLine;
  2964. }
  2965. }
  2966. this.nextToken();
  2967. };
  2968. pp.curContext = function () {
  2969. return this.context[this.context.length - 1];
  2970. };
  2971. // Read a single token, updating the parser object's token-related
  2972. // properties.
  2973. pp.nextToken = function () {
  2974. var curContext = this.curContext();
  2975. if (!curContext || !curContext.preserveSpace) this.skipSpace();
  2976. this.start = this.pos;
  2977. if (this.options.locations) this.startLoc = this.curPosition();
  2978. if (this.pos >= this.input.length) return this.finishToken(_tokentype.types.eof);
  2979. if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());
  2980. };
  2981. pp.readToken = function (code) {
  2982. // Identifier or keyword. '\uXXXX' sequences are allowed in
  2983. // identifiers, so '\' also dispatches to that.
  2984. if ((0, _identifier.isIdentifierStart)(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();
  2985. return this.getTokenFromCode(code);
  2986. };
  2987. pp.fullCharCodeAtPos = function () {
  2988. var code = this.input.charCodeAt(this.pos);
  2989. if (code <= 55295 || code >= 57344) return code;
  2990. var next = this.input.charCodeAt(this.pos + 1);
  2991. return (code << 10) + next - 56613888;
  2992. };
  2993. pp.skipBlockComment = function () {
  2994. var startLoc = this.options.onComment && this.options.locations && this.curPosition();
  2995. var start = this.pos,
  2996. end = this.input.indexOf("*/", this.pos += 2);
  2997. if (end === -1) this.raise(this.pos - 2, "Unterminated comment");
  2998. this.pos = end + 2;
  2999. if (this.options.locations) {
  3000. _whitespace.lineBreakG.lastIndex = start;
  3001. var match = undefined;
  3002. while ((match = _whitespace.lineBreakG.exec(this.input)) && match.index < this.pos) {
  3003. ++this.curLine;
  3004. this.lineStart = match.index + match[0].length;
  3005. }
  3006. }
  3007. if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());
  3008. };
  3009. pp.skipLineComment = function (startSkip) {
  3010. var start = this.pos;
  3011. var startLoc = this.options.onComment && this.options.locations && this.curPosition();
  3012. var ch = this.input.charCodeAt(this.pos += startSkip);
  3013. while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
  3014. ++this.pos;
  3015. ch = this.input.charCodeAt(this.pos);
  3016. }
  3017. if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());
  3018. };
  3019. // Called at the start of the parse and after every token. Skips
  3020. // whitespace and comments, and.
  3021. pp.skipSpace = function () {
  3022. while (this.pos < this.input.length) {
  3023. var ch = this.input.charCodeAt(this.pos);
  3024. if (ch === 32) {
  3025. // ' '
  3026. ++this.pos;
  3027. } else if (ch === 13) {
  3028. ++this.pos;
  3029. var _next = this.input.charCodeAt(this.pos);
  3030. if (_next === 10) {
  3031. ++this.pos;
  3032. }
  3033. if (this.options.locations) {
  3034. ++this.curLine;
  3035. this.lineStart = this.pos;
  3036. }
  3037. } else if (ch === 10 || ch === 8232 || ch === 8233) {
  3038. ++this.pos;
  3039. if (this.options.locations) {
  3040. ++this.curLine;
  3041. this.lineStart = this.pos;
  3042. }
  3043. } else if (ch > 8 && ch < 14) {
  3044. ++this.pos;
  3045. } else if (ch === 47) {
  3046. // '/'
  3047. var _next2 = this.input.charCodeAt(this.pos + 1);
  3048. if (_next2 === 42) {
  3049. // '*'
  3050. this.skipBlockComment();
  3051. } else if (_next2 === 47) {
  3052. // '/'
  3053. this.skipLineComment(2);
  3054. } else break;
  3055. } else if (ch === 160) {
  3056. // '\xa0'
  3057. ++this.pos;
  3058. } else if (ch >= 5760 && _whitespace.nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  3059. ++this.pos;
  3060. } else {
  3061. break;
  3062. }
  3063. }
  3064. };
  3065. // Called at the end of every token. Sets `end`, `val`, and
  3066. // maintains `context` and `exprAllowed`, and skips the space after
  3067. // the token, so that the next one's `start` will point at the
  3068. // right position.
  3069. pp.finishToken = function (type, val) {
  3070. this.end = this.pos;
  3071. if (this.options.locations) this.endLoc = this.curPosition();
  3072. var prevType = this.type;
  3073. this.type = type;
  3074. this.value = val;
  3075. this.updateContext(prevType);
  3076. };
  3077. // ### Token reading
  3078. // This is the function that is called to fetch the next token. It
  3079. // is somewhat obscure, because it works in character codes rather
  3080. // than characters, and because operator parsing has been inlined
  3081. // into it.
  3082. //
  3083. // All in the name of speed.
  3084. //
  3085. pp.readToken_dot = function () {
  3086. var next = this.input.charCodeAt(this.pos + 1);
  3087. if (next >= 48 && next <= 57) return this.readNumber(true);
  3088. var next2 = this.input.charCodeAt(this.pos + 2);
  3089. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
  3090. // 46 = dot '.'
  3091. this.pos += 3;
  3092. return this.finishToken(_tokentype.types.ellipsis);
  3093. } else {
  3094. ++this.pos;
  3095. return this.finishToken(_tokentype.types.dot);
  3096. }
  3097. };
  3098. pp.readToken_slash = function () {
  3099. // '/'
  3100. var next = this.input.charCodeAt(this.pos + 1);
  3101. if (this.exprAllowed) {
  3102. ++this.pos;return this.readRegexp();
  3103. }
  3104. if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
  3105. return this.finishOp(_tokentype.types.slash, 1);
  3106. };
  3107. pp.readToken_mult_modulo = function (code) {
  3108. // '%*'
  3109. var type = code === 42 ? _tokentype.types.star : _tokentype.types.modulo;
  3110. var width = 1;
  3111. var next = this.input.charCodeAt(this.pos + 1);
  3112. if (next === 42) {
  3113. // '*'
  3114. width++;
  3115. next = this.input.charCodeAt(this.pos + 2);
  3116. type = _tokentype.types.exponent;
  3117. }
  3118. if (next === 61) {
  3119. width++;
  3120. type = _tokentype.types.assign;
  3121. }
  3122. return this.finishOp(type, width);
  3123. };
  3124. pp.readToken_pipe_amp = function (code) {
  3125. // '|&'
  3126. var next = this.input.charCodeAt(this.pos + 1);
  3127. if (next === code) return this.finishOp(code === 124 ? _tokentype.types.logicalOR : _tokentype.types.logicalAND, 2);
  3128. if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
  3129. return this.finishOp(code === 124 ? _tokentype.types.bitwiseOR : _tokentype.types.bitwiseAND, 1);
  3130. };
  3131. pp.readToken_caret = function () {
  3132. // '^'
  3133. var next = this.input.charCodeAt(this.pos + 1);
  3134. if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
  3135. return this.finishOp(_tokentype.types.bitwiseXOR, 1);
  3136. };
  3137. pp.readToken_plus_min = function (code) {
  3138. // '+-'
  3139. var next = this.input.charCodeAt(this.pos + 1);
  3140. if (next === code) {
  3141. if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
  3142. // A `-->` line comment
  3143. this.skipLineComment(3);
  3144. this.skipSpace();
  3145. return this.nextToken();
  3146. }
  3147. return this.finishOp(_tokentype.types.incDec, 2);
  3148. }
  3149. if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
  3150. return this.finishOp(_tokentype.types.plusMin, 1);
  3151. };
  3152. pp.readToken_lt_gt = function (code) {
  3153. // '<>'
  3154. var next = this.input.charCodeAt(this.pos + 1);
  3155. var size = 1;
  3156. if (next === code) {
  3157. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  3158. if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(_tokentype.types.assign, size + 1);
  3159. return this.finishOp(_tokentype.types.bitShift, size);
  3160. }
  3161. if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {
  3162. if (this.inModule) this.unexpected();
  3163. // `<!--`, an XML-style comment that should be interpreted as a line comment
  3164. this.skipLineComment(4);
  3165. this.skipSpace();
  3166. return this.nextToken();
  3167. }
  3168. if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;
  3169. return this.finishOp(_tokentype.types.relational, size);
  3170. };
  3171. pp.readToken_eq_excl = function (code) {
  3172. // '=!'
  3173. var next = this.input.charCodeAt(this.pos + 1);
  3174. if (next === 61) return this.finishOp(_tokentype.types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
  3175. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
  3176. // '=>'
  3177. this.pos += 2;
  3178. return this.finishToken(_tokentype.types.arrow);
  3179. }
  3180. return this.finishOp(code === 61 ? _tokentype.types.eq : _tokentype.types.prefix, 1);
  3181. };
  3182. pp.getTokenFromCode = function (code) {
  3183. switch (code) {
  3184. // The interpretation of a dot depends on whether it is followed
  3185. // by a digit or another two dots.
  3186. case 46:
  3187. // '.'
  3188. return this.readToken_dot();
  3189. // Punctuation tokens.
  3190. case 40:
  3191. ++this.pos;return this.finishToken(_tokentype.types.parenL);
  3192. case 41:
  3193. ++this.pos;return this.finishToken(_tokentype.types.parenR);
  3194. case 59:
  3195. ++this.pos;return this.finishToken(_tokentype.types.semi);
  3196. case 44:
  3197. ++this.pos;return this.finishToken(_tokentype.types.comma);
  3198. case 91:
  3199. ++this.pos;return this.finishToken(_tokentype.types.bracketL);
  3200. case 93:
  3201. ++this.pos;return this.finishToken(_tokentype.types.bracketR);
  3202. case 123:
  3203. ++this.pos;return this.finishToken(_tokentype.types.braceL);
  3204. case 125:
  3205. ++this.pos;return this.finishToken(_tokentype.types.braceR);
  3206. case 58:
  3207. if (this.options.features["es7.functionBind"] && this.input.charCodeAt(this.pos + 1) === 58) return this.finishOp(_tokentype.types.doubleColon, 2);
  3208. ++this.pos;
  3209. return this.finishToken(_tokentype.types.colon);
  3210. case 63:
  3211. ++this.pos;return this.finishToken(_tokentype.types.question);
  3212. case 64:
  3213. ++this.pos;return this.finishToken(_tokentype.types.at);
  3214. case 96:
  3215. // '`'
  3216. if (this.options.ecmaVersion < 6) break;
  3217. ++this.pos;
  3218. return this.finishToken(_tokentype.types.backQuote);
  3219. case 48:
  3220. // '0'
  3221. var next = this.input.charCodeAt(this.pos + 1);
  3222. if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number
  3223. if (this.options.ecmaVersion >= 6) {
  3224. if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number
  3225. if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number
  3226. }
  3227. // Anything else beginning with a digit is an integer, octal
  3228. // number, or float.
  3229. case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:
  3230. // 1-9
  3231. return this.readNumber(false);
  3232. // Quotes produce strings.
  3233. case 34:case 39:
  3234. // '"', "'"
  3235. return this.readString(code);
  3236. // Operators are parsed inline in tiny state machines. '=' (61) is
  3237. // often referred to. `finishOp` simply skips the amount of
  3238. // characters it is given as second argument, and returns a token
  3239. // of the type given by its first argument.
  3240. case 47:
  3241. // '/'
  3242. return this.readToken_slash();
  3243. case 37:case 42:
  3244. // '%*'
  3245. return this.readToken_mult_modulo(code);
  3246. case 124:case 38:
  3247. // '|&'
  3248. return this.readToken_pipe_amp(code);
  3249. case 94:
  3250. // '^'
  3251. return this.readToken_caret();
  3252. case 43:case 45:
  3253. // '+-'
  3254. return this.readToken_plus_min(code);
  3255. case 60:case 62:
  3256. // '<>'
  3257. return this.readToken_lt_gt(code);
  3258. case 61:case 33:
  3259. // '=!'
  3260. return this.readToken_eq_excl(code);
  3261. case 126:
  3262. // '~'
  3263. return this.finishOp(_tokentype.types.prefix, 1);
  3264. }
  3265. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  3266. };
  3267. pp.finishOp = function (type, size) {
  3268. var str = this.input.slice(this.pos, this.pos + size);
  3269. this.pos += size;
  3270. return this.finishToken(type, str);
  3271. };
  3272. var regexpUnicodeSupport = false;
  3273. try {
  3274. new RegExp("￿", "u");regexpUnicodeSupport = true;
  3275. } catch (e) {}
  3276. // Parse a regular expression. Some context-awareness is necessary,
  3277. // since a '/' inside a '[]' set does not end the expression.
  3278. pp.readRegexp = function () {
  3279. var escaped = undefined,
  3280. inClass = undefined,
  3281. start = this.pos;
  3282. for (;;) {
  3283. if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");
  3284. var ch = this.input.charAt(this.pos);
  3285. if (_whitespace.lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");
  3286. if (!escaped) {
  3287. if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;
  3288. escaped = ch === "\\";
  3289. } else escaped = false;
  3290. ++this.pos;
  3291. }
  3292. var content = this.input.slice(start, this.pos);
  3293. ++this.pos;
  3294. // Need to use `readWord1` because '\uXXXX' sequences are allowed
  3295. // here (don't ask).
  3296. var mods = this.readWord1();
  3297. var tmp = content;
  3298. if (mods) {
  3299. var validFlags = /^[gmsiy]*$/;
  3300. if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
  3301. if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");
  3302. if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {
  3303. // Replace each astral symbol and every Unicode escape sequence that
  3304. // possibly represents an astral symbol or a paired surrogate with a
  3305. // single ASCII symbol to avoid throwing on regular expressions that
  3306. // are only valid in combination with the `/u` flag.
  3307. // Note: replacing with the ASCII symbol `x` might cause false
  3308. // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
  3309. // perfectly valid pattern that is equivalent to `[a-b]`, but it would
  3310. // be replaced by `[x-b]` which throws an error.
  3311. tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
  3312. }
  3313. }
  3314. // Detect invalid regular expressions.
  3315. try {
  3316. new RegExp(tmp);
  3317. } catch (e) {
  3318. if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);
  3319. this.raise(e);
  3320. }
  3321. // Get a regular expression object for this pattern-flag pair, or `null` in
  3322. // case the current environment doesn't support the flags it uses.
  3323. var value = undefined;
  3324. try {
  3325. value = new RegExp(content, mods);
  3326. } catch (err) {
  3327. value = null;
  3328. }
  3329. return this.finishToken(_tokentype.types.regexp, { pattern: content, flags: mods, value: value });
  3330. };
  3331. // Read an integer in the given radix. Return null if zero digits
  3332. // were read, the integer value otherwise. When `len` is given, this
  3333. // will return `null` unless the integer has exactly `len` digits.
  3334. pp.readInt = function (radix, len) {
  3335. var start = this.pos,
  3336. total = 0;
  3337. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  3338. var code = this.input.charCodeAt(this.pos),
  3339. val = undefined;
  3340. if (code >= 97) val = code - 97 + 10; // a
  3341. else if (code >= 65) val = code - 65 + 10; // A
  3342. else if (code >= 48 && code <= 57) val = code - 48; // 0-9
  3343. else val = Infinity;
  3344. if (val >= radix) break;
  3345. ++this.pos;
  3346. total = total * radix + val;
  3347. }
  3348. if (this.pos === start || len != null && this.pos - start !== len) return null;
  3349. return total;
  3350. };
  3351. pp.readRadixNumber = function (radix) {
  3352. this.pos += 2; // 0x
  3353. var val = this.readInt(radix);
  3354. if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);
  3355. if ((0, _identifier.isIdentifierStart)(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
  3356. return this.finishToken(_tokentype.types.num, val);
  3357. };
  3358. // Read an integer, octal integer, or floating-point number.
  3359. pp.readNumber = function (startsWithDot) {
  3360. var start = this.pos,
  3361. isFloat = false,
  3362. octal = this.input.charCodeAt(this.pos) === 48;
  3363. if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
  3364. if (this.input.charCodeAt(this.pos) === 46) {
  3365. ++this.pos;
  3366. this.readInt(10);
  3367. isFloat = true;
  3368. }
  3369. var next = this.input.charCodeAt(this.pos);
  3370. if (next === 69 || next === 101) {
  3371. // 'eE'
  3372. next = this.input.charCodeAt(++this.pos);
  3373. if (next === 43 || next === 45) ++this.pos; // '+-'
  3374. if (this.readInt(10) === null) this.raise(start, "Invalid number");
  3375. isFloat = true;
  3376. }
  3377. if ((0, _identifier.isIdentifierStart)(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
  3378. var str = this.input.slice(start, this.pos),
  3379. val = undefined;
  3380. if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");else val = parseInt(str, 8);
  3381. return this.finishToken(_tokentype.types.num, val);
  3382. };
  3383. // Read a string value, interpreting backslash-escapes.
  3384. pp.readCodePoint = function () {
  3385. var ch = this.input.charCodeAt(this.pos),
  3386. code = undefined;
  3387. if (ch === 123) {
  3388. if (this.options.ecmaVersion < 6) this.unexpected();
  3389. ++this.pos;
  3390. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  3391. ++this.pos;
  3392. if (code > 1114111) this.unexpected();
  3393. } else {
  3394. code = this.readHexChar(4);
  3395. }
  3396. return code;
  3397. };
  3398. function codePointToString(code) {
  3399. // UTF-16 Decoding
  3400. if (code <= 65535) return String.fromCharCode(code);
  3401. return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);
  3402. }
  3403. pp.readString = function (quote) {
  3404. var out = "",
  3405. chunkStart = ++this.pos;
  3406. for (;;) {
  3407. if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");
  3408. var ch = this.input.charCodeAt(this.pos);
  3409. if (ch === quote) break;
  3410. if (ch === 92) {
  3411. // '\'
  3412. out += this.input.slice(chunkStart, this.pos);
  3413. out += this.readEscapedChar();
  3414. chunkStart = this.pos;
  3415. } else {
  3416. if ((0, _whitespace.isNewLine)(ch)) this.raise(this.start, "Unterminated string constant");
  3417. ++this.pos;
  3418. }
  3419. }
  3420. out += this.input.slice(chunkStart, this.pos++);
  3421. return this.finishToken(_tokentype.types.string, out);
  3422. };
  3423. // Reads template string tokens.
  3424. pp.readTmplToken = function () {
  3425. var out = "",
  3426. chunkStart = this.pos;
  3427. for (;;) {
  3428. if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");
  3429. var ch = this.input.charCodeAt(this.pos);
  3430. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
  3431. // '`', '${'
  3432. if (this.pos === this.start && this.type === _tokentype.types.template) {
  3433. if (ch === 36) {
  3434. this.pos += 2;
  3435. return this.finishToken(_tokentype.types.dollarBraceL);
  3436. } else {
  3437. ++this.pos;
  3438. return this.finishToken(_tokentype.types.backQuote);
  3439. }
  3440. }
  3441. out += this.input.slice(chunkStart, this.pos);
  3442. return this.finishToken(_tokentype.types.template, out);
  3443. }
  3444. if (ch === 92) {
  3445. // '\'
  3446. out += this.input.slice(chunkStart, this.pos);
  3447. out += this.readEscapedChar();
  3448. chunkStart = this.pos;
  3449. } else if ((0, _whitespace.isNewLine)(ch)) {
  3450. out += this.input.slice(chunkStart, this.pos);
  3451. ++this.pos;
  3452. if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
  3453. ++this.pos;
  3454. out += "\n";
  3455. } else {
  3456. out += String.fromCharCode(ch);
  3457. }
  3458. if (this.options.locations) {
  3459. ++this.curLine;
  3460. this.lineStart = this.pos;
  3461. }
  3462. chunkStart = this.pos;
  3463. } else {
  3464. ++this.pos;
  3465. }
  3466. }
  3467. };
  3468. // Used to read escaped characters
  3469. pp.readEscapedChar = function () {
  3470. var ch = this.input.charCodeAt(++this.pos);
  3471. var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));
  3472. if (octal) octal = octal[0];
  3473. while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
  3474. if (octal === "0") octal = null;
  3475. ++this.pos;
  3476. if (octal) {
  3477. if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");
  3478. this.pos += octal.length - 1;
  3479. return String.fromCharCode(parseInt(octal, 8));
  3480. } else {
  3481. switch (ch) {
  3482. case 110:
  3483. return "\n"; // 'n' -> '\n'
  3484. case 114:
  3485. return "\r"; // 'r' -> '\r'
  3486. case 120:
  3487. return String.fromCharCode(this.readHexChar(2)); // 'x'
  3488. case 117:
  3489. return codePointToString(this.readCodePoint()); // 'u'
  3490. case 116:
  3491. return "\t"; // 't' -> '\t'
  3492. case 98:
  3493. return "\b"; // 'b' -> '\b'
  3494. case 118:
  3495. return "\u000b"; // 'v' -> '\u000b'
  3496. case 102:
  3497. return "\f"; // 'f' -> '\f'
  3498. case 48:
  3499. return "\u0000"; // 0 -> '\0'
  3500. case 13:
  3501. if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'
  3502. case 10:
  3503. // ' \n'
  3504. if (this.options.locations) {
  3505. this.lineStart = this.pos;++this.curLine;
  3506. }
  3507. return "";
  3508. default:
  3509. return String.fromCharCode(ch);
  3510. }
  3511. }
  3512. };
  3513. // Used to read character escape sequences ('\x', '\u', '\U').
  3514. pp.readHexChar = function (len) {
  3515. var n = this.readInt(16, len);
  3516. if (n === null) this.raise(this.start, "Bad character escape sequence");
  3517. return n;
  3518. };
  3519. // Used to signal to callers of `readWord1` whether the word
  3520. // contained any escape sequences. This is needed because words with
  3521. // escape sequences must not be interpreted as keywords.
  3522. var containsEsc;
  3523. // Read an identifier, and return it as a string. Sets `containsEsc`
  3524. // to whether the word contained a '\u' escape.
  3525. //
  3526. // Incrementally adds only escaped chars, adding other chunks as-is
  3527. // as a micro-optimization.
  3528. pp.readWord1 = function () {
  3529. containsEsc = false;
  3530. var word = "",
  3531. first = true,
  3532. chunkStart = this.pos;
  3533. var astral = this.options.ecmaVersion >= 6;
  3534. while (this.pos < this.input.length) {
  3535. var ch = this.fullCharCodeAtPos();
  3536. if ((0, _identifier.isIdentifierChar)(ch, astral)) {
  3537. this.pos += ch <= 65535 ? 1 : 2;
  3538. } else if (ch === 92) {
  3539. // "\"
  3540. containsEsc = true;
  3541. word += this.input.slice(chunkStart, this.pos);
  3542. var escStart = this.pos;
  3543. if (this.input.charCodeAt(++this.pos) != 117) // "u"
  3544. this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");
  3545. ++this.pos;
  3546. var esc = this.readCodePoint();
  3547. if (!(first ? _identifier.isIdentifierStart : _identifier.isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");
  3548. word += codePointToString(esc);
  3549. chunkStart = this.pos;
  3550. } else {
  3551. break;
  3552. }
  3553. first = false;
  3554. }
  3555. return word + this.input.slice(chunkStart, this.pos);
  3556. };
  3557. // Read an identifier or keyword token. Will check for reserved
  3558. // words when necessary.
  3559. pp.readWord = function () {
  3560. var word = this.readWord1();
  3561. var type = _tokentype.types.name;
  3562. if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = _tokentype.keywords[word];
  3563. return this.finishToken(type, word);
  3564. };
  3565. },{"./identifier":4,"./location":6,"./state":12,"./tokentype":16,"./whitespace":18}],16:[function(require,module,exports){
  3566. "use strict";
  3567. exports.__esModule = true;
  3568. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3569. // ## Token types
  3570. // The assignment of fine-grained, information-carrying type objects
  3571. // allows the tokenizer to store the information it has about a
  3572. // token in a way that is very cheap for the parser to look up.
  3573. // All token type variables start with an underscore, to make them
  3574. // easy to recognize.
  3575. // The `beforeExpr` property is used to disambiguate between regular
  3576. // expressions and divisions. It is set on all token types that can
  3577. // be followed by an expression (thus, a slash after them would be a
  3578. // regular expression).
  3579. //
  3580. // `isLoop` marks a keyword as starting a loop, which is important
  3581. // to know when parsing a label, in order to allow or disallow
  3582. // continue jumps to that label.
  3583. var TokenType = function TokenType(label) {
  3584. var conf = arguments[1] === undefined ? {} : arguments[1];
  3585. _classCallCheck(this, TokenType);
  3586. this.label = label;
  3587. this.keyword = conf.keyword;
  3588. this.beforeExpr = !!conf.beforeExpr;
  3589. this.startsExpr = !!conf.startsExpr;
  3590. this.rightAssociative = !!conf.rightAssociative;
  3591. this.isLoop = !!conf.isLoop;
  3592. this.isAssign = !!conf.isAssign;
  3593. this.prefix = !!conf.prefix;
  3594. this.postfix = !!conf.postfix;
  3595. this.binop = conf.binop || null;
  3596. this.updateContext = null;
  3597. };
  3598. exports.TokenType = TokenType;
  3599. function binop(name, prec) {
  3600. return new TokenType(name, { beforeExpr: true, binop: prec });
  3601. }
  3602. var beforeExpr = { beforeExpr: true },
  3603. startsExpr = { startsExpr: true };
  3604. var types = {
  3605. num: new TokenType("num", startsExpr),
  3606. regexp: new TokenType("regexp", startsExpr),
  3607. string: new TokenType("string", startsExpr),
  3608. name: new TokenType("name", startsExpr),
  3609. eof: new TokenType("eof"),
  3610. // Punctuation token types.
  3611. bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
  3612. bracketR: new TokenType("]"),
  3613. braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
  3614. braceR: new TokenType("}"),
  3615. parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
  3616. parenR: new TokenType(")"),
  3617. comma: new TokenType(",", beforeExpr),
  3618. semi: new TokenType(";", beforeExpr),
  3619. colon: new TokenType(":", beforeExpr),
  3620. doubleColon: new TokenType("::", beforeExpr),
  3621. dot: new TokenType("."),
  3622. question: new TokenType("?", beforeExpr),
  3623. arrow: new TokenType("=>", beforeExpr),
  3624. template: new TokenType("template"),
  3625. ellipsis: new TokenType("...", beforeExpr),
  3626. backQuote: new TokenType("`", startsExpr),
  3627. dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
  3628. at: new TokenType("@"),
  3629. // Operators. These carry several kinds of properties to help the
  3630. // parser use them properly (the presence of these properties is
  3631. // what categorizes them as operators).
  3632. //
  3633. // `binop`, when present, specifies that this operator is a binary
  3634. // operator, and will refer to its precedence.
  3635. //
  3636. // `prefix` and `postfix` mark the operator as a prefix or postfix
  3637. // unary operator.
  3638. //
  3639. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  3640. // binary operators with a very low precedence, that should result
  3641. // in AssignmentExpression nodes.
  3642. eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
  3643. assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
  3644. incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
  3645. prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),
  3646. logicalOR: binop("||", 1),
  3647. logicalAND: binop("&&", 2),
  3648. bitwiseOR: binop("|", 3),
  3649. bitwiseXOR: binop("^", 4),
  3650. bitwiseAND: binop("&", 5),
  3651. equality: binop("==/!=", 6),
  3652. relational: binop("</>", 7),
  3653. bitShift: binop("<</>>", 8),
  3654. plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
  3655. modulo: binop("%", 10),
  3656. star: binop("*", 10),
  3657. slash: binop("/", 10),
  3658. exponent: new TokenType("**", { beforeExpr: true, binop: 11, rightAssociative: true })
  3659. };
  3660. exports.types = types;
  3661. // Map keyword names to token types.
  3662. var keywords = {};
  3663. exports.keywords = keywords;
  3664. // Succinct definitions of keyword token types
  3665. function kw(name) {
  3666. var options = arguments[1] === undefined ? {} : arguments[1];
  3667. options.keyword = name;
  3668. keywords[name] = types["_" + name] = new TokenType(name, options);
  3669. }
  3670. kw("break");
  3671. kw("case", beforeExpr);
  3672. kw("catch");
  3673. kw("continue");
  3674. kw("debugger");
  3675. kw("default");
  3676. kw("do", { isLoop: true });
  3677. kw("else", beforeExpr);
  3678. kw("finally");
  3679. kw("for", { isLoop: true });
  3680. kw("function", startsExpr);
  3681. kw("if");
  3682. kw("return", beforeExpr);
  3683. kw("switch");
  3684. kw("throw", beforeExpr);
  3685. kw("try");
  3686. kw("var");
  3687. kw("let");
  3688. kw("const");
  3689. kw("while", { isLoop: true });
  3690. kw("with");
  3691. kw("new", { beforeExpr: true, startsExpr: true });
  3692. kw("this", startsExpr);
  3693. kw("super", startsExpr);
  3694. kw("class");
  3695. kw("extends", beforeExpr);
  3696. kw("export");
  3697. kw("import");
  3698. kw("yield", { beforeExpr: true, startsExpr: true });
  3699. kw("null", startsExpr);
  3700. kw("true", startsExpr);
  3701. kw("false", startsExpr);
  3702. kw("in", { beforeExpr: true, binop: 7 });
  3703. kw("instanceof", { beforeExpr: true, binop: 7 });
  3704. kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });
  3705. kw("void", { beforeExpr: true, prefix: true, startsExpr: true });
  3706. kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });
  3707. },{}],17:[function(require,module,exports){
  3708. "use strict";
  3709. exports.__esModule = true;
  3710. exports.isArray = isArray;
  3711. // Checks if an object has a property.
  3712. exports.has = has;
  3713. function isArray(obj) {
  3714. return Object.prototype.toString.call(obj) === "[object Array]";
  3715. }
  3716. function has(obj, propName) {
  3717. return Object.prototype.hasOwnProperty.call(obj, propName);
  3718. }
  3719. },{}],18:[function(require,module,exports){
  3720. "use strict";
  3721. exports.__esModule = true;
  3722. exports.isNewLine = isNewLine;
  3723. // Matches a whole line break (where CRLF is considered a single
  3724. // line break). Used to count lines.
  3725. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  3726. exports.lineBreak = lineBreak;
  3727. var lineBreakG = new RegExp(lineBreak.source, "g");
  3728. exports.lineBreakG = lineBreakG;
  3729. function isNewLine(code) {
  3730. return code === 10 || code === 13 || code === 8232 || code == 8233;
  3731. }
  3732. var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  3733. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  3734. },{}],19:[function(require,module,exports){
  3735. (function (global){
  3736. "use strict";
  3737. require("./node");
  3738. var transform = module.exports = require("../transformation");
  3739. transform.options = require("../transformation/file/options");
  3740. transform.version = require("../../../package").version;
  3741. transform.transform = transform;
  3742. transform.run = function (code) {
  3743. var opts = arguments[1] === undefined ? {} : arguments[1];
  3744. opts.sourceMaps = "inline";
  3745. return new Function(transform(code, opts).code)();
  3746. };
  3747. transform.load = function (url, callback, _x2, hold) {
  3748. var opts = arguments[2] === undefined ? {} : arguments[2];
  3749. opts.filename = opts.filename || url;
  3750. var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
  3751. xhr.open("GET", url, true);
  3752. if ("overrideMimeType" in xhr) xhr.overrideMimeType("text/plain");
  3753. xhr.onreadystatechange = function () {
  3754. if (xhr.readyState !== 4) return;
  3755. var status = xhr.status;
  3756. if (status === 0 || status === 200) {
  3757. var param = [xhr.responseText, opts];
  3758. if (!hold) transform.run.apply(transform, param);
  3759. if (callback) callback(param);
  3760. } else {
  3761. throw new Error("Could not load " + url);
  3762. }
  3763. };
  3764. xhr.send(null);
  3765. };
  3766. var runScripts = function runScripts() {
  3767. var scripts = [];
  3768. var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
  3769. var index = 0;
  3770. var exec = function exec() {
  3771. var param = scripts[index];
  3772. if (param instanceof Array) {
  3773. transform.run.apply(transform, param);
  3774. index++;
  3775. exec();
  3776. }
  3777. };
  3778. var run = function run(script, i) {
  3779. var opts = {};
  3780. if (script.src) {
  3781. transform.load(script.src, function (param) {
  3782. scripts[i] = param;
  3783. exec();
  3784. }, opts, true);
  3785. } else {
  3786. opts.filename = "embedded";
  3787. scripts[i] = [script.innerHTML, opts];
  3788. }
  3789. };
  3790. var _scripts = global.document.getElementsByTagName("script");
  3791. for (var i = 0; i < _scripts.length; ++i) {
  3792. var _script = _scripts[i];
  3793. if (types.indexOf(_script.type) >= 0) scripts.push(_script);
  3794. }
  3795. for (i in scripts) {
  3796. run(scripts[i], i);
  3797. }
  3798. exec();
  3799. };
  3800. if (global.addEventListener) {
  3801. global.addEventListener("DOMContentLoaded", runScripts, false);
  3802. } else if (global.attachEvent) {
  3803. global.attachEvent("onload", runScripts);
  3804. }
  3805. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  3806. },{"../../../package":497,"../transformation":71,"../transformation/file/options":55,"./node":20}],20:[function(require,module,exports){
  3807. "use strict";
  3808. exports.__esModule = true;
  3809. exports.register = register;
  3810. exports.polyfill = polyfill;
  3811. exports.transformFile = transformFile;
  3812. exports.transformFileSync = transformFileSync;
  3813. exports.parse = parse;
  3814. function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
  3815. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  3816. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3817. var _lodashLangIsFunction = require("lodash/lang/isFunction");
  3818. var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
  3819. var _transformation = require("../transformation");
  3820. var _transformation2 = _interopRequireDefault(_transformation);
  3821. var _acorn = require("../../acorn");
  3822. var acorn = _interopRequireWildcard(_acorn);
  3823. var _util = require("../util");
  3824. var util = _interopRequireWildcard(_util);
  3825. var _fs = require("fs");
  3826. var _fs2 = _interopRequireDefault(_fs);
  3827. var _types = require("../types");
  3828. var t = _interopRequireWildcard(_types);
  3829. exports.util = util;
  3830. exports.acorn = acorn;
  3831. exports.transform = _transformation2["default"];
  3832. exports.pipeline = _transformation.pipeline;
  3833. exports.canCompile = _util.canCompile;
  3834. var _transformationFileOptions = require("../transformation/file/options");
  3835. exports.options = _interopRequire(_transformationFileOptions);
  3836. var _transformationTransformer = require("../transformation/transformer");
  3837. exports.Transformer = _interopRequire(_transformationTransformer);
  3838. var _transformationTransformerPipeline = require("../transformation/transformer-pipeline");
  3839. exports.TransformerPipeline = _interopRequire(_transformationTransformerPipeline);
  3840. var _traversal = require("../traversal");
  3841. exports.traverse = _interopRequire(_traversal);
  3842. var _toolsBuildExternalHelpers = require("../tools/build-external-helpers");
  3843. exports.buildExternalHelpers = _interopRequire(_toolsBuildExternalHelpers);
  3844. var _package = require("../../../package");
  3845. exports.version = _package.version;
  3846. exports.types = t;
  3847. function register(opts) {
  3848. var callback = require("./register/node-polyfill");
  3849. if (opts != null) callback(opts);
  3850. return callback;
  3851. }
  3852. function polyfill() {
  3853. require("../polyfill");
  3854. }
  3855. function transformFile(filename, opts, callback) {
  3856. if ((0, _lodashLangIsFunction2["default"])(opts)) {
  3857. callback = opts;
  3858. opts = {};
  3859. }
  3860. opts.filename = filename;
  3861. _fs2["default"].readFile(filename, function (err, code) {
  3862. if (err) return callback(err);
  3863. var result;
  3864. try {
  3865. result = (0, _transformation2["default"])(code, opts);
  3866. } catch (err) {
  3867. return callback(err);
  3868. }
  3869. callback(null, result);
  3870. });
  3871. }
  3872. function transformFileSync(filename) {
  3873. var opts = arguments[1] === undefined ? {} : arguments[1];
  3874. opts.filename = filename;
  3875. return (0, _transformation2["default"])(_fs2["default"].readFileSync(filename, "utf8"), opts);
  3876. }
  3877. function parse(code) {
  3878. var opts = arguments[1] === undefined ? {} : arguments[1];
  3879. opts.allowHashBang = true;
  3880. opts.sourceType = "module";
  3881. opts.ecmaVersion = Infinity;
  3882. opts.plugins = {
  3883. flow: true,
  3884. jsx: true
  3885. };
  3886. opts.features = {};
  3887. for (var key in _transformation2["default"].pipeline.transformers) {
  3888. opts.features[key] = true;
  3889. }
  3890. return acorn.parse(code, opts);
  3891. }
  3892. },{"../../../package":497,"../../acorn":1,"../polyfill":49,"../tools/build-external-helpers":50,"../transformation":71,"../transformation/file/options":55,"../transformation/transformer":85,"../transformation/transformer-pipeline":84,"../traversal":157,"../types":169,"../util":173,"./register/node-polyfill":22,"fs":189,"lodash/lang/isFunction":408}],21:[function(require,module,exports){
  3893. "use strict";
  3894. exports.__esModule = true;
  3895. require("../../polyfill");
  3896. // required to safely use babel/register within a browserify codebase
  3897. exports["default"] = function () {};
  3898. ;
  3899. module.exports = exports["default"];
  3900. },{"../../polyfill":49}],22:[function(require,module,exports){
  3901. "use strict";
  3902. exports.__esModule = true;
  3903. function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
  3904. require("../../polyfill");
  3905. var _node = require("./node");
  3906. exports["default"] = _interopRequire(_node);
  3907. module.exports = exports["default"];
  3908. },{"../../polyfill":49,"./node":21}],23:[function(require,module,exports){
  3909. "use strict";
  3910. exports.__esModule = true;
  3911. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3912. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3913. var _repeating = require("repeating");
  3914. var _repeating2 = _interopRequireDefault(_repeating);
  3915. var _trimRight = require("trim-right");
  3916. var _trimRight2 = _interopRequireDefault(_trimRight);
  3917. var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
  3918. var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
  3919. var _lodashCollectionIncludes = require("lodash/collection/includes");
  3920. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  3921. var _lodashLangIsNumber = require("lodash/lang/isNumber");
  3922. var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
  3923. var Buffer = (function () {
  3924. function Buffer(position, format) {
  3925. _classCallCheck(this, Buffer);
  3926. this.position = position;
  3927. this._indent = format.indent.base;
  3928. this.format = format;
  3929. this.buf = "";
  3930. }
  3931. Buffer.prototype.get = function get() {
  3932. return (0, _trimRight2["default"])(this.buf);
  3933. };
  3934. Buffer.prototype.getIndent = function getIndent() {
  3935. if (this.format.compact || this.format.concise) {
  3936. return "";
  3937. } else {
  3938. return (0, _repeating2["default"])(this.format.indent.style, this._indent);
  3939. }
  3940. };
  3941. Buffer.prototype.indentSize = function indentSize() {
  3942. return this.getIndent().length;
  3943. };
  3944. Buffer.prototype.indent = function indent() {
  3945. this._indent++;
  3946. };
  3947. Buffer.prototype.dedent = function dedent() {
  3948. this._indent--;
  3949. };
  3950. Buffer.prototype.semicolon = function semicolon() {
  3951. this.push(";");
  3952. };
  3953. Buffer.prototype.ensureSemicolon = function ensureSemicolon() {
  3954. if (!this.isLast(";")) this.semicolon();
  3955. };
  3956. Buffer.prototype.rightBrace = function rightBrace() {
  3957. this.newline(true);
  3958. this.push("}");
  3959. };
  3960. Buffer.prototype.keyword = function keyword(name) {
  3961. this.push(name);
  3962. this.space();
  3963. };
  3964. Buffer.prototype.space = function space() {
  3965. if (this.format.compact) return;
  3966. if (this.buf && !this.isLast(" ") && !this.isLast("\n")) {
  3967. this.push(" ");
  3968. }
  3969. };
  3970. Buffer.prototype.removeLast = function removeLast(cha) {
  3971. if (this.format.compact) return;
  3972. if (!this.isLast(cha)) return;
  3973. this.buf = this.buf.substr(0, this.buf.length - 1);
  3974. this.position.unshift(cha);
  3975. };
  3976. Buffer.prototype.newline = function newline(i, removeLast) {
  3977. if (this.format.compact || this.format.retainLines) return;
  3978. if (this.format.concise) {
  3979. this.space();
  3980. return;
  3981. }
  3982. removeLast = removeLast || false;
  3983. if ((0, _lodashLangIsNumber2["default"])(i)) {
  3984. i = Math.min(2, i);
  3985. if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
  3986. if (i <= 0) return;
  3987. while (i > 0) {
  3988. this._newline(removeLast);
  3989. i--;
  3990. }
  3991. return;
  3992. }
  3993. if ((0, _lodashLangIsBoolean2["default"])(i)) {
  3994. removeLast = i;
  3995. }
  3996. this._newline(removeLast);
  3997. };
  3998. Buffer.prototype._newline = function _newline(removeLast) {
  3999. // never allow more than two lines
  4000. if (this.endsWith("\n\n")) return;
  4001. // remove the last newline
  4002. if (removeLast && this.isLast("\n")) this.removeLast("\n");
  4003. this.removeLast(" ");
  4004. this._removeSpacesAfterLastNewline();
  4005. this._push("\n");
  4006. };
  4007. /**
  4008. * If buffer ends with a newline and some spaces after it, trim those spaces.
  4009. */
  4010. Buffer.prototype._removeSpacesAfterLastNewline = function _removeSpacesAfterLastNewline() {
  4011. var lastNewlineIndex = this.buf.lastIndexOf("\n");
  4012. if (lastNewlineIndex === -1) {
  4013. return;
  4014. }
  4015. var index = this.buf.length - 1;
  4016. while (index > lastNewlineIndex) {
  4017. if (this.buf[index] !== " ") {
  4018. break;
  4019. }
  4020. index--;
  4021. }
  4022. if (index === lastNewlineIndex) {
  4023. this.buf = this.buf.substring(0, index + 1);
  4024. }
  4025. };
  4026. Buffer.prototype.push = function push(str, noIndent) {
  4027. if (!this.format.compact && this._indent && !noIndent && str !== "\n") {
  4028. // we have an indent level and we aren't pushing a newline
  4029. var indent = this.getIndent();
  4030. // replace all newlines with newlines with the indentation
  4031. str = str.replace(/\n/g, "\n" + indent);
  4032. // we've got a newline before us so prepend on the indentation
  4033. if (this.isLast("\n")) this._push(indent);
  4034. }
  4035. this._push(str);
  4036. };
  4037. Buffer.prototype._push = function _push(str) {
  4038. this.position.push(str);
  4039. this.buf += str;
  4040. };
  4041. Buffer.prototype.endsWith = function endsWith(str) {
  4042. return this.buf.slice(-str.length) === str;
  4043. };
  4044. Buffer.prototype.isLast = function isLast(cha) {
  4045. if (this.format.compact) return false;
  4046. var buf = this.buf;
  4047. var last = buf[buf.length - 1];
  4048. if (Array.isArray(cha)) {
  4049. return (0, _lodashCollectionIncludes2["default"])(cha, last);
  4050. } else {
  4051. return cha === last;
  4052. }
  4053. };
  4054. return Buffer;
  4055. })();
  4056. exports["default"] = Buffer;
  4057. module.exports = exports["default"];
  4058. },{"lodash/collection/includes":332,"lodash/lang/isBoolean":406,"lodash/lang/isNumber":410,"repeating":479,"trim-right":496}],24:[function(require,module,exports){
  4059. "use strict";
  4060. exports.__esModule = true;
  4061. exports.File = File;
  4062. exports.Program = Program;
  4063. exports.BlockStatement = BlockStatement;
  4064. function File(node, print) {
  4065. print(node.program);
  4066. }
  4067. function Program(node, print) {
  4068. print.sequence(node.body);
  4069. }
  4070. function BlockStatement(node, print) {
  4071. if (node.body.length === 0) {
  4072. this.push("{}");
  4073. } else {
  4074. this.push("{");
  4075. this.newline();
  4076. print.sequence(node.body, { indent: true });
  4077. if (!this.format.retainLines) this.removeLast("\n");
  4078. this.rightBrace();
  4079. }
  4080. }
  4081. },{}],25:[function(require,module,exports){
  4082. "use strict";
  4083. exports.__esModule = true;
  4084. exports.ClassDeclaration = ClassDeclaration;
  4085. exports.ClassBody = ClassBody;
  4086. exports.ClassProperty = ClassProperty;
  4087. exports.MethodDefinition = MethodDefinition;
  4088. function ClassDeclaration(node, print) {
  4089. print.list(node.decorators);
  4090. this.push("class");
  4091. if (node.id) {
  4092. this.space();
  4093. print(node.id);
  4094. }
  4095. print(node.typeParameters);
  4096. if (node.superClass) {
  4097. this.push(" extends ");
  4098. print(node.superClass);
  4099. print(node.superTypeParameters);
  4100. }
  4101. if (node["implements"]) {
  4102. this.push(" implements ");
  4103. print.join(node["implements"], { separator: ", " });
  4104. }
  4105. this.space();
  4106. print(node.body);
  4107. }
  4108. exports.ClassExpression = ClassDeclaration;
  4109. function ClassBody(node, print) {
  4110. if (node.body.length === 0) {
  4111. this.push("{}");
  4112. } else {
  4113. this.push("{");
  4114. this.newline();
  4115. this.indent();
  4116. print.sequence(node.body);
  4117. this.dedent();
  4118. this.rightBrace();
  4119. }
  4120. }
  4121. function ClassProperty(node, print) {
  4122. print.list(node.decorators);
  4123. if (node["static"]) this.push("static ");
  4124. print(node.key);
  4125. print(node.typeAnnotation);
  4126. if (node.value) {
  4127. this.space();
  4128. this.push("=");
  4129. this.space();
  4130. print(node.value);
  4131. }
  4132. this.semicolon();
  4133. }
  4134. function MethodDefinition(node, print) {
  4135. print.list(node.decorators);
  4136. if (node["static"]) {
  4137. this.push("static ");
  4138. }
  4139. this._method(node, print);
  4140. }
  4141. },{}],26:[function(require,module,exports){
  4142. "use strict";
  4143. exports.__esModule = true;
  4144. exports.ComprehensionBlock = ComprehensionBlock;
  4145. exports.ComprehensionExpression = ComprehensionExpression;
  4146. function ComprehensionBlock(node, print) {
  4147. this.keyword("for");
  4148. this.push("(");
  4149. print(node.left);
  4150. this.push(" of ");
  4151. print(node.right);
  4152. this.push(")");
  4153. }
  4154. function ComprehensionExpression(node, print) {
  4155. this.push(node.generator ? "(" : "[");
  4156. print.join(node.blocks, { separator: " " });
  4157. this.space();
  4158. if (node.filter) {
  4159. this.keyword("if");
  4160. this.push("(");
  4161. print(node.filter);
  4162. this.push(")");
  4163. this.space();
  4164. }
  4165. print(node.body);
  4166. this.push(node.generator ? ")" : "]");
  4167. }
  4168. },{}],27:[function(require,module,exports){
  4169. "use strict";
  4170. exports.__esModule = true;
  4171. exports.UnaryExpression = UnaryExpression;
  4172. exports.DoExpression = DoExpression;
  4173. exports.UpdateExpression = UpdateExpression;
  4174. exports.ConditionalExpression = ConditionalExpression;
  4175. exports.NewExpression = NewExpression;
  4176. exports.SequenceExpression = SequenceExpression;
  4177. exports.ThisExpression = ThisExpression;
  4178. exports.Super = Super;
  4179. exports.Decorator = Decorator;
  4180. exports.CallExpression = CallExpression;
  4181. exports.EmptyStatement = EmptyStatement;
  4182. exports.ExpressionStatement = ExpressionStatement;
  4183. exports.AssignmentExpression = AssignmentExpression;
  4184. exports.BindExpression = BindExpression;
  4185. exports.MemberExpression = MemberExpression;
  4186. exports.MetaProperty = MetaProperty;
  4187. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4188. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4189. var _isInteger = require("is-integer");
  4190. var _isInteger2 = _interopRequireDefault(_isInteger);
  4191. var _lodashLangIsNumber = require("lodash/lang/isNumber");
  4192. var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
  4193. var _types = require("../../types");
  4194. var t = _interopRequireWildcard(_types);
  4195. function UnaryExpression(node, print) {
  4196. var hasSpace = /[a-z]$/.test(node.operator);
  4197. var arg = node.argument;
  4198. if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
  4199. hasSpace = true;
  4200. }
  4201. if (t.isUnaryExpression(arg) && arg.operator === "!") {
  4202. hasSpace = false;
  4203. }
  4204. this.push(node.operator);
  4205. if (hasSpace) this.push(" ");
  4206. print(node.argument);
  4207. }
  4208. function DoExpression(node, print) {
  4209. this.push("do");
  4210. this.space();
  4211. print(node.body);
  4212. }
  4213. function UpdateExpression(node, print) {
  4214. if (node.prefix) {
  4215. this.push(node.operator);
  4216. print(node.argument);
  4217. } else {
  4218. print(node.argument);
  4219. this.push(node.operator);
  4220. }
  4221. }
  4222. function ConditionalExpression(node, print) {
  4223. print(node.test);
  4224. this.space();
  4225. this.push("?");
  4226. this.space();
  4227. print(node.consequent);
  4228. this.space();
  4229. this.push(":");
  4230. this.space();
  4231. print(node.alternate);
  4232. }
  4233. function NewExpression(node, print) {
  4234. this.push("new ");
  4235. print(node.callee);
  4236. this.push("(");
  4237. print.list(node.arguments);
  4238. this.push(")");
  4239. }
  4240. function SequenceExpression(node, print) {
  4241. print.list(node.expressions);
  4242. }
  4243. function ThisExpression() {
  4244. this.push("this");
  4245. }
  4246. function Super() {
  4247. this.push("super");
  4248. }
  4249. function Decorator(node, print) {
  4250. this.push("@");
  4251. print(node.expression);
  4252. }
  4253. function CallExpression(node, print) {
  4254. print(node.callee);
  4255. this.push("(");
  4256. var separator = ",";
  4257. if (node._prettyCall) {
  4258. separator += "\n";
  4259. this.newline();
  4260. this.indent();
  4261. } else {
  4262. separator += " ";
  4263. }
  4264. print.list(node.arguments, { separator: separator });
  4265. if (node._prettyCall) {
  4266. this.newline();
  4267. this.dedent();
  4268. }
  4269. this.push(")");
  4270. }
  4271. var buildYieldAwait = function buildYieldAwait(keyword) {
  4272. return function (node, print) {
  4273. this.push(keyword);
  4274. if (node.delegate || node.all) {
  4275. this.push("*");
  4276. }
  4277. if (node.argument) {
  4278. this.space();
  4279. print(node.argument);
  4280. }
  4281. };
  4282. };
  4283. var YieldExpression = buildYieldAwait("yield");
  4284. exports.YieldExpression = YieldExpression;
  4285. var AwaitExpression = buildYieldAwait("await");
  4286. exports.AwaitExpression = AwaitExpression;
  4287. function EmptyStatement() {
  4288. this.semicolon();
  4289. }
  4290. function ExpressionStatement(node, print) {
  4291. print(node.expression);
  4292. this.semicolon();
  4293. }
  4294. function AssignmentExpression(node, print) {
  4295. // todo: add cases where the spaces can be dropped when in compact mode
  4296. print(node.left);
  4297. this.push(" ");
  4298. this.push(node.operator);
  4299. this.push(" ");
  4300. print(node.right);
  4301. }
  4302. function BindExpression(node, print) {
  4303. print(node.object);
  4304. this.push("::");
  4305. print(node.callee);
  4306. }
  4307. exports.BinaryExpression = AssignmentExpression;
  4308. exports.LogicalExpression = AssignmentExpression;
  4309. exports.AssignmentPattern = AssignmentExpression;
  4310. var SCIENTIFIC_NOTATION = /e/i;
  4311. function MemberExpression(node, print) {
  4312. var obj = node.object;
  4313. print(obj);
  4314. if (!node.computed && t.isMemberExpression(node.property)) {
  4315. throw new TypeError("Got a MemberExpression for MemberExpression property");
  4316. }
  4317. var computed = node.computed;
  4318. if (t.isLiteral(node.property) && (0, _lodashLangIsNumber2["default"])(node.property.value)) {
  4319. computed = true;
  4320. }
  4321. if (computed) {
  4322. this.push("[");
  4323. print(node.property);
  4324. this.push("]");
  4325. } else {
  4326. // 5..toFixed(2);
  4327. if (t.isLiteral(obj) && (0, _isInteger2["default"])(obj.value) && !SCIENTIFIC_NOTATION.test(obj.value.toString())) {
  4328. this.push(".");
  4329. }
  4330. this.push(".");
  4331. print(node.property);
  4332. }
  4333. }
  4334. function MetaProperty(node, print) {
  4335. print(node.meta);
  4336. this.push(".");
  4337. print(node.property);
  4338. }
  4339. },{"../../types":169,"is-integer":317,"lodash/lang/isNumber":410}],28:[function(require,module,exports){
  4340. "use strict";
  4341. exports.__esModule = true;
  4342. exports.AnyTypeAnnotation = AnyTypeAnnotation;
  4343. exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
  4344. exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
  4345. exports.DeclareClass = DeclareClass;
  4346. exports.DeclareFunction = DeclareFunction;
  4347. exports.DeclareModule = DeclareModule;
  4348. exports.DeclareVariable = DeclareVariable;
  4349. exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
  4350. exports.FunctionTypeParam = FunctionTypeParam;
  4351. exports.InterfaceExtends = InterfaceExtends;
  4352. exports._interfaceish = _interfaceish;
  4353. exports.InterfaceDeclaration = InterfaceDeclaration;
  4354. exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
  4355. exports.NullableTypeAnnotation = NullableTypeAnnotation;
  4356. exports.NumberTypeAnnotation = NumberTypeAnnotation;
  4357. exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
  4358. exports.StringTypeAnnotation = StringTypeAnnotation;
  4359. exports.TupleTypeAnnotation = TupleTypeAnnotation;
  4360. exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
  4361. exports.TypeAlias = TypeAlias;
  4362. exports.TypeAnnotation = TypeAnnotation;
  4363. exports.TypeParameterInstantiation = TypeParameterInstantiation;
  4364. exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
  4365. exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
  4366. exports.ObjectTypeIndexer = ObjectTypeIndexer;
  4367. exports.ObjectTypeProperty = ObjectTypeProperty;
  4368. exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
  4369. exports.UnionTypeAnnotation = UnionTypeAnnotation;
  4370. exports.TypeCastExpression = TypeCastExpression;
  4371. exports.VoidTypeAnnotation = VoidTypeAnnotation;
  4372. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4373. var _types = require("../../types");
  4374. var t = _interopRequireWildcard(_types);
  4375. function AnyTypeAnnotation() {
  4376. this.push("any");
  4377. }
  4378. function ArrayTypeAnnotation(node, print) {
  4379. print(node.elementType);
  4380. this.push("[");
  4381. this.push("]");
  4382. }
  4383. function BooleanTypeAnnotation(node) {
  4384. this.push("bool");
  4385. }
  4386. function DeclareClass(node, print) {
  4387. this.push("declare class ");
  4388. this._interfaceish(node, print);
  4389. }
  4390. function DeclareFunction(node, print) {
  4391. this.push("declare function ");
  4392. print(node.id);
  4393. print(node.id.typeAnnotation.typeAnnotation);
  4394. this.semicolon();
  4395. }
  4396. function DeclareModule(node, print) {
  4397. this.push("declare module ");
  4398. print(node.id);
  4399. this.space();
  4400. print(node.body);
  4401. }
  4402. function DeclareVariable(node, print) {
  4403. this.push("declare var ");
  4404. print(node.id);
  4405. print(node.id.typeAnnotation);
  4406. this.semicolon();
  4407. }
  4408. function FunctionTypeAnnotation(node, print, parent) {
  4409. print(node.typeParameters);
  4410. this.push("(");
  4411. print.list(node.params);
  4412. if (node.rest) {
  4413. if (node.params.length) {
  4414. this.push(",");
  4415. this.space();
  4416. }
  4417. this.push("...");
  4418. print(node.rest);
  4419. }
  4420. this.push(")");
  4421. // this node type is overloaded, not sure why but it makes it EXTREMELY annoying
  4422. if (parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
  4423. this.push(":");
  4424. } else {
  4425. this.space();
  4426. this.push("=>");
  4427. }
  4428. this.space();
  4429. print(node.returnType);
  4430. }
  4431. function FunctionTypeParam(node, print) {
  4432. print(node.name);
  4433. if (node.optional) this.push("?");
  4434. this.push(":");
  4435. this.space();
  4436. print(node.typeAnnotation);
  4437. }
  4438. function InterfaceExtends(node, print) {
  4439. print(node.id);
  4440. print(node.typeParameters);
  4441. }
  4442. exports.ClassImplements = InterfaceExtends;
  4443. exports.GenericTypeAnnotation = InterfaceExtends;
  4444. function _interfaceish(node, print) {
  4445. print(node.id);
  4446. print(node.typeParameters);
  4447. if (node["extends"].length) {
  4448. this.push(" extends ");
  4449. print.join(node["extends"], { separator: ", " });
  4450. }
  4451. this.space();
  4452. print(node.body);
  4453. }
  4454. function InterfaceDeclaration(node, print) {
  4455. this.push("interface ");
  4456. this._interfaceish(node, print);
  4457. }
  4458. function IntersectionTypeAnnotation(node, print) {
  4459. print.join(node.types, { separator: " & " });
  4460. }
  4461. function NullableTypeAnnotation(node, print) {
  4462. this.push("?");
  4463. print(node.typeAnnotation);
  4464. }
  4465. function NumberTypeAnnotation() {
  4466. this.push("number");
  4467. }
  4468. function StringLiteralTypeAnnotation(node) {
  4469. this._stringLiteral(node.value);
  4470. }
  4471. function StringTypeAnnotation() {
  4472. this.push("string");
  4473. }
  4474. function TupleTypeAnnotation(node, print) {
  4475. this.push("[");
  4476. print.join(node.types, { separator: ", " });
  4477. this.push("]");
  4478. }
  4479. function TypeofTypeAnnotation(node, print) {
  4480. this.push("typeof ");
  4481. print(node.argument);
  4482. }
  4483. function TypeAlias(node, print) {
  4484. this.push("type ");
  4485. print(node.id);
  4486. print(node.typeParameters);
  4487. this.space();
  4488. this.push("=");
  4489. this.space();
  4490. print(node.right);
  4491. this.semicolon();
  4492. }
  4493. function TypeAnnotation(node, print) {
  4494. this.push(":");
  4495. this.space();
  4496. if (node.optional) this.push("?");
  4497. print(node.typeAnnotation);
  4498. }
  4499. function TypeParameterInstantiation(node, print) {
  4500. this.push("<");
  4501. print.join(node.params, { separator: ", " });
  4502. this.push(">");
  4503. }
  4504. exports.TypeParameterDeclaration = TypeParameterInstantiation;
  4505. function ObjectTypeAnnotation(node, print) {
  4506. var _this = this;
  4507. this.push("{");
  4508. var props = node.properties.concat(node.callProperties, node.indexers);
  4509. if (props.length) {
  4510. this.space();
  4511. print.list(props, {
  4512. separator: false,
  4513. indent: true,
  4514. iterator: function iterator() {
  4515. if (props.length !== 1) {
  4516. _this.semicolon();
  4517. _this.space();
  4518. }
  4519. }
  4520. });
  4521. this.space();
  4522. }
  4523. this.push("}");
  4524. }
  4525. function ObjectTypeCallProperty(node, print) {
  4526. if (node["static"]) this.push("static ");
  4527. print(node.value);
  4528. }
  4529. function ObjectTypeIndexer(node, print) {
  4530. if (node["static"]) this.push("static ");
  4531. this.push("[");
  4532. print(node.id);
  4533. this.push(":");
  4534. this.space();
  4535. print(node.key);
  4536. this.push("]");
  4537. this.push(":");
  4538. this.space();
  4539. print(node.value);
  4540. }
  4541. function ObjectTypeProperty(node, print) {
  4542. if (node["static"]) this.push("static ");
  4543. print(node.key);
  4544. if (node.optional) this.push("?");
  4545. if (!t.isFunctionTypeAnnotation(node.value)) {
  4546. this.push(":");
  4547. this.space();
  4548. }
  4549. print(node.value);
  4550. }
  4551. function QualifiedTypeIdentifier(node, print) {
  4552. print(node.qualification);
  4553. this.push(".");
  4554. print(node.id);
  4555. }
  4556. function UnionTypeAnnotation(node, print) {
  4557. print.join(node.types, { separator: " | " });
  4558. }
  4559. function TypeCastExpression(node, print) {
  4560. this.push("(");
  4561. print(node.expression);
  4562. print(node.typeAnnotation);
  4563. this.push(")");
  4564. }
  4565. function VoidTypeAnnotation(node) {
  4566. this.push("void");
  4567. }
  4568. },{"../../types":169}],29:[function(require,module,exports){
  4569. "use strict";
  4570. exports.__esModule = true;
  4571. exports.JSXAttribute = JSXAttribute;
  4572. exports.JSXIdentifier = JSXIdentifier;
  4573. exports.JSXNamespacedName = JSXNamespacedName;
  4574. exports.JSXMemberExpression = JSXMemberExpression;
  4575. exports.JSXSpreadAttribute = JSXSpreadAttribute;
  4576. exports.JSXExpressionContainer = JSXExpressionContainer;
  4577. exports.JSXElement = JSXElement;
  4578. exports.JSXOpeningElement = JSXOpeningElement;
  4579. exports.JSXClosingElement = JSXClosingElement;
  4580. exports.JSXEmptyExpression = JSXEmptyExpression;
  4581. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4582. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4583. var _lodashCollectionEach = require("lodash/collection/each");
  4584. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  4585. var _types = require("../../types");
  4586. var t = _interopRequireWildcard(_types);
  4587. function JSXAttribute(node, print) {
  4588. print(node.name);
  4589. if (node.value) {
  4590. this.push("=");
  4591. print(node.value);
  4592. }
  4593. }
  4594. function JSXIdentifier(node) {
  4595. this.push(node.name);
  4596. }
  4597. function JSXNamespacedName(node, print) {
  4598. print(node.namespace);
  4599. this.push(":");
  4600. print(node.name);
  4601. }
  4602. function JSXMemberExpression(node, print) {
  4603. print(node.object);
  4604. this.push(".");
  4605. print(node.property);
  4606. }
  4607. function JSXSpreadAttribute(node, print) {
  4608. this.push("{...");
  4609. print(node.argument);
  4610. this.push("}");
  4611. }
  4612. function JSXExpressionContainer(node, print) {
  4613. this.push("{");
  4614. print(node.expression);
  4615. this.push("}");
  4616. }
  4617. function JSXElement(node, print) {
  4618. var open = node.openingElement;
  4619. print(open);
  4620. if (open.selfClosing) return;
  4621. this.indent();
  4622. var _arr = node.children;
  4623. for (var _i = 0; _i < _arr.length; _i++) {
  4624. var child = _arr[_i];
  4625. if (t.isLiteral(child)) {
  4626. this.push(child.value, true);
  4627. } else {
  4628. print(child);
  4629. }
  4630. }
  4631. this.dedent();
  4632. print(node.closingElement);
  4633. }
  4634. function JSXOpeningElement(node, print) {
  4635. this.push("<");
  4636. print(node.name);
  4637. if (node.attributes.length > 0) {
  4638. this.push(" ");
  4639. print.join(node.attributes, { separator: " " });
  4640. }
  4641. this.push(node.selfClosing ? " />" : ">");
  4642. }
  4643. function JSXClosingElement(node, print) {
  4644. this.push("</");
  4645. print(node.name);
  4646. this.push(">");
  4647. }
  4648. function JSXEmptyExpression() {}
  4649. },{"../../types":169,"lodash/collection/each":330}],30:[function(require,module,exports){
  4650. "use strict";
  4651. exports.__esModule = true;
  4652. exports._params = _params;
  4653. exports._method = _method;
  4654. exports.FunctionExpression = FunctionExpression;
  4655. exports.ArrowFunctionExpression = ArrowFunctionExpression;
  4656. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4657. var _types = require("../../types");
  4658. var t = _interopRequireWildcard(_types);
  4659. function _params(node, print) {
  4660. var _this = this;
  4661. print(node.typeParameters);
  4662. this.push("(");
  4663. print.list(node.params, {
  4664. iterator: function iterator(node) {
  4665. if (node.optional) _this.push("?");
  4666. print(node.typeAnnotation);
  4667. }
  4668. });
  4669. this.push(")");
  4670. if (node.returnType) {
  4671. print(node.returnType);
  4672. }
  4673. }
  4674. function _method(node, print) {
  4675. var value = node.value;
  4676. var kind = node.kind;
  4677. var key = node.key;
  4678. if (kind === "method" || kind === "init") {
  4679. if (value.generator) {
  4680. this.push("*");
  4681. }
  4682. }
  4683. if (kind === "get" || kind === "set") {
  4684. this.push(kind + " ");
  4685. }
  4686. if (value.async) this.push("async ");
  4687. if (node.computed) {
  4688. this.push("[");
  4689. print(key);
  4690. this.push("]");
  4691. } else {
  4692. print(key);
  4693. }
  4694. this._params(value, print);
  4695. this.push(" ");
  4696. print(value.body);
  4697. }
  4698. function FunctionExpression(node, print) {
  4699. if (node.async) this.push("async ");
  4700. this.push("function");
  4701. if (node.generator) this.push("*");
  4702. if (node.id) {
  4703. this.push(" ");
  4704. print(node.id);
  4705. } else {
  4706. this.space();
  4707. }
  4708. this._params(node, print);
  4709. this.space();
  4710. print(node.body);
  4711. }
  4712. exports.FunctionDeclaration = FunctionExpression;
  4713. function ArrowFunctionExpression(node, print) {
  4714. if (node.async) this.push("async ");
  4715. if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
  4716. print(node.params[0]);
  4717. } else {
  4718. this._params(node, print);
  4719. }
  4720. this.push(" => ");
  4721. var bodyNeedsParens = t.isObjectExpression(node.body);
  4722. if (bodyNeedsParens) {
  4723. this.push("(");
  4724. }
  4725. print(node.body);
  4726. if (bodyNeedsParens) {
  4727. this.push(")");
  4728. }
  4729. }
  4730. },{"../../types":169}],31:[function(require,module,exports){
  4731. "use strict";
  4732. exports.__esModule = true;
  4733. exports.ImportSpecifier = ImportSpecifier;
  4734. exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
  4735. exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
  4736. exports.ExportSpecifier = ExportSpecifier;
  4737. exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
  4738. exports.ExportAllDeclaration = ExportAllDeclaration;
  4739. exports.ExportNamedDeclaration = ExportNamedDeclaration;
  4740. exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
  4741. exports.ImportDeclaration = ImportDeclaration;
  4742. exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
  4743. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4744. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4745. var _lodashCollectionEach = require("lodash/collection/each");
  4746. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  4747. var _types = require("../../types");
  4748. var t = _interopRequireWildcard(_types);
  4749. function ImportSpecifier(node, print) {
  4750. print(node.imported);
  4751. if (node.local && node.local.name !== node.imported.name) {
  4752. this.push(" as ");
  4753. print(node.local);
  4754. }
  4755. }
  4756. function ImportDefaultSpecifier(node, print) {
  4757. print(node.local);
  4758. }
  4759. function ExportDefaultSpecifier(node, print) {
  4760. print(node.exported);
  4761. }
  4762. function ExportSpecifier(node, print) {
  4763. print(node.local);
  4764. if (node.exported && node.local.name !== node.exported.name) {
  4765. this.push(" as ");
  4766. print(node.exported);
  4767. }
  4768. }
  4769. function ExportNamespaceSpecifier(node, print) {
  4770. this.push("* as ");
  4771. print(node.exported);
  4772. }
  4773. function ExportAllDeclaration(node, print) {
  4774. this.push("export *");
  4775. if (node.exported) {
  4776. this.push(" as ");
  4777. print(node.exported);
  4778. }
  4779. this.push(" from ");
  4780. print(node.source);
  4781. this.semicolon();
  4782. }
  4783. function ExportNamedDeclaration(node, print) {
  4784. this.push("export ");
  4785. ExportDeclaration.call(this, node, print);
  4786. }
  4787. function ExportDefaultDeclaration(node, print) {
  4788. this.push("export default ");
  4789. ExportDeclaration.call(this, node, print);
  4790. }
  4791. function ExportDeclaration(node, print) {
  4792. var specifiers = node.specifiers;
  4793. if (node.declaration) {
  4794. var declar = node.declaration;
  4795. print(declar);
  4796. if (t.isStatement(declar) || t.isFunction(declar) || t.isClass(declar)) return;
  4797. } else {
  4798. var first = specifiers[0];
  4799. var hasSpecial = false;
  4800. if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
  4801. hasSpecial = true;
  4802. print(specifiers.shift());
  4803. if (specifiers.length) {
  4804. this.push(", ");
  4805. }
  4806. }
  4807. if (specifiers.length || !specifiers.length && !hasSpecial) {
  4808. this.push("{");
  4809. if (specifiers.length) {
  4810. this.space();
  4811. print.join(specifiers, { separator: ", " });
  4812. this.space();
  4813. }
  4814. this.push("}");
  4815. }
  4816. if (node.source) {
  4817. this.push(" from ");
  4818. print(node.source);
  4819. }
  4820. }
  4821. this.ensureSemicolon();
  4822. }
  4823. function ImportDeclaration(node, print) {
  4824. this.push("import ");
  4825. if (node.isType) {
  4826. this.push("type ");
  4827. }
  4828. var specfiers = node.specifiers;
  4829. if (specfiers && specfiers.length) {
  4830. var first = node.specifiers[0];
  4831. if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
  4832. print(node.specifiers.shift());
  4833. if (node.specifiers.length) {
  4834. this.push(", ");
  4835. }
  4836. }
  4837. if (node.specifiers.length) {
  4838. this.push("{");
  4839. this.space();
  4840. print.join(node.specifiers, { separator: ", " });
  4841. this.space();
  4842. this.push("}");
  4843. }
  4844. this.push(" from ");
  4845. }
  4846. print(node.source);
  4847. this.semicolon();
  4848. }
  4849. function ImportNamespaceSpecifier(node, print) {
  4850. this.push("* as ");
  4851. print(node.local);
  4852. }
  4853. },{"../../types":169,"lodash/collection/each":330}],32:[function(require,module,exports){
  4854. "use strict";
  4855. exports.__esModule = true;
  4856. exports.WithStatement = WithStatement;
  4857. exports.IfStatement = IfStatement;
  4858. exports.ForStatement = ForStatement;
  4859. exports.WhileStatement = WhileStatement;
  4860. exports.DoWhileStatement = DoWhileStatement;
  4861. exports.LabeledStatement = LabeledStatement;
  4862. exports.TryStatement = TryStatement;
  4863. exports.CatchClause = CatchClause;
  4864. exports.ThrowStatement = ThrowStatement;
  4865. exports.SwitchStatement = SwitchStatement;
  4866. exports.SwitchCase = SwitchCase;
  4867. exports.DebuggerStatement = DebuggerStatement;
  4868. exports.VariableDeclaration = VariableDeclaration;
  4869. exports.VariableDeclarator = VariableDeclarator;
  4870. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  4871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4872. var _repeating = require("repeating");
  4873. var _repeating2 = _interopRequireDefault(_repeating);
  4874. var _types = require("../../types");
  4875. var t = _interopRequireWildcard(_types);
  4876. function WithStatement(node, print) {
  4877. this.keyword("with");
  4878. this.push("(");
  4879. print(node.object);
  4880. this.push(")");
  4881. print.block(node.body);
  4882. }
  4883. function IfStatement(node, print) {
  4884. this.keyword("if");
  4885. this.push("(");
  4886. print(node.test);
  4887. this.push(")");
  4888. this.space();
  4889. print.indentOnComments(node.consequent);
  4890. if (node.alternate) {
  4891. if (this.isLast("}")) this.space();
  4892. this.push("else ");
  4893. print.indentOnComments(node.alternate);
  4894. }
  4895. }
  4896. function ForStatement(node, print) {
  4897. this.keyword("for");
  4898. this.push("(");
  4899. print(node.init);
  4900. this.push(";");
  4901. if (node.test) {
  4902. this.push(" ");
  4903. print(node.test);
  4904. }
  4905. this.push(";");
  4906. if (node.update) {
  4907. this.push(" ");
  4908. print(node.update);
  4909. }
  4910. this.push(")");
  4911. print.block(node.body);
  4912. }
  4913. function WhileStatement(node, print) {
  4914. this.keyword("while");
  4915. this.push("(");
  4916. print(node.test);
  4917. this.push(")");
  4918. print.block(node.body);
  4919. }
  4920. var buildForXStatement = function buildForXStatement(op) {
  4921. return function (node, print) {
  4922. this.keyword("for");
  4923. this.push("(");
  4924. print(node.left);
  4925. this.push(" " + op + " ");
  4926. print(node.right);
  4927. this.push(")");
  4928. print.block(node.body);
  4929. };
  4930. };
  4931. var ForInStatement = buildForXStatement("in");
  4932. exports.ForInStatement = ForInStatement;
  4933. var ForOfStatement = buildForXStatement("of");
  4934. exports.ForOfStatement = ForOfStatement;
  4935. function DoWhileStatement(node, print) {
  4936. this.push("do ");
  4937. print(node.body);
  4938. this.space();
  4939. this.keyword("while");
  4940. this.push("(");
  4941. print(node.test);
  4942. this.push(");");
  4943. }
  4944. var buildLabelStatement = function buildLabelStatement(prefix, key) {
  4945. return function (node, print) {
  4946. this.push(prefix);
  4947. var label = node[key || "label"];
  4948. if (label) {
  4949. this.push(" ");
  4950. print(label);
  4951. }
  4952. this.semicolon();
  4953. };
  4954. };
  4955. var ContinueStatement = buildLabelStatement("continue");
  4956. exports.ContinueStatement = ContinueStatement;
  4957. var ReturnStatement = buildLabelStatement("return", "argument");
  4958. exports.ReturnStatement = ReturnStatement;
  4959. var BreakStatement = buildLabelStatement("break");
  4960. exports.BreakStatement = BreakStatement;
  4961. function LabeledStatement(node, print) {
  4962. print(node.label);
  4963. this.push(": ");
  4964. print(node.body);
  4965. }
  4966. function TryStatement(node, print) {
  4967. this.keyword("try");
  4968. print(node.block);
  4969. this.space();
  4970. // Esprima bug puts the catch clause in a `handlers` array.
  4971. // see https://code.google.com/p/esprima/issues/detail?id=433
  4972. // We run into this from regenerator generated ast.
  4973. if (node.handlers) {
  4974. print(node.handlers[0]);
  4975. } else {
  4976. print(node.handler);
  4977. }
  4978. if (node.finalizer) {
  4979. this.space();
  4980. this.push("finally ");
  4981. print(node.finalizer);
  4982. }
  4983. }
  4984. function CatchClause(node, print) {
  4985. this.keyword("catch");
  4986. this.push("(");
  4987. print(node.param);
  4988. this.push(") ");
  4989. print(node.body);
  4990. }
  4991. function ThrowStatement(node, print) {
  4992. this.push("throw ");
  4993. print(node.argument);
  4994. this.semicolon();
  4995. }
  4996. function SwitchStatement(node, print) {
  4997. this.keyword("switch");
  4998. this.push("(");
  4999. print(node.discriminant);
  5000. this.push(")");
  5001. this.space();
  5002. this.push("{");
  5003. print.sequence(node.cases, {
  5004. indent: true,
  5005. addNewlines: function addNewlines(leading, cas) {
  5006. if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
  5007. }
  5008. });
  5009. this.push("}");
  5010. }
  5011. function SwitchCase(node, print) {
  5012. if (node.test) {
  5013. this.push("case ");
  5014. print(node.test);
  5015. this.push(":");
  5016. } else {
  5017. this.push("default:");
  5018. }
  5019. if (node.consequent.length) {
  5020. this.newline();
  5021. print.sequence(node.consequent, { indent: true });
  5022. }
  5023. }
  5024. function DebuggerStatement() {
  5025. this.push("debugger;");
  5026. }
  5027. function VariableDeclaration(node, print, parent) {
  5028. this.push(node.kind + " ");
  5029. var hasInits = false;
  5030. // don't add whitespace to loop heads
  5031. if (!t.isFor(parent)) {
  5032. var _arr = node.declarations;
  5033. for (var _i = 0; _i < _arr.length; _i++) {
  5034. var declar = _arr[_i];
  5035. if (declar.init) {
  5036. // has an init so let's split it up over multiple lines
  5037. hasInits = true;
  5038. }
  5039. }
  5040. }
  5041. var sep = ",";
  5042. if (!this.format.compact && !this.format.concise && hasInits && !this.format.retainLines) {
  5043. sep += "\n" + (0, _repeating2["default"])(" ", node.kind.length + 1);
  5044. } else {
  5045. sep += " ";
  5046. }
  5047. print.list(node.declarations, { separator: sep });
  5048. if (t.isFor(parent)) {
  5049. if (parent.left === node || parent.init === node) return;
  5050. }
  5051. this.semicolon();
  5052. }
  5053. function VariableDeclarator(node, print) {
  5054. print(node.id);
  5055. print(node.id.typeAnnotation);
  5056. if (node.init) {
  5057. this.space();
  5058. this.push("=");
  5059. this.space();
  5060. print(node.init);
  5061. }
  5062. }
  5063. },{"../../types":169,"repeating":479}],33:[function(require,module,exports){
  5064. "use strict";
  5065. exports.__esModule = true;
  5066. exports.TaggedTemplateExpression = TaggedTemplateExpression;
  5067. exports.TemplateElement = TemplateElement;
  5068. exports.TemplateLiteral = TemplateLiteral;
  5069. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5070. var _lodashCollectionEach = require("lodash/collection/each");
  5071. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5072. function TaggedTemplateExpression(node, print) {
  5073. print(node.tag);
  5074. print(node.quasi);
  5075. }
  5076. function TemplateElement(node) {
  5077. this._push(node.value.raw);
  5078. }
  5079. function TemplateLiteral(node, print) {
  5080. this.push("`");
  5081. var quasis = node.quasis;
  5082. var len = quasis.length;
  5083. for (var i = 0; i < len; i++) {
  5084. print(quasis[i]);
  5085. if (i + 1 < len) {
  5086. this.push("${ ");
  5087. print(node.expressions[i]);
  5088. this.push(" }");
  5089. }
  5090. }
  5091. this._push("`");
  5092. }
  5093. },{"lodash/collection/each":330}],34:[function(require,module,exports){
  5094. "use strict";
  5095. exports.__esModule = true;
  5096. exports.Identifier = Identifier;
  5097. exports.RestElement = RestElement;
  5098. exports.ObjectExpression = ObjectExpression;
  5099. exports.Property = Property;
  5100. exports.ArrayExpression = ArrayExpression;
  5101. exports.Literal = Literal;
  5102. exports._stringLiteral = _stringLiteral;
  5103. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5104. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5105. var _lodashCollectionEach = require("lodash/collection/each");
  5106. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5107. var _types = require("../../types");
  5108. var t = _interopRequireWildcard(_types);
  5109. function Identifier(node) {
  5110. this.push(node.name);
  5111. }
  5112. function RestElement(node, print) {
  5113. this.push("...");
  5114. print(node.argument);
  5115. }
  5116. exports.SpreadElement = RestElement;
  5117. exports.SpreadProperty = RestElement;
  5118. function ObjectExpression(node, print) {
  5119. var props = node.properties;
  5120. if (props.length) {
  5121. this.push("{");
  5122. this.space();
  5123. print.list(props, { indent: true });
  5124. this.space();
  5125. this.push("}");
  5126. } else {
  5127. this.push("{}");
  5128. }
  5129. }
  5130. exports.ObjectPattern = ObjectExpression;
  5131. function Property(node, print) {
  5132. if (node.method || node.kind === "get" || node.kind === "set") {
  5133. this._method(node, print);
  5134. } else {
  5135. if (node.computed) {
  5136. this.push("[");
  5137. print(node.key);
  5138. this.push("]");
  5139. } else {
  5140. print(node.key);
  5141. // shorthand!
  5142. if (node.shorthand && (t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name)) {
  5143. return;
  5144. }
  5145. }
  5146. this.push(":");
  5147. this.space();
  5148. print(node.value);
  5149. }
  5150. }
  5151. function ArrayExpression(node, print) {
  5152. var elems = node.elements;
  5153. var len = elems.length;
  5154. this.push("[");
  5155. for (var i = 0; i < elems.length; i++) {
  5156. var elem = elems[i];
  5157. if (!elem) {
  5158. // If the array expression ends with a hole, that hole
  5159. // will be ignored by the interpreter, but if it ends with
  5160. // two (or more) holes, we need to write out two (or more)
  5161. // commas so that the resulting code is interpreted with
  5162. // both (all) of the holes.
  5163. this.push(",");
  5164. } else {
  5165. if (i > 0) this.push(" ");
  5166. print(elem);
  5167. if (i < len - 1) this.push(",");
  5168. }
  5169. }
  5170. this.push("]");
  5171. }
  5172. exports.ArrayPattern = ArrayExpression;
  5173. function Literal(node) {
  5174. var val = node.value;
  5175. var type = typeof val;
  5176. if (type === "string") {
  5177. this._stringLiteral(val);
  5178. } else if (type === "number") {
  5179. this.push(val + "");
  5180. } else if (type === "boolean") {
  5181. this.push(val ? "true" : "false");
  5182. } else if (node.regex) {
  5183. this.push("/" + node.regex.pattern + "/" + node.regex.flags);
  5184. } else if (val === null) {
  5185. this.push("null");
  5186. }
  5187. }
  5188. function _stringLiteral(val) {
  5189. val = JSON.stringify(val);
  5190. // escape illegal js but valid json unicode characters
  5191. val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
  5192. return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
  5193. });
  5194. if (this.format.quotes === "single") {
  5195. val = val.slice(1, -1);
  5196. val = val.replace(/\\"/g, "\"");
  5197. val = val.replace(/'/g, "\\'");
  5198. val = "'" + val + "'";
  5199. }
  5200. this.push(val);
  5201. }
  5202. },{"../../types":169,"lodash/collection/each":330}],35:[function(require,module,exports){
  5203. "use strict";
  5204. var _createClass = (function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  5205. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5206. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5207. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5208. var _detectIndent = require("detect-indent");
  5209. var _detectIndent2 = _interopRequireDefault(_detectIndent);
  5210. var _whitespace = require("./whitespace");
  5211. var _whitespace2 = _interopRequireDefault(_whitespace);
  5212. var _repeating = require("repeating");
  5213. var _repeating2 = _interopRequireDefault(_repeating);
  5214. var _sourceMap = require("./source-map");
  5215. var _sourceMap2 = _interopRequireDefault(_sourceMap);
  5216. var _position = require("./position");
  5217. var _position2 = _interopRequireDefault(_position);
  5218. var _messages = require("../messages");
  5219. var messages = _interopRequireWildcard(_messages);
  5220. var _buffer = require("./buffer");
  5221. var _buffer2 = _interopRequireDefault(_buffer);
  5222. var _lodashObjectExtend = require("lodash/object/extend");
  5223. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  5224. var _lodashCollectionEach = require("lodash/collection/each");
  5225. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5226. var _node = require("./node");
  5227. var _node2 = _interopRequireDefault(_node);
  5228. var _types = require("../types");
  5229. var t = _interopRequireWildcard(_types);
  5230. var CodeGenerator = (function () {
  5231. function CodeGenerator(ast, opts, code) {
  5232. _classCallCheck(this, CodeGenerator);
  5233. opts = opts || {};
  5234. this.comments = ast.comments || [];
  5235. this.tokens = ast.tokens || [];
  5236. this.format = CodeGenerator.normalizeOptions(code, opts, this.tokens);
  5237. this.opts = opts;
  5238. this.ast = ast;
  5239. this.whitespace = new _whitespace2["default"](this.tokens, this.comments, this.format);
  5240. this.position = new _position2["default"]();
  5241. this.map = new _sourceMap2["default"](this.position, opts, code);
  5242. this.buffer = new _buffer2["default"](this.position, this.format);
  5243. }
  5244. CodeGenerator.normalizeOptions = function normalizeOptions(code, opts, tokens) {
  5245. var style = " ";
  5246. if (code) {
  5247. var indent = (0, _detectIndent2["default"])(code).indent;
  5248. if (indent && indent !== " ") style = indent;
  5249. }
  5250. var format = {
  5251. retainLines: opts.retainLines,
  5252. comments: opts.comments == null || opts.comments,
  5253. compact: opts.compact,
  5254. quotes: CodeGenerator.findCommonStringDelimiter(code, tokens),
  5255. indent: {
  5256. adjustMultilineComment: true,
  5257. style: style,
  5258. base: 0
  5259. }
  5260. };
  5261. if (format.compact === "auto") {
  5262. format.compact = code.length > 100000; // 100KB
  5263. if (format.compact) {
  5264. console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "100KB"));
  5265. }
  5266. }
  5267. return format;
  5268. };
  5269. CodeGenerator.findCommonStringDelimiter = function findCommonStringDelimiter(code, tokens) {
  5270. var occurences = {
  5271. single: 0,
  5272. double: 0
  5273. };
  5274. var checked = 0;
  5275. for (var i = 0; i < tokens.length; i++) {
  5276. var token = tokens[i];
  5277. if (token.type.label !== "string") continue;
  5278. if (checked >= 3) continue;
  5279. var raw = code.slice(token.start, token.end);
  5280. if (raw[0] === "'") {
  5281. occurences.single++;
  5282. } else {
  5283. occurences.double++;
  5284. }
  5285. checked++;
  5286. }
  5287. if (occurences.single > occurences.double) {
  5288. return "single";
  5289. } else {
  5290. return "double";
  5291. }
  5292. };
  5293. CodeGenerator.prototype.generate = function generate() {
  5294. var ast = this.ast;
  5295. this.print(ast);
  5296. if (ast.comments) {
  5297. var comments = [];
  5298. var _arr = ast.comments;
  5299. for (var _i = 0; _i < _arr.length; _i++) {
  5300. var comment = _arr[_i];
  5301. if (!comment._displayed) comments.push(comment);
  5302. }
  5303. this._printComments(comments);
  5304. }
  5305. return {
  5306. map: this.map.get(),
  5307. code: this.buffer.get()
  5308. };
  5309. };
  5310. CodeGenerator.prototype.buildPrint = function buildPrint(parent) {
  5311. var _this = this;
  5312. var print = function print(node, opts) {
  5313. return _this.print(node, parent, opts);
  5314. };
  5315. print.sequence = function (nodes) {
  5316. var opts = arguments[1] === undefined ? {} : arguments[1];
  5317. opts.statement = true;
  5318. return _this.printJoin(print, nodes, opts);
  5319. };
  5320. print.join = function (nodes, opts) {
  5321. return _this.printJoin(print, nodes, opts);
  5322. };
  5323. print.list = function (items) {
  5324. var opts = arguments[1] === undefined ? {} : arguments[1];
  5325. if (opts.separator == null) opts.separator = ", ";
  5326. print.join(items, opts);
  5327. };
  5328. print.block = function (node) {
  5329. return _this.printBlock(print, node);
  5330. };
  5331. print.indentOnComments = function (node) {
  5332. return _this.printAndIndentOnComments(print, node);
  5333. };
  5334. return print;
  5335. };
  5336. CodeGenerator.prototype.catchUp = function catchUp(node, parent, leftParenPrinted) {
  5337. // catch up to this nodes newline if we're behind
  5338. if (node.loc && this.format.retainLines && this.buffer.buf) {
  5339. var needsParens = false;
  5340. if (!leftParenPrinted && parent && this.position.line < node.loc.start.line && t.isTerminatorless(parent)) {
  5341. needsParens = true;
  5342. this._push("(");
  5343. }
  5344. while (this.position.line < node.loc.start.line) {
  5345. this._push("\n");
  5346. }
  5347. return needsParens;
  5348. }
  5349. return false;
  5350. };
  5351. CodeGenerator.prototype.print = function print(node, parent) {
  5352. var _this2 = this;
  5353. var opts = arguments[2] === undefined ? {} : arguments[2];
  5354. if (!node) return;
  5355. if (parent && parent._compact) {
  5356. node._compact = true;
  5357. }
  5358. var oldConcise = this.format.concise;
  5359. if (node._compact) {
  5360. this.format.concise = true;
  5361. }
  5362. var newline = function newline(leading) {
  5363. if (!opts.statement && !_node2["default"].isUserWhitespacable(node, parent)) {
  5364. return;
  5365. }
  5366. var lines = 0;
  5367. if (node.start != null && !node._ignoreUserWhitespace) {
  5368. // user node
  5369. if (leading) {
  5370. lines = _this2.whitespace.getNewlinesBefore(node);
  5371. } else {
  5372. lines = _this2.whitespace.getNewlinesAfter(node);
  5373. }
  5374. } else {
  5375. // generated node
  5376. if (!leading) lines++; // always include at least a single line after
  5377. if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
  5378. var needs = _node2["default"].needsWhitespaceAfter;
  5379. if (leading) needs = _node2["default"].needsWhitespaceBefore;
  5380. if (needs(node, parent)) lines++;
  5381. // generated nodes can't add starting file whitespace
  5382. if (!_this2.buffer.buf) lines = 0;
  5383. }
  5384. _this2.newline(lines);
  5385. };
  5386. if (this[node.type]) {
  5387. var needsNoLineTermParens = _node2["default"].needsParensNoLineTerminator(node, parent);
  5388. var needsParens = needsNoLineTermParens || _node2["default"].needsParens(node, parent);
  5389. if (needsParens) this.push("(");
  5390. if (needsNoLineTermParens) this.indent();
  5391. this.printLeadingComments(node, parent);
  5392. var needsParensFromCatchup = this.catchUp(node, parent, needsParens);
  5393. newline(true);
  5394. if (opts.before) opts.before();
  5395. this.map.mark(node, "start");
  5396. this[node.type](node, this.buildPrint(node), parent);
  5397. if (needsNoLineTermParens) {
  5398. this.newline();
  5399. this.dedent();
  5400. }
  5401. if (needsParens || needsParensFromCatchup) this.push(")");
  5402. this.map.mark(node, "end");
  5403. if (opts.after) opts.after();
  5404. this.format.concise = oldConcise;
  5405. newline(false);
  5406. this.printTrailingComments(node, parent);
  5407. } else {
  5408. throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
  5409. }
  5410. };
  5411. CodeGenerator.prototype.printJoin = function printJoin(print, nodes) {
  5412. var _this3 = this;
  5413. var opts = arguments[2] === undefined ? {} : arguments[2];
  5414. if (!nodes || !nodes.length) return;
  5415. var len = nodes.length;
  5416. if (opts.indent) this.indent();
  5417. for (var i = 0; i < nodes.length; i++) {
  5418. var node = nodes[i];
  5419. print(node, {
  5420. statement: opts.statement,
  5421. addNewlines: opts.addNewlines,
  5422. after: function after() {
  5423. if (opts.iterator) {
  5424. opts.iterator(node, i);
  5425. }
  5426. if (opts.separator && i < len - 1) {
  5427. _this3.push(opts.separator);
  5428. }
  5429. }
  5430. });
  5431. }
  5432. if (opts.indent) this.dedent();
  5433. };
  5434. CodeGenerator.prototype.printAndIndentOnComments = function printAndIndentOnComments(print, node) {
  5435. var indent = !!node.leadingComments;
  5436. if (indent) this.indent();
  5437. print(node);
  5438. if (indent) this.dedent();
  5439. };
  5440. CodeGenerator.prototype.printBlock = function printBlock(print, node) {
  5441. if (t.isEmptyStatement(node)) {
  5442. this.semicolon();
  5443. } else {
  5444. this.push(" ");
  5445. print(node);
  5446. }
  5447. };
  5448. CodeGenerator.prototype.generateComment = function generateComment(comment) {
  5449. var val = comment.value;
  5450. if (comment.type === "Line") {
  5451. val = "//" + val;
  5452. } else {
  5453. val = "/*" + val + "*/";
  5454. }
  5455. return val;
  5456. };
  5457. CodeGenerator.prototype.printTrailingComments = function printTrailingComments(node, parent) {
  5458. this._printComments(this.getComments("trailingComments", node, parent));
  5459. };
  5460. CodeGenerator.prototype.printLeadingComments = function printLeadingComments(node, parent) {
  5461. this._printComments(this.getComments("leadingComments", node, parent));
  5462. };
  5463. CodeGenerator.prototype.getComments = function getComments(key, node, parent) {
  5464. if (t.isExpressionStatement(parent)) {
  5465. return [];
  5466. }
  5467. var comments = [];
  5468. var nodes = [node];
  5469. if (t.isExpressionStatement(node)) {
  5470. nodes.push(node.argument);
  5471. }
  5472. var _arr2 = nodes;
  5473. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5474. var node = _arr2[_i2];
  5475. comments = comments.concat(this._getComments(key, node));
  5476. }
  5477. return comments;
  5478. };
  5479. CodeGenerator.prototype._getComments = function _getComments(key, node) {
  5480. return node && node[key] || [];
  5481. };
  5482. CodeGenerator.prototype._printComments = function _printComments(comments) {
  5483. if (this.format.compact) return;
  5484. if (!this.format.comments) return;
  5485. if (!comments || !comments.length) return;
  5486. var _arr3 = comments;
  5487. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  5488. var comment = _arr3[_i3];
  5489. var skip = false;
  5490. if (this.ast.comments) {
  5491. // find the original comment in the ast and set it as displayed
  5492. var _arr4 = this.ast.comments;
  5493. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  5494. var origComment = _arr4[_i4];
  5495. if (origComment.start === comment.start) {
  5496. // comment has already been output
  5497. if (origComment._displayed) skip = true;
  5498. origComment._displayed = true;
  5499. break;
  5500. }
  5501. }
  5502. }
  5503. if (skip) return;
  5504. this.catchUp(comment);
  5505. // whitespace before
  5506. this.newline(this.whitespace.getNewlinesBefore(comment));
  5507. var column = this.position.column;
  5508. var val = this.generateComment(comment);
  5509. if (column && !this.isLast(["\n", " ", "[", "{"])) {
  5510. this._push(" ");
  5511. column++;
  5512. }
  5513. //
  5514. if (comment.type === "Block" && this.format.indent.adjustMultilineComment) {
  5515. var offset = comment.loc.start.column;
  5516. if (offset) {
  5517. var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
  5518. val = val.replace(newlineRegex, "\n");
  5519. }
  5520. var indent = Math.max(this.indentSize(), column);
  5521. val = val.replace(/\n/g, "\n" + (0, _repeating2["default"])(" ", indent));
  5522. }
  5523. if (column === 0) {
  5524. val = this.getIndent() + val;
  5525. }
  5526. // force a newline for line comments when retainLines is set in case the next printed node
  5527. // doesn't catch up
  5528. if (this.format.retainLines && comment.type === "Line") {
  5529. val += "\n";
  5530. }
  5531. //
  5532. this._push(val);
  5533. // whitespace after
  5534. this.newline(this.whitespace.getNewlinesAfter(comment));
  5535. }
  5536. };
  5537. _createClass(CodeGenerator, null, [{
  5538. key: "generators",
  5539. value: {
  5540. templateLiterals: require("./generators/template-literals"),
  5541. comprehensions: require("./generators/comprehensions"),
  5542. expressions: require("./generators/expressions"),
  5543. statements: require("./generators/statements"),
  5544. classes: require("./generators/classes"),
  5545. methods: require("./generators/methods"),
  5546. modules: require("./generators/modules"),
  5547. types: require("./generators/types"),
  5548. flow: require("./generators/flow"),
  5549. base: require("./generators/base"),
  5550. jsx: require("./generators/jsx")
  5551. },
  5552. enumerable: true
  5553. }]);
  5554. return CodeGenerator;
  5555. })();
  5556. (0, _lodashCollectionEach2["default"])(_buffer2["default"].prototype, function (fn, key) {
  5557. CodeGenerator.prototype[key] = function () {
  5558. return fn.apply(this.buffer, arguments);
  5559. };
  5560. });
  5561. (0, _lodashCollectionEach2["default"])(CodeGenerator.generators, function (generator) {
  5562. (0, _lodashObjectExtend2["default"])(CodeGenerator.prototype, generator);
  5563. });
  5564. module.exports = function (ast, opts, code) {
  5565. var gen = new CodeGenerator(ast, opts, code);
  5566. return gen.generate();
  5567. };
  5568. module.exports.CodeGenerator = CodeGenerator;
  5569. },{"../messages":47,"../types":169,"./buffer":23,"./generators/base":24,"./generators/classes":25,"./generators/comprehensions":26,"./generators/expressions":27,"./generators/flow":28,"./generators/jsx":29,"./generators/methods":30,"./generators/modules":31,"./generators/statements":32,"./generators/template-literals":33,"./generators/types":34,"./node":36,"./position":39,"./source-map":40,"./whitespace":41,"detect-indent":306,"lodash/collection/each":330,"lodash/object/extend":419,"repeating":479}],36:[function(require,module,exports){
  5570. "use strict";
  5571. exports.__esModule = true;
  5572. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5573. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5574. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5575. var _whitespace = require("./whitespace");
  5576. var _whitespace2 = _interopRequireDefault(_whitespace);
  5577. var _parentheses = require("./parentheses");
  5578. var parens = _interopRequireWildcard(_parentheses);
  5579. var _lodashCollectionEach = require("lodash/collection/each");
  5580. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5581. var _lodashCollectionSome = require("lodash/collection/some");
  5582. var _lodashCollectionSome2 = _interopRequireDefault(_lodashCollectionSome);
  5583. var _types = require("../../types");
  5584. var t = _interopRequireWildcard(_types);
  5585. var find = function find(obj, node, parent) {
  5586. if (!obj) return;
  5587. var result;
  5588. var types = Object.keys(obj);
  5589. for (var i = 0; i < types.length; i++) {
  5590. var type = types[i];
  5591. if (t.is(type, node)) {
  5592. var fn = obj[type];
  5593. result = fn(node, parent);
  5594. if (result != null) break;
  5595. }
  5596. }
  5597. return result;
  5598. };
  5599. var Node = (function () {
  5600. function Node(node, parent) {
  5601. _classCallCheck(this, Node);
  5602. this.parent = parent;
  5603. this.node = node;
  5604. }
  5605. Node.isUserWhitespacable = function isUserWhitespacable(node) {
  5606. return t.isUserWhitespacable(node);
  5607. };
  5608. Node.needsWhitespace = function needsWhitespace(node, parent, type) {
  5609. if (!node) return 0;
  5610. if (t.isExpressionStatement(node)) {
  5611. node = node.expression;
  5612. }
  5613. var linesInfo = find(_whitespace2["default"].nodes, node, parent);
  5614. if (!linesInfo) {
  5615. var items = find(_whitespace2["default"].list, node, parent);
  5616. if (items) {
  5617. for (var i = 0; i < items.length; i++) {
  5618. linesInfo = Node.needsWhitespace(items[i], node, type);
  5619. if (linesInfo) break;
  5620. }
  5621. }
  5622. }
  5623. return linesInfo && linesInfo[type] || 0;
  5624. };
  5625. Node.needsWhitespaceBefore = function needsWhitespaceBefore(node, parent) {
  5626. return Node.needsWhitespace(node, parent, "before");
  5627. };
  5628. Node.needsWhitespaceAfter = function needsWhitespaceAfter(node, parent) {
  5629. return Node.needsWhitespace(node, parent, "after");
  5630. };
  5631. Node.needsParens = function needsParens(node, parent) {
  5632. if (!parent) return false;
  5633. if (t.isNewExpression(parent) && parent.callee === node) {
  5634. if (t.isCallExpression(node)) return true;
  5635. var hasCall = (0, _lodashCollectionSome2["default"])(node, function (val) {
  5636. return t.isCallExpression(val);
  5637. });
  5638. if (hasCall) return true;
  5639. }
  5640. return find(parens, node, parent);
  5641. };
  5642. Node.needsParensNoLineTerminator = function needsParensNoLineTerminator(node, parent) {
  5643. if (!parent) return false;
  5644. // no comments
  5645. if (!node.leadingComments || !node.leadingComments.length) {
  5646. return false;
  5647. }
  5648. return t.isTerminatorless(parent);
  5649. };
  5650. return Node;
  5651. })();
  5652. exports["default"] = Node;
  5653. (0, _lodashCollectionEach2["default"])(Node, function (fn, key) {
  5654. Node.prototype[key] = function () {
  5655. // Avoid leaking arguments to prevent deoptimization
  5656. var args = new Array(arguments.length + 2);
  5657. args[0] = this.node;
  5658. args[1] = this.parent;
  5659. for (var i = 0; i < args.length; i++) {
  5660. args[i + 2] = arguments[i];
  5661. }
  5662. return Node[key].apply(null, args);
  5663. };
  5664. });
  5665. module.exports = exports["default"];
  5666. },{"../../types":169,"./parentheses":37,"./whitespace":38,"lodash/collection/each":330,"lodash/collection/some":335}],37:[function(require,module,exports){
  5667. "use strict";
  5668. exports.__esModule = true;
  5669. exports.NullableTypeAnnotation = NullableTypeAnnotation;
  5670. exports.UpdateExpression = UpdateExpression;
  5671. exports.ObjectExpression = ObjectExpression;
  5672. exports.Binary = Binary;
  5673. exports.BinaryExpression = BinaryExpression;
  5674. exports.SequenceExpression = SequenceExpression;
  5675. exports.YieldExpression = YieldExpression;
  5676. exports.ClassExpression = ClassExpression;
  5677. exports.UnaryLike = UnaryLike;
  5678. exports.FunctionExpression = FunctionExpression;
  5679. exports.ConditionalExpression = ConditionalExpression;
  5680. exports.AssignmentExpression = AssignmentExpression;
  5681. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5682. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5683. var _lodashCollectionEach = require("lodash/collection/each");
  5684. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5685. var _types = require("../../types");
  5686. var t = _interopRequireWildcard(_types);
  5687. var PRECEDENCE = {};
  5688. (0, _lodashCollectionEach2["default"])([["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]], function (tier, i) {
  5689. (0, _lodashCollectionEach2["default"])(tier, function (op) {
  5690. PRECEDENCE[op] = i;
  5691. });
  5692. });
  5693. function NullableTypeAnnotation(node, parent) {
  5694. return t.isArrayTypeAnnotation(parent);
  5695. }
  5696. exports.FunctionTypeAnnotation = NullableTypeAnnotation;
  5697. function UpdateExpression(node, parent) {
  5698. if (t.isMemberExpression(parent) && parent.object === node) {
  5699. // (foo++).test()
  5700. return true;
  5701. }
  5702. }
  5703. function ObjectExpression(node, parent) {
  5704. if (t.isExpressionStatement(parent)) {
  5705. // ({ foo: "bar" });
  5706. return true;
  5707. }
  5708. if (t.isMemberExpression(parent) && parent.object === node) {
  5709. // ({ foo: "bar" }).foo
  5710. return true;
  5711. }
  5712. return false;
  5713. }
  5714. function Binary(node, parent) {
  5715. if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
  5716. return true;
  5717. }
  5718. if (t.isUnaryLike(parent)) {
  5719. return true;
  5720. }
  5721. if (t.isMemberExpression(parent) && parent.object === node) {
  5722. return true;
  5723. }
  5724. if (t.isBinary(parent)) {
  5725. var parentOp = parent.operator;
  5726. var parentPos = PRECEDENCE[parentOp];
  5727. var nodeOp = node.operator;
  5728. var nodePos = PRECEDENCE[nodeOp];
  5729. if (parentPos > nodePos) {
  5730. return true;
  5731. }
  5732. if (parentPos === nodePos && parent.right === node) {
  5733. return true;
  5734. }
  5735. }
  5736. }
  5737. function BinaryExpression(node, parent) {
  5738. if (node.operator === "in") {
  5739. // var i = (1 in []);
  5740. if (t.isVariableDeclarator(parent)) {
  5741. return true;
  5742. }
  5743. // for ((1 in []);;);
  5744. if (t.isFor(parent)) {
  5745. return true;
  5746. }
  5747. }
  5748. }
  5749. function SequenceExpression(node, parent) {
  5750. if (t.isForStatement(parent)) {
  5751. // Although parentheses wouldn't hurt around sequence
  5752. // expressions in the head of for loops, traditional style
  5753. // dictates that e.g. i++, j++ should not be wrapped with
  5754. // parentheses.
  5755. return false;
  5756. }
  5757. if (t.isExpressionStatement(parent) && parent.expression === node) {
  5758. return false;
  5759. }
  5760. // Otherwise err on the side of overparenthesization, adding
  5761. // explicit exceptions above if this proves overzealous.
  5762. return true;
  5763. }
  5764. function YieldExpression(node, parent) {
  5765. return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isConditionalExpression(parent) || t.isYieldExpression(parent);
  5766. }
  5767. function ClassExpression(node, parent) {
  5768. return t.isExpressionStatement(parent);
  5769. }
  5770. function UnaryLike(node, parent) {
  5771. return t.isMemberExpression(parent) && parent.object === node;
  5772. }
  5773. function FunctionExpression(node, parent) {
  5774. // function () {};
  5775. if (t.isExpressionStatement(parent)) {
  5776. return true;
  5777. }
  5778. // (function test() {}).name;
  5779. if (t.isMemberExpression(parent) && parent.object === node) {
  5780. return true;
  5781. }
  5782. // (function () {})();
  5783. if (t.isCallExpression(parent) && parent.callee === node) {
  5784. return true;
  5785. }
  5786. }
  5787. function ConditionalExpression(node, parent) {
  5788. if (t.isUnaryLike(parent)) {
  5789. return true;
  5790. }
  5791. if (t.isBinary(parent)) {
  5792. return true;
  5793. }
  5794. if (t.isCallExpression(parent) || t.isNewExpression(parent)) {
  5795. if (parent.callee === node) {
  5796. return true;
  5797. }
  5798. }
  5799. if (t.isConditionalExpression(parent) && parent.test === node) {
  5800. return true;
  5801. }
  5802. if (t.isMemberExpression(parent) && parent.object === node) {
  5803. return true;
  5804. }
  5805. return false;
  5806. }
  5807. function AssignmentExpression(node) {
  5808. if (t.isObjectPattern(node.left)) {
  5809. return true;
  5810. } else {
  5811. return ConditionalExpression.apply(undefined, arguments);
  5812. }
  5813. }
  5814. },{"../../types":169,"lodash/collection/each":330}],38:[function(require,module,exports){
  5815. "use strict";
  5816. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5817. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5818. var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
  5819. var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
  5820. var _lodashCollectionEach = require("lodash/collection/each");
  5821. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  5822. var _lodashCollectionMap = require("lodash/collection/map");
  5823. var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
  5824. var _types = require("../../types");
  5825. var t = _interopRequireWildcard(_types);
  5826. function crawl(node) {
  5827. var state = arguments[1] === undefined ? {} : arguments[1];
  5828. if (t.isMemberExpression(node)) {
  5829. crawl(node.object, state);
  5830. if (node.computed) crawl(node.property, state);
  5831. } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
  5832. crawl(node.left, state);
  5833. crawl(node.right, state);
  5834. } else if (t.isCallExpression(node)) {
  5835. state.hasCall = true;
  5836. crawl(node.callee, state);
  5837. } else if (t.isFunction(node)) {
  5838. state.hasFunction = true;
  5839. } else if (t.isIdentifier(node)) {
  5840. state.hasHelper = state.hasHelper || isHelper(node.callee);
  5841. }
  5842. return state;
  5843. }
  5844. function isHelper(node) {
  5845. if (t.isMemberExpression(node)) {
  5846. return isHelper(node.object) || isHelper(node.property);
  5847. } else if (t.isIdentifier(node)) {
  5848. return node.name === "require" || node.name[0] === "_";
  5849. } else if (t.isCallExpression(node)) {
  5850. return isHelper(node.callee);
  5851. } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
  5852. return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
  5853. } else {
  5854. return false;
  5855. }
  5856. }
  5857. function isType(node) {
  5858. return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
  5859. }
  5860. exports.nodes = {
  5861. AssignmentExpression: function AssignmentExpression(node) {
  5862. var state = crawl(node.right);
  5863. if (state.hasCall && state.hasHelper || state.hasFunction) {
  5864. return {
  5865. before: state.hasFunction,
  5866. after: true
  5867. };
  5868. }
  5869. },
  5870. SwitchCase: function SwitchCase(node, parent) {
  5871. return {
  5872. before: node.consequent.length || parent.cases[0] === node
  5873. };
  5874. },
  5875. LogicalExpression: function LogicalExpression(node) {
  5876. if (t.isFunction(node.left) || t.isFunction(node.right)) {
  5877. return {
  5878. after: true
  5879. };
  5880. }
  5881. },
  5882. Literal: function Literal(node) {
  5883. if (node.value === "use strict") {
  5884. return {
  5885. after: true
  5886. };
  5887. }
  5888. },
  5889. CallExpression: function CallExpression(node) {
  5890. if (t.isFunction(node.callee) || isHelper(node)) {
  5891. return {
  5892. before: true,
  5893. after: true
  5894. };
  5895. }
  5896. },
  5897. VariableDeclaration: function VariableDeclaration(node) {
  5898. for (var i = 0; i < node.declarations.length; i++) {
  5899. var declar = node.declarations[i];
  5900. var enabled = isHelper(declar.id) && !isType(declar.init);
  5901. if (!enabled) {
  5902. var state = crawl(declar.init);
  5903. enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
  5904. }
  5905. if (enabled) {
  5906. return {
  5907. before: true,
  5908. after: true
  5909. };
  5910. }
  5911. }
  5912. },
  5913. IfStatement: function IfStatement(node) {
  5914. if (t.isBlockStatement(node.consequent)) {
  5915. return {
  5916. before: true,
  5917. after: true
  5918. };
  5919. }
  5920. }
  5921. };
  5922. exports.nodes.Property = exports.nodes.SpreadProperty = function (node, parent) {
  5923. if (parent.properties[0] === node) {
  5924. return {
  5925. before: true
  5926. };
  5927. }
  5928. };
  5929. exports.list = {
  5930. VariableDeclaration: function VariableDeclaration(node) {
  5931. return (0, _lodashCollectionMap2["default"])(node.declarations, "init");
  5932. },
  5933. ArrayExpression: function ArrayExpression(node) {
  5934. return node.elements;
  5935. },
  5936. ObjectExpression: function ObjectExpression(node) {
  5937. return node.properties;
  5938. }
  5939. };
  5940. (0, _lodashCollectionEach2["default"])({
  5941. Function: true,
  5942. Class: true,
  5943. Loop: true,
  5944. LabeledStatement: true,
  5945. SwitchStatement: true,
  5946. TryStatement: true
  5947. }, function (amounts, type) {
  5948. if ((0, _lodashLangIsBoolean2["default"])(amounts)) {
  5949. amounts = { after: amounts, before: amounts };
  5950. }
  5951. (0, _lodashCollectionEach2["default"])([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
  5952. exports.nodes[type] = function () {
  5953. return amounts;
  5954. };
  5955. });
  5956. });
  5957. },{"../../types":169,"lodash/collection/each":330,"lodash/collection/map":333,"lodash/lang/isBoolean":406}],39:[function(require,module,exports){
  5958. "use strict";
  5959. exports.__esModule = true;
  5960. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5961. var Position = (function () {
  5962. function Position() {
  5963. _classCallCheck(this, Position);
  5964. this.line = 1;
  5965. this.column = 0;
  5966. }
  5967. Position.prototype.push = function push(str) {
  5968. for (var i = 0; i < str.length; i++) {
  5969. if (str[i] === "\n") {
  5970. this.line++;
  5971. this.column = 0;
  5972. } else {
  5973. this.column++;
  5974. }
  5975. }
  5976. };
  5977. Position.prototype.unshift = function unshift(str) {
  5978. for (var i = 0; i < str.length; i++) {
  5979. if (str[i] === "\n") {
  5980. this.line--;
  5981. } else {
  5982. this.column--;
  5983. }
  5984. }
  5985. };
  5986. return Position;
  5987. })();
  5988. exports["default"] = Position;
  5989. module.exports = exports["default"];
  5990. },{}],40:[function(require,module,exports){
  5991. "use strict";
  5992. exports.__esModule = true;
  5993. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  5994. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5995. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5996. var _sourceMap = require("source-map");
  5997. var _sourceMap2 = _interopRequireDefault(_sourceMap);
  5998. var _types = require("../types");
  5999. var t = _interopRequireWildcard(_types);
  6000. var SourceMap = (function () {
  6001. function SourceMap(position, opts, code) {
  6002. _classCallCheck(this, SourceMap);
  6003. this.position = position;
  6004. this.opts = opts;
  6005. if (opts.sourceMaps) {
  6006. this.map = new _sourceMap2["default"].SourceMapGenerator({
  6007. file: opts.sourceMapName,
  6008. sourceRoot: opts.sourceRoot
  6009. });
  6010. this.map.setSourceContent(opts.sourceFileName, code);
  6011. } else {
  6012. this.map = null;
  6013. }
  6014. }
  6015. SourceMap.prototype.get = function get() {
  6016. var map = this.map;
  6017. if (map) {
  6018. return map.toJSON();
  6019. } else {
  6020. return map;
  6021. }
  6022. };
  6023. SourceMap.prototype.mark = function mark(node, type) {
  6024. var loc = node.loc;
  6025. if (!loc) return; // no location info
  6026. var map = this.map;
  6027. if (!map) return; // no source map
  6028. if (t.isProgram(node) || t.isFile(node)) return; // illegal mapping nodes
  6029. var position = this.position;
  6030. var generated = {
  6031. line: position.line,
  6032. column: position.column
  6033. };
  6034. var original = loc[type];
  6035. map.addMapping({
  6036. source: this.opts.sourceFileName,
  6037. generated: generated,
  6038. original: original
  6039. });
  6040. };
  6041. return SourceMap;
  6042. })();
  6043. exports["default"] = SourceMap;
  6044. module.exports = exports["default"];
  6045. },{"../types":169,"source-map":483}],41:[function(require,module,exports){
  6046. "use strict";
  6047. exports.__esModule = true;
  6048. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6049. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6050. var _lodashCollectionSortBy = require("lodash/collection/sortBy");
  6051. var _lodashCollectionSortBy2 = _interopRequireDefault(_lodashCollectionSortBy);
  6052. /**
  6053. * Returns `i`th number from `base`, continuing from 0 when `max` is reached.
  6054. * Useful for shifting `for` loop by a fixed number but going over all items.
  6055. *
  6056. * @param {Number} i Current index in the loop
  6057. * @param {Number} base Start index for which to return 0
  6058. * @param {Number} max Array length
  6059. * @returns {Number} shiftedIndex
  6060. */
  6061. function getLookupIndex(i, base, max) {
  6062. i += base;
  6063. if (i >= max) {
  6064. i -= max;
  6065. }
  6066. return i;
  6067. }
  6068. var Whitespace = (function () {
  6069. function Whitespace(tokens, comments) {
  6070. _classCallCheck(this, Whitespace);
  6071. this.tokens = (0, _lodashCollectionSortBy2["default"])(tokens.concat(comments), "start");
  6072. this.used = {};
  6073. // Profiling this code shows that while generator passes over it, indexes
  6074. // returned by `getNewlinesBefore` and `getNewlinesAfter` are always increasing.
  6075. // We use this implementation detail for an optimization: instead of always
  6076. // starting to look from `this.tokens[0]`, we will start `for` loops from the
  6077. // previous successful match. We will enumerate all tokens—but the common
  6078. // case will be much faster.
  6079. this._lastFoundIndex = 0;
  6080. }
  6081. Whitespace.prototype.getNewlinesBefore = function getNewlinesBefore(node) {
  6082. var startToken;
  6083. var endToken;
  6084. var tokens = this.tokens;
  6085. var token;
  6086. for (var j = 0; j < tokens.length; j++) {
  6087. // optimize for forward traversal by shifting for loop index
  6088. var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
  6089. token = tokens[i];
  6090. // this is the token this node starts with
  6091. if (node.start === token.start) {
  6092. startToken = tokens[i - 1];
  6093. endToken = token;
  6094. this._lastFoundIndex = i;
  6095. break;
  6096. }
  6097. }
  6098. return this.getNewlinesBetween(startToken, endToken);
  6099. };
  6100. Whitespace.prototype.getNewlinesAfter = function getNewlinesAfter(node) {
  6101. var startToken;
  6102. var endToken;
  6103. var tokens = this.tokens;
  6104. var token;
  6105. for (var j = 0; j < tokens.length; j++) {
  6106. // optimize for forward traversal by shifting for loop index
  6107. var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
  6108. token = tokens[i];
  6109. // this is the token this node ends with
  6110. if (node.end === token.end) {
  6111. startToken = token;
  6112. endToken = tokens[i + 1];
  6113. this._lastFoundIndex = i;
  6114. break;
  6115. }
  6116. }
  6117. if (endToken && endToken.type.label === "eof") {
  6118. return 1;
  6119. } else {
  6120. var lines = this.getNewlinesBetween(startToken, endToken);
  6121. if (node.type === "Line" && !lines) {
  6122. // line comment
  6123. return 1;
  6124. } else {
  6125. return lines;
  6126. }
  6127. }
  6128. };
  6129. Whitespace.prototype.getNewlinesBetween = function getNewlinesBetween(startToken, endToken) {
  6130. if (!endToken || !endToken.loc) return 0;
  6131. var start = startToken ? startToken.loc.end.line : 1;
  6132. var end = endToken.loc.start.line;
  6133. var lines = 0;
  6134. for (var line = start; line < end; line++) {
  6135. if (typeof this.used[line] === "undefined") {
  6136. this.used[line] = true;
  6137. lines++;
  6138. }
  6139. }
  6140. return lines;
  6141. };
  6142. return Whitespace;
  6143. })();
  6144. exports["default"] = Whitespace;
  6145. module.exports = exports["default"];
  6146. },{"lodash/collection/sortBy":336}],42:[function(require,module,exports){
  6147. "use strict";
  6148. exports.__esModule = true;
  6149. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6150. var _lineNumbers = require("line-numbers");
  6151. var _lineNumbers2 = _interopRequireDefault(_lineNumbers);
  6152. var _repeating = require("repeating");
  6153. var _repeating2 = _interopRequireDefault(_repeating);
  6154. var _jsTokens = require("js-tokens");
  6155. var _jsTokens2 = _interopRequireDefault(_jsTokens);
  6156. var _esutils = require("esutils");
  6157. var _esutils2 = _interopRequireDefault(_esutils);
  6158. var _chalk = require("chalk");
  6159. var _chalk2 = _interopRequireDefault(_chalk);
  6160. var defs = {
  6161. string: _chalk2["default"].red,
  6162. punctuator: _chalk2["default"].bold,
  6163. curly: _chalk2["default"].green,
  6164. parens: _chalk2["default"].blue.bold,
  6165. square: _chalk2["default"].yellow,
  6166. keyword: _chalk2["default"].cyan,
  6167. number: _chalk2["default"].magenta,
  6168. regex: _chalk2["default"].magenta,
  6169. comment: _chalk2["default"].grey,
  6170. invalid: _chalk2["default"].inverse
  6171. };
  6172. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  6173. function getTokenType(match) {
  6174. var token = _jsTokens2["default"].matchToToken(match);
  6175. if (token.type === "name" && _esutils2["default"].keyword.isReservedWordES6(token.value)) {
  6176. return "keyword";
  6177. }
  6178. if (token.type === "punctuator") {
  6179. switch (token.value) {
  6180. case "{":
  6181. case "}":
  6182. return "curly";
  6183. case "(":
  6184. case ")":
  6185. return "parens";
  6186. case "[":
  6187. case "]":
  6188. return "square";
  6189. }
  6190. }
  6191. return token.type;
  6192. }
  6193. function highlight(text) {
  6194. return text.replace(_jsTokens2["default"], function () {
  6195. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  6196. args[_key] = arguments[_key];
  6197. }
  6198. var type = getTokenType(args);
  6199. var colorize = defs[type];
  6200. if (colorize) {
  6201. return args[0].split(NEWLINE).map(function (str) {
  6202. return colorize(str);
  6203. }).join("\n");
  6204. } else {
  6205. return args[0];
  6206. }
  6207. });
  6208. }
  6209. exports["default"] = function (lines, lineNumber, colNumber) {
  6210. var opts = arguments[3] === undefined ? {} : arguments[3];
  6211. colNumber = Math.max(colNumber, 0);
  6212. if (opts.highlightCode && _chalk2["default"].supportsColor) {
  6213. lines = highlight(lines);
  6214. }
  6215. lines = lines.split(NEWLINE);
  6216. var start = Math.max(lineNumber - 3, 0);
  6217. var end = Math.min(lines.length, lineNumber + 3);
  6218. if (!lineNumber && !colNumber) {
  6219. start = 0;
  6220. end = lines.length;
  6221. }
  6222. return (0, _lineNumbers2["default"])(lines.slice(start, end), {
  6223. start: start + 1,
  6224. before: " ",
  6225. after: " | ",
  6226. transform: function transform(params) {
  6227. if (params.number !== lineNumber) {
  6228. return;
  6229. }
  6230. if (colNumber) {
  6231. params.line += "\n" + params.before + "" + (0, _repeating2["default"])(" ", params.width) + "" + params.after + "" + (0, _repeating2["default"])(" ", colNumber - 1) + "^";
  6232. }
  6233. params.before = params.before.replace(/^./, ">");
  6234. }
  6235. }).join("\n");
  6236. };
  6237. ;
  6238. module.exports = exports["default"];
  6239. },{"chalk":217,"esutils":314,"js-tokens":320,"line-numbers":322,"repeating":479}],43:[function(require,module,exports){
  6240. "use strict";
  6241. exports.__esModule = true;
  6242. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6243. var _lodashObjectMerge = require("lodash/object/merge");
  6244. var _lodashObjectMerge2 = _interopRequireDefault(_lodashObjectMerge);
  6245. exports["default"] = function (dest, src) {
  6246. if (!dest || !src) return;
  6247. return (0, _lodashObjectMerge2["default"])(dest, src, function (a, b) {
  6248. if (Array.isArray(a)) {
  6249. var c = a.slice(0);
  6250. for (var _iterator = b, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  6251. var _ref;
  6252. if (_isArray) {
  6253. if (_i >= _iterator.length) break;
  6254. _ref = _iterator[_i++];
  6255. } else {
  6256. _i = _iterator.next();
  6257. if (_i.done) break;
  6258. _ref = _i.value;
  6259. }
  6260. var v = _ref;
  6261. if (a.indexOf(v) < 0) {
  6262. c.push(v);
  6263. }
  6264. }
  6265. return c;
  6266. }
  6267. });
  6268. };
  6269. module.exports = exports["default"];
  6270. },{"lodash/object/merge":423}],44:[function(require,module,exports){
  6271. "use strict";
  6272. exports.__esModule = true;
  6273. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6274. var _types = require("../types");
  6275. var t = _interopRequireWildcard(_types);
  6276. exports["default"] = function (ast, comments, tokens) {
  6277. if (ast && ast.type === "Program") {
  6278. return t.file(ast, comments || [], tokens || []);
  6279. } else {
  6280. throw new Error("Not a valid ast?");
  6281. }
  6282. };
  6283. ;
  6284. module.exports = exports["default"];
  6285. },{"../types":169}],45:[function(require,module,exports){
  6286. "use strict";
  6287. exports.__esModule = true;
  6288. exports["default"] = function () {
  6289. return Object.create(null);
  6290. };
  6291. ;
  6292. module.exports = exports["default"];
  6293. },{}],46:[function(require,module,exports){
  6294. "use strict";
  6295. exports.__esModule = true;
  6296. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6297. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6298. var _normalizeAst = require("./normalize-ast");
  6299. var _normalizeAst2 = _interopRequireDefault(_normalizeAst);
  6300. var _estraverse = require("estraverse");
  6301. var _estraverse2 = _interopRequireDefault(_estraverse);
  6302. var _acorn = require("../../acorn");
  6303. var acorn = _interopRequireWildcard(_acorn);
  6304. exports["default"] = function (code) {
  6305. var opts = arguments[1] === undefined ? {} : arguments[1];
  6306. var comments = [];
  6307. var tokens = [];
  6308. var parseOpts = {
  6309. allowImportExportEverywhere: opts.looseModules,
  6310. allowReturnOutsideFunction: opts.looseModules,
  6311. allowHashBang: true,
  6312. ecmaVersion: 6,
  6313. strictMode: opts.strictMode,
  6314. sourceType: opts.sourceType,
  6315. locations: true,
  6316. onComment: comments,
  6317. features: opts.features || {},
  6318. plugins: opts.plugins || {},
  6319. onToken: tokens,
  6320. ranges: true
  6321. };
  6322. if (opts.nonStandard) {
  6323. parseOpts.plugins.jsx = true;
  6324. parseOpts.plugins.flow = true;
  6325. }
  6326. var ast = acorn.parse(code, parseOpts);
  6327. _estraverse2["default"].attachComments(ast, comments, tokens);
  6328. ast = (0, _normalizeAst2["default"])(ast, comments, tokens);
  6329. return ast;
  6330. };
  6331. module.exports = exports["default"];
  6332. },{"../../acorn":1,"./normalize-ast":44,"estraverse":309}],47:[function(require,module,exports){
  6333. "use strict";
  6334. exports.__esModule = true;
  6335. exports.get = get;
  6336. exports.parseArgs = parseArgs;
  6337. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6338. var _util = require("util");
  6339. var util = _interopRequireWildcard(_util);
  6340. var MESSAGES = {
  6341. tailCallReassignmentDeopt: "Function reference has been reassigned so it's probably be dereferenced so we can't optimise this with confidence",
  6342. JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",
  6343. classesIllegalBareSuper: "Illegal use of bare super",
  6344. classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
  6345. classesIllegalConstructorKind: "Illegal kind for constructor method",
  6346. scopeDuplicateDeclaration: "Duplicate declaration $1",
  6347. undeclaredVariable: "Reference to undeclared variable $1",
  6348. undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
  6349. settersInvalidParamLength: "Setters must have exactly one parameter",
  6350. settersNoRest: "Setters aren't allowed to have a rest",
  6351. noAssignmentsInForHead: "No assignments allowed in for-in/of head",
  6352. expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier",
  6353. invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
  6354. readOnly: "$1 is read-only",
  6355. modulesIllegalExportName: "Illegal export $1",
  6356. unknownForHead: "Unknown node type $1 in ForStatement",
  6357. didYouMean: "Did you mean $1?",
  6358. codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
  6359. missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
  6360. unsupportedOutputType: "Unsupported output type $1",
  6361. illegalMethodName: "Illegal method name $1",
  6362. lostTrackNodePath: "We lost track of this nodes position, likely because the AST was directly manipulated",
  6363. traverseNeedsParent: "Must pass a scope and parentPath unless traversing a Program/File got a $1 node",
  6364. traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",
  6365. traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",
  6366. traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type",
  6367. pluginIllegalKind: "Illegal kind $1 for plugin $2",
  6368. pluginIllegalPosition: "Illegal position $1 for plugin $2",
  6369. pluginKeyCollision: "The plugin $1 collides with another of the same name",
  6370. pluginNotTransformer: "The plugin $1 didn't export a Transformer instance",
  6371. pluginUnknown: "Unknown plugin $1",
  6372. transformerNotFile: "Transformer $1 is resolving to a different Babel version to what is doing the actual transformation..."
  6373. };
  6374. exports.MESSAGES = MESSAGES;
  6375. function get(key) {
  6376. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6377. args[_key - 1] = arguments[_key];
  6378. }
  6379. var msg = MESSAGES[key];
  6380. if (!msg) throw new ReferenceError("Unknown message " + JSON.stringify(key));
  6381. args = parseArgs(args);
  6382. return msg.replace(/\$(\d+)/g, function (str, i) {
  6383. return args[--i];
  6384. });
  6385. }
  6386. function parseArgs(args) {
  6387. return args.map(function (val) {
  6388. if (val != null && val.inspect) {
  6389. return val.inspect();
  6390. } else {
  6391. try {
  6392. return JSON.stringify(val) || val + "";
  6393. } catch (e) {
  6394. return util.inspect(val);
  6395. }
  6396. }
  6397. });
  6398. }
  6399. },{"util":216}],48:[function(require,module,exports){
  6400. "use strict";
  6401. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6402. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6403. var _estraverse = require("estraverse");
  6404. var _estraverse2 = _interopRequireDefault(_estraverse);
  6405. var _lodashObjectExtend = require("lodash/object/extend");
  6406. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  6407. var _astTypes = require("ast-types");
  6408. var _astTypes2 = _interopRequireDefault(_astTypes);
  6409. var _types = require("./types");
  6410. var t = _interopRequireWildcard(_types);
  6411. // estraverse
  6412. (0, _lodashObjectExtend2["default"])(_estraverse2["default"].VisitorKeys, t.VISITOR_KEYS);
  6413. // regenerator/ast-types
  6414. var def = _astTypes2["default"].Type.def;
  6415. var or = _astTypes2["default"].Type.or;
  6416. //def("File")
  6417. // .bases("Node")
  6418. // .build("program")
  6419. // .field("program", def("Program"));
  6420. def("AssignmentPattern").bases("Pattern").build("left", "right").field("left", def("Pattern")).field("right", def("Expression"));
  6421. def("RestElement").bases("Pattern").build("argument").field("argument", def("expression"));
  6422. def("DoExpression").bases("Expression").build("body").field("body", [def("Statement")]);
  6423. def("Super").bases("Expression");
  6424. def("ExportDefaultDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null));
  6425. def("ExportNamedDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null)).field("specifiers", [or(def("ExportSpecifier"))]).field("source", or(def("ModuleSpecifier"), null));
  6426. def("ExportNamespaceSpecifier").bases("Specifier").field("exported", def("Identifier"));
  6427. def("ExportDefaultSpecifier").bases("Specifier").field("exported", def("Identifier"));
  6428. def("ExportAllDeclaration").bases("Declaration").build("exported", "source").field("exported", def("Identifier")).field("source", def("Literal"));
  6429. def("BindExpression").bases("Expression").build("object", "callee").field("object", or(def("Expression"), null)).field("callee", def("Expression"));
  6430. _astTypes2["default"].finalize();
  6431. },{"./types":169,"ast-types":188,"estraverse":309,"lodash/object/extend":419}],49:[function(require,module,exports){
  6432. (function (global){
  6433. "use strict";
  6434. require("core-js/shim");
  6435. require("regenerator/runtime");
  6436. if (global._babelPolyfill) {
  6437. throw new Error("only one instance of babel/polyfill is allowed");
  6438. }
  6439. global._babelPolyfill = true;
  6440. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6441. },{"core-js/shim":302,"regenerator/runtime":472}],50:[function(require,module,exports){
  6442. "use strict";
  6443. exports.__esModule = true;
  6444. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6445. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6446. var _generation = require("../generation");
  6447. var _generation2 = _interopRequireDefault(_generation);
  6448. var _messages = require("../messages");
  6449. var messages = _interopRequireWildcard(_messages);
  6450. var _util = require("../util");
  6451. var util = _interopRequireWildcard(_util);
  6452. var _transformationFile = require("../transformation/file");
  6453. var _transformationFile2 = _interopRequireDefault(_transformationFile);
  6454. var _lodashCollectionEach = require("lodash/collection/each");
  6455. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  6456. var _types = require("../types");
  6457. var t = _interopRequireWildcard(_types);
  6458. function buildGlobal(namespace, builder) {
  6459. var body = [];
  6460. var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
  6461. var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("helper-self-global")]))]);
  6462. body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])))]));
  6463. builder(body);
  6464. return tree;
  6465. }
  6466. function buildUmd(namespace, builder) {
  6467. var body = [];
  6468. body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.identifier("global"))]));
  6469. builder(body);
  6470. var container = util.template("umd-commonjs-strict", {
  6471. FACTORY_PARAMETERS: t.identifier("global"),
  6472. BROWSER_ARGUMENTS: t.assignmentExpression("=", t.memberExpression(t.identifier("root"), namespace), t.objectExpression({})),
  6473. COMMON_ARGUMENTS: t.identifier("exports"),
  6474. AMD_ARGUMENTS: t.arrayExpression([t.literal("exports")]),
  6475. FACTORY_BODY: body,
  6476. UMD_ROOT: t.identifier("this")
  6477. });
  6478. return t.program([container]);
  6479. }
  6480. function buildVar(namespace, builder) {
  6481. var body = [];
  6482. body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.objectExpression({}))]));
  6483. builder(body);
  6484. return t.program(body);
  6485. }
  6486. function buildHelpers(body, namespace, whitelist) {
  6487. (0, _lodashCollectionEach2["default"])(_transformationFile2["default"].helpers, function (name) {
  6488. if (whitelist && whitelist.indexOf(name) === -1) return;
  6489. var key = t.identifier(t.toIdentifier(name));
  6490. body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template("helper-" + name))));
  6491. });
  6492. }
  6493. exports["default"] = function (whitelist) {
  6494. var outputType = arguments[1] === undefined ? "global" : arguments[1];
  6495. var namespace = t.identifier("babelHelpers");
  6496. var builder = function builder(body) {
  6497. return buildHelpers(body, namespace, whitelist);
  6498. };
  6499. var tree;
  6500. var build = ({
  6501. global: buildGlobal,
  6502. umd: buildUmd,
  6503. "var": buildVar
  6504. })[outputType];
  6505. if (build) {
  6506. tree = build(namespace, builder);
  6507. } else {
  6508. throw new Error(messages.get("unsupportedOutputType", outputType));
  6509. }
  6510. return (0, _generation2["default"])(tree).code;
  6511. };
  6512. ;
  6513. module.exports = exports["default"];
  6514. },{"../generation":35,"../messages":47,"../transformation/file":52,"../types":169,"../util":173,"lodash/collection/each":330}],51:[function(require,module,exports){
  6515. "use strict";
  6516. exports.__esModule = true;
  6517. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6518. var _stripJsonComments = require("strip-json-comments");
  6519. var _stripJsonComments2 = _interopRequireDefault(_stripJsonComments);
  6520. var _helpersMerge = require("../helpers/merge");
  6521. var _helpersMerge2 = _interopRequireDefault(_helpersMerge);
  6522. var _path = require("path");
  6523. var _path2 = _interopRequireDefault(_path);
  6524. var _fs = require("fs");
  6525. var _fs2 = _interopRequireDefault(_fs);
  6526. var cache = {};
  6527. var jsons = {};
  6528. function exists(filename) {
  6529. if (!_fs2["default"].existsSync) return false;
  6530. var cached = cache[filename];
  6531. if (cached != null) return cached;
  6532. return cache[filename] = _fs2["default"].existsSync(filename);
  6533. }
  6534. exports["default"] = function (loc) {
  6535. var opts = arguments[1] === undefined ? {} : arguments[1];
  6536. var rel = ".babelrc";
  6537. if (!opts.babelrc) {
  6538. opts.babelrc = [];
  6539. }
  6540. function find(start, rel) {
  6541. var file = _path2["default"].join(start, rel);
  6542. if (opts.babelrc.indexOf(file) >= 0) {
  6543. return;
  6544. }
  6545. if (exists(file)) {
  6546. var content = _fs2["default"].readFileSync(file, "utf8");
  6547. var json;
  6548. try {
  6549. json = jsons[content] = jsons[content] || JSON.parse((0, _stripJsonComments2["default"])(content));
  6550. } catch (err) {
  6551. err.message = "" + file + ": " + err.message;
  6552. throw err;
  6553. }
  6554. opts.babelrc.push(file);
  6555. if (json.breakConfig) return;
  6556. (0, _helpersMerge2["default"])(opts, json);
  6557. }
  6558. var up = _path2["default"].dirname(start);
  6559. if (up !== start) {
  6560. // root
  6561. find(up, rel);
  6562. }
  6563. }
  6564. if (opts.babelrc.indexOf(loc) < 0 && opts.breakConfig !== true) {
  6565. find(loc, rel);
  6566. }
  6567. return opts;
  6568. };
  6569. ;
  6570. module.exports = exports["default"];
  6571. },{"../helpers/merge":43,"fs":189,"path":199,"strip-json-comments":494}],52:[function(require,module,exports){
  6572. (function (process){
  6573. "use strict";
  6574. exports.__esModule = true;
  6575. var _createClass = (function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  6576. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  6577. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6578. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6579. var _convertSourceMap = require("convert-source-map");
  6580. var _convertSourceMap2 = _interopRequireDefault(_convertSourceMap);
  6581. var _optionParsers = require("./option-parsers");
  6582. var optionParsers = _interopRequireWildcard(_optionParsers);
  6583. var _modules = require("../modules");
  6584. var _modules2 = _interopRequireDefault(_modules);
  6585. var _pluginManager = require("./plugin-manager");
  6586. var _pluginManager2 = _interopRequireDefault(_pluginManager);
  6587. var _shebangRegex = require("shebang-regex");
  6588. var _shebangRegex2 = _interopRequireDefault(_shebangRegex);
  6589. var _traversalPath = require("../../traversal/path");
  6590. var _traversalPath2 = _interopRequireDefault(_traversalPath);
  6591. var _transformer = require("../transformer");
  6592. var _transformer2 = _interopRequireDefault(_transformer);
  6593. var _lodashLangIsFunction = require("lodash/lang/isFunction");
  6594. var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
  6595. var _pathIsAbsolute = require("path-is-absolute");
  6596. var _pathIsAbsolute2 = _interopRequireDefault(_pathIsAbsolute);
  6597. var _toolsResolveRc = require("../../tools/resolve-rc");
  6598. var _toolsResolveRc2 = _interopRequireDefault(_toolsResolveRc);
  6599. var _sourceMap = require("source-map");
  6600. var _sourceMap2 = _interopRequireDefault(_sourceMap);
  6601. var _index = require("./../index");
  6602. var _index2 = _interopRequireDefault(_index);
  6603. var _generation = require("../../generation");
  6604. var _generation2 = _interopRequireDefault(_generation);
  6605. var _helpersCodeFrame = require("../../helpers/code-frame");
  6606. var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
  6607. var _lodashObjectDefaults = require("lodash/object/defaults");
  6608. var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
  6609. var _lodashCollectionIncludes = require("lodash/collection/includes");
  6610. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  6611. var _traversal = require("../../traversal");
  6612. var _traversal2 = _interopRequireDefault(_traversal);
  6613. var _lodashObjectAssign = require("lodash/object/assign");
  6614. var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
  6615. var _logger = require("./logger");
  6616. var _logger2 = _interopRequireDefault(_logger);
  6617. var _helpersParse = require("../../helpers/parse");
  6618. var _helpersParse2 = _interopRequireDefault(_helpersParse);
  6619. var _traversalScope = require("../../traversal/scope");
  6620. var _traversalScope2 = _interopRequireDefault(_traversalScope);
  6621. var _helpersMerge = require("../../helpers/merge");
  6622. var _helpersMerge2 = _interopRequireDefault(_helpersMerge);
  6623. var _slash = require("slash");
  6624. var _slash2 = _interopRequireDefault(_slash);
  6625. var _lodashLangClone = require("lodash/lang/clone");
  6626. var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
  6627. var _util = require("../../util");
  6628. var util = _interopRequireWildcard(_util);
  6629. var _apiNode = require("../../api/node");
  6630. var api = _interopRequireWildcard(_apiNode);
  6631. var _path = require("path");
  6632. var _path2 = _interopRequireDefault(_path);
  6633. var _types = require("../../types");
  6634. var t = _interopRequireWildcard(_types);
  6635. var File = (function () {
  6636. function File(_x, pipeline) {
  6637. var opts = arguments[0] === undefined ? {} : arguments[0];
  6638. _classCallCheck(this, File);
  6639. this.transformerDependencies = {};
  6640. this.dynamicImportTypes = {};
  6641. this.dynamicImportIds = {};
  6642. this.dynamicImports = [];
  6643. this.declarations = {};
  6644. this.usedHelpers = {};
  6645. this.dynamicData = {};
  6646. this.metadata = {};
  6647. this.data = {};
  6648. this.pipeline = pipeline;
  6649. this.log = new _logger2["default"](this, opts.filename || "unknown");
  6650. this.opts = this.normalizeOptions(opts);
  6651. this.ast = {};
  6652. this.buildTransformers();
  6653. }
  6654. File.prototype.normalizeOptions = function normalizeOptions(opts) {
  6655. opts = (0, _lodashObjectAssign2["default"])({}, opts);
  6656. if (opts.filename) {
  6657. var rcFilename = opts.filename;
  6658. if (!(0, _pathIsAbsolute2["default"])(rcFilename)) rcFilename = _path2["default"].join(process.cwd(), rcFilename);
  6659. opts = (0, _toolsResolveRc2["default"])(rcFilename, opts);
  6660. }
  6661. //
  6662. for (var key in opts) {
  6663. if (key[0] === "_") continue;
  6664. var option = File.options[key];
  6665. if (!option) this.log.error("Unknown option: " + key, ReferenceError);
  6666. }
  6667. var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development";
  6668. if (opts.env) (0, _helpersMerge2["default"])(opts, opts.env[envKey]);
  6669. for (var key in File.options) {
  6670. var option = File.options[key];
  6671. var val = opts[key];
  6672. if (!val && option.optional) continue;
  6673. if (val && option.deprecated) {
  6674. throw new Error("Deprecated option " + key + ": " + option.deprecated);
  6675. }
  6676. if (val == null) {
  6677. val = (0, _lodashLangClone2["default"])(option["default"]);
  6678. }
  6679. var optionParser = optionParsers[option.type];
  6680. if (optionParser) val = optionParser(key, val, this.pipeline);
  6681. if (option.alias) {
  6682. opts[option.alias] = opts[option.alias] || val;
  6683. } else {
  6684. opts[key] = val;
  6685. }
  6686. }
  6687. if (opts.inputSourceMap) {
  6688. opts.sourceMaps = true;
  6689. }
  6690. // normalize windows path separators to unix
  6691. opts.filename = (0, _slash2["default"])(opts.filename);
  6692. if (opts.sourceRoot) {
  6693. opts.sourceRoot = (0, _slash2["default"])(opts.sourceRoot);
  6694. }
  6695. if (opts.moduleId) {
  6696. opts.moduleIds = true;
  6697. }
  6698. opts.basename = _path2["default"].basename(opts.filename, _path2["default"].extname(opts.filename));
  6699. opts.ignore = util.arrayify(opts.ignore, util.regexify);
  6700. opts.only = util.arrayify(opts.only, util.regexify);
  6701. (0, _lodashObjectDefaults2["default"])(opts, {
  6702. moduleRoot: opts.sourceRoot
  6703. });
  6704. (0, _lodashObjectDefaults2["default"])(opts, {
  6705. sourceRoot: opts.moduleRoot
  6706. });
  6707. (0, _lodashObjectDefaults2["default"])(opts, {
  6708. filenameRelative: opts.filename
  6709. });
  6710. (0, _lodashObjectDefaults2["default"])(opts, {
  6711. sourceFileName: opts.filenameRelative,
  6712. sourceMapName: opts.filenameRelative
  6713. });
  6714. //
  6715. if (opts.externalHelpers) {
  6716. this.set("helpersNamespace", t.identifier("babelHelpers"));
  6717. }
  6718. return opts;
  6719. };
  6720. File.prototype.isLoose = function isLoose(key) {
  6721. return (0, _lodashCollectionIncludes2["default"])(this.opts.loose, key);
  6722. };
  6723. File.prototype.buildTransformers = function buildTransformers() {
  6724. var file = this;
  6725. var transformers = this.transformers = {};
  6726. var secondaryStack = [];
  6727. var stack = [];
  6728. // build internal transformers
  6729. for (var key in this.pipeline.transformers) {
  6730. var transformer = this.pipeline.transformers[key];
  6731. var pass = transformers[key] = transformer.buildPass(file);
  6732. if (pass.canTransform()) {
  6733. stack.push(pass);
  6734. if (transformer.metadata.secondPass) {
  6735. secondaryStack.push(pass);
  6736. }
  6737. if (transformer.manipulateOptions) {
  6738. transformer.manipulateOptions(file.opts, file);
  6739. }
  6740. }
  6741. }
  6742. // init plugins!
  6743. var beforePlugins = [];
  6744. var afterPlugins = [];
  6745. var pluginManager = new _pluginManager2["default"]({
  6746. file: this,
  6747. transformers: this.transformers,
  6748. before: beforePlugins,
  6749. after: afterPlugins
  6750. });
  6751. for (var i = 0; i < file.opts.plugins.length; i++) {
  6752. pluginManager.add(file.opts.plugins[i]);
  6753. }
  6754. stack = beforePlugins.concat(stack, afterPlugins);
  6755. // build transformer stack
  6756. this.uncollapsedTransformerStack = stack = stack.concat(secondaryStack);
  6757. // build dependency graph
  6758. var _arr = stack;
  6759. for (var _i = 0; _i < _arr.length; _i++) {
  6760. var pass = _arr[_i];var _arr2 = pass.transformer.dependencies;
  6761. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  6762. var dep = _arr2[_i2];
  6763. this.transformerDependencies[dep] = pass.key;
  6764. }
  6765. }
  6766. // collapse stack categories
  6767. this.transformerStack = this.collapseStack(stack);
  6768. };
  6769. File.prototype.collapseStack = function collapseStack(_stack) {
  6770. var stack = [];
  6771. var ignore = [];
  6772. var _arr3 = _stack;
  6773. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  6774. var pass = _arr3[_i3];
  6775. // been merged
  6776. if (ignore.indexOf(pass) >= 0) continue;
  6777. var group = pass.transformer.metadata.group;
  6778. // can't merge
  6779. if (!pass.canTransform() || !group) {
  6780. stack.push(pass);
  6781. continue;
  6782. }
  6783. var mergeStack = [];
  6784. var _arr4 = _stack;
  6785. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  6786. var _pass = _arr4[_i4];
  6787. if (_pass.transformer.metadata.group === group) {
  6788. mergeStack.push(_pass);
  6789. ignore.push(_pass);
  6790. }
  6791. }
  6792. var visitors = [];
  6793. var _arr5 = mergeStack;
  6794. for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
  6795. var _pass2 = _arr5[_i5];
  6796. visitors.push(_pass2.handlers);
  6797. }
  6798. var visitor = _traversal2["default"].visitors.merge(visitors);
  6799. var mergeTransformer = new _transformer2["default"](group, visitor);
  6800. //console.log(mergeTransformer);
  6801. stack.push(mergeTransformer.buildPass(this));
  6802. }
  6803. return stack;
  6804. };
  6805. File.prototype.set = function set(key, val) {
  6806. return this.data[key] = val;
  6807. };
  6808. File.prototype.setDynamic = function setDynamic(key, fn) {
  6809. this.dynamicData[key] = fn;
  6810. };
  6811. File.prototype.get = function get(key) {
  6812. var data = this.data[key];
  6813. if (data) {
  6814. return data;
  6815. } else {
  6816. var dynamic = this.dynamicData[key];
  6817. if (dynamic) {
  6818. return this.set(key, dynamic());
  6819. }
  6820. }
  6821. };
  6822. File.prototype.resolveModuleSource = function resolveModuleSource(source) {
  6823. var resolveModuleSource = this.opts.resolveModuleSource;
  6824. if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename);
  6825. return source;
  6826. };
  6827. File.prototype.addImport = function addImport(source, name, type) {
  6828. name = name || source;
  6829. var id = this.dynamicImportIds[name];
  6830. if (!id) {
  6831. source = this.resolveModuleSource(source);
  6832. id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);
  6833. var specifiers = [t.importDefaultSpecifier(id)];
  6834. var declar = t.importDeclaration(specifiers, t.literal(source));
  6835. declar._blockHoist = 3;
  6836. if (type) {
  6837. var modules = this.dynamicImportTypes[type] = this.dynamicImportTypes[type] || [];
  6838. modules.push(declar);
  6839. }
  6840. if (this.transformers["es6.modules"].canTransform()) {
  6841. this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
  6842. this.moduleFormatter.hasLocalImports = true;
  6843. } else {
  6844. this.dynamicImports.push(declar);
  6845. }
  6846. }
  6847. return id;
  6848. };
  6849. File.prototype.attachAuxiliaryComment = function attachAuxiliaryComment(node) {
  6850. var comment = this.opts.auxiliaryComment;
  6851. if (comment) {
  6852. node.leadingComments = node.leadingComments || [];
  6853. node.leadingComments.push({
  6854. type: "Line",
  6855. value: " " + comment
  6856. });
  6857. }
  6858. return node;
  6859. };
  6860. File.prototype.addHelper = function addHelper(name) {
  6861. var isSolo = (0, _lodashCollectionIncludes2["default"])(File.soloHelpers, name);
  6862. if (!isSolo && !(0, _lodashCollectionIncludes2["default"])(File.helpers, name)) {
  6863. throw new ReferenceError("Unknown helper " + name);
  6864. }
  6865. var program = this.ast.program;
  6866. var declar = this.declarations[name];
  6867. if (declar) return declar;
  6868. this.usedHelpers[name] = true;
  6869. if (!isSolo) {
  6870. var generator = this.get("helperGenerator");
  6871. var runtime = this.get("helpersNamespace");
  6872. if (generator) {
  6873. return generator(name);
  6874. } else if (runtime) {
  6875. var id = t.identifier(t.toIdentifier(name));
  6876. return t.memberExpression(runtime, id);
  6877. }
  6878. }
  6879. var ref = util.template("helper-" + name);
  6880. var uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
  6881. if (t.isFunctionExpression(ref) && !ref.id) {
  6882. ref.body._compact = true;
  6883. ref._generated = true;
  6884. ref.id = uid;
  6885. ref.type = "FunctionDeclaration";
  6886. this.attachAuxiliaryComment(ref);
  6887. this.path.unshiftContainer("body", ref);
  6888. } else {
  6889. ref._compact = true;
  6890. this.scope.push({
  6891. id: uid,
  6892. init: ref,
  6893. unique: true
  6894. });
  6895. }
  6896. return uid;
  6897. };
  6898. File.prototype.errorWithNode = function errorWithNode(node, msg) {
  6899. var Error = arguments[2] === undefined ? SyntaxError : arguments[2];
  6900. var loc = node.loc.start;
  6901. var err = new Error("Line " + loc.line + ": " + msg);
  6902. err.loc = loc;
  6903. return err;
  6904. };
  6905. File.prototype.mergeSourceMap = function mergeSourceMap(map) {
  6906. var opts = this.opts;
  6907. var inputMap = opts.inputSourceMap;
  6908. if (inputMap) {
  6909. map.sources[0] = inputMap.file;
  6910. var inputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(inputMap);
  6911. var outputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(map);
  6912. var outputMapGenerator = _sourceMap2["default"].SourceMapGenerator.fromSourceMap(outputMapConsumer);
  6913. outputMapGenerator.applySourceMap(inputMapConsumer);
  6914. var mergedMap = outputMapGenerator.toJSON();
  6915. mergedMap.sources = inputMap.sources;
  6916. mergedMap.file = inputMap.file;
  6917. return mergedMap;
  6918. }
  6919. return map;
  6920. };
  6921. File.prototype.getModuleFormatter = function getModuleFormatter(type) {
  6922. var ModuleFormatter = (0, _lodashLangIsFunction2["default"])(type) ? type : _modules2["default"][type];
  6923. if (!ModuleFormatter) {
  6924. var loc = util.resolveRelative(type);
  6925. if (loc) ModuleFormatter = require(loc);
  6926. }
  6927. if (!ModuleFormatter) {
  6928. throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
  6929. }
  6930. return new ModuleFormatter(this);
  6931. };
  6932. File.prototype.parse = function parse(code) {
  6933. var opts = this.opts;
  6934. //
  6935. var parseOpts = {
  6936. highlightCode: opts.highlightCode,
  6937. nonStandard: opts.nonStandard,
  6938. filename: opts.filename,
  6939. plugins: {}
  6940. };
  6941. var features = parseOpts.features = {};
  6942. for (var key in this.transformers) {
  6943. var transformer = this.transformers[key];
  6944. features[key] = transformer.canTransform();
  6945. }
  6946. parseOpts.looseModules = this.isLoose("es6.modules");
  6947. parseOpts.strictMode = features.strict;
  6948. parseOpts.sourceType = "module";
  6949. this.log.debug("Parse start");
  6950. var tree = (0, _helpersParse2["default"])(code, parseOpts);
  6951. this.log.debug("Parse stop");
  6952. return tree;
  6953. };
  6954. File.prototype._addAst = function _addAst(ast) {
  6955. this.path = _traversalPath2["default"].get(null, ast, ast, "program", this).setContext(null, this);
  6956. this.scope = this.path.scope;
  6957. this.ast = ast;
  6958. };
  6959. File.prototype.addAst = function addAst(ast) {
  6960. this.log.debug("Start set AST");
  6961. this._addAst(ast);
  6962. this.log.debug("End set AST");
  6963. this.log.debug("Start module formatter init");
  6964. var modFormatter = this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
  6965. if (modFormatter.init && this.transformers["es6.modules"].canTransform()) {
  6966. modFormatter.init();
  6967. }
  6968. this.log.debug("End module formatter init");
  6969. this.call("pre");
  6970. var _arr6 = this.transformerStack;
  6971. for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
  6972. var pass = _arr6[_i6];
  6973. pass.transform();
  6974. }
  6975. this.call("post");
  6976. };
  6977. File.prototype.wrap = function wrap(code, callback) {
  6978. code = code + "";
  6979. try {
  6980. if (this.shouldIgnore()) {
  6981. return {
  6982. metadata: this.metadata,
  6983. ignored: true,
  6984. code: code,
  6985. map: null,
  6986. ast: null
  6987. };
  6988. }
  6989. callback();
  6990. return this.generate();
  6991. } catch (err) {
  6992. if (err._babel) {
  6993. throw err;
  6994. } else {
  6995. err._babel = true;
  6996. }
  6997. var message = err.message = "" + this.opts.filename + ": " + err.message;
  6998. var loc = err.loc;
  6999. if (loc) {
  7000. err.codeFrame = (0, _helpersCodeFrame2["default"])(code, loc.line, loc.column + 1, this.opts);
  7001. message += "\n" + err.codeFrame;
  7002. }
  7003. if (err.stack) {
  7004. var newStack = err.stack.replace(err.message, message);
  7005. try {
  7006. err.stack = newStack;
  7007. } catch (e) {}
  7008. }
  7009. throw err;
  7010. }
  7011. };
  7012. File.prototype.addCode = function addCode(code, parseCode) {
  7013. code = (code || "") + "";
  7014. code = this.parseInputSourceMap(code);
  7015. this.code = code;
  7016. if (parseCode) {
  7017. this.parseShebang();
  7018. this.addAst(this.parse(this.code));
  7019. }
  7020. };
  7021. File.prototype.shouldIgnore = function shouldIgnore() {
  7022. var opts = this.opts;
  7023. return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
  7024. };
  7025. File.prototype.call = function call(key) {
  7026. var _arr7 = this.uncollapsedTransformerStack;
  7027. for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
  7028. var pass = _arr7[_i7];
  7029. var fn = pass.transformer[key];
  7030. if (fn) fn(this);
  7031. }
  7032. };
  7033. File.prototype.parseInputSourceMap = function parseInputSourceMap(code) {
  7034. var opts = this.opts;
  7035. if (opts.inputSourceMap !== false) {
  7036. var inputMap = _convertSourceMap2["default"].fromSource(code);
  7037. if (inputMap) {
  7038. opts.inputSourceMap = inputMap.toObject();
  7039. code = _convertSourceMap2["default"].removeComments(code);
  7040. }
  7041. }
  7042. return code;
  7043. };
  7044. File.prototype.parseShebang = function parseShebang() {
  7045. var shebangMatch = _shebangRegex2["default"].exec(this.code);
  7046. if (shebangMatch) {
  7047. this.shebang = shebangMatch[0];
  7048. this.code = this.code.replace(_shebangRegex2["default"], "");
  7049. }
  7050. };
  7051. File.prototype.generate = function generate() {
  7052. var opts = this.opts;
  7053. var ast = this.ast;
  7054. var result = {
  7055. metadata: this.metadata,
  7056. code: "",
  7057. map: null,
  7058. ast: null
  7059. };
  7060. if (this.opts.metadataUsedHelpers) {
  7061. result.metadata.usedHelpers = Object.keys(this.usedHelpers);
  7062. }
  7063. if (opts.ast) result.ast = ast;
  7064. if (!opts.code) return result;
  7065. this.log.debug("Generation start");
  7066. var _result = (0, _generation2["default"])(ast, opts, this.code);
  7067. result.code = _result.code;
  7068. result.map = _result.map;
  7069. this.log.debug("Generation end");
  7070. if (this.shebang) {
  7071. // add back shebang
  7072. result.code = "" + this.shebang + "\n" + result.code;
  7073. }
  7074. if (result.map) {
  7075. result.map = this.mergeSourceMap(result.map);
  7076. }
  7077. if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
  7078. result.code += "\n" + _convertSourceMap2["default"].fromObject(result.map).toComment();
  7079. }
  7080. if (opts.sourceMaps === "inline") {
  7081. result.map = null;
  7082. }
  7083. return result;
  7084. };
  7085. _createClass(File, null, [{
  7086. key: "helpers",
  7087. value: ["inherits", "defaults", "create-class", "create-decorated-class", "create-decorated-object", "define-decorated-property-descriptor", "tagged-template-literal", "tagged-template-literal-loose", "to-array", "to-consumable-array", "sliced-to-array", "sliced-to-array-loose", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-require-wildcard", "interop-require-default", "typeof", "extends", "get", "set", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global", "default-props", "instanceof",
  7088. // legacy
  7089. "interop-require"],
  7090. enumerable: true
  7091. }, {
  7092. key: "soloHelpers",
  7093. value: [],
  7094. enumerable: true
  7095. }, {
  7096. key: "options",
  7097. value: require("./options"),
  7098. enumerable: true
  7099. }]);
  7100. return File;
  7101. })();
  7102. exports["default"] = File;
  7103. module.exports = exports["default"];
  7104. // `err.stack` may be a readonly property in some environments
  7105. }).call(this,require('_process'))
  7106. },{"../../api/node":20,"../../generation":35,"../../helpers/code-frame":42,"../../helpers/merge":43,"../../helpers/parse":46,"../../tools/resolve-rc":51,"../../traversal":157,"../../traversal/path":161,"../../traversal/scope":164,"../../types":169,"../../util":173,"../modules":79,"../transformer":85,"./../index":71,"./logger":53,"./option-parsers":54,"./options":55,"./plugin-manager":56,"_process":200,"convert-source-map":225,"lodash/collection/includes":332,"lodash/lang/clone":402,"lodash/lang/isFunction":408,"lodash/object/assign":417,"lodash/object/defaults":418,"path":199,"path-is-absolute":434,"shebang-regex":481,"slash":482,"source-map":483}],53:[function(require,module,exports){
  7107. "use strict";
  7108. exports.__esModule = true;
  7109. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7110. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7111. var _debugNode = require("debug/node");
  7112. var _debugNode2 = _interopRequireDefault(_debugNode);
  7113. var verboseDebug = (0, _debugNode2["default"])("babel:verbose");
  7114. var generalDebug = (0, _debugNode2["default"])("babel");
  7115. var Logger = (function () {
  7116. function Logger(file, filename) {
  7117. _classCallCheck(this, Logger);
  7118. this.filename = filename;
  7119. this.file = file;
  7120. }
  7121. Logger.prototype._buildMessage = function _buildMessage(msg) {
  7122. var parts = "[BABEL] " + this.filename;
  7123. if (msg) parts += ": " + msg;
  7124. return parts;
  7125. };
  7126. Logger.prototype.error = function error(msg) {
  7127. var Constructor = arguments[1] === undefined ? Error : arguments[1];
  7128. throw new Constructor(this._buildMessage(msg));
  7129. };
  7130. Logger.prototype.deprecate = function deprecate(msg) {
  7131. if (!this.file.opts.suppressDeprecationMessages) {
  7132. console.error(this._buildMessage(msg));
  7133. }
  7134. };
  7135. Logger.prototype.verbose = function verbose(msg) {
  7136. if (verboseDebug.enabled) verboseDebug(this._buildMessage(msg));
  7137. };
  7138. Logger.prototype.debug = function debug(msg) {
  7139. if (generalDebug.enabled) generalDebug(this._buildMessage(msg));
  7140. };
  7141. Logger.prototype.deopt = function deopt(node, msg) {
  7142. this.debug(msg);
  7143. };
  7144. return Logger;
  7145. })();
  7146. exports["default"] = Logger;
  7147. module.exports = exports["default"];
  7148. },{"debug/node":304}],54:[function(require,module,exports){
  7149. "use strict";
  7150. exports.__esModule = true;
  7151. exports.transformerList = transformerList;
  7152. exports.number = number;
  7153. exports.boolean = boolean;
  7154. exports.booleanString = booleanString;
  7155. exports.list = list;
  7156. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7157. var _util = require("../../util");
  7158. var util = _interopRequireWildcard(_util);
  7159. function transformerList(key, val, pipeline) {
  7160. val = util.arrayify(val);
  7161. if (val.indexOf("all") >= 0 || val.indexOf(true) >= 0) {
  7162. val = Object.keys(pipeline.transformers);
  7163. }
  7164. return pipeline._ensureTransformerNames(key, val);
  7165. }
  7166. function number(key, val) {
  7167. return +val;
  7168. }
  7169. function boolean(key, val) {
  7170. return !!val;
  7171. }
  7172. function booleanString(key, val) {
  7173. return util.booleanify(val);
  7174. }
  7175. function list(key, val) {
  7176. return util.list(val);
  7177. }
  7178. },{"../../util":173}],55:[function(require,module,exports){
  7179. module.exports={
  7180. "filename": {
  7181. "type": "string",
  7182. "description": "filename to use when reading from stdin - this will be used in source-maps, errors etc",
  7183. "default": "unknown",
  7184. "shorthand": "f"
  7185. },
  7186. "filenameRelative": {
  7187. "hidden": true,
  7188. "type": "string"
  7189. },
  7190. "inputSourceMap": {
  7191. "hidden": true
  7192. },
  7193. "extra": {
  7194. "hidden": true,
  7195. "default": {}
  7196. },
  7197. "env": {
  7198. "hidden": true,
  7199. "default": {}
  7200. },
  7201. "moduleId": {
  7202. "description": "specify a custom name for module ids",
  7203. "type": "string"
  7204. },
  7205. "getModuleId": {
  7206. "hidden": true
  7207. },
  7208. "retainLines": {
  7209. "type": "boolean",
  7210. "default": false,
  7211. "description": "retain line numbers - will result in really ugly code"
  7212. },
  7213. "nonStandard": {
  7214. "type": "boolean",
  7215. "default": true,
  7216. "description": "enable support for JSX and Flow"
  7217. },
  7218. "experimental": {
  7219. "deprecated": "use `--stage 0`/`{ stage: 0 }` instead"
  7220. },
  7221. "highlightCode": {
  7222. "description": "ANSI syntax highlight code frames",
  7223. "type": "boolean",
  7224. "default": true
  7225. },
  7226. "suppressDeprecationMessages": {
  7227. "type": "boolean",
  7228. "default": false,
  7229. "hidden": true
  7230. },
  7231. "resolveModuleSource": {
  7232. "hidden": true
  7233. },
  7234. "stage": {
  7235. "description": "ECMAScript proposal stage version to allow [0-4]",
  7236. "shorthand": "e",
  7237. "type": "number",
  7238. "default": 2
  7239. },
  7240. "blacklist": {
  7241. "type": "transformerList",
  7242. "description": "blacklist of transformers to NOT use",
  7243. "shorthand": "b"
  7244. },
  7245. "whitelist": {
  7246. "type": "transformerList",
  7247. "optional": true,
  7248. "description": "whitelist of transformers to ONLY use",
  7249. "shorthand": "l"
  7250. },
  7251. "optional": {
  7252. "type": "transformerList",
  7253. "description": "list of optional transformers to enable"
  7254. },
  7255. "modules": {
  7256. "type": "string",
  7257. "description": "module formatter type to use [common]",
  7258. "default": "common",
  7259. "shorthand": "m"
  7260. },
  7261. "moduleIds": {
  7262. "type": "boolean",
  7263. "default": false,
  7264. "shorthand": "M",
  7265. "description": "insert an explicit id for modules"
  7266. },
  7267. "loose": {
  7268. "type": "transformerList",
  7269. "description": "list of transformers to enable loose mode ON",
  7270. "shorthand": "L"
  7271. },
  7272. "jsxPragma": {
  7273. "type": "string",
  7274. "description": "custom pragma to use with JSX (same functionality as @jsx comments)",
  7275. "default": "React.createElement",
  7276. "shorthand": "P"
  7277. },
  7278. "plugins": {
  7279. "type": "list",
  7280. "description": ""
  7281. },
  7282. "ignore": {
  7283. "type": "list",
  7284. "description": "list of glob paths to **not** compile"
  7285. },
  7286. "only": {
  7287. "type": "list",
  7288. "description": "list of glob paths to **only** compile"
  7289. },
  7290. "code": {
  7291. "hidden": true,
  7292. "default": true,
  7293. "type": "boolean"
  7294. },
  7295. "ast": {
  7296. "hidden": true,
  7297. "default": true,
  7298. "type": "boolean"
  7299. },
  7300. "comments": {
  7301. "type": "boolean",
  7302. "default": true,
  7303. "description": "output comments in generated output"
  7304. },
  7305. "compact": {
  7306. "type": "booleanString",
  7307. "default": "auto",
  7308. "description": "do not include superfluous whitespace characters and line terminators [true|false|auto]"
  7309. },
  7310. "keepModuleIdExtensions": {
  7311. "type": "boolean",
  7312. "description": "keep extensions when generating module ids",
  7313. "default": false,
  7314. "shorthand": "k"
  7315. },
  7316. "auxiliaryComment": {
  7317. "type": "string",
  7318. "default": "",
  7319. "shorthand": "a",
  7320. "description": "attach a comment before all helper declarations and auxiliary code"
  7321. },
  7322. "externalHelpers": {
  7323. "type": "boolean",
  7324. "default": false,
  7325. "shorthand": "r",
  7326. "description": "uses a reference to `babelHelpers` instead of placing helpers at the top of your code."
  7327. },
  7328. "metadataUsedHelpers": {
  7329. "type": "boolean",
  7330. "default": false,
  7331. "hidden": true
  7332. },
  7333. "sourceMap": {
  7334. "alias": "sourceMaps",
  7335. "hidden": true
  7336. },
  7337. "sourceMaps": {
  7338. "type": "booleanString",
  7339. "description": "[true|false|inline]",
  7340. "default": false,
  7341. "shorthand": "s"
  7342. },
  7343. "sourceMapName": {
  7344. "type": "string",
  7345. "description": "set `file` on returned source map"
  7346. },
  7347. "sourceFileName": {
  7348. "type": "string",
  7349. "description": "set `sources[0]` on returned source map"
  7350. },
  7351. "sourceRoot": {
  7352. "type": "string",
  7353. "description": "the root from which all sources are relative"
  7354. },
  7355. "moduleRoot": {
  7356. "type": "string",
  7357. "description": "optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"
  7358. },
  7359. "breakConfig": {
  7360. "type": "boolean",
  7361. "default": false,
  7362. "hidden": true,
  7363. "description": "stop trying to load .babelrc files"
  7364. },
  7365. "babelrc": {
  7366. "hidden": true,
  7367. "description": "do not load the same .babelrc file twice"
  7368. }
  7369. }
  7370. },{}],56:[function(require,module,exports){
  7371. "use strict";
  7372. exports.__esModule = true;
  7373. var _createClass = (function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  7374. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7375. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7376. var _apiNode = require("../../api/node");
  7377. var node = _interopRequireWildcard(_apiNode);
  7378. var _messages = require("../../messages");
  7379. var messages = _interopRequireWildcard(_messages);
  7380. var _util = require("../../util");
  7381. var util = _interopRequireWildcard(_util);
  7382. var PluginManager = (function () {
  7383. function PluginManager() {
  7384. var _ref = arguments[0] === undefined ? { transformers: {}, before: [], after: [] } : arguments[0];
  7385. var file = _ref.file;
  7386. var transformers = _ref.transformers;
  7387. var before = _ref.before;
  7388. var after = _ref.after;
  7389. _classCallCheck(this, PluginManager);
  7390. this.transformers = transformers;
  7391. this.file = file;
  7392. this.before = before;
  7393. this.after = after;
  7394. }
  7395. PluginManager.memoisePluginContainer = function memoisePluginContainer(fn) {
  7396. for (var i = 0; i < PluginManager.memoisedPlugins.length; i++) {
  7397. var plugin = PluginManager.memoisedPlugins[i];
  7398. if (plugin.container === fn) return plugin.transformer;
  7399. }
  7400. var transformer = fn(node);
  7401. PluginManager.memoisedPlugins.push({
  7402. container: fn,
  7403. transformer: transformer
  7404. });
  7405. return transformer;
  7406. };
  7407. PluginManager.prototype.subnormaliseString = function subnormaliseString(name, position) {
  7408. // this is a plugin in the form of "foobar" or "foobar:after"
  7409. // where the optional colon is the delimiter for plugin position in the transformer stack
  7410. var match = name.match(/^(.*?):(after|before)$/);
  7411. if (match) {
  7412. ;
  7413. var _temp = match;
  7414. name = _temp[1];
  7415. position = _temp[2];
  7416. _temp;
  7417. }var loc = util.resolveRelative(name) || util.resolveRelative("babel-plugin-" + name);
  7418. if (loc) {
  7419. return {
  7420. position: position,
  7421. plugin: require(loc)
  7422. };
  7423. } else {
  7424. throw new ReferenceError(messages.get("pluginUnknown", name));
  7425. }
  7426. };
  7427. PluginManager.prototype.validate = function validate(name, plugin) {
  7428. // validate transformer key
  7429. var key = plugin.key;
  7430. if (this.transformers[key]) {
  7431. throw new ReferenceError(messages.get("pluginKeyCollision", key));
  7432. }
  7433. // validate Transformer instance
  7434. if (!plugin.buildPass || plugin.constructor.name !== "Transformer") {
  7435. throw new TypeError(messages.get("pluginNotTransformer", name));
  7436. }
  7437. // register as a plugin
  7438. plugin.metadata.plugin = true;
  7439. };
  7440. PluginManager.prototype.add = function add(name) {
  7441. var position;
  7442. var plugin;
  7443. if (name) {
  7444. if (typeof name === "object" && name.transformer) {
  7445. var _temp2 = name;
  7446. plugin = _temp2.transformer;
  7447. position = _temp2.position;
  7448. _temp2;
  7449. } else if (typeof name !== "string") {
  7450. // not a string so we'll just assume that it's a direct Transformer instance, if not then
  7451. // the checks later on will complain
  7452. plugin = name;
  7453. }
  7454. if (typeof name === "string") {
  7455. var _temp3 = this.subnormaliseString(name, position);
  7456. plugin = _temp3.plugin;
  7457. position = _temp3.position;
  7458. _temp3;
  7459. }
  7460. } else {
  7461. throw new TypeError(messages.get("pluginIllegalKind", typeof name, name));
  7462. }
  7463. // default position
  7464. position = position || "before";
  7465. // validate position
  7466. if (PluginManager.positions.indexOf(position) < 0) {
  7467. throw new TypeError(messages.get("pluginIllegalPosition", position, name));
  7468. }
  7469. // allow plugin containers to be specified so they don't have to manually require
  7470. if (typeof plugin === "function") {
  7471. plugin = PluginManager.memoisePluginContainer(plugin);
  7472. }
  7473. //
  7474. this.validate(name, plugin);
  7475. // build!
  7476. var pass = this.transformers[plugin.key] = plugin.buildPass(this.file);
  7477. if (pass.canTransform()) {
  7478. var stack = position === "before" ? this.before : this.after;
  7479. stack.push(pass);
  7480. }
  7481. };
  7482. _createClass(PluginManager, null, [{
  7483. key: "memoisedPlugins",
  7484. value: [],
  7485. enumerable: true
  7486. }, {
  7487. key: "positions",
  7488. value: ["before", "after"],
  7489. enumerable: true
  7490. }]);
  7491. return PluginManager;
  7492. })();
  7493. exports["default"] = PluginManager;
  7494. module.exports = exports["default"];
  7495. },{"../../api/node":20,"../../messages":47,"../../util":173}],57:[function(require,module,exports){
  7496. "use strict";
  7497. exports.__esModule = true;
  7498. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7499. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7500. var _explodeAssignableExpression = require("./explode-assignable-expression");
  7501. var _explodeAssignableExpression2 = _interopRequireDefault(_explodeAssignableExpression);
  7502. var _types = require("../../types");
  7503. var t = _interopRequireWildcard(_types);
  7504. exports["default"] = function (opts) {
  7505. var exports = {};
  7506. var isAssignment = function isAssignment(node) {
  7507. return node.operator === opts.operator + "=";
  7508. };
  7509. var buildAssignment = function buildAssignment(left, right) {
  7510. return t.assignmentExpression("=", left, right);
  7511. };
  7512. exports.ExpressionStatement = function (node, parent, scope, file) {
  7513. // hit the `AssignmentExpression` one below
  7514. if (this.isCompletionRecord()) return;
  7515. var expr = node.expression;
  7516. if (!isAssignment(expr)) return;
  7517. var nodes = [];
  7518. var exploded = (0, _explodeAssignableExpression2["default"])(expr.left, nodes, file, scope, true);
  7519. nodes.push(t.expressionStatement(buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))));
  7520. return nodes;
  7521. };
  7522. exports.AssignmentExpression = function (node, parent, scope, file) {
  7523. if (!isAssignment(node)) return;
  7524. var nodes = [];
  7525. var exploded = (0, _explodeAssignableExpression2["default"])(node.left, nodes, file, scope);
  7526. nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
  7527. return nodes;
  7528. };
  7529. exports.BinaryExpression = function (node) {
  7530. if (node.operator !== opts.operator) return;
  7531. return opts.build(node.left, node.right);
  7532. };
  7533. return exports;
  7534. };
  7535. ;
  7536. module.exports = exports["default"];
  7537. },{"../../types":169,"./explode-assignable-expression":62}],58:[function(require,module,exports){
  7538. "use strict";
  7539. exports.__esModule = true;
  7540. exports["default"] = build;
  7541. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7542. var _types = require("../../types");
  7543. var t = _interopRequireWildcard(_types);
  7544. function build(node, buildBody) {
  7545. var self = node.blocks.shift();
  7546. if (!self) return;
  7547. var child = build(node, buildBody);
  7548. if (!child) {
  7549. // last item
  7550. child = buildBody();
  7551. // add a filter as this is our final stop
  7552. if (node.filter) {
  7553. child = t.ifStatement(node.filter, t.blockStatement([child]));
  7554. }
  7555. }
  7556. return t.forOfStatement(t.variableDeclaration("let", [t.variableDeclarator(self.left)]), self.right, t.blockStatement([child]));
  7557. }
  7558. module.exports = exports["default"];
  7559. },{"../../types":169}],59:[function(require,module,exports){
  7560. // Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
  7561. // https://github.com/RReverser/jsx-transpiler
  7562. // jsx
  7563. "use strict";
  7564. exports.__esModule = true;
  7565. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7566. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7567. var _lodashLangIsString = require("lodash/lang/isString");
  7568. var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
  7569. var _messages = require("../../messages");
  7570. var messages = _interopRequireWildcard(_messages);
  7571. var _esutils = require("esutils");
  7572. var _esutils2 = _interopRequireDefault(_esutils);
  7573. var _react = require("./react");
  7574. var react = _interopRequireWildcard(_react);
  7575. var _types = require("../../types");
  7576. var t = _interopRequireWildcard(_types);
  7577. exports["default"] = function (exports, opts) {
  7578. exports.JSXIdentifier = function (node, parent) {
  7579. if (node.name === "this" && this.isReferenced()) {
  7580. return t.thisExpression();
  7581. } else if (_esutils2["default"].keyword.isIdentifierNameES6(node.name)) {
  7582. node.type = "Identifier";
  7583. } else {
  7584. return t.literal(node.name);
  7585. }
  7586. };
  7587. exports.JSXNamespacedName = function (node, parent, scope, file) {
  7588. throw this.errorWithNode(messages.get("JSXNamespacedTags"));
  7589. };
  7590. exports.JSXMemberExpression = {
  7591. exit: function exit(node) {
  7592. node.computed = t.isLiteral(node.property);
  7593. node.type = "MemberExpression";
  7594. }
  7595. };
  7596. exports.JSXExpressionContainer = function (node) {
  7597. return node.expression;
  7598. };
  7599. exports.JSXAttribute = {
  7600. enter: function enter(node) {
  7601. var value = node.value;
  7602. if (t.isLiteral(value) && (0, _lodashLangIsString2["default"])(value.value)) {
  7603. value.value = value.value.replace(/\n\s+/g, " ");
  7604. }
  7605. },
  7606. exit: function exit(node) {
  7607. var value = node.value || t.literal(true);
  7608. return t.inherits(t.property("init", node.name, value), node);
  7609. }
  7610. };
  7611. exports.JSXOpeningElement = {
  7612. exit: function exit(node, parent, scope, file) {
  7613. parent.children = react.buildChildren(parent);
  7614. var tagExpr = node.name;
  7615. var args = [];
  7616. var tagName;
  7617. if (t.isIdentifier(tagExpr)) {
  7618. tagName = tagExpr.name;
  7619. } else if (t.isLiteral(tagExpr)) {
  7620. tagName = tagExpr.value;
  7621. }
  7622. var state = {
  7623. tagExpr: tagExpr,
  7624. tagName: tagName,
  7625. args: args
  7626. };
  7627. if (opts.pre) {
  7628. opts.pre(state, file);
  7629. }
  7630. var attribs = node.attributes;
  7631. if (attribs.length) {
  7632. attribs = buildJSXOpeningElementAttributes(attribs, file);
  7633. } else {
  7634. attribs = t.literal(null);
  7635. }
  7636. args.push(attribs);
  7637. if (opts.post) {
  7638. opts.post(state, file);
  7639. }
  7640. return state.call || t.callExpression(state.callee, args);
  7641. }
  7642. };
  7643. /**
  7644. * The logic for this is quite terse. It's because we need to
  7645. * support spread elements. We loop over all attributes,
  7646. * breaking on spreads, we then push a new object containg
  7647. * all prior attributes to an array for later processing.
  7648. */
  7649. var buildJSXOpeningElementAttributes = function buildJSXOpeningElementAttributes(attribs, file) {
  7650. var _props = [];
  7651. var objs = [];
  7652. var pushProps = function pushProps() {
  7653. if (!_props.length) return;
  7654. objs.push(t.objectExpression(_props));
  7655. _props = [];
  7656. };
  7657. while (attribs.length) {
  7658. var prop = attribs.shift();
  7659. if (t.isJSXSpreadAttribute(prop)) {
  7660. pushProps();
  7661. objs.push(prop.argument);
  7662. } else {
  7663. _props.push(prop);
  7664. }
  7665. }
  7666. pushProps();
  7667. if (objs.length === 1) {
  7668. // only one object
  7669. attribs = objs[0];
  7670. } else {
  7671. // looks like we have multiple objects
  7672. if (!t.isObjectExpression(objs[0])) {
  7673. objs.unshift(t.objectExpression([]));
  7674. }
  7675. // spread it
  7676. attribs = t.callExpression(file.addHelper("extends"), objs);
  7677. }
  7678. return attribs;
  7679. };
  7680. exports.JSXElement = {
  7681. exit: function exit(node) {
  7682. var callExpr = node.openingElement;
  7683. callExpr.arguments = callExpr.arguments.concat(node.children);
  7684. if (callExpr.arguments.length >= 3) {
  7685. callExpr._prettyCall = true;
  7686. }
  7687. return t.inherits(callExpr, node);
  7688. }
  7689. };
  7690. // display names
  7691. var addDisplayName = function addDisplayName(id, call) {
  7692. var props = call.arguments[0].properties;
  7693. var safe = true;
  7694. for (var i = 0; i < props.length; i++) {
  7695. var prop = props[i];
  7696. if (t.isIdentifier(prop.key, { name: "displayName" })) {
  7697. safe = false;
  7698. break;
  7699. }
  7700. }
  7701. if (safe) {
  7702. props.unshift(t.property("init", t.identifier("displayName"), t.literal(id)));
  7703. }
  7704. };
  7705. exports.ExportDefaultDeclaration = function (node, parent, scope, file) {
  7706. if (react.isCreateClass(node.declaration)) {
  7707. addDisplayName(file.opts.basename, node.declaration);
  7708. }
  7709. };
  7710. exports.AssignmentExpression = exports.Property = exports.VariableDeclarator = function (node) {
  7711. var left, right;
  7712. if (t.isAssignmentExpression(node)) {
  7713. left = node.left;
  7714. right = node.right;
  7715. } else if (t.isProperty(node)) {
  7716. left = node.key;
  7717. right = node.value;
  7718. } else if (t.isVariableDeclarator(node)) {
  7719. left = node.id;
  7720. right = node.init;
  7721. }
  7722. if (t.isMemberExpression(left)) {
  7723. left = left.property;
  7724. }
  7725. if (t.isIdentifier(left) && react.isCreateClass(right)) {
  7726. addDisplayName(left.name, right);
  7727. }
  7728. };
  7729. };
  7730. ;
  7731. module.exports = exports["default"];
  7732. },{"../../messages":47,"../../types":169,"./react":66,"esutils":314,"lodash/lang/isString":414}],60:[function(require,module,exports){
  7733. "use strict";
  7734. exports.__esModule = true;
  7735. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7736. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7737. var _traversal = require("../../traversal");
  7738. var _traversal2 = _interopRequireDefault(_traversal);
  7739. var _types = require("../../types");
  7740. var t = _interopRequireWildcard(_types);
  7741. var visitor = {
  7742. enter: function enter(node, parent, scope, state) {
  7743. if (this.isThisExpression() || this.isReferencedIdentifier({ name: "arguments" })) {
  7744. state.found = true;
  7745. this.stop();
  7746. }
  7747. if (this.isFunction()) {
  7748. this.skip();
  7749. }
  7750. }
  7751. };
  7752. exports["default"] = function (node, scope) {
  7753. var container = t.functionExpression(null, [], node.body, node.generator, node.async);
  7754. var callee = container;
  7755. var args = [];
  7756. var state = { found: false };
  7757. scope.traverse(node, visitor, state);
  7758. if (state.found) {
  7759. callee = t.memberExpression(container, t.identifier("apply"));
  7760. args = [t.thisExpression(), t.identifier("arguments")];
  7761. }
  7762. var call = t.callExpression(callee, args);
  7763. if (node.generator) call = t.yieldExpression(call, true);
  7764. return t.returnStatement(call);
  7765. };
  7766. module.exports = exports["default"];
  7767. },{"../../traversal":157,"../../types":169}],61:[function(require,module,exports){
  7768. "use strict";
  7769. exports.__esModule = true;
  7770. exports.push = push;
  7771. exports.hasComputed = hasComputed;
  7772. exports.toComputedObjectFromClass = toComputedObjectFromClass;
  7773. exports.toClassObject = toClassObject;
  7774. exports.toDefineObject = toDefineObject;
  7775. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7776. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7777. var _lodashLangCloneDeep = require("lodash/lang/cloneDeep");
  7778. var _lodashLangCloneDeep2 = _interopRequireDefault(_lodashLangCloneDeep);
  7779. var _traversal = require("../../traversal");
  7780. var _traversal2 = _interopRequireDefault(_traversal);
  7781. var _lodashCollectionEach = require("lodash/collection/each");
  7782. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  7783. var _lodashObjectHas = require("lodash/object/has");
  7784. var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
  7785. var _types = require("../../types");
  7786. var t = _interopRequireWildcard(_types);
  7787. function push(mutatorMap, node, kind, file) {
  7788. var alias = t.toKeyAlias(node);
  7789. //
  7790. var map = {};
  7791. if ((0, _lodashObjectHas2["default"])(mutatorMap, alias)) map = mutatorMap[alias];
  7792. mutatorMap[alias] = map;
  7793. //
  7794. map._inherits = map._inherits || [];
  7795. map._inherits.push(node);
  7796. map._key = node.key;
  7797. if (node.computed) {
  7798. map._computed = true;
  7799. }
  7800. if (node.decorators) {
  7801. var decorators = map.decorators = map.decorators || t.arrayExpression([]);
  7802. decorators.elements = decorators.elements.concat(node.decorators.map(function (dec) {
  7803. return dec.expression;
  7804. }).reverse());
  7805. }
  7806. if (map.value || map.initializer) {
  7807. throw file.errorWithNode(node, "Key conflict with sibling node");
  7808. }
  7809. if (node.value) {
  7810. if (node.kind === "init") kind = "value";
  7811. if (node.kind === "get") kind = "get";
  7812. if (node.kind === "set") kind = "set";
  7813. t.inheritsComments(node.value, node);
  7814. map[kind] = node.value;
  7815. }
  7816. return map;
  7817. }
  7818. function hasComputed(mutatorMap) {
  7819. for (var key in mutatorMap) {
  7820. if (mutatorMap[key]._computed) {
  7821. return true;
  7822. }
  7823. }
  7824. return false;
  7825. }
  7826. function toComputedObjectFromClass(obj) {
  7827. var objExpr = t.arrayExpression([]);
  7828. for (var i = 0; i < obj.properties.length; i++) {
  7829. var prop = obj.properties[i];
  7830. var val = prop.value;
  7831. val.properties.unshift(t.property("init", t.identifier("key"), t.toComputedKey(prop)));
  7832. objExpr.elements.push(val);
  7833. }
  7834. return objExpr;
  7835. }
  7836. function toClassObject(mutatorMap) {
  7837. var objExpr = t.objectExpression([]);
  7838. (0, _lodashCollectionEach2["default"])(mutatorMap, function (map) {
  7839. var mapNode = t.objectExpression([]);
  7840. var propNode = t.property("init", map._key, mapNode, map._computed);
  7841. (0, _lodashCollectionEach2["default"])(map, function (node, key) {
  7842. if (key[0] === "_") return;
  7843. var inheritNode = node;
  7844. if (t.isMethodDefinition(node) || t.isClassProperty(node)) node = node.value;
  7845. var prop = t.property("init", t.identifier(key), node);
  7846. t.inheritsComments(prop, inheritNode);
  7847. t.removeComments(inheritNode);
  7848. mapNode.properties.push(prop);
  7849. });
  7850. objExpr.properties.push(propNode);
  7851. });
  7852. return objExpr;
  7853. }
  7854. function toDefineObject(mutatorMap) {
  7855. (0, _lodashCollectionEach2["default"])(mutatorMap, function (map) {
  7856. if (map.value) map.writable = t.literal(true);
  7857. map.configurable = t.literal(true);
  7858. map.enumerable = t.literal(true);
  7859. });
  7860. return toClassObject(mutatorMap);
  7861. }
  7862. },{"../../traversal":157,"../../types":169,"lodash/collection/each":330,"lodash/lang/cloneDeep":403,"lodash/object/has":420}],62:[function(require,module,exports){
  7863. "use strict";
  7864. exports.__esModule = true;
  7865. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7866. var _types = require("../../types");
  7867. var t = _interopRequireWildcard(_types);
  7868. var getObjRef = function getObjRef(node, nodes, file, scope) {
  7869. var ref;
  7870. if (t.isIdentifier(node)) {
  7871. if (scope.hasBinding(node.name)) {
  7872. // this variable is declared in scope so we can be 100% sure
  7873. // that evaluating it multiple times wont trigger a getter
  7874. // or something else
  7875. return node;
  7876. } else {
  7877. // could possibly trigger a getter so we need to only evaluate
  7878. // it once
  7879. ref = node;
  7880. }
  7881. } else if (t.isMemberExpression(node)) {
  7882. ref = node.object;
  7883. if (t.isIdentifier(ref) && scope.hasGlobal(ref.name)) {
  7884. // the object reference that we need to save is locally declared
  7885. // so as per the previous comment we can be 100% sure evaluating
  7886. // it multiple times will be safe
  7887. return ref;
  7888. }
  7889. } else {
  7890. throw new Error("We can't explode this node type " + node.type);
  7891. }
  7892. var temp = scope.generateUidIdentifierBasedOnNode(ref);
  7893. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, ref)]));
  7894. return temp;
  7895. };
  7896. var getPropRef = function getPropRef(node, nodes, file, scope) {
  7897. var prop = node.property;
  7898. var key = t.toComputedKey(node, prop);
  7899. if (t.isLiteral(key)) return key;
  7900. var temp = scope.generateUidIdentifierBasedOnNode(prop);
  7901. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, prop)]));
  7902. return temp;
  7903. };
  7904. exports["default"] = function (node, nodes, file, scope, allowedSingleIdent) {
  7905. var obj;
  7906. if (t.isIdentifier(node) && allowedSingleIdent) {
  7907. obj = node;
  7908. } else {
  7909. obj = getObjRef(node, nodes, file, scope);
  7910. }
  7911. var ref, uid;
  7912. if (t.isIdentifier(node)) {
  7913. ref = node;
  7914. uid = obj;
  7915. } else {
  7916. var prop = getPropRef(node, nodes, file, scope);
  7917. var computed = node.computed || t.isLiteral(prop);
  7918. uid = ref = t.memberExpression(obj, prop, computed);
  7919. }
  7920. return {
  7921. uid: uid,
  7922. ref: ref
  7923. };
  7924. };
  7925. ;
  7926. module.exports = exports["default"];
  7927. },{"../../types":169}],63:[function(require,module,exports){
  7928. "use strict";
  7929. exports.__esModule = true;
  7930. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7931. var _types = require("../../types");
  7932. var t = _interopRequireWildcard(_types);
  7933. exports["default"] = function (node) {
  7934. var lastNonDefault = 0;
  7935. for (var i = 0; i < node.params.length; i++) {
  7936. if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
  7937. }
  7938. return lastNonDefault;
  7939. };
  7940. ;
  7941. module.exports = exports["default"];
  7942. },{"../../types":169}],64:[function(require,module,exports){
  7943. "use strict";
  7944. exports.__esModule = true;
  7945. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7946. var _types = require("../../types");
  7947. var t = _interopRequireWildcard(_types);
  7948. exports["default"] = function (decorators, scope) {
  7949. for (var i = 0; i < decorators.length; i++) {
  7950. var decorator = decorators[i];
  7951. var expression = decorator.expression;
  7952. if (!t.isMemberExpression(expression)) continue;
  7953. var temp = scope.maybeGenerateMemoised(expression.object);
  7954. var ref;
  7955. var nodes = [];
  7956. if (temp) {
  7957. ref = temp;
  7958. nodes.push(t.assignmentExpression("=", temp, expression.object));
  7959. } else {
  7960. ref = expression.object;
  7961. }
  7962. nodes.push(t.callExpression(t.memberExpression(t.memberExpression(ref, expression.property, expression.computed), t.identifier("bind")), [ref]));
  7963. if (nodes.length === 1) {
  7964. decorator.expression = nodes[0];
  7965. } else {
  7966. decorator.expression = t.sequenceExpression(nodes);
  7967. }
  7968. }
  7969. return decorators;
  7970. };
  7971. module.exports = exports["default"];
  7972. },{"../../types":169}],65:[function(require,module,exports){
  7973. "use strict";
  7974. exports.__esModule = true;
  7975. exports.custom = custom;
  7976. exports.property = property;
  7977. exports.bare = bare;
  7978. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  7979. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7980. var _getFunctionArity = require("./get-function-arity");
  7981. var _getFunctionArity2 = _interopRequireDefault(_getFunctionArity);
  7982. var _util = require("../../util");
  7983. var util = _interopRequireWildcard(_util);
  7984. var _types = require("../../types");
  7985. var t = _interopRequireWildcard(_types);
  7986. var visitor = {
  7987. enter: function enter(node, parent, scope, state) {
  7988. // check if this node is a referenced identifier that matches the same as our
  7989. // function id
  7990. if (!this.isReferencedIdentifier({ name: state.name })) return;
  7991. // check that we don't have a local variable declared as that removes the need
  7992. // for the wrapper
  7993. var localDeclar = scope.getBindingIdentifier(state.name);
  7994. if (localDeclar !== state.outerDeclar) return;
  7995. state.selfReference = true;
  7996. this.stop();
  7997. }
  7998. };
  7999. var wrap = function wrap(state, method, id, scope) {
  8000. if (state.selfReference) {
  8001. if (scope.hasBinding(id.name)) {
  8002. // we can just munge the local binding
  8003. scope.rename(id.name);
  8004. } else {
  8005. // need to add a wrapper since we can't change the references
  8006. var templateName = "property-method-assignment-wrapper";
  8007. if (method.generator) templateName += "-generator";
  8008. var template = util.template(templateName, {
  8009. FUNCTION: method,
  8010. FUNCTION_ID: id,
  8011. FUNCTION_KEY: scope.generateUidIdentifier(id.name)
  8012. });
  8013. template.callee._skipModulesRemap = true;
  8014. // shim in dummy params to retain function arity, if you try to read the
  8015. // source then you'll get the original since it's proxied so it's all good
  8016. var params = template.callee.body.body[0].params;
  8017. for (var i = 0, len = (0, _getFunctionArity2["default"])(method); i < len; i++) {
  8018. params.push(scope.generateUidIdentifier("x"));
  8019. }
  8020. return template;
  8021. }
  8022. }
  8023. method.id = id;
  8024. };
  8025. var visit = function visit(node, name, scope) {
  8026. var state = {
  8027. selfAssignment: false,
  8028. selfReference: false,
  8029. outerDeclar: scope.getBindingIdentifier(name),
  8030. references: [],
  8031. name: name
  8032. };
  8033. // check to see if we have a local binding of the id we're setting inside of
  8034. // the function, this is important as there are caveats associated
  8035. var bindingInfo = scope.getOwnBindingInfo(name);
  8036. if (bindingInfo) {
  8037. if (bindingInfo.kind === "param") {
  8038. // safari will blow up in strict mode with code like:
  8039. //
  8040. // var t = function t(t) {};
  8041. //
  8042. // with the error:
  8043. //
  8044. // Cannot declare a parameter named 't' as it shadows the name of a
  8045. // strict mode function.
  8046. //
  8047. // this isn't to the spec and they've invented this behaviour which is
  8048. // **extremely** annoying so we avoid setting the name if it has a param
  8049. // with the same id
  8050. state.selfReference = true;
  8051. } else {}
  8052. } else if (state.outerDeclar || scope.hasGlobal(name)) {
  8053. scope.traverse(node, visitor, state);
  8054. }
  8055. return state;
  8056. };
  8057. function custom(node, id, scope) {
  8058. var state = visit(node, id.name, scope);
  8059. return wrap(state, node, id, scope);
  8060. }
  8061. function property(node, file, scope) {
  8062. var key = t.toComputedKey(node, node.key);
  8063. if (!t.isLiteral(key)) return; // we can't set a function id with this
  8064. var name = t.toIdentifier(key.value);
  8065. if (name === "eval" || name === "arguments") name = "_" + name;
  8066. var id = t.identifier(name);
  8067. var method = node.value;
  8068. var state = visit(method, name, scope);
  8069. node.value = wrap(state, method, id, scope) || method;
  8070. }
  8071. function bare(node, parent, scope) {
  8072. // has an `id` so we don't need to infer one
  8073. if (node.id) return;
  8074. var id;
  8075. if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
  8076. // { foo() {} };
  8077. id = parent.key;
  8078. } else if (t.isVariableDeclarator(parent)) {
  8079. // var foo = function () {};
  8080. id = parent.id;
  8081. if (t.isIdentifier(id)) {
  8082. var bindingInfo = scope.parent.getBinding(id.name);
  8083. if (bindingInfo && bindingInfo.constant && scope.getBinding(id.name) === bindingInfo) {
  8084. // always going to reference this method
  8085. node.id = id;
  8086. return;
  8087. }
  8088. }
  8089. } else {
  8090. return;
  8091. }
  8092. var name;
  8093. if (t.isLiteral(id)) {
  8094. name = id.value;
  8095. } else if (t.isIdentifier(id)) {
  8096. name = id.name;
  8097. } else {
  8098. return;
  8099. }
  8100. name = t.toIdentifier(name);
  8101. id = t.identifier(name);
  8102. var state = visit(node, name, scope);
  8103. return wrap(state, node, id, scope);
  8104. }
  8105. // otherwise it's defined somewhere in scope like:
  8106. //
  8107. // var t = function () {
  8108. // var t = 2;
  8109. // };
  8110. //
  8111. // so we can safely just set the id and move along as it shadows the
  8112. // bound function id
  8113. },{"../../types":169,"../../util":173,"./get-function-arity":63}],66:[function(require,module,exports){
  8114. "use strict";
  8115. exports.__esModule = true;
  8116. exports.isCreateClass = isCreateClass;
  8117. exports.isCompatTag = isCompatTag;
  8118. exports.buildChildren = buildChildren;
  8119. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8120. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8121. var _lodashLangIsString = require("lodash/lang/isString");
  8122. var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
  8123. var _types = require("../../types");
  8124. var t = _interopRequireWildcard(_types);
  8125. var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
  8126. function isCreateClass(node) {
  8127. if (!node || !t.isCallExpression(node)) return false;
  8128. // not React.createClass call member object
  8129. if (!isCreateClassCallExpression(node.callee)) return false;
  8130. // no call arguments
  8131. var args = node.arguments;
  8132. if (args.length !== 1) return false;
  8133. // first node arg is not an object
  8134. var first = args[0];
  8135. if (!t.isObjectExpression(first)) return false;
  8136. return true;
  8137. }
  8138. var isReactComponent = t.buildMatchMemberExpression("React.Component");
  8139. exports.isReactComponent = isReactComponent;
  8140. function isCompatTag(tagName) {
  8141. return tagName && /^[a-z]|\-/.test(tagName);
  8142. }
  8143. function isStringLiteral(node) {
  8144. return t.isLiteral(node) && (0, _lodashLangIsString2["default"])(node.value);
  8145. }
  8146. function cleanJSXElementLiteralChild(child, args) {
  8147. var lines = child.value.split(/\r\n|\n|\r/);
  8148. var lastNonEmptyLine = 0;
  8149. for (var i = 0; i < lines.length; i++) {
  8150. if (lines[i].match(/[^ \t]/)) {
  8151. lastNonEmptyLine = i;
  8152. }
  8153. }
  8154. var str = "";
  8155. for (var i = 0; i < lines.length; i++) {
  8156. var line = lines[i];
  8157. var isFirstLine = i === 0;
  8158. var isLastLine = i === lines.length - 1;
  8159. var isLastNonEmptyLine = i === lastNonEmptyLine;
  8160. // replace rendered whitespace tabs with spaces
  8161. var trimmedLine = line.replace(/\t/g, " ");
  8162. // trim whitespace touching a newline
  8163. if (!isFirstLine) {
  8164. trimmedLine = trimmedLine.replace(/^[ ]+/, "");
  8165. }
  8166. // trim whitespace touching an endline
  8167. if (!isLastLine) {
  8168. trimmedLine = trimmedLine.replace(/[ ]+$/, "");
  8169. }
  8170. if (trimmedLine) {
  8171. if (!isLastNonEmptyLine) {
  8172. trimmedLine += " ";
  8173. }
  8174. str += trimmedLine;
  8175. }
  8176. }
  8177. if (str) args.push(t.literal(str));
  8178. }
  8179. function buildChildren(node) {
  8180. var elems = [];
  8181. for (var i = 0; i < node.children.length; i++) {
  8182. var child = node.children[i];
  8183. if (t.isLiteral(child) && typeof child.value === "string") {
  8184. cleanJSXElementLiteralChild(child, elems);
  8185. continue;
  8186. }
  8187. if (t.isJSXExpressionContainer(child)) child = child.expression;
  8188. if (t.isJSXEmptyExpression(child)) continue;
  8189. elems.push(child);
  8190. }
  8191. return elems;
  8192. }
  8193. },{"../../types":169,"lodash/lang/isString":414}],67:[function(require,module,exports){
  8194. "use strict";
  8195. exports.__esModule = true;
  8196. exports.is = is;
  8197. exports.pullFlag = pullFlag;
  8198. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8199. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8200. var _lodashArrayPull = require("lodash/array/pull");
  8201. var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
  8202. var _types = require("../../types");
  8203. var t = _interopRequireWildcard(_types);
  8204. function is(node, flag) {
  8205. return t.isLiteral(node) && node.regex && node.regex.flags.indexOf(flag) >= 0;
  8206. }
  8207. function pullFlag(node, flag) {
  8208. var flags = node.regex.flags.split("");
  8209. if (node.regex.flags.indexOf(flag) < 0) return;
  8210. (0, _lodashArrayPull2["default"])(flags, flag);
  8211. node.regex.flags = flags.join("");
  8212. }
  8213. },{"../../types":169,"lodash/array/pull":327}],68:[function(require,module,exports){
  8214. "use strict";
  8215. exports.__esModule = true;
  8216. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8217. var _types = require("../../types");
  8218. var t = _interopRequireWildcard(_types);
  8219. var awaitVisitor = {
  8220. enter: function enter(node, parent, scope, state) {
  8221. if (t.isFunction(node)) this.skip();
  8222. if (t.isAwaitExpression(node)) {
  8223. node.type = "YieldExpression";
  8224. if (node.all) {
  8225. // await* foo; -> yield Promise.all(foo);
  8226. node.all = false;
  8227. node.argument = t.callExpression(t.memberExpression(t.identifier("Promise"), t.identifier("all")), [node.argument]);
  8228. }
  8229. }
  8230. }
  8231. };
  8232. var referenceVisitor = {
  8233. enter: function enter(node, parent, scope, state) {
  8234. var name = state.id.name;
  8235. if (this.isReferencedIdentifier({ name: name }) && scope.bindingIdentifierEquals(name, state.id)) {
  8236. return state.ref = state.ref || scope.generateUidIdentifier(name);
  8237. }
  8238. }
  8239. };
  8240. exports["default"] = function (node, callId, scope) {
  8241. node.async = false;
  8242. node.generator = true;
  8243. scope.traverse(node, awaitVisitor, state);
  8244. var call = t.callExpression(callId, [node]);
  8245. var id = node.id;
  8246. node.id = null;
  8247. if (t.isFunctionDeclaration(node)) {
  8248. var declar = t.variableDeclaration("let", [t.variableDeclarator(id, call)]);
  8249. declar._blockHoist = true;
  8250. return declar;
  8251. } else {
  8252. if (id) {
  8253. var state = { id: id };
  8254. scope.traverse(node, referenceVisitor, state);
  8255. if (state.ref) {
  8256. scope.parent.push({ id: state.ref });
  8257. return t.assignmentExpression("=", state.ref, call);
  8258. }
  8259. }
  8260. return call;
  8261. }
  8262. };
  8263. ;
  8264. module.exports = exports["default"];
  8265. },{"../../types":169}],69:[function(require,module,exports){
  8266. "use strict";
  8267. exports.__esModule = true;
  8268. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8269. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8270. var _messages = require("../../messages");
  8271. var messages = _interopRequireWildcard(_messages);
  8272. var _types = require("../../types");
  8273. var t = _interopRequireWildcard(_types);
  8274. function isIllegalBareSuper(node, parent) {
  8275. if (!t.isSuper(node)) return false;
  8276. if (t.isMemberExpression(parent, { computed: false })) return false;
  8277. if (t.isCallExpression(parent, { callee: node })) return false;
  8278. return true;
  8279. }
  8280. function isMemberExpressionSuper(node) {
  8281. return t.isMemberExpression(node) && t.isSuper(node.object);
  8282. }
  8283. var visitor = {
  8284. enter: function enter(node, parent, scope, state) {
  8285. var topLevel = state.topLevel;
  8286. var self = state.self;
  8287. if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
  8288. // we need to call traverseLevel again so we're context aware
  8289. self.traverseLevel(this, false);
  8290. return this.skip();
  8291. }
  8292. if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
  8293. // break on object methods
  8294. return this.skip();
  8295. }
  8296. var getThisReference = topLevel ?
  8297. // top level so `this` is the instance
  8298. t.thisExpression :
  8299. // not in the top level so we need to create a reference
  8300. self.getThisReference.bind(self);
  8301. var callback = self.specHandle;
  8302. if (self.isLoose) callback = self.looseHandle;
  8303. var result = callback.call(self, this, getThisReference);
  8304. if (result) this.hasSuper = true;
  8305. if (result === true) return;
  8306. return result;
  8307. }
  8308. };
  8309. var ReplaceSupers = (function () {
  8310. /**
  8311. * Description
  8312. */
  8313. function ReplaceSupers(opts) {
  8314. var inClass = arguments[1] === undefined ? false : arguments[1];
  8315. _classCallCheck(this, ReplaceSupers);
  8316. this.topLevelThisReference = opts.topLevelThisReference;
  8317. this.methodPath = opts.methodPath;
  8318. this.methodNode = opts.methodNode;
  8319. this.superRef = opts.superRef;
  8320. this.isStatic = opts.isStatic;
  8321. this.hasSuper = false;
  8322. this.inClass = inClass;
  8323. this.isLoose = opts.isLoose;
  8324. this.scope = opts.scope;
  8325. this.file = opts.file;
  8326. this.opts = opts;
  8327. }
  8328. ReplaceSupers.prototype.getObjectRef = function getObjectRef() {
  8329. return this.opts.objectRef || this.opts.getObjectRef();
  8330. };
  8331. /**
  8332. * Sets a super class value of the named property.
  8333. *
  8334. * @example
  8335. *
  8336. * _set(Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this)
  8337. *
  8338. */
  8339. ReplaceSupers.prototype.setSuperProperty = function setSuperProperty(property, value, isComputed, thisExpression) {
  8340. return t.callExpression(this.file.addHelper("set"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), value, thisExpression]);
  8341. };
  8342. /**
  8343. * Gets a node representing the super class value of the named property.
  8344. *
  8345. * @example
  8346. *
  8347. * _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
  8348. *
  8349. */
  8350. ReplaceSupers.prototype.getSuperProperty = function getSuperProperty(property, isComputed, thisExpression) {
  8351. return t.callExpression(this.file.addHelper("get"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), thisExpression]);
  8352. };
  8353. /**
  8354. * Description
  8355. */
  8356. ReplaceSupers.prototype.replace = function replace() {
  8357. this.traverseLevel(this.methodPath.get("value"), true);
  8358. };
  8359. /**
  8360. * Description
  8361. */
  8362. ReplaceSupers.prototype.traverseLevel = function traverseLevel(path, topLevel) {
  8363. var state = { self: this, topLevel: topLevel };
  8364. path.traverse(visitor, state);
  8365. };
  8366. /**
  8367. * Description
  8368. */
  8369. ReplaceSupers.prototype.getThisReference = function getThisReference() {
  8370. if (this.topLevelThisReference) {
  8371. return this.topLevelThisReference;
  8372. } else {
  8373. var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
  8374. this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(this.topLevelThisReference, t.thisExpression())]));
  8375. return ref;
  8376. }
  8377. };
  8378. /**
  8379. * Description
  8380. */
  8381. ReplaceSupers.prototype.getLooseSuperProperty = function getLooseSuperProperty(id, parent) {
  8382. var methodNode = this.methodNode;
  8383. var methodName = methodNode.key;
  8384. var superRef = this.superRef || t.identifier("Function");
  8385. if (parent.property === id) {
  8386. return;
  8387. } else if (t.isCallExpression(parent, { callee: id })) {
  8388. // super(); -> objectRef.prototype.MethodName.call(this);
  8389. parent.arguments.unshift(t.thisExpression());
  8390. if (methodName.name === "constructor") {
  8391. // constructor() { super(); }
  8392. return t.memberExpression(superRef, t.identifier("call"));
  8393. } else {
  8394. id = superRef;
  8395. // foo() { super(); }
  8396. if (!methodNode["static"]) {
  8397. id = t.memberExpression(id, t.identifier("prototype"));
  8398. }
  8399. id = t.memberExpression(id, methodName, methodNode.computed);
  8400. return t.memberExpression(id, t.identifier("call"));
  8401. }
  8402. } else if (t.isMemberExpression(parent) && !methodNode["static"]) {
  8403. // super.test -> objectRef.prototype.test
  8404. return t.memberExpression(superRef, t.identifier("prototype"));
  8405. } else {
  8406. return superRef;
  8407. }
  8408. };
  8409. /**
  8410. * Description
  8411. */
  8412. ReplaceSupers.prototype.looseHandle = function looseHandle(path, getThisReference) {
  8413. var node = path.node;
  8414. if (path.isSuper()) {
  8415. return this.getLooseSuperProperty(node, path.parent);
  8416. } else if (path.isCallExpression()) {
  8417. var callee = node.callee;
  8418. if (!t.isMemberExpression(callee)) return;
  8419. if (!t.isSuper(callee.object)) return;
  8420. // super.test(); -> objectRef.prototype.MethodName.call(this);
  8421. t.appendToMemberExpression(callee, t.identifier("call"));
  8422. node.arguments.unshift(getThisReference());
  8423. return true;
  8424. }
  8425. };
  8426. /**
  8427. * Description
  8428. */
  8429. ReplaceSupers.prototype.specHandleAssignmentExpression = function specHandleAssignmentExpression(ref, path, node, getThisReference) {
  8430. if (node.operator === "=") {
  8431. // super.name = "val"; -> _set(Object.getPrototypeOf(objectRef.prototype), "name", this);
  8432. return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
  8433. } else {
  8434. // super.age += 2; -> var _ref = super.age; super.age = _ref + 2;
  8435. ref = ref || path.scope.generateUidIdentifier("ref");
  8436. return [t.variableDeclaration("var", [t.variableDeclarator(ref, node.left)]), t.expressionStatement(t.assignmentExpression("=", node.left, t.binaryExpression(node.operator[0], ref, node.right)))];
  8437. }
  8438. };
  8439. /**
  8440. * Description
  8441. */
  8442. ReplaceSupers.prototype.specHandle = function specHandle(path, getThisReference) {
  8443. var methodNode = this.methodNode;
  8444. var property;
  8445. var computed;
  8446. var args;
  8447. var thisReference;
  8448. var parent = path.parent;
  8449. var node = path.node;
  8450. if (isIllegalBareSuper(node, parent)) {
  8451. throw path.errorWithNode(messages.get("classesIllegalBareSuper"));
  8452. }
  8453. if (t.isCallExpression(node)) {
  8454. var callee = node.callee;
  8455. if (t.isSuper(callee)) {
  8456. // super(); -> _get(Object.getPrototypeOf(objectRef), "MethodName", this).call(this);
  8457. property = methodNode.key;
  8458. computed = methodNode.computed;
  8459. args = node.arguments;
  8460. // bare `super` call is illegal inside non-constructors
  8461. // - https://esdiscuss.org/topic/super-call-in-methods
  8462. // - https://twitter.com/wycats/status/544553184396836864
  8463. if (methodNode.key.name !== "constructor" || !this.inClass) {
  8464. var methodName = methodNode.key.name || "METHOD_NAME";
  8465. throw this.file.errorWithNode(node, messages.get("classesIllegalSuperCall", methodName));
  8466. }
  8467. } else if (isMemberExpressionSuper(callee)) {
  8468. // super.test(); -> _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this);
  8469. property = callee.property;
  8470. computed = callee.computed;
  8471. args = node.arguments;
  8472. }
  8473. } else if (t.isMemberExpression(node) && t.isSuper(node.object)) {
  8474. // super.name; -> _get(Object.getPrototypeOf(objectRef.prototype), "name", this);
  8475. property = node.property;
  8476. computed = node.computed;
  8477. } else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) {
  8478. var binary = t.binaryExpression(node.operator[0], node.argument, t.literal(1));
  8479. if (node.prefix) {
  8480. // ++super.foo; -> super.foo += 1;
  8481. return this.specHandleAssignmentExpression(null, path, binary, getThisReference);
  8482. } else {
  8483. // super.foo++; -> var _ref = super.foo; super.foo = _ref + 1;
  8484. var ref = path.scope.generateUidIdentifier("ref");
  8485. return this.specHandleAssignmentExpression(ref, path, binary, getThisReference).concat(t.expressionStatement(ref));
  8486. }
  8487. } else if (t.isAssignmentExpression(node) && isMemberExpressionSuper(node.left)) {
  8488. return this.specHandleAssignmentExpression(null, path, node, getThisReference);
  8489. }
  8490. if (!property) return;
  8491. thisReference = getThisReference();
  8492. var superProperty = this.getSuperProperty(property, computed, thisReference);
  8493. if (args) {
  8494. if (args.length === 1 && t.isSpreadElement(args[0])) {
  8495. // super(...arguments);
  8496. return t.callExpression(t.memberExpression(superProperty, t.identifier("apply")), [thisReference, args[0].argument]);
  8497. } else {
  8498. return t.callExpression(t.memberExpression(superProperty, t.identifier("call")), [thisReference].concat(args));
  8499. }
  8500. } else {
  8501. return superProperty;
  8502. }
  8503. };
  8504. return ReplaceSupers;
  8505. })();
  8506. exports["default"] = ReplaceSupers;
  8507. module.exports = exports["default"];
  8508. },{"../../messages":47,"../../types":169}],70:[function(require,module,exports){
  8509. "use strict";
  8510. exports.__esModule = true;
  8511. exports.has = has;
  8512. exports.wrap = wrap;
  8513. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8514. var _types = require("../../types");
  8515. var t = _interopRequireWildcard(_types);
  8516. function has(node) {
  8517. var first = node.body[0];
  8518. return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" });
  8519. }
  8520. function wrap(node, callback) {
  8521. var useStrictNode;
  8522. if (has(node)) {
  8523. useStrictNode = node.body.shift();
  8524. }
  8525. callback();
  8526. if (useStrictNode) {
  8527. node.body.unshift(useStrictNode);
  8528. }
  8529. }
  8530. },{"../../types":169}],71:[function(require,module,exports){
  8531. "use strict";
  8532. exports.__esModule = true;
  8533. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8534. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8535. var _transformerPipeline = require("./transformer-pipeline");
  8536. var _transformerPipeline2 = _interopRequireDefault(_transformerPipeline);
  8537. //
  8538. var _transformers = require("./transformers");
  8539. var _transformers2 = _interopRequireDefault(_transformers);
  8540. //
  8541. var _transformersDeprecated = require("./transformers/deprecated");
  8542. var _transformersDeprecated2 = _interopRequireDefault(_transformersDeprecated);
  8543. //
  8544. var _transformersAliases = require("./transformers/aliases");
  8545. var _transformersAliases2 = _interopRequireDefault(_transformersAliases);
  8546. //
  8547. var _transformersFilters = require("./transformers/filters");
  8548. var filters = _interopRequireWildcard(_transformersFilters);
  8549. var pipeline = new _transformerPipeline2["default"]();
  8550. for (var key in _transformers2["default"]) {
  8551. var transformer = _transformers2["default"][key];
  8552. var metadata = transformer.metadata = transformer.metadata || {};
  8553. metadata.group = metadata.group || "builtin-basic";
  8554. }
  8555. pipeline.addTransformers(_transformers2["default"]);
  8556. pipeline.addDeprecated(_transformersDeprecated2["default"]);
  8557. pipeline.addAliases(_transformersAliases2["default"]);
  8558. pipeline.addFilter(filters.internal);
  8559. pipeline.addFilter(filters.blacklist);
  8560. pipeline.addFilter(filters.whitelist);
  8561. pipeline.addFilter(filters.stage);
  8562. pipeline.addFilter(filters.optional);
  8563. //
  8564. var transform = pipeline.transform.bind(pipeline);
  8565. transform.fromAst = pipeline.transformFromAst.bind(pipeline);
  8566. transform.pipeline = pipeline;
  8567. exports["default"] = transform;
  8568. module.exports = exports["default"];
  8569. },{"./transformer-pipeline":84,"./transformers":122,"./transformers/aliases":86,"./transformers/deprecated":87,"./transformers/filters":121}],72:[function(require,module,exports){
  8570. "use strict";
  8571. exports.__esModule = true;
  8572. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8573. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8574. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8575. var _messages = require("../../messages");
  8576. var messages = _interopRequireWildcard(_messages);
  8577. var _traversal = require("../../traversal");
  8578. var _traversal2 = _interopRequireDefault(_traversal);
  8579. var _lodashObjectExtend = require("lodash/object/extend");
  8580. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  8581. var _helpersObject = require("../../helpers/object");
  8582. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  8583. var _util = require("../../util");
  8584. var util = _interopRequireWildcard(_util);
  8585. var _types = require("../../types");
  8586. var t = _interopRequireWildcard(_types);
  8587. var remapVisitor = {
  8588. enter: function enter(node, parent, scope, formatter) {
  8589. if (node._skipModulesRemap) {
  8590. return this.skip();
  8591. }
  8592. },
  8593. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, formatter) {
  8594. var remap = formatter.internalRemap[node.name];
  8595. if (remap && node !== remap) {
  8596. if (!scope.hasBinding(node.name) || scope.bindingIdentifierEquals(node.name, formatter.localImports[node.name])) {
  8597. if (this.key === "callee" && this.parentPath.isCallExpression()) {
  8598. return t.sequenceExpression([t.literal(0), remap]);
  8599. } else {
  8600. return remap;
  8601. }
  8602. }
  8603. }
  8604. },
  8605. AssignmentExpression: {
  8606. exit: function exit(node, parent, scope, formatter) {
  8607. if (!node._ignoreModulesRemap) {
  8608. var exported = formatter.getExport(node.left, scope);
  8609. if (exported) {
  8610. return formatter.remapExportAssignment(node, exported);
  8611. }
  8612. }
  8613. }
  8614. },
  8615. UpdateExpression: function UpdateExpression(node, parent, scope, formatter) {
  8616. var exported = formatter.getExport(node.argument, scope);
  8617. if (!exported) return;
  8618. this.skip();
  8619. // expand to long file assignment expression
  8620. var assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.literal(1));
  8621. // remap this assignment expression
  8622. var remapped = formatter.remapExportAssignment(assign, exported);
  8623. // we don't need to change the result
  8624. if (t.isExpressionStatement(parent) || node.prefix) {
  8625. return remapped;
  8626. }
  8627. var nodes = [];
  8628. nodes.push(remapped);
  8629. var operator;
  8630. if (node.operator === "--") {
  8631. operator = "+";
  8632. } else {
  8633. // "++"
  8634. operator = "-";
  8635. }
  8636. nodes.push(t.binaryExpression(operator, node.argument, t.literal(1)));
  8637. return t.sequenceExpression(nodes);
  8638. }
  8639. };
  8640. var importsVisitor = {
  8641. ImportDeclaration: {
  8642. enter: function enter(node, parent, scope, formatter) {
  8643. formatter.hasLocalImports = true;
  8644. (0, _lodashObjectExtend2["default"])(formatter.localImports, this.getBindingIdentifiers());
  8645. }
  8646. }
  8647. };
  8648. var exportsVisitor = {
  8649. ExportDeclaration: {
  8650. enter: function enter(node, parent, scope, formatter) {
  8651. formatter.hasLocalExports = true;
  8652. var declar = this.get("declaration");
  8653. if (declar.isStatement()) {
  8654. var bindings = declar.getBindingIdentifiers();
  8655. for (var name in bindings) {
  8656. var binding = bindings[name];
  8657. formatter._addExport(name, binding);
  8658. }
  8659. }
  8660. if (this.isExportNamedDeclaration() && node.specifiers) {
  8661. for (var i = 0; i < node.specifiers.length; i++) {
  8662. var specifier = node.specifiers[i];
  8663. var local = specifier.local;
  8664. if (!local) continue;
  8665. formatter._addExport(local.name, specifier.exported);
  8666. }
  8667. }
  8668. if (!t.isExportDefaultDeclaration(node)) {
  8669. var onlyDefault = node.specifiers && node.specifiers.length === 1 && t.isSpecifierDefault(node.specifiers[0]);
  8670. if (!onlyDefault) {
  8671. formatter.hasNonDefaultExports = true;
  8672. }
  8673. }
  8674. }
  8675. }
  8676. };
  8677. var DefaultFormatter = (function () {
  8678. function DefaultFormatter(file) {
  8679. _classCallCheck(this, DefaultFormatter);
  8680. this.internalRemap = (0, _helpersObject2["default"])();
  8681. this.defaultIds = (0, _helpersObject2["default"])();
  8682. this.scope = file.scope;
  8683. this.file = file;
  8684. this.ids = (0, _helpersObject2["default"])();
  8685. this.hasNonDefaultExports = false;
  8686. this.hasLocalExports = false;
  8687. this.hasLocalImports = false;
  8688. this.localExports = (0, _helpersObject2["default"])();
  8689. this.localImports = (0, _helpersObject2["default"])();
  8690. this.getLocalExports();
  8691. this.getLocalImports();
  8692. }
  8693. DefaultFormatter.prototype.isModuleType = function isModuleType(node, type) {
  8694. var modules = this.file.dynamicImportTypes[type];
  8695. return modules && modules.indexOf(node) >= 0;
  8696. };
  8697. DefaultFormatter.prototype.transform = function transform() {
  8698. this.remapAssignments();
  8699. };
  8700. DefaultFormatter.prototype.doDefaultExportInterop = function doDefaultExportInterop(node) {
  8701. return (t.isExportDefaultDeclaration(node) || t.isSpecifierDefault(node)) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
  8702. };
  8703. DefaultFormatter.prototype.getLocalExports = function getLocalExports() {
  8704. this.file.path.traverse(exportsVisitor, this);
  8705. };
  8706. DefaultFormatter.prototype.getLocalImports = function getLocalImports() {
  8707. this.file.path.traverse(importsVisitor, this);
  8708. };
  8709. DefaultFormatter.prototype.remapAssignments = function remapAssignments() {
  8710. if (this.hasLocalExports || this.hasLocalImports) {
  8711. this.file.path.traverse(remapVisitor, this);
  8712. }
  8713. };
  8714. DefaultFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
  8715. var assign = node;
  8716. for (var i = 0; i < exported.length; i++) {
  8717. assign = t.assignmentExpression("=", t.memberExpression(t.identifier("exports"), exported[i]), assign);
  8718. }
  8719. return assign;
  8720. };
  8721. DefaultFormatter.prototype._addExport = function _addExport(name, exported) {
  8722. var info = this.localExports[name] = this.localExports[name] || {
  8723. binding: this.scope.getBindingIdentifier(name),
  8724. exported: []
  8725. };
  8726. info.exported.push(exported);
  8727. };
  8728. DefaultFormatter.prototype.getExport = function getExport(node, scope) {
  8729. if (!t.isIdentifier(node)) return;
  8730. var local = this.localExports[node.name];
  8731. if (local && local.binding === scope.getBindingIdentifier(node.name)) {
  8732. return local.exported;
  8733. }
  8734. };
  8735. DefaultFormatter.prototype.getModuleName = function getModuleName() {
  8736. var opts = this.file.opts;
  8737. // moduleId is n/a if a `getModuleId()` is provided
  8738. if (opts.moduleId && !opts.getModuleId) {
  8739. return opts.moduleId;
  8740. }
  8741. var filenameRelative = opts.filenameRelative;
  8742. var moduleName = "";
  8743. if (opts.moduleRoot) {
  8744. moduleName = opts.moduleRoot + "/";
  8745. }
  8746. if (!opts.filenameRelative) {
  8747. return moduleName + opts.filename.replace(/^\//, "");
  8748. }
  8749. if (opts.sourceRoot) {
  8750. // remove sourceRoot from filename
  8751. var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "/?");
  8752. filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
  8753. }
  8754. if (!opts.keepModuleIdExtensions) {
  8755. // remove extension
  8756. filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
  8757. }
  8758. moduleName += filenameRelative;
  8759. // normalize path separators
  8760. moduleName = moduleName.replace(/\\/g, "/");
  8761. if (opts.getModuleId) {
  8762. // If return is falsy, assume they want us to use our generated default name
  8763. return opts.getModuleId(moduleName) || moduleName;
  8764. } else {
  8765. return moduleName;
  8766. }
  8767. };
  8768. DefaultFormatter.prototype._pushStatement = function _pushStatement(ref, nodes) {
  8769. if (t.isClass(ref) || t.isFunction(ref)) {
  8770. if (ref.id) {
  8771. nodes.push(t.toStatement(ref));
  8772. ref = ref.id;
  8773. }
  8774. }
  8775. return ref;
  8776. };
  8777. DefaultFormatter.prototype._hoistExport = function _hoistExport(declar, assign, priority) {
  8778. if (t.isFunctionDeclaration(declar)) {
  8779. assign._blockHoist = priority || 2;
  8780. }
  8781. return assign;
  8782. };
  8783. DefaultFormatter.prototype.getExternalReference = function getExternalReference(node, nodes) {
  8784. var ids = this.ids;
  8785. var id = node.source.value;
  8786. if (ids[id]) {
  8787. return ids[id];
  8788. } else {
  8789. return this.ids[id] = this._getExternalReference(node, nodes);
  8790. }
  8791. };
  8792. DefaultFormatter.prototype.checkExportIdentifier = function checkExportIdentifier(node) {
  8793. if (t.isIdentifier(node, { name: "__esModule" })) {
  8794. throw this.file.errorWithNode(node, messages.get("modulesIllegalExportName", node.name));
  8795. }
  8796. };
  8797. DefaultFormatter.prototype.exportAllDeclaration = function exportAllDeclaration(node, nodes) {
  8798. var ref = this.getExternalReference(node, nodes);
  8799. nodes.push(this.buildExportsWildcard(ref, node));
  8800. };
  8801. DefaultFormatter.prototype.isLoose = function isLoose() {
  8802. return this.file.isLoose("es6.modules");
  8803. };
  8804. DefaultFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
  8805. if (node.source) {
  8806. var ref = this.getExternalReference(node, nodes);
  8807. if (specifier.local.name === "default" && !this.noInteropRequireExport) {
  8808. // importing a default so we need to normalize it
  8809. ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
  8810. } else {
  8811. ref = t.memberExpression(ref, specifier.local);
  8812. if (!this.isLoose()) {
  8813. nodes.push(this.buildExportsFromAssignment(specifier.exported, ref, node));
  8814. return;
  8815. }
  8816. }
  8817. // export { foo } from "test";
  8818. nodes.push(this.buildExportsAssignment(specifier.exported, ref, node));
  8819. } else {
  8820. // export { foo };
  8821. nodes.push(this.buildExportsAssignment(specifier.exported, specifier.local, node));
  8822. }
  8823. };
  8824. DefaultFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier) {
  8825. return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [t.identifier("exports"), t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])]));
  8826. };
  8827. DefaultFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment(id, init) {
  8828. this.checkExportIdentifier(id);
  8829. return util.template("exports-from-assign", {
  8830. INIT: init,
  8831. ID: t.literal(id.name)
  8832. }, true);
  8833. };
  8834. DefaultFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init) {
  8835. this.checkExportIdentifier(id);
  8836. return util.template("exports-assign", {
  8837. VALUE: init,
  8838. KEY: id
  8839. }, true);
  8840. };
  8841. DefaultFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
  8842. var declar = node.declaration;
  8843. var id = declar.id;
  8844. if (t.isExportDefaultDeclaration(node)) {
  8845. id = t.identifier("default");
  8846. }
  8847. var assign;
  8848. if (t.isVariableDeclaration(declar)) {
  8849. for (var i = 0; i < declar.declarations.length; i++) {
  8850. var decl = declar.declarations[i];
  8851. decl.init = this.buildExportsAssignment(decl.id, decl.init, node).expression;
  8852. var newDeclar = t.variableDeclaration(declar.kind, [decl]);
  8853. if (i === 0) t.inherits(newDeclar, declar);
  8854. nodes.push(newDeclar);
  8855. }
  8856. } else {
  8857. var ref = declar;
  8858. if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
  8859. ref = declar.id;
  8860. nodes.push(declar);
  8861. }
  8862. assign = this.buildExportsAssignment(id, ref, node);
  8863. nodes.push(assign);
  8864. this._hoistExport(declar, assign);
  8865. }
  8866. };
  8867. return DefaultFormatter;
  8868. })();
  8869. exports["default"] = DefaultFormatter;
  8870. module.exports = exports["default"];
  8871. },{"../../helpers/object":45,"../../messages":47,"../../traversal":157,"../../types":169,"../../util":173,"lodash/object/extend":419}],73:[function(require,module,exports){
  8872. "use strict";
  8873. exports.__esModule = true;
  8874. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8875. var _util = require("../../util");
  8876. var util = _interopRequireWildcard(_util);
  8877. exports["default"] = function (Parent) {
  8878. var Constructor = function Constructor() {
  8879. this.noInteropRequireImport = true;
  8880. this.noInteropRequireExport = true;
  8881. Parent.apply(this, arguments);
  8882. };
  8883. util.inherits(Constructor, Parent);
  8884. return Constructor;
  8885. };
  8886. ;
  8887. module.exports = exports["default"];
  8888. },{"../../util":173}],74:[function(require,module,exports){
  8889. "use strict";
  8890. exports.__esModule = true;
  8891. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8892. var _amd = require("./amd");
  8893. var _amd2 = _interopRequireDefault(_amd);
  8894. var _strict = require("./_strict");
  8895. var _strict2 = _interopRequireDefault(_strict);
  8896. exports["default"] = (0, _strict2["default"])(_amd2["default"]);
  8897. module.exports = exports["default"];
  8898. },{"./_strict":73,"./amd":75}],75:[function(require,module,exports){
  8899. "use strict";
  8900. exports.__esModule = true;
  8901. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  8902. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8903. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8904. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
  8905. var _default = require("./_default");
  8906. var _default2 = _interopRequireDefault(_default);
  8907. var _common = require("./common");
  8908. var _common2 = _interopRequireDefault(_common);
  8909. var _lodashCollectionIncludes = require("lodash/collection/includes");
  8910. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  8911. var _lodashObjectValues = require("lodash/object/values");
  8912. var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
  8913. var _util = require("../../util");
  8914. var util = _interopRequireWildcard(_util);
  8915. var _types = require("../../types");
  8916. var t = _interopRequireWildcard(_types);
  8917. var AMDFormatter = (function (_DefaultFormatter) {
  8918. function AMDFormatter() {
  8919. _classCallCheck(this, AMDFormatter);
  8920. if (_DefaultFormatter != null) {
  8921. _DefaultFormatter.apply(this, arguments);
  8922. }
  8923. }
  8924. _inherits(AMDFormatter, _DefaultFormatter);
  8925. AMDFormatter.prototype.setup = function setup() {
  8926. _common2["default"].prototype._setup.call(this, this.hasNonDefaultExports);
  8927. };
  8928. AMDFormatter.prototype.buildDependencyLiterals = function buildDependencyLiterals() {
  8929. var names = [];
  8930. for (var name in this.ids) {
  8931. names.push(t.literal(name));
  8932. }
  8933. return names;
  8934. };
  8935. /**
  8936. * Wrap the entire body in a `define` wrapper.
  8937. */
  8938. AMDFormatter.prototype.transform = function transform(program) {
  8939. _common2["default"].prototype.transform.apply(this, arguments);
  8940. var body = program.body;
  8941. // build an array of module names
  8942. var names = [t.literal("exports")];
  8943. if (this.passModuleArg) names.push(t.literal("module"));
  8944. names = names.concat(this.buildDependencyLiterals());
  8945. names = t.arrayExpression(names);
  8946. // build up define container
  8947. var params = (0, _lodashObjectValues2["default"])(this.ids);
  8948. if (this.passModuleArg) params.unshift(t.identifier("module"));
  8949. params.unshift(t.identifier("exports"));
  8950. var container = t.functionExpression(null, params, t.blockStatement(body));
  8951. var defineArgs = [names, container];
  8952. var moduleName = this.getModuleName();
  8953. if (moduleName) defineArgs.unshift(t.literal(moduleName));
  8954. var call = t.callExpression(t.identifier("define"), defineArgs);
  8955. program.body = [t.expressionStatement(call)];
  8956. };
  8957. /**
  8958. * Get the AMD module name that we'll prepend to the wrapper
  8959. * to define this module
  8960. */
  8961. AMDFormatter.prototype.getModuleName = function getModuleName() {
  8962. if (this.file.opts.moduleIds) {
  8963. return _default2["default"].prototype.getModuleName.apply(this, arguments);
  8964. } else {
  8965. return null;
  8966. }
  8967. };
  8968. AMDFormatter.prototype._getExternalReference = function _getExternalReference(node) {
  8969. return this.scope.generateUidIdentifier(node.source.value);
  8970. };
  8971. AMDFormatter.prototype.importDeclaration = function importDeclaration(node) {
  8972. this.getExternalReference(node);
  8973. };
  8974. AMDFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
  8975. var key = node.source.value;
  8976. var ref = this.getExternalReference(node);
  8977. if (t.isImportNamespaceSpecifier(specifier) || t.isImportDefaultSpecifier(specifier)) {
  8978. this.defaultIds[key] = specifier.local;
  8979. }
  8980. if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
  8981. // prevent unnecessary renaming of dynamic imports
  8982. this.ids[node.source.value] = ref;
  8983. ref = t.memberExpression(ref, t.identifier("default"));
  8984. } else if (t.isImportNamespaceSpecifier(specifier)) {} else if (!(0, _lodashCollectionIncludes2["default"])(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
  8985. // import foo from "foo";
  8986. var uid = this.scope.generateUidIdentifier(specifier.local.name);
  8987. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require"), [ref]))]));
  8988. ref = uid;
  8989. } else {
  8990. // import { foo } from "foo";
  8991. var imported = specifier.imported;
  8992. if (t.isSpecifierDefault(specifier)) imported = t.identifier("default");
  8993. ref = t.memberExpression(ref, imported);
  8994. }
  8995. this.internalRemap[specifier.local.name] = ref;
  8996. };
  8997. AMDFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
  8998. if (this.doDefaultExportInterop(specifier)) {
  8999. this.passModuleArg = true;
  9000. if (specifier.exported !== specifier.local && !node.source) {
  9001. nodes.push(util.template("exports-default-assign", {
  9002. VALUE: specifier.local
  9003. }, true));
  9004. return;
  9005. }
  9006. }
  9007. _common2["default"].prototype.exportSpecifier.apply(this, arguments);
  9008. };
  9009. AMDFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
  9010. if (this.doDefaultExportInterop(node)) {
  9011. this.passModuleArg = true;
  9012. var declar = node.declaration;
  9013. var assign = util.template("exports-default-assign", {
  9014. VALUE: this._pushStatement(declar, nodes)
  9015. }, true);
  9016. if (t.isFunctionDeclaration(declar)) {
  9017. // we can hoist this assignment to the top of the file
  9018. assign._blockHoist = 3;
  9019. }
  9020. nodes.push(assign);
  9021. return;
  9022. }
  9023. _default2["default"].prototype.exportDeclaration.apply(this, arguments);
  9024. };
  9025. return AMDFormatter;
  9026. })(_default2["default"]);
  9027. exports["default"] = AMDFormatter;
  9028. module.exports = exports["default"];
  9029. // absolute module reference
  9030. // import * as bar from "foo";
  9031. },{"../../types":169,"../../util":173,"./_default":72,"./common":77,"lodash/collection/includes":332,"lodash/object/values":424}],76:[function(require,module,exports){
  9032. "use strict";
  9033. exports.__esModule = true;
  9034. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9035. var _common = require("./common");
  9036. var _common2 = _interopRequireDefault(_common);
  9037. var _strict = require("./_strict");
  9038. var _strict2 = _interopRequireDefault(_strict);
  9039. exports["default"] = (0, _strict2["default"])(_common2["default"]);
  9040. module.exports = exports["default"];
  9041. },{"./_strict":73,"./common":77}],77:[function(require,module,exports){
  9042. "use strict";
  9043. exports.__esModule = true;
  9044. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9045. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9046. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9047. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
  9048. var _default = require("./_default");
  9049. var _default2 = _interopRequireDefault(_default);
  9050. var _lodashCollectionIncludes = require("lodash/collection/includes");
  9051. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  9052. var _util = require("../../util");
  9053. var util = _interopRequireWildcard(_util);
  9054. var _types = require("../../types");
  9055. var t = _interopRequireWildcard(_types);
  9056. var CommonJSFormatter = (function (_DefaultFormatter) {
  9057. function CommonJSFormatter() {
  9058. _classCallCheck(this, CommonJSFormatter);
  9059. if (_DefaultFormatter != null) {
  9060. _DefaultFormatter.apply(this, arguments);
  9061. }
  9062. }
  9063. _inherits(CommonJSFormatter, _DefaultFormatter);
  9064. CommonJSFormatter.prototype.setup = function setup() {
  9065. this._setup(this.hasLocalExports);
  9066. };
  9067. CommonJSFormatter.prototype._setup = function _setup(conditional) {
  9068. var file = this.file;
  9069. var scope = file.scope;
  9070. scope.rename("module");
  9071. scope.rename("exports");
  9072. if (!this.noInteropRequireImport && conditional) {
  9073. var templateName = "exports-module-declaration";
  9074. if (this.file.isLoose("es6.modules")) templateName += "-loose";
  9075. var declar = util.template(templateName, true);
  9076. declar._blockHoist = 3;
  9077. file.path.unshiftContainer("body", [declar]);
  9078. }
  9079. };
  9080. CommonJSFormatter.prototype.transform = function transform(program) {
  9081. _default2["default"].prototype.transform.apply(this, arguments);
  9082. if (this.hasDefaultOnlyExport) {
  9083. program.body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("module"), t.identifier("exports")), t.memberExpression(t.identifier("exports"), t.identifier("default")))));
  9084. }
  9085. };
  9086. CommonJSFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
  9087. var variableName = specifier.local;
  9088. var ref = this.getExternalReference(node, nodes);
  9089. // import foo from "foo";
  9090. if (t.isSpecifierDefault(specifier)) {
  9091. if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
  9092. this.internalRemap[variableName.name] = ref;
  9093. } else if (this.noInteropRequireImport) {
  9094. this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"));
  9095. } else {
  9096. var uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
  9097. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-default"), [ref]))]));
  9098. this.internalRemap[variableName.name] = t.memberExpression(uid, t.identifier("default"));
  9099. }
  9100. } else {
  9101. if (t.isImportNamespaceSpecifier(specifier)) {
  9102. if (!this.noInteropRequireImport) {
  9103. ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);
  9104. }
  9105. // import * as bar from "foo";
  9106. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));
  9107. } else {
  9108. // import { foo } from "foo";
  9109. this.internalRemap[variableName.name] = t.memberExpression(ref, specifier.imported);
  9110. }
  9111. }
  9112. };
  9113. CommonJSFormatter.prototype.importDeclaration = function importDeclaration(node, nodes) {
  9114. // import "foo";
  9115. nodes.push(util.template("require", {
  9116. MODULE_NAME: node.source
  9117. }, true));
  9118. };
  9119. CommonJSFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
  9120. if (this.doDefaultExportInterop(specifier)) {
  9121. this.hasDefaultOnlyExport = true;
  9122. }
  9123. _default2["default"].prototype.exportSpecifier.apply(this, arguments);
  9124. };
  9125. CommonJSFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
  9126. if (this.doDefaultExportInterop(node)) {
  9127. this.hasDefaultOnlyExport = true;
  9128. }
  9129. _default2["default"].prototype.exportDeclaration.apply(this, arguments);
  9130. };
  9131. CommonJSFormatter.prototype._getExternalReference = function _getExternalReference(node, nodes) {
  9132. var source = node.source.value;
  9133. var call = t.callExpression(t.identifier("require"), [node.source]);
  9134. var uid;
  9135. if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
  9136. call = t.memberExpression(call, t.identifier("default"));
  9137. } else {
  9138. uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
  9139. }
  9140. uid = uid || node.specifiers[0].local;
  9141. var declar = t.variableDeclaration("var", [t.variableDeclarator(uid, call)]);
  9142. nodes.push(declar);
  9143. return uid;
  9144. };
  9145. return CommonJSFormatter;
  9146. })(_default2["default"]);
  9147. exports["default"] = CommonJSFormatter;
  9148. module.exports = exports["default"];
  9149. // absolute module reference
  9150. // absolute module reference
  9151. },{"../../types":169,"../../util":173,"./_default":72,"lodash/collection/includes":332}],78:[function(require,module,exports){
  9152. "use strict";
  9153. exports.__esModule = true;
  9154. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9155. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9156. var _types = require("../../types");
  9157. var t = _interopRequireWildcard(_types);
  9158. var IgnoreFormatter = (function () {
  9159. function IgnoreFormatter() {
  9160. _classCallCheck(this, IgnoreFormatter);
  9161. }
  9162. IgnoreFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
  9163. var declar = t.toStatement(node.declaration, true);
  9164. if (declar) nodes.push(t.inherits(declar, node));
  9165. };
  9166. IgnoreFormatter.prototype.exportAllDeclaration = function exportAllDeclaration() {};
  9167. IgnoreFormatter.prototype.importDeclaration = function importDeclaration() {};
  9168. IgnoreFormatter.prototype.importSpecifier = function importSpecifier() {};
  9169. IgnoreFormatter.prototype.exportSpecifier = function exportSpecifier() {};
  9170. return IgnoreFormatter;
  9171. })();
  9172. exports["default"] = IgnoreFormatter;
  9173. module.exports = exports["default"];
  9174. },{"../../types":169}],79:[function(require,module,exports){
  9175. "use strict";
  9176. exports.__esModule = true;
  9177. exports["default"] = {
  9178. commonStrict: require("./common-strict"),
  9179. amdStrict: require("./amd-strict"),
  9180. umdStrict: require("./umd-strict"),
  9181. common: require("./common"),
  9182. system: require("./system"),
  9183. ignore: require("./ignore"),
  9184. amd: require("./amd"),
  9185. umd: require("./umd")
  9186. };
  9187. module.exports = exports["default"];
  9188. },{"./amd":75,"./amd-strict":74,"./common":77,"./common-strict":76,"./ignore":78,"./system":80,"./umd":82,"./umd-strict":81}],80:[function(require,module,exports){
  9189. "use strict";
  9190. exports.__esModule = true;
  9191. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9192. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9193. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9194. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
  9195. var _default = require("./_default");
  9196. var _default2 = _interopRequireDefault(_default);
  9197. var _amd = require("./amd");
  9198. var _amd2 = _interopRequireDefault(_amd);
  9199. var _helpersObject = require("../../helpers/object");
  9200. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  9201. var _util = require("../../util");
  9202. var util = _interopRequireWildcard(_util);
  9203. var _lodashArrayLast = require("lodash/array/last");
  9204. var _lodashArrayLast2 = _interopRequireDefault(_lodashArrayLast);
  9205. var _lodashCollectionEach = require("lodash/collection/each");
  9206. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  9207. var _lodashCollectionMap = require("lodash/collection/map");
  9208. var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
  9209. var _types = require("../../types");
  9210. var t = _interopRequireWildcard(_types);
  9211. var hoistVariablesVisitor = {
  9212. enter: function enter(node, parent, scope, state) {
  9213. if (t.isFunction(node)) {
  9214. // nothing inside is accessible
  9215. return this.skip();
  9216. }
  9217. if (t.isVariableDeclaration(node)) {
  9218. if (node.kind !== "var" && !t.isProgram(parent)) {
  9219. // let, const
  9220. // can't be accessed
  9221. return;
  9222. }
  9223. // ignore block hoisted nodes as these can be left in
  9224. if (state.formatter._canHoist(node)) return;
  9225. var nodes = [];
  9226. for (var i = 0; i < node.declarations.length; i++) {
  9227. var declar = node.declarations[i];
  9228. state.hoistDeclarators.push(t.variableDeclarator(declar.id));
  9229. if (declar.init) {
  9230. // no initializer so we can just hoist it as-is
  9231. var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
  9232. nodes.push(assign);
  9233. }
  9234. }
  9235. // for (var i in test)
  9236. // for (var i = 0;;)
  9237. if (t.isFor(parent) && parent.left === node) {
  9238. return node.declarations[0].id;
  9239. }
  9240. return nodes;
  9241. }
  9242. }
  9243. };
  9244. var hoistFunctionsVisitor = {
  9245. enter: function enter(node, parent, scope, state) {
  9246. if (t.isFunction(node)) this.skip();
  9247. if (t.isFunctionDeclaration(node) || state.formatter._canHoist(node)) {
  9248. state.handlerBody.push(node);
  9249. this.remove();
  9250. }
  9251. }
  9252. };
  9253. var runnerSettersVisitor = {
  9254. enter: function enter(node, parent, scope, state) {
  9255. if (node._importSource === state.source) {
  9256. if (t.isVariableDeclaration(node)) {
  9257. var _arr = node.declarations;
  9258. for (var _i = 0; _i < _arr.length; _i++) {
  9259. var declar = _arr[_i];
  9260. state.hoistDeclarators.push(t.variableDeclarator(declar.id));
  9261. state.nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
  9262. }
  9263. } else {
  9264. state.nodes.push(node);
  9265. }
  9266. this.remove();
  9267. }
  9268. }
  9269. };
  9270. var SystemFormatter = (function (_AMDFormatter) {
  9271. function SystemFormatter(file) {
  9272. _classCallCheck(this, SystemFormatter);
  9273. _AMDFormatter.call(this, file);
  9274. this.exportIdentifier = file.scope.generateUidIdentifier("export");
  9275. this.noInteropRequireExport = true;
  9276. this.noInteropRequireImport = true;
  9277. }
  9278. _inherits(SystemFormatter, _AMDFormatter);
  9279. SystemFormatter.prototype._addImportSource = function _addImportSource(node, exportNode) {
  9280. if (node) node._importSource = exportNode.source && exportNode.source.value;
  9281. return node;
  9282. };
  9283. SystemFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier, node) {
  9284. var leftIdentifier = this.scope.generateUidIdentifier("key");
  9285. var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
  9286. var left = t.variableDeclaration("var", [t.variableDeclarator(leftIdentifier)]);
  9287. var right = objectIdentifier;
  9288. var block = t.blockStatement([t.expressionStatement(this._buildExportCall(leftIdentifier, valIdentifier))]);
  9289. return this._addImportSource(t.forInStatement(left, right, block), node);
  9290. };
  9291. SystemFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init, node) {
  9292. var call = this._buildExportCall(t.literal(id.name), init, true);
  9293. return this._addImportSource(call, node);
  9294. };
  9295. SystemFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment() {
  9296. return this.buildExportsAssignment.apply(this, arguments);
  9297. };
  9298. SystemFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
  9299. var assign = node;
  9300. for (var i = 0; i < exported.length; i++) {
  9301. assign = this._buildExportCall(t.literal(exported[i].name), assign);
  9302. }
  9303. return assign;
  9304. };
  9305. SystemFormatter.prototype._buildExportCall = function _buildExportCall(id, init, isStatement) {
  9306. var call = t.callExpression(this.exportIdentifier, [id, init]);
  9307. if (isStatement) {
  9308. return t.expressionStatement(call);
  9309. } else {
  9310. return call;
  9311. }
  9312. };
  9313. SystemFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
  9314. _amd2["default"].prototype.importSpecifier.apply(this, arguments);
  9315. for (var name in this.internalRemap) {
  9316. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(t.identifier(name), this.internalRemap[name])]));
  9317. }
  9318. this.internalRemap = (0, _helpersObject2["default"])();
  9319. this._addImportSource((0, _lodashArrayLast2["default"])(nodes), node);
  9320. };
  9321. SystemFormatter.prototype._buildRunnerSetters = function _buildRunnerSetters(block, hoistDeclarators) {
  9322. var scope = this.file.scope;
  9323. return t.arrayExpression((0, _lodashCollectionMap2["default"])(this.ids, function (uid, source) {
  9324. var state = {
  9325. hoistDeclarators: hoistDeclarators,
  9326. source: source,
  9327. nodes: []
  9328. };
  9329. scope.traverse(block, runnerSettersVisitor, state);
  9330. return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
  9331. }));
  9332. };
  9333. SystemFormatter.prototype._canHoist = function _canHoist(node) {
  9334. return node._blockHoist && !this.file.dynamicImports.length;
  9335. };
  9336. SystemFormatter.prototype.transform = function transform(program) {
  9337. _default2["default"].prototype.transform.apply(this, arguments);
  9338. var hoistDeclarators = [];
  9339. var moduleName = this.getModuleName();
  9340. var moduleNameLiteral = t.literal(moduleName);
  9341. var block = t.blockStatement(program.body);
  9342. var runner = util.template("system", {
  9343. MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
  9344. EXPORT_IDENTIFIER: this.exportIdentifier,
  9345. MODULE_NAME: moduleNameLiteral,
  9346. SETTERS: this._buildRunnerSetters(block, hoistDeclarators),
  9347. EXECUTE: t.functionExpression(null, [], block)
  9348. }, true);
  9349. var handlerBody = runner.expression.arguments[2].body.body;
  9350. if (!moduleName) runner.expression.arguments.shift();
  9351. var returnStatement = handlerBody.pop();
  9352. // hoist up all variable declarations
  9353. this.file.scope.traverse(block, hoistVariablesVisitor, {
  9354. formatter: this,
  9355. hoistDeclarators: hoistDeclarators
  9356. });
  9357. if (hoistDeclarators.length) {
  9358. var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
  9359. hoistDeclar._blockHoist = true;
  9360. handlerBody.unshift(hoistDeclar);
  9361. }
  9362. // hoist up function declarations for circular references
  9363. this.file.scope.traverse(block, hoistFunctionsVisitor, {
  9364. formatter: this,
  9365. handlerBody: handlerBody
  9366. });
  9367. handlerBody.push(returnStatement);
  9368. program.body = [runner];
  9369. };
  9370. return SystemFormatter;
  9371. })(_amd2["default"]);
  9372. exports["default"] = SystemFormatter;
  9373. module.exports = exports["default"];
  9374. },{"../../helpers/object":45,"../../types":169,"../../util":173,"./_default":72,"./amd":75,"lodash/array/last":326,"lodash/collection/each":330,"lodash/collection/map":333}],81:[function(require,module,exports){
  9375. "use strict";
  9376. exports.__esModule = true;
  9377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9378. var _umd = require("./umd");
  9379. var _umd2 = _interopRequireDefault(_umd);
  9380. var _strict = require("./_strict");
  9381. var _strict2 = _interopRequireDefault(_strict);
  9382. exports["default"] = (0, _strict2["default"])(_umd2["default"]);
  9383. module.exports = exports["default"];
  9384. },{"./_strict":73,"./umd":82}],82:[function(require,module,exports){
  9385. "use strict";
  9386. exports.__esModule = true;
  9387. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9388. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9389. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9390. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
  9391. var _default = require("./_default");
  9392. var _default2 = _interopRequireDefault(_default);
  9393. var _amd = require("./amd");
  9394. var _amd2 = _interopRequireDefault(_amd);
  9395. var _lodashObjectValues = require("lodash/object/values");
  9396. var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
  9397. var _path = require("path");
  9398. var _path2 = _interopRequireDefault(_path);
  9399. var _util = require("../../util");
  9400. var util = _interopRequireWildcard(_util);
  9401. var _types = require("../../types");
  9402. var t = _interopRequireWildcard(_types);
  9403. var UMDFormatter = (function (_AMDFormatter) {
  9404. function UMDFormatter() {
  9405. _classCallCheck(this, UMDFormatter);
  9406. if (_AMDFormatter != null) {
  9407. _AMDFormatter.apply(this, arguments);
  9408. }
  9409. }
  9410. _inherits(UMDFormatter, _AMDFormatter);
  9411. UMDFormatter.prototype.transform = function transform(program) {
  9412. _default2["default"].prototype.transform.apply(this, arguments);
  9413. var body = program.body;
  9414. // build an array of module names
  9415. var names = [];
  9416. for (var _name in this.ids) {
  9417. names.push(t.literal(_name));
  9418. }
  9419. // factory
  9420. var ids = (0, _lodashObjectValues2["default"])(this.ids);
  9421. var args = [t.identifier("exports")];
  9422. if (this.passModuleArg) args.push(t.identifier("module"));
  9423. args = args.concat(ids);
  9424. var factory = t.functionExpression(null, args, t.blockStatement(body));
  9425. // amd
  9426. var defineArgs = [t.literal("exports")];
  9427. if (this.passModuleArg) defineArgs.push(t.literal("module"));
  9428. defineArgs = defineArgs.concat(names);
  9429. defineArgs = [t.arrayExpression(defineArgs)];
  9430. // common
  9431. var testExports = util.template("test-exports");
  9432. var testModule = util.template("test-module");
  9433. var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
  9434. var commonArgs = [t.identifier("exports")];
  9435. if (this.passModuleArg) commonArgs.push(t.identifier("module"));
  9436. commonArgs = commonArgs.concat(names.map(function (name) {
  9437. return t.callExpression(t.identifier("require"), [name]);
  9438. }));
  9439. // globals
  9440. var browserArgs = [];
  9441. if (this.passModuleArg) browserArgs.push(t.identifier("mod"));
  9442. for (var _name2 in this.ids) {
  9443. var id = this.defaultIds[_name2] || t.identifier(t.toIdentifier(_path2["default"].basename(_name2, _path2["default"].extname(_name2))));
  9444. browserArgs.push(t.memberExpression(t.identifier("global"), id));
  9445. }
  9446. //
  9447. var moduleName = this.getModuleName();
  9448. if (moduleName) defineArgs.unshift(t.literal(moduleName));
  9449. //
  9450. var globalArg = this.file.opts.basename;
  9451. if (moduleName) globalArg = moduleName;
  9452. globalArg = t.identifier(t.toIdentifier(globalArg));
  9453. var runner = util.template("umd-runner-body", {
  9454. AMD_ARGUMENTS: defineArgs,
  9455. COMMON_TEST: commonTests,
  9456. COMMON_ARGUMENTS: commonArgs,
  9457. BROWSER_ARGUMENTS: browserArgs,
  9458. GLOBAL_ARG: globalArg
  9459. });
  9460. //
  9461. program.body = [t.expressionStatement(t.callExpression(runner, [t.thisExpression(), factory]))];
  9462. };
  9463. return UMDFormatter;
  9464. })(_amd2["default"]);
  9465. exports["default"] = UMDFormatter;
  9466. module.exports = exports["default"];
  9467. },{"../../types":169,"../../util":173,"./_default":72,"./amd":75,"lodash/object/values":424,"path":199}],83:[function(require,module,exports){
  9468. "use strict";
  9469. exports.__esModule = true;
  9470. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9471. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9472. var _lodashCollectionIncludes = require("lodash/collection/includes");
  9473. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  9474. var _traversal = require("../traversal");
  9475. var _traversal2 = _interopRequireDefault(_traversal);
  9476. /**
  9477. * This class is responsible for traversing over the provided `File`s
  9478. * AST and running it's parent transformers handlers over it.
  9479. */
  9480. var TransformerPass = (function () {
  9481. function TransformerPass(file, transformer) {
  9482. _classCallCheck(this, TransformerPass);
  9483. this.transformer = transformer;
  9484. this.handlers = transformer.handlers;
  9485. this.file = file;
  9486. this.ran = false;
  9487. this.key = transformer.key;
  9488. }
  9489. TransformerPass.prototype.canTransform = function canTransform() {
  9490. return this.file.transformerDependencies[this.key] || this.file.pipeline.canTransform(this.transformer, this.file.opts);
  9491. };
  9492. TransformerPass.prototype.transform = function transform() {
  9493. var file = this.file;
  9494. file.log.debug("Start transformer " + this.key);
  9495. (0, _traversal2["default"])(file.ast, this.handlers, file.scope, file);
  9496. file.log.debug("Finish transformer " + this.key);
  9497. this.ran = true;
  9498. };
  9499. return TransformerPass;
  9500. })();
  9501. exports["default"] = TransformerPass;
  9502. module.exports = exports["default"];
  9503. },{"../traversal":157,"lodash/collection/includes":332}],84:[function(require,module,exports){
  9504. "use strict";
  9505. exports.__esModule = true;
  9506. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9507. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9508. var _transformer = require("./transformer");
  9509. var _transformer2 = _interopRequireDefault(_transformer);
  9510. var _helpersNormalizeAst = require("../helpers/normalize-ast");
  9511. var _helpersNormalizeAst2 = _interopRequireDefault(_helpersNormalizeAst);
  9512. var _lodashObjectAssign = require("lodash/object/assign");
  9513. var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
  9514. var _helpersObject = require("../helpers/object");
  9515. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  9516. var _file = require("./file");
  9517. var _file2 = _interopRequireDefault(_file);
  9518. var TransformerPipeline = (function () {
  9519. function TransformerPipeline() {
  9520. _classCallCheck(this, TransformerPipeline);
  9521. this.transformers = (0, _helpersObject2["default"])();
  9522. this.namespaces = (0, _helpersObject2["default"])();
  9523. this.deprecated = (0, _helpersObject2["default"])();
  9524. this.aliases = (0, _helpersObject2["default"])();
  9525. this.filters = [];
  9526. }
  9527. TransformerPipeline.prototype.addTransformers = function addTransformers(transformers) {
  9528. for (var key in transformers) {
  9529. this.addTransformer(key, transformers[key]);
  9530. }
  9531. return this;
  9532. };
  9533. TransformerPipeline.prototype.addTransformer = function addTransformer(key, transformer) {
  9534. if (this.transformers[key]) throw new Error(); // todo: error
  9535. var namespace = key.split(".")[0];
  9536. this.namespaces[namespace] = this.namespaces[namespace] || [];
  9537. this.namespaces[namespace].push(key);
  9538. this.namespaces[key] = namespace;
  9539. this.transformers[key] = new _transformer2["default"](key, transformer);
  9540. };
  9541. TransformerPipeline.prototype.addAliases = function addAliases(names) {
  9542. (0, _lodashObjectAssign2["default"])(this.aliases, names);
  9543. return this;
  9544. };
  9545. TransformerPipeline.prototype.addDeprecated = function addDeprecated(names) {
  9546. (0, _lodashObjectAssign2["default"])(this.deprecated, names);
  9547. return this;
  9548. };
  9549. TransformerPipeline.prototype.addFilter = function addFilter(filter) {
  9550. this.filters.push(filter);
  9551. return this;
  9552. };
  9553. TransformerPipeline.prototype.canTransform = function canTransform(transformer, fileOpts) {
  9554. if (transformer.metadata.plugin) return true;
  9555. var _arr = this.filters;
  9556. for (var _i = 0; _i < _arr.length; _i++) {
  9557. var filter = _arr[_i];
  9558. var result = filter(transformer, fileOpts);
  9559. if (result != null) return result;
  9560. }
  9561. return true;
  9562. };
  9563. TransformerPipeline.prototype.transform = function transform(code, opts) {
  9564. var file = new _file2["default"](opts, this);
  9565. return file.wrap(code, function () {
  9566. file.addCode(code, true);
  9567. });
  9568. };
  9569. TransformerPipeline.prototype.transformFromAst = function transformFromAst(ast, code, opts) {
  9570. ast = (0, _helpersNormalizeAst2["default"])(ast);
  9571. var file = new _file2["default"](opts, this);
  9572. return file.wrap(code, function () {
  9573. file.addCode(code);
  9574. file.addAst(ast);
  9575. });
  9576. };
  9577. TransformerPipeline.prototype._ensureTransformerNames = function _ensureTransformerNames(type, rawKeys) {
  9578. var keys = [];
  9579. for (var i = 0; i < rawKeys.length; i++) {
  9580. var key = rawKeys[i];
  9581. var deprecatedKey = this.deprecated[key];
  9582. var aliasKey = this.aliases[key];
  9583. if (aliasKey) {
  9584. keys.push(aliasKey);
  9585. } else if (deprecatedKey) {
  9586. // deprecated key, remap it to the new one
  9587. console.error("[BABEL] The transformer " + key + " has been renamed to " + deprecatedKey);
  9588. rawKeys.push(deprecatedKey);
  9589. } else if (this.transformers[key]) {
  9590. // valid key
  9591. keys.push(key);
  9592. } else if (this.namespaces[key]) {
  9593. // namespace, append all transformers within this namespace
  9594. keys = keys.concat(this.namespaces[key]);
  9595. } else {
  9596. // invalid key
  9597. throw new ReferenceError("Unknown transformer " + key + " specified in " + type);
  9598. }
  9599. }
  9600. return keys;
  9601. };
  9602. return TransformerPipeline;
  9603. })();
  9604. exports["default"] = TransformerPipeline;
  9605. module.exports = exports["default"];
  9606. },{"../helpers/normalize-ast":44,"../helpers/object":45,"./file":52,"./transformer":85,"lodash/object/assign":417}],85:[function(require,module,exports){
  9607. "use strict";
  9608. exports.__esModule = true;
  9609. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9610. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9612. var _transformerPass = require("./transformer-pass");
  9613. var _transformerPass2 = _interopRequireDefault(_transformerPass);
  9614. var _messages = require("../messages");
  9615. var messages = _interopRequireWildcard(_messages);
  9616. var _lodashLangIsFunction = require("lodash/lang/isFunction");
  9617. var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
  9618. var _traversal = require("../traversal");
  9619. var _traversal2 = _interopRequireDefault(_traversal);
  9620. var _lodashLangIsObject = require("lodash/lang/isObject");
  9621. var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
  9622. var _lodashObjectAssign = require("lodash/object/assign");
  9623. var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
  9624. var _acorn = require("../../acorn");
  9625. var acorn = _interopRequireWildcard(_acorn);
  9626. var _file = require("./file");
  9627. var _file2 = _interopRequireDefault(_file);
  9628. var _lodashCollectionEach = require("lodash/collection/each");
  9629. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  9630. /**
  9631. * This is the class responsible for normalising a transformers handlers
  9632. * as well as constructing a `TransformerPass` that is responsible for
  9633. * actually running the transformer over the provided `File`.
  9634. */
  9635. var Transformer = (function () {
  9636. function Transformer(transformerKey, transformer) {
  9637. _classCallCheck(this, Transformer);
  9638. transformer = (0, _lodashObjectAssign2["default"])({}, transformer);
  9639. var take = function take(key) {
  9640. var val = transformer[key];
  9641. delete transformer[key];
  9642. return val;
  9643. };
  9644. this.manipulateOptions = take("manipulateOptions");
  9645. this.metadata = take("metadata") || {};
  9646. this.dependencies = this.metadata.dependencies || [];
  9647. this.parser = take("parser");
  9648. this.post = take("post");
  9649. this.pre = take("pre");
  9650. //
  9651. if (this.metadata.stage != null) {
  9652. this.metadata.optional = true;
  9653. }
  9654. //
  9655. this.handlers = this.normalize(transformer);
  9656. this.key = transformerKey;
  9657. }
  9658. Transformer.prototype.normalize = function normalize(transformer) {
  9659. var _this = this;
  9660. if ((0, _lodashLangIsFunction2["default"])(transformer)) {
  9661. transformer = { ast: transformer };
  9662. }
  9663. _traversal2["default"].explode(transformer);
  9664. (0, _lodashCollectionEach2["default"])(transformer, function (fns, type) {
  9665. // hidden property
  9666. if (type[0] === "_") {
  9667. _this[type] = fns;
  9668. return;
  9669. }
  9670. if (type === "enter" || type === "exit") return;
  9671. if ((0, _lodashLangIsFunction2["default"])(fns)) fns = { enter: fns };
  9672. if (!(0, _lodashLangIsObject2["default"])(fns)) return;
  9673. if (!fns.enter) fns.enter = function () {};
  9674. if (!fns.exit) fns.exit = function () {};
  9675. transformer[type] = fns;
  9676. });
  9677. return transformer;
  9678. };
  9679. Transformer.prototype.buildPass = function buildPass(file) {
  9680. // validate Transformer instance
  9681. if (!(file instanceof _file2["default"])) {
  9682. throw new TypeError(messages.get("transformerNotFile", this.key));
  9683. }
  9684. return new _transformerPass2["default"](file, this);
  9685. };
  9686. return Transformer;
  9687. })();
  9688. exports["default"] = Transformer;
  9689. module.exports = exports["default"];
  9690. },{"../../acorn":1,"../messages":47,"../traversal":157,"./file":52,"./transformer-pass":83,"lodash/collection/each":330,"lodash/lang/isFunction":408,"lodash/lang/isObject":411,"lodash/object/assign":417}],86:[function(require,module,exports){
  9691. module.exports={
  9692. "useStrict": "strict",
  9693. "es5.runtime": "runtime",
  9694. "es6.runtime": "runtime"
  9695. }
  9696. },{}],87:[function(require,module,exports){
  9697. module.exports={
  9698. "selfContained": "runtime",
  9699. "unicode-regex": "regex.unicode",
  9700. "spec.typeofSymbol": "es6.spec.symbols",
  9701. "es6.symbols": "es6.spec.symbols",
  9702. "es6.blockScopingTDZ": "es6.spec.blockScoping",
  9703. "utility.inlineExpressions": "minification.inlineExpressions",
  9704. "utility.deadCodeElimination": "minification.deadCodeElimination",
  9705. "utility.removeConsoleCalls": "minification.removeConsole",
  9706. "utility.removeDebugger": "minification.removeDebugger"
  9707. }
  9708. },{}],88:[function(require,module,exports){
  9709. "use strict";
  9710. exports.__esModule = true;
  9711. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9712. var _types = require("../../../types");
  9713. var t = _interopRequireWildcard(_types);
  9714. var metadata = {
  9715. group: "builtin-trailing"
  9716. };
  9717. exports.metadata = metadata;
  9718. var MemberExpression = {
  9719. exit: function exit(node) {
  9720. var prop = node.property;
  9721. if (!node.computed && t.isIdentifier(prop) && !t.isValidIdentifier(prop.name)) {
  9722. // foo.default -> foo["default"]
  9723. node.property = t.literal(prop.name);
  9724. node.computed = true;
  9725. }
  9726. }
  9727. };
  9728. exports.MemberExpression = MemberExpression;
  9729. },{"../../../types":169}],89:[function(require,module,exports){
  9730. "use strict";
  9731. exports.__esModule = true;
  9732. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9733. var _types = require("../../../types");
  9734. var t = _interopRequireWildcard(_types);
  9735. var metadata = {
  9736. group: "builtin-trailing"
  9737. };
  9738. exports.metadata = metadata;
  9739. var Property = {
  9740. exit: function exit(node) {
  9741. var key = node.key;
  9742. if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) {
  9743. // default: "bar" -> "default": "bar"
  9744. node.key = t.literal(key.name);
  9745. }
  9746. }
  9747. };
  9748. exports.Property = Property;
  9749. },{"../../../types":169}],90:[function(require,module,exports){
  9750. "use strict";
  9751. exports.__esModule = true;
  9752. exports.ObjectExpression = ObjectExpression;
  9753. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9754. var _helpersDefineMap = require("../../helpers/define-map");
  9755. var defineMap = _interopRequireWildcard(_helpersDefineMap);
  9756. var _types = require("../../../types");
  9757. var t = _interopRequireWildcard(_types);
  9758. function ObjectExpression(node, parent, scope, file) {
  9759. var mutatorMap = {};
  9760. var hasAny = false;
  9761. node.properties = node.properties.filter(function (prop) {
  9762. if (prop.kind === "get" || prop.kind === "set") {
  9763. hasAny = true;
  9764. defineMap.push(mutatorMap, prop, prop.kind, file);
  9765. return false;
  9766. } else {
  9767. return true;
  9768. }
  9769. });
  9770. if (!hasAny) return;
  9771. return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")), [node, defineMap.toDefineObject(mutatorMap)]);
  9772. }
  9773. },{"../../../types":169,"../../helpers/define-map":61}],91:[function(require,module,exports){
  9774. "use strict";
  9775. exports.__esModule = true;
  9776. exports.ArrowFunctionExpression = ArrowFunctionExpression;
  9777. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9778. var _types = require("../../../types");
  9779. var t = _interopRequireWildcard(_types);
  9780. function ArrowFunctionExpression(node) {
  9781. t.ensureBlock(node);
  9782. node.expression = false;
  9783. node.type = "FunctionExpression";
  9784. node.shadow = true;
  9785. }
  9786. },{"../../../types":169}],92:[function(require,module,exports){
  9787. "use strict";
  9788. exports.__esModule = true;
  9789. exports.VariableDeclaration = VariableDeclaration;
  9790. exports.Loop = Loop;
  9791. exports.BlockStatement = BlockStatement;
  9792. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  9793. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9794. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9795. var _traversal = require("../../../traversal");
  9796. var _traversal2 = _interopRequireDefault(_traversal);
  9797. var _helpersObject = require("../../../helpers/object");
  9798. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  9799. var _util = require("../../../util");
  9800. var util = _interopRequireWildcard(_util);
  9801. var _types = require("../../../types");
  9802. var t = _interopRequireWildcard(_types);
  9803. var _lodashObjectValues = require("lodash/object/values");
  9804. var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
  9805. var _lodashObjectExtend = require("lodash/object/extend");
  9806. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  9807. function isLet(node, parent) {
  9808. if (!t.isVariableDeclaration(node)) return false;
  9809. if (node._let) return true;
  9810. if (node.kind !== "let") return false;
  9811. // https://github.com/babel/babel/issues/255
  9812. if (isLetInitable(node, parent)) {
  9813. for (var i = 0; i < node.declarations.length; i++) {
  9814. var declar = node.declarations[i];
  9815. declar.init = declar.init || t.identifier("undefined");
  9816. }
  9817. }
  9818. node._let = true;
  9819. node.kind = "var";
  9820. return true;
  9821. }
  9822. function isLetInitable(node, parent) {
  9823. return !t.isFor(parent) || !t.isFor(parent, { left: node });
  9824. }
  9825. function isVar(node, parent) {
  9826. return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
  9827. }
  9828. function standardizeLets(declars) {
  9829. var _arr = declars;
  9830. for (var _i = 0; _i < _arr.length; _i++) {
  9831. var declar = _arr[_i];
  9832. delete declar._let;
  9833. }
  9834. }
  9835. var metadata = {
  9836. group: "builtin-advanced"
  9837. };
  9838. exports.metadata = metadata;
  9839. function VariableDeclaration(node, parent, scope, file) {
  9840. if (!isLet(node, parent)) return;
  9841. if (isLetInitable(node) && file.transformers["es6.spec.blockScoping"].canTransform()) {
  9842. var nodes = [node];
  9843. for (var i = 0; i < node.declarations.length; i++) {
  9844. var decl = node.declarations[i];
  9845. if (decl.init) {
  9846. var assign = t.assignmentExpression("=", decl.id, decl.init);
  9847. assign._ignoreBlockScopingTDZ = true;
  9848. nodes.push(t.expressionStatement(assign));
  9849. }
  9850. decl.init = file.addHelper("temporal-undefined");
  9851. }
  9852. node._blockHoist = 2;
  9853. return nodes;
  9854. }
  9855. }
  9856. function Loop(node, parent, scope, file) {
  9857. var init = node.left || node.init;
  9858. if (isLet(init, node)) {
  9859. t.ensureBlock(node);
  9860. node.body._letDeclarators = [init];
  9861. }
  9862. var blockScoping = new BlockScoping(this, this.get("body"), parent, scope, file);
  9863. return blockScoping.run();
  9864. }
  9865. function BlockStatement(block, parent, scope, file) {
  9866. if (!t.isLoop(parent)) {
  9867. var blockScoping = new BlockScoping(null, this, parent, scope, file);
  9868. blockScoping.run();
  9869. }
  9870. }
  9871. exports.Program = BlockStatement;
  9872. function replace(node, parent, scope, remaps) {
  9873. if (!t.isReferencedIdentifier(node, parent)) return;
  9874. var remap = remaps[node.name];
  9875. if (!remap) return;
  9876. var ownBinding = scope.getBindingIdentifier(node.name);
  9877. if (ownBinding === remap.binding) {
  9878. node.name = remap.uid;
  9879. } else {
  9880. // scope already has it's own binding that doesn't
  9881. // match the one we have a stored replacement for
  9882. if (this) this.skip();
  9883. }
  9884. }
  9885. var replaceVisitor = {
  9886. enter: replace
  9887. };
  9888. function traverseReplace(node, parent, scope, remaps) {
  9889. replace(node, parent, scope, remaps);
  9890. scope.traverse(node, replaceVisitor, remaps);
  9891. }
  9892. var letReferenceBlockVisitor = {
  9893. Function: function Function(node, parent, scope, state) {
  9894. this.traverse(letReferenceFunctionVisitor, state);
  9895. return this.skip();
  9896. }
  9897. };
  9898. var letReferenceFunctionVisitor = {
  9899. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  9900. var ref = state.letReferences[node.name];
  9901. // not a part of our scope
  9902. if (!ref) return;
  9903. // this scope has a variable with the same name so it couldn't belong
  9904. // to our let scope
  9905. if (scope.getBindingIdentifier(node.name) !== ref) return;
  9906. state.closurify = true;
  9907. }
  9908. };
  9909. var hoistVarDeclarationsVisitor = {
  9910. enter: function enter(node, parent, scope, self) {
  9911. if (this.isForStatement()) {
  9912. if (isVar(node.init, node)) {
  9913. var nodes = self.pushDeclar(node.init);
  9914. if (nodes.length === 1) {
  9915. node.init = nodes[0];
  9916. } else {
  9917. node.init = t.sequenceExpression(nodes);
  9918. }
  9919. }
  9920. } else if (this.isFor()) {
  9921. if (isVar(node.left, node)) {
  9922. node.left = node.left.declarations[0].id;
  9923. }
  9924. } else if (isVar(node, parent)) {
  9925. return self.pushDeclar(node).map(t.expressionStatement);
  9926. } else if (this.isFunction()) {
  9927. return this.skip();
  9928. }
  9929. }
  9930. };
  9931. var loopLabelVisitor = {
  9932. LabeledStatement: function LabeledStatement(node, parent, scope, state) {
  9933. state.innerLabels.push(node.label.name);
  9934. }
  9935. };
  9936. var continuationVisitor = {
  9937. enter: function enter(node, parent, scope, state) {
  9938. if (this.isAssignmentExpression() || this.isUpdateExpression()) {
  9939. var bindings = this.getBindingIdentifiers();
  9940. for (var name in bindings) {
  9941. if (state.outsideReferences[name] !== scope.getBindingIdentifier(name)) continue;
  9942. state.reassignments[name] = true;
  9943. }
  9944. }
  9945. }
  9946. };
  9947. var loopNodeTo = function loopNodeTo(node) {
  9948. if (t.isBreakStatement(node)) {
  9949. return "break";
  9950. } else if (t.isContinueStatement(node)) {
  9951. return "continue";
  9952. }
  9953. };
  9954. var loopVisitor = {
  9955. Loop: function Loop(node, parent, scope, state) {
  9956. var oldIgnoreLabeless = state.ignoreLabeless;
  9957. state.ignoreLabeless = true;
  9958. this.traverse(loopVisitor, state);
  9959. state.ignoreLabeless = oldIgnoreLabeless;
  9960. this.skip();
  9961. },
  9962. Function: function Function() {
  9963. this.skip();
  9964. },
  9965. SwitchCase: function SwitchCase(node, parent, scope, state) {
  9966. var oldInSwitchCase = state.inSwitchCase;
  9967. state.inSwitchCase = true;
  9968. this.traverse(loopVisitor, state);
  9969. state.inSwitchCase = oldInSwitchCase;
  9970. this.skip();
  9971. },
  9972. enter: function enter(node, parent, scope, state) {
  9973. var replace;
  9974. var loopText = loopNodeTo(node);
  9975. if (loopText) {
  9976. if (node.label) {
  9977. // we shouldn't be transforming this because it exists somewhere inside
  9978. if (state.innerLabels.indexOf(node.label.name) >= 0) {
  9979. return;
  9980. }
  9981. loopText = "" + loopText + "|" + node.label.name;
  9982. } else {
  9983. // we shouldn't be transforming these statements because
  9984. // they don't refer to the actual loop we're scopifying
  9985. if (state.ignoreLabeless) return;
  9986. //
  9987. if (state.inSwitchCase) return;
  9988. // break statements mean something different in this context
  9989. if (t.isBreakStatement(node) && t.isSwitchCase(parent)) return;
  9990. }
  9991. state.hasBreakContinue = true;
  9992. state.map[loopText] = node;
  9993. replace = t.literal(loopText);
  9994. }
  9995. if (this.isReturnStatement()) {
  9996. state.hasReturn = true;
  9997. replace = t.objectExpression([t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))]);
  9998. }
  9999. if (replace) {
  10000. replace = t.returnStatement(replace);
  10001. this.skip();
  10002. return t.inherits(replace, node);
  10003. }
  10004. }
  10005. };
  10006. var BlockScoping = (function () {
  10007. /**
  10008. * Description
  10009. */
  10010. function BlockScoping(loopPath, blockPath, parent, scope, file) {
  10011. _classCallCheck(this, BlockScoping);
  10012. this.parent = parent;
  10013. this.scope = scope;
  10014. this.file = file;
  10015. this.blockPath = blockPath;
  10016. this.block = blockPath.node;
  10017. this.outsideLetReferences = (0, _helpersObject2["default"])();
  10018. this.hasLetReferences = false;
  10019. this.letReferences = this.block._letReferences = (0, _helpersObject2["default"])();
  10020. this.body = [];
  10021. if (loopPath) {
  10022. this.loopParent = loopPath.parent;
  10023. this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
  10024. this.loopPath = loopPath;
  10025. this.loop = loopPath.node;
  10026. }
  10027. }
  10028. /**
  10029. * Start the ball rolling.
  10030. */
  10031. BlockScoping.prototype.run = function run() {
  10032. var block = this.block;
  10033. if (block._letDone) return;
  10034. block._letDone = true;
  10035. var needsClosure = this.getLetReferences();
  10036. // this is a block within a `Function/Program` so we can safely leave it be
  10037. if (t.isFunction(this.parent) || t.isProgram(this.block)) return;
  10038. // we can skip everything
  10039. if (!this.hasLetReferences) return;
  10040. if (needsClosure) {
  10041. this.wrapClosure();
  10042. } else {
  10043. this.remap();
  10044. }
  10045. if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
  10046. return t.labeledStatement(this.loopLabel, this.loop);
  10047. }
  10048. };
  10049. /**
  10050. * Description
  10051. */
  10052. BlockScoping.prototype.remap = function remap() {
  10053. var hasRemaps = false;
  10054. var letRefs = this.letReferences;
  10055. var scope = this.scope;
  10056. // alright, so since we aren't wrapping this block in a closure
  10057. // we have to check if any of our let variables collide with
  10058. // those in upper scopes and then if they do, generate a uid
  10059. // for them and replace all references with it
  10060. var remaps = (0, _helpersObject2["default"])();
  10061. for (var key in letRefs) {
  10062. // just an Identifier node we collected in `getLetReferences`
  10063. // this is the defining identifier of a declaration
  10064. var ref = letRefs[key];
  10065. if (scope.parentHasBinding(key) || scope.hasGlobal(key)) {
  10066. var uid = scope.generateUidIdentifier(ref.name).name;
  10067. ref.name = uid;
  10068. hasRemaps = true;
  10069. remaps[key] = remaps[uid] = {
  10070. binding: ref,
  10071. uid: uid
  10072. };
  10073. }
  10074. }
  10075. if (!hasRemaps) return;
  10076. //
  10077. var loop = this.loop;
  10078. if (loop) {
  10079. traverseReplace(loop.right, loop, scope, remaps);
  10080. traverseReplace(loop.test, loop, scope, remaps);
  10081. traverseReplace(loop.update, loop, scope, remaps);
  10082. }
  10083. this.blockPath.traverse(replaceVisitor, remaps);
  10084. };
  10085. /**
  10086. * Description
  10087. */
  10088. BlockScoping.prototype.wrapClosure = function wrapClosure() {
  10089. var block = this.block;
  10090. var outsideRefs = this.outsideLetReferences;
  10091. // remap loop heads with colliding variables
  10092. if (this.loop) {
  10093. for (var name in outsideRefs) {
  10094. var id = outsideRefs[name];
  10095. if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) {
  10096. delete outsideRefs[id.name];
  10097. delete this.letReferences[id.name];
  10098. this.scope.rename(id.name);
  10099. this.letReferences[id.name] = id;
  10100. outsideRefs[id.name] = id;
  10101. }
  10102. }
  10103. }
  10104. // if we're inside of a for loop then we search to see if there are any
  10105. // `break`s, `continue`s, `return`s etc
  10106. this.has = this.checkLoop();
  10107. // hoist var references to retain scope
  10108. this.hoistVarDeclarations();
  10109. // turn outsideLetReferences into an array
  10110. var params = (0, _lodashObjectValues2["default"])(outsideRefs);
  10111. var args = (0, _lodashObjectValues2["default"])(outsideRefs);
  10112. // build the closure that we're going to wrap the block with
  10113. var fn = t.functionExpression(null, params, t.blockStatement(block.body));
  10114. fn.shadow = true;
  10115. // continuation
  10116. this.addContinuations(fn);
  10117. // replace the current block body with the one we're going to build
  10118. block.body = this.body;
  10119. var ref = fn;
  10120. if (this.loop) {
  10121. ref = this.scope.generateUidIdentifier("loop");
  10122. this.loopPath.insertBefore(t.variableDeclaration("var", [t.variableDeclarator(ref, fn)]));
  10123. }
  10124. // build a call and a unique id that we can assign the return value to
  10125. var call = t.callExpression(ref, args);
  10126. var ret = this.scope.generateUidIdentifier("ret");
  10127. // handle generators
  10128. var hasYield = _traversal2["default"].hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES);
  10129. if (hasYield) {
  10130. fn.generator = true;
  10131. call = t.yieldExpression(call, true);
  10132. }
  10133. // handlers async functions
  10134. var hasAsync = _traversal2["default"].hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES);
  10135. if (hasAsync) {
  10136. fn.async = true;
  10137. call = t.awaitExpression(call);
  10138. }
  10139. this.buildClosure(ret, call);
  10140. };
  10141. /**
  10142. * Push the closure to the body.
  10143. */
  10144. BlockScoping.prototype.buildClosure = function buildClosure(ret, call) {
  10145. var has = this.has;
  10146. if (has.hasReturn || has.hasBreakContinue) {
  10147. this.buildHas(ret, call);
  10148. } else {
  10149. this.body.push(t.expressionStatement(call));
  10150. }
  10151. };
  10152. /**
  10153. * If any of the outer let variables are reassigned then we need to rename them in
  10154. * the closure so we can get direct access to the outer variable to continue the
  10155. * iteration with bindings based on each iteration.
  10156. *
  10157. * Reference: https://github.com/babel/babel/issues/1078
  10158. */
  10159. BlockScoping.prototype.addContinuations = function addContinuations(fn) {
  10160. var state = {
  10161. reassignments: {},
  10162. outsideReferences: this.outsideLetReferences
  10163. };
  10164. this.scope.traverse(fn, continuationVisitor, state);
  10165. for (var i = 0; i < fn.params.length; i++) {
  10166. var param = fn.params[i];
  10167. if (!state.reassignments[param.name]) continue;
  10168. var newParam = this.scope.generateUidIdentifier(param.name);
  10169. fn.params[i] = newParam;
  10170. this.scope.rename(param.name, newParam.name, fn);
  10171. // assign outer reference as it's been modified internally and needs to be retained
  10172. fn.body.body.push(t.expressionStatement(t.assignmentExpression("=", param, newParam)));
  10173. }
  10174. };
  10175. /**
  10176. * Description
  10177. */
  10178. BlockScoping.prototype.getLetReferences = function getLetReferences() {
  10179. var block = this.block;
  10180. var declarators = block._letDeclarators || [];
  10181. //
  10182. for (var i = 0; i < declarators.length; i++) {
  10183. var declar = declarators[i];
  10184. (0, _lodashObjectExtend2["default"])(this.outsideLetReferences, t.getBindingIdentifiers(declar));
  10185. }
  10186. //
  10187. if (block.body) {
  10188. for (var i = 0; i < block.body.length; i++) {
  10189. var declar = block.body[i];
  10190. if (isLet(declar, block)) {
  10191. declarators = declarators.concat(declar.declarations);
  10192. }
  10193. }
  10194. }
  10195. //
  10196. for (var i = 0; i < declarators.length; i++) {
  10197. var declar = declarators[i];
  10198. var keys = t.getBindingIdentifiers(declar);
  10199. (0, _lodashObjectExtend2["default"])(this.letReferences, keys);
  10200. this.hasLetReferences = true;
  10201. }
  10202. // no let references so we can just quit
  10203. if (!this.hasLetReferences) return;
  10204. // set let references to plain var references
  10205. standardizeLets(declarators);
  10206. var state = {
  10207. letReferences: this.letReferences,
  10208. closurify: false
  10209. };
  10210. // traverse through this block, stopping on functions and checking if they
  10211. // contain any local let references
  10212. this.blockPath.traverse(letReferenceBlockVisitor, state);
  10213. return state.closurify;
  10214. };
  10215. /**
  10216. * If we're inside of a loop then traverse it and check if it has one of
  10217. * the following node types `ReturnStatement`, `BreakStatement`,
  10218. * `ContinueStatement` and replace it with a return value that we can track
  10219. * later on.
  10220. *
  10221. * @returns {Object}
  10222. */
  10223. BlockScoping.prototype.checkLoop = function checkLoop() {
  10224. var state = {
  10225. hasBreakContinue: false,
  10226. ignoreLabeless: false,
  10227. inSwitchCase: false,
  10228. innerLabels: [],
  10229. hasReturn: false,
  10230. isLoop: !!this.loop,
  10231. map: {}
  10232. };
  10233. this.blockPath.traverse(loopLabelVisitor, state);
  10234. this.blockPath.traverse(loopVisitor, state);
  10235. return state;
  10236. };
  10237. /**
  10238. * Hoist all var declarations in this block to before it so they retain scope
  10239. * once we wrap everything in a closure.
  10240. */
  10241. BlockScoping.prototype.hoistVarDeclarations = function hoistVarDeclarations() {
  10242. this.blockPath.traverse(hoistVarDeclarationsVisitor, this);
  10243. };
  10244. /**
  10245. * Turn a `VariableDeclaration` into an array of `AssignmentExpressions` with
  10246. * their declarations hoisted to before the closure wrapper.
  10247. */
  10248. BlockScoping.prototype.pushDeclar = function pushDeclar(node) {
  10249. var declars = [];
  10250. var names = t.getBindingIdentifiers(node);
  10251. for (var name in names) {
  10252. declars.push(t.variableDeclarator(names[name]));
  10253. }
  10254. this.body.push(t.variableDeclaration(node.kind, declars));
  10255. var replace = [];
  10256. for (var i = 0; i < node.declarations.length; i++) {
  10257. var declar = node.declarations[i];
  10258. if (!declar.init) continue;
  10259. var expr = t.assignmentExpression("=", declar.id, declar.init);
  10260. replace.push(t.inherits(expr, declar));
  10261. }
  10262. return replace;
  10263. };
  10264. /**
  10265. * Description
  10266. */
  10267. BlockScoping.prototype.buildHas = function buildHas(ret, call) {
  10268. var body = this.body;
  10269. body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)]));
  10270. var loop = this.loop;
  10271. var retCheck;
  10272. var has = this.has;
  10273. var cases = [];
  10274. if (has.hasReturn) {
  10275. // typeof ret === "object"
  10276. retCheck = util.template("let-scoping-return", {
  10277. RETURN: ret
  10278. });
  10279. }
  10280. if (has.hasBreakContinue) {
  10281. for (var key in has.map) {
  10282. cases.push(t.switchCase(t.literal(key), [has.map[key]]));
  10283. }
  10284. if (has.hasReturn) {
  10285. cases.push(t.switchCase(null, [retCheck]));
  10286. }
  10287. if (cases.length === 1) {
  10288. var single = cases[0];
  10289. body.push(this.file.attachAuxiliaryComment(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])));
  10290. } else {
  10291. // https://github.com/babel/babel/issues/998
  10292. for (var i = 0; i < cases.length; i++) {
  10293. var caseConsequent = cases[i].consequent[0];
  10294. if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
  10295. caseConsequent.label = this.loopLabel = this.loopLabel || this.file.scope.generateUidIdentifier("loop");
  10296. }
  10297. }
  10298. body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
  10299. }
  10300. } else {
  10301. if (has.hasReturn) {
  10302. body.push(this.file.attachAuxiliaryComment(retCheck));
  10303. }
  10304. }
  10305. };
  10306. return BlockScoping;
  10307. })();
  10308. },{"../../../helpers/object":45,"../../../traversal":157,"../../../types":169,"../../../util":173,"lodash/object/extend":419,"lodash/object/values":424}],93:[function(require,module,exports){
  10309. "use strict";
  10310. exports.__esModule = true;
  10311. exports.ClassDeclaration = ClassDeclaration;
  10312. exports.ClassExpression = ClassExpression;
  10313. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  10314. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10315. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10316. var _helpersMemoiseDecorators = require("../../helpers/memoise-decorators");
  10317. var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
  10318. var _helpersReplaceSupers = require("../../helpers/replace-supers");
  10319. var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
  10320. var _helpersNameMethod = require("../../helpers/name-method");
  10321. var nameMethod = _interopRequireWildcard(_helpersNameMethod);
  10322. var _helpersDefineMap = require("../../helpers/define-map");
  10323. var defineMap = _interopRequireWildcard(_helpersDefineMap);
  10324. var _messages = require("../../../messages");
  10325. var messages = _interopRequireWildcard(_messages);
  10326. var _util = require("../../../util");
  10327. var util = _interopRequireWildcard(_util);
  10328. var _traversal = require("../../../traversal");
  10329. var _traversal2 = _interopRequireDefault(_traversal);
  10330. var _lodashCollectionEach = require("lodash/collection/each");
  10331. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  10332. var _lodashObjectHas = require("lodash/object/has");
  10333. var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
  10334. var _types = require("../../../types");
  10335. var t = _interopRequireWildcard(_types);
  10336. var PROPERTY_COLLISION_METHOD_NAME = "__initializeProperties";
  10337. function ClassDeclaration(node, parent, scope, file) {
  10338. return t.variableDeclaration("let", [t.variableDeclarator(node.id, t.toExpression(node))]);
  10339. }
  10340. function ClassExpression(node, parent, scope, file) {
  10341. return new ClassTransformer(this, file).run();
  10342. }
  10343. var collectPropertyReferencesVisitor = {
  10344. Identifier: {
  10345. enter: function enter(node, parent, scope, state) {
  10346. if (this.parentPath.isClassProperty({ key: node })) {
  10347. return;
  10348. }
  10349. if (this.isReferenced() && scope.getBinding(node.name) === state.scope.getBinding(node.name)) {
  10350. state.references[node.name] = true;
  10351. }
  10352. }
  10353. }
  10354. };
  10355. var constructorVisitor = {
  10356. ThisExpression: {
  10357. enter: function enter(node, parent, scope, ref) {
  10358. return ref;
  10359. }
  10360. },
  10361. Function: {
  10362. enter: function enter(node) {
  10363. if (!node.shadow) {
  10364. this.skip();
  10365. }
  10366. }
  10367. }
  10368. };
  10369. var verifyConstructorVisitor = {
  10370. MethodDefinition: {
  10371. enter: function enter() {
  10372. this.skip();
  10373. }
  10374. },
  10375. Property: {
  10376. enter: function enter(node) {
  10377. if (node.method) this.skip();
  10378. }
  10379. },
  10380. CallExpression: {
  10381. exit: function exit(node, parent, scope, state) {
  10382. if (this.get("callee").isSuper()) {
  10383. state.hasBareSuper = true;
  10384. state.bareSuper = this;
  10385. if (!state.hasSuper) {
  10386. throw this.errorWithNode("super call is only allowed in derived constructor");
  10387. }
  10388. }
  10389. }
  10390. },
  10391. FunctionDeclaration: {
  10392. enter: function enter() {
  10393. this.skip();
  10394. }
  10395. },
  10396. FunctionExpression: {
  10397. enter: function enter() {
  10398. this.skip();
  10399. }
  10400. },
  10401. ThisExpression: {
  10402. enter: function enter(node, parent, scope, state) {
  10403. if (state.hasSuper && !state.hasBareSuper) {
  10404. throw this.errorWithNode("'this' is not allowed before super()");
  10405. }
  10406. }
  10407. }
  10408. };
  10409. var ClassTransformer = (function () {
  10410. /**
  10411. * Description
  10412. */
  10413. function ClassTransformer(path, file) {
  10414. _classCallCheck(this, ClassTransformer);
  10415. this.parent = path.parent;
  10416. this.scope = path.scope;
  10417. this.node = path.node;
  10418. this.path = path;
  10419. this.file = file;
  10420. this.hasInstanceDescriptors = false;
  10421. this.hasStaticDescriptors = false;
  10422. this.instanceMutatorMap = {};
  10423. this.staticMutatorMap = {};
  10424. this.instancePropBody = [];
  10425. this.instancePropRefs = {};
  10426. this.staticPropBody = [];
  10427. this.body = [];
  10428. this.hasConstructor = false;
  10429. this.hasDecorators = false;
  10430. this.className = this.node.id;
  10431. this.classRef = this.node.id || this.scope.generateUidIdentifier("class");
  10432. this.superName = this.node.superClass || t.identifier("Function");
  10433. this.hasSuper = !!this.node.superClass;
  10434. this.isLoose = file.isLoose("es6.classes");
  10435. }
  10436. /**
  10437. * Description
  10438. *
  10439. * @returns {Array}
  10440. */
  10441. ClassTransformer.prototype.run = function run() {
  10442. var superName = this.superName;
  10443. var className = this.className;
  10444. var classBody = this.node.body.body;
  10445. var classRef = this.classRef;
  10446. var file = this.file;
  10447. //
  10448. var body = this.body;
  10449. //
  10450. var constructorBody = this.constructorBody = t.blockStatement([]);
  10451. var constructor;
  10452. if (this.className) {
  10453. constructor = t.functionDeclaration(this.className, [], constructorBody);
  10454. body.push(constructor);
  10455. } else {
  10456. constructor = t.functionExpression(null, [], constructorBody);
  10457. }
  10458. this.constructor = constructor;
  10459. //
  10460. var closureParams = [];
  10461. var closureArgs = [];
  10462. //
  10463. if (this.hasSuper) {
  10464. closureArgs.push(superName);
  10465. superName = this.scope.generateUidIdentifierBasedOnNode(superName);
  10466. closureParams.push(superName);
  10467. this.superName = superName;
  10468. body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [classRef, superName])));
  10469. }
  10470. //
  10471. var decorators = this.node.decorators;
  10472. if (decorators) {
  10473. // create a class reference to use later on
  10474. this.classRef = this.scope.generateUidIdentifier(classRef);
  10475. // this is so super calls and the decorators have access to the raw function
  10476. body.push(t.variableDeclaration("var", [t.variableDeclarator(this.classRef, classRef)]));
  10477. }
  10478. //
  10479. this.buildBody();
  10480. // make sure this class isn't directly called
  10481. constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), this.classRef])));
  10482. //
  10483. if (decorators) {
  10484. // reverse the decorators so we execute them in the right order
  10485. decorators = decorators.reverse();
  10486. for (var i = 0; i < decorators.length; i++) {
  10487. var decorator = decorators[i];
  10488. var decoratorNode = util.template("class-decorator", {
  10489. DECORATOR: decorator.expression,
  10490. CLASS_REF: classRef
  10491. }, true);
  10492. decoratorNode.expression._ignoreModulesRemap = true;
  10493. body.push(decoratorNode);
  10494. }
  10495. }
  10496. if (this.className) {
  10497. // named class with only a constructor
  10498. if (body.length === 1) return t.toExpression(body[0]);
  10499. } else {
  10500. // infer class name if this is a nameless class expression
  10501. constructor = nameMethod.bare(constructor, this.parent, this.scope) || constructor;
  10502. body.unshift(t.variableDeclaration("var", [t.variableDeclarator(classRef, constructor)]));
  10503. t.inheritsComments(body[0], this.node);
  10504. }
  10505. body = body.concat(this.staticPropBody);
  10506. //
  10507. body.push(t.returnStatement(classRef));
  10508. return t.callExpression(t.functionExpression(null, closureParams, t.blockStatement(body)), closureArgs);
  10509. };
  10510. /**
  10511. * Description
  10512. */
  10513. ClassTransformer.prototype.pushToMap = function pushToMap(node, enumerable) {
  10514. var kind = arguments[2] === undefined ? "value" : arguments[2];
  10515. var mutatorMap;
  10516. if (node["static"]) {
  10517. this.hasStaticDescriptors = true;
  10518. mutatorMap = this.staticMutatorMap;
  10519. } else {
  10520. this.hasInstanceDescriptors = true;
  10521. mutatorMap = this.instanceMutatorMap;
  10522. }
  10523. var map = defineMap.push(mutatorMap, node, kind, this.file);
  10524. if (enumerable) {
  10525. map.enumerable = t.literal(true);
  10526. }
  10527. if (map.decorators) {
  10528. this.hasDecorators = true;
  10529. }
  10530. };
  10531. /**
  10532. * Description
  10533. */
  10534. ClassTransformer.prototype.buildBody = function buildBody() {
  10535. var constructorBody = this.constructorBody;
  10536. var constructor = this.constructor;
  10537. var className = this.className;
  10538. var superName = this.superName;
  10539. var classBody = this.node.body.body;
  10540. var body = this.body;
  10541. var classBodyPaths = this.path.get("body").get("body");
  10542. for (var i = 0; i < classBody.length; i++) {
  10543. var node = classBody[i];
  10544. var path = classBodyPaths[i];
  10545. if (node.decorators) {
  10546. (0, _helpersMemoiseDecorators2["default"])(node.decorators, this.scope);
  10547. }
  10548. if (t.isMethodDefinition(node)) {
  10549. var isConstructor = node.kind === "constructor";
  10550. if (isConstructor) this.verifyConstructor(path);
  10551. var replaceSupers = new _helpersReplaceSupers2["default"]({
  10552. methodPath: path,
  10553. methodNode: node,
  10554. objectRef: this.classRef,
  10555. superRef: this.superName,
  10556. isStatic: node["static"],
  10557. isLoose: this.isLoose,
  10558. scope: this.scope,
  10559. file: this.file
  10560. }, true);
  10561. replaceSupers.replace();
  10562. if (isConstructor) {
  10563. this.pushConstructor(node, path);
  10564. } else {
  10565. this.pushMethod(node, path);
  10566. }
  10567. } else if (t.isClassProperty(node)) {
  10568. this.pushProperty(node);
  10569. }
  10570. }
  10571. // we have no constructor, but we're a derived class
  10572. if (!this.hasConstructor && this.hasSuper) {
  10573. var helperName = "class-super-constructor-call";
  10574. if (this.isLoose) helperName += "-loose";
  10575. constructorBody.body.push(util.template(helperName, {
  10576. CLASS_NAME: this.classRef,
  10577. SUPER_NAME: this.superName
  10578. }, true));
  10579. }
  10580. //
  10581. this.placePropertyInitializers();
  10582. //
  10583. if (this.userConstructor) {
  10584. constructorBody.body = constructorBody.body.concat(this.userConstructor.body.body);
  10585. t.inherits(this.constructor, this.userConstructor);
  10586. t.inherits(this.constructorBody, this.userConstructor.body);
  10587. }
  10588. var instanceProps;
  10589. var staticProps;
  10590. var classHelper = "create-class";
  10591. if (this.hasDecorators) classHelper = "create-decorated-class";
  10592. if (this.hasInstanceDescriptors) {
  10593. instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
  10594. }
  10595. if (this.hasStaticDescriptors) {
  10596. staticProps = defineMap.toClassObject(this.staticMutatorMap);
  10597. }
  10598. if (instanceProps || staticProps) {
  10599. if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
  10600. if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
  10601. var nullNode = t.literal(null);
  10602. // (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
  10603. var args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
  10604. if (instanceProps) args[1] = instanceProps;
  10605. if (staticProps) args[2] = staticProps;
  10606. if (this.instanceInitializersId) {
  10607. args[3] = this.instanceInitializersId;
  10608. body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
  10609. }
  10610. if (this.staticInitializersId) {
  10611. args[4] = this.staticInitializersId;
  10612. body.unshift(this.buildObjectAssignment(this.staticInitializersId));
  10613. }
  10614. var lastNonNullIndex = 0;
  10615. for (var i = 0; i < args.length; i++) {
  10616. if (args[i] !== nullNode) lastNonNullIndex = i;
  10617. }
  10618. args = args.slice(0, lastNonNullIndex + 1);
  10619. body.push(t.expressionStatement(t.callExpression(this.file.addHelper(classHelper), args)));
  10620. }
  10621. };
  10622. ClassTransformer.prototype.buildObjectAssignment = function buildObjectAssignment(id) {
  10623. return t.variableDeclaration("var", [t.variableDeclarator(id, t.objectExpression([]))]);
  10624. };
  10625. /**
  10626. * Description
  10627. */
  10628. ClassTransformer.prototype.placePropertyInitializers = function placePropertyInitializers() {
  10629. var body = this.instancePropBody;
  10630. if (!body.length) return;
  10631. if (this.hasPropertyCollision()) {
  10632. var call = t.expressionStatement(t.callExpression(t.memberExpression(t.thisExpression(), t.identifier(PROPERTY_COLLISION_METHOD_NAME)), []));
  10633. this.pushMethod(t.methodDefinition(t.identifier(PROPERTY_COLLISION_METHOD_NAME), t.functionExpression(null, [], t.blockStatement(body))), null, true);
  10634. if (this.hasSuper) {
  10635. this.bareSuper.insertAfter(call);
  10636. } else {
  10637. this.constructorBody.body.unshift(call);
  10638. }
  10639. } else {
  10640. if (this.hasSuper) {
  10641. if (this.hasConstructor) {
  10642. this.bareSuper.insertAfter(body);
  10643. } else {
  10644. this.constructorBody.body = this.constructorBody.body.concat(body);
  10645. }
  10646. } else {
  10647. this.constructorBody.body = body.concat(this.constructorBody.body);
  10648. }
  10649. }
  10650. };
  10651. /**
  10652. * Description
  10653. */
  10654. ClassTransformer.prototype.hasPropertyCollision = function hasPropertyCollision() {
  10655. if (this.userConstructorPath) {
  10656. for (var name in this.instancePropRefs) {
  10657. if (this.userConstructorPath.scope.hasOwnBinding(name)) {
  10658. return true;
  10659. }
  10660. }
  10661. }
  10662. return false;
  10663. };
  10664. /**
  10665. * Description
  10666. */
  10667. ClassTransformer.prototype.verifyConstructor = function verifyConstructor(path) {
  10668. var state = {
  10669. hasBareSuper: false,
  10670. bareSuper: null,
  10671. hasSuper: this.hasSuper,
  10672. file: this.file
  10673. };
  10674. path.get("value").traverse(verifyConstructorVisitor, state);
  10675. this.bareSuper = state.bareSuper;
  10676. if (!state.hasBareSuper && this.hasSuper) {
  10677. throw path.errorWithNode("Derived constructor must call super()");
  10678. }
  10679. };
  10680. /**
  10681. * Push a method to its respective mutatorMap.
  10682. */
  10683. ClassTransformer.prototype.pushMethod = function pushMethod(node, path, allowedIllegal) {
  10684. if (!allowedIllegal && t.isLiteral(t.toComputedKey(node), { value: PROPERTY_COLLISION_METHOD_NAME })) {
  10685. throw this.file.errorWithNode(node, messages.get("illegalMethodName", PROPERTY_COLLISION_METHOD_NAME));
  10686. }
  10687. if (node.kind === "method") {
  10688. nameMethod.property(node, this.file, path ? path.get("value").scope : this.scope);
  10689. if (this.isLoose && !node.decorators) {
  10690. // use assignments instead of define properties for loose classes
  10691. var classRef = this.classRef;
  10692. if (!node["static"]) classRef = t.memberExpression(classRef, t.identifier("prototype"));
  10693. var methodName = t.memberExpression(classRef, node.key, node.computed);
  10694. var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
  10695. t.inheritsComments(expr, node);
  10696. this.body.push(expr);
  10697. return;
  10698. }
  10699. }
  10700. this.pushToMap(node);
  10701. };
  10702. /**
  10703. * Description
  10704. */
  10705. ClassTransformer.prototype.pushProperty = function pushProperty(node) {
  10706. var key;
  10707. this.scope.traverse(node, collectPropertyReferencesVisitor, {
  10708. references: this.instancePropRefs,
  10709. scope: this.scope
  10710. });
  10711. if (node.decorators) {
  10712. var body = [];
  10713. if (node.value) {
  10714. body.push(t.returnStatement(node.value));
  10715. node.value = t.functionExpression(null, [], t.blockStatement(body));
  10716. } else {
  10717. node.value = t.literal(null);
  10718. }
  10719. this.pushToMap(node, true, "initializer");
  10720. var initializers;
  10721. var body;
  10722. var target;
  10723. if (node["static"]) {
  10724. initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
  10725. body = this.staticPropBody;
  10726. target = this.classRef;
  10727. } else {
  10728. initializers = this.instanceInitializersId = this.instanceInitializersId || this.scope.generateUidIdentifier("instanceInitializers");
  10729. body = this.instancePropBody;
  10730. target = t.thisExpression();
  10731. }
  10732. body.push(t.expressionStatement(t.callExpression(this.file.addHelper("define-decorated-property-descriptor"), [target, t.literal(node.key.name), initializers])));
  10733. } else {
  10734. if (!node.value && !node.decorators) return;
  10735. if (node["static"]) {
  10736. // can just be added to the static map
  10737. this.pushToMap(node, true);
  10738. } else if (node.value) {
  10739. // add this to the instancePropBody which will be added after the super call in a derived constructor
  10740. // or at the start of a constructor for a non-derived constructor
  10741. this.instancePropBody.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)));
  10742. }
  10743. }
  10744. };
  10745. /**
  10746. * Replace the constructor body of our class.
  10747. */
  10748. ClassTransformer.prototype.pushConstructor = function pushConstructor(method, path) {
  10749. // https://github.com/babel/babel/issues/1077
  10750. var fnPath = path.get("value");
  10751. if (fnPath.scope.hasOwnBinding(this.classRef.name)) {
  10752. fnPath.scope.rename(this.classRef.name);
  10753. }
  10754. var construct = this.constructor;
  10755. var fn = method.value;
  10756. this.userConstructorPath = fnPath;
  10757. this.userConstructor = fn;
  10758. this.hasConstructor = true;
  10759. t.inheritsComments(construct, method);
  10760. construct._ignoreUserWhitespace = true;
  10761. construct.params = fn.params;
  10762. t.inherits(construct.body, fn.body);
  10763. };
  10764. return ClassTransformer;
  10765. })();
  10766. },{"../../../messages":47,"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/define-map":61,"../../helpers/memoise-decorators":64,"../../helpers/name-method":65,"../../helpers/replace-supers":69,"lodash/collection/each":330,"lodash/object/has":420}],94:[function(require,module,exports){
  10767. "use strict";
  10768. exports.__esModule = true;
  10769. exports.AssignmentExpression = AssignmentExpression;
  10770. exports.VariableDeclaration = VariableDeclaration;
  10771. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  10772. var _messages = require("../../../messages");
  10773. var messages = _interopRequireWildcard(_messages);
  10774. var _types = require("../../../types");
  10775. var t = _interopRequireWildcard(_types);
  10776. function AssignmentExpression(node, parent, scope, file) {
  10777. var ids = this.getBindingIdentifiers();
  10778. for (var name in ids) {
  10779. var id = ids[name];
  10780. var binding = scope.getBinding(name);
  10781. // no binding exists
  10782. if (!binding) continue;
  10783. // not a constant
  10784. if (binding.kind !== "const" && binding.kind !== "module") continue;
  10785. // check if the assignment id matches the constant declaration id
  10786. // if it does then it was the id used to initially declare the
  10787. // constant so we can just ignore it
  10788. if (binding.identifier === id) continue;
  10789. throw file.errorWithNode(id, messages.get("readOnly", name));
  10790. }
  10791. }
  10792. exports.UpdateExpression = AssignmentExpression;
  10793. function VariableDeclaration(node) {
  10794. if (node.kind === "const") node.kind = "let";
  10795. }
  10796. },{"../../../messages":47,"../../../types":169}],95:[function(require,module,exports){
  10797. "use strict";
  10798. exports.__esModule = true;
  10799. exports.ForOfStatement = ForOfStatement;
  10800. exports.Func /*tion*/ = Func;
  10801. exports.CatchClause = CatchClause;
  10802. exports.ExpressionStatement = ExpressionStatement;
  10803. exports.AssignmentExpression = AssignmentExpression;
  10804. exports.VariableDeclaration = VariableDeclaration;
  10805. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  10806. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10807. var _messages = require("../../../messages");
  10808. var messages = _interopRequireWildcard(_messages);
  10809. var _types = require("../../../types");
  10810. var t = _interopRequireWildcard(_types);
  10811. var metadata = {
  10812. group: "builtin-advanced"
  10813. };
  10814. exports.metadata = metadata;
  10815. function ForOfStatement(node, parent, scope, file) {
  10816. var left = node.left;
  10817. if (t.isPattern(left)) {
  10818. // for ({ length: k } in { abc: 3 });
  10819. var temp = scope.generateUidIdentifier("ref");
  10820. node.left = t.variableDeclaration("var", [t.variableDeclarator(temp)]);
  10821. t.ensureBlock(node);
  10822. node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(left, temp)]));
  10823. return;
  10824. }
  10825. if (!t.isVariableDeclaration(left)) return;
  10826. var pattern = left.declarations[0].id;
  10827. if (!t.isPattern(pattern)) return;
  10828. var key = scope.generateUidIdentifier("ref");
  10829. node.left = t.variableDeclaration(left.kind, [t.variableDeclarator(key, null)]);
  10830. var nodes = [];
  10831. var destructuring = new DestructuringTransformer({
  10832. kind: left.kind,
  10833. file: file,
  10834. scope: scope,
  10835. nodes: nodes
  10836. });
  10837. destructuring.init(pattern, key);
  10838. t.ensureBlock(node);
  10839. var block = node.body;
  10840. block.body = nodes.concat(block.body);
  10841. }
  10842. exports.ForInStatement = ForOfStatement;
  10843. function Func(node, parent, scope, file) {
  10844. var nodes = [];
  10845. var hasDestructuring = false;
  10846. node.params = node.params.map(function (pattern, i) {
  10847. if (!t.isPattern(pattern)) return pattern;
  10848. hasDestructuring = true;
  10849. var ref = scope.generateUidIdentifier("ref");
  10850. t.inherits(ref, pattern);
  10851. var destructuring = new DestructuringTransformer({
  10852. blockHoist: node.params.length - i,
  10853. nodes: nodes,
  10854. scope: scope,
  10855. file: file,
  10856. kind: "let"
  10857. });
  10858. destructuring.init(pattern, ref);
  10859. return ref;
  10860. });
  10861. if (!hasDestructuring) return;
  10862. t.ensureBlock(node);
  10863. var block = node.body;
  10864. block.body = nodes.concat(block.body);
  10865. }
  10866. function CatchClause(node, parent, scope, file) {
  10867. var pattern = node.param;
  10868. if (!t.isPattern(pattern)) return;
  10869. var ref = scope.generateUidIdentifier("ref");
  10870. node.param = ref;
  10871. var nodes = [];
  10872. var destructuring = new DestructuringTransformer({
  10873. kind: "let",
  10874. file: file,
  10875. scope: scope,
  10876. nodes: nodes
  10877. });
  10878. destructuring.init(pattern, ref);
  10879. node.body.body = nodes.concat(node.body.body);
  10880. }
  10881. function ExpressionStatement(node, parent, scope, file) {
  10882. var expr = node.expression;
  10883. if (expr.type !== "AssignmentExpression") return;
  10884. if (!t.isPattern(expr.left)) return;
  10885. if (this.isCompletionRecord()) return;
  10886. var destructuring = new DestructuringTransformer({
  10887. operator: expr.operator,
  10888. scope: scope,
  10889. file: file });
  10890. return destructuring.init(expr.left, expr.right);
  10891. }
  10892. function AssignmentExpression(node, parent, scope, file) {
  10893. if (!t.isPattern(node.left)) return;
  10894. var ref = scope.generateUidIdentifier("temp");
  10895. var nodes = [];
  10896. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, node.right)]));
  10897. var destructuring = new DestructuringTransformer({
  10898. operator: node.operator,
  10899. file: file,
  10900. scope: scope,
  10901. nodes: nodes
  10902. });
  10903. if (t.isArrayExpression(node.right)) {
  10904. destructuring.arrays[ref.name] = true;
  10905. }
  10906. destructuring.init(node.left, ref);
  10907. nodes.push(t.expressionStatement(ref));
  10908. return nodes;
  10909. }
  10910. function variableDeclarationHasPattern(node) {
  10911. for (var i = 0; i < node.declarations.length; i++) {
  10912. if (t.isPattern(node.declarations[i].id)) {
  10913. return true;
  10914. }
  10915. }
  10916. return false;
  10917. }
  10918. function VariableDeclaration(node, parent, scope, file) {
  10919. if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
  10920. if (!variableDeclarationHasPattern(node)) return;
  10921. var nodes = [];
  10922. var declar;
  10923. for (var i = 0; i < node.declarations.length; i++) {
  10924. declar = node.declarations[i];
  10925. var patternId = declar.init;
  10926. var pattern = declar.id;
  10927. var destructuring = new DestructuringTransformer({
  10928. nodes: nodes,
  10929. scope: scope,
  10930. kind: node.kind,
  10931. file: file
  10932. });
  10933. if (t.isPattern(pattern)) {
  10934. destructuring.init(pattern, patternId);
  10935. if (+i !== node.declarations.length - 1) {
  10936. // we aren't the last declarator so let's just make the
  10937. // last transformed node inherit from us
  10938. t.inherits(nodes[nodes.length - 1], declar);
  10939. }
  10940. } else {
  10941. nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar));
  10942. }
  10943. }
  10944. if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
  10945. // https://github.com/babel/babel/issues/113
  10946. // for (let [x] = [0]; false;) {}
  10947. declar = null;
  10948. for (i = 0; i < nodes.length; i++) {
  10949. node = nodes[i];
  10950. declar = declar || t.variableDeclaration(node.kind, []);
  10951. if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
  10952. throw file.errorWithNode(node, messages.get("invalidParentForThisNode"));
  10953. }
  10954. declar.declarations = declar.declarations.concat(node.declarations);
  10955. }
  10956. return declar;
  10957. }
  10958. return nodes;
  10959. }
  10960. function hasRest(pattern) {
  10961. for (var i = 0; i < pattern.elements.length; i++) {
  10962. if (t.isRestElement(pattern.elements[i])) {
  10963. return true;
  10964. }
  10965. }
  10966. return false;
  10967. }
  10968. var arrayUnpackVisitor = {
  10969. enter: function enter(node, parent, scope, state) {
  10970. if (this.isReferencedIdentifier() && state.bindings[node.name]) {
  10971. state.deopt = true;
  10972. this.stop();
  10973. }
  10974. }
  10975. };
  10976. var DestructuringTransformer = (function () {
  10977. function DestructuringTransformer(opts) {
  10978. _classCallCheck(this, DestructuringTransformer);
  10979. this.blockHoist = opts.blockHoist;
  10980. this.operator = opts.operator;
  10981. this.arrays = {};
  10982. this.nodes = opts.nodes || [];
  10983. this.scope = opts.scope;
  10984. this.file = opts.file;
  10985. this.kind = opts.kind;
  10986. }
  10987. DestructuringTransformer.prototype.buildVariableAssignment = function buildVariableAssignment(id, init) {
  10988. var op = this.operator;
  10989. if (t.isMemberExpression(id)) op = "=";
  10990. var node;
  10991. if (op) {
  10992. node = t.expressionStatement(t.assignmentExpression(op, id, init));
  10993. } else {
  10994. node = t.variableDeclaration(this.kind, [t.variableDeclarator(id, init)]);
  10995. }
  10996. node._blockHoist = this.blockHoist;
  10997. return node;
  10998. };
  10999. DestructuringTransformer.prototype.buildVariableDeclaration = function buildVariableDeclaration(id, init) {
  11000. var declar = t.variableDeclaration("var", [t.variableDeclarator(id, init)]);
  11001. declar._blockHoist = this.blockHoist;
  11002. return declar;
  11003. };
  11004. DestructuringTransformer.prototype.push = function push(id, init) {
  11005. if (t.isObjectPattern(id)) {
  11006. this.pushObjectPattern(id, init);
  11007. } else if (t.isArrayPattern(id)) {
  11008. this.pushArrayPattern(id, init);
  11009. } else if (t.isAssignmentPattern(id)) {
  11010. this.pushAssignmentPattern(id, init);
  11011. } else {
  11012. this.nodes.push(this.buildVariableAssignment(id, init));
  11013. }
  11014. };
  11015. DestructuringTransformer.prototype.toArray = function toArray(node, count) {
  11016. if (this.file.isLoose("es6.destructuring") || t.isIdentifier(node) && this.arrays[node.name]) {
  11017. return node;
  11018. } else {
  11019. return this.scope.toArray(node, count);
  11020. }
  11021. };
  11022. DestructuringTransformer.prototype.pushAssignmentPattern = function pushAssignmentPattern(pattern, valueRef) {
  11023. // we need to assign the current value of the assignment to avoid evaluating
  11024. // it more than once
  11025. var tempValueRef = this.scope.generateUidIdentifierBasedOnNode(valueRef);
  11026. var declar = t.variableDeclaration("var", [t.variableDeclarator(tempValueRef, valueRef)]);
  11027. declar._blockHoist = this.blockHoist;
  11028. this.nodes.push(declar);
  11029. //
  11030. var tempConditional = t.conditionalExpression(t.binaryExpression("===", tempValueRef, t.identifier("undefined")), pattern.right, tempValueRef);
  11031. var left = pattern.left;
  11032. if (t.isPattern(left)) {
  11033. this.nodes.push(t.expressionStatement(t.assignmentExpression("=", tempValueRef, tempConditional)));
  11034. this.push(left, tempValueRef);
  11035. } else {
  11036. this.nodes.push(this.buildVariableAssignment(left, tempConditional));
  11037. }
  11038. };
  11039. DestructuringTransformer.prototype.pushObjectSpread = function pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) {
  11040. // get all the keys that appear in this object before the current spread
  11041. var keys = [];
  11042. for (var i = 0; i < pattern.properties.length; i++) {
  11043. var prop = pattern.properties[i];
  11044. // we've exceeded the index of the spread property to all properties to the
  11045. // right need to be ignored
  11046. if (i >= spreadPropIndex) break;
  11047. // ignore other spread properties
  11048. if (t.isSpreadProperty(prop)) continue;
  11049. var key = prop.key;
  11050. if (t.isIdentifier(key) && !prop.computed) key = t.literal(prop.key.name);
  11051. keys.push(key);
  11052. }
  11053. keys = t.arrayExpression(keys);
  11054. //
  11055. var value = t.callExpression(this.file.addHelper("object-without-properties"), [objRef, keys]);
  11056. this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value));
  11057. };
  11058. DestructuringTransformer.prototype.pushObjectProperty = function pushObjectProperty(prop, propRef) {
  11059. if (t.isLiteral(prop.key)) prop.computed = true;
  11060. var pattern = prop.value;
  11061. var objRef = t.memberExpression(propRef, prop.key, prop.computed);
  11062. if (t.isPattern(pattern)) {
  11063. this.push(pattern, objRef);
  11064. } else {
  11065. this.nodes.push(this.buildVariableAssignment(pattern, objRef));
  11066. }
  11067. };
  11068. DestructuringTransformer.prototype.pushObjectPattern = function pushObjectPattern(pattern, objRef) {
  11069. // https://github.com/babel/babel/issues/681
  11070. if (!pattern.properties.length) {
  11071. this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"), [objRef])));
  11072. }
  11073. // if we have more than one properties in this pattern and the objectRef is a
  11074. // member expression then we need to assign it to a temporary variable so it's
  11075. // only evaluated once
  11076. if (pattern.properties.length > 1 && t.isMemberExpression(objRef)) {
  11077. var temp = this.scope.generateUidIdentifierBasedOnNode(objRef, this.file);
  11078. this.nodes.push(this.buildVariableDeclaration(temp, objRef));
  11079. objRef = temp;
  11080. }
  11081. //
  11082. for (var i = 0; i < pattern.properties.length; i++) {
  11083. var prop = pattern.properties[i];
  11084. if (t.isSpreadProperty(prop)) {
  11085. this.pushObjectSpread(pattern, objRef, prop, i);
  11086. } else {
  11087. this.pushObjectProperty(prop, objRef);
  11088. }
  11089. }
  11090. };
  11091. DestructuringTransformer.prototype.canUnpackArrayPattern = function canUnpackArrayPattern(pattern, arr) {
  11092. // not an array so there's no way we can deal with this
  11093. if (!t.isArrayExpression(arr)) return false;
  11094. // pattern has less elements than the array and doesn't have a rest so some
  11095. // elements wont be evaluated
  11096. if (pattern.elements.length > arr.elements.length) return;
  11097. if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) return false;
  11098. for (var i = 0; i < pattern.elements.length; i++) {
  11099. var elem = pattern.elements[i];
  11100. // deopt on holes
  11101. if (!elem) return false;
  11102. // deopt on member expressions
  11103. if (t.isMemberExpression(elem)) return false;
  11104. }
  11105. // deopt on reference to left side identifiers
  11106. var bindings = t.getBindingIdentifiers(pattern);
  11107. var state = { deopt: false, bindings: bindings };
  11108. this.scope.traverse(arr, arrayUnpackVisitor, state);
  11109. return !state.deopt;
  11110. };
  11111. DestructuringTransformer.prototype.pushUnpackedArrayPattern = function pushUnpackedArrayPattern(pattern, arr) {
  11112. for (var i = 0; i < pattern.elements.length; i++) {
  11113. var elem = pattern.elements[i];
  11114. if (t.isRestElement(elem)) {
  11115. this.push(elem.argument, t.arrayExpression(arr.elements.slice(i)));
  11116. } else {
  11117. this.push(elem, arr.elements[i]);
  11118. }
  11119. }
  11120. };
  11121. DestructuringTransformer.prototype.pushArrayPattern = function pushArrayPattern(pattern, arrayRef) {
  11122. if (!pattern.elements) return;
  11123. // optimise basic array destructuring of an array expression
  11124. //
  11125. // we can't do this to a pattern of unequal size to it's right hand
  11126. // array expression as then there will be values that wont be evaluated
  11127. //
  11128. // eg: var [a, b] = [1, 2];
  11129. if (this.canUnpackArrayPattern(pattern, arrayRef)) {
  11130. return this.pushUnpackedArrayPattern(pattern, arrayRef);
  11131. }
  11132. // if we have a rest then we need all the elements so don't tell
  11133. // `scope.toArray` to only get a certain amount
  11134. var count = !hasRest(pattern) && pattern.elements.length;
  11135. // so we need to ensure that the `arrayRef` is an array, `scope.toArray` will
  11136. // return a locally bound identifier if it's been inferred to be an array,
  11137. // otherwise it'll be a call to a helper that will ensure it's one
  11138. var toArray = this.toArray(arrayRef, count);
  11139. if (t.isIdentifier(toArray)) {
  11140. // we've been given an identifier so it must have been inferred to be an
  11141. // array
  11142. arrayRef = toArray;
  11143. } else {
  11144. arrayRef = this.scope.generateUidIdentifierBasedOnNode(arrayRef);
  11145. this.arrays[arrayRef.name] = true;
  11146. this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray));
  11147. }
  11148. //
  11149. for (var i = 0; i < pattern.elements.length; i++) {
  11150. var elem = pattern.elements[i];
  11151. // hole
  11152. if (!elem) continue;
  11153. var elemRef;
  11154. if (t.isRestElement(elem)) {
  11155. elemRef = this.toArray(arrayRef);
  11156. if (i > 0) {
  11157. elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.literal(i)]);
  11158. }
  11159. // set the element to the rest element argument since we've dealt with it
  11160. // being a rest already
  11161. elem = elem.argument;
  11162. } else {
  11163. elemRef = t.memberExpression(arrayRef, t.literal(i), true);
  11164. }
  11165. this.push(elem, elemRef);
  11166. }
  11167. };
  11168. DestructuringTransformer.prototype.init = function init(pattern, ref) {
  11169. // trying to destructure a value that we can't evaluate more than once so we
  11170. // need to save it to a variable
  11171. var shouldMemoise = true;
  11172. if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) {
  11173. var memo = this.scope.maybeGenerateMemoised(ref, true);
  11174. if (memo) {
  11175. this.nodes.push(this.buildVariableDeclaration(memo, ref));
  11176. ref = memo;
  11177. }
  11178. }
  11179. //
  11180. this.push(pattern, ref);
  11181. return this.nodes;
  11182. };
  11183. return DestructuringTransformer;
  11184. })();
  11185. },{"../../../messages":47,"../../../types":169}],96:[function(require,module,exports){
  11186. "use strict";
  11187. exports.__esModule = true;
  11188. exports.ForOfStatement = ForOfStatement;
  11189. exports._ForOfStatementArray = _ForOfStatementArray;
  11190. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11191. var _messages = require("../../../messages");
  11192. var messages = _interopRequireWildcard(_messages);
  11193. var _util = require("../../../util");
  11194. var util = _interopRequireWildcard(_util);
  11195. var _types = require("../../../types");
  11196. var t = _interopRequireWildcard(_types);
  11197. function ForOfStatement(node, parent, scope, file) {
  11198. if (this.get("right").isArrayExpression()) {
  11199. return _ForOfStatementArray.call(this, node, scope, file);
  11200. }
  11201. var callback = spec;
  11202. if (file.isLoose("es6.forOf")) callback = loose;
  11203. var build = callback(node, parent, scope, file);
  11204. var declar = build.declar;
  11205. var loop = build.loop;
  11206. var block = loop.body;
  11207. // ensure that it's a block so we can take all its statements
  11208. t.ensureBlock(node);
  11209. // add the value declaration to the new loop body
  11210. if (declar) {
  11211. block.body.push(declar);
  11212. }
  11213. // push the rest of the original loop body onto our new body
  11214. block.body = block.body.concat(node.body.body);
  11215. t.inherits(loop, node);
  11216. t.inherits(loop.body, node.body);
  11217. if (build.replaceParent) {
  11218. this.parentPath.replaceWithMultiple(build.node);
  11219. this.remove();
  11220. } else {
  11221. return build.node;
  11222. }
  11223. }
  11224. function _ForOfStatementArray(node, scope, file) {
  11225. var nodes = [];
  11226. var right = node.right;
  11227. if (!t.isIdentifier(right) || !scope.hasBinding(right.name)) {
  11228. var uid = scope.generateUidIdentifier("arr");
  11229. nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, right)]));
  11230. right = uid;
  11231. }
  11232. var iterationKey = scope.generateUidIdentifier("i");
  11233. var loop = util.template("for-of-array", {
  11234. BODY: node.body,
  11235. KEY: iterationKey,
  11236. ARR: right
  11237. });
  11238. t.inherits(loop, node);
  11239. t.ensureBlock(loop);
  11240. var iterationValue = t.memberExpression(right, iterationKey, true);
  11241. var left = node.left;
  11242. if (t.isVariableDeclaration(left)) {
  11243. left.declarations[0].init = iterationValue;
  11244. loop.body.body.unshift(left);
  11245. } else {
  11246. loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue)));
  11247. }
  11248. nodes.push(loop);
  11249. return nodes;
  11250. }
  11251. var loose = function loose(node, parent, scope, file) {
  11252. var left = node.left;
  11253. var declar, id;
  11254. if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
  11255. // for (i of test), for ({ i } of test)
  11256. id = left;
  11257. } else if (t.isVariableDeclaration(left)) {
  11258. // for (var i of test)
  11259. id = scope.generateUidIdentifier("ref");
  11260. declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, id)]);
  11261. } else {
  11262. throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
  11263. }
  11264. var iteratorKey = scope.generateUidIdentifier("iterator");
  11265. var isArrayKey = scope.generateUidIdentifier("isArray");
  11266. var loop = util.template("for-of-loose", {
  11267. LOOP_OBJECT: iteratorKey,
  11268. IS_ARRAY: isArrayKey,
  11269. OBJECT: node.right,
  11270. INDEX: scope.generateUidIdentifier("i"),
  11271. ID: id
  11272. });
  11273. if (!declar) {
  11274. // no declaration so we need to remove the variable declaration at the top of
  11275. // the for-of-loose template
  11276. loop.body.body.shift();
  11277. }
  11278. //
  11279. return {
  11280. declar: declar,
  11281. node: loop,
  11282. loop: loop
  11283. };
  11284. };
  11285. var spec = function spec(node, parent, scope, file) {
  11286. var left = node.left;
  11287. var declar;
  11288. var stepKey = scope.generateUidIdentifier("step");
  11289. var stepValue = t.memberExpression(stepKey, t.identifier("value"));
  11290. if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
  11291. // for (i of test), for ({ i } of test)
  11292. declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
  11293. } else if (t.isVariableDeclaration(left)) {
  11294. // for (var i of test)
  11295. declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, stepValue)]);
  11296. } else {
  11297. throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
  11298. }
  11299. //
  11300. var iteratorKey = scope.generateUidIdentifier("iterator");
  11301. var template = util.template("for-of", {
  11302. ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
  11303. ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"),
  11304. ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
  11305. ITERATOR_KEY: iteratorKey,
  11306. STEP_KEY: stepKey,
  11307. OBJECT: node.right,
  11308. BODY: null
  11309. });
  11310. var isLabeledParent = t.isLabeledStatement(parent);
  11311. var tryBody = template[3].block.body;
  11312. var loop = tryBody[0];
  11313. if (isLabeledParent) {
  11314. tryBody[0] = t.labeledStatement(parent.label, loop);
  11315. }
  11316. //
  11317. return {
  11318. replaceParent: isLabeledParent,
  11319. declar: declar,
  11320. loop: loop,
  11321. node: template
  11322. };
  11323. };
  11324. },{"../../../messages":47,"../../../types":169,"../../../util":173}],97:[function(require,module,exports){
  11325. "use strict";
  11326. exports.__esModule = true;
  11327. exports.ImportDeclaration = ImportDeclaration;
  11328. exports.ExportAllDeclaration = ExportAllDeclaration;
  11329. exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
  11330. exports.ExportNamedDeclaration = ExportNamedDeclaration;
  11331. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11332. var _types = require("../../../types");
  11333. var t = _interopRequireWildcard(_types);
  11334. function keepBlockHoist(node, nodes) {
  11335. if (node._blockHoist) {
  11336. for (var i = 0; i < nodes.length; i++) {
  11337. nodes[i]._blockHoist = node._blockHoist;
  11338. }
  11339. }
  11340. }
  11341. var metadata = {
  11342. group: "builtin-modules"
  11343. };
  11344. exports.metadata = metadata;
  11345. function ImportDeclaration(node, parent, scope, file) {
  11346. // flow type
  11347. if (node.isType) return;
  11348. var nodes = [];
  11349. if (node.specifiers.length) {
  11350. for (var i = 0; i < node.specifiers.length; i++) {
  11351. file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
  11352. }
  11353. } else {
  11354. file.moduleFormatter.importDeclaration(node, nodes, parent);
  11355. }
  11356. if (nodes.length === 1) {
  11357. // inherit `_blockHoist` - this is for `_blockHoist` in File.prototype.addImport
  11358. nodes[0]._blockHoist = node._blockHoist;
  11359. }
  11360. return nodes;
  11361. }
  11362. function ExportAllDeclaration(node, parent, scope, file) {
  11363. var nodes = [];
  11364. file.moduleFormatter.exportAllDeclaration(node, nodes, parent);
  11365. keepBlockHoist(node, nodes);
  11366. return nodes;
  11367. }
  11368. function ExportDefaultDeclaration(node, parent, scope, file) {
  11369. var nodes = [];
  11370. file.moduleFormatter.exportDeclaration(node, nodes, parent);
  11371. keepBlockHoist(node, nodes);
  11372. return nodes;
  11373. }
  11374. function ExportNamedDeclaration(node, parent, scope, file) {
  11375. // flow type
  11376. if (this.get("declaration").isTypeAlias()) return;
  11377. var nodes = [];
  11378. if (node.declaration) {
  11379. // make sure variable exports have an initializer
  11380. // this is done here to avoid duplicating it in the module formatters
  11381. if (t.isVariableDeclaration(node.declaration)) {
  11382. var declar = node.declaration.declarations[0];
  11383. declar.init = declar.init || t.identifier("undefined");
  11384. }
  11385. file.moduleFormatter.exportDeclaration(node, nodes, parent);
  11386. } else if (node.specifiers) {
  11387. for (var i = 0; i < node.specifiers.length; i++) {
  11388. file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
  11389. }
  11390. }
  11391. keepBlockHoist(node, nodes);
  11392. return nodes;
  11393. }
  11394. },{"../../../types":169}],98:[function(require,module,exports){
  11395. "use strict";
  11396. exports.__esModule = true;
  11397. exports.ObjectExpression = ObjectExpression;
  11398. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11399. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11400. var _helpersReplaceSupers = require("../../helpers/replace-supers");
  11401. var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
  11402. var _types = require("../../../types");
  11403. var t = _interopRequireWildcard(_types);
  11404. function Property(path, node, scope, getObjectRef, file) {
  11405. if (!node.method && node.kind === "init") return;
  11406. if (!t.isFunction(node.value)) return;
  11407. var replaceSupers = new _helpersReplaceSupers2["default"]({
  11408. getObjectRef: getObjectRef,
  11409. methodNode: node,
  11410. methodPath: path,
  11411. isStatic: true,
  11412. scope: scope,
  11413. file: file
  11414. });
  11415. replaceSupers.replace();
  11416. }
  11417. function ObjectExpression(node, parent, scope, file) {
  11418. var objectRef;
  11419. var getObjectRef = function getObjectRef() {
  11420. return objectRef = objectRef || scope.generateUidIdentifier("obj");
  11421. };
  11422. var propPaths = this.get("properties");
  11423. for (var i = 0; i < node.properties.length; i++) {
  11424. Property(propPaths[i], node.properties[i], scope, getObjectRef, file);
  11425. }
  11426. if (objectRef) {
  11427. scope.push({ id: objectRef });
  11428. return t.assignmentExpression("=", objectRef, node);
  11429. }
  11430. }
  11431. },{"../../../types":169,"../../helpers/replace-supers":69}],99:[function(require,module,exports){
  11432. "use strict";
  11433. exports.__esModule = true;
  11434. exports.Func /*tion*/ = Func;
  11435. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11436. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11437. var _helpersCallDelegate = require("../../helpers/call-delegate");
  11438. var _helpersCallDelegate2 = _interopRequireDefault(_helpersCallDelegate);
  11439. var _util = require("../../../util");
  11440. var util = _interopRequireWildcard(_util);
  11441. var _traversal = require("../../../traversal");
  11442. var _traversal2 = _interopRequireDefault(_traversal);
  11443. var _types = require("../../../types");
  11444. var t = _interopRequireWildcard(_types);
  11445. var hasDefaults = function hasDefaults(node) {
  11446. for (var i = 0; i < node.params.length; i++) {
  11447. if (!t.isIdentifier(node.params[i])) return true;
  11448. }
  11449. return false;
  11450. };
  11451. var iifeVisitor = {
  11452. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  11453. if (node.name !== "eval") {
  11454. if (!state.scope.hasOwnBinding(node.name)) return;
  11455. if (state.scope.bindingIdentifierEquals(node.name, node)) return;
  11456. }
  11457. state.iife = true;
  11458. this.stop();
  11459. }
  11460. };
  11461. function Func(node, parent, scope, file) {
  11462. if (!hasDefaults(node)) return;
  11463. t.ensureBlock(node);
  11464. var body = [];
  11465. var argsIdentifier = t.identifier("arguments");
  11466. argsIdentifier._shadowedFunctionLiteral = true;
  11467. var lastNonDefaultParam = 0;
  11468. var state = { iife: false, scope: scope };
  11469. var pushDefNode = function pushDefNode(left, right, i) {
  11470. var defNode = util.template("default-parameter", {
  11471. VARIABLE_NAME: left,
  11472. DEFAULT_VALUE: right,
  11473. ARGUMENT_KEY: t.literal(i),
  11474. ARGUMENTS: argsIdentifier
  11475. }, true);
  11476. defNode._blockHoist = node.params.length - i;
  11477. body.push(defNode);
  11478. };
  11479. var params = this.get("params");
  11480. for (var i = 0; i < params.length; i++) {
  11481. var param = params[i];
  11482. if (!param.isAssignmentPattern()) {
  11483. if (!param.isRestElement()) {
  11484. lastNonDefaultParam = i + 1;
  11485. }
  11486. if (!param.isIdentifier()) {
  11487. param.traverse(iifeVisitor, state);
  11488. }
  11489. if (file.transformers["es6.spec.blockScoping"].canTransform() && param.isIdentifier()) {
  11490. pushDefNode(param.node, t.identifier("undefined"), i);
  11491. }
  11492. continue;
  11493. }
  11494. var left = param.get("left");
  11495. var right = param.get("right");
  11496. var placeholder = scope.generateUidIdentifier("x");
  11497. placeholder._isDefaultPlaceholder = true;
  11498. node.params[i] = placeholder;
  11499. if (!state.iife) {
  11500. if (right.isIdentifier() && scope.hasOwnBinding(right.node.name)) {
  11501. state.iife = true;
  11502. } else {
  11503. right.traverse(iifeVisitor, state);
  11504. }
  11505. }
  11506. pushDefNode(left.node, right.node, i);
  11507. }
  11508. // we need to cut off all trailing default parameters
  11509. node.params = node.params.slice(0, lastNonDefaultParam);
  11510. if (state.iife) {
  11511. body.push((0, _helpersCallDelegate2["default"])(node, scope));
  11512. node.body = t.blockStatement(body);
  11513. } else {
  11514. node.body.body = body.concat(node.body.body);
  11515. }
  11516. }
  11517. },{"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/call-delegate":60}],100:[function(require,module,exports){
  11518. "use strict";
  11519. exports.__esModule = true;
  11520. exports.Func /*tion*/ = Func;
  11521. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11522. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11523. var _lodashLangIsNumber = require("lodash/lang/isNumber");
  11524. var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
  11525. var _util = require("../../../util");
  11526. var util = _interopRequireWildcard(_util);
  11527. var _types = require("../../../types");
  11528. var t = _interopRequireWildcard(_types);
  11529. var memberExpressionOptimisationVisitor = {
  11530. enter: function enter(node, parent, scope, state) {
  11531. // check if this scope has a local binding that will shadow the rest parameter
  11532. if (this.isScope() && !scope.bindingIdentifierEquals(state.name, state.outerBinding)) {
  11533. return this.skip();
  11534. }
  11535. // skip over functions as whatever `arguments` we reference inside will refer
  11536. // to the wrong function
  11537. if (this.isFunctionDeclaration() || this.isFunctionExpression()) {
  11538. state.noOptimise = true;
  11539. this.traverse(memberExpressionOptimisationVisitor, state);
  11540. state.noOptimise = false;
  11541. return this.skip();
  11542. }
  11543. // is this a referenced identifier and is it referencing the rest parameter?
  11544. if (!this.isReferencedIdentifier({ name: state.name })) return;
  11545. if (!state.noOptimise && t.isMemberExpression(parent) && parent.computed) {
  11546. // if we know that this member expression is referencing a number then we can safely
  11547. // optimise it
  11548. var prop = parent.property;
  11549. if ((0, _lodashLangIsNumber2["default"])(prop.value) || t.isUnaryExpression(prop) || t.isBinaryExpression(prop)) {
  11550. state.candidates.push(this);
  11551. return;
  11552. }
  11553. }
  11554. state.canOptimise = false;
  11555. this.stop();
  11556. }
  11557. };
  11558. function optimizeMemberExpression(parent, offset) {
  11559. var newExpr;
  11560. var prop = parent.property;
  11561. if (t.isLiteral(prop)) {
  11562. prop.value += offset;
  11563. prop.raw = String(prop.value);
  11564. } else {
  11565. // // UnaryExpression, BinaryExpression
  11566. newExpr = t.binaryExpression("+", prop, t.literal(offset));
  11567. parent.property = newExpr;
  11568. }
  11569. }
  11570. var hasRest = function hasRest(node) {
  11571. return t.isRestElement(node.params[node.params.length - 1]);
  11572. };
  11573. function Func(node, parent, scope, file) {
  11574. if (!hasRest(node)) return;
  11575. var restParam = node.params.pop();
  11576. var rest = restParam.argument;
  11577. var argsId = t.identifier("arguments");
  11578. // otherwise `arguments` will be remapped in arrow functions
  11579. argsId._shadowedFunctionLiteral = true;
  11580. // support patterns
  11581. if (t.isPattern(rest)) {
  11582. var pattern = rest;
  11583. rest = scope.generateUidIdentifier("ref");
  11584. var declar = t.variableDeclaration("let", pattern.elements.map(function (elem, index) {
  11585. var accessExpr = t.memberExpression(rest, t.literal(index), true);
  11586. return t.variableDeclarator(elem, accessExpr);
  11587. }));
  11588. node.body.body.unshift(declar);
  11589. }
  11590. // check if rest is used in member expressions and optimise for those cases
  11591. var state = {
  11592. outerBinding: scope.getBindingIdentifier(rest.name),
  11593. canOptimise: true,
  11594. candidates: [],
  11595. method: node,
  11596. name: rest.name
  11597. };
  11598. this.traverse(memberExpressionOptimisationVisitor, state);
  11599. // we only have shorthands and there's no other references
  11600. if (state.canOptimise && state.candidates.length) {
  11601. for (var i = 0; i < state.candidates.length; i++) {
  11602. var candidate = state.candidates[i];
  11603. candidate.replaceWith(argsId);
  11604. optimizeMemberExpression(candidate.parent, node.params.length);
  11605. }
  11606. return;
  11607. }
  11608. //
  11609. var start = t.literal(node.params.length);
  11610. var key = scope.generateUidIdentifier("key");
  11611. var len = scope.generateUidIdentifier("len");
  11612. var arrKey = key;
  11613. var arrLen = len;
  11614. if (node.params.length) {
  11615. // this method has additional params, so we need to subtract
  11616. // the index of the current argument position from the
  11617. // position in the array that we want to populate
  11618. arrKey = t.binaryExpression("-", key, start);
  11619. // we need to work out the size of the array that we're
  11620. // going to store all the rest parameters
  11621. //
  11622. // we need to add a check to avoid constructing the array
  11623. // with <0 if there are less arguments than params as it'll
  11624. // cause an error
  11625. arrLen = t.conditionalExpression(t.binaryExpression(">", len, start), t.binaryExpression("-", len, start), t.literal(0));
  11626. }
  11627. var loop = util.template("rest", {
  11628. ARRAY_TYPE: restParam.typeAnnotation,
  11629. ARGUMENTS: argsId,
  11630. ARRAY_KEY: arrKey,
  11631. ARRAY_LEN: arrLen,
  11632. START: start,
  11633. ARRAY: rest,
  11634. KEY: key,
  11635. LEN: len
  11636. });
  11637. loop._blockHoist = node.params.length + 1;
  11638. node.body.body.unshift(loop);
  11639. }
  11640. },{"../../../types":169,"../../../util":173,"lodash/lang/isNumber":410}],101:[function(require,module,exports){
  11641. "use strict";
  11642. exports.__esModule = true;
  11643. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11644. var _types = require("../../../types");
  11645. var t = _interopRequireWildcard(_types);
  11646. function loose(node, body, objId) {
  11647. for (var i = 0; i < node.properties.length; i++) {
  11648. var prop = node.properties[i];
  11649. body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)), prop.value)));
  11650. }
  11651. }
  11652. function spec(node, body, objId, initProps, file) {
  11653. var props = node.properties;
  11654. // add all non-computed properties and `__proto__` properties to the initializer
  11655. var broken = false;
  11656. for (var i = 0; i < props.length; i++) {
  11657. var prop = props[i];
  11658. if (prop.computed) {
  11659. broken = true;
  11660. }
  11661. if (prop.kind !== "init" || !broken || t.isLiteral(t.toComputedKey(prop, prop.key), { value: "__proto__" })) {
  11662. initProps.push(prop);
  11663. props[i] = null;
  11664. }
  11665. }
  11666. // add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
  11667. // otherwise use Object.defineProperty
  11668. for (var i = 0; i < props.length; i++) {
  11669. var prop = props[i];
  11670. if (!prop) continue;
  11671. var key = prop.key;
  11672. if (t.isIdentifier(key) && !prop.computed) {
  11673. key = t.literal(key.name);
  11674. }
  11675. var bodyNode = t.callExpression(file.addHelper("define-property"), [objId, key, prop.value]);
  11676. body.push(t.expressionStatement(bodyNode));
  11677. }
  11678. // only one node and it's a Object.defineProperty that returns the object
  11679. if (body.length === 1) {
  11680. var first = body[0].expression;
  11681. if (t.isCallExpression(first)) {
  11682. first.arguments[0] = t.objectExpression(initProps);
  11683. return first;
  11684. }
  11685. }
  11686. }
  11687. var ObjectExpression = {
  11688. exit: function exit(node, parent, scope, file) {
  11689. var hasComputed = false;
  11690. var _arr = node.properties;
  11691. for (var _i = 0; _i < _arr.length; _i++) {
  11692. var prop = _arr[_i];
  11693. hasComputed = t.isProperty(prop, { computed: true, kind: "init" });
  11694. if (hasComputed) break;
  11695. }
  11696. if (!hasComputed) return;
  11697. var initProps = [];
  11698. var objId = scope.generateUidIdentifierBasedOnNode(parent);
  11699. //
  11700. var body = [];
  11701. //
  11702. var callback = spec;
  11703. if (file.isLoose("es6.properties.computed")) callback = loose;
  11704. var result = callback(node, body, objId, initProps, file);
  11705. if (result) return result;
  11706. //
  11707. body.unshift(t.variableDeclaration("var", [t.variableDeclarator(objId, t.objectExpression(initProps))]));
  11708. body.push(t.expressionStatement(objId));
  11709. return body;
  11710. }
  11711. };
  11712. exports.ObjectExpression = ObjectExpression;
  11713. },{"../../../types":169}],102:[function(require,module,exports){
  11714. "use strict";
  11715. exports.__esModule = true;
  11716. exports.Property = Property;
  11717. function Property(node) {
  11718. if (node.method) {
  11719. node.method = false;
  11720. }
  11721. if (node.shorthand) {
  11722. node.shorthand = false;
  11723. }
  11724. }
  11725. },{}],103:[function(require,module,exports){
  11726. "use strict";
  11727. exports.__esModule = true;
  11728. exports.Literal = Literal;
  11729. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11730. var _helpersRegex = require("../../helpers/regex");
  11731. var regex = _interopRequireWildcard(_helpersRegex);
  11732. var _types = require("../../../types");
  11733. var t = _interopRequireWildcard(_types);
  11734. function Literal(node) {
  11735. if (!regex.is(node, "y")) return;
  11736. return t.newExpression(t.identifier("RegExp"), [t.literal(node.regex.pattern), t.literal(node.regex.flags)]);
  11737. }
  11738. },{"../../../types":169,"../../helpers/regex":67}],104:[function(require,module,exports){
  11739. "use strict";
  11740. exports.__esModule = true;
  11741. exports.Literal = Literal;
  11742. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11743. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11744. var _regexpuRewritePattern = require("regexpu/rewrite-pattern");
  11745. var _regexpuRewritePattern2 = _interopRequireDefault(_regexpuRewritePattern);
  11746. var _helpersRegex = require("../../helpers/regex");
  11747. var regex = _interopRequireWildcard(_helpersRegex);
  11748. function Literal(node) {
  11749. if (!regex.is(node, "u")) return;
  11750. node.regex.pattern = (0, _regexpuRewritePattern2["default"])(node.regex.pattern, node.regex.flags);
  11751. regex.pullFlag(node, "u");
  11752. }
  11753. },{"../../helpers/regex":67,"regexpu/rewrite-pattern":478}],105:[function(require,module,exports){
  11754. "use strict";
  11755. exports.__esModule = true;
  11756. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11757. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11758. var _traversal = require("../../../traversal");
  11759. var _traversal2 = _interopRequireDefault(_traversal);
  11760. var _types = require("../../../types");
  11761. var t = _interopRequireWildcard(_types);
  11762. var visitor = {
  11763. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  11764. if (t.isFor(parent) && parent.left === node) return;
  11765. var declared = state.letRefs[node.name];
  11766. if (!declared) return;
  11767. // declared node is different in this scope
  11768. if (scope.getBindingIdentifier(node.name) !== declared) return;
  11769. var assert = t.callExpression(state.file.addHelper("temporal-assert-defined"), [node, t.literal(node.name), state.file.addHelper("temporal-undefined")]);
  11770. this.skip();
  11771. if (t.isAssignmentExpression(parent) || t.isUpdateExpression(parent)) {
  11772. if (parent._ignoreBlockScopingTDZ) return;
  11773. this.parentPath.replaceWith(t.sequenceExpression([assert, parent]));
  11774. } else {
  11775. return t.logicalExpression("&&", assert, node);
  11776. }
  11777. }
  11778. };
  11779. var metadata = {
  11780. optional: true,
  11781. group: "builtin-advanced"
  11782. };
  11783. exports.metadata = metadata;
  11784. var BlockStatement = {
  11785. exit: function exit(node, parent, scope, file) {
  11786. var letRefs = node._letReferences;
  11787. if (!letRefs) return;
  11788. this.traverse(visitor, {
  11789. letRefs: letRefs,
  11790. file: file
  11791. });
  11792. }
  11793. };
  11794. exports.BlockStatement = BlockStatement;
  11795. exports.Program = BlockStatement;
  11796. exports.Loop = BlockStatement;
  11797. },{"../../../traversal":157,"../../../types":169}],106:[function(require,module,exports){
  11798. "use strict";
  11799. exports.__esModule = true;
  11800. exports.UnaryExpression = UnaryExpression;
  11801. exports.BinaryExpression = BinaryExpression;
  11802. exports.VariableDeclaration = VariableDeclaration;
  11803. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11804. var _types = require("../../../types");
  11805. var t = _interopRequireWildcard(_types);
  11806. var metadata = {
  11807. optional: true
  11808. };
  11809. exports.metadata = metadata;
  11810. function UnaryExpression(node, parent, scope, file) {
  11811. if (node._ignoreSpecSymbols) return;
  11812. if (node.operator === "typeof") {
  11813. var call = t.callExpression(file.addHelper("typeof"), [node.argument]);
  11814. if (this.get("argument").isIdentifier()) {
  11815. var undefLiteral = t.literal("undefined");
  11816. var unary = t.unaryExpression("typeof", node.argument);
  11817. unary._ignoreSpecSymbols = true;
  11818. return t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call);
  11819. } else {
  11820. return call;
  11821. }
  11822. }
  11823. }
  11824. function BinaryExpression(node, parent, scope, file) {
  11825. if (node.operator === "instanceof") {
  11826. return t.callExpression(file.addHelper("instanceof"), [node.left, node.right]);
  11827. }
  11828. }
  11829. function VariableDeclaration(node) {
  11830. if (node._generated) this.skip();
  11831. }
  11832. exports.FunctionDeclaration = VariableDeclaration;
  11833. },{"../../../types":169}],107:[function(require,module,exports){
  11834. "use strict";
  11835. exports.__esModule = true;
  11836. exports.TemplateLiteral = TemplateLiteral;
  11837. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11838. var _types = require("../../../types");
  11839. var t = _interopRequireWildcard(_types);
  11840. var metadata = {
  11841. optional: true
  11842. };
  11843. exports.metadata = metadata;
  11844. function TemplateLiteral(node, parent, scope, file) {
  11845. if (t.isTaggedTemplateExpression(parent)) return;
  11846. for (var i = 0; i < node.expressions.length; i++) {
  11847. node.expressions[i] = t.callExpression(t.identifier("String"), [node.expressions[i]]);
  11848. }
  11849. }
  11850. },{"../../../types":169}],108:[function(require,module,exports){
  11851. "use strict";
  11852. exports.__esModule = true;
  11853. exports.ArrayExpression = ArrayExpression;
  11854. exports.CallExpression = CallExpression;
  11855. exports.NewExpression = NewExpression;
  11856. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11857. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11858. var _lodashCollectionIncludes = require("lodash/collection/includes");
  11859. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  11860. var _types = require("../../../types");
  11861. var t = _interopRequireWildcard(_types);
  11862. function getSpreadLiteral(spread, scope) {
  11863. if (scope.file.isLoose("es6.spread")) {
  11864. return spread.argument;
  11865. } else {
  11866. return scope.toArray(spread.argument, true);
  11867. }
  11868. }
  11869. function hasSpread(nodes) {
  11870. for (var i = 0; i < nodes.length; i++) {
  11871. if (t.isSpreadElement(nodes[i])) {
  11872. return true;
  11873. }
  11874. }
  11875. return false;
  11876. }
  11877. function build(props, scope) {
  11878. var nodes = [];
  11879. var _props = [];
  11880. var push = function push() {
  11881. if (!_props.length) return;
  11882. nodes.push(t.arrayExpression(_props));
  11883. _props = [];
  11884. };
  11885. for (var i = 0; i < props.length; i++) {
  11886. var prop = props[i];
  11887. if (t.isSpreadElement(prop)) {
  11888. push();
  11889. nodes.push(getSpreadLiteral(prop, scope));
  11890. } else {
  11891. _props.push(prop);
  11892. }
  11893. }
  11894. push();
  11895. return nodes;
  11896. }
  11897. function ArrayExpression(node, parent, scope) {
  11898. var elements = node.elements;
  11899. if (!hasSpread(elements)) return;
  11900. var nodes = build(elements, scope);
  11901. var first = nodes.shift();
  11902. if (!t.isArrayExpression(first)) {
  11903. nodes.unshift(first);
  11904. first = t.arrayExpression([]);
  11905. }
  11906. return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
  11907. }
  11908. function CallExpression(node, parent, scope) {
  11909. var args = node.arguments;
  11910. if (!hasSpread(args)) return;
  11911. var contextLiteral = t.identifier("undefined");
  11912. node.arguments = [];
  11913. var nodes;
  11914. if (args.length === 1 && args[0].argument.name === "arguments") {
  11915. nodes = [args[0].argument];
  11916. } else {
  11917. nodes = build(args, scope);
  11918. }
  11919. var first = nodes.shift();
  11920. if (nodes.length) {
  11921. node.arguments.push(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes));
  11922. } else {
  11923. node.arguments.push(first);
  11924. }
  11925. var callee = node.callee;
  11926. if (this.get("callee").isMemberExpression()) {
  11927. var temp = scope.maybeGenerateMemoised(callee.object);
  11928. if (temp) {
  11929. callee.object = t.assignmentExpression("=", temp, callee.object);
  11930. contextLiteral = temp;
  11931. } else {
  11932. contextLiteral = callee.object;
  11933. }
  11934. t.appendToMemberExpression(callee, t.identifier("apply"));
  11935. } else {
  11936. node.callee = t.memberExpression(node.callee, t.identifier("apply"));
  11937. }
  11938. node.arguments.unshift(contextLiteral);
  11939. }
  11940. function NewExpression(node, parent, scope, file) {
  11941. var args = node.arguments;
  11942. if (!hasSpread(args)) return;
  11943. var nodes = build(args, scope);
  11944. var context = t.arrayExpression([t.literal(null)]);
  11945. args = t.callExpression(t.memberExpression(context, t.identifier("concat")), nodes);
  11946. return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
  11947. }
  11948. },{"../../../types":169,"lodash/collection/includes":332}],109:[function(require,module,exports){
  11949. "use strict";
  11950. exports.__esModule = true;
  11951. exports.Func /*tion*/ = Func;
  11952. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  11953. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11954. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11955. var _lodashCollectionReduceRight = require("lodash/collection/reduceRight");
  11956. var _lodashCollectionReduceRight2 = _interopRequireDefault(_lodashCollectionReduceRight);
  11957. var _messages = require("../../../messages");
  11958. var messages = _interopRequireWildcard(_messages);
  11959. var _lodashArrayFlatten = require("lodash/array/flatten");
  11960. var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
  11961. var _traversal = require("../../../traversal");
  11962. var _traversal2 = _interopRequireDefault(_traversal);
  11963. var _util = require("../../../util");
  11964. var util = _interopRequireWildcard(_util);
  11965. var _lodashCollectionMap = require("lodash/collection/map");
  11966. var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
  11967. var _types = require("../../../types");
  11968. var t = _interopRequireWildcard(_types);
  11969. var metadata = {
  11970. group: "builtin-trailing"
  11971. };
  11972. exports.metadata = metadata;
  11973. function Func(node, parent, scope, file) {
  11974. if (node.generator || node.async) return;
  11975. var tailCall = new TailCallTransformer(this, scope, file);
  11976. tailCall.run();
  11977. }
  11978. function returnBlock(expr) {
  11979. return t.blockStatement([t.returnStatement(expr)]);
  11980. }
  11981. var visitor = {
  11982. enter: function enter(node, parent, scope, state) {
  11983. if (t.isTryStatement(parent)) {
  11984. if (node === parent.block) {
  11985. this.skip();
  11986. } else if (parent.finalizer && node !== parent.finalizer) {
  11987. this.skip();
  11988. }
  11989. }
  11990. },
  11991. ReturnStatement: function ReturnStatement(node, parent, scope, state) {
  11992. return state.subTransform(node.argument);
  11993. },
  11994. Function: function Function(node, parent, scope, state) {
  11995. this.skip();
  11996. },
  11997. VariableDeclaration: function VariableDeclaration(node, parent, scope, state) {
  11998. state.vars.push(node);
  11999. },
  12000. ThisExpression: function ThisExpression(node, parent, scope, state) {
  12001. state.needsThis = true;
  12002. state.thisPaths.push(this);
  12003. },
  12004. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  12005. if (node.name === "arguments") {
  12006. state.needsArguments = true;
  12007. state.argumentsPaths.push(this);
  12008. }
  12009. }
  12010. };
  12011. var TailCallTransformer = (function () {
  12012. function TailCallTransformer(path, scope, file) {
  12013. _classCallCheck(this, TailCallTransformer);
  12014. this.hasTailRecursion = false;
  12015. this.needsArguments = false;
  12016. this.argumentsPaths = [];
  12017. this.setsArguments = false;
  12018. this.needsThis = false;
  12019. this.thisPaths = [];
  12020. this.ownerId = path.node.id;
  12021. this.vars = [];
  12022. this.scope = scope;
  12023. this.path = path;
  12024. this.file = file;
  12025. this.node = path.node;
  12026. }
  12027. TailCallTransformer.prototype.getArgumentsId = function getArgumentsId() {
  12028. return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments");
  12029. };
  12030. TailCallTransformer.prototype.getThisId = function getThisId() {
  12031. return this.thisId = this.thisId || this.scope.generateUidIdentifier("this");
  12032. };
  12033. TailCallTransformer.prototype.getLeftId = function getLeftId() {
  12034. return this.leftId = this.leftId || this.scope.generateUidIdentifier("left");
  12035. };
  12036. TailCallTransformer.prototype.getFunctionId = function getFunctionId() {
  12037. return this.functionId = this.functionId || this.scope.generateUidIdentifier("function");
  12038. };
  12039. TailCallTransformer.prototype.getAgainId = function getAgainId() {
  12040. return this.againId = this.againId || this.scope.generateUidIdentifier("again");
  12041. };
  12042. TailCallTransformer.prototype.getParams = function getParams() {
  12043. var params = this.params;
  12044. if (!params) {
  12045. params = this.node.params;
  12046. this.paramDecls = [];
  12047. for (var i = 0; i < params.length; i++) {
  12048. var param = params[i];
  12049. if (!param._isDefaultPlaceholder) {
  12050. this.paramDecls.push(t.variableDeclarator(param, params[i] = this.scope.generateUidIdentifier("x")));
  12051. }
  12052. }
  12053. }
  12054. return this.params = params;
  12055. };
  12056. TailCallTransformer.prototype.hasDeopt = function hasDeopt() {
  12057. // check if the ownerId has been reassigned, if it has then it's not safe to
  12058. // perform optimisations
  12059. var ownerIdInfo = this.scope.getBinding(this.ownerId.name);
  12060. return ownerIdInfo && !ownerIdInfo.constant;
  12061. };
  12062. TailCallTransformer.prototype.run = function run() {
  12063. var scope = this.scope;
  12064. var node = this.node;
  12065. // only tail recursion can be optimized as for now, so we can skip anonymous
  12066. // functions entirely
  12067. var ownerId = this.ownerId;
  12068. if (!ownerId) return;
  12069. // traverse the function and look for tail recursion
  12070. this.path.traverse(visitor, this);
  12071. // has no tail call recursion
  12072. if (!this.hasTailRecursion) return;
  12073. // the function binding isn't constant so we can't be sure that it's the same function :(
  12074. if (this.hasDeopt()) {
  12075. this.file.log.deopt(node, messages.get("tailCallReassignmentDeopt"));
  12076. return;
  12077. }
  12078. //
  12079. var body = t.ensureBlock(node).body;
  12080. for (var i = 0; i < body.length; i++) {
  12081. var bodyNode = body[i];
  12082. if (!t.isFunctionDeclaration(bodyNode)) continue;
  12083. bodyNode = body[i] = t.variableDeclaration("var", [t.variableDeclarator(bodyNode.id, t.toExpression(bodyNode))]);
  12084. bodyNode._blockHoist = 2;
  12085. }
  12086. if (this.vars.length > 0) {
  12087. var declarations = (0, _lodashArrayFlatten2["default"])((0, _lodashCollectionMap2["default"])(this.vars, function (decl) {
  12088. return decl.declarations;
  12089. }));
  12090. var assignment = (0, _lodashCollectionReduceRight2["default"])(declarations, function (expr, decl) {
  12091. return t.assignmentExpression("=", decl.id, expr);
  12092. }, t.identifier("undefined"));
  12093. var statement = t.expressionStatement(assignment);
  12094. statement._blockHoist = Infinity;
  12095. body.unshift(statement);
  12096. }
  12097. var paramDecls = this.paramDecls;
  12098. if (paramDecls.length > 0) {
  12099. var paramDecl = t.variableDeclaration("var", paramDecls);
  12100. paramDecl._blockHoist = Infinity;
  12101. body.unshift(paramDecl);
  12102. }
  12103. body.unshift(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(false))));
  12104. node.body = util.template("tail-call-body", {
  12105. FUNCTION_ID: this.getFunctionId(),
  12106. AGAIN_ID: this.getAgainId(),
  12107. BLOCK: node.body
  12108. });
  12109. var topVars = [];
  12110. if (this.needsThis) {
  12111. var _arr = this.thisPaths;
  12112. for (var _i = 0; _i < _arr.length; _i++) {
  12113. var path = _arr[_i];
  12114. path.replaceWith(this.getThisId());
  12115. }
  12116. topVars.push(t.variableDeclarator(this.getThisId(), t.thisExpression()));
  12117. }
  12118. if (this.needsArguments || this.setsArguments) {
  12119. var _arr2 = this.argumentsPaths;
  12120. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  12121. var path = _arr2[_i2];
  12122. path.replaceWith(this.argumentsId);
  12123. }
  12124. var decl = t.variableDeclarator(this.argumentsId);
  12125. if (this.argumentsId) {
  12126. decl.init = t.identifier("arguments");
  12127. }
  12128. topVars.push(decl);
  12129. }
  12130. var leftId = this.leftId;
  12131. if (leftId) {
  12132. topVars.push(t.variableDeclarator(leftId));
  12133. }
  12134. if (topVars.length > 0) {
  12135. node.body.body.unshift(t.variableDeclaration("var", topVars));
  12136. }
  12137. };
  12138. TailCallTransformer.prototype.subTransform = function subTransform(node) {
  12139. if (!node) return;
  12140. var handler = this["subTransform" + node.type];
  12141. if (handler) return handler.call(this, node);
  12142. };
  12143. TailCallTransformer.prototype.subTransformConditionalExpression = function subTransformConditionalExpression(node) {
  12144. var callConsequent = this.subTransform(node.consequent);
  12145. var callAlternate = this.subTransform(node.alternate);
  12146. if (!callConsequent && !callAlternate) {
  12147. return;
  12148. }
  12149. // if ternary operator had tail recursion in value, convert to optimized if-statement
  12150. node.type = "IfStatement";
  12151. node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent);
  12152. if (callAlternate) {
  12153. node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate);
  12154. } else {
  12155. node.alternate = returnBlock(node.alternate);
  12156. }
  12157. return [node];
  12158. };
  12159. TailCallTransformer.prototype.subTransformLogicalExpression = function subTransformLogicalExpression(node) {
  12160. // only call in right-value of can be optimized
  12161. var callRight = this.subTransform(node.right);
  12162. if (!callRight) return;
  12163. // cache left value as it might have side-effects
  12164. var leftId = this.getLeftId();
  12165. var testExpr = t.assignmentExpression("=", leftId, node.left);
  12166. if (node.operator === "&&") {
  12167. testExpr = t.unaryExpression("!", testExpr);
  12168. }
  12169. return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight);
  12170. };
  12171. TailCallTransformer.prototype.subTransformSequenceExpression = function subTransformSequenceExpression(node) {
  12172. var seq = node.expressions;
  12173. // only last element can be optimized
  12174. var lastCall = this.subTransform(seq[seq.length - 1]);
  12175. if (!lastCall) {
  12176. return;
  12177. }
  12178. // remove converted expression from sequence
  12179. // and convert to regular expression if needed
  12180. if (--seq.length === 1) {
  12181. node = seq[0];
  12182. }
  12183. return [t.expressionStatement(node)].concat(lastCall);
  12184. };
  12185. TailCallTransformer.prototype.subTransformCallExpression = function subTransformCallExpression(node) {
  12186. var callee = node.callee,
  12187. thisBinding,
  12188. args;
  12189. if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) {
  12190. switch (callee.property.name) {
  12191. case "call":
  12192. args = t.arrayExpression(node.arguments.slice(1));
  12193. break;
  12194. case "apply":
  12195. args = node.arguments[1] || t.identifier("undefined");
  12196. break;
  12197. default:
  12198. return;
  12199. }
  12200. thisBinding = node.arguments[0];
  12201. callee = callee.object;
  12202. }
  12203. // only tail recursion can be optimized as for now
  12204. if (!t.isIdentifier(callee) || !this.scope.bindingIdentifierEquals(callee.name, this.ownerId)) {
  12205. return;
  12206. }
  12207. this.hasTailRecursion = true;
  12208. if (this.hasDeopt()) return;
  12209. var body = [];
  12210. if (this.needsThis && !t.isThisExpression(thisBinding)) {
  12211. body.push(t.expressionStatement(t.assignmentExpression("=", this.getThisId(), thisBinding || t.identifier("undefined"))));
  12212. }
  12213. if (!args) {
  12214. args = t.arrayExpression(node.arguments);
  12215. }
  12216. var argumentsId = this.getArgumentsId();
  12217. var params = this.getParams();
  12218. if (this.needsArguments) {
  12219. body.push(t.expressionStatement(t.assignmentExpression("=", argumentsId, args)));
  12220. }
  12221. if (t.isArrayExpression(args)) {
  12222. var elems = args.elements;
  12223. for (var i = 0; i < elems.length && i < params.length; i++) {
  12224. var param = params[i];
  12225. var elem = elems[i] || (elems[i] = t.identifier("undefined"));
  12226. if (!param._isDefaultPlaceholder) {
  12227. elems[i] = t.assignmentExpression("=", param, elem);
  12228. }
  12229. }
  12230. if (!this.needsArguments) {
  12231. var _arr3 = elems;
  12232. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  12233. var elem = _arr3[_i3];
  12234. body.push(t.expressionStatement(elem));
  12235. }
  12236. }
  12237. } else {
  12238. this.setsArguments = true;
  12239. for (var i = 0; i < params.length; i++) {
  12240. var param = params[i];
  12241. if (!param._isDefaultPlaceholder) {
  12242. body.push(t.expressionStatement(t.assignmentExpression("=", param, t.memberExpression(argumentsId, t.literal(i), true))));
  12243. }
  12244. }
  12245. }
  12246. body.push(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(true))));
  12247. body.push(t.continueStatement(this.getFunctionId()));
  12248. return body;
  12249. };
  12250. return TailCallTransformer;
  12251. })();
  12252. },{"../../../messages":47,"../../../traversal":157,"../../../types":169,"../../../util":173,"lodash/array/flatten":325,"lodash/collection/map":333,"lodash/collection/reduceRight":334}],110:[function(require,module,exports){
  12253. "use strict";
  12254. exports.__esModule = true;
  12255. exports.TaggedTemplateExpression = TaggedTemplateExpression;
  12256. exports.TemplateLiteral = TemplateLiteral;
  12257. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12258. var _types = require("../../../types");
  12259. var t = _interopRequireWildcard(_types);
  12260. var buildBinaryExpression = function buildBinaryExpression(left, right) {
  12261. return t.binaryExpression("+", left, right);
  12262. };
  12263. function TaggedTemplateExpression(node, parent, scope, file) {
  12264. var quasi = node.quasi;
  12265. var args = [];
  12266. var strings = [];
  12267. var raw = [];
  12268. for (var i = 0; i < quasi.quasis.length; i++) {
  12269. var elem = quasi.quasis[i];
  12270. strings.push(t.literal(elem.value.cooked));
  12271. raw.push(t.literal(elem.value.raw));
  12272. }
  12273. strings = t.arrayExpression(strings);
  12274. raw = t.arrayExpression(raw);
  12275. var templateName = "tagged-template-literal";
  12276. if (file.isLoose("es6.templateLiterals")) templateName += "-loose";
  12277. args.push(t.callExpression(file.addHelper(templateName), [strings, raw]));
  12278. args = args.concat(quasi.expressions);
  12279. return t.callExpression(node.tag, args);
  12280. }
  12281. function TemplateLiteral(node, parent, scope, file) {
  12282. var nodes = [];
  12283. var i;
  12284. for (i = 0; i < node.quasis.length; i++) {
  12285. var elem = node.quasis[i];
  12286. nodes.push(t.literal(elem.value.cooked));
  12287. var expr = node.expressions.shift();
  12288. if (expr) nodes.push(expr);
  12289. }
  12290. if (nodes.length > 1) {
  12291. // remove redundant '' at the end of the expression
  12292. var last = nodes[nodes.length - 1];
  12293. if (t.isLiteral(last, { value: "" })) nodes.pop();
  12294. var root = buildBinaryExpression(nodes.shift(), nodes.shift());
  12295. for (i = 0; i < nodes.length; i++) {
  12296. root = buildBinaryExpression(root, nodes[i]);
  12297. }
  12298. return root;
  12299. } else {
  12300. return nodes[0];
  12301. }
  12302. }
  12303. },{"../../../types":169}],111:[function(require,module,exports){
  12304. "use strict";
  12305. exports.__esModule = true;
  12306. var metadata = {
  12307. stage: 1
  12308. };
  12309. exports.metadata = metadata;
  12310. },{}],112:[function(require,module,exports){
  12311. "use strict";
  12312. exports.__esModule = true;
  12313. var metadata = {
  12314. stage: 0,
  12315. dependencies: ["es6.classes"]
  12316. };
  12317. exports.metadata = metadata;
  12318. },{}],113:[function(require,module,exports){
  12319. "use strict";
  12320. exports.__esModule = true;
  12321. exports.ComprehensionExpression = ComprehensionExpression;
  12322. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12323. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12324. var _helpersBuildComprehension = require("../../helpers/build-comprehension");
  12325. var _helpersBuildComprehension2 = _interopRequireDefault(_helpersBuildComprehension);
  12326. var _traversal = require("../../../traversal");
  12327. var _traversal2 = _interopRequireDefault(_traversal);
  12328. var _util = require("../../../util");
  12329. var util = _interopRequireWildcard(_util);
  12330. var _types = require("../../../types");
  12331. var t = _interopRequireWildcard(_types);
  12332. var metadata = {
  12333. stage: 0
  12334. };
  12335. exports.metadata = metadata;
  12336. function ComprehensionExpression(node, parent, scope, file) {
  12337. var callback = array;
  12338. if (node.generator) callback = generator;
  12339. return callback(node, parent, scope, file);
  12340. }
  12341. function generator(node) {
  12342. var body = [];
  12343. var container = t.functionExpression(null, [], t.blockStatement(body), true);
  12344. container.shadow = true;
  12345. body.push((0, _helpersBuildComprehension2["default"])(node, function () {
  12346. return t.expressionStatement(t.yieldExpression(node.body));
  12347. }));
  12348. return t.callExpression(container, []);
  12349. }
  12350. function array(node, parent, scope, file) {
  12351. var uid = scope.generateUidIdentifierBasedOnNode(parent);
  12352. var container = util.template("array-comprehension-container", {
  12353. KEY: uid
  12354. });
  12355. container.callee.shadow = true;
  12356. var block = container.callee.body;
  12357. var body = block.body;
  12358. if (_traversal2["default"].hasType(node, scope, "YieldExpression", t.FUNCTION_TYPES)) {
  12359. container.callee.generator = true;
  12360. container = t.yieldExpression(container, true);
  12361. }
  12362. var returnStatement = body.pop();
  12363. body.push((0, _helpersBuildComprehension2["default"])(node, function () {
  12364. return util.template("array-push", {
  12365. STATEMENT: node.body,
  12366. KEY: uid
  12367. }, true);
  12368. }));
  12369. body.push(returnStatement);
  12370. return container;
  12371. }
  12372. },{"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/build-comprehension":58}],114:[function(require,module,exports){
  12373. "use strict";
  12374. exports.__esModule = true;
  12375. exports.ObjectExpression = ObjectExpression;
  12376. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12378. var _helpersMemoiseDecorators = require("../../helpers/memoise-decorators");
  12379. var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
  12380. var _helpersDefineMap = require("../../helpers/define-map");
  12381. var defineMap = _interopRequireWildcard(_helpersDefineMap);
  12382. var _types = require("../../../types");
  12383. var t = _interopRequireWildcard(_types);
  12384. var metadata = {
  12385. dependencies: ["es6.classes"],
  12386. optional: true,
  12387. stage: 1
  12388. };
  12389. exports.metadata = metadata;
  12390. function ObjectExpression(node, parent, scope, file) {
  12391. var hasDecorators = false;
  12392. for (var i = 0; i < node.properties.length; i++) {
  12393. var prop = node.properties[i];
  12394. if (prop.decorators) {
  12395. hasDecorators = true;
  12396. break;
  12397. }
  12398. }
  12399. if (!hasDecorators) return;
  12400. var mutatorMap = {};
  12401. for (var i = 0; i < node.properties.length; i++) {
  12402. var prop = node.properties[i];
  12403. if (prop.decorators) (0, _helpersMemoiseDecorators2["default"])(prop.decorators, scope);
  12404. if (prop.kind === "init") {
  12405. prop.kind = "";
  12406. prop.value = t.functionExpression(null, [], t.blockStatement([t.returnStatement(prop.value)]));
  12407. }
  12408. defineMap.push(mutatorMap, prop, "initializer", file);
  12409. }
  12410. var obj = defineMap.toClassObject(mutatorMap);
  12411. obj = defineMap.toComputedObjectFromClass(obj);
  12412. return t.callExpression(file.addHelper("create-decorated-object"), [obj]);
  12413. }
  12414. },{"../../../types":169,"../../helpers/define-map":61,"../../helpers/memoise-decorators":64}],115:[function(require,module,exports){
  12415. "use strict";
  12416. exports.__esModule = true;
  12417. exports.DoExpression = DoExpression;
  12418. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12419. var _types = require("../../../types");
  12420. var t = _interopRequireWildcard(_types);
  12421. var metadata = {
  12422. optional: true,
  12423. stage: 0
  12424. };
  12425. exports.metadata = metadata;
  12426. function DoExpression(node) {
  12427. var body = node.body.body;
  12428. if (body.length) {
  12429. return body;
  12430. } else {
  12431. return t.identifier("undefined");
  12432. }
  12433. }
  12434. },{"../../../types":169}],116:[function(require,module,exports){
  12435. // https://github.com/rwaldron/exponentiation-operator
  12436. "use strict";
  12437. exports.__esModule = true;
  12438. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12439. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12440. var _helpersBuildBinaryAssignmentOperatorTransformer = require("../../helpers/build-binary-assignment-operator-transformer");
  12441. var _helpersBuildBinaryAssignmentOperatorTransformer2 = _interopRequireDefault(_helpersBuildBinaryAssignmentOperatorTransformer);
  12442. var _types = require("../../../types");
  12443. var t = _interopRequireWildcard(_types);
  12444. var metadata = {
  12445. stage: 2
  12446. };
  12447. exports.metadata = metadata;
  12448. var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
  12449. var _build = (0, _helpersBuildBinaryAssignmentOperatorTransformer2["default"])({
  12450. operator: "**",
  12451. build: function build(left, right) {
  12452. return t.callExpression(MATH_POW, [left, right]);
  12453. }
  12454. });
  12455. var ExpressionStatement = _build.ExpressionStatement;
  12456. var AssignmentExpression = _build.AssignmentExpression;
  12457. var BinaryExpression = _build.BinaryExpression;
  12458. exports.ExpressionStatement = ExpressionStatement;
  12459. exports.AssignmentExpression = AssignmentExpression;
  12460. exports.BinaryExpression = BinaryExpression;
  12461. },{"../../../types":169,"../../helpers/build-binary-assignment-operator-transformer":57}],117:[function(require,module,exports){
  12462. // https://github.com/leebyron/ecmascript-more-export-from
  12463. "use strict";
  12464. exports.__esModule = true;
  12465. exports.ExportNamedDeclaration = ExportNamedDeclaration;
  12466. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12467. var _types = require("../../../types");
  12468. var t = _interopRequireWildcard(_types);
  12469. var metadata = {
  12470. stage: 1
  12471. };
  12472. exports.metadata = metadata;
  12473. function build(node, nodes, scope) {
  12474. var first = node.specifiers[0];
  12475. if (!t.isExportNamespaceSpecifier(first) && !t.isExportDefaultSpecifier(first)) return;
  12476. var specifier = node.specifiers.shift();
  12477. var uid = scope.generateUidIdentifier(specifier.exported.name);
  12478. var newSpecifier;
  12479. if (t.isExportNamespaceSpecifier(specifier)) {
  12480. newSpecifier = t.importNamespaceSpecifier(uid);
  12481. } else {
  12482. newSpecifier = t.importDefaultSpecifier(uid);
  12483. }
  12484. nodes.push(t.importDeclaration([newSpecifier], node.source));
  12485. nodes.push(t.exportNamedDeclaration(null, [t.exportSpecifier(uid, specifier.exported)]));
  12486. build(node, nodes, scope);
  12487. }
  12488. function ExportNamedDeclaration(node, parent, scope) {
  12489. var nodes = [];
  12490. build(node, nodes, scope);
  12491. if (!nodes.length) return;
  12492. if (node.specifiers.length >= 1) {
  12493. nodes.push(node);
  12494. }
  12495. return nodes;
  12496. }
  12497. },{"../../../types":169}],118:[function(require,module,exports){
  12498. // https://github.com/zenparsing/es-function-bind
  12499. "use strict";
  12500. exports.__esModule = true;
  12501. exports.CallExpression = CallExpression;
  12502. exports.BindExpression = BindExpression;
  12503. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12504. var _types = require("../../../types");
  12505. var t = _interopRequireWildcard(_types);
  12506. var metadata = {
  12507. optional: true,
  12508. stage: 0
  12509. };
  12510. exports.metadata = metadata;
  12511. function getTempId(scope) {
  12512. var id = scope.path.getData("functionBind");
  12513. if (id) return id;
  12514. id = scope.generateDeclaredUidIdentifier("context");
  12515. return scope.path.setData("functionBind", id);
  12516. }
  12517. function getStaticContext(bind, scope) {
  12518. var object = bind.object || bind.callee.object;
  12519. return scope.isStatic(object) && object;
  12520. }
  12521. function inferBindContext(bind, scope) {
  12522. var staticContext = getStaticContext(bind, scope);
  12523. if (staticContext) return staticContext;
  12524. var tempId = getTempId(scope);
  12525. if (bind.object) {
  12526. bind.callee = t.sequenceExpression([t.assignmentExpression("=", tempId, bind.object), bind.callee]);
  12527. } else {
  12528. bind.callee.object = t.assignmentExpression("=", tempId, bind.callee.object);
  12529. }
  12530. return tempId;
  12531. }
  12532. function CallExpression(node, parent, scope, file) {
  12533. var bind = node.callee;
  12534. if (!t.isBindExpression(bind)) return;
  12535. var context = inferBindContext(bind, scope);
  12536. node.callee = t.memberExpression(bind.callee, t.identifier("call"));
  12537. node.arguments.unshift(context);
  12538. }
  12539. function BindExpression(node, parent, scope, file) {
  12540. var context = inferBindContext(node, scope);
  12541. return t.callExpression(t.memberExpression(node.callee, t.identifier("bind")), [context]);
  12542. }
  12543. },{"../../../types":169}],119:[function(require,module,exports){
  12544. // https://github.com/sebmarkbage/ecmascript-rest-spread
  12545. "use strict";
  12546. exports.__esModule = true;
  12547. exports.ObjectExpression = ObjectExpression;
  12548. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12549. var _types = require("../../../types");
  12550. var t = _interopRequireWildcard(_types);
  12551. var metadata = {
  12552. stage: 1,
  12553. dependencies: ["es6.destructuring"]
  12554. };
  12555. exports.metadata = metadata;
  12556. var hasSpread = function hasSpread(node) {
  12557. for (var i = 0; i < node.properties.length; i++) {
  12558. if (t.isSpreadProperty(node.properties[i])) {
  12559. return true;
  12560. }
  12561. }
  12562. return false;
  12563. };
  12564. function ObjectExpression(node, parent, scope, file) {
  12565. if (!hasSpread(node)) return;
  12566. var args = [];
  12567. var props = [];
  12568. var push = function push() {
  12569. if (!props.length) return;
  12570. args.push(t.objectExpression(props));
  12571. props = [];
  12572. };
  12573. for (var i = 0; i < node.properties.length; i++) {
  12574. var prop = node.properties[i];
  12575. if (t.isSpreadProperty(prop)) {
  12576. push();
  12577. args.push(prop.argument);
  12578. } else {
  12579. props.push(prop);
  12580. }
  12581. }
  12582. push();
  12583. if (!t.isObjectExpression(args[0])) {
  12584. args.unshift(t.objectExpression([]));
  12585. }
  12586. return t.callExpression(file.addHelper("extends"), args);
  12587. }
  12588. },{"../../../types":169}],120:[function(require,module,exports){
  12589. arguments[4][111][0].apply(exports,arguments)
  12590. },{"dup":111}],121:[function(require,module,exports){
  12591. "use strict";
  12592. exports.__esModule = true;
  12593. exports.internal = internal;
  12594. exports.blacklist = blacklist;
  12595. exports.whitelist = whitelist;
  12596. exports.stage = stage;
  12597. exports.optional = optional;
  12598. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12599. var _lodashCollectionIncludes = require("lodash/collection/includes");
  12600. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  12601. function internal(transformer, opts) {
  12602. if (transformer.key[0] === "_") return true;
  12603. }
  12604. function blacklist(transformer, opts) {
  12605. var blacklist = opts.blacklist;
  12606. if (blacklist.length && (0, _lodashCollectionIncludes2["default"])(blacklist, transformer.key)) return false;
  12607. }
  12608. function whitelist(transformer, opts) {
  12609. var whitelist = opts.whitelist;
  12610. if (whitelist) return (0, _lodashCollectionIncludes2["default"])(whitelist, transformer.key);
  12611. }
  12612. function stage(transformer, opts) {
  12613. var stage = transformer.metadata.stage;
  12614. if (stage != null && stage >= opts.stage) return true;
  12615. }
  12616. function optional(transformer, opts) {
  12617. if (transformer.metadata.optional && !(0, _lodashCollectionIncludes2["default"])(opts.optional, transformer.key)) return false;
  12618. }
  12619. },{"lodash/collection/includes":332}],122:[function(require,module,exports){
  12620. "use strict";
  12621. exports.__esModule = true;
  12622. exports["default"] = {
  12623. //- builtin-setup
  12624. strict: require("./other/strict"),
  12625. _explode: require("./internal/explode"),
  12626. _validation: require("./internal/validation"),
  12627. _hoistDirectives: require("./internal/hoist-directives"),
  12628. "minification.removeDebugger": require("./minification/remove-debugger"),
  12629. "minification.removeConsole": require("./minification/remove-console"),
  12630. "utility.inlineEnvironmentVariables": require("./utility/inline-environment-variables"),
  12631. "minification.inlineExpressions": require("./minification/inline-expressions"),
  12632. "minification.deadCodeElimination": require("./minification/dead-code-elimination"),
  12633. _modules: require("./internal/modules"),
  12634. "spec.functionName": require("./spec/function-name"),
  12635. //- builtin-basic
  12636. // this is where the bulk of the ES6 transformations take place, none of them require traversal state
  12637. // so they can all be concatenated together for performance
  12638. "es7.classProperties": require("./es7/class-properties"),
  12639. "es7.trailingFunctionCommas": require("./es7/trailing-function-commas"),
  12640. "es7.asyncFunctions": require("./es7/async-functions"),
  12641. "es7.decorators": require("./es7/decorators"),
  12642. "validation.undeclaredVariableCheck": require("./validation/undeclared-variable-check"),
  12643. "validation.react": require("./validation/react"),
  12644. "es6.arrowFunctions": require("./es6/arrow-functions"),
  12645. "spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
  12646. "optimisation.react.constantElements": require("./optimisation/react.constant-elements"),
  12647. "optimisation.react.inlineElements": require("./optimisation/react.inline-elements"),
  12648. "es7.comprehensions": require("./es7/comprehensions"),
  12649. "es6.classes": require("./es6/classes"),
  12650. asyncToGenerator: require("./other/async-to-generator"),
  12651. bluebirdCoroutines: require("./other/bluebird-coroutines"),
  12652. "es6.objectSuper": require("./es6/object-super"),
  12653. "es7.objectRestSpread": require("./es7/object-rest-spread"),
  12654. "es7.exponentiationOperator": require("./es7/exponentiation-operator"),
  12655. "es6.spec.templateLiterals": require("./es6/spec.template-literals"),
  12656. "es6.templateLiterals": require("./es6/template-literals"),
  12657. "es5.properties.mutators": require("./es5/properties.mutators"),
  12658. "es6.properties.shorthand": require("./es6/properties.shorthand"),
  12659. "es6.properties.computed": require("./es6/properties.computed"),
  12660. "optimisation.flow.forOf": require("./optimisation/flow.for-of"),
  12661. "es6.forOf": require("./es6/for-of"),
  12662. "es6.regex.sticky": require("./es6/regex.sticky"),
  12663. "es6.regex.unicode": require("./es6/regex.unicode"),
  12664. "es6.constants": require("./es6/constants"),
  12665. "es6.parameters.rest": require("./es6/parameters.rest"),
  12666. "es6.spread": require("./es6/spread"),
  12667. "es6.parameters.default": require("./es6/parameters.default"),
  12668. "es7.exportExtensions": require("./es7/export-extensions"),
  12669. "spec.protoToAssign": require("./spec/proto-to-assign"),
  12670. "es7.doExpressions": require("./es7/do-expressions"),
  12671. "es6.spec.symbols": require("./es6/spec.symbols"),
  12672. "es7.functionBind": require("./es7/function-bind"),
  12673. "spec.undefinedToVoid": require("./spec/undefined-to-void"),
  12674. jscript: require("./other/jscript"),
  12675. flow: require("./other/flow"),
  12676. //- builtin-advanced
  12677. "es6.destructuring": require("./es6/destructuring"),
  12678. "es6.blockScoping": require("./es6/block-scoping"),
  12679. "es6.spec.blockScoping": require("./es6/spec.block-scoping"),
  12680. reactCompat: require("./other/react-compat"),
  12681. react: require("./other/react"),
  12682. // es6 syntax transformation is **forbidden** past this point since regenerator will chuck a massive
  12683. // hissy fit
  12684. //- regenerator
  12685. regenerator: require("./other/regenerator"),
  12686. //- builtin-modules
  12687. runtime: require("./other/runtime"),
  12688. "es6.modules": require("./es6/modules"),
  12689. _moduleFormatter: require("./internal/module-formatter"),
  12690. //- builtin-trailing
  12691. // these clean up the output and do finishing up transformations, it's important to note that by this
  12692. // stage you can't import any new modules or insert new ES6 as all those transformers have already
  12693. // been ran
  12694. "es6.tailCall": require("./es6/tail-call"),
  12695. _shadowFunctions: require("./internal/shadow-functions"),
  12696. "es3.propertyLiterals": require("./es3/property-literals"),
  12697. "es3.memberExpressionLiterals": require("./es3/member-expression-literals"),
  12698. "minification.memberExpressionLiterals": require("./minification/member-expression-literals"),
  12699. "minification.propertyLiterals": require("./minification/property-literals"),
  12700. _blockHoist: require("./internal/block-hoist") };
  12701. module.exports = exports["default"];
  12702. },{"./es3/member-expression-literals":88,"./es3/property-literals":89,"./es5/properties.mutators":90,"./es6/arrow-functions":91,"./es6/block-scoping":92,"./es6/classes":93,"./es6/constants":94,"./es6/destructuring":95,"./es6/for-of":96,"./es6/modules":97,"./es6/object-super":98,"./es6/parameters.default":99,"./es6/parameters.rest":100,"./es6/properties.computed":101,"./es6/properties.shorthand":102,"./es6/regex.sticky":103,"./es6/regex.unicode":104,"./es6/spec.block-scoping":105,"./es6/spec.symbols":106,"./es6/spec.template-literals":107,"./es6/spread":108,"./es6/tail-call":109,"./es6/template-literals":110,"./es7/async-functions":111,"./es7/class-properties":112,"./es7/comprehensions":113,"./es7/decorators":114,"./es7/do-expressions":115,"./es7/exponentiation-operator":116,"./es7/export-extensions":117,"./es7/function-bind":118,"./es7/object-rest-spread":119,"./es7/trailing-function-commas":120,"./internal/block-hoist":123,"./internal/explode":124,"./internal/hoist-directives":125,"./internal/module-formatter":126,"./internal/modules":127,"./internal/shadow-functions":128,"./internal/validation":129,"./minification/dead-code-elimination":130,"./minification/inline-expressions":131,"./minification/member-expression-literals":132,"./minification/property-literals":133,"./minification/remove-console":134,"./minification/remove-debugger":135,"./optimisation/flow.for-of":136,"./optimisation/react.constant-elements":137,"./optimisation/react.inline-elements":138,"./other/async-to-generator":139,"./other/bluebird-coroutines":140,"./other/flow":141,"./other/jscript":142,"./other/react":144,"./other/react-compat":143,"./other/regenerator":145,"./other/runtime":147,"./other/strict":148,"./spec/block-scoped-functions":149,"./spec/function-name":150,"./spec/proto-to-assign":151,"./spec/undefined-to-void":152,"./utility/inline-environment-variables":153,"./validation/react":154,"./validation/undeclared-variable-check":155}],123:[function(require,module,exports){
  12703. "use strict";
  12704. exports.__esModule = true;
  12705. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12706. var _lodashCollectionSortBy = require("lodash/collection/sortBy");
  12707. var _lodashCollectionSortBy2 = _interopRequireDefault(_lodashCollectionSortBy);
  12708. var metadata = {
  12709. group: "builtin-trailing"
  12710. };
  12711. exports.metadata = metadata;
  12712. // Priority:
  12713. //
  12714. // - 0 We want this to be at the **very** bottom
  12715. // - 1 Default node position
  12716. // - 2 Priority over normal nodes
  12717. // - 3 We want this to be at the **very** top
  12718. var BlockStatement = {
  12719. exit: function exit(node) {
  12720. var hasChange = false;
  12721. for (var i = 0; i < node.body.length; i++) {
  12722. var bodyNode = node.body[i];
  12723. if (bodyNode && bodyNode._blockHoist != null) hasChange = true;
  12724. }
  12725. if (!hasChange) return;
  12726. node.body = (0, _lodashCollectionSortBy2["default"])(node.body, function (bodyNode) {
  12727. var priority = bodyNode && bodyNode._blockHoist;
  12728. if (priority == null) priority = 1;
  12729. if (priority === true) priority = 2;
  12730. // Higher priorities should move toward the top.
  12731. return -1 * priority;
  12732. });
  12733. }
  12734. };
  12735. exports.BlockStatement = BlockStatement;
  12736. exports.Program = BlockStatement;
  12737. },{"lodash/collection/sortBy":336}],124:[function(require,module,exports){
  12738. "use strict";
  12739. exports.__esModule = true;
  12740. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12741. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12742. var _lodashLangClone = require("lodash/lang/clone");
  12743. var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
  12744. var _types = require("../../../types");
  12745. var t = _interopRequireWildcard(_types);
  12746. var metadata = {
  12747. group: "builtin-setup"
  12748. };
  12749. exports.metadata = metadata;
  12750. function buildClone(bindingKey, refKey) {
  12751. return function (node) {
  12752. if (node[bindingKey] === node[refKey]) {
  12753. node[refKey] = t.removeComments((0, _lodashLangClone2["default"])(node[refKey]));
  12754. }
  12755. };
  12756. }
  12757. function buildListClone(listKey, bindingKey, refKey) {
  12758. var clone = buildClone(bindingKey, refKey);
  12759. return function (node) {
  12760. if (!node[listKey]) return;
  12761. var _arr = node[listKey];
  12762. for (var _i = 0; _i < _arr.length; _i++) {
  12763. var subNode = _arr[_i];
  12764. clone(subNode);
  12765. }
  12766. };
  12767. }
  12768. var Property = buildClone("value", "key");
  12769. exports.Property = Property;
  12770. var ExportDeclaration = buildListClone("specifiers", "local", "exported");
  12771. exports.ExportDeclaration = ExportDeclaration;
  12772. var ImportDeclaration = buildListClone("specifiers", "local", "imported");
  12773. exports.ImportDeclaration = ImportDeclaration;
  12774. },{"../../../types":169,"lodash/lang/clone":402}],125:[function(require,module,exports){
  12775. "use strict";
  12776. exports.__esModule = true;
  12777. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12778. var _types = require("../../../types");
  12779. var t = _interopRequireWildcard(_types);
  12780. var metadata = {
  12781. group: "builtin-setup"
  12782. };
  12783. exports.metadata = metadata;
  12784. var BlockStatement = {
  12785. exit: function exit(node) {
  12786. for (var i = 0; i < node.body.length; i++) {
  12787. var bodyNode = node.body[i];
  12788. if (t.isExpressionStatement(bodyNode) && t.isLiteral(bodyNode.expression)) {
  12789. bodyNode._blockHoist = Infinity;
  12790. } else {
  12791. return;
  12792. }
  12793. }
  12794. }
  12795. };
  12796. exports.BlockStatement = BlockStatement;
  12797. exports.Program = BlockStatement;
  12798. },{"../../../types":169}],126:[function(require,module,exports){
  12799. "use strict";
  12800. exports.__esModule = true;
  12801. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12802. var _helpersStrict = require("../../helpers/strict");
  12803. var strict = _interopRequireWildcard(_helpersStrict);
  12804. var metadata = {
  12805. group: "builtin-modules"
  12806. };
  12807. exports.metadata = metadata;
  12808. var Program = {
  12809. exit: function exit(program, parent, scope, file) {
  12810. strict.wrap(program, function () {
  12811. // ensure that these are at the top, just like normal imports
  12812. var _arr = file.dynamicImports;
  12813. for (var _i = 0; _i < _arr.length; _i++) {
  12814. var node = _arr[_i];
  12815. node._blockHoist = 3;
  12816. }
  12817. program.body = file.dynamicImports.concat(program.body);
  12818. });
  12819. if (!file.transformers["es6.modules"].canTransform()) return;
  12820. if (file.moduleFormatter.transform) {
  12821. file.moduleFormatter.transform(program);
  12822. }
  12823. }
  12824. };
  12825. exports.Program = Program;
  12826. },{"../../helpers/strict":70}],127:[function(require,module,exports){
  12827. // in this transformer we have to split up classes and function declarations
  12828. // from their exports. why? because sometimes we need to replace classes with
  12829. // nodes that aren't allowed in the same contexts. also, if you're exporting
  12830. // a generator function as a default then regenerator will destroy the export
  12831. // declaration and leave a variable declaration in it's place... yeah, handy.
  12832. "use strict";
  12833. exports.__esModule = true;
  12834. exports.ImportDeclaration = ImportDeclaration;
  12835. exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
  12836. exports.ExportNamedDeclaration = ExportNamedDeclaration;
  12837. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12838. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12839. var _lodashLangClone = require("lodash/lang/clone");
  12840. var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
  12841. var _types = require("../../../types");
  12842. var t = _interopRequireWildcard(_types);
  12843. var metadata = {
  12844. group: "builtin-setup"
  12845. };
  12846. exports.metadata = metadata;
  12847. function ImportDeclaration(node, parent, scope, file) {
  12848. if (node.source) {
  12849. node.source.value = file.resolveModuleSource(node.source.value);
  12850. }
  12851. }
  12852. exports.ExportAllDeclaration = ImportDeclaration;
  12853. function ExportDefaultDeclaration(node, parent, scope) {
  12854. ImportDeclaration.apply(this, arguments);
  12855. var declar = node.declaration;
  12856. var getDeclar = function getDeclar() {
  12857. declar._ignoreUserWhitespace = true;
  12858. return declar;
  12859. };
  12860. if (t.isClassDeclaration(declar)) {
  12861. // export default class Foo {};
  12862. node.declaration = declar.id;
  12863. return [getDeclar(), node];
  12864. } else if (t.isClassExpression(declar)) {
  12865. // export default class {};
  12866. var temp = scope.generateUidIdentifier("default");
  12867. declar = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
  12868. node.declaration = temp;
  12869. return [getDeclar(), node];
  12870. } else if (t.isFunctionDeclaration(declar)) {
  12871. // export default function Foo() {}
  12872. node._blockHoist = 2;
  12873. node.declaration = declar.id;
  12874. return [getDeclar(), node];
  12875. }
  12876. }
  12877. function buildExportSpecifier(id) {
  12878. return t.exportSpecifier((0, _lodashLangClone2["default"])(id), (0, _lodashLangClone2["default"])(id));
  12879. }
  12880. function ExportNamedDeclaration(node, parent, scope) {
  12881. ImportDeclaration.apply(this, arguments);
  12882. var declar = node.declaration;
  12883. var getDeclar = function getDeclar() {
  12884. declar._ignoreUserWhitespace = true;
  12885. return declar;
  12886. };
  12887. if (t.isClassDeclaration(declar)) {
  12888. // export class Foo {}
  12889. node.specifiers = [buildExportSpecifier(declar.id)];
  12890. node.declaration = null;
  12891. return [getDeclar(), node];
  12892. } else if (t.isFunctionDeclaration(declar)) {
  12893. // export function Foo() {}
  12894. node.specifiers = [buildExportSpecifier(declar.id)];
  12895. node.declaration = null;
  12896. node._blockHoist = 2;
  12897. return [getDeclar(), node];
  12898. } else if (t.isVariableDeclaration(declar)) {
  12899. // export var foo = "bar";
  12900. var specifiers = [];
  12901. var bindings = this.get("declaration").getBindingIdentifiers();
  12902. for (var key in bindings) {
  12903. specifiers.push(buildExportSpecifier(bindings[key]));
  12904. }
  12905. return [declar, t.exportNamedDeclaration(null, specifiers)];
  12906. }
  12907. }
  12908. var Program = {
  12909. enter: function enter(node) {
  12910. var imports = [];
  12911. var rest = [];
  12912. for (var i = 0; i < node.body.length; i++) {
  12913. var bodyNode = node.body[i];
  12914. if (t.isImportDeclaration(bodyNode)) {
  12915. imports.push(bodyNode);
  12916. } else {
  12917. rest.push(bodyNode);
  12918. }
  12919. }
  12920. node.body = imports.concat(rest);
  12921. },
  12922. exit: function exit(node, parent, scope, file) {
  12923. if (!file.transformers["es6.modules"].canTransform()) return;
  12924. if (file.moduleFormatter.setup) {
  12925. file.moduleFormatter.setup();
  12926. }
  12927. }
  12928. };
  12929. exports.Program = Program;
  12930. },{"../../../types":169,"lodash/lang/clone":402}],128:[function(require,module,exports){
  12931. "use strict";
  12932. exports.__esModule = true;
  12933. exports.ThisExpression = ThisExpression;
  12934. exports.ReferencedIdentifier = ReferencedIdentifier;
  12935. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12936. var _types = require("../../../types");
  12937. var t = _interopRequireWildcard(_types);
  12938. var metadata = {
  12939. group: "builtin-trailing"
  12940. };
  12941. exports.metadata = metadata;
  12942. function remap(path, key, create) {
  12943. // ensure that we're shadowed
  12944. if (!path.inShadow()) return;
  12945. var fnPath = path.findParent(function (node, path) {
  12946. return !node.shadow && (path.isFunction() || path.isProgram());
  12947. });
  12948. var cached = fnPath.getData(key);
  12949. if (cached) return cached;
  12950. var init = create();
  12951. var id = path.scope.generateUidIdentifier(key);
  12952. fnPath.setData(key, id);
  12953. fnPath.scope.push({ id: id, init: init });
  12954. return id;
  12955. }
  12956. function ThisExpression() {
  12957. return remap(this, "this", function () {
  12958. return t.thisExpression();
  12959. });
  12960. }
  12961. function ReferencedIdentifier(node) {
  12962. if (node.name === "arguments" && !node._shadowedFunctionLiteral) {
  12963. return remap(this, "arguments", function () {
  12964. return t.identifier("arguments");
  12965. });
  12966. }
  12967. }
  12968. },{"../../../types":169}],129:[function(require,module,exports){
  12969. "use strict";
  12970. exports.__esModule = true;
  12971. exports.ForOfStatement = ForOfStatement;
  12972. exports.MethodDefinition = MethodDefinition;
  12973. exports.Property = Property;
  12974. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  12975. var _messages = require("../../../messages");
  12976. var messages = _interopRequireWildcard(_messages);
  12977. var _types = require("../../../types");
  12978. var t = _interopRequireWildcard(_types);
  12979. var metadata = {
  12980. group: "builtin-setup"
  12981. };
  12982. exports.metadata = metadata;
  12983. function ForOfStatement(node, parent, scope, file) {
  12984. var left = node.left;
  12985. if (t.isVariableDeclaration(left)) {
  12986. var declar = left.declarations[0];
  12987. if (declar.init) throw file.errorWithNode(declar, messages.get("noAssignmentsInForHead"));
  12988. }
  12989. }
  12990. exports.ForInStatement = ForOfStatement;
  12991. function MethodDefinition(node) {
  12992. if (node.kind !== "constructor") {
  12993. // get constructor() {}
  12994. var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
  12995. // get ["constructor"]() {}
  12996. isConstructor = isConstructor || t.isLiteral(node.key, { value: "constructor" });
  12997. if (isConstructor) {
  12998. throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
  12999. }
  13000. }
  13001. Property.apply(this, arguments);
  13002. }
  13003. function Property(node, parent, scope, file) {
  13004. if (node.kind === "set") {
  13005. if (node.value.params.length !== 1) {
  13006. throw file.errorWithNode(node.value, messages.get("settersInvalidParamLength"));
  13007. }
  13008. var first = node.value.params[0];
  13009. if (t.isRestElement(first)) {
  13010. throw file.errorWithNode(first, messages.get("settersNoRest"));
  13011. }
  13012. }
  13013. }
  13014. },{"../../../messages":47,"../../../types":169}],130:[function(require,module,exports){
  13015. "use strict";
  13016. exports.__esModule = true;
  13017. exports.ReferencedIdentifier = ReferencedIdentifier;
  13018. exports.FunctionDeclaration = FunctionDeclaration;
  13019. exports.VariableDeclarator = VariableDeclarator;
  13020. exports.ConditionalExpression = ConditionalExpression;
  13021. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13022. var _types = require("../../../types");
  13023. var t = _interopRequireWildcard(_types);
  13024. function toStatements(node) {
  13025. if (t.isBlockStatement(node)) {
  13026. var hasBlockScoped = false;
  13027. for (var i = 0; i < node.body.length; i++) {
  13028. var bodyNode = node.body[i];
  13029. if (t.isBlockScoped(bodyNode)) hasBlockScoped = true;
  13030. }
  13031. if (!hasBlockScoped) {
  13032. return node.body;
  13033. }
  13034. }
  13035. return node;
  13036. }
  13037. var metadata = {
  13038. optional: true,
  13039. group: "builtin-setup"
  13040. };
  13041. exports.metadata = metadata;
  13042. function ReferencedIdentifier(node, parent, scope) {
  13043. var binding = scope.getBinding(node.name);
  13044. if (!binding || binding.references > 1 || !binding.constant) return;
  13045. if (binding.kind === "param" || binding.kind === "module") return;
  13046. var replacement = binding.path.node;
  13047. if (t.isVariableDeclarator(replacement)) {
  13048. replacement = replacement.init;
  13049. }
  13050. if (!replacement) return;
  13051. if (this.findParent(function (node) {
  13052. return replacement;
  13053. })) {
  13054. return;
  13055. }
  13056. t.toExpression(replacement);
  13057. scope.removeBinding(node.name);
  13058. binding.path.remove();
  13059. return replacement;
  13060. }
  13061. function FunctionDeclaration(node, parent, scope) {
  13062. var bindingInfo = scope.getBinding(node.id.name);
  13063. if (bindingInfo && !bindingInfo.referenced) {
  13064. this.remove();
  13065. }
  13066. }
  13067. exports.ClassDeclaration = FunctionDeclaration;
  13068. function VariableDeclarator(node, parent, scope) {
  13069. if (!t.isIdentifier(node.id) || !scope.isPure(node.init)) return;
  13070. FunctionDeclaration.apply(this, arguments);
  13071. }
  13072. function ConditionalExpression(node, parent, scope) {
  13073. var evaluateTest = this.get("test").evaluateTruthy();
  13074. if (evaluateTest === true) {
  13075. return node.consequent;
  13076. } else if (evaluateTest === false) {
  13077. return node.alternate;
  13078. }
  13079. }
  13080. var IfStatement = {
  13081. exit: function exit(node, parent, scope) {
  13082. var consequent = node.consequent;
  13083. var alternate = node.alternate;
  13084. var test = node.test;
  13085. var evaluateTest = this.get("test").evaluateTruthy();
  13086. // we can check if a test will be truthy 100% and if so then we can inline
  13087. // the consequent and completely ignore the alternate
  13088. //
  13089. // if (true) { foo; } -> { foo; }
  13090. // if ("foo") { foo; } -> { foo; }
  13091. //
  13092. if (evaluateTest === true) {
  13093. return toStatements(consequent);
  13094. }
  13095. // we can check if a test will be falsy 100% and if so we can inline the
  13096. // alternate if there is one and completely remove the consequent
  13097. //
  13098. // if ("") { bar; } else { foo; } -> { foo; }
  13099. // if ("") { bar; } ->
  13100. //
  13101. if (evaluateTest === false) {
  13102. if (alternate) {
  13103. return toStatements(alternate);
  13104. } else {
  13105. return this.remove();
  13106. }
  13107. }
  13108. // remove alternate blocks that are empty
  13109. //
  13110. // if (foo) { foo; } else {} -> if (foo) { foo; }
  13111. //
  13112. if (t.isBlockStatement(alternate) && !alternate.body.length) {
  13113. alternate = node.alternate = null;
  13114. }
  13115. // if the consequent block is empty turn alternate blocks into a consequent
  13116. // and flip the test
  13117. //
  13118. // if (foo) {} else { bar; } -> if (!foo) { bar; }
  13119. //
  13120. if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
  13121. node.consequent = node.alternate;
  13122. node.alternate = null;
  13123. node.test = t.unaryExpression("!", test, true);
  13124. }
  13125. }
  13126. };
  13127. exports.IfStatement = IfStatement;
  13128. },{"../../../types":169}],131:[function(require,module,exports){
  13129. "use strict";
  13130. exports.__esModule = true;
  13131. exports.Identifier = Identifier;
  13132. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13133. var _types = require("../../../types");
  13134. var t = _interopRequireWildcard(_types);
  13135. var metadata = {
  13136. optional: true,
  13137. group: "builtin-setup"
  13138. };
  13139. exports.metadata = metadata;
  13140. var Expression = {
  13141. exit: function exit(node, parent, scope) {
  13142. var res = this.evaluate();
  13143. if (res.confident) return t.valueToNode(res.value);
  13144. }
  13145. };
  13146. exports.Expression = Expression;
  13147. function Identifier() {}
  13148. // override Expression
  13149. },{"../../../types":169}],132:[function(require,module,exports){
  13150. "use strict";
  13151. exports.__esModule = true;
  13152. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13153. var _types = require("../../../types");
  13154. var t = _interopRequireWildcard(_types);
  13155. var metadata = {
  13156. optional: true,
  13157. group: "builtin-trailing"
  13158. };
  13159. exports.metadata = metadata;
  13160. var MemberExpression = {
  13161. exit: function exit(node) {
  13162. var prop = node.property;
  13163. if (node.computed && t.isLiteral(prop) && t.isValidIdentifier(prop.value)) {
  13164. // foo["bar"] => foo.bar
  13165. node.property = t.identifier(prop.value);
  13166. node.computed = false;
  13167. }
  13168. }
  13169. };
  13170. exports.MemberExpression = MemberExpression;
  13171. },{"../../../types":169}],133:[function(require,module,exports){
  13172. "use strict";
  13173. exports.__esModule = true;
  13174. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13175. var _types = require("../../../types");
  13176. var t = _interopRequireWildcard(_types);
  13177. var metadata = {
  13178. optional: true,
  13179. group: "builtin-trailing"
  13180. };
  13181. exports.metadata = metadata;
  13182. var Property = {
  13183. exit: function exit(node) {
  13184. var key = node.key;
  13185. if (t.isLiteral(key) && t.isValidIdentifier(key.value)) {
  13186. // "foo": "bar" -> foo: "bar"
  13187. node.key = t.identifier(key.value);
  13188. node.computed = false;
  13189. }
  13190. }
  13191. };
  13192. exports.Property = Property;
  13193. },{"../../../types":169}],134:[function(require,module,exports){
  13194. "use strict";
  13195. exports.__esModule = true;
  13196. exports.CallExpression = CallExpression;
  13197. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13198. var _types = require("../../../types");
  13199. var t = _interopRequireWildcard(_types);
  13200. var metadata = {
  13201. optional: true,
  13202. group: "builtin-setup"
  13203. };
  13204. exports.metadata = metadata;
  13205. function CallExpression(node, parent) {
  13206. if (this.get("callee").matchesPattern("console", true)) {
  13207. if (t.isExpressionStatement(parent)) {
  13208. this.parentPath.remove();
  13209. } else {
  13210. this.remove();
  13211. }
  13212. }
  13213. }
  13214. },{"../../../types":169}],135:[function(require,module,exports){
  13215. "use strict";
  13216. exports.__esModule = true;
  13217. exports.ExpressionStatement = ExpressionStatement;
  13218. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13219. var _types = require("../../../types");
  13220. var t = _interopRequireWildcard(_types);
  13221. var metadata = {
  13222. optional: true,
  13223. group: "builtin-setup"
  13224. };
  13225. exports.metadata = metadata;
  13226. function ExpressionStatement(node) {
  13227. if (this.get("expression").isIdentifier({ name: "debugger" })) {
  13228. this.remove();
  13229. }
  13230. }
  13231. },{"../../../types":169}],136:[function(require,module,exports){
  13232. "use strict";
  13233. exports.__esModule = true;
  13234. exports.ForOfStatement = ForOfStatement;
  13235. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13236. var _es6ForOf = require("../es6/for-of");
  13237. var _types = require("../../../types");
  13238. var t = _interopRequireWildcard(_types);
  13239. var metadata = {
  13240. optional: true
  13241. };
  13242. exports.metadata = metadata;
  13243. function ForOfStatement(node, parent, scope, file) {
  13244. if (this.get("right").isTypeGeneric("Array")) {
  13245. return _es6ForOf._ForOfStatementArray.call(this, node, scope, file);
  13246. }
  13247. }
  13248. },{"../../../types":169,"../es6/for-of":96}],137:[function(require,module,exports){
  13249. "use strict";
  13250. exports.__esModule = true;
  13251. exports.JSXElement = JSXElement;
  13252. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13253. var _helpersReact = require("../../helpers/react");
  13254. var react = _interopRequireWildcard(_helpersReact);
  13255. var metadata = {
  13256. optional: true
  13257. };
  13258. exports.metadata = metadata;
  13259. var immutabilityVisitor = {
  13260. enter: function enter(node, parent, scope, state) {
  13261. var _this = this;
  13262. var stop = function stop() {
  13263. state.isImmutable = false;
  13264. _this.stop();
  13265. };
  13266. if (this.isJSXClosingElement()) {
  13267. this.skip();
  13268. return;
  13269. }
  13270. if (this.isJSXIdentifier({ name: "ref" }) && this.parentPath.isJSXAttribute({ name: node })) {
  13271. return stop();
  13272. }
  13273. if (this.isJSXIdentifier() || this.isIdentifier() || this.isJSXMemberExpression()) {
  13274. return;
  13275. }
  13276. if (!this.isImmutable()) stop();
  13277. }
  13278. };
  13279. function JSXElement(node, parent, scope, file) {
  13280. if (node._hoisted) return;
  13281. var state = { isImmutable: true };
  13282. this.traverse(immutabilityVisitor, state);
  13283. if (state.isImmutable) {
  13284. this.hoist();
  13285. } else {
  13286. node._hoisted = true;
  13287. }
  13288. }
  13289. },{"../../helpers/react":66}],138:[function(require,module,exports){
  13290. "use strict";
  13291. exports.__esModule = true;
  13292. exports.JSXElement = JSXElement;
  13293. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13294. var _helpersReact = require("../../helpers/react");
  13295. var react = _interopRequireWildcard(_helpersReact);
  13296. var _types = require("../../../types");
  13297. var t = _interopRequireWildcard(_types);
  13298. var metadata = {
  13299. optional: true
  13300. };
  13301. exports.metadata = metadata;
  13302. function hasRefOrSpread(attrs) {
  13303. for (var i = 0; i < attrs.length; i++) {
  13304. var attr = attrs[i];
  13305. if (t.isJSXSpreadAttribute(attr)) return true;
  13306. if (isJSXAttributeOfName(attr, "ref")) return true;
  13307. }
  13308. return false;
  13309. }
  13310. function isJSXAttributeOfName(attr, name) {
  13311. return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: name });
  13312. }
  13313. function JSXElement(node, parent, scope, file) {
  13314. // filter
  13315. var open = node.openingElement;
  13316. if (hasRefOrSpread(open.attributes)) return;
  13317. // init
  13318. var isComponent = true;
  13319. var props = t.objectExpression([]);
  13320. var obj = t.objectExpression([]);
  13321. var key = t.literal(null);
  13322. var type = open.name;
  13323. if (t.isJSXIdentifier(type) && react.isCompatTag(type.name)) {
  13324. type = t.literal(type.name);
  13325. isComponent = false;
  13326. }
  13327. function pushElemProp(key, value) {
  13328. pushProp(obj.properties, t.identifier(key), value);
  13329. }
  13330. function pushProp(objProps, key, value) {
  13331. objProps.push(t.property("init", key, value));
  13332. }
  13333. // metadata
  13334. pushElemProp("type", type);
  13335. pushElemProp("ref", t.literal(null));
  13336. if (node.children.length) {
  13337. pushProp(props.properties, t.identifier("children"), t.arrayExpression(react.buildChildren(node)));
  13338. }
  13339. // props
  13340. for (var i = 0; i < open.attributes.length; i++) {
  13341. var attr = open.attributes[i];
  13342. if (isJSXAttributeOfName(attr, "key")) {
  13343. key = attr.value;
  13344. } else {
  13345. pushProp(props.properties, attr.name, attr.value || t.identifier("true"));
  13346. }
  13347. }
  13348. if (isComponent) {
  13349. props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
  13350. }
  13351. pushElemProp("props", props);
  13352. // key
  13353. pushElemProp("key", key);
  13354. return obj;
  13355. }
  13356. },{"../../../types":169,"../../helpers/react":66}],139:[function(require,module,exports){
  13357. "use strict";
  13358. exports.__esModule = true;
  13359. exports.Func /*tion*/ = Func;
  13360. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13361. var _helpersRemapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
  13362. var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
  13363. var _bluebirdCoroutines = require("./bluebird-coroutines");
  13364. exports.manipulateOptions = _bluebirdCoroutines.manipulateOptions;
  13365. var metadata = {
  13366. optional: true,
  13367. dependencies: ["es7.asyncFunctions", "es6.classes"]
  13368. };
  13369. exports.metadata = metadata;
  13370. function Func(node, parent, scope, file) {
  13371. if (!node.async || node.generator) return;
  13372. return (0, _helpersRemapAsyncToGenerator2["default"])(node, file.addHelper("async-to-generator"), scope);
  13373. }
  13374. },{"../../helpers/remap-async-to-generator":68,"./bluebird-coroutines":140}],140:[function(require,module,exports){
  13375. "use strict";
  13376. exports.__esModule = true;
  13377. exports.manipulateOptions = manipulateOptions;
  13378. exports.Func /*tion*/ = Func;
  13379. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13380. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13381. var _helpersRemapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
  13382. var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
  13383. var _types = require("../../../types");
  13384. var t = _interopRequireWildcard(_types);
  13385. function manipulateOptions(opts) {
  13386. opts.blacklist.push("regenerator");
  13387. }
  13388. var metadata = {
  13389. optional: true,
  13390. dependencies: ["es7.asyncFunctions", "es6.classes"]
  13391. };
  13392. exports.metadata = metadata;
  13393. function Func(node, parent, scope, file) {
  13394. if (!node.async || node.generator) return;
  13395. return (0, _helpersRemapAsyncToGenerator2["default"])(node, t.memberExpression(file.addImport("bluebird", null, "absolute"), t.identifier("coroutine")), scope);
  13396. }
  13397. },{"../../../types":169,"../../helpers/remap-async-to-generator":68}],141:[function(require,module,exports){
  13398. "use strict";
  13399. exports.__esModule = true;
  13400. exports.Flow = Flow;
  13401. exports.ClassProperty = ClassProperty;
  13402. exports.Class = Class;
  13403. exports.Func /*tion*/ = Func;
  13404. exports.TypeCastExpression = TypeCastExpression;
  13405. exports.ImportDeclaration = ImportDeclaration;
  13406. exports.ExportDeclaration = ExportDeclaration;
  13407. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13408. var _types = require("../../../types");
  13409. var t = _interopRequireWildcard(_types);
  13410. function Flow(node) {
  13411. this.remove();
  13412. }
  13413. function ClassProperty(node) {
  13414. node.typeAnnotation = null;
  13415. }
  13416. function Class(node) {
  13417. node["implements"] = null;
  13418. }
  13419. function Func(node) {
  13420. for (var i = 0; i < node.params.length; i++) {
  13421. var param = node.params[i];
  13422. param.optional = false;
  13423. }
  13424. }
  13425. function TypeCastExpression(node) {
  13426. return node.expression;
  13427. }
  13428. function ImportDeclaration(node) {
  13429. if (node.isType) this.remove();
  13430. }
  13431. function ExportDeclaration(node) {
  13432. if (this.get("declaration").isTypeAlias()) this.remove();
  13433. }
  13434. },{"../../../types":169}],142:[function(require,module,exports){
  13435. "use strict";
  13436. exports.__esModule = true;
  13437. exports.FunctionExpression = FunctionExpression;
  13438. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13439. var _types = require("../../../types");
  13440. var t = _interopRequireWildcard(_types);
  13441. var metadata = {
  13442. optional: true
  13443. };
  13444. exports.metadata = metadata;
  13445. function FunctionExpression(node, print) {
  13446. if (!node.id) return;
  13447. node._ignoreUserWhitespace = true;
  13448. return t.callExpression(t.functionExpression(null, [], t.blockStatement([t.toStatement(node), t.returnStatement(node.id)])), []);
  13449. }
  13450. },{"../../../types":169}],143:[function(require,module,exports){
  13451. "use strict";
  13452. exports.__esModule = true;
  13453. exports.manipulateOptions = manipulateOptions;
  13454. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13455. var _helpersReact = require("../../helpers/react");
  13456. var react = _interopRequireWildcard(_helpersReact);
  13457. var _types = require("../../../types");
  13458. var t = _interopRequireWildcard(_types);
  13459. function manipulateOptions(opts) {
  13460. opts.blacklist.push("react");
  13461. }
  13462. var metadata = {
  13463. optional: true,
  13464. group: "builtin-advanced"
  13465. };
  13466. exports.metadata = metadata;
  13467. require("../../helpers/build-react-transformer")(exports, {
  13468. pre: function pre(state) {
  13469. state.callee = state.tagExpr;
  13470. },
  13471. post: function post(state) {
  13472. if (react.isCompatTag(state.tagName)) {
  13473. state.call = t.callExpression(t.memberExpression(t.memberExpression(t.identifier("React"), t.identifier("DOM")), state.tagExpr, t.isLiteral(state.tagExpr)), state.args);
  13474. }
  13475. }
  13476. });
  13477. },{"../../../types":169,"../../helpers/build-react-transformer":59,"../../helpers/react":66}],144:[function(require,module,exports){
  13478. "use strict";
  13479. exports.__esModule = true;
  13480. exports.Program = Program;
  13481. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13482. var _helpersReact = require("../../helpers/react");
  13483. var react = _interopRequireWildcard(_helpersReact);
  13484. var _types = require("../../../types");
  13485. var t = _interopRequireWildcard(_types);
  13486. var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
  13487. var metadata = {
  13488. group: "builtin-advanced"
  13489. };
  13490. exports.metadata = metadata;
  13491. function Program(node, parent, scope, file) {
  13492. var id = file.opts.jsxPragma;
  13493. for (var i = 0; i < file.ast.comments.length; i++) {
  13494. var comment = file.ast.comments[i];
  13495. var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
  13496. if (matches) {
  13497. id = matches[1];
  13498. if (id === "React.DOM") {
  13499. throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
  13500. } else {
  13501. break;
  13502. }
  13503. }
  13504. }
  13505. file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
  13506. return t.memberExpression(object, property);
  13507. }));
  13508. }
  13509. require("../../helpers/build-react-transformer")(exports, {
  13510. pre: function pre(state) {
  13511. var tagName = state.tagName;
  13512. var args = state.args;
  13513. if (react.isCompatTag(tagName)) {
  13514. args.push(t.literal(tagName));
  13515. } else {
  13516. args.push(state.tagExpr);
  13517. }
  13518. },
  13519. post: function post(state, file) {
  13520. state.callee = file.get("jsxIdentifier");
  13521. }
  13522. });
  13523. },{"../../../types":169,"../../helpers/build-react-transformer":59,"../../helpers/react":66}],145:[function(require,module,exports){
  13524. "use strict";
  13525. exports.__esModule = true;
  13526. exports.Func /*tion*/ = Func;
  13527. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13528. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13529. var _regenerator = require("regenerator");
  13530. var _regenerator2 = _interopRequireDefault(_regenerator);
  13531. var _types = require("../../../types");
  13532. var t = _interopRequireWildcard(_types);
  13533. var _astTypes = require("ast-types");
  13534. var metadata = {
  13535. group: "regenerator"
  13536. };
  13537. exports.metadata = metadata;
  13538. function Func(node) {
  13539. if (node.async || node.generator) {
  13540. // Although this code transforms only the subtree rooted at the given
  13541. // Function node, that node might contain other generator functions
  13542. // that will also be transformed. It might help performance to ignore
  13543. // nested functions, and rely on the traversal to visit them later,
  13544. // but that's a small optimization. Starting here instead of at the
  13545. // root of the AST is the key optimization, since huge async/generator
  13546. // functions are relatively rare.
  13547. _regenerator2["default"].transform(convertTraversalPathToNodePath(this));
  13548. }
  13549. }
  13550. // Given a TraversalPath, return a NodePath that includes full ancestry
  13551. // information (up to and including the Program node). This is complicated
  13552. // by having to include intermediate objects like blockStatement.body
  13553. // arrays, in addition to Node objects.
  13554. function convertTraversalPathToNodePath(path) {
  13555. var programNode;
  13556. var keysAlongPath = [];
  13557. while (path) {
  13558. var pp = path.parentPath;
  13559. var parentNode = pp && pp.node;
  13560. if (parentNode) {
  13561. keysAlongPath.push(path.key);
  13562. if (parentNode !== path.container) {
  13563. var found = Object.keys(parentNode).some(function (containerKey) {
  13564. if (parentNode[containerKey] === path.container) {
  13565. keysAlongPath.push(containerKey);
  13566. return true;
  13567. }
  13568. });
  13569. if (!found) {
  13570. throw new Error("Failed to find container object in parent node");
  13571. }
  13572. }
  13573. if (t.isProgram(parentNode)) {
  13574. programNode = parentNode;
  13575. break;
  13576. }
  13577. }
  13578. path = pp;
  13579. }
  13580. if (!programNode) {
  13581. throw new Error("Failed to find root Program node");
  13582. }
  13583. var nodePath = new _astTypes.NodePath(programNode);
  13584. while (keysAlongPath.length > 0) {
  13585. nodePath = nodePath.get(keysAlongPath.pop());
  13586. }
  13587. return nodePath;
  13588. }
  13589. },{"../../../types":169,"ast-types":188,"regenerator":442}],146:[function(require,module,exports){
  13590. module.exports={
  13591. "builtins": {
  13592. "Symbol": "symbol",
  13593. "Promise": "promise",
  13594. "Map": "map",
  13595. "WeakMap": "weak-map",
  13596. "Set": "set",
  13597. "WeakSet": "weak-set"
  13598. },
  13599. "methods": {
  13600. "Array": {
  13601. "concat": "array/concat",
  13602. "copyWithin": "array/copy-within",
  13603. "entries": "array/entries",
  13604. "every": "array/every",
  13605. "fill": "array/fill",
  13606. "filter": "array/filter",
  13607. "findIndex": "array/find-index",
  13608. "find": "array/find",
  13609. "forEach": "array/for-each",
  13610. "from": "array/from",
  13611. "includes": "array/includes",
  13612. "indexOf": "array/index-of",
  13613. "join": "array/join",
  13614. "keys": "array/keys",
  13615. "lastIndexOf": "array/last-index-of",
  13616. "map": "array/map",
  13617. "of": "array/of",
  13618. "pop": "array/pop",
  13619. "push": "array/push",
  13620. "reduceRight": "array/reduce-right",
  13621. "reduce": "array/reduce",
  13622. "reverse": "array/reverse",
  13623. "shift": "array/shift",
  13624. "slice": "array/slice",
  13625. "some": "array/some",
  13626. "sort": "array/sort",
  13627. "splice": "array/splice",
  13628. "turn": "array/turn",
  13629. "unshift": "array/unshift",
  13630. "values": "array/values"
  13631. },
  13632. "Object": {
  13633. "assign": "object/assign",
  13634. "classof": "object/classof",
  13635. "create": "object/create",
  13636. "define": "object/define",
  13637. "defineProperties": "object/define-properties",
  13638. "defineProperty": "object/define-property",
  13639. "entries": "object/entries",
  13640. "freeze": "object/freeze",
  13641. "getOwnPropertyDescriptor": "object/get-own-property-descriptor",
  13642. "getOwnPropertyDescriptors": "object/get-own-property-descriptors",
  13643. "getOwnPropertyNames": "object/get-own-property-names",
  13644. "getOwnPropertySymbols": "object/get-own-property-symbols",
  13645. "getPrototypePf": "object/get-prototype-of",
  13646. "index": "object/index",
  13647. "isExtensible": "object/is-extensible",
  13648. "isFrozen": "object/is-frozen",
  13649. "isObject": "object/is-object",
  13650. "isSealed": "object/is-sealed",
  13651. "is": "object/is",
  13652. "keys": "object/keys",
  13653. "make": "object/make",
  13654. "preventExtensions": "object/prevent-extensions",
  13655. "seal": "object/seal",
  13656. "setPrototypeOf": "object/set-prototype-of",
  13657. "values": "object/values"
  13658. },
  13659. "RegExp": {
  13660. "escape": "regexp/escape"
  13661. },
  13662. "Function": {
  13663. "only": "function/only",
  13664. "part": "function/part"
  13665. },
  13666. "Math": {
  13667. "acosh": "math/acosh",
  13668. "asinh": "math/asinh",
  13669. "atanh": "math/atanh",
  13670. "cbrt": "math/cbrt",
  13671. "clz32": "math/clz32",
  13672. "cosh": "math/cosh",
  13673. "expm1": "math/expm1",
  13674. "fround": "math/fround",
  13675. "hypot": "math/hypot",
  13676. "pot": "math/pot",
  13677. "imul": "math/imul",
  13678. "log10": "math/log10",
  13679. "log1p": "math/log1p",
  13680. "log2": "math/log2",
  13681. "sign": "math/sign",
  13682. "sinh": "math/sinh",
  13683. "tanh": "math/tanh",
  13684. "trunc": "math/trunc"
  13685. },
  13686. "Date": {
  13687. "addLocale": "date/add-locale",
  13688. "formatUTC": "date/format-utc",
  13689. "format": "date/format"
  13690. },
  13691. "Symbol": {
  13692. "for": "symbol/for",
  13693. "hasInstance": "symbol/for-instance",
  13694. "is-concat-spreadable": "symbol/is-concat-spreadable",
  13695. "iterator": "symbol/iterator",
  13696. "keyFor": "symbol/key-for",
  13697. "match": "symbol/match",
  13698. "replace": "symbol/replace",
  13699. "search": "symbol/search",
  13700. "species": "symbol/species",
  13701. "split": "symbol/split",
  13702. "toPrimitive": "symbol/to-primitive",
  13703. "toStringTag": "symbol/to-string-tag",
  13704. "unscopables": "symbol/unscopables"
  13705. },
  13706. "String": {
  13707. "at": "string/at",
  13708. "codePointAt": "string/code-point-at",
  13709. "endsWith": "string/ends-with",
  13710. "escapeHTML": "string/escape-html",
  13711. "fromCodePoint": "string/from-code-point",
  13712. "includes": "string/includes",
  13713. "raw": "string/raw",
  13714. "repeat": "string/repeat",
  13715. "startsWith": "string/starts-with",
  13716. "unescapeHTML": "string/unescape-html"
  13717. },
  13718. "Number": {
  13719. "EPSILON": "number/epsilon",
  13720. "isFinite": "number/is-finite",
  13721. "isInteger": "number/is-integer",
  13722. "isNaN": "number/is-nan",
  13723. "isSafeInteger": "number/is-safe-integer",
  13724. "MAX_SAFE_INTEGER": "number/max-safe-integer",
  13725. "MIN_SAFE_INTEGER": "number/min-safe-integer",
  13726. "parseFloat": "number/parse-float",
  13727. "parseInt": "number/parse-int",
  13728. "random": "number/random"
  13729. },
  13730. "Reflect": {
  13731. "apply": "reflect/apply",
  13732. "construct": "reflect/construct",
  13733. "defineProperty": "reflect/define-property",
  13734. "deleteProperty": "reflect/delete-property",
  13735. "enumerate": "reflect/enumerate",
  13736. "getOwnPropertyDescriptor": "reflect/get-own-property-descriptor",
  13737. "getPrototypeOf": "reflect/get-prototype-of",
  13738. "get": "reflect/get",
  13739. "has": "reflect/has",
  13740. "isExtensible": "reflect/is-extensible",
  13741. "ownKeys": "reflect/own-keys",
  13742. "preventExtensions": "reflect/prevent-extensions",
  13743. "setPrototypeOf": "reflect/set-prototype-of",
  13744. "set": "reflect/set"
  13745. }
  13746. }
  13747. }
  13748. },{}],147:[function(require,module,exports){
  13749. "use strict";
  13750. exports.__esModule = true;
  13751. exports.pre = pre;
  13752. exports.ReferencedIdentifier = ReferencedIdentifier;
  13753. exports.CallExpression = CallExpression;
  13754. exports.BinaryExpression = BinaryExpression;
  13755. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13756. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13757. var _lodashCollectionIncludes = require("lodash/collection/includes");
  13758. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  13759. var _traversal = require("../../../../traversal");
  13760. var _traversal2 = _interopRequireDefault(_traversal);
  13761. var _util = require("../../../../util");
  13762. var util = _interopRequireWildcard(_util);
  13763. var _lodashObjectHas = require("lodash/object/has");
  13764. var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
  13765. var _types = require("../../../../types");
  13766. var t = _interopRequireWildcard(_types);
  13767. var _definitions = require("./definitions");
  13768. var _definitions2 = _interopRequireDefault(_definitions);
  13769. var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");
  13770. var RUNTIME_MODULE_NAME = "babel-runtime";
  13771. var metadata = {
  13772. optional: true,
  13773. group: "builtin-post-modules"
  13774. };
  13775. exports.metadata = metadata;
  13776. function pre(file) {
  13777. file.set("helperGenerator", function (name) {
  13778. return file.addImport("" + RUNTIME_MODULE_NAME + "/helpers/" + name, name, "absoluteDefault");
  13779. });
  13780. file.setDynamic("regeneratorIdentifier", function () {
  13781. return file.addImport("" + RUNTIME_MODULE_NAME + "/regenerator", "regeneratorRuntime", "absoluteDefault");
  13782. });
  13783. }
  13784. function ReferencedIdentifier(node, parent, scope, file) {
  13785. if (node.name === "regeneratorRuntime") {
  13786. return file.get("regeneratorIdentifier");
  13787. }
  13788. if (t.isMemberExpression(parent)) return;
  13789. if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].builtins, node.name)) return;
  13790. if (scope.getBindingIdentifier(node.name)) return;
  13791. // Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
  13792. var modulePath = _definitions2["default"].builtins[node.name];
  13793. return file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, node.name, "absoluteDefault");
  13794. }
  13795. function CallExpression(node, parent, scope, file) {
  13796. // arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
  13797. if (node.arguments.length) return;
  13798. var callee = node.callee;
  13799. if (!t.isMemberExpression(callee)) return;
  13800. if (!callee.computed) return;
  13801. if (!this.get("callee.property").matchesPattern("Symbol.iterator")) return;
  13802. return t.callExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/get-iterator", "getIterator", "absoluteDefault"), [callee.object]);
  13803. }
  13804. function BinaryExpression(node, parent, scope, file) {
  13805. // Symbol.iterator in arr -> core.$for.isIterable(arr)
  13806. if (node.operator !== "in") return;
  13807. if (!this.get("left").matchesPattern("Symbol.iterator")) return;
  13808. return t.callExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/is-iterable", "isIterable", "absoluteDefault"), [node.right]);
  13809. }
  13810. var MemberExpression = {
  13811. enter: function enter(node, parent, scope, file) {
  13812. // Array.from -> _core.Array.from
  13813. if (!this.isReferenced()) return;
  13814. var obj = node.object;
  13815. var prop = node.property;
  13816. if (!t.isReferenced(obj, node)) return;
  13817. if (node.computed) return;
  13818. if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].methods, obj.name)) return;
  13819. var methods = _definitions2["default"].methods[obj.name];
  13820. if (!(0, _lodashObjectHas2["default"])(methods, prop.name)) return;
  13821. if (scope.getBindingIdentifier(obj.name)) return;
  13822. var modulePath = methods[prop.name];
  13823. return file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, "" + obj.name + "$" + prop.name, "absoluteDefault");
  13824. },
  13825. exit: function exit(node, parent, scope, file) {
  13826. if (!this.isReferenced()) return;
  13827. var prop = node.property;
  13828. var obj = node.object;
  13829. if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].builtins, obj.name)) return;
  13830. if (scope.getBindingIdentifier(obj.name)) return;
  13831. var modulePath = _definitions2["default"].builtins[obj.name];
  13832. return t.memberExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, "" + obj.name, "absoluteDefault"), prop);
  13833. }
  13834. };
  13835. exports.MemberExpression = MemberExpression;
  13836. },{"../../../../traversal":157,"../../../../types":169,"../../../../util":173,"./definitions":146,"lodash/collection/includes":332,"lodash/object/has":420}],148:[function(require,module,exports){
  13837. "use strict";
  13838. exports.__esModule = true;
  13839. exports.ThisExpression = ThisExpression;
  13840. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13841. var _messages = require("../../../messages");
  13842. var messages = _interopRequireWildcard(_messages);
  13843. var _types = require("../../../types");
  13844. var t = _interopRequireWildcard(_types);
  13845. var metadata = {
  13846. group: "builtin-setup"
  13847. };
  13848. exports.metadata = metadata;
  13849. var THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassExpression", "ClassDeclaration"];
  13850. var Program = {
  13851. enter: function enter(program, parent, scope, file) {
  13852. var first = program.body[0];
  13853. var directive;
  13854. if (t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" })) {
  13855. directive = first;
  13856. } else {
  13857. directive = t.expressionStatement(t.literal("use strict"));
  13858. this.unshiftContainer("body", directive);
  13859. if (first) {
  13860. directive.leadingComments = first.leadingComments;
  13861. first.leadingComments = [];
  13862. }
  13863. }
  13864. directive._blockHoist = Infinity;
  13865. }
  13866. };
  13867. exports.Program = Program;
  13868. function ThisExpression() {
  13869. if (!this.findParent(function (node) {
  13870. return !node.shadow && THIS_BREAK_KEYS.indexOf(node.type) >= 0;
  13871. })) {
  13872. return t.identifier("undefined");
  13873. }
  13874. }
  13875. },{"../../../messages":47,"../../../types":169}],149:[function(require,module,exports){
  13876. "use strict";
  13877. exports.__esModule = true;
  13878. exports.BlockStatement = BlockStatement;
  13879. exports.SwitchCase = SwitchCase;
  13880. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13881. var _types = require("../../../types");
  13882. var t = _interopRequireWildcard(_types);
  13883. function statementList(key, path, file) {
  13884. var paths = path.get(key);
  13885. for (var i = 0; i < paths.length; i++) {
  13886. var path = paths[i];
  13887. var func = path.node;
  13888. if (!t.isFunctionDeclaration(func)) continue;
  13889. var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]);
  13890. // hoist it up above everything else
  13891. declar._blockHoist = 2;
  13892. // todo: name this
  13893. func.id = null;
  13894. path.replaceWith(declar);
  13895. }
  13896. }
  13897. function BlockStatement(node, parent, scope, file) {
  13898. if (t.isFunction(parent) && parent.body === node || t.isExportDeclaration(parent)) {
  13899. return;
  13900. }
  13901. statementList("body", this, file);
  13902. }
  13903. function SwitchCase(node, parent, scope, file) {
  13904. statementList("consequent", this, file);
  13905. }
  13906. },{"../../../types":169}],150:[function(require,module,exports){
  13907. "use strict";
  13908. exports.__esModule = true;
  13909. var _helpersNameMethod = require("../../helpers/name-method");
  13910. var metadata = {
  13911. group: "builtin-setup"
  13912. };
  13913. exports.metadata = metadata;
  13914. var FunctionExpression = {
  13915. exit: _helpersNameMethod.bare
  13916. };
  13917. exports.FunctionExpression = FunctionExpression;
  13918. exports.ArrowFunctionExpression = FunctionExpression;
  13919. },{"../../helpers/name-method":65}],151:[function(require,module,exports){
  13920. "use strict";
  13921. exports.__esModule = true;
  13922. exports.AssignmentExpression = AssignmentExpression;
  13923. exports.ExpressionStatement = ExpressionStatement;
  13924. exports.ObjectExpression = ObjectExpression;
  13925. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13926. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13927. var _types = require("../../../types");
  13928. var t = _interopRequireWildcard(_types);
  13929. var _lodashArrayPull = require("lodash/array/pull");
  13930. var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
  13931. function isProtoKey(node) {
  13932. return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" });
  13933. }
  13934. function isProtoAssignmentExpression(node) {
  13935. var left = node.left;
  13936. return t.isMemberExpression(left) && t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" });
  13937. }
  13938. function buildDefaultsCallExpression(expr, ref, file) {
  13939. return t.expressionStatement(t.callExpression(file.addHelper("defaults"), [ref, expr.right]));
  13940. }
  13941. var metadata = {
  13942. secondPass: true,
  13943. optional: true
  13944. };
  13945. exports.metadata = metadata;
  13946. function AssignmentExpression(node, parent, scope, file) {
  13947. if (!isProtoAssignmentExpression(node)) return;
  13948. var nodes = [];
  13949. var left = node.left.object;
  13950. var temp = scope.maybeGenerateMemoised(left);
  13951. nodes.push(t.expressionStatement(t.assignmentExpression("=", temp, left)));
  13952. nodes.push(buildDefaultsCallExpression(node, temp, file));
  13953. if (temp) nodes.push(temp);
  13954. return nodes;
  13955. }
  13956. function ExpressionStatement(node, parent, scope, file) {
  13957. var expr = node.expression;
  13958. if (!t.isAssignmentExpression(expr, { operator: "=" })) return;
  13959. if (isProtoAssignmentExpression(expr)) {
  13960. return buildDefaultsCallExpression(expr, expr.left.object, file);
  13961. }
  13962. }
  13963. function ObjectExpression(node, parent, scope, file) {
  13964. var proto;
  13965. for (var i = 0; i < node.properties.length; i++) {
  13966. var prop = node.properties[i];
  13967. if (isProtoKey(prop)) {
  13968. proto = prop.value;
  13969. (0, _lodashArrayPull2["default"])(node.properties, prop);
  13970. }
  13971. }
  13972. if (proto) {
  13973. var args = [t.objectExpression([]), proto];
  13974. if (node.properties.length) args.push(node);
  13975. return t.callExpression(file.addHelper("extends"), args);
  13976. }
  13977. }
  13978. },{"../../../types":169,"lodash/array/pull":327}],152:[function(require,module,exports){
  13979. "use strict";
  13980. exports.__esModule = true;
  13981. exports.Identifier = Identifier;
  13982. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  13983. var _types = require("../../../types");
  13984. var t = _interopRequireWildcard(_types);
  13985. var metadata = {
  13986. optional: true,
  13987. react: true
  13988. };
  13989. exports.metadata = metadata;
  13990. function Identifier(node, parent) {
  13991. if (node.name === "undefined" && this.isReferenced()) {
  13992. return t.unaryExpression("void", t.literal(0), true);
  13993. }
  13994. }
  13995. },{"../../../types":169}],153:[function(require,module,exports){
  13996. (function (process){
  13997. "use strict";
  13998. exports.__esModule = true;
  13999. exports.MemberExpression = MemberExpression;
  14000. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14001. var _types = require("../../../types");
  14002. var t = _interopRequireWildcard(_types);
  14003. var metadata = {
  14004. optional: true,
  14005. group: "builtin-setup"
  14006. };
  14007. exports.metadata = metadata;
  14008. var match = t.buildMatchMemberExpression("process.env");
  14009. function MemberExpression(node) {
  14010. if (match(node.object)) {
  14011. var key = this.toComputedKey();
  14012. if (t.isLiteral(key)) {
  14013. return t.valueToNode(process.env[key.value]);
  14014. }
  14015. }
  14016. }
  14017. }).call(this,require('_process'))
  14018. },{"../../../types":169,"_process":200}],154:[function(require,module,exports){
  14019. "use strict";
  14020. exports.__esModule = true;
  14021. exports.CallExpression = CallExpression;
  14022. exports.ModuleDeclaration = ModuleDeclaration;
  14023. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14024. var _messages = require("../../../messages");
  14025. var messages = _interopRequireWildcard(_messages);
  14026. var _types = require("../../../types");
  14027. var t = _interopRequireWildcard(_types);
  14028. // check if the input Literal `source` is an alternate casing of "react"
  14029. function check(source, file) {
  14030. if (t.isLiteral(source)) {
  14031. var name = source.value;
  14032. var lower = name.toLowerCase();
  14033. if (lower === "react" && name !== lower) {
  14034. throw file.errorWithNode(source, messages.get("didYouMean", "react"));
  14035. }
  14036. }
  14037. }
  14038. function CallExpression(node, parent, scope, file) {
  14039. if (this.get("callee").isIdentifier({ name: "require" }) && node.arguments.length === 1) {
  14040. check(node.arguments[0], file);
  14041. }
  14042. }
  14043. function ModuleDeclaration(node, parent, scope, file) {
  14044. check(node.source, file);
  14045. }
  14046. },{"../../../messages":47,"../../../types":169}],155:[function(require,module,exports){
  14047. "use strict";
  14048. exports.__esModule = true;
  14049. exports.Identifier = Identifier;
  14050. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14051. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14052. var _leven = require("leven");
  14053. var _leven2 = _interopRequireDefault(_leven);
  14054. var _messages = require("../../../messages");
  14055. var messages = _interopRequireWildcard(_messages);
  14056. var metadata = {
  14057. optional: true
  14058. };
  14059. exports.metadata = metadata;
  14060. function Identifier(node, parent, scope, file) {
  14061. if (!this.isReferenced()) return;
  14062. if (scope.hasBinding(node.name)) return;
  14063. // get the closest declaration to offer as a suggestion
  14064. // the variable name may have just been mistyped
  14065. var bindings = scope.getAllBindings();
  14066. var closest;
  14067. var shortest = -1;
  14068. for (var name in bindings) {
  14069. var distance = (0, _leven2["default"])(node.name, name);
  14070. if (distance <= 0 || distance > 3) continue;
  14071. if (distance <= shortest) continue;
  14072. closest = name;
  14073. shortest = distance;
  14074. }
  14075. var msg;
  14076. if (closest) {
  14077. msg = messages.get("undeclaredVariableSuggestion", node.name, closest);
  14078. } else {
  14079. msg = messages.get("undeclaredVariable", node.name);
  14080. }
  14081. //
  14082. throw file.errorWithNode(node, msg, ReferenceError);
  14083. }
  14084. },{"../../../messages":47,"leven":321}],156:[function(require,module,exports){
  14085. "use strict";
  14086. exports.__esModule = true;
  14087. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14088. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14089. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14090. var _path = require("./path");
  14091. var _path2 = _interopRequireDefault(_path);
  14092. var _lodashArrayCompact = require("lodash/array/compact");
  14093. var _lodashArrayCompact2 = _interopRequireDefault(_lodashArrayCompact);
  14094. var _types = require("../types");
  14095. var t = _interopRequireWildcard(_types);
  14096. var TraversalContext = (function () {
  14097. function TraversalContext(scope, opts, state, parentPath) {
  14098. _classCallCheck(this, TraversalContext);
  14099. this.parentPath = parentPath;
  14100. this.scope = scope;
  14101. this.state = state;
  14102. this.opts = opts;
  14103. }
  14104. TraversalContext.prototype.shouldVisit = function shouldVisit(node) {
  14105. var keys = t.VISITOR_KEYS[node.type];
  14106. return !!(this.opts.enter || this.opts.exit || this.opts[node.type] || keys && keys.length);
  14107. };
  14108. TraversalContext.prototype.create = function create(node, obj, key) {
  14109. var path = _path2["default"].get(this.parentPath, node, obj, key);
  14110. path.unshiftContext(this);
  14111. return path;
  14112. };
  14113. TraversalContext.prototype.visitMultiple = function visitMultiple(nodes, node, key) {
  14114. // nothing to traverse!
  14115. if (nodes.length === 0) return false;
  14116. var visited = [];
  14117. var queue = this.queue = [];
  14118. var stop = false;
  14119. // build up initial queue
  14120. for (var i = 0; i < nodes.length; i++) {
  14121. var self = nodes[i];
  14122. if (self && this.shouldVisit(self)) {
  14123. queue.push(this.create(node, nodes, i));
  14124. }
  14125. }
  14126. // visit the queue
  14127. var _arr = queue;
  14128. for (var _i = 0; _i < _arr.length; _i++) {
  14129. var path = _arr[_i];
  14130. path.update();
  14131. if (visited.indexOf(path.node) >= 0) continue;
  14132. visited.push(path.node);
  14133. if (path.visit()) {
  14134. stop = true;
  14135. break;
  14136. }
  14137. }
  14138. var _arr2 = queue;
  14139. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  14140. var path = _arr2[_i2];
  14141. path.shiftContext();
  14142. }
  14143. this.queue = null;
  14144. return stop;
  14145. };
  14146. TraversalContext.prototype.visitSingle = function visitSingle(node, key) {
  14147. if (this.shouldVisit(node[key])) {
  14148. var path = this.create(node, node, key);
  14149. path.visit();
  14150. path.shiftContext();
  14151. }
  14152. };
  14153. TraversalContext.prototype.visit = function visit(node, key) {
  14154. var nodes = node[key];
  14155. if (!nodes) return;
  14156. if (Array.isArray(nodes)) {
  14157. return this.visitMultiple(nodes, node, key);
  14158. } else {
  14159. return this.visitSingle(node, key);
  14160. }
  14161. };
  14162. return TraversalContext;
  14163. })();
  14164. exports["default"] = TraversalContext;
  14165. module.exports = exports["default"];
  14166. },{"../types":169,"./path":161,"lodash/array/compact":324}],157:[function(require,module,exports){
  14167. "use strict";
  14168. exports.__esModule = true;
  14169. exports["default"] = traverse;
  14170. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14172. var _context = require("./context");
  14173. var _context2 = _interopRequireDefault(_context);
  14174. var _visitors = require("./visitors");
  14175. var visitors = _interopRequireWildcard(_visitors);
  14176. var _messages = require("../messages");
  14177. var messages = _interopRequireWildcard(_messages);
  14178. var _lodashCollectionIncludes = require("lodash/collection/includes");
  14179. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  14180. var _types = require("../types");
  14181. var t = _interopRequireWildcard(_types);
  14182. function traverse(parent, opts, scope, state, parentPath) {
  14183. if (!parent) return;
  14184. if (!opts.noScope && !scope) {
  14185. if (parent.type !== "Program" && parent.type !== "File") {
  14186. throw new Error(messages.get("traverseNeedsParent", parent.type));
  14187. }
  14188. }
  14189. if (!opts) opts = {};
  14190. visitors.verify(opts);
  14191. visitors.explode(opts);
  14192. // array of nodes
  14193. if (Array.isArray(parent)) {
  14194. for (var i = 0; i < parent.length; i++) {
  14195. traverse.node(parent[i], opts, scope, state, parentPath);
  14196. }
  14197. } else {
  14198. traverse.node(parent, opts, scope, state, parentPath);
  14199. }
  14200. }
  14201. traverse.visitors = visitors;
  14202. traverse.verify = visitors.verify;
  14203. traverse.explode = visitors.explode;
  14204. traverse.node = function (node, opts, scope, state, parentPath) {
  14205. var keys = t.VISITOR_KEYS[node.type];
  14206. if (!keys) return;
  14207. var context = new _context2["default"](scope, opts, state, parentPath);
  14208. for (var i = 0; i < keys.length; i++) {
  14209. if (context.visit(node, keys[i])) {
  14210. return;
  14211. }
  14212. }
  14213. };
  14214. var CLEAR_KEYS = ["trailingComments", "leadingComments", "extendedRange", "_scopeInfo", "_paths", "tokens", "range", "start", "end", "loc", "raw"];
  14215. function clearNode(node) {
  14216. for (var i = 0; i < CLEAR_KEYS.length; i++) {
  14217. var key = CLEAR_KEYS[i];
  14218. if (node[key] != null) node[key] = null;
  14219. }
  14220. for (var key in node) {
  14221. var val = node[key];
  14222. if (Array.isArray(val)) {
  14223. delete val._paths;
  14224. }
  14225. }
  14226. }
  14227. var clearVisitor = {
  14228. noScope: true,
  14229. exit: clearNode
  14230. };
  14231. function clearComments(comments) {
  14232. for (var i = 0; i < comments.length; i++) {
  14233. clearNode(comments[i]);
  14234. }
  14235. }
  14236. traverse.removeProperties = function (tree) {
  14237. traverse(tree, clearVisitor);
  14238. clearNode(tree);
  14239. return tree;
  14240. };
  14241. function hasBlacklistedType(node, parent, scope, state) {
  14242. if (node.type === state.type) {
  14243. state.has = true;
  14244. this.skip();
  14245. }
  14246. }
  14247. traverse.hasType = function (tree, scope, type, blacklistTypes) {
  14248. // the node we're searching in is blacklisted
  14249. if ((0, _lodashCollectionIncludes2["default"])(blacklistTypes, tree.type)) return false;
  14250. // the type we're looking for is the same as the passed node
  14251. if (tree.type === type) return true;
  14252. var state = {
  14253. has: false,
  14254. type: type
  14255. };
  14256. traverse(tree, {
  14257. blacklist: blacklistTypes,
  14258. enter: hasBlacklistedType
  14259. }, scope, state);
  14260. return state.has;
  14261. };
  14262. module.exports = exports["default"];
  14263. },{"../messages":47,"../types":169,"./context":156,"./visitors":165,"lodash/collection/includes":332}],158:[function(require,module,exports){
  14264. "use strict";
  14265. exports.__esModule = true;
  14266. /**
  14267. * Description
  14268. */
  14269. exports.toComputedKey = toComputedKey;
  14270. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14271. var _types = require("../../types");
  14272. var t = _interopRequireWildcard(_types);
  14273. function toComputedKey() {
  14274. var node = this.node;
  14275. var key;
  14276. if (this.isMemberExpression()) {
  14277. key = node.property;
  14278. } else if (this.isProperty()) {
  14279. key = node.key;
  14280. } else {
  14281. throw new ReferenceError("todo");
  14282. }
  14283. if (!node.computed) {
  14284. if (t.isIdentifier(key)) key = t.literal(key.name);
  14285. }
  14286. return key;
  14287. }
  14288. },{"../../types":169}],159:[function(require,module,exports){
  14289. "use strict";
  14290. exports.__esModule = true;
  14291. /**
  14292. * Walk the input `node` and statically evaluate if it's truthy.
  14293. *
  14294. * Returning `true` when we're sure that the expression will evaluate to a
  14295. * truthy value, `false` if we're sure that it will evaluate to a falsy
  14296. * value and `undefined` if we aren't sure. Because of this please do not
  14297. * rely on coercion when using this method and check with === if it's false.
  14298. *
  14299. * For example do:
  14300. *
  14301. * if (t.evaluateTruthy(node) === false) falsyLogic();
  14302. *
  14303. * **AND NOT**
  14304. *
  14305. * if (!t.evaluateTruthy(node)) falsyLogic();
  14306. *
  14307. */
  14308. exports.evaluateTruthy = evaluateTruthy;
  14309. /**
  14310. * Walk the input `node` and statically evaluate it.
  14311. *
  14312. * Returns an object in the form `{ confident, value }`. `confident` indicates
  14313. * whether or not we had to drop out of evaluating the expression because of
  14314. * hitting an unknown node that we couldn't confidently find the value of.
  14315. *
  14316. * Example:
  14317. *
  14318. * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
  14319. * t.evaluate(parse("!true")) // { confident: true, value: false }
  14320. * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
  14321. *
  14322. */
  14323. exports.evaluate = evaluate;
  14324. function evaluateTruthy() {
  14325. var res = this.evaluate();
  14326. if (res.confident) return !!res.value;
  14327. }
  14328. function evaluate() {
  14329. var confident = true;
  14330. var value = evaluate(this);
  14331. if (!confident) value = undefined;
  14332. return {
  14333. confident: confident,
  14334. value: value
  14335. };
  14336. function evaluate(path) {
  14337. if (!confident) return;
  14338. var node = path.node;
  14339. if (path.isSequenceExpression()) {
  14340. var exprs = path.get("expressions");
  14341. return evaluate(exprs[exprs.length - 1]);
  14342. }
  14343. if (path.isLiteral()) {
  14344. if (node.regex) {} else {
  14345. return node.value;
  14346. }
  14347. }
  14348. if (path.isConditionalExpression()) {
  14349. if (evaluate(path.get("test"))) {
  14350. return evaluate(path.get("consequent"));
  14351. } else {
  14352. return evaluate(path.get("alternate"));
  14353. }
  14354. }
  14355. if (path.isIdentifier({ name: "undefined" })) {
  14356. return undefined;
  14357. }
  14358. if (path.isIdentifier() || path.isMemberExpression()) {
  14359. path = path.resolve();
  14360. if (path) {
  14361. return evaluate(path);
  14362. } else {
  14363. return confident = false;
  14364. }
  14365. }
  14366. if (path.isUnaryExpression({ prefix: true })) {
  14367. var arg = evaluate(path.get("argument"));
  14368. switch (node.operator) {
  14369. case "void":
  14370. return undefined;
  14371. case "!":
  14372. return !arg;
  14373. case "+":
  14374. return +arg;
  14375. case "-":
  14376. return -arg;
  14377. case "~":
  14378. return ~arg;
  14379. }
  14380. }
  14381. if (path.isArrayExpression() || path.isObjectExpression()) {}
  14382. if (path.isLogicalExpression()) {
  14383. var left = evaluate(path.get("left"));
  14384. var right = evaluate(path.get("right"));
  14385. switch (node.operator) {
  14386. case "||":
  14387. return left || right;
  14388. case "&&":
  14389. return left && right;
  14390. }
  14391. }
  14392. if (path.isBinaryExpression()) {
  14393. var left = evaluate(path.get("left"));
  14394. var right = evaluate(path.get("right"));
  14395. switch (node.operator) {
  14396. case "-":
  14397. return left - right;
  14398. case "+":
  14399. return left + right;
  14400. case "/":
  14401. return left / right;
  14402. case "*":
  14403. return left * right;
  14404. case "%":
  14405. return left % right;
  14406. case "**":
  14407. return Math.pow(left, right);
  14408. case "<":
  14409. return left < right;
  14410. case ">":
  14411. return left > right;
  14412. case "<=":
  14413. return left <= right;
  14414. case ">=":
  14415. return left >= right;
  14416. case "==":
  14417. return left == right;
  14418. case "!=":
  14419. return left != right;
  14420. case "===":
  14421. return left === right;
  14422. case "!==":
  14423. return left !== right;
  14424. }
  14425. }
  14426. confident = false;
  14427. }
  14428. }
  14429. // we have a regex and we can't represent it natively
  14430. // we could evaluate these but it's probably impractical and not very useful
  14431. },{}],160:[function(require,module,exports){
  14432. "use strict";
  14433. exports.__esModule = true;
  14434. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14435. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14436. var _transformationHelpersReact = require("../../transformation/helpers/react");
  14437. var react = _interopRequireWildcard(_transformationHelpersReact);
  14438. var _types = require("../../types");
  14439. var t = _interopRequireWildcard(_types);
  14440. var referenceVisitor = {
  14441. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  14442. if (this.isJSXIdentifier() && react.isCompatTag(node.name)) {
  14443. return;
  14444. }
  14445. // direct references that we need to track to hoist this to the highest scope we can
  14446. var bindingInfo = scope.getBinding(node.name);
  14447. if (!bindingInfo) return;
  14448. // this binding isn't accessible from the parent scope so we can safely ignore it
  14449. // eg. it's in a closure etc
  14450. if (bindingInfo !== state.scope.getBinding(node.name)) return;
  14451. if (bindingInfo.constant) {
  14452. state.bindings[node.name] = bindingInfo;
  14453. } else {
  14454. var _arr = bindingInfo.constantViolations;
  14455. for (var _i = 0; _i < _arr.length; _i++) {
  14456. var violationPath = _arr[_i];
  14457. state.breakOnScopePaths.push(violationPath.scope.path);
  14458. }
  14459. }
  14460. }
  14461. };
  14462. var PathHoister = (function () {
  14463. function PathHoister(path, scope) {
  14464. _classCallCheck(this, PathHoister);
  14465. this.breakOnScopePaths = [];
  14466. this.bindings = {};
  14467. this.scopes = [];
  14468. this.scope = scope;
  14469. this.path = path;
  14470. }
  14471. PathHoister.prototype.isCompatibleScope = function isCompatibleScope(scope) {
  14472. for (var key in this.bindings) {
  14473. var binding = this.bindings[key];
  14474. if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
  14475. return false;
  14476. }
  14477. }
  14478. return true;
  14479. };
  14480. PathHoister.prototype.getCompatibleScopes = function getCompatibleScopes() {
  14481. var scope = this.path.scope;
  14482. do {
  14483. if (this.isCompatibleScope(scope)) {
  14484. this.scopes.push(scope);
  14485. } else {
  14486. break;
  14487. }
  14488. if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
  14489. break;
  14490. }
  14491. } while (scope = scope.parent);
  14492. };
  14493. PathHoister.prototype.getAttachmentPath = function getAttachmentPath() {
  14494. var scopes = this.scopes;
  14495. var scope = scopes.pop();
  14496. if (!scope) return;
  14497. if (scope.path.isFunction()) {
  14498. if (this.hasOwnParamBindings(scope)) {
  14499. // should ignore this scope since it's ourselves
  14500. if (this.scope.is(scope)) return;
  14501. // needs to be attached to the body
  14502. return scope.path.get("body").get("body")[0];
  14503. } else {
  14504. // doesn't need to be be attached to this scope
  14505. return this.getNextScopeStatementParent();
  14506. }
  14507. } else if (scope.path.isProgram()) {
  14508. return this.getNextScopeStatementParent();
  14509. }
  14510. };
  14511. PathHoister.prototype.getNextScopeStatementParent = function getNextScopeStatementParent() {
  14512. var scope = this.scopes.pop();
  14513. if (scope) return scope.path.getStatementParent();
  14514. };
  14515. PathHoister.prototype.hasOwnParamBindings = function hasOwnParamBindings(scope) {
  14516. for (var name in this.bindings) {
  14517. if (!scope.hasOwnBinding(name)) continue;
  14518. var binding = this.bindings[name];
  14519. if (binding.kind === "param") return true;
  14520. }
  14521. return false;
  14522. };
  14523. PathHoister.prototype.run = function run() {
  14524. var node = this.path.node;
  14525. if (node._hoisted) return;
  14526. node._hoisted = true;
  14527. this.path.traverse(referenceVisitor, this);
  14528. this.getCompatibleScopes();
  14529. var path = this.getAttachmentPath();
  14530. if (!path) return;
  14531. var uid = path.scope.generateUidIdentifier("ref");
  14532. path.insertBefore([t.variableDeclaration("var", [t.variableDeclarator(uid, this.path.node)])]);
  14533. var parent = this.path.parentPath;
  14534. if (parent.isJSXElement() && this.path.container === parent.node.children) {
  14535. // turning the `span` in `<div><span /></div>` to an expression so we need to wrap it with
  14536. // an expression container
  14537. uid = t.jSXExpressionContainer(uid);
  14538. }
  14539. this.path.replaceWith(uid);
  14540. };
  14541. return PathHoister;
  14542. })();
  14543. exports["default"] = PathHoister;
  14544. module.exports = exports["default"];
  14545. },{"../../transformation/helpers/react":66,"../../types":169}],161:[function(require,module,exports){
  14546. "use strict";
  14547. exports.__esModule = true;
  14548. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  14549. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14550. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14551. var _hoister = require("./hoister");
  14552. var _hoister2 = _interopRequireDefault(_hoister);
  14553. var _virtualTypes = require("./virtual-types");
  14554. var virtualTypes = _interopRequireWildcard(_virtualTypes);
  14555. var _messages = require("../../messages");
  14556. var messages = _interopRequireWildcard(_messages);
  14557. var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
  14558. var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
  14559. var _lodashLangIsNumber = require("lodash/lang/isNumber");
  14560. var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
  14561. var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
  14562. var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
  14563. var _lodashLangIsString = require("lodash/lang/isString");
  14564. var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
  14565. var _helpersCodeFrame = require("../../helpers/code-frame");
  14566. var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
  14567. var _helpersParse = require("../../helpers/parse");
  14568. var _helpersParse2 = _interopRequireDefault(_helpersParse);
  14569. var _visitors = require("../visitors");
  14570. var _index = require("../index");
  14571. var _index2 = _interopRequireDefault(_index);
  14572. var _lodashCollectionIncludes = require("lodash/collection/includes");
  14573. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  14574. var _lodashObjectAssign = require("lodash/object/assign");
  14575. var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
  14576. var _lodashObjectExtend = require("lodash/object/extend");
  14577. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  14578. var _scope = require("../scope");
  14579. var _scope2 = _interopRequireDefault(_scope);
  14580. var _types = require("../../types");
  14581. var t = _interopRequireWildcard(_types);
  14582. var hoistVariablesVisitor = (0, _visitors.explode)({
  14583. Function: function Function() {
  14584. this.skip();
  14585. },
  14586. VariableDeclaration: function VariableDeclaration(node, parent, scope) {
  14587. if (node.kind !== "var") return;
  14588. var bindings = this.getBindingIdentifiers();
  14589. for (var key in bindings) {
  14590. scope.push({ id: bindings[key] });
  14591. }
  14592. var exprs = [];
  14593. var _arr = node.declarations;
  14594. for (var _i = 0; _i < _arr.length; _i++) {
  14595. var declar = _arr[_i];
  14596. var declar = node.declarations[i];
  14597. if (declar.init) {
  14598. exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
  14599. }
  14600. }
  14601. return exprs;
  14602. }
  14603. });
  14604. var TraversalPath = (function () {
  14605. function TraversalPath(parent, container) {
  14606. _classCallCheck(this, TraversalPath);
  14607. this.container = container;
  14608. this.contexts = [];
  14609. this.parent = parent;
  14610. this.data = {};
  14611. }
  14612. /**
  14613. * Description
  14614. */
  14615. TraversalPath.get = function get(parentPath, parent, container, key) {
  14616. var targetNode = container[key];
  14617. var paths = container._paths = container._paths || [];
  14618. var path;
  14619. for (var i = 0; i < paths.length; i++) {
  14620. var pathCheck = paths[i];
  14621. if (pathCheck.node === targetNode) {
  14622. path = pathCheck;
  14623. break;
  14624. }
  14625. }
  14626. if (!path) {
  14627. path = new TraversalPath(parent, container);
  14628. paths.push(path);
  14629. }
  14630. path.setup(parentPath, key);
  14631. return path;
  14632. };
  14633. /**
  14634. * Description
  14635. */
  14636. TraversalPath.getScope = function getScope(path, scope, file) {
  14637. var ourScope = scope;
  14638. // we're entering a new scope so let's construct it!
  14639. if (path.isScope()) {
  14640. ourScope = new _scope2["default"](path, scope, file);
  14641. }
  14642. return ourScope;
  14643. };
  14644. /**
  14645. * Description
  14646. */
  14647. TraversalPath.prototype.getAncestry = function getAncestry() {
  14648. var ancestry = [];
  14649. var path = this.parentPath;
  14650. while (path) {
  14651. ancestry.push(path.node);
  14652. path = path.parentPath;
  14653. }
  14654. return ancestry;
  14655. };
  14656. /**
  14657. * Description
  14658. */
  14659. TraversalPath.prototype.inType = function inType(types) {
  14660. if (!Array.isArray(types)) types = [types];
  14661. var path = this;
  14662. while (path) {
  14663. var _arr3 = types;
  14664. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  14665. var type = _arr3[_i3];
  14666. if (path.node.type === type) return true;
  14667. }
  14668. path = path.parentPath;
  14669. }
  14670. return false;
  14671. };
  14672. /**
  14673. * Description
  14674. */
  14675. TraversalPath.prototype.inShadow = function inShadow() {
  14676. var path = this;
  14677. while (path) {
  14678. if (path.isFunction()) {
  14679. if (path.node.shadow) {
  14680. return path;
  14681. } else {
  14682. return null;
  14683. }
  14684. }
  14685. path = path.parentPath;
  14686. }
  14687. return null;
  14688. };
  14689. /**
  14690. * Check whether this node was a part of the original AST.
  14691. */
  14692. TraversalPath.prototype.isUser = function isUser() {
  14693. return this.node && !!this.node.loc;
  14694. };
  14695. /**
  14696. * Check whether this node was generated by us and not a part of the original AST.
  14697. */
  14698. TraversalPath.prototype.isGenerated = function isGenerated() {
  14699. return !this.isUser();
  14700. };
  14701. /**
  14702. * Description
  14703. */
  14704. TraversalPath.prototype.findParent = function findParent(callback) {
  14705. var path = this;
  14706. while (path) {
  14707. if (callback(path.node, path)) return path;
  14708. path = path.parentPath;
  14709. }
  14710. return null;
  14711. };
  14712. /**
  14713. * Description
  14714. */
  14715. TraversalPath.prototype.queueNode = function queueNode(path) {
  14716. var _arr4 = this.contexts;
  14717. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  14718. var context = _arr4[_i4];
  14719. if (context.queue) {
  14720. context.queue.push(path);
  14721. }
  14722. }
  14723. };
  14724. /**
  14725. * Description
  14726. */
  14727. TraversalPath.prototype.insertBefore = function insertBefore(nodes) {
  14728. nodes = this._verifyNodeList(nodes);
  14729. if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
  14730. return this.parentPath.insertBefore(nodes);
  14731. } else if (this.isPreviousType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
  14732. if (this.node) nodes.push(this.node);
  14733. this.replaceExpressionWithStatements(nodes);
  14734. } else if (this.isPreviousType("Statement") || !this.type) {
  14735. this._maybePopFromStatements(nodes);
  14736. if (Array.isArray(this.container)) {
  14737. this._containerInsertBefore(nodes);
  14738. } else if (this.isStatementOrBlock()) {
  14739. if (this.node) nodes.push(this.node);
  14740. this.node = this.container[this.key] = t.blockStatement(nodes);
  14741. } else {
  14742. throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
  14743. }
  14744. } else {
  14745. throw new Error("No clue what to do with this node type.");
  14746. }
  14747. };
  14748. TraversalPath.prototype._containerInsert = function _containerInsert(from, nodes) {
  14749. this.updateSiblingKeys(from, nodes.length);
  14750. var paths = [];
  14751. for (var i = 0; i < nodes.length; i++) {
  14752. var to = from + i;
  14753. var node = nodes[i];
  14754. this.container.splice(to, 0, node);
  14755. if (this.context) {
  14756. var path = this.context.create(this.parent, this.container, to);
  14757. paths.push(path);
  14758. this.queueNode(path);
  14759. } else {
  14760. paths.push(TraversalPath.get(this, node, this.container, to));
  14761. }
  14762. }
  14763. return paths;
  14764. };
  14765. TraversalPath.prototype._containerInsertBefore = function _containerInsertBefore(nodes) {
  14766. return this._containerInsert(this.key, nodes);
  14767. };
  14768. TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
  14769. return this._containerInsert(this.key + 1, nodes);
  14770. };
  14771. TraversalPath.prototype._maybePopFromStatements = function _maybePopFromStatements(nodes) {
  14772. var last = nodes[nodes.length - 1];
  14773. if (t.isExpressionStatement(last) && t.isIdentifier(last.expression) && !this.isCompletionRecord()) {
  14774. nodes.pop();
  14775. }
  14776. };
  14777. /**
  14778. * Description
  14779. */
  14780. TraversalPath.prototype.isCompletionRecord = function isCompletionRecord() {
  14781. var path = this;
  14782. do {
  14783. var container = path.container;
  14784. if (Array.isArray(container) && path.key !== container.length - 1) {
  14785. return false;
  14786. }
  14787. } while (path = path.parentPath && !path.isProgram());
  14788. return true;
  14789. };
  14790. /**
  14791. * Description
  14792. */
  14793. TraversalPath.prototype.isStatementOrBlock = function isStatementOrBlock() {
  14794. if (t.isLabeledStatement(this.parent) || t.isBlockStatement(this.container)) {
  14795. return false;
  14796. } else {
  14797. return (0, _lodashCollectionIncludes2["default"])(t.STATEMENT_OR_BLOCK_KEYS, this.key);
  14798. }
  14799. };
  14800. /**
  14801. * Description
  14802. */
  14803. TraversalPath.prototype.insertAfter = function insertAfter(nodes) {
  14804. nodes = this._verifyNodeList(nodes);
  14805. if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
  14806. return this.parentPath.insertAfter(nodes);
  14807. } else if (this.isPreviousType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
  14808. if (this.node) {
  14809. var temp = this.scope.generateDeclaredUidIdentifier();
  14810. nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node)));
  14811. nodes.push(t.expressionStatement(temp));
  14812. }
  14813. this.replaceExpressionWithStatements(nodes);
  14814. } else if (this.isPreviousType("Statement") || !this.type) {
  14815. this._maybePopFromStatements(nodes);
  14816. if (Array.isArray(this.container)) {
  14817. this._containerInsertAfter(nodes);
  14818. } else if (this.isStatementOrBlock()) {
  14819. if (this.node) nodes.unshift(this.node);
  14820. this.node = this.container[this.key] = t.blockStatement(nodes);
  14821. } else {
  14822. throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
  14823. }
  14824. } else {
  14825. throw new Error("No clue what to do with this node type.");
  14826. }
  14827. };
  14828. /**
  14829. * Description
  14830. */
  14831. TraversalPath.prototype.updateSiblingKeys = function updateSiblingKeys(fromIndex, incrementBy) {
  14832. var paths = this.container._paths;
  14833. for (var i = 0; i < paths.length; i++) {
  14834. var path = paths[i];
  14835. if (path.key >= fromIndex) {
  14836. path.key += incrementBy;
  14837. }
  14838. }
  14839. };
  14840. /**
  14841. * Description
  14842. */
  14843. TraversalPath.prototype.setData = function setData(key, val) {
  14844. return this.data[key] = val;
  14845. };
  14846. /**
  14847. * Description
  14848. */
  14849. TraversalPath.prototype.getData = function getData(key, def) {
  14850. var val = this.data[key];
  14851. if (!val && def) val = this.data[key] = def;
  14852. return val;
  14853. };
  14854. /**
  14855. * Description
  14856. */
  14857. TraversalPath.prototype.setScope = function setScope(file) {
  14858. if (this.opts && this.opts.noScope) return;
  14859. var target = this.context || this.parentPath;
  14860. this.scope = TraversalPath.getScope(this, target && target.scope, file);
  14861. };
  14862. /**
  14863. * Description
  14864. */
  14865. TraversalPath.prototype.setContext = function setContext(context, file) {
  14866. this.shouldSkip = false;
  14867. this.shouldStop = false;
  14868. this.removed = false;
  14869. if (context) {
  14870. this.context = context;
  14871. this.state = context.state;
  14872. this.opts = context.opts;
  14873. }
  14874. var log = file && this.type === "Program";
  14875. if (log) file.log.debug("Start scope building");
  14876. this.setScope(file);
  14877. if (log) file.log.debug("End scope building");
  14878. return this;
  14879. };
  14880. /**
  14881. * Description
  14882. */
  14883. TraversalPath.prototype.update = function update() {
  14884. if (this.node === this.container[this.key]) return;
  14885. // grrr, path key is out of sync. this is likely due to a modification to the AST
  14886. // not through our path APIs
  14887. if (Array.isArray(this.container)) {
  14888. for (var i = 0; i < this.container.length; i++) {
  14889. if (this.container[i] === this.node) {
  14890. return this.setKey(i);
  14891. }
  14892. }
  14893. } else {
  14894. for (var key in this.container) {
  14895. if (this.container[key] === this.node) {
  14896. return this.setKey(key);
  14897. }
  14898. }
  14899. }
  14900. throw new Error(messages.get("lostTrackNodePath"));
  14901. };
  14902. /**
  14903. * Description
  14904. */
  14905. TraversalPath.prototype.shiftContext = function shiftContext() {
  14906. this.contexts.shift();
  14907. this.setContext(this.contexts[0]);
  14908. };
  14909. /**
  14910. * Description
  14911. */
  14912. TraversalPath.prototype.unshiftContext = function unshiftContext(context) {
  14913. this.contexts.unshift(context);
  14914. this.setContext(context);
  14915. };
  14916. /**
  14917. * Description
  14918. */
  14919. TraversalPath.prototype.setup = function setup(parentPath, key) {
  14920. this.parentPath = parentPath || this.parentPath;
  14921. this.setKey(key);
  14922. };
  14923. /**
  14924. * Description
  14925. */
  14926. TraversalPath.prototype.setKey = function setKey(key) {
  14927. this.key = key;
  14928. this.node = this.container[this.key];
  14929. this.type = this.node && this.node.type;
  14930. };
  14931. /**
  14932. * Share comments amongst siblings.
  14933. */
  14934. TraversalPath.prototype.shareCommentsWithSiblings = function shareCommentsWithSiblings() {
  14935. var node = this.node;
  14936. if (!node) return;
  14937. var trailing = node.trailingComments;
  14938. var leading = node.leadingComments;
  14939. if (!trailing && !leading) return;
  14940. var prev = this.getSibling(this.key - 1);
  14941. var next = this.getSibling(this.key + 1);
  14942. if (!prev.node) prev = next;
  14943. if (!next.node) next = prev;
  14944. prev.giveComments("trailing", leading);
  14945. next.giveComments("leading", trailing);
  14946. };
  14947. /**
  14948. * Give node `comments` of the specified `type`.
  14949. */
  14950. TraversalPath.prototype.giveComments = function giveComments(type, comments) {
  14951. if (!comments) return;
  14952. var node = this.node;
  14953. if (!node) return;
  14954. var key = "" + type + "Comments";
  14955. if (node[key]) {
  14956. node[key] = node[key].concat(comments);
  14957. } else {
  14958. node[key] = comments;
  14959. }
  14960. };
  14961. /**
  14962. * Description
  14963. */
  14964. TraversalPath.prototype.remove = function remove() {
  14965. this.shareCommentsWithSiblings();
  14966. this._remove();
  14967. this.removed = true;
  14968. var parentPath = this.parentPath;
  14969. var parent = this.parent;
  14970. if (!parentPath) return;
  14971. // we've just removed the last declarator of a variable declaration so there's no point in
  14972. // keeping it
  14973. if (parentPath.isVariableDeclaration() && parent.declarations.length === 0) {
  14974. return parentPath.remove();
  14975. }
  14976. // we're the child of an expression statement so we should remove the parent
  14977. if (parentPath.isExpressionStatement()) {
  14978. return parentPath.remove();
  14979. }
  14980. // we've just removed the second element of a sequence expression so let's turn that sequence
  14981. // expression into a regular expression
  14982. if (parentPath.isSequenceExpression() && parent.expressions.length === 1) {
  14983. parentPath.replaceWith(parent.expressions[0]);
  14984. }
  14985. // we're in a binary expression, better remove it and replace it with the last expression
  14986. if (parentPath.isBinary()) {
  14987. if (this.key === "left") {
  14988. parentPath.replaceWith(parent.right);
  14989. } else {
  14990. // key === "right"
  14991. parentPath.replaceWith(parent.left);
  14992. }
  14993. }
  14994. };
  14995. TraversalPath.prototype._remove = function _remove() {
  14996. if (Array.isArray(this.container)) {
  14997. this.container.splice(this.key, 1);
  14998. this.updateSiblingKeys(this.key, -1);
  14999. } else {
  15000. this.container[this.key] = null;
  15001. }
  15002. this.node = null;
  15003. };
  15004. /**
  15005. * Description
  15006. */
  15007. TraversalPath.prototype.skip = function skip() {
  15008. this.shouldSkip = true;
  15009. };
  15010. /**
  15011. * Description
  15012. */
  15013. TraversalPath.prototype.stop = function stop() {
  15014. this.shouldStop = true;
  15015. this.shouldSkip = true;
  15016. };
  15017. /**
  15018. * Description
  15019. */
  15020. TraversalPath.prototype.errorWithNode = function errorWithNode(msg) {
  15021. var Error = arguments[1] === undefined ? SyntaxError : arguments[1];
  15022. var loc = this.node.loc.start;
  15023. var err = new Error("Line " + loc.line + ": " + msg);
  15024. err.loc = loc;
  15025. return err;
  15026. };
  15027. /**
  15028. * Description
  15029. */
  15030. TraversalPath.prototype.replaceInline = function replaceInline(nodes) {
  15031. if (Array.isArray(nodes)) {
  15032. if (Array.isArray(this.container)) {
  15033. nodes = this._verifyNodeList(nodes);
  15034. this._containerInsertAfter(nodes);
  15035. return this.remove();
  15036. } else {
  15037. return this.replaceWithMultiple(nodes);
  15038. }
  15039. } else {
  15040. return this.replaceWith(nodes);
  15041. }
  15042. };
  15043. /**
  15044. * Description
  15045. */
  15046. TraversalPath.prototype._verifyNodeList = function _verifyNodeList(nodes) {
  15047. if (nodes.constructor !== Array) {
  15048. nodes = [nodes];
  15049. }
  15050. for (var i = 0; i < nodes.length; i++) {
  15051. var node = nodes[i];
  15052. if (!node) {
  15053. throw new Error("Node list has falsy node with the index of " + i);
  15054. } else if (typeof node !== "object") {
  15055. throw new Error("Node list contains a non-object node with the index of " + i);
  15056. } else if (!node.type) {
  15057. throw new Error("Node list contains a node without a type with the index of " + i);
  15058. }
  15059. }
  15060. return nodes;
  15061. };
  15062. /**
  15063. * Description
  15064. */
  15065. TraversalPath.prototype.unshiftContainer = function unshiftContainer(containerKey, nodes) {
  15066. nodes = this._verifyNodeList(nodes);
  15067. // get the first path and insert our nodes before it, if it doesn't exist then it
  15068. // doesn't matter, our nodes will be inserted anyway
  15069. var container = this.node[containerKey];
  15070. var path = TraversalPath.get(this, this.node, container, 0);
  15071. return path.insertBefore(nodes);
  15072. };
  15073. /**
  15074. * Description
  15075. */
  15076. TraversalPath.prototype.pushContainer = function pushContainer(containerKey, nodes) {
  15077. nodes = this._verifyNodeList(nodes);
  15078. // get an invisible path that represents the last node + 1 and replace it with our
  15079. // nodes, effectively inlining it
  15080. var container = this.node[containerKey];
  15081. var i = container.length;
  15082. var path = TraversalPath.get(this, this.node, container, i);
  15083. return path.replaceWith(nodes, true);
  15084. };
  15085. /**
  15086. * Description
  15087. */
  15088. TraversalPath.prototype.replaceWithMultiple = function replaceWithMultiple(nodes) {
  15089. nodes = this._verifyNodeList(nodes);
  15090. t.inheritsComments(nodes[0], this.node);
  15091. this.node = this.container[this.key] = null;
  15092. this.insertAfter(nodes);
  15093. if (!this.node) this.remove();
  15094. };
  15095. /**
  15096. * Description
  15097. */
  15098. TraversalPath.prototype.replaceWithSourceString = function replaceWithSourceString(replacement) {
  15099. try {
  15100. replacement = "(" + replacement + ")";
  15101. replacement = (0, _helpersParse2["default"])(replacement);
  15102. } catch (err) {
  15103. var loc = err.loc;
  15104. if (loc) {
  15105. err.message += " - make sure this is an expression.";
  15106. err.message += "\n" + (0, _helpersCodeFrame2["default"])(replacement, loc.line, loc.column + 1);
  15107. }
  15108. throw err;
  15109. }
  15110. replacement = replacement.program.body[0].expression;
  15111. _index2["default"].removeProperties(replacement);
  15112. return this.replaceWith(replacement);
  15113. };
  15114. /**
  15115. * Description
  15116. */
  15117. TraversalPath.prototype.replaceWith = function replaceWith(replacement, whateverAllowed) {
  15118. if (this.removed) {
  15119. throw new Error("You can't replace this node, we've already removed it");
  15120. }
  15121. if (!replacement) {
  15122. throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");
  15123. }
  15124. if (this.node === replacement) {
  15125. return;
  15126. }
  15127. // normalise inserting an entire AST
  15128. if (t.isProgram(replacement)) {
  15129. replacement = replacement.body;
  15130. whateverAllowed = true;
  15131. }
  15132. if (Array.isArray(replacement)) {
  15133. if (whateverAllowed) {
  15134. return this.replaceWithMultiple(replacement);
  15135. } else {
  15136. throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
  15137. }
  15138. }
  15139. if (typeof replacement === "string") {
  15140. if (whateverAllowed) {
  15141. return this.replaceWithSourceString(replacement);
  15142. } else {
  15143. throw new Error("Don't use `path.replaceWith()` with a string, use `path.replaceWithSourceString()`");
  15144. }
  15145. }
  15146. // replacing a statement with an expression so wrap it in an expression statement
  15147. if (this.isPreviousType("Statement") && t.isExpression(replacement)) {
  15148. replacement = t.expressionStatement(replacement);
  15149. }
  15150. // replacing an expression with a statement so let's explode it
  15151. if (this.isPreviousType("Expression") && t.isStatement(replacement)) {
  15152. return this.replaceExpressionWithStatements([replacement]);
  15153. }
  15154. var oldNode = this.node;
  15155. if (oldNode) t.inheritsComments(replacement, oldNode);
  15156. // replace the node
  15157. this.node = this.container[this.key] = replacement;
  15158. this.type = replacement.type;
  15159. // potentially create new scope
  15160. this.setScope();
  15161. };
  15162. /**
  15163. * Description
  15164. */
  15165. TraversalPath.prototype.getStatementParent = function getStatementParent() {
  15166. var path = this;
  15167. do {
  15168. if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
  15169. break;
  15170. } else {
  15171. path = path.parentPath;
  15172. }
  15173. } while (path);
  15174. if (path && (path.isProgram() || path.isFile())) {
  15175. throw new Error("File/Program node, we can't possibly find a statement parent to this");
  15176. }
  15177. return path;
  15178. };
  15179. /**
  15180. * Description
  15181. */
  15182. TraversalPath.prototype.getLastStatements = function getLastStatements() {
  15183. var paths = [];
  15184. var add = function add(path) {
  15185. if (path) paths = paths.concat(path.getLastStatements());
  15186. };
  15187. if (this.isIfStatement()) {
  15188. add(this.get("consequent"));
  15189. add(this.get("alternate"));
  15190. } else if (this.isDoExpression()) {
  15191. add(this.get("body"));
  15192. } else if (this.isProgram() || this.isBlockStatement()) {
  15193. add(this.get("body").pop());
  15194. } else {
  15195. paths.push(this);
  15196. }
  15197. return paths;
  15198. };
  15199. /**
  15200. * Description
  15201. */
  15202. TraversalPath.prototype.replaceExpressionWithStatements = function replaceExpressionWithStatements(nodes) {
  15203. var toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
  15204. if (toSequenceExpression) {
  15205. return this.replaceWith(toSequenceExpression);
  15206. } else {
  15207. var container = t.functionExpression(null, [], t.blockStatement(nodes));
  15208. container.shadow = true;
  15209. // add implicit returns to all ending expression statements
  15210. var last = this.getLastStatements();
  15211. for (var i = 0; i < last.length; i++) {
  15212. var lastNode = last[i];
  15213. if (lastNode.isExpressionStatement()) {
  15214. lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
  15215. }
  15216. }
  15217. this.replaceWith(t.callExpression(container, []));
  15218. this.traverse(hoistVariablesVisitor);
  15219. return this.node;
  15220. }
  15221. };
  15222. /**
  15223. * Description
  15224. */
  15225. TraversalPath.prototype.call = function call(key) {
  15226. var node = this.node;
  15227. if (!node) return;
  15228. var opts = this.opts;
  15229. if (!opts[key] && !opts[node.type]) return;
  15230. var fns = [].concat(opts[key]);
  15231. if (opts[node.type]) fns = fns.concat(opts[node.type][key]);
  15232. var _arr5 = fns;
  15233. for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
  15234. var fn = _arr5[_i5];
  15235. if (!fn) continue;
  15236. var node = this.node;
  15237. if (!node) return;
  15238. var previousType = this.type;
  15239. // call the function with the params (node, parent, scope, state)
  15240. var replacement = fn.call(this, node, this.parent, this.scope, this.state);
  15241. if (replacement) {
  15242. this.replaceWith(replacement, true);
  15243. }
  15244. if (this.shouldStop || this.shouldSkip || this.removed) return;
  15245. if (previousType !== this.type) {
  15246. this.queueNode(this);
  15247. return;
  15248. }
  15249. }
  15250. };
  15251. /**
  15252. * Description
  15253. */
  15254. TraversalPath.prototype.isBlacklisted = function isBlacklisted() {
  15255. var blacklist = this.opts.blacklist;
  15256. return blacklist && blacklist.indexOf(this.node.type) > -1;
  15257. };
  15258. /**
  15259. * Description
  15260. */
  15261. TraversalPath.prototype.visit = function visit() {
  15262. if (this.isBlacklisted()) return false;
  15263. if (this.opts.shouldSkip && this.opts.shouldSkip(this)) return false;
  15264. this.call("enter");
  15265. if (this.shouldSkip) {
  15266. return this.shouldStop;
  15267. }
  15268. var node = this.node;
  15269. var opts = this.opts;
  15270. if (node) {
  15271. if (Array.isArray(node)) {
  15272. // traverse over these replacement nodes we purposely don't call exitNode
  15273. // as the original node has been destroyed
  15274. for (var i = 0; i < node.length; i++) {
  15275. _index2["default"].node(node[i], opts, this.scope, this.state, this);
  15276. }
  15277. } else {
  15278. _index2["default"].node(node, opts, this.scope, this.state, this);
  15279. this.call("exit");
  15280. }
  15281. }
  15282. return this.shouldStop;
  15283. };
  15284. /**
  15285. * Description
  15286. */
  15287. TraversalPath.prototype.getSibling = function getSibling(key) {
  15288. return TraversalPath.get(this.parentPath, this.parent, this.container, key, this.file);
  15289. };
  15290. /**
  15291. * Description
  15292. */
  15293. TraversalPath.prototype.get = function get(key) {
  15294. var parts = key.split(".");
  15295. if (parts.length === 1) {
  15296. // "foo"
  15297. return this._getKey(key);
  15298. } else {
  15299. // "foo.bar"
  15300. return this._getPattern(parts);
  15301. }
  15302. };
  15303. /**
  15304. * Description
  15305. */
  15306. TraversalPath.prototype._getKey = function _getKey(key) {
  15307. var _this = this;
  15308. var node = this.node;
  15309. var container = node[key];
  15310. if (Array.isArray(container)) {
  15311. // requested a container so give them all the paths
  15312. return container.map(function (_, i) {
  15313. return TraversalPath.get(_this, node, container, i).setContext();
  15314. });
  15315. } else {
  15316. return TraversalPath.get(this, node, node, key).setContext();
  15317. }
  15318. };
  15319. /**
  15320. * Description
  15321. */
  15322. TraversalPath.prototype._getPattern = function _getPattern(parts) {
  15323. var path = this;
  15324. var _arr6 = parts;
  15325. for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
  15326. var part = _arr6[_i6];
  15327. if (part === ".") {
  15328. path = path.parentPath;
  15329. } else {
  15330. if (Array.isArray(path)) {
  15331. path = path[part];
  15332. } else {
  15333. path = path.get(part);
  15334. }
  15335. }
  15336. }
  15337. return path;
  15338. };
  15339. /**
  15340. * Description
  15341. */
  15342. TraversalPath.prototype.has = function has(key) {
  15343. var val = this.node[key];
  15344. if (val && Array.isArray(val)) {
  15345. return !!val.length;
  15346. } else {
  15347. return !!val;
  15348. }
  15349. };
  15350. /**
  15351. * Description
  15352. */
  15353. TraversalPath.prototype.is = function is(key) {
  15354. return this.has(key);
  15355. };
  15356. /**
  15357. * Description
  15358. */
  15359. TraversalPath.prototype.isnt = function isnt(key) {
  15360. return !this.has(key);
  15361. };
  15362. /**
  15363. * Description
  15364. */
  15365. TraversalPath.prototype.equals = function equals(key, value) {
  15366. return this.node[key] === value;
  15367. };
  15368. /**
  15369. * Description
  15370. */
  15371. TraversalPath.prototype.getTypeAnnotation = function getTypeAnnotation() {
  15372. if (this.typeInfo) {
  15373. return this.typeInfo;
  15374. }
  15375. var info = this.typeInfo = {
  15376. inferred: false,
  15377. annotation: null
  15378. };
  15379. var type = this.node && this.node.typeAnnotation;
  15380. if (!type) {
  15381. info.inferred = true;
  15382. type = this.inferType(this);
  15383. }
  15384. if (type) {
  15385. if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
  15386. info.annotation = type;
  15387. }
  15388. return info;
  15389. };
  15390. /**
  15391. * Description
  15392. */
  15393. TraversalPath.prototype.resolve = function resolve() {
  15394. if (this.isVariableDeclarator()) {
  15395. if (this.get("id").isIdentifier()) {
  15396. return this.get("init").resolve();
  15397. } else {}
  15398. } else if (this.isIdentifier()) {
  15399. var binding = this.scope.getBinding(this.node.name);
  15400. if (!binding || !binding.constant) return;
  15401. // todo: take into consideration infinite recursion #1149
  15402. return;
  15403. if (binding.path === this) {
  15404. return this;
  15405. } else {
  15406. return binding.path.resolve();
  15407. }
  15408. } else if (this.isMemberExpression()) {
  15409. // this is dangerous, as non-direct target assignments will mutate it's state
  15410. // making this resolution inaccurate
  15411. var targetKey = this.toComputedKey();
  15412. if (!t.isLiteral(targetKey)) return;
  15413. var targetName = targetKey.value;
  15414. var target = this.get("object").resolve();
  15415. if (!target || !target.isObjectExpression()) return;
  15416. var props = target.get("properties");
  15417. for (var i = 0; i < props.length; i++) {
  15418. var prop = props[i];
  15419. if (!prop.isProperty()) continue;
  15420. var key = prop.get("key");
  15421. // { foo: obj }
  15422. var match = prop.isnt("computed") && key.isIdentifier({ name: targetName });
  15423. // { "foo": "obj" } or { ["foo"]: "obj" }
  15424. match = match || key.isLiteral({ value: targetName });
  15425. if (match) return prop.get("value");
  15426. }
  15427. } else {
  15428. return this;
  15429. }
  15430. };
  15431. /**
  15432. * Description
  15433. */
  15434. TraversalPath.prototype.inferType = function inferType(path) {
  15435. path = path.resolve();
  15436. if (!path) return;
  15437. if (path.isPreviousType("RestElement") || path.parentPath.isPreviousType("RestElement") || path.isPreviousType("ArrayExpression")) {
  15438. return t.genericTypeAnnotation(t.identifier("Array"));
  15439. }
  15440. if (path.parentPath.isPreviousType("TypeCastExpression")) {
  15441. return path.parentPath.node.typeAnnotation;
  15442. }
  15443. if (path.isPreviousType("TypeCastExpression")) {
  15444. return path.node.typeAnnotation;
  15445. }
  15446. if (path.isPreviousType("ObjectExpression")) {
  15447. return t.genericTypeAnnotation(t.identifier("Object"));
  15448. }
  15449. if (path.isPreviousType("Function")) {
  15450. return t.identifier("Function");
  15451. }
  15452. if (path.isPreviousType("Literal")) {
  15453. var value = path.node.value;
  15454. if ((0, _lodashLangIsString2["default"])(value)) return t.stringTypeAnnotation();
  15455. if ((0, _lodashLangIsNumber2["default"])(value)) return t.numberTypeAnnotation();
  15456. if ((0, _lodashLangIsBoolean2["default"])(value)) return t.booleanTypeAnnotation();
  15457. }
  15458. if (path.isPreviousType("CallExpression")) {
  15459. var callee = path.get("callee").resolve();
  15460. if (callee && callee.isPreviousType("Function")) return callee.node.returnType;
  15461. }
  15462. };
  15463. /**
  15464. * Description
  15465. */
  15466. TraversalPath.prototype.isPreviousType = function isPreviousType(type) {
  15467. return t.isType(this.type, type);
  15468. };
  15469. /**
  15470. * Description
  15471. */
  15472. TraversalPath.prototype.isTypeGeneric = function isTypeGeneric(genericName) {
  15473. var opts = arguments[1] === undefined ? {} : arguments[1];
  15474. var typeInfo = this.getTypeAnnotation();
  15475. var type = typeInfo.annotation;
  15476. if (!type) return false;
  15477. if (typeInfo.inferred && opts.inference === false) {
  15478. return false;
  15479. }
  15480. if (!t.isGenericTypeAnnotation(type) || !t.isIdentifier(type.id, { name: genericName })) {
  15481. return false;
  15482. }
  15483. if (opts.requireTypeParameters && !type.typeParameters) {
  15484. return false;
  15485. }
  15486. return true;
  15487. };
  15488. /**
  15489. * Description
  15490. */
  15491. TraversalPath.prototype.getBindingIdentifiers = function getBindingIdentifiers() {
  15492. return t.getBindingIdentifiers(this.node);
  15493. };
  15494. /**
  15495. * Description
  15496. */
  15497. TraversalPath.prototype.traverse = function traverse(visitor, state) {
  15498. if (!this.scope) console.log(this.contexts);
  15499. (0, _index2["default"])(this.node, visitor, this.scope, state, this);
  15500. };
  15501. /**
  15502. * Description
  15503. */
  15504. TraversalPath.prototype.hoist = function hoist() {
  15505. var scope = arguments[0] === undefined ? this.scope : arguments[0];
  15506. var hoister = new _hoister2["default"](this, scope);
  15507. return hoister.run();
  15508. };
  15509. /**
  15510. * Match the current node if it matches the provided `pattern`.
  15511. *
  15512. * For example, given the match `React.createClass` it would match the
  15513. * parsed nodes of `React.createClass` and `React["createClass"]`.
  15514. */
  15515. TraversalPath.prototype.matchesPattern = function matchesPattern(pattern, allowPartial) {
  15516. var parts = pattern.split(".");
  15517. // not a member expression
  15518. if (!this.isMemberExpression()) return false;
  15519. var search = [this.node];
  15520. var i = 0;
  15521. function matches(name) {
  15522. var part = parts[i];
  15523. return part === "*" || name === part;
  15524. }
  15525. while (search.length) {
  15526. var node = search.shift();
  15527. if (allowPartial && i === parts.length) {
  15528. return true;
  15529. }
  15530. if (t.isIdentifier(node)) {
  15531. // this part doesn't match
  15532. if (!matches(node.name)) return false;
  15533. } else if (t.isLiteral(node)) {
  15534. // this part doesn't match
  15535. if (!matches(node.value)) return false;
  15536. } else if (t.isMemberExpression(node)) {
  15537. if (node.computed && !t.isLiteral(node.property)) {
  15538. // we can't deal with this
  15539. return false;
  15540. } else {
  15541. search.push(node.object);
  15542. search.push(node.property);
  15543. continue;
  15544. }
  15545. } else {
  15546. // we can't deal with this
  15547. return false;
  15548. }
  15549. // too many parts
  15550. if (++i > parts.length) {
  15551. return false;
  15552. }
  15553. }
  15554. return true;
  15555. };
  15556. return TraversalPath;
  15557. })();
  15558. exports["default"] = TraversalPath;
  15559. (0, _lodashObjectAssign2["default"])(TraversalPath.prototype, require("./evaluation"));
  15560. (0, _lodashObjectAssign2["default"])(TraversalPath.prototype, require("./conversion"));
  15561. var _loop = function (type) {
  15562. if (type[0] === "_") return "continue";
  15563. TraversalPath.prototype["is" + type] = function (opts) {
  15564. return virtualTypes[type].checkPath(this, opts);
  15565. };
  15566. };
  15567. for (var type in virtualTypes) {
  15568. var _ret = _loop(type);
  15569. if (_ret === "continue") continue;
  15570. }
  15571. var _arr2 = t.TYPES;
  15572. var _loop2 = function () {
  15573. var type = _arr2[_i2];
  15574. var typeKey = "is" + type;
  15575. TraversalPath.prototype[typeKey] = function (opts) {
  15576. return t[typeKey](this.node, opts);
  15577. };
  15578. };
  15579. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  15580. _loop2();
  15581. }
  15582. module.exports = exports["default"];
  15583. // otherwise it's a request for a destructuring declarator and i'm not
  15584. // ready to resolve those just yet
  15585. },{"../../helpers/code-frame":42,"../../helpers/parse":46,"../../messages":47,"../../types":169,"../index":157,"../scope":164,"../visitors":165,"./conversion":158,"./evaluation":159,"./hoister":160,"./virtual-types":162,"lodash/collection/includes":332,"lodash/lang/isBoolean":406,"lodash/lang/isNumber":410,"lodash/lang/isRegExp":413,"lodash/lang/isString":414,"lodash/object/assign":417,"lodash/object/extend":419}],162:[function(require,module,exports){
  15586. "use strict";
  15587. exports.__esModule = true;
  15588. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  15589. var _types = require("../../types");
  15590. var t = _interopRequireWildcard(_types);
  15591. var ReferencedIdentifier = {
  15592. type: "Identifier",
  15593. checkPath: function checkPath(path, opts) {
  15594. return t.isReferencedIdentifier(path.node, path.parent, opts);
  15595. }
  15596. };
  15597. exports.ReferencedIdentifier = ReferencedIdentifier;
  15598. var Scope = {
  15599. type: "Scopable",
  15600. checkPath: function checkPath(path) {
  15601. return t.isScope(path.node, path.parent);
  15602. }
  15603. };
  15604. exports.Scope = Scope;
  15605. var Referenced = {
  15606. checkPath: function checkPath(path) {
  15607. return t.isReferenced(path.node, path.parent);
  15608. }
  15609. };
  15610. exports.Referenced = Referenced;
  15611. var BlockScoped = {
  15612. checkPath: function checkPath(path) {
  15613. return t.isBlockScoped(path.node);
  15614. }
  15615. };
  15616. exports.BlockScoped = BlockScoped;
  15617. var Var = {
  15618. type: "VariableDeclaration",
  15619. checkPath: function checkPath(path) {
  15620. return t.isVar(path.node);
  15621. }
  15622. };
  15623. exports.Var = Var;
  15624. },{"../../types":169}],163:[function(require,module,exports){
  15625. "use strict";
  15626. exports.__esModule = true;
  15627. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  15628. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15629. var _types = require("../../types");
  15630. var t = _interopRequireWildcard(_types);
  15631. var Binding = (function () {
  15632. function Binding(_ref) {
  15633. var identifier = _ref.identifier;
  15634. var scope = _ref.scope;
  15635. var path = _ref.path;
  15636. var kind = _ref.kind;
  15637. _classCallCheck(this, Binding);
  15638. this.constantViolations = [];
  15639. this.constant = true;
  15640. this.identifier = identifier;
  15641. this.references = 0;
  15642. this.referenced = false;
  15643. this.scope = scope;
  15644. this.path = path;
  15645. this.kind = kind;
  15646. }
  15647. /**
  15648. * Description
  15649. */
  15650. Binding.prototype.setTypeAnnotation = function setTypeAnnotation() {
  15651. var typeInfo = this.path.getTypeAnnotation();
  15652. this.typeAnnotationInferred = typeInfo.inferred;
  15653. this.typeAnnotation = typeInfo.annotation;
  15654. };
  15655. /**
  15656. * Description
  15657. */
  15658. Binding.prototype.isTypeGeneric = function isTypeGeneric() {
  15659. var _path;
  15660. return (_path = this.path).isTypeGeneric.apply(_path, arguments);
  15661. };
  15662. /**
  15663. * Description
  15664. */
  15665. Binding.prototype.assignTypeGeneric = function assignTypeGeneric(type, params) {
  15666. var typeParams = null;
  15667. if (params) params = t.typeParameterInstantiation(params);
  15668. this.assignType(t.genericTypeAnnotation(t.identifier(type), typeParams));
  15669. };
  15670. /**
  15671. * Description
  15672. */
  15673. Binding.prototype.assignType = function assignType(type) {
  15674. this.typeAnnotation = type;
  15675. };
  15676. /**
  15677. * Description
  15678. */
  15679. Binding.prototype.reassign = function reassign(path) {
  15680. this.constant = false;
  15681. this.constantViolations.push(path);
  15682. if (this.typeAnnotationInferred) {
  15683. // destroy the inferred typeAnnotation
  15684. this.typeAnnotation = null;
  15685. }
  15686. };
  15687. /**
  15688. * Description
  15689. */
  15690. Binding.prototype.reference = function reference() {
  15691. this.referenced = true;
  15692. this.references++;
  15693. };
  15694. /**
  15695. * Description
  15696. */
  15697. Binding.prototype.dereference = function dereference() {
  15698. this.references--;
  15699. this.referenced = !!this.references;
  15700. };
  15701. /**
  15702. * Description
  15703. */
  15704. Binding.prototype.isCompatibleWithType = function isCompatibleWithType(newType) {
  15705. return false;
  15706. };
  15707. return Binding;
  15708. })();
  15709. exports["default"] = Binding;
  15710. module.exports = exports["default"];
  15711. },{"../../types":169}],164:[function(require,module,exports){
  15712. "use strict";
  15713. exports.__esModule = true;
  15714. var _createClass = (function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  15715. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  15716. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15717. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15718. var _lodashCollectionIncludes = require("lodash/collection/includes");
  15719. var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
  15720. var _visitors = require("../visitors");
  15721. var _index = require("../index");
  15722. var _index2 = _interopRequireDefault(_index);
  15723. var _lodashObjectDefaults = require("lodash/object/defaults");
  15724. var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
  15725. var _messages = require("../../messages");
  15726. var messages = _interopRequireWildcard(_messages);
  15727. var _binding = require("./binding");
  15728. var _binding2 = _interopRequireDefault(_binding);
  15729. var _globals = require("globals");
  15730. var _globals2 = _interopRequireDefault(_globals);
  15731. var _lodashArrayFlatten = require("lodash/array/flatten");
  15732. var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
  15733. var _lodashObjectExtend = require("lodash/object/extend");
  15734. var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
  15735. var _helpersObject = require("../../helpers/object");
  15736. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  15737. var _lodashCollectionEach = require("lodash/collection/each");
  15738. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  15739. var _types = require("../../types");
  15740. var t = _interopRequireWildcard(_types);
  15741. var functionVariableVisitor = {
  15742. enter: function enter(node, parent, scope, state) {
  15743. if (t.isFor(node)) {
  15744. var _arr = t.FOR_INIT_KEYS;
  15745. for (var _i = 0; _i < _arr.length; _i++) {
  15746. var key = _arr[_i];
  15747. var declar = this.get(key);
  15748. if (declar.isVar()) state.scope.registerBinding("var", declar);
  15749. }
  15750. }
  15751. // this block is a function so we'll stop since none of the variables
  15752. // declared within are accessible
  15753. if (this.isFunction()) return this.skip();
  15754. // function identifier doesn't belong to this scope
  15755. if (state.blockId && node === state.blockId) return;
  15756. // delegate block scope handling to the `blockVariableVisitor`
  15757. if (this.isBlockScoped()) return;
  15758. // this will be hit again once we traverse into it after this iteration
  15759. if (this.isExportDeclaration() && t.isDeclaration(node.declaration)) return;
  15760. // we've ran into a declaration!
  15761. if (this.isDeclaration()) state.scope.registerDeclaration(this);
  15762. }
  15763. };
  15764. var programReferenceVisitor = (0, _visitors.explode)({
  15765. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  15766. var bindingInfo = scope.getBinding(node.name);
  15767. if (bindingInfo) {
  15768. bindingInfo.reference();
  15769. } else {
  15770. state.addGlobal(node);
  15771. }
  15772. },
  15773. Scopable: function Scopable(node, parent, scope, state) {
  15774. for (var name in scope.bindings) {
  15775. state.references[name] = true;
  15776. }
  15777. },
  15778. ExportDeclaration: {
  15779. exit: function exit(node, parent, scope, state) {
  15780. var declar = node.declaration;
  15781. if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
  15782. scope.getBinding(declar.id.name).reference();
  15783. } else if (t.isVariableDeclaration(declar)) {
  15784. var _arr2 = declar.declarations;
  15785. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  15786. var decl = _arr2[_i2];
  15787. var ids = t.getBindingIdentifiers(decl);
  15788. for (var name in ids) {
  15789. scope.getBinding(name).reference();
  15790. }
  15791. }
  15792. }
  15793. }
  15794. },
  15795. LabeledStatement: function LabeledStatement(node, parent, scope, state) {
  15796. state.addGlobal(node);
  15797. },
  15798. AssignmentExpression: function AssignmentExpression(node, parent, scope, state) {
  15799. scope.registerConstantViolation(this.get("left"), this.get("right"));
  15800. },
  15801. UpdateExpression: function UpdateExpression(node, parent, scope, state) {
  15802. scope.registerConstantViolation(this.get("argument"), null);
  15803. },
  15804. UnaryExpression: function UnaryExpression(node, parent, scope, state) {
  15805. if (node.operator === "delete") scope.registerConstantViolation(this.get("left"), null);
  15806. }
  15807. });
  15808. var blockVariableVisitor = (0, _visitors.explode)({
  15809. Scope: function Scope() {
  15810. this.skip();
  15811. },
  15812. enter: function enter(node, parent, scope, state) {
  15813. if (this.isFunctionDeclaration() || this.isBlockScoped()) {
  15814. state.registerDeclaration(this);
  15815. }
  15816. }
  15817. });
  15818. var renameVisitor = (0, _visitors.explode)({
  15819. ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
  15820. if (node.name === state.oldName) {
  15821. node.name = state.newName;
  15822. }
  15823. },
  15824. Declaration: function Declaration(node, parent, scope, state) {
  15825. var ids = this.getBindingIdentifiers();;
  15826. for (var name in ids) {
  15827. if (name === state.oldName) ids[name].name = state.newName;
  15828. }
  15829. },
  15830. Scopable: function Scopable(node, parent, scope, state) {
  15831. if (this.isScope()) {
  15832. if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) {
  15833. this.skip();
  15834. }
  15835. }
  15836. }
  15837. });
  15838. var Scope = (function () {
  15839. /**
  15840. * This searches the current "scope" and collects all references/bindings
  15841. * within.
  15842. */
  15843. function Scope(path, parent, file) {
  15844. _classCallCheck(this, Scope);
  15845. if (parent && parent.block === path.node) {
  15846. return parent;
  15847. }
  15848. var cached = path.getData("scope");
  15849. if (cached && cached.parent === parent) {
  15850. return cached;
  15851. } else {}
  15852. this.parent = parent;
  15853. this.file = parent ? parent.file : file;
  15854. this.parentBlock = path.parent;
  15855. this.block = path.node;
  15856. this.path = path;
  15857. this.crawl();
  15858. }
  15859. /**
  15860. * Description
  15861. */
  15862. Scope.prototype.traverse = function traverse(node, opts, state) {
  15863. (0, _index2["default"])(node, opts, this, state, this.path);
  15864. };
  15865. /**
  15866. * Since `Scope` instances are unique to their traversal we need some other
  15867. * way to compare if scopes are the same. Here we just compare `this.bindings`
  15868. * as it will be the same across all instances.
  15869. */
  15870. Scope.prototype.is = function is(scope) {
  15871. return this.bindings === scope.bindings;
  15872. };
  15873. /**
  15874. * Description
  15875. */
  15876. Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier() {
  15877. var name = arguments[0] === undefined ? "temp" : arguments[0];
  15878. var id = this.generateUidIdentifier(name);
  15879. this.push({ id: id });
  15880. return id;
  15881. };
  15882. /**
  15883. * Description
  15884. */
  15885. Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
  15886. return t.identifier(this.generateUid(name));
  15887. };
  15888. /**
  15889. * Description
  15890. */
  15891. Scope.prototype.generateUid = function generateUid(name) {
  15892. name = t.toIdentifier(name).replace(/^_+/, "");
  15893. var uid;
  15894. var i = 0;
  15895. do {
  15896. uid = this._generateUid(name, i);
  15897. i++;
  15898. } while (this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
  15899. var program = this.getProgramParent();
  15900. program.references[uid] = true;
  15901. program.uids[uid] = true;
  15902. return uid;
  15903. };
  15904. Scope.prototype._generateUid = function _generateUid(name, i) {
  15905. var id = name;
  15906. if (i > 1) id += i;
  15907. return "_" + id;
  15908. };
  15909. /*
  15910. * Description
  15911. */
  15912. Scope.prototype.generateUidIdentifierBasedOnNode = function generateUidIdentifierBasedOnNode(parent, defaultName) {
  15913. var node = parent;
  15914. if (t.isAssignmentExpression(parent)) {
  15915. node = parent.left;
  15916. } else if (t.isVariableDeclarator(parent)) {
  15917. node = parent.id;
  15918. } else if (t.isProperty(node)) {
  15919. node = node.key;
  15920. }
  15921. var parts = [];
  15922. var add = function add(node) {
  15923. if (t.isModuleDeclaration(node)) {
  15924. if (node.source) {
  15925. add(node.source);
  15926. } else if (node.specifiers && node.specifiers.length) {
  15927. var _arr3 = node.specifiers;
  15928. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  15929. var specifier = _arr3[_i3];
  15930. add(specifier);
  15931. }
  15932. } else if (node.declaration) {
  15933. add(node.declaration);
  15934. }
  15935. } else if (t.isModuleSpecifier(node)) {
  15936. add(node.local);
  15937. } else if (t.isMemberExpression(node)) {
  15938. add(node.object);
  15939. add(node.property);
  15940. } else if (t.isIdentifier(node)) {
  15941. parts.push(node.name);
  15942. } else if (t.isLiteral(node)) {
  15943. parts.push(node.value);
  15944. } else if (t.isCallExpression(node)) {
  15945. add(node.callee);
  15946. } else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
  15947. var _arr4 = node.properties;
  15948. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  15949. var prop = _arr4[_i4];
  15950. add(prop.key || prop.argument);
  15951. }
  15952. }
  15953. };
  15954. add(node);
  15955. var id = parts.join("$");
  15956. id = id.replace(/^_/, "") || defaultName || "ref";
  15957. return this.generateUidIdentifier(id);
  15958. };
  15959. /**
  15960. * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
  15961. * evaluating it wont result in potentially arbitrary code from being ran. The following are
  15962. * whitelisted and determined not cause side effects:
  15963. *
  15964. * - `this` expressions
  15965. * - `super` expressions
  15966. * - Bound identifiers
  15967. */
  15968. Scope.prototype.isStatic = function isStatic(node) {
  15969. if (t.isThisExpression(node) || t.isSuper(node)) {
  15970. return true;
  15971. }
  15972. if (t.isIdentifier(node) && this.hasBinding(node.name)) {
  15973. return true;
  15974. }
  15975. return false;
  15976. };
  15977. /**
  15978. * Description
  15979. */
  15980. Scope.prototype.maybeGenerateMemoised = function maybeGenerateMemoised(node, dontPush) {
  15981. if (this.isStatic(node)) {
  15982. return null;
  15983. } else {
  15984. var id = this.generateUidIdentifierBasedOnNode(node);
  15985. if (!dontPush) this.push({ id: id });
  15986. return id;
  15987. }
  15988. };
  15989. /**
  15990. * Description
  15991. */
  15992. Scope.prototype.checkBlockScopedCollisions = function checkBlockScopedCollisions(kind, name, id) {
  15993. var local = this.getOwnBindingInfo(name);
  15994. if (!local) return;
  15995. if (kind === "param") return;
  15996. if (kind === "hoisted" && local.kind === "let") return;
  15997. var duplicate = false;
  15998. if (!duplicate) duplicate = kind === "let" || kind === "const" || local.kind === "let" || local.kind === "const" || local.kind === "module";
  15999. if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const");
  16000. if (duplicate) {
  16001. throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
  16002. }
  16003. };
  16004. /**
  16005. * Description
  16006. */
  16007. Scope.prototype.rename = function rename(oldName, newName, block) {
  16008. newName = newName || this.generateUidIdentifier(oldName).name;
  16009. var info = this.getBinding(oldName);
  16010. if (!info) return;
  16011. var state = {
  16012. newName: newName,
  16013. oldName: oldName,
  16014. binding: info.identifier,
  16015. info: info
  16016. };
  16017. var scope = info.scope;
  16018. scope.traverse(block || scope.block, renameVisitor, state);
  16019. if (!block) {
  16020. scope.removeOwnBinding(oldName);
  16021. scope.bindings[newName] = info;
  16022. state.binding.name = newName;
  16023. }
  16024. var file = this.file;
  16025. if (file) {
  16026. this._renameFromMap(file.moduleFormatter.localImports, oldName, newName, state.binding);
  16027. //this._renameFromMap(file.moduleFormatter.localExports, oldName, newName);
  16028. }
  16029. };
  16030. Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
  16031. if (map[oldName]) {
  16032. map[newName] = value;
  16033. map[oldName] = null;
  16034. }
  16035. };
  16036. /**
  16037. * Description
  16038. */
  16039. Scope.prototype.dump = function dump() {
  16040. var scope = this;
  16041. do {
  16042. console.log(scope.block.type, "Bindings:", Object.keys(scope.bindings));
  16043. } while (scope = scope.parent);
  16044. console.log("-------------");
  16045. };
  16046. /**
  16047. * Description
  16048. */
  16049. Scope.prototype.toArray = function toArray(node, i) {
  16050. var file = this.file;
  16051. if (t.isIdentifier(node)) {
  16052. var binding = this.getBinding(node.name);
  16053. if (binding && binding.constant && binding.isTypeGeneric("Array")) return node;
  16054. }
  16055. if (t.isArrayExpression(node)) {
  16056. return node;
  16057. }
  16058. if (t.isIdentifier(node, { name: "arguments" })) {
  16059. return t.callExpression(t.memberExpression(file.addHelper("slice"), t.identifier("call")), [node]);
  16060. }
  16061. var helperName = "to-array";
  16062. var args = [node];
  16063. if (i === true) {
  16064. helperName = "to-consumable-array";
  16065. } else if (i) {
  16066. args.push(t.literal(i));
  16067. helperName = "sliced-to-array";
  16068. if (this.file.isLoose("es6.forOf")) helperName += "-loose";
  16069. }
  16070. return t.callExpression(file.addHelper(helperName), args);
  16071. };
  16072. /**
  16073. * Description
  16074. */
  16075. Scope.prototype.registerDeclaration = function registerDeclaration(path) {
  16076. var node = path.node;
  16077. if (t.isFunctionDeclaration(node)) {
  16078. this.registerBinding("hoisted", path);
  16079. } else if (t.isVariableDeclaration(node)) {
  16080. var declarations = path.get("declarations");
  16081. var _arr5 = declarations;
  16082. for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
  16083. var declar = _arr5[_i5];
  16084. this.registerBinding(node.kind, declar);
  16085. }
  16086. } else if (t.isClassDeclaration(node)) {
  16087. this.registerBinding("let", path);
  16088. } else if (t.isImportDeclaration(node) || t.isExportDeclaration(node)) {
  16089. this.registerBinding("module", path);
  16090. } else {
  16091. this.registerBinding("unknown", path);
  16092. }
  16093. };
  16094. /**
  16095. * Description
  16096. */
  16097. Scope.prototype.registerConstantViolation = function registerConstantViolation(left, right) {
  16098. var ids = left.getBindingIdentifiers();
  16099. for (var name in ids) {
  16100. var binding = this.getBinding(name);
  16101. if (!binding) continue;
  16102. if (right) {
  16103. var rightType = right.typeAnnotation;
  16104. if (rightType && binding.isCompatibleWithType(rightType)) continue;
  16105. }
  16106. binding.reassign(left, right);
  16107. }
  16108. };
  16109. /**
  16110. * Description
  16111. */
  16112. Scope.prototype.registerBinding = function registerBinding(kind, path) {
  16113. if (!kind) throw new ReferenceError("no `kind`");
  16114. if (path.isVariableDeclaration()) {
  16115. var declarators = path.get("declarations");
  16116. var _arr6 = declarators;
  16117. for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
  16118. var declar = _arr6[_i6];
  16119. this.registerBinding(kind, declar);
  16120. }
  16121. return;
  16122. }
  16123. var ids = path.getBindingIdentifiers();
  16124. for (var name in ids) {
  16125. var id = ids[name];
  16126. this.checkBlockScopedCollisions(kind, name, id);
  16127. this.bindings[name] = new _binding2["default"]({
  16128. identifier: id,
  16129. scope: this,
  16130. path: path,
  16131. kind: kind
  16132. });
  16133. }
  16134. };
  16135. /**
  16136. * Description
  16137. */
  16138. Scope.prototype.addGlobal = function addGlobal(node) {
  16139. this.globals[node.name] = node;
  16140. };
  16141. /**
  16142. * Description
  16143. */
  16144. Scope.prototype.hasUid = function hasUid(name) {
  16145. var scope = this;
  16146. do {
  16147. if (scope.uids[name]) return true;
  16148. } while (scope = scope.parent);
  16149. return false;
  16150. };
  16151. /**
  16152. * Description
  16153. */
  16154. Scope.prototype.hasGlobal = function hasGlobal(name) {
  16155. var scope = this;
  16156. do {
  16157. if (scope.globals[name]) return true;
  16158. } while (scope = scope.parent);
  16159. return false;
  16160. };
  16161. /**
  16162. * Description
  16163. */
  16164. Scope.prototype.hasReference = function hasReference(name) {
  16165. var scope = this;
  16166. do {
  16167. if (scope.references[name]) return true;
  16168. } while (scope = scope.parent);
  16169. return false;
  16170. };
  16171. /**
  16172. * Description
  16173. */
  16174. Scope.prototype.recrawl = function recrawl() {
  16175. this.path.setData("scopeInfo", null);
  16176. this.crawl();
  16177. };
  16178. /**
  16179. * Description
  16180. */
  16181. Scope.prototype.isPure = function isPure(node) {
  16182. if (t.isIdentifier(node)) {
  16183. var bindingInfo = this.getBinding(node.name);
  16184. return bindingInfo && bindingInfo.constant;
  16185. } else {
  16186. return t.isPure(node);
  16187. }
  16188. };
  16189. /**
  16190. * Description
  16191. */
  16192. Scope.prototype.crawl = function crawl() {
  16193. var path = this.path;
  16194. //
  16195. var info = this.block._scopeInfo;
  16196. if (info) return (0, _lodashObjectExtend2["default"])(this, info);
  16197. info = this.block._scopeInfo = {
  16198. references: (0, _helpersObject2["default"])(),
  16199. bindings: (0, _helpersObject2["default"])(),
  16200. globals: (0, _helpersObject2["default"])(),
  16201. uids: (0, _helpersObject2["default"])() };
  16202. (0, _lodashObjectExtend2["default"])(this, info);
  16203. // ForStatement - left, init
  16204. if (path.isLoop()) {
  16205. var _arr7 = t.FOR_INIT_KEYS;
  16206. for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
  16207. var key = _arr7[_i7];
  16208. var node = path.get(key);
  16209. if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
  16210. }
  16211. }
  16212. // FunctionExpression - id
  16213. if (path.isFunctionExpression() && path.has("id")) {
  16214. if (!t.isProperty(path.parent, { method: true })) {
  16215. this.registerBinding("var", path.get("id"));
  16216. }
  16217. }
  16218. // Class
  16219. if (path.isClassDeclaration()) {
  16220. var name = path.node.id.name;
  16221. this.bindings[name] = this.parent.bindings[name];
  16222. }
  16223. if (path.isClassExpression() && path.has("id")) {
  16224. this.registerBinding("var", path);
  16225. }
  16226. // Function - params, rest
  16227. if (path.isFunction()) {
  16228. var params = path.get("params");
  16229. var _arr8 = params;
  16230. for (var _i8 = 0; _i8 < _arr8.length; _i8++) {
  16231. var param = _arr8[_i8];
  16232. this.registerBinding("param", param);
  16233. }
  16234. this.traverse(path.get("body").node, blockVariableVisitor, this);
  16235. }
  16236. // Program, Function - var variables
  16237. if (path.isProgram() || path.isFunction()) {
  16238. this.traverse(path.node, functionVariableVisitor, {
  16239. blockId: path.get("id").node,
  16240. scope: this
  16241. });
  16242. }
  16243. // Program, BlockStatement, Function - let variables
  16244. if (path.isBlockStatement() || path.isProgram()) {
  16245. this.traverse(path.node, blockVariableVisitor, this);
  16246. }
  16247. // CatchClause - param
  16248. if (path.isCatchClause()) {
  16249. this.registerBinding("let", path.get("param"));
  16250. }
  16251. // ComprehensionExpression - blocks
  16252. if (path.isComprehensionExpression()) {
  16253. this.registerBinding("let", path);
  16254. }
  16255. // Program
  16256. if (path.isProgram()) {
  16257. this.traverse(path.node, programReferenceVisitor, this);
  16258. }
  16259. };
  16260. /**
  16261. * Description
  16262. */
  16263. Scope.prototype.push = function push(opts) {
  16264. var path = this.path;
  16265. if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
  16266. t.ensureBlock(path.node);
  16267. path = path.get("body");
  16268. }
  16269. if (!path.isBlockStatement() && !path.isProgram()) {
  16270. path = this.getBlockParent().path;
  16271. }
  16272. var unique = opts.unique;
  16273. var kind = opts.kind || "var";
  16274. var dataKey = "declaration:" + kind;
  16275. var declar = !unique && path.getData(dataKey);
  16276. if (!declar) {
  16277. declar = t.variableDeclaration(kind, []);
  16278. declar._generated = true;
  16279. declar._blockHoist = 2;
  16280. this.file.attachAuxiliaryComment(declar);
  16281. var _path$get$0$_containerInsertBefore = path.get("body")[0]._containerInsertBefore([declar]);
  16282. var declarPath = _path$get$0$_containerInsertBefore[0];
  16283. this.registerBinding(kind, declarPath);
  16284. if (!unique) path.setData(dataKey, declar);
  16285. }
  16286. declar.declarations.push(t.variableDeclarator(opts.id, opts.init));
  16287. };
  16288. /**
  16289. * Walk up to the top of the scope tree and get the `Program`.
  16290. */
  16291. Scope.prototype.getProgramParent = function getProgramParent() {
  16292. var scope = this;
  16293. while (scope.parent) {
  16294. scope = scope.parent;
  16295. }
  16296. return scope;
  16297. };
  16298. /**
  16299. * Walk up the scope tree until we hit either a Function or reach the
  16300. * very top and hit Program.
  16301. */
  16302. Scope.prototype.getFunctionParent = function getFunctionParent() {
  16303. var scope = this;
  16304. while (scope.parent && !t.isFunction(scope.block)) {
  16305. scope = scope.parent;
  16306. }
  16307. return scope;
  16308. };
  16309. /**
  16310. * Walk up the scope tree until we hit either a BlockStatement/Loop or reach the
  16311. * very top and hit Program.
  16312. */
  16313. Scope.prototype.getBlockParent = function getBlockParent() {
  16314. var scope = this;
  16315. while (scope.parent && !t.isFunction(scope.block) && !t.isLoop(scope.block) && !t.isFunction(scope.block)) {
  16316. scope = scope.parent;
  16317. }
  16318. return scope;
  16319. };
  16320. /**
  16321. * Walks the scope tree and gathers **all** bindings.
  16322. */
  16323. Scope.prototype.getAllBindings = function getAllBindings() {
  16324. var ids = (0, _helpersObject2["default"])();
  16325. var scope = this;
  16326. do {
  16327. (0, _lodashObjectDefaults2["default"])(ids, scope.bindings);
  16328. scope = scope.parent;
  16329. } while (scope);
  16330. return ids;
  16331. };
  16332. /**
  16333. * Walks the scope tree and gathers all declarations of `kind`.
  16334. */
  16335. Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind() {
  16336. var ids = (0, _helpersObject2["default"])();
  16337. var _arr9 = arguments;
  16338. for (var _i9 = 0; _i9 < _arr9.length; _i9++) {
  16339. var kind = _arr9[_i9];
  16340. var scope = this;
  16341. do {
  16342. for (var name in scope.bindings) {
  16343. var binding = scope.bindings[name];
  16344. if (binding.kind === kind) ids[name] = binding;
  16345. }
  16346. scope = scope.parent;
  16347. } while (scope);
  16348. }
  16349. return ids;
  16350. };
  16351. /**
  16352. * Description
  16353. */
  16354. Scope.prototype.bindingIdentifierEquals = function bindingIdentifierEquals(name, node) {
  16355. return this.getBindingIdentifier(name) === node;
  16356. };
  16357. /**
  16358. * Description
  16359. */
  16360. Scope.prototype.getBinding = function getBinding(name) {
  16361. var scope = this;
  16362. do {
  16363. var binding = scope.getOwnBindingInfo(name);
  16364. if (binding) return binding;
  16365. } while (scope = scope.parent);
  16366. };
  16367. /**
  16368. * Description
  16369. */
  16370. Scope.prototype.getOwnBindingInfo = function getOwnBindingInfo(name) {
  16371. return this.bindings[name];
  16372. };
  16373. /**
  16374. * Description
  16375. */
  16376. Scope.prototype.getBindingIdentifier = function getBindingIdentifier(name) {
  16377. var info = this.getBinding(name);
  16378. return info && info.identifier;
  16379. };
  16380. /**
  16381. * Description
  16382. */
  16383. Scope.prototype.getOwnBindingIdentifier = function getOwnBindingIdentifier(name) {
  16384. var binding = this.bindings[name];
  16385. return binding && binding.identifier;
  16386. };
  16387. /**
  16388. * Description
  16389. */
  16390. Scope.prototype.hasOwnBinding = function hasOwnBinding(name) {
  16391. return !!this.getOwnBindingInfo(name);
  16392. };
  16393. /**
  16394. * Description
  16395. */
  16396. Scope.prototype.hasBinding = function hasBinding(name) {
  16397. if (!name) return false;
  16398. if (this.hasOwnBinding(name)) return true;
  16399. if (this.parentHasBinding(name)) return true;
  16400. if (this.hasUid(name)) return true;
  16401. if ((0, _lodashCollectionIncludes2["default"])(Scope.globals, name)) return true;
  16402. if ((0, _lodashCollectionIncludes2["default"])(Scope.contextVariables, name)) return true;
  16403. return false;
  16404. };
  16405. /**
  16406. * Description
  16407. */
  16408. Scope.prototype.parentHasBinding = function parentHasBinding(name) {
  16409. return this.parent && this.parent.hasBinding(name);
  16410. };
  16411. /**
  16412. * Move a binding of `name` to another `scope`.
  16413. */
  16414. Scope.prototype.moveBindingTo = function moveBindingTo(name, scope) {
  16415. var info = this.getBinding(name);
  16416. if (info) {
  16417. info.scope.removeOwnBinding(name);
  16418. info.scope = scope;
  16419. scope.bindings[name] = info;
  16420. }
  16421. };
  16422. /**
  16423. * Description
  16424. */
  16425. Scope.prototype.removeOwnBinding = function removeOwnBinding(name) {
  16426. delete this.bindings[name];
  16427. };
  16428. /**
  16429. * Description
  16430. */
  16431. Scope.prototype.removeBinding = function removeBinding(name) {
  16432. var info = this.getBinding(name);
  16433. if (info) info.scope.removeOwnBinding(name);
  16434. };
  16435. _createClass(Scope, null, [{
  16436. key: "globals",
  16437. value: (0, _lodashArrayFlatten2["default"])([_globals2["default"].builtin, _globals2["default"].browser, _globals2["default"].node].map(Object.keys)),
  16438. enumerable: true
  16439. }, {
  16440. key: "contextVariables",
  16441. value: ["this", "arguments", "super"],
  16442. enumerable: true
  16443. }]);
  16444. return Scope;
  16445. })();
  16446. exports["default"] = Scope;
  16447. module.exports = exports["default"];
  16448. //path.setData("scope", this);
  16449. },{"../../helpers/object":45,"../../messages":47,"../../types":169,"../index":157,"../visitors":165,"./binding":163,"globals":316,"lodash/array/flatten":325,"lodash/collection/each":330,"lodash/collection/includes":332,"lodash/object/defaults":418,"lodash/object/extend":419}],165:[function(require,module,exports){
  16450. "use strict";
  16451. exports.__esModule = true;
  16452. exports.explode = explode;
  16453. exports.verify = verify;
  16454. exports.merge = merge;
  16455. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16456. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  16457. var _pathVirtualTypes = require("./path/virtual-types");
  16458. var virtualTypes = _interopRequireWildcard(_pathVirtualTypes);
  16459. var _messages = require("../messages");
  16460. var messages = _interopRequireWildcard(_messages);
  16461. var _types = require("../types");
  16462. var t = _interopRequireWildcard(_types);
  16463. var _esquery = require("esquery");
  16464. var _esquery2 = _interopRequireDefault(_esquery);
  16465. function explode(visitor, mergeConflicts) {
  16466. if (visitor._exploded) return visitor;
  16467. visitor._exploded = true;
  16468. // make sure there's no __esModule type since this is because we're using loose mode
  16469. // and it sets __esModule to be enumerable on all modules :(
  16470. delete visitor.__esModule;
  16471. if (visitor.queries) {
  16472. ensureEntranceObjects(visitor.queries);
  16473. addQueries(visitor);
  16474. delete visitor.queries;
  16475. }
  16476. // ensure visitors are objects
  16477. ensureEntranceObjects(visitor);
  16478. // add type wrappers
  16479. for (var nodeType in visitor) {
  16480. if (shouldIgnoreKey(nodeType)) continue;
  16481. var wrapper = virtualTypes[nodeType];
  16482. if (!wrapper) continue;
  16483. // wrap all the functions
  16484. var fns = visitor[nodeType];
  16485. for (var type in fns) {
  16486. fns[type] = wrapCheck(wrapper, fns[type]);
  16487. }
  16488. // clear it from the visitor
  16489. delete visitor[nodeType];
  16490. if (wrapper.type) {
  16491. // merge the visitor if necessary or just put it back in
  16492. if (visitor[wrapper.type]) {
  16493. mergePair(visitor[wrapper.type], fns);
  16494. } else {
  16495. visitor[wrapper.type] = fns;
  16496. }
  16497. } else {
  16498. mergePair(visitor, fns);
  16499. }
  16500. }
  16501. // add aliases
  16502. for (var nodeType in visitor) {
  16503. if (shouldIgnoreKey(nodeType)) continue;
  16504. var fns = visitor[nodeType];
  16505. var aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
  16506. if (!aliases) continue;
  16507. // clear it form the visitor
  16508. delete visitor[nodeType];
  16509. var _arr = aliases;
  16510. for (var _i = 0; _i < _arr.length; _i++) {
  16511. var alias = _arr[_i];
  16512. var existing = visitor[alias];
  16513. if (existing) {
  16514. if (mergeConflicts) {
  16515. mergePair(existing, fns);
  16516. }
  16517. } else {
  16518. visitor[alias] = fns;
  16519. }
  16520. }
  16521. }
  16522. return visitor;
  16523. }
  16524. function verify(visitor) {
  16525. if (visitor._verified) return;
  16526. if (typeof visitor === "function") {
  16527. throw new Error(messages.get("traverseVerifyRootFunction"));
  16528. }
  16529. for (var nodeType in visitor) {
  16530. if (shouldIgnoreKey(nodeType)) continue;
  16531. if (t.TYPES.indexOf(nodeType) < 0 && !virtualTypes[nodeType]) {
  16532. throw new Error(messages.get("traverseVerifyNodeType", nodeType));
  16533. }
  16534. var visitors = visitor[nodeType];
  16535. if (typeof visitors === "object") {
  16536. for (var visitorKey in visitors) {
  16537. if (visitorKey === "enter" || visitorKey === "exit") continue;
  16538. throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
  16539. }
  16540. }
  16541. }
  16542. visitor._verified = true;
  16543. }
  16544. function merge(visitors) {
  16545. var rootVisitor = {};
  16546. var _arr2 = visitors;
  16547. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  16548. var visitor = _arr2[_i2];
  16549. for (var type in visitor) {
  16550. var nodeVisitor = rootVisitor[type] = rootVisitor[type] || {};
  16551. mergePair(nodeVisitor, visitor[type]);
  16552. }
  16553. }
  16554. return rootVisitor;
  16555. }
  16556. function ensureEntranceObjects(obj) {
  16557. for (var key in obj) {
  16558. if (shouldIgnoreKey(key)) continue;
  16559. var fns = obj[key];
  16560. if (typeof fns === "function") {
  16561. obj[key] = { enter: fns };
  16562. }
  16563. }
  16564. }
  16565. function addQueries(visitor) {
  16566. for (var selector in visitor.queries) {
  16567. var fns = visitor.queries[selector];
  16568. addSelector(visitor, selector, fns);
  16569. }
  16570. }
  16571. function addSelector(visitor, selector, fns) {
  16572. selector = _esquery2["default"].parse(selector);
  16573. var _loop = function () {
  16574. var fn = fns[key];
  16575. fns[key] = function (node) {
  16576. if (_esquery2["default"].matches(node, selector, this.getAncestry())) {
  16577. return fn.apply(this, arguments);
  16578. }
  16579. };
  16580. };
  16581. for (var key in fns) {
  16582. _loop();
  16583. }
  16584. mergePair(visitor, fns);
  16585. }
  16586. function wrapCheck(wrapper, fn) {
  16587. return function () {
  16588. if (wrapper.checkPath(this)) {
  16589. return fn.apply(this, arguments);
  16590. }
  16591. };
  16592. }
  16593. function shouldIgnoreKey(key) {
  16594. // internal/hidden key
  16595. if (key[0] === "_") return true;
  16596. // ignore function keys
  16597. if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
  16598. // ignore other options
  16599. if (key === "blacklist" || key === "noScope") return true;
  16600. return false;
  16601. }
  16602. function mergePair(dest, src) {
  16603. for (var key in src) {
  16604. dest[key] = (dest[key] || []).concat(src[key]);
  16605. }
  16606. }
  16607. },{"../messages":47,"../types":169,"./path/virtual-types":162,"esquery":307}],166:[function(require,module,exports){
  16608. module.exports={
  16609. "ExpressionStatement": ["Statement"],
  16610. "BreakStatement": ["Statement", "Terminatorless"],
  16611. "ContinueStatement": ["Statement", "Terminatorless"],
  16612. "DebuggerStatement": ["Statement"],
  16613. "DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
  16614. "IfStatement": ["Statement"],
  16615. "ReturnStatement": ["Statement", "Terminatorless"],
  16616. "SwitchStatement": ["Statement", "Scopable"],
  16617. "ThrowStatement": ["Statement", "Terminatorless"],
  16618. "TryStatement": ["Statement"],
  16619. "WhileStatement": ["Statement", "Loop", "While", "Scopable"],
  16620. "WithStatement": ["Statement"],
  16621. "EmptyStatement": ["Statement"],
  16622. "LabeledStatement": ["Statement"],
  16623. "VariableDeclaration": ["Statement", "Declaration"],
  16624. "ImportSpecifier": ["ModuleSpecifier"],
  16625. "ExportSpecifier": ["ModuleSpecifier"],
  16626. "ImportDefaultSpecifier": ["ModuleSpecifier"],
  16627. "ExportDefaultSpecifier": ["ModuleSpecifier"],
  16628. "ExportNamespaceSpecifier": ["ModuleSpecifier"],
  16629. "ExportDefaultFromSpecifier": ["ModuleSpecifier"],
  16630. "ExportAllDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
  16631. "ExportDefaultDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
  16632. "ExportNamedDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
  16633. "ImportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],
  16634. "ArrowFunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
  16635. "FunctionDeclaration": ["Scopable", "Function", "Func", "Statement", "Pure", "Declaration"],
  16636. "FunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
  16637. "BlockStatement": ["Scopable", "Statement"],
  16638. "Program": ["Scopable"],
  16639. "CatchClause": ["Scopable"],
  16640. "LogicalExpression": ["Binary", "Expression"],
  16641. "BinaryExpression": ["Binary", "Expression"],
  16642. "UnaryExpression": ["UnaryLike", "Expression"],
  16643. "SpreadProperty": ["UnaryLike"],
  16644. "SpreadElement": ["UnaryLike"],
  16645. "ClassDeclaration": ["Scopable", "Class", "Pure", "Statement", "Declaration"],
  16646. "ClassExpression": ["Scopable", "Class", "Pure", "Expression"],
  16647. "ForOfStatement": ["Scopable", "Statement", "For", "Loop"],
  16648. "ForInStatement": ["Scopable", "Statement", "For", "Loop"],
  16649. "ForStatement": ["Scopable", "Statement", "For", "Loop"],
  16650. "ObjectPattern": ["Pattern"],
  16651. "ArrayPattern": ["Pattern"],
  16652. "AssignmentPattern": ["Pattern"],
  16653. "Property": ["UserWhitespacable"],
  16654. "ArrayExpression": ["Expression"],
  16655. "AssignmentExpression": ["Expression"],
  16656. "AwaitExpression": ["Expression", "Terminatorless"],
  16657. "CallExpression": ["Expression"],
  16658. "ComprehensionExpression": ["Expression", "Scopable"],
  16659. "ConditionalExpression": ["Expression"],
  16660. "DoExpression": ["Expression"],
  16661. "Identifier": ["Expression"],
  16662. "Literal": ["Expression", "Pure"],
  16663. "MemberExpression": ["Expression"],
  16664. "MetaProperty": ["Expression"],
  16665. "NewExpression": ["Expression"],
  16666. "ObjectExpression": ["Expression"],
  16667. "SequenceExpression": ["Expression"],
  16668. "TaggedTemplateExpression": ["Expression"],
  16669. "ThisExpression": ["Expression"],
  16670. "Super": ["Expression"],
  16671. "UpdateExpression": ["Expression"],
  16672. "JSXEmptyExpression": ["Expression"],
  16673. "JSXMemberExpression": ["Expression"],
  16674. "YieldExpression": ["Expression", "Terminatorless"],
  16675. "AnyTypeAnnotation": ["Flow"],
  16676. "ArrayTypeAnnotation": ["Flow"],
  16677. "BooleanTypeAnnotation": ["Flow"],
  16678. "ClassImplements": ["Flow"],
  16679. "DeclareClass": ["Flow", "Statement"],
  16680. "DeclareFunction": ["Flow", "Statement"],
  16681. "DeclareModule": ["Flow", "Statement"],
  16682. "DeclareVariable": ["Flow", "Statement"],
  16683. "FunctionTypeAnnotation": ["Flow"],
  16684. "FunctionTypeParam": ["Flow"],
  16685. "GenericTypeAnnotation": ["Flow"],
  16686. "InterfaceExtends": ["Flow"],
  16687. "InterfaceDeclaration": ["Flow", "Statement", "Declaration"],
  16688. "IntersectionTypeAnnotation": ["Flow"],
  16689. "NullableTypeAnnotation": ["Flow"],
  16690. "NumberTypeAnnotation": ["Flow"],
  16691. "StringLiteralTypeAnnotation": ["Flow"],
  16692. "StringTypeAnnotation": ["Flow"],
  16693. "TupleTypeAnnotation": ["Flow"],
  16694. "TypeofTypeAnnotation": ["Flow"],
  16695. "TypeAlias": ["Flow", "Statement"],
  16696. "TypeAnnotation": ["Flow"],
  16697. "TypeCastExpression": ["Flow"],
  16698. "TypeParameterDeclaration": ["Flow"],
  16699. "TypeParameterInstantiation": ["Flow"],
  16700. "ObjectTypeAnnotation": ["Flow"],
  16701. "ObjectTypeCallProperty": ["Flow", "UserWhitespacable"],
  16702. "ObjectTypeIndexer": ["Flow", "UserWhitespacable"],
  16703. "ObjectTypeProperty": ["Flow", "UserWhitespacable"],
  16704. "QualifiedTypeIdentifier": ["Flow"],
  16705. "UnionTypeAnnotation": ["Flow"],
  16706. "VoidTypeAnnotation": ["Flow"],
  16707. "JSXAttribute": ["JSX", "Immutable"],
  16708. "JSXClosingElement": ["JSX", "Immutable"],
  16709. "JSXElement": ["JSX", "Immutable", "Expression"],
  16710. "JSXEmptyExpression": ["JSX", "Immutable"],
  16711. "JSXExpressionContainer": ["JSX", "Immutable"],
  16712. "JSXIdentifier": ["JSX"],
  16713. "JSXMemberExpression": ["JSX"],
  16714. "JSXNamespacedName": ["JSX"],
  16715. "JSXOpeningElement": ["JSX", "Immutable"],
  16716. "JSXSpreadAttribute": ["JSX"]
  16717. }
  16718. },{}],167:[function(require,module,exports){
  16719. module.exports={
  16720. "ArrayExpression": {
  16721. "elements": null
  16722. },
  16723. "ArrowFunctionExpression": {
  16724. "params": null,
  16725. "body": null
  16726. },
  16727. "AssignmentExpression": {
  16728. "operator": null,
  16729. "left": null,
  16730. "right": null
  16731. },
  16732. "BinaryExpression": {
  16733. "operator": null,
  16734. "left": null,
  16735. "right": null
  16736. },
  16737. "BindExpression": {
  16738. "object": null,
  16739. "callee": null
  16740. },
  16741. "BlockStatement": {
  16742. "body": null
  16743. },
  16744. "CallExpression": {
  16745. "callee": null,
  16746. "arguments": null
  16747. },
  16748. "ConditionalExpression": {
  16749. "test": null,
  16750. "consequent": null,
  16751. "alternate": null
  16752. },
  16753. "ExpressionStatement": {
  16754. "expression": null
  16755. },
  16756. "File": {
  16757. "program": null,
  16758. "comments": null,
  16759. "tokens": null
  16760. },
  16761. "FunctionExpression": {
  16762. "id": null,
  16763. "params": null,
  16764. "body": null,
  16765. "generator": false,
  16766. "async": false
  16767. },
  16768. "FunctionDeclaration": {
  16769. "id": null,
  16770. "params": null,
  16771. "body": null,
  16772. "generator": false,
  16773. "async": false
  16774. },
  16775. "GenericTypeAnnotation": {
  16776. "id": null,
  16777. "typeParameters": null
  16778. },
  16779. "Identifier": {
  16780. "name": null
  16781. },
  16782. "IfStatement": {
  16783. "test": null,
  16784. "consequent": null,
  16785. "alternate": null
  16786. },
  16787. "ImportDeclaration": {
  16788. "specifiers": null,
  16789. "source": null
  16790. },
  16791. "ImportSpecifier": {
  16792. "local": null,
  16793. "imported": null
  16794. },
  16795. "LabeledStatement": {
  16796. "label": null,
  16797. "body": null
  16798. },
  16799. "Literal": {
  16800. "value": null
  16801. },
  16802. "LogicalExpression": {
  16803. "operator": null,
  16804. "left": null,
  16805. "right": null
  16806. },
  16807. "MemberExpression": {
  16808. "object": null,
  16809. "property": null,
  16810. "computed": false
  16811. },
  16812. "MethodDefinition": {
  16813. "key": null,
  16814. "value": null,
  16815. "kind": "method",
  16816. "computed": false,
  16817. "static": false
  16818. },
  16819. "NewExpression": {
  16820. "callee": null,
  16821. "arguments": null
  16822. },
  16823. "ObjectExpression": {
  16824. "properties": null
  16825. },
  16826. "Program": {
  16827. "body": null
  16828. },
  16829. "Property": {
  16830. "kind": null,
  16831. "key": null,
  16832. "value": null,
  16833. "computed": false
  16834. },
  16835. "ReturnStatement": {
  16836. "argument": null
  16837. },
  16838. "SequenceExpression": {
  16839. "expressions": null
  16840. },
  16841. "TemplateLiteral": {
  16842. "quasis": null,
  16843. "expressions": null
  16844. },
  16845. "ThrowExpression": {
  16846. "argument": null
  16847. },
  16848. "UnaryExpression": {
  16849. "operator": null,
  16850. "argument": null,
  16851. "prefix": null
  16852. },
  16853. "VariableDeclaration": {
  16854. "kind": null,
  16855. "declarations": null
  16856. },
  16857. "VariableDeclarator": {
  16858. "id": null,
  16859. "init": null
  16860. },
  16861. "WithStatement": {
  16862. "object": null,
  16863. "body": null
  16864. },
  16865. "YieldExpression": {
  16866. "argument": null,
  16867. "delegate": null
  16868. }
  16869. }
  16870. },{}],168:[function(require,module,exports){
  16871. "use strict";
  16872. exports.__esModule = true;
  16873. /**
  16874. * Description
  16875. */
  16876. exports.toComputedKey = toComputedKey;
  16877. /**
  16878. * Turn an array of statement `nodes` into a `SequenceExpression`.
  16879. *
  16880. * Variable declarations are turned into simple assignments and their
  16881. * declarations hoisted to the top of the current scope.
  16882. *
  16883. * Expression statements are just resolved to their expression.
  16884. */
  16885. exports.toSequenceExpression = toSequenceExpression;
  16886. /**
  16887. * Description
  16888. */
  16889. exports.toKeyAlias = toKeyAlias;
  16890. /*
  16891. * Description
  16892. */
  16893. exports.toIdentifier = toIdentifier;
  16894. /**
  16895. * Description
  16896. *
  16897. * @returns {Object|Boolean}
  16898. */
  16899. exports.toStatement = toStatement;
  16900. /**
  16901. * Description
  16902. */
  16903. exports.toExpression = toExpression;
  16904. /**
  16905. * Description
  16906. */
  16907. exports.toBlock = toBlock;
  16908. /**
  16909. * Description
  16910. */
  16911. exports.valueToNode = valueToNode;
  16912. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  16913. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16914. var _lodashLangIsPlainObject = require("lodash/lang/isPlainObject");
  16915. var _lodashLangIsPlainObject2 = _interopRequireDefault(_lodashLangIsPlainObject);
  16916. var _lodashLangIsNumber = require("lodash/lang/isNumber");
  16917. var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
  16918. var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
  16919. var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
  16920. var _lodashLangIsString = require("lodash/lang/isString");
  16921. var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
  16922. var _traversal = require("../traversal");
  16923. var _traversal2 = _interopRequireDefault(_traversal);
  16924. var _lodashCollectionEach = require("lodash/collection/each");
  16925. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  16926. var _index = require("./index");
  16927. var t = _interopRequireWildcard(_index);
  16928. function toComputedKey(node) {
  16929. var key = arguments[1] === undefined ? node.key || node.property : arguments[1];
  16930. return (function () {
  16931. if (!node.computed) {
  16932. if (t.isIdentifier(key)) key = t.literal(key.name);
  16933. }
  16934. return key;
  16935. })();
  16936. }
  16937. function toSequenceExpression(nodes, scope) {
  16938. var declars = [];
  16939. var bailed = false;
  16940. var result = convert(nodes);
  16941. if (bailed) return;
  16942. for (var i = 0; i < declars.length; i++) {
  16943. scope.push(declars[i]);
  16944. }
  16945. return result;
  16946. function convert(nodes) {
  16947. var ensureLastUndefined = false;
  16948. var exprs = [];
  16949. var _arr = nodes;
  16950. for (var _i = 0; _i < _arr.length; _i++) {
  16951. var node = _arr[_i];
  16952. if (t.isExpression(node)) {
  16953. exprs.push(node);
  16954. } else if (t.isExpressionStatement(node)) {
  16955. exprs.push(node.expression);
  16956. } else if (t.isVariableDeclaration(node)) {
  16957. if (node.kind !== "var") return bailed = true; // bailed
  16958. var _arr2 = node.declarations;
  16959. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  16960. var declar = _arr2[_i2];
  16961. var bindings = t.getBindingIdentifiers(declar);
  16962. for (var key in bindings) {
  16963. declars.push({
  16964. kind: node.kind,
  16965. id: bindings[key]
  16966. });
  16967. }
  16968. if (declar.init) {
  16969. exprs.push(t.assignmentExpression("=", declar.id, declar.init));
  16970. }
  16971. }
  16972. ensureLastUndefined = true;
  16973. continue;
  16974. } else if (t.isIfStatement(node)) {
  16975. var consequent = node.consequent ? convert([node.consequent]) : t.identifier("undefined");
  16976. var alternate = node.alternate ? convert([node.alternate]) : t.identifier("undefined");
  16977. if (!consequent || !alternate) return bailed = true;
  16978. exprs.push(t.conditionalExpression(node.test, consequent, alternate));
  16979. } else if (t.isBlockStatement(node)) {
  16980. exprs.push(convert(node.body));
  16981. } else {
  16982. // bailed, we can't understand this
  16983. return bailed = true;
  16984. }
  16985. ensureLastUndefined = false;
  16986. }
  16987. if (ensureLastUndefined) {
  16988. exprs.push(t.identifier("undefined"));
  16989. }
  16990. //
  16991. if (exprs.length === 1) {
  16992. return exprs[0];
  16993. } else {
  16994. return t.sequenceExpression(exprs);
  16995. }
  16996. }
  16997. }
  16998. function toKeyAlias(node) {
  16999. var key = arguments[1] === undefined ? node.key : arguments[1];
  17000. return (function () {
  17001. var alias;
  17002. if (t.isIdentifier(key)) {
  17003. alias = key.name;
  17004. } else if (t.isLiteral(key)) {
  17005. alias = JSON.stringify(key.value);
  17006. } else {
  17007. alias = JSON.stringify(_traversal2["default"].removeProperties(t.cloneDeep(key)));
  17008. }
  17009. if (node.computed) alias = "[" + alias + "]";
  17010. return alias;
  17011. })();
  17012. }
  17013. function toIdentifier(name) {
  17014. if (t.isIdentifier(name)) return name.name;
  17015. name = name + "";
  17016. // replace all non-valid identifiers with dashes
  17017. name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
  17018. // remove all dashes and numbers from start of name
  17019. name = name.replace(/^[-0-9]+/, "");
  17020. // camel case
  17021. name = name.replace(/[-\s]+(.)?/g, function (match, c) {
  17022. return c ? c.toUpperCase() : "";
  17023. });
  17024. if (!t.isValidIdentifier(name)) {
  17025. name = "_" + name;
  17026. }
  17027. return name || "_";
  17028. }
  17029. function toStatement(node, ignore) {
  17030. if (t.isStatement(node)) {
  17031. return node;
  17032. }
  17033. var mustHaveId = false;
  17034. var newType;
  17035. if (t.isClass(node)) {
  17036. mustHaveId = true;
  17037. newType = "ClassDeclaration";
  17038. } else if (t.isFunction(node)) {
  17039. mustHaveId = true;
  17040. newType = "FunctionDeclaration";
  17041. } else if (t.isAssignmentExpression(node)) {
  17042. return t.expressionStatement(node);
  17043. }
  17044. if (mustHaveId && !node.id) {
  17045. newType = false;
  17046. }
  17047. if (!newType) {
  17048. if (ignore) {
  17049. return false;
  17050. } else {
  17051. throw new Error("cannot turn " + node.type + " to a statement");
  17052. }
  17053. }
  17054. node.type = newType;
  17055. return node;
  17056. }
  17057. function toExpression(node) {
  17058. if (t.isExpressionStatement(node)) {
  17059. node = node.expression;
  17060. }
  17061. if (t.isClass(node)) {
  17062. node.type = "ClassExpression";
  17063. } else if (t.isFunction(node)) {
  17064. node.type = "FunctionExpression";
  17065. }
  17066. if (t.isExpression(node)) {
  17067. return node;
  17068. } else {
  17069. throw new Error("cannot turn " + node.type + " to an expression");
  17070. }
  17071. }
  17072. function toBlock(node, parent) {
  17073. if (t.isBlockStatement(node)) {
  17074. return node;
  17075. }
  17076. if (t.isEmptyStatement(node)) {
  17077. node = [];
  17078. }
  17079. if (!Array.isArray(node)) {
  17080. if (!t.isStatement(node)) {
  17081. if (t.isFunction(parent)) {
  17082. node = t.returnStatement(node);
  17083. } else {
  17084. node = t.expressionStatement(node);
  17085. }
  17086. }
  17087. node = [node];
  17088. }
  17089. return t.blockStatement(node);
  17090. }
  17091. function valueToNode(value) {
  17092. if (value === undefined) {
  17093. return t.identifier("undefined");
  17094. }
  17095. if (value === true || value === false || value === null || (0, _lodashLangIsString2["default"])(value) || (0, _lodashLangIsNumber2["default"])(value) || (0, _lodashLangIsRegExp2["default"])(value)) {
  17096. return t.literal(value);
  17097. }
  17098. if (Array.isArray(value)) {
  17099. return t.arrayExpression(value.map(t.valueToNode));
  17100. }
  17101. if ((0, _lodashLangIsPlainObject2["default"])(value)) {
  17102. var props = [];
  17103. for (var key in value) {
  17104. var nodeKey;
  17105. if (t.isValidIdentifier(key)) {
  17106. nodeKey = t.identifier(key);
  17107. } else {
  17108. nodeKey = t.literal(key);
  17109. }
  17110. props.push(t.property("init", nodeKey, t.valueToNode(value[key])));
  17111. }
  17112. return t.objectExpression(props);
  17113. }
  17114. throw new Error("don't know how to turn this value into a node");
  17115. }
  17116. },{"../traversal":157,"./index":169,"lodash/collection/each":330,"lodash/lang/isNumber":410,"lodash/lang/isPlainObject":412,"lodash/lang/isRegExp":413,"lodash/lang/isString":414}],169:[function(require,module,exports){
  17117. "use strict";
  17118. exports.__esModule = true;
  17119. /**
  17120. * Returns whether `node` is of given `type`.
  17121. *
  17122. * For better performance, use this instead of `is[Type]` when `type` is unknown.
  17123. * Optionally, pass `skipAliasCheck` to directly compare `node.type` with `type`.
  17124. */
  17125. exports.is = is;
  17126. exports.isType = isType;
  17127. /*
  17128. * Description
  17129. */
  17130. exports.shallowEqual = shallowEqual;
  17131. /**
  17132. * Description
  17133. */
  17134. exports.appendToMemberExpression = appendToMemberExpression;
  17135. /**
  17136. * Description
  17137. */
  17138. exports.prependToMemberExpression = prependToMemberExpression;
  17139. /**
  17140. * Description
  17141. */
  17142. exports.ensureBlock = ensureBlock;
  17143. /**
  17144. * Description
  17145. */
  17146. exports.clone = clone;
  17147. /**
  17148. * Description
  17149. */
  17150. exports.cloneDeep = cloneDeep;
  17151. /**
  17152. * Build a function that when called will return whether or not the
  17153. * input `node` `MemberExpression` matches the input `match`.
  17154. *
  17155. * For example, given the match `React.createClass` it would match the
  17156. * parsed nodes of `React.createClass` and `React["createClass"]`.
  17157. */
  17158. exports.buildMatchMemberExpression = buildMatchMemberExpression;
  17159. /**
  17160. * Description
  17161. */
  17162. exports.removeComments = removeComments;
  17163. /**
  17164. * Description
  17165. */
  17166. exports.inheritsComments = inheritsComments;
  17167. /**
  17168. * Description
  17169. */
  17170. exports.inherits = inherits;
  17171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17172. var _toFastProperties = require("to-fast-properties");
  17173. var _toFastProperties2 = _interopRequireDefault(_toFastProperties);
  17174. var _lodashArrayCompact = require("lodash/array/compact");
  17175. var _lodashArrayCompact2 = _interopRequireDefault(_lodashArrayCompact);
  17176. var _lodashObjectAssign = require("lodash/object/assign");
  17177. var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
  17178. var _lodashCollectionEach = require("lodash/collection/each");
  17179. var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
  17180. var _lodashArrayUniq = require("lodash/array/uniq");
  17181. var _lodashArrayUniq2 = _interopRequireDefault(_lodashArrayUniq);
  17182. var t = exports;
  17183. /**
  17184. * Registers `is[Type]` and `assert[Type]` generated functions for a given `type`.
  17185. * Pass `skipAliasCheck` to force it to directly compare `node.type` with `type`.
  17186. */
  17187. function registerType(type, skipAliasCheck) {
  17188. var is = t["is" + type] = function (node, opts) {
  17189. return t.is(type, node, opts, skipAliasCheck);
  17190. };
  17191. t["assert" + type] = function (node, opts) {
  17192. opts = opts || {};
  17193. if (!is(node, opts)) {
  17194. throw new Error("Expected type " + JSON.stringify(type) + " with option " + JSON.stringify(opts));
  17195. }
  17196. };
  17197. }
  17198. var STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
  17199. exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
  17200. var NATIVE_TYPE_NAMES = ["Array", "ArrayBuffer", "Boolean", "DataView", "Date", "Error", "EvalError", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Map", "Number", "Object", "Proxy", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "Symbol", "SyntaxError", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "URIError", "WeakMap", "WeakSet"];
  17201. exports.NATIVE_TYPE_NAMES = NATIVE_TYPE_NAMES;
  17202. var FLATTENABLE_KEYS = ["body", "expressions"];
  17203. exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS;
  17204. var FOR_INIT_KEYS = ["left", "init"];
  17205. exports.FOR_INIT_KEYS = FOR_INIT_KEYS;
  17206. var COMMENT_KEYS = ["leadingComments", "trailingComments"];
  17207. exports.COMMENT_KEYS = COMMENT_KEYS;
  17208. var VISITOR_KEYS = require("./visitor-keys");
  17209. exports.VISITOR_KEYS = VISITOR_KEYS;
  17210. var BUILDER_KEYS = require("./builder-keys");
  17211. exports.BUILDER_KEYS = BUILDER_KEYS;
  17212. var ALIAS_KEYS = require("./alias-keys");
  17213. exports.ALIAS_KEYS = ALIAS_KEYS;
  17214. t.FLIPPED_ALIAS_KEYS = {};
  17215. (0, _lodashCollectionEach2["default"])(t.VISITOR_KEYS, function (keys, type) {
  17216. registerType(type, true);
  17217. });
  17218. (0, _lodashCollectionEach2["default"])(t.ALIAS_KEYS, function (aliases, type) {
  17219. (0, _lodashCollectionEach2["default"])(aliases, function (alias) {
  17220. var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || [];
  17221. types.push(type);
  17222. });
  17223. });
  17224. (0, _lodashCollectionEach2["default"])(t.FLIPPED_ALIAS_KEYS, function (types, type) {
  17225. t[type.toUpperCase() + "_TYPES"] = types;
  17226. registerType(type, false);
  17227. });
  17228. var TYPES = Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS));exports.TYPES = TYPES;
  17229. function is(type, node, opts, skipAliasCheck) {
  17230. if (!node) return false;
  17231. var matches = isType(node.type, type);
  17232. if (!matches) return false;
  17233. if (typeof opts === "undefined") {
  17234. return true;
  17235. } else {
  17236. return t.shallowEqual(node, opts);
  17237. }
  17238. }
  17239. function isType(nodeType, targetType) {
  17240. if (nodeType === targetType) return true;
  17241. var aliases = t.FLIPPED_ALIAS_KEYS[targetType];
  17242. if (aliases) {
  17243. if (aliases[0] === nodeType) return true;
  17244. var _arr = aliases;
  17245. for (var _i = 0; _i < _arr.length; _i++) {
  17246. var alias = _arr[_i];
  17247. if (nodeType === alias) return true;
  17248. }
  17249. }
  17250. return false;
  17251. }
  17252. (0, _lodashCollectionEach2["default"])(t.VISITOR_KEYS, function (keys, type) {
  17253. if (t.BUILDER_KEYS[type]) return;
  17254. var defs = {};
  17255. (0, _lodashCollectionEach2["default"])(keys, function (key) {
  17256. defs[key] = null;
  17257. });
  17258. t.BUILDER_KEYS[type] = defs;
  17259. });
  17260. (0, _lodashCollectionEach2["default"])(t.BUILDER_KEYS, function (keys, type) {
  17261. t[type[0].toLowerCase() + type.slice(1)] = function () {
  17262. var node = {};
  17263. node.start = null;
  17264. node.type = type;
  17265. var i = 0;
  17266. for (var key in keys) {
  17267. var arg = arguments[i++];
  17268. if (arg === undefined) arg = keys[key];
  17269. node[key] = arg;
  17270. }
  17271. return node;
  17272. };
  17273. });
  17274. function shallowEqual(actual, expected) {
  17275. var keys = Object.keys(expected);
  17276. var _arr2 = keys;
  17277. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  17278. var key = _arr2[_i2];
  17279. if (actual[key] !== expected[key]) {
  17280. return false;
  17281. }
  17282. }
  17283. return true;
  17284. }
  17285. function appendToMemberExpression(member, append, computed) {
  17286. member.object = t.memberExpression(member.object, member.property, member.computed);
  17287. member.property = append;
  17288. member.computed = !!computed;
  17289. return member;
  17290. }
  17291. function prependToMemberExpression(member, append) {
  17292. member.object = t.memberExpression(append, member.object);
  17293. return member;
  17294. }
  17295. function ensureBlock(node) {
  17296. var key = arguments[1] === undefined ? "body" : arguments[1];
  17297. return node[key] = t.toBlock(node[key], node);
  17298. }
  17299. function clone(node) {
  17300. var newNode = {};
  17301. for (var key in node) {
  17302. if (key[0] === "_") continue;
  17303. newNode[key] = node[key];
  17304. }
  17305. return newNode;
  17306. }
  17307. function cloneDeep(node) {
  17308. var newNode = {};
  17309. for (var key in node) {
  17310. if (key[0] === "_") continue;
  17311. var val = node[key];
  17312. if (val) {
  17313. if (val.type) {
  17314. val = t.cloneDeep(val);
  17315. } else if (Array.isArray(val)) {
  17316. val = val.map(t.cloneDeep);
  17317. }
  17318. }
  17319. newNode[key] = val;
  17320. }
  17321. return newNode;
  17322. }
  17323. function buildMatchMemberExpression(match, allowPartial) {
  17324. var parts = match.split(".");
  17325. return function (member) {
  17326. // not a member expression
  17327. if (!t.isMemberExpression(member)) return false;
  17328. var search = [member];
  17329. var i = 0;
  17330. while (search.length) {
  17331. var node = search.shift();
  17332. if (allowPartial && i === parts.length) {
  17333. return true;
  17334. }
  17335. if (t.isIdentifier(node)) {
  17336. // this part doesn't match
  17337. if (parts[i] !== node.name) return false;
  17338. } else if (t.isLiteral(node)) {
  17339. // this part doesn't match
  17340. if (parts[i] !== node.value) return false;
  17341. } else if (t.isMemberExpression(node)) {
  17342. if (node.computed && !t.isLiteral(node.property)) {
  17343. // we can't deal with this
  17344. return false;
  17345. } else {
  17346. search.push(node.object);
  17347. search.push(node.property);
  17348. continue;
  17349. }
  17350. } else {
  17351. // we can't deal with this
  17352. return false;
  17353. }
  17354. // too many parts
  17355. if (++i > parts.length) {
  17356. return false;
  17357. }
  17358. }
  17359. return true;
  17360. };
  17361. }
  17362. function removeComments(child) {
  17363. var _arr3 = COMMENT_KEYS;
  17364. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  17365. var key = _arr3[_i3];
  17366. delete child[key];
  17367. }
  17368. return child;
  17369. }
  17370. function inheritsComments(child, parent) {
  17371. if (child && parent) {
  17372. var _arr4 = COMMENT_KEYS;
  17373. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  17374. var key = _arr4[_i4];
  17375. child[key] = (0, _lodashArrayUniq2["default"])((0, _lodashArrayCompact2["default"])([].concat(child[key], parent[key])));
  17376. }
  17377. }
  17378. return child;
  17379. }
  17380. function inherits(child, parent) {
  17381. if (!child || !parent) return child;
  17382. child._scopeInfo = parent._scopeInfo;
  17383. child.range = parent.range;
  17384. child.start = parent.start;
  17385. child.loc = parent.loc;
  17386. child.end = parent.end;
  17387. child.typeAnnotation = parent.typeAnnotation;
  17388. child.returnType = parent.returnType;
  17389. t.inheritsComments(child, parent);
  17390. return child;
  17391. }
  17392. (0, _toFastProperties2["default"])(t);
  17393. (0, _toFastProperties2["default"])(t.VISITOR_KEYS);
  17394. exports.__esModule = true;
  17395. (0, _lodashObjectAssign2["default"])(t, require("./retrievers"));
  17396. (0, _lodashObjectAssign2["default"])(t, require("./validators"));
  17397. (0, _lodashObjectAssign2["default"])(t, require("./converters"));
  17398. },{"./alias-keys":166,"./builder-keys":167,"./converters":168,"./retrievers":170,"./validators":171,"./visitor-keys":172,"lodash/array/compact":324,"lodash/array/uniq":328,"lodash/collection/each":330,"lodash/object/assign":417,"to-fast-properties":495}],170:[function(require,module,exports){
  17399. "use strict";
  17400. exports.__esModule = true;
  17401. /**
  17402. * Return a list of binding identifiers associated with
  17403. * the input `node`.
  17404. */
  17405. exports.getBindingIdentifiers = getBindingIdentifiers;
  17406. /**
  17407. * Description
  17408. */
  17409. exports.getLastStatements = getLastStatements;
  17410. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  17411. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17412. var _helpersObject = require("../helpers/object");
  17413. var _helpersObject2 = _interopRequireDefault(_helpersObject);
  17414. var _index = require("./index");
  17415. var t = _interopRequireWildcard(_index);
  17416. function getBindingIdentifiers(node) {
  17417. var search = [].concat(node);
  17418. var ids = (0, _helpersObject2["default"])();
  17419. while (search.length) {
  17420. var id = search.shift();
  17421. if (!id) continue;
  17422. var keys = t.getBindingIdentifiers.keys[id.type];
  17423. if (t.isIdentifier(id)) {
  17424. ids[id.name] = id;
  17425. } else if (t.isExportDeclaration(id)) {
  17426. if (t.isDeclaration(node.declaration)) {
  17427. search.push(node.declaration);
  17428. }
  17429. } else if (keys) {
  17430. var _arr = keys;
  17431. for (var _i = 0; _i < _arr.length; _i++) {
  17432. var key = _arr[_i];
  17433. search = search.concat(id[key] || []);
  17434. }
  17435. }
  17436. }
  17437. return ids;
  17438. }
  17439. getBindingIdentifiers.keys = {
  17440. UnaryExpression: ["argument"],
  17441. AssignmentExpression: ["left"],
  17442. ImportSpecifier: ["local"],
  17443. ImportNamespaceSpecifier: ["local"],
  17444. ImportDefaultSpecifier: ["local"],
  17445. VariableDeclarator: ["id"],
  17446. FunctionDeclaration: ["id"],
  17447. FunctionExpression: ["id"],
  17448. ClassDeclaration: ["id"],
  17449. ClassExpression: ["id"],
  17450. SpreadElement: ["argument"],
  17451. RestElement: ["argument"],
  17452. UpdateExpression: ["argument"],
  17453. SpreadProperty: ["argument"],
  17454. Property: ["value"],
  17455. ComprehensionBlock: ["left"],
  17456. AssignmentPattern: ["left"],
  17457. ComprehensionExpression: ["blocks"],
  17458. ImportDeclaration: ["specifiers"],
  17459. VariableDeclaration: ["declarations"],
  17460. ArrayPattern: ["elements"],
  17461. ObjectPattern: ["properties"]
  17462. };
  17463. function getLastStatements(node) {
  17464. var nodes = [];
  17465. var add = function add(node) {
  17466. nodes = nodes.concat(getLastStatements(node));
  17467. };
  17468. if (t.isIfStatement(node)) {
  17469. add(node.consequent);
  17470. add(node.alternate);
  17471. } else if (t.isFor(node) || t.isWhile(node)) {
  17472. add(node.body);
  17473. } else if (t.isProgram(node) || t.isBlockStatement(node)) {
  17474. add(node.body[node.body.length - 1]);
  17475. } else if (t.isLoop()) {} else if (node) {
  17476. nodes.push(node);
  17477. }
  17478. return nodes;
  17479. }
  17480. },{"../helpers/object":45,"./index":169}],171:[function(require,module,exports){
  17481. "use strict";
  17482. exports.__esModule = true;
  17483. /**
  17484. * Check if the input `node` is a reference to a bound variable.
  17485. */
  17486. exports.isReferenced = isReferenced;
  17487. /**
  17488. * Check if the input `node` is an `Identifier` and `isReferenced`.
  17489. */
  17490. exports.isReferencedIdentifier = isReferencedIdentifier;
  17491. /**
  17492. * Check if the input `name` is a valid identifier name
  17493. * and isn't a reserved word.
  17494. */
  17495. exports.isValidIdentifier = isValidIdentifier;
  17496. /**
  17497. * Description
  17498. */
  17499. exports.isLet = isLet;
  17500. /**
  17501. * Description
  17502. */
  17503. exports.isBlockScoped = isBlockScoped;
  17504. /**
  17505. * Description
  17506. */
  17507. exports.isVar = isVar;
  17508. /**
  17509. * Description
  17510. */
  17511. exports.isSpecifierDefault = isSpecifierDefault;
  17512. /**
  17513. * Description
  17514. */
  17515. exports.isScope = isScope;
  17516. /**
  17517. * Description
  17518. */
  17519. exports.isImmutable = isImmutable;
  17520. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  17521. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17522. var _esutils = require("esutils");
  17523. var _esutils2 = _interopRequireDefault(_esutils);
  17524. var _index = require("./index");
  17525. var t = _interopRequireWildcard(_index);
  17526. function isReferenced(node, parent) {
  17527. switch (parent.type) {
  17528. // yes: PARENT[NODE]
  17529. // yes: NODE.child
  17530. // no: parent.CHILD
  17531. case "MemberExpression":
  17532. if (parent.property === node && parent.computed) {
  17533. return true;
  17534. } else if (parent.object === node) {
  17535. return true;
  17536. } else {
  17537. return false;
  17538. }
  17539. // no: new.NODE
  17540. // no: NODE.target
  17541. case "MetaProperty":
  17542. return false;
  17543. // yes: { [NODE]: "" }
  17544. // yes: { NODE }
  17545. // no: { NODE: "" }
  17546. case "Property":
  17547. if (parent.key === node) {
  17548. return parent.computed;
  17549. }
  17550. // no: var NODE = init;
  17551. // yes: var id = NODE;
  17552. case "VariableDeclarator":
  17553. return parent.id !== node;
  17554. // no: function NODE() {}
  17555. // no: function foo(NODE) {}
  17556. case "ArrowFunctionExpression":
  17557. case "FunctionDeclaration":
  17558. case "FunctionExpression":
  17559. var _arr = parent.params;
  17560. for (var _i = 0; _i < _arr.length; _i++) {
  17561. var param = _arr[_i];
  17562. if (param === node) return false;
  17563. }
  17564. return parent.id !== node;
  17565. // no: export { foo as NODE };
  17566. // yes: export { NODE as foo };
  17567. // no: export { NODE as foo } from "foo";
  17568. case "ExportSpecifier":
  17569. if (parent.source) {
  17570. return false;
  17571. } else {
  17572. return parent.local === node;
  17573. }
  17574. // no: import NODE from "foo";
  17575. case "ImportDefaultSpecifier":
  17576. return false;
  17577. // no: import * as NODE from "foo";
  17578. case "ImportNamespaceSpecifier":
  17579. return false;
  17580. // no: import { NODE as foo } from "foo";
  17581. // no: import { foo as NODE } from "foo";
  17582. case "ImportSpecifier":
  17583. return false;
  17584. // no: class NODE {}
  17585. case "ClassDeclaration":
  17586. case "ClassExpression":
  17587. return parent.id !== node;
  17588. // yes: class { [NODE](){} }
  17589. case "MethodDefinition":
  17590. return parent.key === node && parent.computed;
  17591. // no: NODE: for (;;) {}
  17592. case "LabeledStatement":
  17593. return false;
  17594. // no: try {} catch (NODE) {}
  17595. case "CatchClause":
  17596. return parent.param !== node;
  17597. // no: function foo(...NODE) {}
  17598. case "RestElement":
  17599. return false;
  17600. // no: [NODE = foo] = [];
  17601. // yes: [foo = NODE] = [];
  17602. case "AssignmentPattern":
  17603. return parent.right === node;
  17604. // no: [NODE] = [];
  17605. // no: ({ NODE }) = [];
  17606. case "ObjectPattern":
  17607. case "ArrayPattern":
  17608. return false;
  17609. // no: import NODE from "bar";
  17610. case "ImportSpecifier":
  17611. return false;
  17612. // no: import * as NODE from "foo";
  17613. case "ImportNamespaceSpecifier":
  17614. return false;
  17615. }
  17616. return true;
  17617. }
  17618. function isReferencedIdentifier(node, parent, opts) {
  17619. return (t.isIdentifier(node, opts) || t.isJSXIdentifier(node, opts)) && t.isReferenced(node, parent);
  17620. }
  17621. function isValidIdentifier(name) {
  17622. if (typeof name !== "string" || _esutils2["default"].keyword.isReservedWordES6(name, true)) {
  17623. return false;
  17624. } else {
  17625. return _esutils2["default"].keyword.isIdentifierNameES6(name);
  17626. }
  17627. }
  17628. function isLet(node) {
  17629. return t.isVariableDeclaration(node) && (node.kind !== "var" || node._let);
  17630. }
  17631. function isBlockScoped(node) {
  17632. return t.isFunctionDeclaration(node) || t.isClassDeclaration(node) || t.isLet(node);
  17633. }
  17634. function isVar(node) {
  17635. return t.isVariableDeclaration(node, { kind: "var" }) && !node._let;
  17636. }
  17637. function isSpecifierDefault(specifier) {
  17638. return t.isImportDefaultSpecifier(specifier) || t.isExportDefaultSpecifier(specifier) || t.isIdentifier(specifier.imported || specifier.exported, { name: "default" });
  17639. }
  17640. function isScope(node, parent) {
  17641. if (t.isBlockStatement(node) && t.isFunction(parent, { body: node })) {
  17642. return false;
  17643. }
  17644. return t.isScopable(node);
  17645. }
  17646. function isImmutable(node) {
  17647. if (t.isType(node.type, "Immutable")) return true;
  17648. if (t.isLiteral(node)) {
  17649. if (node.regex) {
  17650. // regexes are mutable
  17651. return false;
  17652. } else {
  17653. // immutable!
  17654. return true;
  17655. }
  17656. } else if (t.isIdentifier(node)) {
  17657. if (node.name === "undefined") {
  17658. // immutable!
  17659. return true;
  17660. } else {
  17661. // no idea...
  17662. return false;
  17663. }
  17664. }
  17665. return false;
  17666. }
  17667. },{"./index":169,"esutils":314}],172:[function(require,module,exports){
  17668. module.exports={
  17669. "ArrayExpression": ["elements"],
  17670. "ArrayPattern": ["elements", "typeAnnotation"],
  17671. "ArrowFunctionExpression": ["params", "body", "returnType"],
  17672. "AssignmentExpression": ["left", "right"],
  17673. "AssignmentPattern": ["left", "right"],
  17674. "AwaitExpression": ["argument"],
  17675. "BinaryExpression": ["left", "right"],
  17676. "BindExpression": ["object", "callee"],
  17677. "BlockStatement": ["body"],
  17678. "BreakStatement": ["label"],
  17679. "CallExpression": ["callee", "arguments"],
  17680. "CatchClause": ["param", "body"],
  17681. "ClassBody": ["body"],
  17682. "ClassDeclaration": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
  17683. "ClassExpression": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
  17684. "ComprehensionBlock": ["left", "right", "body"],
  17685. "ComprehensionExpression": ["filter", "blocks", "body"],
  17686. "ConditionalExpression": ["test", "consequent", "alternate"],
  17687. "ContinueStatement": ["label"],
  17688. "Decorator": ["expression"],
  17689. "DebuggerStatement": [],
  17690. "DoWhileStatement": ["body", "test"],
  17691. "DoExpression": ["body"],
  17692. "EmptyStatement": [],
  17693. "ExpressionStatement": ["expression"],
  17694. "File": ["program"],
  17695. "ForInStatement": ["left", "right", "body"],
  17696. "ForOfStatement": ["left", "right", "body"],
  17697. "ForStatement": ["init", "test", "update", "body"],
  17698. "FunctionDeclaration": ["id", "params", "body", "returnType", "typeParameters"],
  17699. "FunctionExpression": ["id", "params", "body", "returnType", "typeParameters"],
  17700. "Identifier": ["typeAnnotation"],
  17701. "IfStatement": ["test", "consequent", "alternate"],
  17702. "ImportDefaultSpecifier": ["local"],
  17703. "ImportNamespaceSpecifier": ["local"],
  17704. "ImportDeclaration": ["specifiers", "source"],
  17705. "ImportSpecifier": ["imported", "local"],
  17706. "LabeledStatement": ["label", "body"],
  17707. "Literal": [],
  17708. "LogicalExpression": ["left", "right"],
  17709. "MemberExpression": ["object", "property"],
  17710. "MetaProperty": ["meta", "property"],
  17711. "MethodDefinition": ["key", "value", "decorators"],
  17712. "NewExpression": ["callee", "arguments"],
  17713. "ObjectExpression": ["properties"],
  17714. "ObjectPattern": ["properties", "typeAnnotation"],
  17715. "Program": ["body"],
  17716. "Property": ["key", "value", "decorators"],
  17717. "RestElement": ["argument", "typeAnnotation"],
  17718. "ReturnStatement": ["argument"],
  17719. "SequenceExpression": ["expressions"],
  17720. "SpreadElement": ["argument"],
  17721. "SpreadProperty": ["argument"],
  17722. "Super": [],
  17723. "SwitchCase": ["test", "consequent"],
  17724. "SwitchStatement": ["discriminant", "cases"],
  17725. "TaggedTemplateExpression": ["tag", "quasi"],
  17726. "TemplateElement": [],
  17727. "TemplateLiteral": ["quasis", "expressions"],
  17728. "ThisExpression": [],
  17729. "ThrowStatement": ["argument"],
  17730. "TryStatement": ["block", "handlers", "handler", "guardedHandlers", "finalizer"],
  17731. "UnaryExpression": ["argument"],
  17732. "UpdateExpression": ["argument"],
  17733. "VariableDeclaration": ["declarations"],
  17734. "VariableDeclarator": ["id", "init"],
  17735. "WhileStatement": ["test", "body"],
  17736. "WithStatement": ["object", "body"],
  17737. "YieldExpression": ["argument"],
  17738. "ExportAllDeclaration": ["source", "exported"],
  17739. "ExportDefaultDeclaration": ["declaration"],
  17740. "ExportNamedDeclaration": ["declaration", "specifiers", "source"],
  17741. "ExportDefaultSpecifier": ["exported"],
  17742. "ExportNamespaceSpecifier": ["exported"],
  17743. "ExportSpecifier": ["local", "exported"],
  17744. "AnyTypeAnnotation": [],
  17745. "ArrayTypeAnnotation": ["elementType"],
  17746. "BooleanTypeAnnotation": [],
  17747. "ClassImplements": ["id", "typeParameters"],
  17748. "ClassProperty": ["key", "value", "typeAnnotation", "decorators"],
  17749. "DeclareClass": ["id", "typeParameters", "extends", "body"],
  17750. "DeclareFunction": ["id"],
  17751. "DeclareModule": ["id", "body"],
  17752. "DeclareVariable": ["id"],
  17753. "FunctionTypeAnnotation": ["typeParameters", "params", "rest", "returnType"],
  17754. "FunctionTypeParam": ["name", "typeAnnotation"],
  17755. "GenericTypeAnnotation": ["id", "typeParameters"],
  17756. "InterfaceExtends": ["id", "typeParameters"],
  17757. "InterfaceDeclaration": ["id", "typeParameters", "extends", "body"],
  17758. "IntersectionTypeAnnotation": ["types"],
  17759. "NullableTypeAnnotation": ["typeAnnotation"],
  17760. "NumberTypeAnnotation": [],
  17761. "StringLiteralTypeAnnotation": [],
  17762. "StringTypeAnnotation": [],
  17763. "TupleTypeAnnotation": ["types"],
  17764. "TypeofTypeAnnotation": ["argument"],
  17765. "TypeAlias": ["id", "typeParameters", "right"],
  17766. "TypeAnnotation": ["typeAnnotation"],
  17767. "TypeCastExpression": ["expression", "typeAnnotation"],
  17768. "TypeParameterDeclaration": ["params"],
  17769. "TypeParameterInstantiation": ["params"],
  17770. "ObjectTypeAnnotation": ["properties", "indexers", "callProperties"],
  17771. "ObjectTypeCallProperty": ["value"],
  17772. "ObjectTypeIndexer": ["id", "key", "value"],
  17773. "ObjectTypeProperty": ["key", "value"],
  17774. "QualifiedTypeIdentifier": ["id", "qualification"],
  17775. "UnionTypeAnnotation": ["types"],
  17776. "VoidTypeAnnotation": [],
  17777. "JSXAttribute": ["name", "value"],
  17778. "JSXClosingElement": ["name"],
  17779. "JSXElement": ["openingElement", "closingElement", "children"],
  17780. "JSXEmptyExpression": [],
  17781. "JSXExpressionContainer": ["expression"],
  17782. "JSXIdentifier": [],
  17783. "JSXMemberExpression": ["object", "property"],
  17784. "JSXNamespacedName": ["namespace", "name"],
  17785. "JSXOpeningElement": ["name", "attributes"],
  17786. "JSXSpreadAttribute": ["argument"]
  17787. }
  17788. },{}],173:[function(require,module,exports){
  17789. (function (process,__dirname){
  17790. "use strict";
  17791. exports.__esModule = true;
  17792. exports.canCompile = canCompile;
  17793. exports.resolve = resolve;
  17794. exports.resolveRelative = resolveRelative;
  17795. exports.list = list;
  17796. exports.regexify = regexify;
  17797. exports.arrayify = arrayify;
  17798. exports.booleanify = booleanify;
  17799. exports.shouldIgnore = shouldIgnore;
  17800. //
  17801. exports.template = template;
  17802. exports.parseTemplate = parseTemplate;
  17803. 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)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
  17804. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  17805. require("./patch");
  17806. var _lodashStringEscapeRegExp = require("lodash/string/escapeRegExp");
  17807. var _lodashStringEscapeRegExp2 = _interopRequireDefault(_lodashStringEscapeRegExp);
  17808. var _lodashStringStartsWith = require("lodash/string/startsWith");
  17809. var _lodashStringStartsWith2 = _interopRequireDefault(_lodashStringStartsWith);
  17810. var _lodashLangCloneDeep = require("lodash/lang/cloneDeep");
  17811. var _lodashLangCloneDeep2 = _interopRequireDefault(_lodashLangCloneDeep);
  17812. var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
  17813. var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
  17814. var _messages = require("./messages");
  17815. var messages = _interopRequireWildcard(_messages);
  17816. var _minimatch = require("minimatch");
  17817. var _minimatch2 = _interopRequireDefault(_minimatch);
  17818. var _lodashCollectionContains = require("lodash/collection/contains");
  17819. var _lodashCollectionContains2 = _interopRequireDefault(_lodashCollectionContains);
  17820. var _traversal = require("./traversal");
  17821. var _traversal2 = _interopRequireDefault(_traversal);
  17822. var _lodashLangIsString = require("lodash/lang/isString");
  17823. var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
  17824. var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
  17825. var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
  17826. var _module2 = require("module");
  17827. var _module3 = _interopRequireDefault(_module2);
  17828. var _lodashLangIsEmpty = require("lodash/lang/isEmpty");
  17829. var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
  17830. var _helpersParse = require("./helpers/parse");
  17831. var _helpersParse2 = _interopRequireDefault(_helpersParse);
  17832. var _path = require("path");
  17833. var _path2 = _interopRequireDefault(_path);
  17834. var _lodashObjectHas = require("lodash/object/has");
  17835. var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
  17836. var _fs = require("fs");
  17837. var _fs2 = _interopRequireDefault(_fs);
  17838. var _types = require("./types");
  17839. var t = _interopRequireWildcard(_types);
  17840. var _slash = require("slash");
  17841. var _slash2 = _interopRequireDefault(_slash);
  17842. var _util = require("util");
  17843. exports.inherits = _util.inherits;
  17844. exports.inspect = _util.inspect;
  17845. function canCompile(filename, altExts) {
  17846. var exts = altExts || canCompile.EXTENSIONS;
  17847. var ext = _path2["default"].extname(filename);
  17848. return (0, _lodashCollectionContains2["default"])(exts, ext);
  17849. }
  17850. canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"];
  17851. function resolve(loc) {
  17852. try {
  17853. return require.resolve(loc);
  17854. } catch (err) {
  17855. return null;
  17856. }
  17857. }
  17858. var relativeMod;
  17859. function resolveRelative(loc) {
  17860. // we're in the browser, probably
  17861. if (typeof _module3["default"] === "object") return null;
  17862. if (!relativeMod) {
  17863. relativeMod = new _module3["default"]();
  17864. relativeMod.paths = _module3["default"]._nodeModulePaths(process.cwd());
  17865. }
  17866. try {
  17867. return _module3["default"]._resolveFilename(loc, relativeMod);
  17868. } catch (err) {
  17869. return null;
  17870. }
  17871. }
  17872. function list(val) {
  17873. if (!val) {
  17874. return [];
  17875. } else if (Array.isArray(val)) {
  17876. return val;
  17877. } else if (typeof val === "string") {
  17878. return val.split(",");
  17879. } else {
  17880. return [val];
  17881. }
  17882. }
  17883. function regexify(val) {
  17884. if (!val) return new RegExp(/.^/);
  17885. if (Array.isArray(val)) val = new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"), "i");
  17886. if ((0, _lodashLangIsString2["default"])(val)) {
  17887. // normalise path separators
  17888. val = (0, _slash2["default"])(val);
  17889. // remove starting wildcards or relative separator if present
  17890. if ((0, _lodashStringStartsWith2["default"])(val, "./") || (0, _lodashStringStartsWith2["default"])(val, "*/")) val = val.slice(2);
  17891. if ((0, _lodashStringStartsWith2["default"])(val, "**/")) val = val.slice(3);
  17892. var regex = _minimatch2["default"].makeRe(val, { nocase: true });
  17893. return new RegExp(regex.source.slice(1, -1), "i");
  17894. }
  17895. if ((0, _lodashLangIsRegExp2["default"])(val)) return val;
  17896. throw new TypeError("illegal type for regexify");
  17897. }
  17898. function arrayify(val, mapFn) {
  17899. if (!val) return [];
  17900. if ((0, _lodashLangIsBoolean2["default"])(val)) return arrayify([val], mapFn);
  17901. if ((0, _lodashLangIsString2["default"])(val)) return arrayify(list(val), mapFn);
  17902. if (Array.isArray(val)) {
  17903. if (mapFn) val = val.map(mapFn);
  17904. return val;
  17905. }
  17906. return [val];
  17907. }
  17908. function booleanify(val) {
  17909. if (val === "true") return true;
  17910. if (val === "false") return false;
  17911. return val;
  17912. }
  17913. function shouldIgnore(filename, ignore, only) {
  17914. filename = (0, _slash2["default"])(filename);
  17915. if (only.length) {
  17916. var _arr = only;
  17917. for (var _i = 0; _i < _arr.length; _i++) {
  17918. var pattern = _arr[_i];
  17919. if (pattern.test(filename)) return false;
  17920. }
  17921. return true;
  17922. } else if (ignore.length) {
  17923. var _arr2 = ignore;
  17924. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  17925. var pattern = _arr2[_i2];
  17926. if (pattern.test(filename)) return true;
  17927. }
  17928. }
  17929. return false;
  17930. }
  17931. var templateVisitor = {
  17932. enter: function enter(node, parent, scope, nodes) {
  17933. if (t.isExpressionStatement(node)) {
  17934. node = node.expression;
  17935. }
  17936. if (t.isIdentifier(node) && (0, _lodashObjectHas2["default"])(nodes, node.name)) {
  17937. this.skip();
  17938. this.replaceInline(nodes[node.name]);
  17939. }
  17940. }
  17941. };
  17942. function template(name, nodes, keepExpression) {
  17943. var ast = exports.templates[name];
  17944. if (!ast) throw new ReferenceError("unknown template " + name);
  17945. if (nodes === true) {
  17946. keepExpression = true;
  17947. nodes = null;
  17948. }
  17949. ast = (0, _lodashLangCloneDeep2["default"])(ast);
  17950. if (!(0, _lodashLangIsEmpty2["default"])(nodes)) {
  17951. (0, _traversal2["default"])(ast, templateVisitor, null, nodes);
  17952. }
  17953. if (ast.body.length > 1) return ast.body;
  17954. var node = ast.body[0];
  17955. if (!keepExpression && t.isExpressionStatement(node)) {
  17956. return node.expression;
  17957. } else {
  17958. return node;
  17959. }
  17960. }
  17961. function parseTemplate(loc, code) {
  17962. var ast = (0, _helpersParse2["default"])(code, { filename: loc, looseModules: true }).program;
  17963. ast = _traversal2["default"].removeProperties(ast);
  17964. return ast;
  17965. }
  17966. function loadTemplates() {
  17967. var templates = {};
  17968. var templatesLoc = _path2["default"].join(__dirname, "transformation/templates");
  17969. if (!_fs2["default"].existsSync(templatesLoc)) {
  17970. throw new ReferenceError(messages.get("missingTemplatesDirectory"));
  17971. }
  17972. var _arr3 = _fs2["default"].readdirSync(templatesLoc);
  17973. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  17974. var name = _arr3[_i3];
  17975. if (name[0] === ".") return;
  17976. var key = _path2["default"].basename(name, _path2["default"].extname(name));
  17977. var loc = _path2["default"].join(templatesLoc, name);
  17978. var code = _fs2["default"].readFileSync(loc, "utf8");
  17979. templates[key] = parseTemplate(loc, code);
  17980. }
  17981. return templates;
  17982. }
  17983. try {
  17984. exports.templates = require("../../templates.json");
  17985. } catch (err) {
  17986. if (err.code !== "MODULE_NOT_FOUND") throw err;
  17987. exports.templates = loadTemplates();
  17988. }
  17989. }).call(this,require('_process'),"/lib/babel")
  17990. },{"../../templates.json":498,"./helpers/parse":46,"./messages":47,"./patch":48,"./traversal":157,"./types":169,"_process":200,"fs":189,"lodash/collection/contains":329,"lodash/lang/cloneDeep":403,"lodash/lang/isBoolean":406,"lodash/lang/isEmpty":407,"lodash/lang/isRegExp":413,"lodash/lang/isString":414,"lodash/object/has":420,"lodash/string/escapeRegExp":425,"lodash/string/startsWith":426,"minimatch":430,"module":189,"path":199,"slash":482,"util":216}],174:[function(require,module,exports){
  17991. 'use strict';
  17992. module.exports = function(acorn) {
  17993. var tt = acorn.tokTypes;
  17994. var tc = acorn.tokContexts;
  17995. tc.j_oTag = new acorn.TokContext('<tag', false);
  17996. tc.j_cTag = new acorn.TokContext('</tag', false);
  17997. tc.j_expr = new acorn.TokContext('<tag>...</tag>', true, true);
  17998. tt.jsxName = new acorn.TokenType('jsxName');
  17999. tt.jsxText = new acorn.TokenType('jsxText', {beforeExpr: true});
  18000. tt.jsxTagStart = new acorn.TokenType('jsxTagStart');
  18001. tt.jsxTagEnd = new acorn.TokenType('jsxTagEnd');
  18002. tt.jsxTagStart.updateContext = function() {
  18003. this.context.push(tc.j_expr); // treat as beginning of JSX expression
  18004. this.context.push(tc.j_oTag); // start opening tag context
  18005. this.exprAllowed = false;
  18006. };
  18007. tt.jsxTagEnd.updateContext = function(prevType) {
  18008. var out = this.context.pop();
  18009. if (out === tc.j_oTag && prevType === tt.slash || out === tc.j_cTag) {
  18010. this.context.pop();
  18011. this.exprAllowed = this.curContext() === tc.j_expr;
  18012. } else {
  18013. this.exprAllowed = true;
  18014. }
  18015. };
  18016. var pp = acorn.Parser.prototype;
  18017. // Reads inline JSX contents token.
  18018. pp.jsx_readToken = function() {
  18019. var out = '', chunkStart = this.pos;
  18020. for (;;) {
  18021. if (this.pos >= this.input.length)
  18022. this.raise(this.start, 'Unterminated JSX contents');
  18023. var ch = this.input.charCodeAt(this.pos);
  18024. switch (ch) {
  18025. case 60: // '<'
  18026. case 123: // '{'
  18027. if (this.pos === this.start) {
  18028. if (ch === 60 && this.exprAllowed) {
  18029. ++this.pos;
  18030. return this.finishToken(tt.jsxTagStart);
  18031. }
  18032. return this.getTokenFromCode(ch);
  18033. }
  18034. out += this.input.slice(chunkStart, this.pos);
  18035. return this.finishToken(tt.jsxText, out);
  18036. case 38: // '&'
  18037. out += this.input.slice(chunkStart, this.pos);
  18038. out += this.jsx_readEntity();
  18039. chunkStart = this.pos;
  18040. break;
  18041. default:
  18042. if (acorn.isNewLine(ch)) {
  18043. out += this.input.slice(chunkStart, this.pos);
  18044. ++this.pos;
  18045. if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
  18046. ++this.pos;
  18047. out += '\n';
  18048. } else {
  18049. out += String.fromCharCode(ch);
  18050. }
  18051. if (this.options.locations) {
  18052. ++this.curLine;
  18053. this.lineStart = this.pos;
  18054. }
  18055. chunkStart = this.pos;
  18056. } else {
  18057. ++this.pos;
  18058. }
  18059. }
  18060. }
  18061. };
  18062. pp.jsx_readString = function(quote) {
  18063. var out = '', chunkStart = ++this.pos;
  18064. for (;;) {
  18065. if (this.pos >= this.input.length)
  18066. this.raise(this.start, 'Unterminated string constant');
  18067. var ch = this.input.charCodeAt(this.pos);
  18068. if (ch === quote) break;
  18069. if (ch === 38) { // '&'
  18070. out += this.input.slice(chunkStart, this.pos);
  18071. out += this.jsx_readEntity();
  18072. chunkStart = this.pos;
  18073. } else {
  18074. ++this.pos;
  18075. }
  18076. }
  18077. out += this.input.slice(chunkStart, this.pos++);
  18078. return this.finishToken(tt.string, out);
  18079. };
  18080. var XHTMLEntities = {
  18081. quot: '\u0022',
  18082. amp: '&',
  18083. apos: '\u0027',
  18084. lt: '<',
  18085. gt: '>',
  18086. nbsp: '\u00A0',
  18087. iexcl: '\u00A1',
  18088. cent: '\u00A2',
  18089. pound: '\u00A3',
  18090. curren: '\u00A4',
  18091. yen: '\u00A5',
  18092. brvbar: '\u00A6',
  18093. sect: '\u00A7',
  18094. uml: '\u00A8',
  18095. copy: '\u00A9',
  18096. ordf: '\u00AA',
  18097. laquo: '\u00AB',
  18098. not: '\u00AC',
  18099. shy: '\u00AD',
  18100. reg: '\u00AE',
  18101. macr: '\u00AF',
  18102. deg: '\u00B0',
  18103. plusmn: '\u00B1',
  18104. sup2: '\u00B2',
  18105. sup3: '\u00B3',
  18106. acute: '\u00B4',
  18107. micro: '\u00B5',
  18108. para: '\u00B6',
  18109. middot: '\u00B7',
  18110. cedil: '\u00B8',
  18111. sup1: '\u00B9',
  18112. ordm: '\u00BA',
  18113. raquo: '\u00BB',
  18114. frac14: '\u00BC',
  18115. frac12: '\u00BD',
  18116. frac34: '\u00BE',
  18117. iquest: '\u00BF',
  18118. Agrave: '\u00C0',
  18119. Aacute: '\u00C1',
  18120. Acirc: '\u00C2',
  18121. Atilde: '\u00C3',
  18122. Auml: '\u00C4',
  18123. Aring: '\u00C5',
  18124. AElig: '\u00C6',
  18125. Ccedil: '\u00C7',
  18126. Egrave: '\u00C8',
  18127. Eacute: '\u00C9',
  18128. Ecirc: '\u00CA',
  18129. Euml: '\u00CB',
  18130. Igrave: '\u00CC',
  18131. Iacute: '\u00CD',
  18132. Icirc: '\u00CE',
  18133. Iuml: '\u00CF',
  18134. ETH: '\u00D0',
  18135. Ntilde: '\u00D1',
  18136. Ograve: '\u00D2',
  18137. Oacute: '\u00D3',
  18138. Ocirc: '\u00D4',
  18139. Otilde: '\u00D5',
  18140. Ouml: '\u00D6',
  18141. times: '\u00D7',
  18142. Oslash: '\u00D8',
  18143. Ugrave: '\u00D9',
  18144. Uacute: '\u00DA',
  18145. Ucirc: '\u00DB',
  18146. Uuml: '\u00DC',
  18147. Yacute: '\u00DD',
  18148. THORN: '\u00DE',
  18149. szlig: '\u00DF',
  18150. agrave: '\u00E0',
  18151. aacute: '\u00E1',
  18152. acirc: '\u00E2',
  18153. atilde: '\u00E3',
  18154. auml: '\u00E4',
  18155. aring: '\u00E5',
  18156. aelig: '\u00E6',
  18157. ccedil: '\u00E7',
  18158. egrave: '\u00E8',
  18159. eacute: '\u00E9',
  18160. ecirc: '\u00EA',
  18161. euml: '\u00EB',
  18162. igrave: '\u00EC',
  18163. iacute: '\u00ED',
  18164. icirc: '\u00EE',
  18165. iuml: '\u00EF',
  18166. eth: '\u00F0',
  18167. ntilde: '\u00F1',
  18168. ograve: '\u00F2',
  18169. oacute: '\u00F3',
  18170. ocirc: '\u00F4',
  18171. otilde: '\u00F5',
  18172. ouml: '\u00F6',
  18173. divide: '\u00F7',
  18174. oslash: '\u00F8',
  18175. ugrave: '\u00F9',
  18176. uacute: '\u00FA',
  18177. ucirc: '\u00FB',
  18178. uuml: '\u00FC',
  18179. yacute: '\u00FD',
  18180. thorn: '\u00FE',
  18181. yuml: '\u00FF',
  18182. OElig: '\u0152',
  18183. oelig: '\u0153',
  18184. Scaron: '\u0160',
  18185. scaron: '\u0161',
  18186. Yuml: '\u0178',
  18187. fnof: '\u0192',
  18188. circ: '\u02C6',
  18189. tilde: '\u02DC',
  18190. Alpha: '\u0391',
  18191. Beta: '\u0392',
  18192. Gamma: '\u0393',
  18193. Delta: '\u0394',
  18194. Epsilon: '\u0395',
  18195. Zeta: '\u0396',
  18196. Eta: '\u0397',
  18197. Theta: '\u0398',
  18198. Iota: '\u0399',
  18199. Kappa: '\u039A',
  18200. Lambda: '\u039B',
  18201. Mu: '\u039C',
  18202. Nu: '\u039D',
  18203. Xi: '\u039E',
  18204. Omicron: '\u039F',
  18205. Pi: '\u03A0',
  18206. Rho: '\u03A1',
  18207. Sigma: '\u03A3',
  18208. Tau: '\u03A4',
  18209. Upsilon: '\u03A5',
  18210. Phi: '\u03A6',
  18211. Chi: '\u03A7',
  18212. Psi: '\u03A8',
  18213. Omega: '\u03A9',
  18214. alpha: '\u03B1',
  18215. beta: '\u03B2',
  18216. gamma: '\u03B3',
  18217. delta: '\u03B4',
  18218. epsilon: '\u03B5',
  18219. zeta: '\u03B6',
  18220. eta: '\u03B7',
  18221. theta: '\u03B8',
  18222. iota: '\u03B9',
  18223. kappa: '\u03BA',
  18224. lambda: '\u03BB',
  18225. mu: '\u03BC',
  18226. nu: '\u03BD',
  18227. xi: '\u03BE',
  18228. omicron: '\u03BF',
  18229. pi: '\u03C0',
  18230. rho: '\u03C1',
  18231. sigmaf: '\u03C2',
  18232. sigma: '\u03C3',
  18233. tau: '\u03C4',
  18234. upsilon: '\u03C5',
  18235. phi: '\u03C6',
  18236. chi: '\u03C7',
  18237. psi: '\u03C8',
  18238. omega: '\u03C9',
  18239. thetasym: '\u03D1',
  18240. upsih: '\u03D2',
  18241. piv: '\u03D6',
  18242. ensp: '\u2002',
  18243. emsp: '\u2003',
  18244. thinsp: '\u2009',
  18245. zwnj: '\u200C',
  18246. zwj: '\u200D',
  18247. lrm: '\u200E',
  18248. rlm: '\u200F',
  18249. ndash: '\u2013',
  18250. mdash: '\u2014',
  18251. lsquo: '\u2018',
  18252. rsquo: '\u2019',
  18253. sbquo: '\u201A',
  18254. ldquo: '\u201C',
  18255. rdquo: '\u201D',
  18256. bdquo: '\u201E',
  18257. dagger: '\u2020',
  18258. Dagger: '\u2021',
  18259. bull: '\u2022',
  18260. hellip: '\u2026',
  18261. permil: '\u2030',
  18262. prime: '\u2032',
  18263. Prime: '\u2033',
  18264. lsaquo: '\u2039',
  18265. rsaquo: '\u203A',
  18266. oline: '\u203E',
  18267. frasl: '\u2044',
  18268. euro: '\u20AC',
  18269. image: '\u2111',
  18270. weierp: '\u2118',
  18271. real: '\u211C',
  18272. trade: '\u2122',
  18273. alefsym: '\u2135',
  18274. larr: '\u2190',
  18275. uarr: '\u2191',
  18276. rarr: '\u2192',
  18277. darr: '\u2193',
  18278. harr: '\u2194',
  18279. crarr: '\u21B5',
  18280. lArr: '\u21D0',
  18281. uArr: '\u21D1',
  18282. rArr: '\u21D2',
  18283. dArr: '\u21D3',
  18284. hArr: '\u21D4',
  18285. forall: '\u2200',
  18286. part: '\u2202',
  18287. exist: '\u2203',
  18288. empty: '\u2205',
  18289. nabla: '\u2207',
  18290. isin: '\u2208',
  18291. notin: '\u2209',
  18292. ni: '\u220B',
  18293. prod: '\u220F',
  18294. sum: '\u2211',
  18295. minus: '\u2212',
  18296. lowast: '\u2217',
  18297. radic: '\u221A',
  18298. prop: '\u221D',
  18299. infin: '\u221E',
  18300. ang: '\u2220',
  18301. and: '\u2227',
  18302. or: '\u2228',
  18303. cap: '\u2229',
  18304. cup: '\u222A',
  18305. 'int': '\u222B',
  18306. there4: '\u2234',
  18307. sim: '\u223C',
  18308. cong: '\u2245',
  18309. asymp: '\u2248',
  18310. ne: '\u2260',
  18311. equiv: '\u2261',
  18312. le: '\u2264',
  18313. ge: '\u2265',
  18314. sub: '\u2282',
  18315. sup: '\u2283',
  18316. nsub: '\u2284',
  18317. sube: '\u2286',
  18318. supe: '\u2287',
  18319. oplus: '\u2295',
  18320. otimes: '\u2297',
  18321. perp: '\u22A5',
  18322. sdot: '\u22C5',
  18323. lceil: '\u2308',
  18324. rceil: '\u2309',
  18325. lfloor: '\u230A',
  18326. rfloor: '\u230B',
  18327. lang: '\u2329',
  18328. rang: '\u232A',
  18329. loz: '\u25CA',
  18330. spades: '\u2660',
  18331. clubs: '\u2663',
  18332. hearts: '\u2665',
  18333. diams: '\u2666'
  18334. };
  18335. var hexNumber = /^[\da-fA-F]+$/;
  18336. var decimalNumber = /^\d+$/;
  18337. pp.jsx_readEntity = function() {
  18338. var str = '', count = 0, entity;
  18339. var ch = this.input[this.pos];
  18340. if (ch !== '&')
  18341. this.raise(this.pos, 'Entity must start with an ampersand');
  18342. var startPos = ++this.pos;
  18343. while (this.pos < this.input.length && count++ < 10) {
  18344. ch = this.input[this.pos++];
  18345. if (ch === ';') {
  18346. if (str[0] === '#') {
  18347. if (str[1] === 'x') {
  18348. str = str.substr(2);
  18349. if (hexNumber.test(str))
  18350. entity = String.fromCharCode(parseInt(str, 16));
  18351. } else {
  18352. str = str.substr(1);
  18353. if (decimalNumber.test(str))
  18354. entity = String.fromCharCode(parseInt(str, 10));
  18355. }
  18356. } else {
  18357. entity = XHTMLEntities[str];
  18358. }
  18359. break;
  18360. }
  18361. str += ch;
  18362. }
  18363. if (!entity) {
  18364. this.pos = startPos;
  18365. return '&';
  18366. }
  18367. return entity;
  18368. };
  18369. // Read a JSX identifier (valid tag or attribute name).
  18370. //
  18371. // Optimized version since JSX identifiers can't contain
  18372. // escape characters and so can be read as single slice.
  18373. // Also assumes that first character was already checked
  18374. // by isIdentifierStart in readToken.
  18375. pp.jsx_readWord = function() {
  18376. var ch, start = this.pos;
  18377. do {
  18378. ch = this.input.charCodeAt(++this.pos);
  18379. } while (acorn.isIdentifierChar(ch) || ch === 45); // '-'
  18380. return this.finishToken(tt.jsxName, this.input.slice(start, this.pos));
  18381. };
  18382. // Transforms JSX element name to string.
  18383. function getQualifiedJSXName(object) {
  18384. if (object.type === 'JSXIdentifier')
  18385. return object.name;
  18386. if (object.type === 'JSXNamespacedName')
  18387. return object.namespace.name + ':' + object.name.name;
  18388. if (object.type === 'JSXMemberExpression')
  18389. return getQualifiedJSXName(object.object) + '.' +
  18390. getQualifiedJSXName(object.property);
  18391. }
  18392. // Parse next token as JSX identifier
  18393. pp.jsx_parseIdentifier = function() {
  18394. var node = this.startNode();
  18395. if (this.type === tt.jsxName)
  18396. node.name = this.value;
  18397. else if (this.type.keyword)
  18398. node.name = this.type.keyword;
  18399. else
  18400. this.unexpected();
  18401. this.next();
  18402. return this.finishNode(node, 'JSXIdentifier');
  18403. };
  18404. // Parse namespaced identifier.
  18405. pp.jsx_parseNamespacedName = function() {
  18406. var start = this.markPosition();
  18407. var name = this.jsx_parseIdentifier();
  18408. if (!this.eat(tt.colon)) return name;
  18409. var node = this.startNodeAt(start);
  18410. node.namespace = name;
  18411. node.name = this.jsx_parseIdentifier();
  18412. return this.finishNode(node, 'JSXNamespacedName');
  18413. };
  18414. // Parses element name in any form - namespaced, member
  18415. // or single identifier.
  18416. pp.jsx_parseElementName = function() {
  18417. var start = this.markPosition();
  18418. var node = this.jsx_parseNamespacedName();
  18419. while (this.eat(tt.dot)) {
  18420. var newNode = this.startNodeAt(start);
  18421. newNode.object = node;
  18422. newNode.property = this.jsx_parseIdentifier();
  18423. node = this.finishNode(newNode, 'JSXMemberExpression');
  18424. }
  18425. return node;
  18426. };
  18427. // Parses any type of JSX attribute value.
  18428. pp.jsx_parseAttributeValue = function() {
  18429. switch (this.type) {
  18430. case tt.braceL:
  18431. var node = this.jsx_parseExpressionContainer();
  18432. if (node.expression.type === 'JSXEmptyExpression')
  18433. this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
  18434. return node;
  18435. case tt.jsxTagStart:
  18436. case tt.string:
  18437. return this.parseExprAtom();
  18438. default:
  18439. this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
  18440. }
  18441. };
  18442. // JSXEmptyExpression is unique type since it doesn't actually parse anything,
  18443. // and so it should start at the end of last read token (left brace) and finish
  18444. // at the beginning of the next one (right brace).
  18445. pp.jsx_parseEmptyExpression = function() {
  18446. var tmp = this.start;
  18447. this.start = this.lastTokEnd;
  18448. this.lastTokEnd = tmp;
  18449. tmp = this.startLoc;
  18450. this.startLoc = this.lastTokEndLoc;
  18451. this.lastTokEndLoc = tmp;
  18452. return this.finishNode(this.startNode(), 'JSXEmptyExpression');
  18453. };
  18454. // Parses JSX expression enclosed into curly brackets.
  18455. pp.jsx_parseExpressionContainer = function() {
  18456. var node = this.startNode();
  18457. this.next();
  18458. node.expression = this.type === tt.braceR
  18459. ? this.jsx_parseEmptyExpression()
  18460. : this.parseExpression();
  18461. this.expect(tt.braceR);
  18462. return this.finishNode(node, 'JSXExpressionContainer');
  18463. };
  18464. // Parses following JSX attribute name-value pair.
  18465. pp.jsx_parseAttribute = function() {
  18466. var node = this.startNode();
  18467. if (this.eat(tt.braceL)) {
  18468. this.expect(tt.ellipsis);
  18469. node.argument = this.parseMaybeAssign();
  18470. this.expect(tt.braceR);
  18471. return this.finishNode(node, 'JSXSpreadAttribute');
  18472. }
  18473. node.name = this.jsx_parseNamespacedName();
  18474. node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
  18475. return this.finishNode(node, 'JSXAttribute');
  18476. };
  18477. // Parses JSX opening tag starting after '<'.
  18478. pp.jsx_parseOpeningElementAt = function(start) {
  18479. var node = this.startNodeAt(start);
  18480. node.attributes = [];
  18481. node.name = this.jsx_parseElementName();
  18482. while (this.type !== tt.slash && this.type !== tt.jsxTagEnd)
  18483. node.attributes.push(this.jsx_parseAttribute());
  18484. node.selfClosing = this.eat(tt.slash);
  18485. this.expect(tt.jsxTagEnd);
  18486. return this.finishNode(node, 'JSXOpeningElement');
  18487. };
  18488. // Parses JSX closing tag starting after '</'.
  18489. pp.jsx_parseClosingElementAt = function(start) {
  18490. var node = this.startNodeAt(start);
  18491. node.name = this.jsx_parseElementName();
  18492. this.expect(tt.jsxTagEnd);
  18493. return this.finishNode(node, 'JSXClosingElement');
  18494. };
  18495. // Parses entire JSX element, including it's opening tag
  18496. // (starting after '<'), attributes, contents and closing tag.
  18497. pp.jsx_parseElementAt = function(start) {
  18498. var node = this.startNodeAt(start);
  18499. var children = [];
  18500. var openingElement = this.jsx_parseOpeningElementAt(start);
  18501. var closingElement = null;
  18502. if (!openingElement.selfClosing) {
  18503. contents: for (;;) {
  18504. switch (this.type) {
  18505. case tt.jsxTagStart:
  18506. start = this.markPosition();
  18507. this.next();
  18508. if (this.eat(tt.slash)) {
  18509. closingElement = this.jsx_parseClosingElementAt(start);
  18510. break contents;
  18511. }
  18512. children.push(this.jsx_parseElementAt(start));
  18513. break;
  18514. case tt.jsxText:
  18515. children.push(this.parseExprAtom());
  18516. break;
  18517. case tt.braceL:
  18518. children.push(this.jsx_parseExpressionContainer());
  18519. break;
  18520. default:
  18521. this.unexpected();
  18522. }
  18523. }
  18524. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name))
  18525. this.raise(
  18526. closingElement.start,
  18527. 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
  18528. }
  18529. node.openingElement = openingElement;
  18530. node.closingElement = closingElement;
  18531. node.children = children;
  18532. return this.finishNode(node, 'JSXElement');
  18533. };
  18534. // Parses entire JSX element from current position.
  18535. pp.jsx_parseElement = function() {
  18536. var start = this.markPosition();
  18537. this.next();
  18538. return this.jsx_parseElementAt(start);
  18539. };
  18540. acorn.plugins.jsx = function(instance) {
  18541. instance.extend('parseExprAtom', function(inner) {
  18542. return function(refShortHandDefaultPos) {
  18543. if (this.type === tt.jsxText)
  18544. return this.parseLiteral(this.value);
  18545. else if (this.type === tt.jsxTagStart)
  18546. return this.jsx_parseElement();
  18547. else
  18548. return inner.call(this, refShortHandDefaultPos);
  18549. };
  18550. });
  18551. instance.extend('readToken', function(inner) {
  18552. return function(code) {
  18553. var context = this.curContext();
  18554. if (context === tc.j_expr) return this.jsx_readToken();
  18555. if (context === tc.j_oTag || context === tc.j_cTag) {
  18556. if (acorn.isIdentifierStart(code)) return this.jsx_readWord();
  18557. if (code == 62) {
  18558. ++this.pos;
  18559. return this.finishToken(tt.jsxTagEnd);
  18560. }
  18561. if ((code === 34 || code === 39) && context == tc.j_oTag)
  18562. return this.jsx_readString(code);
  18563. }
  18564. if (code === 60 && this.exprAllowed) {
  18565. ++this.pos;
  18566. return this.finishToken(tt.jsxTagStart);
  18567. }
  18568. return inner.call(this, code);
  18569. };
  18570. });
  18571. instance.extend('updateContext', function(inner) {
  18572. return function(prevType) {
  18573. if (this.type == tt.braceL) {
  18574. var curContext = this.curContext();
  18575. if (curContext == tc.j_oTag) this.context.push(tc.b_expr);
  18576. else if (curContext == tc.j_expr) this.context.push(tc.b_tmpl);
  18577. else inner.call(this, prevType);
  18578. this.exprAllowed = true;
  18579. } else if (this.type === tt.slash && prevType === tt.jsxTagStart) {
  18580. this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
  18581. this.context.push(tc.j_cTag); // reconsider as closing tag context
  18582. this.exprAllowed = false;
  18583. } else {
  18584. return inner.call(this, prevType);
  18585. }
  18586. };
  18587. });
  18588. };
  18589. return acorn;
  18590. };
  18591. },{}],175:[function(require,module,exports){
  18592. var types = require("../lib/types");
  18593. var Type = types.Type;
  18594. var def = Type.def;
  18595. var or = Type.or;
  18596. var builtin = types.builtInTypes;
  18597. var isString = builtin.string;
  18598. var isNumber = builtin.number;
  18599. var isBoolean = builtin.boolean;
  18600. var isRegExp = builtin.RegExp;
  18601. var shared = require("../lib/shared");
  18602. var defaults = shared.defaults;
  18603. var geq = shared.geq;
  18604. // Abstract supertype of all syntactic entities that are allowed to have a
  18605. // .loc field.
  18606. def("Printable")
  18607. .field("loc", or(
  18608. def("SourceLocation"),
  18609. null
  18610. ), defaults["null"], true);
  18611. def("Node")
  18612. .bases("Printable")
  18613. .field("type", isString)
  18614. .field("comments", or(
  18615. [def("Comment")],
  18616. null
  18617. ), defaults["null"], true);
  18618. def("SourceLocation")
  18619. .build("start", "end", "source")
  18620. .field("start", def("Position"))
  18621. .field("end", def("Position"))
  18622. .field("source", or(isString, null), defaults["null"]);
  18623. def("Position")
  18624. .build("line", "column")
  18625. .field("line", geq(1))
  18626. .field("column", geq(0));
  18627. def("Program")
  18628. .bases("Node")
  18629. .build("body")
  18630. .field("body", [def("Statement")]);
  18631. def("Function")
  18632. .bases("Node")
  18633. .field("id", or(def("Identifier"), null), defaults["null"])
  18634. .field("params", [def("Pattern")])
  18635. .field("body", def("BlockStatement"));
  18636. def("Statement").bases("Node");
  18637. // The empty .build() here means that an EmptyStatement can be constructed
  18638. // (i.e. it's not abstract) but that it needs no arguments.
  18639. def("EmptyStatement").bases("Statement").build();
  18640. def("BlockStatement")
  18641. .bases("Statement")
  18642. .build("body")
  18643. .field("body", [def("Statement")]);
  18644. // TODO Figure out how to silently coerce Expressions to
  18645. // ExpressionStatements where a Statement was expected.
  18646. def("ExpressionStatement")
  18647. .bases("Statement")
  18648. .build("expression")
  18649. .field("expression", def("Expression"));
  18650. def("IfStatement")
  18651. .bases("Statement")
  18652. .build("test", "consequent", "alternate")
  18653. .field("test", def("Expression"))
  18654. .field("consequent", def("Statement"))
  18655. .field("alternate", or(def("Statement"), null), defaults["null"]);
  18656. def("LabeledStatement")
  18657. .bases("Statement")
  18658. .build("label", "body")
  18659. .field("label", def("Identifier"))
  18660. .field("body", def("Statement"));
  18661. def("BreakStatement")
  18662. .bases("Statement")
  18663. .build("label")
  18664. .field("label", or(def("Identifier"), null), defaults["null"]);
  18665. def("ContinueStatement")
  18666. .bases("Statement")
  18667. .build("label")
  18668. .field("label", or(def("Identifier"), null), defaults["null"]);
  18669. def("WithStatement")
  18670. .bases("Statement")
  18671. .build("object", "body")
  18672. .field("object", def("Expression"))
  18673. .field("body", def("Statement"));
  18674. def("SwitchStatement")
  18675. .bases("Statement")
  18676. .build("discriminant", "cases", "lexical")
  18677. .field("discriminant", def("Expression"))
  18678. .field("cases", [def("SwitchCase")])
  18679. .field("lexical", isBoolean, defaults["false"]);
  18680. def("ReturnStatement")
  18681. .bases("Statement")
  18682. .build("argument")
  18683. .field("argument", or(def("Expression"), null));
  18684. def("ThrowStatement")
  18685. .bases("Statement")
  18686. .build("argument")
  18687. .field("argument", def("Expression"));
  18688. def("TryStatement")
  18689. .bases("Statement")
  18690. .build("block", "handler", "finalizer")
  18691. .field("block", def("BlockStatement"))
  18692. .field("handler", or(def("CatchClause"), null), function() {
  18693. return this.handlers && this.handlers[0] || null;
  18694. })
  18695. .field("handlers", [def("CatchClause")], function() {
  18696. return this.handler ? [this.handler] : [];
  18697. }, true) // Indicates this field is hidden from eachField iteration.
  18698. .field("guardedHandlers", [def("CatchClause")], defaults.emptyArray)
  18699. .field("finalizer", or(def("BlockStatement"), null), defaults["null"]);
  18700. def("CatchClause")
  18701. .bases("Node")
  18702. .build("param", "guard", "body")
  18703. .field("param", def("Pattern"))
  18704. .field("guard", or(def("Expression"), null), defaults["null"])
  18705. .field("body", def("BlockStatement"));
  18706. def("WhileStatement")
  18707. .bases("Statement")
  18708. .build("test", "body")
  18709. .field("test", def("Expression"))
  18710. .field("body", def("Statement"));
  18711. def("DoWhileStatement")
  18712. .bases("Statement")
  18713. .build("body", "test")
  18714. .field("body", def("Statement"))
  18715. .field("test", def("Expression"));
  18716. def("ForStatement")
  18717. .bases("Statement")
  18718. .build("init", "test", "update", "body")
  18719. .field("init", or(
  18720. def("VariableDeclaration"),
  18721. def("Expression"),
  18722. null))
  18723. .field("test", or(def("Expression"), null))
  18724. .field("update", or(def("Expression"), null))
  18725. .field("body", def("Statement"));
  18726. def("ForInStatement")
  18727. .bases("Statement")
  18728. .build("left", "right", "body", "each")
  18729. .field("left", or(
  18730. def("VariableDeclaration"),
  18731. def("Expression")))
  18732. .field("right", def("Expression"))
  18733. .field("body", def("Statement"))
  18734. .field("each", isBoolean);
  18735. def("DebuggerStatement").bases("Statement").build();
  18736. def("Declaration").bases("Statement");
  18737. def("FunctionDeclaration")
  18738. .bases("Function", "Declaration")
  18739. .build("id", "params", "body")
  18740. .field("id", def("Identifier"));
  18741. def("FunctionExpression")
  18742. .bases("Function", "Expression")
  18743. .build("id", "params", "body");
  18744. def("VariableDeclaration")
  18745. .bases("Declaration")
  18746. .build("kind", "declarations")
  18747. .field("kind", or("var", "let", "const"))
  18748. .field("declarations", [or(
  18749. def("VariableDeclarator"),
  18750. def("Identifier") // TODO Esprima deviation.
  18751. )]);
  18752. def("VariableDeclarator")
  18753. .bases("Node")
  18754. .build("id", "init")
  18755. .field("id", def("Pattern"))
  18756. .field("init", or(def("Expression"), null));
  18757. // TODO Are all Expressions really Patterns?
  18758. def("Expression").bases("Node", "Pattern");
  18759. def("ThisExpression").bases("Expression").build();
  18760. def("ArrayExpression")
  18761. .bases("Expression")
  18762. .build("elements")
  18763. .field("elements", [or(def("Expression"), null)]);
  18764. def("ObjectExpression")
  18765. .bases("Expression")
  18766. .build("properties")
  18767. .field("properties", [def("Property")]);
  18768. // TODO Not in the Mozilla Parser API, but used by Esprima.
  18769. def("Property")
  18770. .bases("Node") // Want to be able to visit Property Nodes.
  18771. .build("kind", "key", "value")
  18772. .field("kind", or("init", "get", "set"))
  18773. .field("key", or(def("Literal"), def("Identifier")))
  18774. // esprima allows Pattern
  18775. .field("value", or(def("Expression"), def("Pattern")));
  18776. def("SequenceExpression")
  18777. .bases("Expression")
  18778. .build("expressions")
  18779. .field("expressions", [def("Expression")]);
  18780. var UnaryOperator = or(
  18781. "-", "+", "!", "~",
  18782. "typeof", "void", "delete");
  18783. def("UnaryExpression")
  18784. .bases("Expression")
  18785. .build("operator", "argument", "prefix")
  18786. .field("operator", UnaryOperator)
  18787. .field("argument", def("Expression"))
  18788. // TODO Esprima doesn't bother with this field, presumably because
  18789. // it's always true for unary operators.
  18790. .field("prefix", isBoolean, defaults["true"]);
  18791. var BinaryOperator = or(
  18792. "==", "!=", "===", "!==",
  18793. "<", "<=", ">", ">=",
  18794. "<<", ">>", ">>>",
  18795. "+", "-", "*", "/", "%",
  18796. "&", // TODO Missing from the Parser API.
  18797. "|", "^", "in",
  18798. "instanceof", "..");
  18799. def("BinaryExpression")
  18800. .bases("Expression")
  18801. .build("operator", "left", "right")
  18802. .field("operator", BinaryOperator)
  18803. .field("left", def("Expression"))
  18804. .field("right", def("Expression"));
  18805. var AssignmentOperator = or(
  18806. "=", "+=", "-=", "*=", "/=", "%=",
  18807. "<<=", ">>=", ">>>=",
  18808. "|=", "^=", "&=");
  18809. def("AssignmentExpression")
  18810. .bases("Expression")
  18811. .build("operator", "left", "right")
  18812. .field("operator", AssignmentOperator)
  18813. .field("left", def("Pattern"))
  18814. .field("right", def("Expression"));
  18815. var UpdateOperator = or("++", "--");
  18816. def("UpdateExpression")
  18817. .bases("Expression")
  18818. .build("operator", "argument", "prefix")
  18819. .field("operator", UpdateOperator)
  18820. .field("argument", def("Expression"))
  18821. .field("prefix", isBoolean);
  18822. var LogicalOperator = or("||", "&&");
  18823. def("LogicalExpression")
  18824. .bases("Expression")
  18825. .build("operator", "left", "right")
  18826. .field("operator", LogicalOperator)
  18827. .field("left", def("Expression"))
  18828. .field("right", def("Expression"));
  18829. def("ConditionalExpression")
  18830. .bases("Expression")
  18831. .build("test", "consequent", "alternate")
  18832. .field("test", def("Expression"))
  18833. .field("consequent", def("Expression"))
  18834. .field("alternate", def("Expression"));
  18835. def("NewExpression")
  18836. .bases("Expression")
  18837. .build("callee", "arguments")
  18838. .field("callee", def("Expression"))
  18839. // The Mozilla Parser API gives this type as [or(def("Expression"),
  18840. // null)], but null values don't really make sense at the call site.
  18841. // TODO Report this nonsense.
  18842. .field("arguments", [def("Expression")]);
  18843. def("CallExpression")
  18844. .bases("Expression")
  18845. .build("callee", "arguments")
  18846. .field("callee", def("Expression"))
  18847. // See comment for NewExpression above.
  18848. .field("arguments", [def("Expression")]);
  18849. def("MemberExpression")
  18850. .bases("Expression")
  18851. .build("object", "property", "computed")
  18852. .field("object", def("Expression"))
  18853. .field("property", or(def("Identifier"), def("Expression")))
  18854. .field("computed", isBoolean, defaults["false"]);
  18855. def("Pattern").bases("Node");
  18856. def("ObjectPattern")
  18857. .bases("Pattern")
  18858. .build("properties")
  18859. // TODO File a bug to get PropertyPattern added to the interfaces API.
  18860. // esprima uses Property
  18861. .field("properties", [or(def("PropertyPattern"), def("Property"))]);
  18862. def("PropertyPattern")
  18863. .bases("Pattern")
  18864. .build("key", "pattern")
  18865. .field("key", or(def("Literal"), def("Identifier")))
  18866. .field("pattern", def("Pattern"));
  18867. def("ArrayPattern")
  18868. .bases("Pattern")
  18869. .build("elements")
  18870. .field("elements", [or(def("Pattern"), null)]);
  18871. def("SwitchCase")
  18872. .bases("Node")
  18873. .build("test", "consequent")
  18874. .field("test", or(def("Expression"), null))
  18875. .field("consequent", [def("Statement")]);
  18876. def("Identifier")
  18877. // But aren't Expressions and Patterns already Nodes? TODO Report this.
  18878. .bases("Node", "Expression", "Pattern")
  18879. .build("name")
  18880. .field("name", isString);
  18881. def("Literal")
  18882. // But aren't Expressions already Nodes? TODO Report this.
  18883. .bases("Node", "Expression")
  18884. .build("value")
  18885. .field("value", or(
  18886. isString,
  18887. isBoolean,
  18888. null, // isNull would also work here.
  18889. isNumber,
  18890. isRegExp
  18891. ))
  18892. .field("regex", or({
  18893. pattern: isString,
  18894. flags: isString
  18895. }, null), function() {
  18896. if (!isRegExp.check(this.value))
  18897. return null;
  18898. var flags = "";
  18899. if (this.value.ignoreCase) flags += "i";
  18900. if (this.value.multiline) flags += "m";
  18901. if (this.value.global) flags += "g";
  18902. return {
  18903. pattern: this.value.source,
  18904. flags: flags
  18905. };
  18906. });
  18907. // Abstract (non-buildable) comment supertype. Not a Node.
  18908. def("Comment")
  18909. .bases("Printable")
  18910. .field("value", isString)
  18911. // A .leading comment comes before the node, whereas a .trailing
  18912. // comment comes after it. These two fields should not both be true,
  18913. // but they might both be false when the comment falls inside a node
  18914. // and the node has no children for the comment to lead or trail,
  18915. // e.g. { /*dangling*/ }.
  18916. .field("leading", isBoolean, defaults["true"])
  18917. .field("trailing", isBoolean, defaults["false"]);
  18918. // Block comment. The .type really should be BlockComment rather than
  18919. // Block, but that's what we're stuck with for now.
  18920. def("Block")
  18921. .bases("Comment")
  18922. .build("value", /*optional:*/ "leading", "trailing");
  18923. // Single line comment. The .type really should be LineComment rather than
  18924. // Line, but that's what we're stuck with for now.
  18925. def("Line")
  18926. .bases("Comment")
  18927. .build("value", /*optional:*/ "leading", "trailing");
  18928. },{"../lib/shared":186,"../lib/types":187}],176:[function(require,module,exports){
  18929. require("./core");
  18930. var types = require("../lib/types");
  18931. var def = types.Type.def;
  18932. var or = types.Type.or;
  18933. var builtin = types.builtInTypes;
  18934. var isString = builtin.string;
  18935. var isBoolean = builtin.boolean;
  18936. // Note that none of these types are buildable because the Mozilla Parser
  18937. // API doesn't specify any builder functions, and nobody uses E4X anymore.
  18938. def("XMLDefaultDeclaration")
  18939. .bases("Declaration")
  18940. .field("namespace", def("Expression"));
  18941. def("XMLAnyName").bases("Expression");
  18942. def("XMLQualifiedIdentifier")
  18943. .bases("Expression")
  18944. .field("left", or(def("Identifier"), def("XMLAnyName")))
  18945. .field("right", or(def("Identifier"), def("Expression")))
  18946. .field("computed", isBoolean);
  18947. def("XMLFunctionQualifiedIdentifier")
  18948. .bases("Expression")
  18949. .field("right", or(def("Identifier"), def("Expression")))
  18950. .field("computed", isBoolean);
  18951. def("XMLAttributeSelector")
  18952. .bases("Expression")
  18953. .field("attribute", def("Expression"));
  18954. def("XMLFilterExpression")
  18955. .bases("Expression")
  18956. .field("left", def("Expression"))
  18957. .field("right", def("Expression"));
  18958. def("XMLElement")
  18959. .bases("XML", "Expression")
  18960. .field("contents", [def("XML")]);
  18961. def("XMLList")
  18962. .bases("XML", "Expression")
  18963. .field("contents", [def("XML")]);
  18964. def("XML").bases("Node");
  18965. def("XMLEscape")
  18966. .bases("XML")
  18967. .field("expression", def("Expression"));
  18968. def("XMLText")
  18969. .bases("XML")
  18970. .field("text", isString);
  18971. def("XMLStartTag")
  18972. .bases("XML")
  18973. .field("contents", [def("XML")]);
  18974. def("XMLEndTag")
  18975. .bases("XML")
  18976. .field("contents", [def("XML")]);
  18977. def("XMLPointTag")
  18978. .bases("XML")
  18979. .field("contents", [def("XML")]);
  18980. def("XMLName")
  18981. .bases("XML")
  18982. .field("contents", or(isString, [def("XML")]));
  18983. def("XMLAttribute")
  18984. .bases("XML")
  18985. .field("value", isString);
  18986. def("XMLCdata")
  18987. .bases("XML")
  18988. .field("contents", isString);
  18989. def("XMLComment")
  18990. .bases("XML")
  18991. .field("contents", isString);
  18992. def("XMLProcessingInstruction")
  18993. .bases("XML")
  18994. .field("target", isString)
  18995. .field("contents", or(isString, null));
  18996. },{"../lib/types":187,"./core":175}],177:[function(require,module,exports){
  18997. require("./core");
  18998. var types = require("../lib/types");
  18999. var def = types.Type.def;
  19000. var or = types.Type.or;
  19001. var builtin = types.builtInTypes;
  19002. var isBoolean = builtin.boolean;
  19003. var isObject = builtin.object;
  19004. var isString = builtin.string;
  19005. var defaults = require("../lib/shared").defaults;
  19006. def("Function")
  19007. .field("generator", isBoolean, defaults["false"])
  19008. .field("expression", isBoolean, defaults["false"])
  19009. .field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
  19010. // TODO This could be represented as a SpreadElementPattern in .params.
  19011. .field("rest", or(def("Identifier"), null), defaults["null"]);
  19012. def("FunctionDeclaration")
  19013. .build("id", "params", "body", "generator", "expression");
  19014. def("FunctionExpression")
  19015. .build("id", "params", "body", "generator", "expression");
  19016. // TODO The Parser API calls this ArrowExpression, but Esprima uses
  19017. // ArrowFunctionExpression.
  19018. def("ArrowFunctionExpression")
  19019. .bases("Function", "Expression")
  19020. .build("params", "body", "expression")
  19021. // The forced null value here is compatible with the overridden
  19022. // definition of the "id" field in the Function interface.
  19023. .field("id", null, defaults["null"])
  19024. // Arrow function bodies are allowed to be expressions.
  19025. .field("body", or(def("BlockStatement"), def("Expression")))
  19026. // The current spec forbids arrow generators, so I have taken the
  19027. // liberty of enforcing that. TODO Report this.
  19028. .field("generator", false, defaults["false"]);
  19029. def("YieldExpression")
  19030. .bases("Expression")
  19031. .build("argument", "delegate")
  19032. .field("argument", or(def("Expression"), null))
  19033. .field("delegate", isBoolean, defaults["false"]);
  19034. def("GeneratorExpression")
  19035. .bases("Expression")
  19036. .build("body", "blocks", "filter")
  19037. .field("body", def("Expression"))
  19038. .field("blocks", [def("ComprehensionBlock")])
  19039. .field("filter", or(def("Expression"), null));
  19040. def("ComprehensionExpression")
  19041. .bases("Expression")
  19042. .build("body", "blocks", "filter")
  19043. .field("body", def("Expression"))
  19044. .field("blocks", [def("ComprehensionBlock")])
  19045. .field("filter", or(def("Expression"), null));
  19046. def("ComprehensionBlock")
  19047. .bases("Node")
  19048. .build("left", "right", "each")
  19049. .field("left", def("Pattern"))
  19050. .field("right", def("Expression"))
  19051. .field("each", isBoolean);
  19052. def("ModuleSpecifier")
  19053. .bases("Literal")
  19054. .build("value")
  19055. .field("value", isString);
  19056. def("Property")
  19057. // Esprima extensions not mentioned in the Mozilla Parser API:
  19058. .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
  19059. .field("method", isBoolean, defaults["false"])
  19060. .field("shorthand", isBoolean, defaults["false"])
  19061. .field("computed", isBoolean, defaults["false"]);
  19062. def("PropertyPattern")
  19063. .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
  19064. .field("computed", isBoolean, defaults["false"]);
  19065. def("MethodDefinition")
  19066. .bases("Declaration")
  19067. .build("kind", "key", "value", "static")
  19068. .field("kind", or("init", "get", "set", ""))
  19069. .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
  19070. .field("value", def("Function"))
  19071. .field("computed", isBoolean, defaults["false"])
  19072. .field("static", isBoolean, defaults["false"]);
  19073. def("SpreadElement")
  19074. .bases("Node")
  19075. .build("argument")
  19076. .field("argument", def("Expression"));
  19077. def("ArrayExpression")
  19078. .field("elements", [or(def("Expression"), def("SpreadElement"), null)]);
  19079. def("NewExpression")
  19080. .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
  19081. def("CallExpression")
  19082. .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
  19083. def("SpreadElementPattern")
  19084. .bases("Pattern")
  19085. .build("argument")
  19086. .field("argument", def("Pattern"));
  19087. def("ArrayPattern")
  19088. .field("elements", [or(
  19089. def("Pattern"),
  19090. null,
  19091. // used by esprima
  19092. def("SpreadElement")
  19093. )]);
  19094. var ClassBodyElement = or(
  19095. def("MethodDefinition"),
  19096. def("VariableDeclarator"),
  19097. def("ClassPropertyDefinition"),
  19098. def("ClassProperty")
  19099. );
  19100. def("ClassProperty")
  19101. .bases("Declaration")
  19102. .build("key")
  19103. .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
  19104. .field("computed", isBoolean, defaults["false"]);
  19105. def("ClassPropertyDefinition") // static property
  19106. .bases("Declaration")
  19107. .build("definition")
  19108. // Yes, Virginia, circular definitions are permitted.
  19109. .field("definition", ClassBodyElement);
  19110. def("ClassBody")
  19111. .bases("Declaration")
  19112. .build("body")
  19113. .field("body", [ClassBodyElement]);
  19114. def("ClassDeclaration")
  19115. .bases("Declaration")
  19116. .build("id", "body", "superClass")
  19117. .field("id", or(def("Identifier"), null))
  19118. .field("body", def("ClassBody"))
  19119. .field("superClass", or(def("Expression"), null), defaults["null"]);
  19120. def("ClassExpression")
  19121. .bases("Expression")
  19122. .build("id", "body", "superClass")
  19123. .field("id", or(def("Identifier"), null), defaults["null"])
  19124. .field("body", def("ClassBody"))
  19125. .field("superClass", or(def("Expression"), null), defaults["null"])
  19126. .field("implements", [def("ClassImplements")], defaults.emptyArray);
  19127. def("ClassImplements")
  19128. .bases("Node")
  19129. .build("id")
  19130. .field("id", def("Identifier"))
  19131. .field("superClass", or(def("Expression"), null), defaults["null"]);
  19132. // Specifier and NamedSpecifier are abstract non-standard types that I
  19133. // introduced for definitional convenience.
  19134. def("Specifier").bases("Node");
  19135. def("NamedSpecifier")
  19136. .bases("Specifier")
  19137. // Note: this abstract type is intentionally not buildable.
  19138. .field("id", def("Identifier"))
  19139. .field("name", or(def("Identifier"), null), defaults["null"]);
  19140. // Like NamedSpecifier, except type:"ExportSpecifier" and buildable.
  19141. // export {<id [as name]>} [from ...];
  19142. def("ExportSpecifier")
  19143. .bases("NamedSpecifier")
  19144. .build("id", "name");
  19145. // export <*> from ...;
  19146. def("ExportBatchSpecifier")
  19147. .bases("Specifier")
  19148. .build();
  19149. // Like NamedSpecifier, except type:"ImportSpecifier" and buildable.
  19150. // import {<id [as name]>} from ...;
  19151. def("ImportSpecifier")
  19152. .bases("NamedSpecifier")
  19153. .build("id", "name");
  19154. // import <* as id> from ...;
  19155. def("ImportNamespaceSpecifier")
  19156. .bases("Specifier")
  19157. .build("id")
  19158. .field("id", def("Identifier"));
  19159. // import <id> from ...;
  19160. def("ImportDefaultSpecifier")
  19161. .bases("Specifier")
  19162. .build("id")
  19163. .field("id", def("Identifier"));
  19164. def("ExportDeclaration")
  19165. .bases("Declaration")
  19166. .build("default", "declaration", "specifiers", "source")
  19167. .field("default", isBoolean)
  19168. .field("declaration", or(
  19169. def("Declaration"),
  19170. def("Expression"), // Implies default.
  19171. null
  19172. ))
  19173. .field("specifiers", [or(
  19174. def("ExportSpecifier"),
  19175. def("ExportBatchSpecifier")
  19176. )], defaults.emptyArray)
  19177. .field("source", or(
  19178. def("Literal"),
  19179. def("ModuleSpecifier"),
  19180. null
  19181. ), defaults["null"]);
  19182. def("ImportDeclaration")
  19183. .bases("Declaration")
  19184. .build("specifiers", "source")
  19185. .field("specifiers", [or(
  19186. def("ImportSpecifier"),
  19187. def("ImportNamespaceSpecifier"),
  19188. def("ImportDefaultSpecifier")
  19189. )], defaults.emptyArray)
  19190. .field("source", or(
  19191. def("Literal"),
  19192. def("ModuleSpecifier")
  19193. ));
  19194. def("TaggedTemplateExpression")
  19195. .bases("Expression")
  19196. .field("tag", def("Expression"))
  19197. .field("quasi", def("TemplateLiteral"));
  19198. def("TemplateLiteral")
  19199. .bases("Expression")
  19200. .build("quasis", "expressions")
  19201. .field("quasis", [def("TemplateElement")])
  19202. .field("expressions", [def("Expression")]);
  19203. def("TemplateElement")
  19204. .bases("Node")
  19205. .build("value", "tail")
  19206. .field("value", {"cooked": isString, "raw": isString})
  19207. .field("tail", isBoolean);
  19208. },{"../lib/shared":186,"../lib/types":187,"./core":175}],178:[function(require,module,exports){
  19209. require("./core");
  19210. var types = require("../lib/types");
  19211. var def = types.Type.def;
  19212. var or = types.Type.or;
  19213. var builtin = types.builtInTypes;
  19214. var isBoolean = builtin.boolean;
  19215. var defaults = require("../lib/shared").defaults;
  19216. def("Function")
  19217. .field("async", isBoolean, defaults["false"]);
  19218. def("SpreadProperty")
  19219. .bases("Node")
  19220. .build("argument")
  19221. .field("argument", def("Expression"));
  19222. def("ObjectExpression")
  19223. .field("properties", [or(def("Property"), def("SpreadProperty"))]);
  19224. def("SpreadPropertyPattern")
  19225. .bases("Pattern")
  19226. .build("argument")
  19227. .field("argument", def("Pattern"));
  19228. def("ObjectPattern")
  19229. .field("properties", [or(
  19230. def("PropertyPattern"),
  19231. def("SpreadPropertyPattern"),
  19232. // used by esprima
  19233. def("Property"),
  19234. def("SpreadProperty")
  19235. )]);
  19236. def("AwaitExpression")
  19237. .bases("Expression")
  19238. .build("argument", "all")
  19239. .field("argument", or(def("Expression"), null))
  19240. .field("all", isBoolean, defaults["false"]);
  19241. },{"../lib/shared":186,"../lib/types":187,"./core":175}],179:[function(require,module,exports){
  19242. require("./core");
  19243. var types = require("../lib/types");
  19244. var def = types.Type.def;
  19245. var or = types.Type.or;
  19246. var builtin = types.builtInTypes;
  19247. var isString = builtin.string;
  19248. var isBoolean = builtin.boolean;
  19249. var defaults = require("../lib/shared").defaults;
  19250. def("JSXAttribute")
  19251. .bases("Node")
  19252. .build("name", "value")
  19253. .field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
  19254. .field("value", or(
  19255. def("Literal"), // attr="value"
  19256. def("JSXExpressionContainer"), // attr={value}
  19257. null // attr= or just attr
  19258. ), defaults["null"]);
  19259. def("JSXIdentifier")
  19260. .bases("Identifier")
  19261. .build("name")
  19262. .field("name", isString);
  19263. def("JSXNamespacedName")
  19264. .bases("Node")
  19265. .build("namespace", "name")
  19266. .field("namespace", def("JSXIdentifier"))
  19267. .field("name", def("JSXIdentifier"));
  19268. def("JSXMemberExpression")
  19269. .bases("MemberExpression")
  19270. .build("object", "property")
  19271. .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
  19272. .field("property", def("JSXIdentifier"))
  19273. .field("computed", isBoolean, defaults.false);
  19274. var JSXElementName = or(
  19275. def("JSXIdentifier"),
  19276. def("JSXNamespacedName"),
  19277. def("JSXMemberExpression")
  19278. );
  19279. def("JSXSpreadAttribute")
  19280. .bases("Node")
  19281. .build("argument")
  19282. .field("argument", def("Expression"));
  19283. var JSXAttributes = [or(
  19284. def("JSXAttribute"),
  19285. def("JSXSpreadAttribute")
  19286. )];
  19287. def("JSXExpressionContainer")
  19288. .bases("Expression")
  19289. .build("expression")
  19290. .field("expression", def("Expression"));
  19291. def("JSXElement")
  19292. .bases("Expression")
  19293. .build("openingElement", "closingElement", "children")
  19294. .field("openingElement", def("JSXOpeningElement"))
  19295. .field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
  19296. .field("children", [or(
  19297. def("JSXElement"),
  19298. def("JSXExpressionContainer"),
  19299. def("JSXText"),
  19300. def("Literal") // TODO Esprima should return JSXText instead.
  19301. )], defaults.emptyArray)
  19302. .field("name", JSXElementName, function() {
  19303. // Little-known fact: the `this` object inside a default function
  19304. // is none other than the partially-built object itself, and any
  19305. // fields initialized directly from builder function arguments
  19306. // (like openingElement, closingElement, and children) are
  19307. // guaranteed to be available.
  19308. return this.openingElement.name;
  19309. })
  19310. .field("selfClosing", isBoolean, function() {
  19311. return this.openingElement.selfClosing;
  19312. })
  19313. .field("attributes", JSXAttributes, function() {
  19314. return this.openingElement.attributes;
  19315. });
  19316. def("JSXOpeningElement")
  19317. .bases("Node") // TODO Does this make sense? Can't really be an JSXElement.
  19318. .build("name", "attributes", "selfClosing")
  19319. .field("name", JSXElementName)
  19320. .field("attributes", JSXAttributes, defaults.emptyArray)
  19321. .field("selfClosing", isBoolean, defaults["false"]);
  19322. def("JSXClosingElement")
  19323. .bases("Node") // TODO Same concern.
  19324. .build("name")
  19325. .field("name", JSXElementName);
  19326. def("JSXText")
  19327. .bases("Literal")
  19328. .build("value")
  19329. .field("value", isString);
  19330. def("JSXEmptyExpression").bases("Expression").build();
  19331. // Type Annotations
  19332. def("Type")
  19333. .bases("Node");
  19334. def("AnyTypeAnnotation")
  19335. .bases("Type");
  19336. def("VoidTypeAnnotation")
  19337. .bases("Type");
  19338. def("NumberTypeAnnotation")
  19339. .bases("Type");
  19340. def("StringTypeAnnotation")
  19341. .bases("Type");
  19342. def("StringLiteralTypeAnnotation")
  19343. .bases("Type")
  19344. .build("value", "raw")
  19345. .field("value", isString)
  19346. .field("raw", isString);
  19347. def("BooleanTypeAnnotation")
  19348. .bases("Type");
  19349. def("TypeAnnotation")
  19350. .bases("Node")
  19351. .build("typeAnnotation")
  19352. .field("typeAnnotation", def("Type"));
  19353. def("NullableTypeAnnotation")
  19354. .bases("Type")
  19355. .build("typeAnnotation")
  19356. .field("typeAnnotation", def("Type"));
  19357. def("FunctionTypeAnnotation")
  19358. .bases("Type")
  19359. .build("params", "returnType", "rest", "typeParameters")
  19360. .field("params", [def("FunctionTypeParam")])
  19361. .field("returnType", def("Type"))
  19362. .field("rest", or(def("FunctionTypeParam"), null))
  19363. .field("typeParameters", or(def("TypeParameterDeclaration"), null));
  19364. def("FunctionTypeParam")
  19365. .bases("Node")
  19366. .build("name", "typeAnnotation", "optional")
  19367. .field("name", def("Identifier"))
  19368. .field("typeAnnotation", def("Type"))
  19369. .field("optional", isBoolean);
  19370. def("ArrayTypeAnnotation")
  19371. .bases("Type")
  19372. .build("elementType")
  19373. .field("elementType", def("Type"));
  19374. def("ObjectTypeAnnotation")
  19375. .bases("Type")
  19376. .build("properties")
  19377. .field("properties", [def("ObjectTypeProperty")])
  19378. .field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray)
  19379. .field("callProperties", [def("ObjectTypeCallProperty")], defaults.emptyArray);
  19380. def("ObjectTypeProperty")
  19381. .bases("Node")
  19382. .build("key", "value", "optional")
  19383. .field("key", or(def("Literal"), def("Identifier")))
  19384. .field("value", def("Type"))
  19385. .field("optional", isBoolean);
  19386. def("ObjectTypeIndexer")
  19387. .bases("Node")
  19388. .build("id", "key", "value")
  19389. .field("id", def("Identifier"))
  19390. .field("key", def("Type"))
  19391. .field("value", def("Type"));
  19392. def("ObjectTypeCallProperty")
  19393. .bases("Node")
  19394. .build("value")
  19395. .field("value", def("FunctionTypeAnnotation"))
  19396. .field("static", isBoolean, false);
  19397. def("QualifiedTypeIdentifier")
  19398. .bases("Node")
  19399. .build("qualification", "id")
  19400. .field("qualification", or(def("Identifier"), def("QualifiedTypeIdentifier")))
  19401. .field("id", def("Identifier"));
  19402. def("GenericTypeAnnotation")
  19403. .bases("Type")
  19404. .build("id", "typeParameters")
  19405. .field("id", or(def("Identifier"), def("QualifiedTypeIdentifier")))
  19406. .field("typeParameters", or(def("TypeParameterInstantiation"), null));
  19407. def("MemberTypeAnnotation")
  19408. .bases("Type")
  19409. .build("object", "property")
  19410. .field("object", def("Identifier"))
  19411. .field("property", or(def("MemberTypeAnnotation"), def("GenericTypeAnnotation")));
  19412. def("UnionTypeAnnotation")
  19413. .bases("Type")
  19414. .build("types")
  19415. .field("types", [def("Type")]);
  19416. def("IntersectionTypeAnnotation")
  19417. .bases("Type")
  19418. .build("types")
  19419. .field("types", [def("Type")]);
  19420. def("TypeofTypeAnnotation")
  19421. .bases("Type")
  19422. .build("argument")
  19423. .field("argument", def("Type"));
  19424. def("Identifier")
  19425. .field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
  19426. def("TypeParameterDeclaration")
  19427. .bases("Node")
  19428. .build("params")
  19429. .field("params", [def("Identifier")]);
  19430. def("TypeParameterInstantiation")
  19431. .bases("Node")
  19432. .build("params")
  19433. .field("params", [def("Type")]);
  19434. def("Function")
  19435. .field("returnType", or(def("TypeAnnotation"), null), defaults["null"])
  19436. .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"]);
  19437. def("ClassProperty")
  19438. .build("key", "typeAnnotation")
  19439. .field("typeAnnotation", def("TypeAnnotation"))
  19440. .field("static", isBoolean, false);
  19441. def("ClassImplements")
  19442. .field("typeParameters", or(def("TypeParameterInstantiation"), null), defaults["null"]);
  19443. def("InterfaceDeclaration")
  19444. .bases("Statement")
  19445. .build("id", "body", "extends")
  19446. .field("id", def("Identifier"))
  19447. .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"])
  19448. .field("body", def("ObjectTypeAnnotation"))
  19449. .field("extends", [def("InterfaceExtends")]);
  19450. def("InterfaceExtends")
  19451. .bases("Node")
  19452. .build("id")
  19453. .field("id", def("Identifier"))
  19454. .field("typeParameters", or(def("TypeParameterInstantiation"), null));
  19455. def("TypeAlias")
  19456. .bases("Statement")
  19457. .build("id", "typeParameters", "right")
  19458. .field("id", def("Identifier"))
  19459. .field("typeParameters", or(def("TypeParameterDeclaration"), null))
  19460. .field("right", def("Type"));
  19461. def("TypeCastExpression")
  19462. .bases("Expression")
  19463. .build("expression", "typeAnnotation")
  19464. .field("expression", def("Expression"))
  19465. .field("typeAnnotation", def("TypeAnnotation"));
  19466. def("TupleTypeAnnotation")
  19467. .bases("Type")
  19468. .build("types")
  19469. .field("types", [def("Type")]);
  19470. def("DeclareVariable")
  19471. .bases("Statement")
  19472. .build("id")
  19473. .field("id", def("Identifier"));
  19474. def("DeclareFunction")
  19475. .bases("Statement")
  19476. .build("id")
  19477. .field("id", def("Identifier"));
  19478. def("DeclareClass")
  19479. .bases("InterfaceDeclaration")
  19480. .build("id");
  19481. def("DeclareModule")
  19482. .bases("Statement")
  19483. .build("id", "body")
  19484. .field("id", or(def("Identifier"), def("Literal")))
  19485. .field("body", def("BlockStatement"));
  19486. },{"../lib/shared":186,"../lib/types":187,"./core":175}],180:[function(require,module,exports){
  19487. require("./core");
  19488. var types = require("../lib/types");
  19489. var def = types.Type.def;
  19490. var or = types.Type.or;
  19491. var geq = require("../lib/shared").geq;
  19492. def("Function")
  19493. // SpiderMonkey allows expression closures: function(x) x+1
  19494. .field("body", or(def("BlockStatement"), def("Expression")));
  19495. def("ForOfStatement")
  19496. .bases("Statement")
  19497. .build("left", "right", "body")
  19498. .field("left", or(
  19499. def("VariableDeclaration"),
  19500. def("Expression")))
  19501. .field("right", def("Expression"))
  19502. .field("body", def("Statement"));
  19503. def("LetStatement")
  19504. .bases("Statement")
  19505. .build("head", "body")
  19506. // TODO Deviating from the spec by reusing VariableDeclarator here.
  19507. .field("head", [def("VariableDeclarator")])
  19508. .field("body", def("Statement"));
  19509. def("LetExpression")
  19510. .bases("Expression")
  19511. .build("head", "body")
  19512. // TODO Deviating from the spec by reusing VariableDeclarator here.
  19513. .field("head", [def("VariableDeclarator")])
  19514. .field("body", def("Expression"));
  19515. def("GraphExpression")
  19516. .bases("Expression")
  19517. .build("index", "expression")
  19518. .field("index", geq(0))
  19519. .field("expression", def("Literal"));
  19520. def("GraphIndexExpression")
  19521. .bases("Expression")
  19522. .build("index")
  19523. .field("index", geq(0));
  19524. },{"../lib/shared":186,"../lib/types":187,"./core":175}],181:[function(require,module,exports){
  19525. var assert = require("assert");
  19526. var types = require("../main");
  19527. var getFieldNames = types.getFieldNames;
  19528. var getFieldValue = types.getFieldValue;
  19529. var isArray = types.builtInTypes.array;
  19530. var isObject = types.builtInTypes.object;
  19531. var isDate = types.builtInTypes.Date;
  19532. var isRegExp = types.builtInTypes.RegExp;
  19533. var hasOwn = Object.prototype.hasOwnProperty;
  19534. function astNodesAreEquivalent(a, b, problemPath) {
  19535. if (isArray.check(problemPath)) {
  19536. problemPath.length = 0;
  19537. } else {
  19538. problemPath = null;
  19539. }
  19540. return areEquivalent(a, b, problemPath);
  19541. }
  19542. astNodesAreEquivalent.assert = function(a, b) {
  19543. var problemPath = [];
  19544. if (!astNodesAreEquivalent(a, b, problemPath)) {
  19545. if (problemPath.length === 0) {
  19546. assert.strictEqual(a, b);
  19547. } else {
  19548. assert.ok(
  19549. false,
  19550. "Nodes differ in the following path: " +
  19551. problemPath.map(subscriptForProperty).join("")
  19552. );
  19553. }
  19554. }
  19555. };
  19556. function subscriptForProperty(property) {
  19557. if (/[_$a-z][_$a-z0-9]*/i.test(property)) {
  19558. return "." + property;
  19559. }
  19560. return "[" + JSON.stringify(property) + "]";
  19561. }
  19562. function areEquivalent(a, b, problemPath) {
  19563. if (a === b) {
  19564. return true;
  19565. }
  19566. if (isArray.check(a)) {
  19567. return arraysAreEquivalent(a, b, problemPath);
  19568. }
  19569. if (isObject.check(a)) {
  19570. return objectsAreEquivalent(a, b, problemPath);
  19571. }
  19572. if (isDate.check(a)) {
  19573. return isDate.check(b) && (+a === +b);
  19574. }
  19575. if (isRegExp.check(a)) {
  19576. return isRegExp.check(b) && (
  19577. a.source === b.source &&
  19578. a.global === b.global &&
  19579. a.multiline === b.multiline &&
  19580. a.ignoreCase === b.ignoreCase
  19581. );
  19582. }
  19583. return a == b;
  19584. }
  19585. function arraysAreEquivalent(a, b, problemPath) {
  19586. isArray.assert(a);
  19587. var aLength = a.length;
  19588. if (!isArray.check(b) || b.length !== aLength) {
  19589. if (problemPath) {
  19590. problemPath.push("length");
  19591. }
  19592. return false;
  19593. }
  19594. for (var i = 0; i < aLength; ++i) {
  19595. if (problemPath) {
  19596. problemPath.push(i);
  19597. }
  19598. if (i in a !== i in b) {
  19599. return false;
  19600. }
  19601. if (!areEquivalent(a[i], b[i], problemPath)) {
  19602. return false;
  19603. }
  19604. if (problemPath) {
  19605. assert.strictEqual(problemPath.pop(), i);
  19606. }
  19607. }
  19608. return true;
  19609. }
  19610. function objectsAreEquivalent(a, b, problemPath) {
  19611. isObject.assert(a);
  19612. if (!isObject.check(b)) {
  19613. return false;
  19614. }
  19615. // Fast path for a common property of AST nodes.
  19616. if (a.type !== b.type) {
  19617. if (problemPath) {
  19618. problemPath.push("type");
  19619. }
  19620. return false;
  19621. }
  19622. var aNames = getFieldNames(a);
  19623. var aNameCount = aNames.length;
  19624. var bNames = getFieldNames(b);
  19625. var bNameCount = bNames.length;
  19626. if (aNameCount === bNameCount) {
  19627. for (var i = 0; i < aNameCount; ++i) {
  19628. var name = aNames[i];
  19629. var aChild = getFieldValue(a, name);
  19630. var bChild = getFieldValue(b, name);
  19631. if (problemPath) {
  19632. problemPath.push(name);
  19633. }
  19634. if (!areEquivalent(aChild, bChild, problemPath)) {
  19635. return false;
  19636. }
  19637. if (problemPath) {
  19638. assert.strictEqual(problemPath.pop(), name);
  19639. }
  19640. }
  19641. return true;
  19642. }
  19643. if (!problemPath) {
  19644. return false;
  19645. }
  19646. // Since aNameCount !== bNameCount, we need to find some name that's
  19647. // missing in aNames but present in bNames, or vice-versa.
  19648. var seenNames = Object.create(null);
  19649. for (i = 0; i < aNameCount; ++i) {
  19650. seenNames[aNames[i]] = true;
  19651. }
  19652. for (i = 0; i < bNameCount; ++i) {
  19653. name = bNames[i];
  19654. if (!hasOwn.call(seenNames, name)) {
  19655. problemPath.push(name);
  19656. return false;
  19657. }
  19658. delete seenNames[name];
  19659. }
  19660. for (name in seenNames) {
  19661. problemPath.push(name);
  19662. break;
  19663. }
  19664. return false;
  19665. }
  19666. module.exports = astNodesAreEquivalent;
  19667. },{"../main":188,"assert":190}],182:[function(require,module,exports){
  19668. var assert = require("assert");
  19669. var types = require("./types");
  19670. var n = types.namedTypes;
  19671. var b = types.builders;
  19672. var isNumber = types.builtInTypes.number;
  19673. var isArray = types.builtInTypes.array;
  19674. var Path = require("./path");
  19675. var Scope = require("./scope");
  19676. function NodePath(value, parentPath, name) {
  19677. assert.ok(this instanceof NodePath);
  19678. Path.call(this, value, parentPath, name);
  19679. }
  19680. require("util").inherits(NodePath, Path);
  19681. var NPp = NodePath.prototype;
  19682. Object.defineProperties(NPp, {
  19683. node: {
  19684. get: function() {
  19685. Object.defineProperty(this, "node", {
  19686. configurable: true, // Enable deletion.
  19687. value: this._computeNode()
  19688. });
  19689. return this.node;
  19690. }
  19691. },
  19692. parent: {
  19693. get: function() {
  19694. Object.defineProperty(this, "parent", {
  19695. configurable: true, // Enable deletion.
  19696. value: this._computeParent()
  19697. });
  19698. return this.parent;
  19699. }
  19700. },
  19701. scope: {
  19702. get: function() {
  19703. Object.defineProperty(this, "scope", {
  19704. configurable: true, // Enable deletion.
  19705. value: this._computeScope()
  19706. });
  19707. return this.scope;
  19708. }
  19709. }
  19710. });
  19711. NPp.replace = function() {
  19712. delete this.node;
  19713. delete this.parent;
  19714. delete this.scope;
  19715. return Path.prototype.replace.apply(this, arguments);
  19716. };
  19717. NPp.prune = function() {
  19718. var remainingNodePath = this.parent;
  19719. this.replace();
  19720. return cleanUpNodesAfterPrune(remainingNodePath);
  19721. };
  19722. // The value of the first ancestor Path whose value is a Node.
  19723. NPp._computeNode = function() {
  19724. var value = this.value;
  19725. if (n.Node.check(value)) {
  19726. return value;
  19727. }
  19728. var pp = this.parentPath;
  19729. return pp && pp.node || null;
  19730. };
  19731. // The first ancestor Path whose value is a Node distinct from this.node.
  19732. NPp._computeParent = function() {
  19733. var value = this.value;
  19734. var pp = this.parentPath;
  19735. if (!n.Node.check(value)) {
  19736. while (pp && !n.Node.check(pp.value)) {
  19737. pp = pp.parentPath;
  19738. }
  19739. if (pp) {
  19740. pp = pp.parentPath;
  19741. }
  19742. }
  19743. while (pp && !n.Node.check(pp.value)) {
  19744. pp = pp.parentPath;
  19745. }
  19746. return pp || null;
  19747. };
  19748. // The closest enclosing scope that governs this node.
  19749. NPp._computeScope = function() {
  19750. var value = this.value;
  19751. var pp = this.parentPath;
  19752. var scope = pp && pp.scope;
  19753. if (n.Node.check(value) &&
  19754. Scope.isEstablishedBy(value)) {
  19755. scope = new Scope(this, scope);
  19756. }
  19757. return scope || null;
  19758. };
  19759. NPp.getValueProperty = function(name) {
  19760. return types.getFieldValue(this.value, name);
  19761. };
  19762. /**
  19763. * Determine whether this.node needs to be wrapped in parentheses in order
  19764. * for a parser to reproduce the same local AST structure.
  19765. *
  19766. * For instance, in the expression `(1 + 2) * 3`, the BinaryExpression
  19767. * whose operator is "+" needs parentheses, because `1 + 2 * 3` would
  19768. * parse differently.
  19769. *
  19770. * If assumeExpressionContext === true, we don't worry about edge cases
  19771. * like an anonymous FunctionExpression appearing lexically first in its
  19772. * enclosing statement and thus needing parentheses to avoid being parsed
  19773. * as a FunctionDeclaration with a missing name.
  19774. */
  19775. NPp.needsParens = function(assumeExpressionContext) {
  19776. var pp = this.parentPath;
  19777. if (!pp) {
  19778. return false;
  19779. }
  19780. var node = this.value;
  19781. // Only expressions need parentheses.
  19782. if (!n.Expression.check(node)) {
  19783. return false;
  19784. }
  19785. // Identifiers never need parentheses.
  19786. if (node.type === "Identifier") {
  19787. return false;
  19788. }
  19789. while (!n.Node.check(pp.value)) {
  19790. pp = pp.parentPath;
  19791. if (!pp) {
  19792. return false;
  19793. }
  19794. }
  19795. var parent = pp.value;
  19796. switch (node.type) {
  19797. case "UnaryExpression":
  19798. case "SpreadElement":
  19799. case "SpreadProperty":
  19800. return parent.type === "MemberExpression"
  19801. && this.name === "object"
  19802. && parent.object === node;
  19803. case "BinaryExpression":
  19804. case "LogicalExpression":
  19805. switch (parent.type) {
  19806. case "CallExpression":
  19807. return this.name === "callee"
  19808. && parent.callee === node;
  19809. case "UnaryExpression":
  19810. case "SpreadElement":
  19811. case "SpreadProperty":
  19812. return true;
  19813. case "MemberExpression":
  19814. return this.name === "object"
  19815. && parent.object === node;
  19816. case "BinaryExpression":
  19817. case "LogicalExpression":
  19818. var po = parent.operator;
  19819. var pp = PRECEDENCE[po];
  19820. var no = node.operator;
  19821. var np = PRECEDENCE[no];
  19822. if (pp > np) {
  19823. return true;
  19824. }
  19825. if (pp === np && this.name === "right") {
  19826. assert.strictEqual(parent.right, node);
  19827. return true;
  19828. }
  19829. default:
  19830. return false;
  19831. }
  19832. case "SequenceExpression":
  19833. switch (parent.type) {
  19834. case "ForStatement":
  19835. // Although parentheses wouldn't hurt around sequence
  19836. // expressions in the head of for loops, traditional style
  19837. // dictates that e.g. i++, j++ should not be wrapped with
  19838. // parentheses.
  19839. return false;
  19840. case "ExpressionStatement":
  19841. return this.name !== "expression";
  19842. default:
  19843. // Otherwise err on the side of overparenthesization, adding
  19844. // explicit exceptions above if this proves overzealous.
  19845. return true;
  19846. }
  19847. case "YieldExpression":
  19848. switch (parent.type) {
  19849. case "BinaryExpression":
  19850. case "LogicalExpression":
  19851. case "UnaryExpression":
  19852. case "SpreadElement":
  19853. case "SpreadProperty":
  19854. case "CallExpression":
  19855. case "MemberExpression":
  19856. case "NewExpression":
  19857. case "ConditionalExpression":
  19858. case "YieldExpression":
  19859. return true;
  19860. default:
  19861. return false;
  19862. }
  19863. case "Literal":
  19864. return parent.type === "MemberExpression"
  19865. && isNumber.check(node.value)
  19866. && this.name === "object"
  19867. && parent.object === node;
  19868. case "AssignmentExpression":
  19869. case "ConditionalExpression":
  19870. switch (parent.type) {
  19871. case "UnaryExpression":
  19872. case "SpreadElement":
  19873. case "SpreadProperty":
  19874. case "BinaryExpression":
  19875. case "LogicalExpression":
  19876. return true;
  19877. case "CallExpression":
  19878. return this.name === "callee"
  19879. && parent.callee === node;
  19880. case "ConditionalExpression":
  19881. return this.name === "test"
  19882. && parent.test === node;
  19883. case "MemberExpression":
  19884. return this.name === "object"
  19885. && parent.object === node;
  19886. default:
  19887. return false;
  19888. }
  19889. default:
  19890. if (parent.type === "NewExpression" &&
  19891. this.name === "callee" &&
  19892. parent.callee === node) {
  19893. return containsCallExpression(node);
  19894. }
  19895. }
  19896. if (assumeExpressionContext !== true &&
  19897. !this.canBeFirstInStatement() &&
  19898. this.firstInStatement())
  19899. return true;
  19900. return false;
  19901. };
  19902. function isBinary(node) {
  19903. return n.BinaryExpression.check(node)
  19904. || n.LogicalExpression.check(node);
  19905. }
  19906. function isUnaryLike(node) {
  19907. return n.UnaryExpression.check(node)
  19908. // I considered making SpreadElement and SpreadProperty subtypes
  19909. // of UnaryExpression, but they're not really Expression nodes.
  19910. || (n.SpreadElement && n.SpreadElement.check(node))
  19911. || (n.SpreadProperty && n.SpreadProperty.check(node));
  19912. }
  19913. var PRECEDENCE = {};
  19914. [["||"],
  19915. ["&&"],
  19916. ["|"],
  19917. ["^"],
  19918. ["&"],
  19919. ["==", "===", "!=", "!=="],
  19920. ["<", ">", "<=", ">=", "in", "instanceof"],
  19921. [">>", "<<", ">>>"],
  19922. ["+", "-"],
  19923. ["*", "/", "%"]
  19924. ].forEach(function(tier, i) {
  19925. tier.forEach(function(op) {
  19926. PRECEDENCE[op] = i;
  19927. });
  19928. });
  19929. function containsCallExpression(node) {
  19930. if (n.CallExpression.check(node)) {
  19931. return true;
  19932. }
  19933. if (isArray.check(node)) {
  19934. return node.some(containsCallExpression);
  19935. }
  19936. if (n.Node.check(node)) {
  19937. return types.someField(node, function(name, child) {
  19938. return containsCallExpression(child);
  19939. });
  19940. }
  19941. return false;
  19942. }
  19943. NPp.canBeFirstInStatement = function() {
  19944. var node = this.node;
  19945. return !n.FunctionExpression.check(node)
  19946. && !n.ObjectExpression.check(node);
  19947. };
  19948. NPp.firstInStatement = function() {
  19949. return firstInStatement(this);
  19950. };
  19951. function firstInStatement(path) {
  19952. for (var node, parent; path.parent; path = path.parent) {
  19953. node = path.node;
  19954. parent = path.parent.node;
  19955. if (n.BlockStatement.check(parent) &&
  19956. path.parent.name === "body" &&
  19957. path.name === 0) {
  19958. assert.strictEqual(parent.body[0], node);
  19959. return true;
  19960. }
  19961. if (n.ExpressionStatement.check(parent) &&
  19962. path.name === "expression") {
  19963. assert.strictEqual(parent.expression, node);
  19964. return true;
  19965. }
  19966. if (n.SequenceExpression.check(parent) &&
  19967. path.parent.name === "expressions" &&
  19968. path.name === 0) {
  19969. assert.strictEqual(parent.expressions[0], node);
  19970. continue;
  19971. }
  19972. if (n.CallExpression.check(parent) &&
  19973. path.name === "callee") {
  19974. assert.strictEqual(parent.callee, node);
  19975. continue;
  19976. }
  19977. if (n.MemberExpression.check(parent) &&
  19978. path.name === "object") {
  19979. assert.strictEqual(parent.object, node);
  19980. continue;
  19981. }
  19982. if (n.ConditionalExpression.check(parent) &&
  19983. path.name === "test") {
  19984. assert.strictEqual(parent.test, node);
  19985. continue;
  19986. }
  19987. if (isBinary(parent) &&
  19988. path.name === "left") {
  19989. assert.strictEqual(parent.left, node);
  19990. continue;
  19991. }
  19992. if (n.UnaryExpression.check(parent) &&
  19993. !parent.prefix &&
  19994. path.name === "argument") {
  19995. assert.strictEqual(parent.argument, node);
  19996. continue;
  19997. }
  19998. return false;
  19999. }
  20000. return true;
  20001. }
  20002. /**
  20003. * Pruning certain nodes will result in empty or incomplete nodes, here we clean those nodes up.
  20004. */
  20005. function cleanUpNodesAfterPrune(remainingNodePath) {
  20006. if (n.VariableDeclaration.check(remainingNodePath.node)) {
  20007. var declarations = remainingNodePath.get('declarations').value;
  20008. if (!declarations || declarations.length === 0) {
  20009. return remainingNodePath.prune();
  20010. }
  20011. } else if (n.ExpressionStatement.check(remainingNodePath.node)) {
  20012. if (!remainingNodePath.get('expression').value) {
  20013. return remainingNodePath.prune();
  20014. }
  20015. } else if (n.IfStatement.check(remainingNodePath.node)) {
  20016. cleanUpIfStatementAfterPrune(remainingNodePath);
  20017. }
  20018. return remainingNodePath;
  20019. }
  20020. function cleanUpIfStatementAfterPrune(ifStatement) {
  20021. var testExpression = ifStatement.get('test').value;
  20022. var alternate = ifStatement.get('alternate').value;
  20023. var consequent = ifStatement.get('consequent').value;
  20024. if (!consequent && !alternate) {
  20025. var testExpressionStatement = b.expressionStatement(testExpression);
  20026. ifStatement.replace(testExpressionStatement);
  20027. } else if (!consequent && alternate) {
  20028. var negatedTestExpression = b.unaryExpression('!', testExpression, true);
  20029. if (n.UnaryExpression.check(testExpression) && testExpression.operator === '!') {
  20030. negatedTestExpression = testExpression.argument;
  20031. }
  20032. ifStatement.get("test").replace(negatedTestExpression);
  20033. ifStatement.get("consequent").replace(alternate);
  20034. ifStatement.get("alternate").replace();
  20035. }
  20036. }
  20037. module.exports = NodePath;
  20038. },{"./path":184,"./scope":185,"./types":187,"assert":190,"util":216}],183:[function(require,module,exports){
  20039. var assert = require("assert");
  20040. var types = require("./types");
  20041. var NodePath = require("./node-path");
  20042. var Printable = types.namedTypes.Printable;
  20043. var isArray = types.builtInTypes.array;
  20044. var isObject = types.builtInTypes.object;
  20045. var isFunction = types.builtInTypes.function;
  20046. var hasOwn = Object.prototype.hasOwnProperty;
  20047. var undefined;
  20048. function PathVisitor() {
  20049. assert.ok(this instanceof PathVisitor);
  20050. // Permanent state.
  20051. this._reusableContextStack = [];
  20052. this._methodNameTable = computeMethodNameTable(this);
  20053. this._shouldVisitComments =
  20054. hasOwn.call(this._methodNameTable, "Block") ||
  20055. hasOwn.call(this._methodNameTable, "Line");
  20056. this.Context = makeContextConstructor(this);
  20057. // State reset every time PathVisitor.prototype.visit is called.
  20058. this._visiting = false;
  20059. this._changeReported = false;
  20060. }
  20061. function computeMethodNameTable(visitor) {
  20062. var typeNames = Object.create(null);
  20063. for (var methodName in visitor) {
  20064. if (/^visit[A-Z]/.test(methodName)) {
  20065. typeNames[methodName.slice("visit".length)] = true;
  20066. }
  20067. }
  20068. var supertypeTable = types.computeSupertypeLookupTable(typeNames);
  20069. var methodNameTable = Object.create(null);
  20070. var typeNames = Object.keys(supertypeTable);
  20071. var typeNameCount = typeNames.length;
  20072. for (var i = 0; i < typeNameCount; ++i) {
  20073. var typeName = typeNames[i];
  20074. methodName = "visit" + supertypeTable[typeName];
  20075. if (isFunction.check(visitor[methodName])) {
  20076. methodNameTable[typeName] = methodName;
  20077. }
  20078. }
  20079. return methodNameTable;
  20080. }
  20081. PathVisitor.fromMethodsObject = function fromMethodsObject(methods) {
  20082. if (methods instanceof PathVisitor) {
  20083. return methods;
  20084. }
  20085. if (!isObject.check(methods)) {
  20086. // An empty visitor?
  20087. return new PathVisitor;
  20088. }
  20089. function Visitor() {
  20090. assert.ok(this instanceof Visitor);
  20091. PathVisitor.call(this);
  20092. }
  20093. var Vp = Visitor.prototype = Object.create(PVp);
  20094. Vp.constructor = Visitor;
  20095. extend(Vp, methods);
  20096. extend(Visitor, PathVisitor);
  20097. isFunction.assert(Visitor.fromMethodsObject);
  20098. isFunction.assert(Visitor.visit);
  20099. return new Visitor;
  20100. };
  20101. function extend(target, source) {
  20102. for (var property in source) {
  20103. if (hasOwn.call(source, property)) {
  20104. target[property] = source[property];
  20105. }
  20106. }
  20107. return target;
  20108. }
  20109. PathVisitor.visit = function visit(node, methods) {
  20110. return PathVisitor.fromMethodsObject(methods).visit(node);
  20111. };
  20112. var PVp = PathVisitor.prototype;
  20113. var recursiveVisitWarning = [
  20114. "Recursively calling visitor.visit(path) resets visitor state.",
  20115. "Try this.visit(path) or this.traverse(path) instead."
  20116. ].join(" ");
  20117. PVp.visit = function() {
  20118. assert.ok(!this._visiting, recursiveVisitWarning);
  20119. // Private state that needs to be reset before every traversal.
  20120. this._visiting = true;
  20121. this._changeReported = false;
  20122. this._abortRequested = false;
  20123. var argc = arguments.length;
  20124. var args = new Array(argc)
  20125. for (var i = 0; i < argc; ++i) {
  20126. args[i] = arguments[i];
  20127. }
  20128. if (!(args[0] instanceof NodePath)) {
  20129. args[0] = new NodePath({ root: args[0] }).get("root");
  20130. }
  20131. // Called with the same arguments as .visit.
  20132. this.reset.apply(this, args);
  20133. try {
  20134. var root = this.visitWithoutReset(args[0]);
  20135. var didNotThrow = true;
  20136. } finally {
  20137. this._visiting = false;
  20138. if (!didNotThrow && this._abortRequested) {
  20139. // If this.visitWithoutReset threw an exception and
  20140. // this._abortRequested was set to true, return the root of
  20141. // the AST instead of letting the exception propagate, so that
  20142. // client code does not have to provide a try-catch block to
  20143. // intercept the AbortRequest exception. Other kinds of
  20144. // exceptions will propagate without being intercepted and
  20145. // rethrown by a catch block, so their stacks will accurately
  20146. // reflect the original throwing context.
  20147. return args[0].value;
  20148. }
  20149. }
  20150. return root;
  20151. };
  20152. PVp.AbortRequest = function AbortRequest() {};
  20153. PVp.abort = function() {
  20154. var visitor = this;
  20155. visitor._abortRequested = true;
  20156. var request = new visitor.AbortRequest();
  20157. // If you decide to catch this exception and stop it from propagating,
  20158. // make sure to call its cancel method to avoid silencing other
  20159. // exceptions that might be thrown later in the traversal.
  20160. request.cancel = function() {
  20161. visitor._abortRequested = false;
  20162. };
  20163. throw request;
  20164. };
  20165. PVp.reset = function(path/*, additional arguments */) {
  20166. // Empty stub; may be reassigned or overridden by subclasses.
  20167. };
  20168. PVp.visitWithoutReset = function(path) {
  20169. if (this instanceof this.Context) {
  20170. // Since this.Context.prototype === this, there's a chance we
  20171. // might accidentally call context.visitWithoutReset. If that
  20172. // happens, re-invoke the method against context.visitor.
  20173. return this.visitor.visitWithoutReset(path);
  20174. }
  20175. assert.ok(path instanceof NodePath);
  20176. var value = path.value;
  20177. var methodName = Printable.check(value) && this._methodNameTable[value.type];
  20178. if (methodName) {
  20179. var context = this.acquireContext(path);
  20180. try {
  20181. return context.invokeVisitorMethod(methodName);
  20182. } finally {
  20183. this.releaseContext(context);
  20184. }
  20185. } else {
  20186. // If there was no visitor method to call, visit the children of
  20187. // this node generically.
  20188. return visitChildren(path, this);
  20189. }
  20190. };
  20191. function visitChildren(path, visitor) {
  20192. assert.ok(path instanceof NodePath);
  20193. assert.ok(visitor instanceof PathVisitor);
  20194. var value = path.value;
  20195. if (isArray.check(value)) {
  20196. path.each(visitor.visitWithoutReset, visitor);
  20197. } else if (!isObject.check(value)) {
  20198. // No children to visit.
  20199. } else {
  20200. var childNames = types.getFieldNames(value);
  20201. // The .comments field of the Node type is hidden, so we only
  20202. // visit it if the visitor defines visitBlock or visitLine, and
  20203. // value.comments is defined.
  20204. if (visitor._shouldVisitComments &&
  20205. value.comments &&
  20206. childNames.indexOf("comments") < 0) {
  20207. childNames.push("comments");
  20208. }
  20209. var childCount = childNames.length;
  20210. var childPaths = [];
  20211. for (var i = 0; i < childCount; ++i) {
  20212. var childName = childNames[i];
  20213. if (!hasOwn.call(value, childName)) {
  20214. value[childName] = types.getFieldValue(value, childName);
  20215. }
  20216. childPaths.push(path.get(childName));
  20217. }
  20218. for (var i = 0; i < childCount; ++i) {
  20219. visitor.visitWithoutReset(childPaths[i]);
  20220. }
  20221. }
  20222. return path.value;
  20223. }
  20224. PVp.acquireContext = function(path) {
  20225. if (this._reusableContextStack.length === 0) {
  20226. return new this.Context(path);
  20227. }
  20228. return this._reusableContextStack.pop().reset(path);
  20229. };
  20230. PVp.releaseContext = function(context) {
  20231. assert.ok(context instanceof this.Context);
  20232. this._reusableContextStack.push(context);
  20233. context.currentPath = null;
  20234. };
  20235. PVp.reportChanged = function() {
  20236. this._changeReported = true;
  20237. };
  20238. PVp.wasChangeReported = function() {
  20239. return this._changeReported;
  20240. };
  20241. function makeContextConstructor(visitor) {
  20242. function Context(path) {
  20243. assert.ok(this instanceof Context);
  20244. assert.ok(this instanceof PathVisitor);
  20245. assert.ok(path instanceof NodePath);
  20246. Object.defineProperty(this, "visitor", {
  20247. value: visitor,
  20248. writable: false,
  20249. enumerable: true,
  20250. configurable: false
  20251. });
  20252. this.currentPath = path;
  20253. this.needToCallTraverse = true;
  20254. Object.seal(this);
  20255. }
  20256. assert.ok(visitor instanceof PathVisitor);
  20257. // Note that the visitor object is the prototype of Context.prototype,
  20258. // so all visitor methods are inherited by context objects.
  20259. var Cp = Context.prototype = Object.create(visitor);
  20260. Cp.constructor = Context;
  20261. extend(Cp, sharedContextProtoMethods);
  20262. return Context;
  20263. }
  20264. // Every PathVisitor has a different this.Context constructor and
  20265. // this.Context.prototype object, but those prototypes can all use the
  20266. // same reset, invokeVisitorMethod, and traverse function objects.
  20267. var sharedContextProtoMethods = Object.create(null);
  20268. sharedContextProtoMethods.reset =
  20269. function reset(path) {
  20270. assert.ok(this instanceof this.Context);
  20271. assert.ok(path instanceof NodePath);
  20272. this.currentPath = path;
  20273. this.needToCallTraverse = true;
  20274. return this;
  20275. };
  20276. sharedContextProtoMethods.invokeVisitorMethod =
  20277. function invokeVisitorMethod(methodName) {
  20278. assert.ok(this instanceof this.Context);
  20279. assert.ok(this.currentPath instanceof NodePath);
  20280. var result = this.visitor[methodName].call(this, this.currentPath);
  20281. if (result === false) {
  20282. // Visitor methods return false to indicate that they have handled
  20283. // their own traversal needs, and we should not complain if
  20284. // this.needToCallTraverse is still true.
  20285. this.needToCallTraverse = false;
  20286. } else if (result !== undefined) {
  20287. // Any other non-undefined value returned from the visitor method
  20288. // is interpreted as a replacement value.
  20289. this.currentPath = this.currentPath.replace(result)[0];
  20290. if (this.needToCallTraverse) {
  20291. // If this.traverse still hasn't been called, visit the
  20292. // children of the replacement node.
  20293. this.traverse(this.currentPath);
  20294. }
  20295. }
  20296. assert.strictEqual(
  20297. this.needToCallTraverse, false,
  20298. "Must either call this.traverse or return false in " + methodName
  20299. );
  20300. var path = this.currentPath;
  20301. return path && path.value;
  20302. };
  20303. sharedContextProtoMethods.traverse =
  20304. function traverse(path, newVisitor) {
  20305. assert.ok(this instanceof this.Context);
  20306. assert.ok(path instanceof NodePath);
  20307. assert.ok(this.currentPath instanceof NodePath);
  20308. this.needToCallTraverse = false;
  20309. return visitChildren(path, PathVisitor.fromMethodsObject(
  20310. newVisitor || this.visitor
  20311. ));
  20312. };
  20313. sharedContextProtoMethods.visit =
  20314. function visit(path, newVisitor) {
  20315. assert.ok(this instanceof this.Context);
  20316. assert.ok(path instanceof NodePath);
  20317. assert.ok(this.currentPath instanceof NodePath);
  20318. this.needToCallTraverse = false;
  20319. return PathVisitor.fromMethodsObject(
  20320. newVisitor || this.visitor
  20321. ).visitWithoutReset(path);
  20322. };
  20323. sharedContextProtoMethods.reportChanged = function reportChanged() {
  20324. this.visitor.reportChanged();
  20325. };
  20326. sharedContextProtoMethods.abort = function abort() {
  20327. this.needToCallTraverse = false;
  20328. this.visitor.abort();
  20329. };
  20330. module.exports = PathVisitor;
  20331. },{"./node-path":182,"./types":187,"assert":190}],184:[function(require,module,exports){
  20332. var assert = require("assert");
  20333. var Op = Object.prototype;
  20334. var hasOwn = Op.hasOwnProperty;
  20335. var types = require("./types");
  20336. var isArray = types.builtInTypes.array;
  20337. var isNumber = types.builtInTypes.number;
  20338. var Ap = Array.prototype;
  20339. var slice = Ap.slice;
  20340. var map = Ap.map;
  20341. function Path(value, parentPath, name) {
  20342. assert.ok(this instanceof Path);
  20343. if (parentPath) {
  20344. assert.ok(parentPath instanceof Path);
  20345. } else {
  20346. parentPath = null;
  20347. name = null;
  20348. }
  20349. // The value encapsulated by this Path, generally equal to
  20350. // parentPath.value[name] if we have a parentPath.
  20351. this.value = value;
  20352. // The immediate parent Path of this Path.
  20353. this.parentPath = parentPath;
  20354. // The name of the property of parentPath.value through which this
  20355. // Path's value was reached.
  20356. this.name = name;
  20357. // Calling path.get("child") multiple times always returns the same
  20358. // child Path object, for both performance and consistency reasons.
  20359. this.__childCache = null;
  20360. }
  20361. var Pp = Path.prototype;
  20362. function getChildCache(path) {
  20363. // Lazily create the child cache. This also cheapens cache
  20364. // invalidation, since you can just reset path.__childCache to null.
  20365. return path.__childCache || (path.__childCache = Object.create(null));
  20366. }
  20367. function getChildPath(path, name) {
  20368. var cache = getChildCache(path);
  20369. var actualChildValue = path.getValueProperty(name);
  20370. var childPath = cache[name];
  20371. if (!hasOwn.call(cache, name) ||
  20372. // Ensure consistency between cache and reality.
  20373. childPath.value !== actualChildValue) {
  20374. childPath = cache[name] = new path.constructor(
  20375. actualChildValue, path, name
  20376. );
  20377. }
  20378. return childPath;
  20379. }
  20380. // This method is designed to be overridden by subclasses that need to
  20381. // handle missing properties, etc.
  20382. Pp.getValueProperty = function getValueProperty(name) {
  20383. return this.value[name];
  20384. };
  20385. Pp.get = function get(name) {
  20386. var path = this;
  20387. var names = arguments;
  20388. var count = names.length;
  20389. for (var i = 0; i < count; ++i) {
  20390. path = getChildPath(path, names[i]);
  20391. }
  20392. return path;
  20393. };
  20394. Pp.each = function each(callback, context) {
  20395. var childPaths = [];
  20396. var len = this.value.length;
  20397. var i = 0;
  20398. // Collect all the original child paths before invoking the callback.
  20399. for (var i = 0; i < len; ++i) {
  20400. if (hasOwn.call(this.value, i)) {
  20401. childPaths[i] = this.get(i);
  20402. }
  20403. }
  20404. // Invoke the callback on just the original child paths, regardless of
  20405. // any modifications made to the array by the callback. I chose these
  20406. // semantics over cleverly invoking the callback on new elements because
  20407. // this way is much easier to reason about.
  20408. context = context || this;
  20409. for (i = 0; i < len; ++i) {
  20410. if (hasOwn.call(childPaths, i)) {
  20411. callback.call(context, childPaths[i]);
  20412. }
  20413. }
  20414. };
  20415. Pp.map = function map(callback, context) {
  20416. var result = [];
  20417. this.each(function(childPath) {
  20418. result.push(callback.call(this, childPath));
  20419. }, context);
  20420. return result;
  20421. };
  20422. Pp.filter = function filter(callback, context) {
  20423. var result = [];
  20424. this.each(function(childPath) {
  20425. if (callback.call(this, childPath)) {
  20426. result.push(childPath);
  20427. }
  20428. }, context);
  20429. return result;
  20430. };
  20431. function emptyMoves() {}
  20432. function getMoves(path, offset, start, end) {
  20433. isArray.assert(path.value);
  20434. if (offset === 0) {
  20435. return emptyMoves;
  20436. }
  20437. var length = path.value.length;
  20438. if (length < 1) {
  20439. return emptyMoves;
  20440. }
  20441. var argc = arguments.length;
  20442. if (argc === 2) {
  20443. start = 0;
  20444. end = length;
  20445. } else if (argc === 3) {
  20446. start = Math.max(start, 0);
  20447. end = length;
  20448. } else {
  20449. start = Math.max(start, 0);
  20450. end = Math.min(end, length);
  20451. }
  20452. isNumber.assert(start);
  20453. isNumber.assert(end);
  20454. var moves = Object.create(null);
  20455. var cache = getChildCache(path);
  20456. for (var i = start; i < end; ++i) {
  20457. if (hasOwn.call(path.value, i)) {
  20458. var childPath = path.get(i);
  20459. assert.strictEqual(childPath.name, i);
  20460. var newIndex = i + offset;
  20461. childPath.name = newIndex;
  20462. moves[newIndex] = childPath;
  20463. delete cache[i];
  20464. }
  20465. }
  20466. delete cache.length;
  20467. return function() {
  20468. for (var newIndex in moves) {
  20469. var childPath = moves[newIndex];
  20470. assert.strictEqual(childPath.name, +newIndex);
  20471. cache[newIndex] = childPath;
  20472. path.value[newIndex] = childPath.value;
  20473. }
  20474. };
  20475. }
  20476. Pp.shift = function shift() {
  20477. var move = getMoves(this, -1);
  20478. var result = this.value.shift();
  20479. move();
  20480. return result;
  20481. };
  20482. Pp.unshift = function unshift(node) {
  20483. var move = getMoves(this, arguments.length);
  20484. var result = this.value.unshift.apply(this.value, arguments);
  20485. move();
  20486. return result;
  20487. };
  20488. Pp.push = function push(node) {
  20489. isArray.assert(this.value);
  20490. delete getChildCache(this).length
  20491. return this.value.push.apply(this.value, arguments);
  20492. };
  20493. Pp.pop = function pop() {
  20494. isArray.assert(this.value);
  20495. var cache = getChildCache(this);
  20496. delete cache[this.value.length - 1];
  20497. delete cache.length;
  20498. return this.value.pop();
  20499. };
  20500. Pp.insertAt = function insertAt(index, node) {
  20501. var argc = arguments.length;
  20502. var move = getMoves(this, argc - 1, index);
  20503. if (move === emptyMoves) {
  20504. return this;
  20505. }
  20506. index = Math.max(index, 0);
  20507. for (var i = 1; i < argc; ++i) {
  20508. this.value[index + i - 1] = arguments[i];
  20509. }
  20510. move();
  20511. return this;
  20512. };
  20513. Pp.insertBefore = function insertBefore(node) {
  20514. var pp = this.parentPath;
  20515. var argc = arguments.length;
  20516. var insertAtArgs = [this.name];
  20517. for (var i = 0; i < argc; ++i) {
  20518. insertAtArgs.push(arguments[i]);
  20519. }
  20520. return pp.insertAt.apply(pp, insertAtArgs);
  20521. };
  20522. Pp.insertAfter = function insertAfter(node) {
  20523. var pp = this.parentPath;
  20524. var argc = arguments.length;
  20525. var insertAtArgs = [this.name + 1];
  20526. for (var i = 0; i < argc; ++i) {
  20527. insertAtArgs.push(arguments[i]);
  20528. }
  20529. return pp.insertAt.apply(pp, insertAtArgs);
  20530. };
  20531. function repairRelationshipWithParent(path) {
  20532. assert.ok(path instanceof Path);
  20533. var pp = path.parentPath;
  20534. if (!pp) {
  20535. // Orphan paths have no relationship to repair.
  20536. return path;
  20537. }
  20538. var parentValue = pp.value;
  20539. var parentCache = getChildCache(pp);
  20540. // Make sure parentCache[path.name] is populated.
  20541. if (parentValue[path.name] === path.value) {
  20542. parentCache[path.name] = path;
  20543. } else if (isArray.check(parentValue)) {
  20544. // Something caused path.name to become out of date, so attempt to
  20545. // recover by searching for path.value in parentValue.
  20546. var i = parentValue.indexOf(path.value);
  20547. if (i >= 0) {
  20548. parentCache[path.name = i] = path;
  20549. }
  20550. } else {
  20551. // If path.value disagrees with parentValue[path.name], and
  20552. // path.name is not an array index, let path.value become the new
  20553. // parentValue[path.name] and update parentCache accordingly.
  20554. parentValue[path.name] = path.value;
  20555. parentCache[path.name] = path;
  20556. }
  20557. assert.strictEqual(parentValue[path.name], path.value);
  20558. assert.strictEqual(path.parentPath.get(path.name), path);
  20559. return path;
  20560. }
  20561. Pp.replace = function replace(replacement) {
  20562. var results = [];
  20563. var parentValue = this.parentPath.value;
  20564. var parentCache = getChildCache(this.parentPath);
  20565. var count = arguments.length;
  20566. repairRelationshipWithParent(this);
  20567. if (isArray.check(parentValue)) {
  20568. var originalLength = parentValue.length;
  20569. var move = getMoves(this.parentPath, count - 1, this.name + 1);
  20570. var spliceArgs = [this.name, 1];
  20571. for (var i = 0; i < count; ++i) {
  20572. spliceArgs.push(arguments[i]);
  20573. }
  20574. var splicedOut = parentValue.splice.apply(parentValue, spliceArgs);
  20575. assert.strictEqual(splicedOut[0], this.value);
  20576. assert.strictEqual(
  20577. parentValue.length,
  20578. originalLength - 1 + count
  20579. );
  20580. move();
  20581. if (count === 0) {
  20582. delete this.value;
  20583. delete parentCache[this.name];
  20584. this.__childCache = null;
  20585. } else {
  20586. assert.strictEqual(parentValue[this.name], replacement);
  20587. if (this.value !== replacement) {
  20588. this.value = replacement;
  20589. this.__childCache = null;
  20590. }
  20591. for (i = 0; i < count; ++i) {
  20592. results.push(this.parentPath.get(this.name + i));
  20593. }
  20594. assert.strictEqual(results[0], this);
  20595. }
  20596. } else if (count === 1) {
  20597. if (this.value !== replacement) {
  20598. this.__childCache = null;
  20599. }
  20600. this.value = parentValue[this.name] = replacement;
  20601. results.push(this);
  20602. } else if (count === 0) {
  20603. delete parentValue[this.name];
  20604. delete this.value;
  20605. this.__childCache = null;
  20606. // Leave this path cached as parentCache[this.name], even though
  20607. // it no longer has a value defined.
  20608. } else {
  20609. assert.ok(false, "Could not replace path");
  20610. }
  20611. return results;
  20612. };
  20613. module.exports = Path;
  20614. },{"./types":187,"assert":190}],185:[function(require,module,exports){
  20615. var assert = require("assert");
  20616. var types = require("./types");
  20617. var Type = types.Type;
  20618. var namedTypes = types.namedTypes;
  20619. var Node = namedTypes.Node;
  20620. var Expression = namedTypes.Expression;
  20621. var isArray = types.builtInTypes.array;
  20622. var hasOwn = Object.prototype.hasOwnProperty;
  20623. var b = types.builders;
  20624. function Scope(path, parentScope) {
  20625. assert.ok(this instanceof Scope);
  20626. assert.ok(path instanceof require("./node-path"));
  20627. ScopeType.assert(path.value);
  20628. var depth;
  20629. if (parentScope) {
  20630. assert.ok(parentScope instanceof Scope);
  20631. depth = parentScope.depth + 1;
  20632. } else {
  20633. parentScope = null;
  20634. depth = 0;
  20635. }
  20636. Object.defineProperties(this, {
  20637. path: { value: path },
  20638. node: { value: path.value },
  20639. isGlobal: { value: !parentScope, enumerable: true },
  20640. depth: { value: depth },
  20641. parent: { value: parentScope },
  20642. bindings: { value: {} }
  20643. });
  20644. }
  20645. var scopeTypes = [
  20646. // Program nodes introduce global scopes.
  20647. namedTypes.Program,
  20648. // Function is the supertype of FunctionExpression,
  20649. // FunctionDeclaration, ArrowExpression, etc.
  20650. namedTypes.Function,
  20651. // In case you didn't know, the caught parameter shadows any variable
  20652. // of the same name in an outer scope.
  20653. namedTypes.CatchClause
  20654. ];
  20655. var ScopeType = Type.or.apply(Type, scopeTypes);
  20656. Scope.isEstablishedBy = function(node) {
  20657. return ScopeType.check(node);
  20658. };
  20659. var Sp = Scope.prototype;
  20660. // Will be overridden after an instance lazily calls scanScope.
  20661. Sp.didScan = false;
  20662. Sp.declares = function(name) {
  20663. this.scan();
  20664. return hasOwn.call(this.bindings, name);
  20665. };
  20666. Sp.declareTemporary = function(prefix) {
  20667. if (prefix) {
  20668. assert.ok(/^[a-z$_]/i.test(prefix), prefix);
  20669. } else {
  20670. prefix = "t$";
  20671. }
  20672. // Include this.depth in the name to make sure the name does not
  20673. // collide with any variables in nested/enclosing scopes.
  20674. prefix += this.depth.toString(36) + "$";
  20675. this.scan();
  20676. var index = 0;
  20677. while (this.declares(prefix + index)) {
  20678. ++index;
  20679. }
  20680. var name = prefix + index;
  20681. return this.bindings[name] = types.builders.identifier(name);
  20682. };
  20683. Sp.injectTemporary = function(identifier, init) {
  20684. identifier || (identifier = this.declareTemporary());
  20685. var bodyPath = this.path.get("body");
  20686. if (namedTypes.BlockStatement.check(bodyPath.value)) {
  20687. bodyPath = bodyPath.get("body");
  20688. }
  20689. bodyPath.unshift(
  20690. b.variableDeclaration(
  20691. "var",
  20692. [b.variableDeclarator(identifier, init || null)]
  20693. )
  20694. );
  20695. return identifier;
  20696. };
  20697. Sp.scan = function(force) {
  20698. if (force || !this.didScan) {
  20699. for (var name in this.bindings) {
  20700. // Empty out this.bindings, just in cases.
  20701. delete this.bindings[name];
  20702. }
  20703. scanScope(this.path, this.bindings);
  20704. this.didScan = true;
  20705. }
  20706. };
  20707. Sp.getBindings = function () {
  20708. this.scan();
  20709. return this.bindings;
  20710. };
  20711. function scanScope(path, bindings) {
  20712. var node = path.value;
  20713. ScopeType.assert(node);
  20714. if (namedTypes.CatchClause.check(node)) {
  20715. // A catch clause establishes a new scope but the only variable
  20716. // bound in that scope is the catch parameter. Any other
  20717. // declarations create bindings in the outer scope.
  20718. addPattern(path.get("param"), bindings);
  20719. } else {
  20720. recursiveScanScope(path, bindings);
  20721. }
  20722. }
  20723. function recursiveScanScope(path, bindings) {
  20724. var node = path.value;
  20725. if (path.parent &&
  20726. namedTypes.FunctionExpression.check(path.parent.node) &&
  20727. path.parent.node.id) {
  20728. addPattern(path.parent.get("id"), bindings);
  20729. }
  20730. if (!node) {
  20731. // None of the remaining cases matter if node is falsy.
  20732. } else if (isArray.check(node)) {
  20733. path.each(function(childPath) {
  20734. recursiveScanChild(childPath, bindings);
  20735. });
  20736. } else if (namedTypes.Function.check(node)) {
  20737. path.get("params").each(function(paramPath) {
  20738. addPattern(paramPath, bindings);
  20739. });
  20740. recursiveScanChild(path.get("body"), bindings);
  20741. } else if (namedTypes.VariableDeclarator.check(node)) {
  20742. addPattern(path.get("id"), bindings);
  20743. recursiveScanChild(path.get("init"), bindings);
  20744. } else if (node.type === "ImportSpecifier" ||
  20745. node.type === "ImportNamespaceSpecifier" ||
  20746. node.type === "ImportDefaultSpecifier") {
  20747. addPattern(
  20748. // Esprima used to use the .name field to refer to the local
  20749. // binding identifier for ImportSpecifier nodes, but .id for
  20750. // ImportNamespaceSpecifier and ImportDefaultSpecifier nodes.
  20751. // ESTree/Acorn/ESpree use .local for all three node types.
  20752. path.get(node.local ? "local" :
  20753. node.name ? "name" : "id"),
  20754. bindings
  20755. );
  20756. } else if (Node.check(node) && !Expression.check(node)) {
  20757. types.eachField(node, function(name, child) {
  20758. var childPath = path.get(name);
  20759. assert.strictEqual(childPath.value, child);
  20760. recursiveScanChild(childPath, bindings);
  20761. });
  20762. }
  20763. }
  20764. function recursiveScanChild(path, bindings) {
  20765. var node = path.value;
  20766. if (!node || Expression.check(node)) {
  20767. // Ignore falsy values and Expressions.
  20768. } else if (namedTypes.FunctionDeclaration.check(node)) {
  20769. addPattern(path.get("id"), bindings);
  20770. } else if (namedTypes.ClassDeclaration &&
  20771. namedTypes.ClassDeclaration.check(node)) {
  20772. addPattern(path.get("id"), bindings);
  20773. } else if (ScopeType.check(node)) {
  20774. if (namedTypes.CatchClause.check(node)) {
  20775. var catchParamName = node.param.name;
  20776. var hadBinding = hasOwn.call(bindings, catchParamName);
  20777. // Any declarations that occur inside the catch body that do
  20778. // not have the same name as the catch parameter should count
  20779. // as bindings in the outer scope.
  20780. recursiveScanScope(path.get("body"), bindings);
  20781. // If a new binding matching the catch parameter name was
  20782. // created while scanning the catch body, ignore it because it
  20783. // actually refers to the catch parameter and not the outer
  20784. // scope that we're currently scanning.
  20785. if (!hadBinding) {
  20786. delete bindings[catchParamName];
  20787. }
  20788. }
  20789. } else {
  20790. recursiveScanScope(path, bindings);
  20791. }
  20792. }
  20793. function addPattern(patternPath, bindings) {
  20794. var pattern = patternPath.value;
  20795. namedTypes.Pattern.assert(pattern);
  20796. if (namedTypes.Identifier.check(pattern)) {
  20797. if (hasOwn.call(bindings, pattern.name)) {
  20798. bindings[pattern.name].push(patternPath);
  20799. } else {
  20800. bindings[pattern.name] = [patternPath];
  20801. }
  20802. } else if (namedTypes.ObjectPattern &&
  20803. namedTypes.ObjectPattern.check(pattern)) {
  20804. patternPath.get('properties').each(function(propertyPath) {
  20805. var property = propertyPath.value;
  20806. if (namedTypes.Pattern.check(property)) {
  20807. addPattern(propertyPath, bindings);
  20808. } else if (namedTypes.Property.check(property)) {
  20809. addPattern(propertyPath.get('value'), bindings);
  20810. } else if (namedTypes.SpreadProperty &&
  20811. namedTypes.SpreadProperty.check(property)) {
  20812. addPattern(propertyPath.get('argument'), bindings);
  20813. }
  20814. });
  20815. } else if (namedTypes.ArrayPattern &&
  20816. namedTypes.ArrayPattern.check(pattern)) {
  20817. patternPath.get('elements').each(function(elementPath) {
  20818. var element = elementPath.value;
  20819. if (namedTypes.Pattern.check(element)) {
  20820. addPattern(elementPath, bindings);
  20821. } else if (namedTypes.SpreadElement &&
  20822. namedTypes.SpreadElement.check(element)) {
  20823. addPattern(elementPath.get("argument"), bindings);
  20824. }
  20825. });
  20826. } else if (namedTypes.PropertyPattern &&
  20827. namedTypes.PropertyPattern.check(pattern)) {
  20828. addPattern(patternPath.get('pattern'), bindings);
  20829. } else if ((namedTypes.SpreadElementPattern &&
  20830. namedTypes.SpreadElementPattern.check(pattern)) ||
  20831. (namedTypes.SpreadPropertyPattern &&
  20832. namedTypes.SpreadPropertyPattern.check(pattern))) {
  20833. addPattern(patternPath.get('argument'), bindings);
  20834. }
  20835. }
  20836. Sp.lookup = function(name) {
  20837. for (var scope = this; scope; scope = scope.parent)
  20838. if (scope.declares(name))
  20839. break;
  20840. return scope;
  20841. };
  20842. Sp.getGlobalScope = function() {
  20843. var scope = this;
  20844. while (!scope.isGlobal)
  20845. scope = scope.parent;
  20846. return scope;
  20847. };
  20848. module.exports = Scope;
  20849. },{"./node-path":182,"./types":187,"assert":190}],186:[function(require,module,exports){
  20850. var types = require("../lib/types");
  20851. var Type = types.Type;
  20852. var builtin = types.builtInTypes;
  20853. var isNumber = builtin.number;
  20854. // An example of constructing a new type with arbitrary constraints from
  20855. // an existing type.
  20856. exports.geq = function(than) {
  20857. return new Type(function(value) {
  20858. return isNumber.check(value) && value >= than;
  20859. }, isNumber + " >= " + than);
  20860. };
  20861. // Default value-returning functions that may optionally be passed as a
  20862. // third argument to Def.prototype.field.
  20863. exports.defaults = {
  20864. // Functions were used because (among other reasons) that's the most
  20865. // elegant way to allow for the emptyArray one always to give a new
  20866. // array instance.
  20867. "null": function() { return null },
  20868. "emptyArray": function() { return [] },
  20869. "false": function() { return false },
  20870. "true": function() { return true },
  20871. "undefined": function() {}
  20872. };
  20873. var naiveIsPrimitive = Type.or(
  20874. builtin.string,
  20875. builtin.number,
  20876. builtin.boolean,
  20877. builtin.null,
  20878. builtin.undefined
  20879. );
  20880. exports.isPrimitive = new Type(function(value) {
  20881. if (value === null)
  20882. return true;
  20883. var type = typeof value;
  20884. return !(type === "object" ||
  20885. type === "function");
  20886. }, naiveIsPrimitive.toString());
  20887. },{"../lib/types":187}],187:[function(require,module,exports){
  20888. var assert = require("assert");
  20889. var Ap = Array.prototype;
  20890. var slice = Ap.slice;
  20891. var map = Ap.map;
  20892. var each = Ap.forEach;
  20893. var Op = Object.prototype;
  20894. var objToStr = Op.toString;
  20895. var funObjStr = objToStr.call(function(){});
  20896. var strObjStr = objToStr.call("");
  20897. var hasOwn = Op.hasOwnProperty;
  20898. // A type is an object with a .check method that takes a value and returns
  20899. // true or false according to whether the value matches the type.
  20900. function Type(check, name) {
  20901. var self = this;
  20902. assert.ok(self instanceof Type, self);
  20903. // Unfortunately we can't elegantly reuse isFunction and isString,
  20904. // here, because this code is executed while defining those types.
  20905. assert.strictEqual(objToStr.call(check), funObjStr,
  20906. check + " is not a function");
  20907. // The `name` parameter can be either a function or a string.
  20908. var nameObjStr = objToStr.call(name);
  20909. assert.ok(nameObjStr === funObjStr ||
  20910. nameObjStr === strObjStr,
  20911. name + " is neither a function nor a string");
  20912. Object.defineProperties(self, {
  20913. name: { value: name },
  20914. check: {
  20915. value: function(value, deep) {
  20916. var result = check.call(self, value, deep);
  20917. if (!result && deep && objToStr.call(deep) === funObjStr)
  20918. deep(self, value);
  20919. return result;
  20920. }
  20921. }
  20922. });
  20923. }
  20924. var Tp = Type.prototype;
  20925. // Throughout this file we use Object.defineProperty to prevent
  20926. // redefinition of exported properties.
  20927. exports.Type = Type;
  20928. // Like .check, except that failure triggers an AssertionError.
  20929. Tp.assert = function(value, deep) {
  20930. if (!this.check(value, deep)) {
  20931. var str = shallowStringify(value);
  20932. assert.ok(false, str + " does not match type " + this);
  20933. return false;
  20934. }
  20935. return true;
  20936. };
  20937. function shallowStringify(value) {
  20938. if (isObject.check(value))
  20939. return "{" + Object.keys(value).map(function(key) {
  20940. return key + ": " + value[key];
  20941. }).join(", ") + "}";
  20942. if (isArray.check(value))
  20943. return "[" + value.map(shallowStringify).join(", ") + "]";
  20944. return JSON.stringify(value);
  20945. }
  20946. Tp.toString = function() {
  20947. var name = this.name;
  20948. if (isString.check(name))
  20949. return name;
  20950. if (isFunction.check(name))
  20951. return name.call(this) + "";
  20952. return name + " type";
  20953. };
  20954. var builtInTypes = {};
  20955. exports.builtInTypes = builtInTypes;
  20956. function defBuiltInType(example, name) {
  20957. var objStr = objToStr.call(example);
  20958. Object.defineProperty(builtInTypes, name, {
  20959. enumerable: true,
  20960. value: new Type(function(value) {
  20961. return objToStr.call(value) === objStr;
  20962. }, name)
  20963. });
  20964. return builtInTypes[name];
  20965. }
  20966. // These types check the underlying [[Class]] attribute of the given
  20967. // value, rather than using the problematic typeof operator. Note however
  20968. // that no subtyping is considered; so, for instance, isObject.check
  20969. // returns false for [], /./, new Date, and null.
  20970. var isString = defBuiltInType("", "string");
  20971. var isFunction = defBuiltInType(function(){}, "function");
  20972. var isArray = defBuiltInType([], "array");
  20973. var isObject = defBuiltInType({}, "object");
  20974. var isRegExp = defBuiltInType(/./, "RegExp");
  20975. var isDate = defBuiltInType(new Date, "Date");
  20976. var isNumber = defBuiltInType(3, "number");
  20977. var isBoolean = defBuiltInType(true, "boolean");
  20978. var isNull = defBuiltInType(null, "null");
  20979. var isUndefined = defBuiltInType(void 0, "undefined");
  20980. // There are a number of idiomatic ways of expressing types, so this
  20981. // function serves to coerce them all to actual Type objects. Note that
  20982. // providing the name argument is not necessary in most cases.
  20983. function toType(from, name) {
  20984. // The toType function should of course be idempotent.
  20985. if (from instanceof Type)
  20986. return from;
  20987. // The Def type is used as a helper for constructing compound
  20988. // interface types for AST nodes.
  20989. if (from instanceof Def)
  20990. return from.type;
  20991. // Support [ElemType] syntax.
  20992. if (isArray.check(from))
  20993. return Type.fromArray(from);
  20994. // Support { someField: FieldType, ... } syntax.
  20995. if (isObject.check(from))
  20996. return Type.fromObject(from);
  20997. // If isFunction.check(from), assume that from is a binary predicate
  20998. // function we can use to define the type.
  20999. if (isFunction.check(from))
  21000. return new Type(from, name);
  21001. // As a last resort, toType returns a type that matches any value that
  21002. // is === from. This is primarily useful for literal values like
  21003. // toType(null), but it has the additional advantage of allowing
  21004. // toType to be a total function.
  21005. return new Type(function(value) {
  21006. return value === from;
  21007. }, isUndefined.check(name) ? function() {
  21008. return from + "";
  21009. } : name);
  21010. }
  21011. // Returns a type that matches the given value iff any of type1, type2,
  21012. // etc. match the value.
  21013. Type.or = function(/* type1, type2, ... */) {
  21014. var types = [];
  21015. var len = arguments.length;
  21016. for (var i = 0; i < len; ++i)
  21017. types.push(toType(arguments[i]));
  21018. return new Type(function(value, deep) {
  21019. for (var i = 0; i < len; ++i)
  21020. if (types[i].check(value, deep))
  21021. return true;
  21022. return false;
  21023. }, function() {
  21024. return types.join(" | ");
  21025. });
  21026. };
  21027. Type.fromArray = function(arr) {
  21028. assert.ok(isArray.check(arr));
  21029. assert.strictEqual(
  21030. arr.length, 1,
  21031. "only one element type is permitted for typed arrays");
  21032. return toType(arr[0]).arrayOf();
  21033. };
  21034. Tp.arrayOf = function() {
  21035. var elemType = this;
  21036. return new Type(function(value, deep) {
  21037. return isArray.check(value) && value.every(function(elem) {
  21038. return elemType.check(elem, deep);
  21039. });
  21040. }, function() {
  21041. return "[" + elemType + "]";
  21042. });
  21043. };
  21044. Type.fromObject = function(obj) {
  21045. var fields = Object.keys(obj).map(function(name) {
  21046. return new Field(name, obj[name]);
  21047. });
  21048. return new Type(function(value, deep) {
  21049. return isObject.check(value) && fields.every(function(field) {
  21050. return field.type.check(value[field.name], deep);
  21051. });
  21052. }, function() {
  21053. return "{ " + fields.join(", ") + " }";
  21054. });
  21055. };
  21056. function Field(name, type, defaultFn, hidden) {
  21057. var self = this;
  21058. assert.ok(self instanceof Field);
  21059. isString.assert(name);
  21060. type = toType(type);
  21061. var properties = {
  21062. name: { value: name },
  21063. type: { value: type },
  21064. hidden: { value: !!hidden }
  21065. };
  21066. if (isFunction.check(defaultFn)) {
  21067. properties.defaultFn = { value: defaultFn };
  21068. }
  21069. Object.defineProperties(self, properties);
  21070. }
  21071. var Fp = Field.prototype;
  21072. Fp.toString = function() {
  21073. return JSON.stringify(this.name) + ": " + this.type;
  21074. };
  21075. Fp.getValue = function(obj) {
  21076. var value = obj[this.name];
  21077. if (!isUndefined.check(value))
  21078. return value;
  21079. if (this.defaultFn)
  21080. value = this.defaultFn.call(obj);
  21081. return value;
  21082. };
  21083. // Define a type whose name is registered in a namespace (the defCache) so
  21084. // that future definitions will return the same type given the same name.
  21085. // In particular, this system allows for circular and forward definitions.
  21086. // The Def object d returned from Type.def may be used to configure the
  21087. // type d.type by calling methods such as d.bases, d.build, and d.field.
  21088. Type.def = function(typeName) {
  21089. isString.assert(typeName);
  21090. return hasOwn.call(defCache, typeName)
  21091. ? defCache[typeName]
  21092. : defCache[typeName] = new Def(typeName);
  21093. };
  21094. // In order to return the same Def instance every time Type.def is called
  21095. // with a particular name, those instances need to be stored in a cache.
  21096. var defCache = Object.create(null);
  21097. function Def(typeName) {
  21098. var self = this;
  21099. assert.ok(self instanceof Def);
  21100. Object.defineProperties(self, {
  21101. typeName: { value: typeName },
  21102. baseNames: { value: [] },
  21103. ownFields: { value: Object.create(null) },
  21104. // These two are populated during finalization.
  21105. allSupertypes: { value: Object.create(null) }, // Includes own typeName.
  21106. supertypeList: { value: [] }, // Linear inheritance hierarchy.
  21107. allFields: { value: Object.create(null) }, // Includes inherited fields.
  21108. fieldNames: { value: [] }, // Non-hidden keys of allFields.
  21109. type: {
  21110. value: new Type(function(value, deep) {
  21111. return self.check(value, deep);
  21112. }, typeName)
  21113. }
  21114. });
  21115. }
  21116. Def.fromValue = function(value) {
  21117. if (value && typeof value === "object") {
  21118. var type = value.type;
  21119. if (typeof type === "string" &&
  21120. hasOwn.call(defCache, type)) {
  21121. var d = defCache[type];
  21122. if (d.finalized) {
  21123. return d;
  21124. }
  21125. }
  21126. }
  21127. return null;
  21128. };
  21129. var Dp = Def.prototype;
  21130. Dp.isSupertypeOf = function(that) {
  21131. if (that instanceof Def) {
  21132. assert.strictEqual(this.finalized, true);
  21133. assert.strictEqual(that.finalized, true);
  21134. return hasOwn.call(that.allSupertypes, this.typeName);
  21135. } else {
  21136. assert.ok(false, that + " is not a Def");
  21137. }
  21138. };
  21139. // Note that the list returned by this function is a copy of the internal
  21140. // supertypeList, *without* the typeName itself as the first element.
  21141. exports.getSupertypeNames = function(typeName) {
  21142. assert.ok(hasOwn.call(defCache, typeName));
  21143. var d = defCache[typeName];
  21144. assert.strictEqual(d.finalized, true);
  21145. return d.supertypeList.slice(1);
  21146. };
  21147. // Returns an object mapping from every known type in the defCache to the
  21148. // most specific supertype whose name is an own property of the candidates
  21149. // object.
  21150. exports.computeSupertypeLookupTable = function(candidates) {
  21151. var table = {};
  21152. var typeNames = Object.keys(defCache);
  21153. var typeNameCount = typeNames.length;
  21154. for (var i = 0; i < typeNameCount; ++i) {
  21155. var typeName = typeNames[i];
  21156. var d = defCache[typeName];
  21157. assert.strictEqual(d.finalized, true);
  21158. for (var j = 0; j < d.supertypeList.length; ++j) {
  21159. var superTypeName = d.supertypeList[j];
  21160. if (hasOwn.call(candidates, superTypeName)) {
  21161. table[typeName] = superTypeName;
  21162. break;
  21163. }
  21164. }
  21165. }
  21166. return table;
  21167. };
  21168. Dp.checkAllFields = function(value, deep) {
  21169. var allFields = this.allFields;
  21170. assert.strictEqual(this.finalized, true);
  21171. function checkFieldByName(name) {
  21172. var field = allFields[name];
  21173. var type = field.type;
  21174. var child = field.getValue(value);
  21175. return type.check(child, deep);
  21176. }
  21177. return isObject.check(value)
  21178. && Object.keys(allFields).every(checkFieldByName);
  21179. };
  21180. Dp.check = function(value, deep) {
  21181. assert.strictEqual(
  21182. this.finalized, true,
  21183. "prematurely checking unfinalized type " + this.typeName);
  21184. // A Def type can only match an object value.
  21185. if (!isObject.check(value))
  21186. return false;
  21187. var vDef = Def.fromValue(value);
  21188. if (!vDef) {
  21189. // If we couldn't infer the Def associated with the given value,
  21190. // and we expected it to be a SourceLocation or a Position, it was
  21191. // probably just missing a "type" field (because Esprima does not
  21192. // assign a type property to such nodes). Be optimistic and let
  21193. // this.checkAllFields make the final decision.
  21194. if (this.typeName === "SourceLocation" ||
  21195. this.typeName === "Position") {
  21196. return this.checkAllFields(value, deep);
  21197. }
  21198. // Calling this.checkAllFields for any other type of node is both
  21199. // bad for performance and way too forgiving.
  21200. return false;
  21201. }
  21202. // If checking deeply and vDef === this, then we only need to call
  21203. // checkAllFields once. Calling checkAllFields is too strict when deep
  21204. // is false, because then we only care about this.isSupertypeOf(vDef).
  21205. if (deep && vDef === this)
  21206. return this.checkAllFields(value, deep);
  21207. // In most cases we rely exclusively on isSupertypeOf to make O(1)
  21208. // subtyping determinations. This suffices in most situations outside
  21209. // of unit tests, since interface conformance is checked whenever new
  21210. // instances are created using builder functions.
  21211. if (!this.isSupertypeOf(vDef))
  21212. return false;
  21213. // The exception is when deep is true; then, we recursively check all
  21214. // fields.
  21215. if (!deep)
  21216. return true;
  21217. // Use the more specific Def (vDef) to perform the deep check, but
  21218. // shallow-check fields defined by the less specific Def (this).
  21219. return vDef.checkAllFields(value, deep)
  21220. && this.checkAllFields(value, false);
  21221. };
  21222. Dp.bases = function() {
  21223. var bases = this.baseNames;
  21224. assert.strictEqual(this.finalized, false);
  21225. each.call(arguments, function(baseName) {
  21226. isString.assert(baseName);
  21227. // This indexOf lookup may be O(n), but the typical number of base
  21228. // names is very small, and indexOf is a native Array method.
  21229. if (bases.indexOf(baseName) < 0)
  21230. bases.push(baseName);
  21231. });
  21232. return this; // For chaining.
  21233. };
  21234. // False by default until .build(...) is called on an instance.
  21235. Object.defineProperty(Dp, "buildable", { value: false });
  21236. var builders = {};
  21237. exports.builders = builders;
  21238. // This object is used as prototype for any node created by a builder.
  21239. var nodePrototype = {};
  21240. // Call this function to define a new method to be shared by all AST
  21241. // nodes. The replaced method (if any) is returned for easy wrapping.
  21242. exports.defineMethod = function(name, func) {
  21243. var old = nodePrototype[name];
  21244. // Pass undefined as func to delete nodePrototype[name].
  21245. if (isUndefined.check(func)) {
  21246. delete nodePrototype[name];
  21247. } else {
  21248. isFunction.assert(func);
  21249. Object.defineProperty(nodePrototype, name, {
  21250. enumerable: true, // For discoverability.
  21251. configurable: true, // For delete proto[name].
  21252. value: func
  21253. });
  21254. }
  21255. return old;
  21256. };
  21257. // Calling the .build method of a Def simultaneously marks the type as
  21258. // buildable (by defining builders[getBuilderName(typeName)]) and
  21259. // specifies the order of arguments that should be passed to the builder
  21260. // function to create an instance of the type.
  21261. Dp.build = function(/* param1, param2, ... */) {
  21262. var self = this;
  21263. // Calling Def.prototype.build multiple times has the effect of merely
  21264. // redefining this property.
  21265. Object.defineProperty(self, "buildParams", {
  21266. value: slice.call(arguments),
  21267. writable: false,
  21268. enumerable: false,
  21269. configurable: true
  21270. });
  21271. assert.strictEqual(self.finalized, false);
  21272. isString.arrayOf().assert(self.buildParams);
  21273. if (self.buildable) {
  21274. // If this Def is already buildable, update self.buildParams and
  21275. // continue using the old builder function.
  21276. return self;
  21277. }
  21278. // Every buildable type will have its "type" field filled in
  21279. // automatically. This includes types that are not subtypes of Node,
  21280. // like SourceLocation, but that seems harmless (TODO?).
  21281. self.field("type", self.typeName, function() { return self.typeName });
  21282. // Override Dp.buildable for this Def instance.
  21283. Object.defineProperty(self, "buildable", { value: true });
  21284. Object.defineProperty(builders, getBuilderName(self.typeName), {
  21285. enumerable: true,
  21286. value: function() {
  21287. var args = arguments;
  21288. var argc = args.length;
  21289. var built = Object.create(nodePrototype);
  21290. assert.ok(
  21291. self.finalized,
  21292. "attempting to instantiate unfinalized type " + self.typeName);
  21293. function add(param, i) {
  21294. if (hasOwn.call(built, param))
  21295. return;
  21296. var all = self.allFields;
  21297. assert.ok(hasOwn.call(all, param), param);
  21298. var field = all[param];
  21299. var type = field.type;
  21300. var value;
  21301. if (isNumber.check(i) && i < argc) {
  21302. value = args[i];
  21303. } else if (field.defaultFn) {
  21304. // Expose the partially-built object to the default
  21305. // function as its `this` object.
  21306. value = field.defaultFn.call(built);
  21307. } else {
  21308. var message = "no value or default function given for field " +
  21309. JSON.stringify(param) + " of " + self.typeName + "(" +
  21310. self.buildParams.map(function(name) {
  21311. return all[name];
  21312. }).join(", ") + ")";
  21313. assert.ok(false, message);
  21314. }
  21315. if (!type.check(value)) {
  21316. assert.ok(
  21317. false,
  21318. shallowStringify(value) +
  21319. " does not match field " + field +
  21320. " of type " + self.typeName
  21321. );
  21322. }
  21323. // TODO Could attach getters and setters here to enforce
  21324. // dynamic type safety.
  21325. built[param] = value;
  21326. }
  21327. self.buildParams.forEach(function(param, i) {
  21328. add(param, i);
  21329. });
  21330. Object.keys(self.allFields).forEach(function(param) {
  21331. add(param); // Use the default value.
  21332. });
  21333. // Make sure that the "type" field was filled automatically.
  21334. assert.strictEqual(built.type, self.typeName);
  21335. return built;
  21336. }
  21337. });
  21338. return self; // For chaining.
  21339. };
  21340. function getBuilderName(typeName) {
  21341. return typeName.replace(/^[A-Z]+/, function(upperCasePrefix) {
  21342. var len = upperCasePrefix.length;
  21343. switch (len) {
  21344. case 0: return "";
  21345. // If there's only one initial capital letter, just lower-case it.
  21346. case 1: return upperCasePrefix.toLowerCase();
  21347. default:
  21348. // If there's more than one initial capital letter, lower-case
  21349. // all but the last one, so that XMLDefaultDeclaration (for
  21350. // example) becomes xmlDefaultDeclaration.
  21351. return upperCasePrefix.slice(
  21352. 0, len - 1).toLowerCase() +
  21353. upperCasePrefix.charAt(len - 1);
  21354. }
  21355. });
  21356. }
  21357. // The reason fields are specified using .field(...) instead of an object
  21358. // literal syntax is somewhat subtle: the object literal syntax would
  21359. // support only one key and one value, but with .field(...) we can pass
  21360. // any number of arguments to specify the field.
  21361. Dp.field = function(name, type, defaultFn, hidden) {
  21362. assert.strictEqual(this.finalized, false);
  21363. this.ownFields[name] = new Field(name, type, defaultFn, hidden);
  21364. return this; // For chaining.
  21365. };
  21366. var namedTypes = {};
  21367. exports.namedTypes = namedTypes;
  21368. // Like Object.keys, but aware of what fields each AST type should have.
  21369. function getFieldNames(object) {
  21370. var d = Def.fromValue(object);
  21371. if (d) {
  21372. return d.fieldNames.slice(0);
  21373. }
  21374. if ("type" in object) {
  21375. assert.ok(
  21376. false,
  21377. "did not recognize object of type " +
  21378. JSON.stringify(object.type)
  21379. );
  21380. }
  21381. return Object.keys(object);
  21382. }
  21383. exports.getFieldNames = getFieldNames;
  21384. // Get the value of an object property, taking object.type and default
  21385. // functions into account.
  21386. function getFieldValue(object, fieldName) {
  21387. var d = Def.fromValue(object);
  21388. if (d) {
  21389. var field = d.allFields[fieldName];
  21390. if (field) {
  21391. return field.getValue(object);
  21392. }
  21393. }
  21394. return object[fieldName];
  21395. }
  21396. exports.getFieldValue = getFieldValue;
  21397. // Iterate over all defined fields of an object, including those missing
  21398. // or undefined, passing each field name and effective value (as returned
  21399. // by getFieldValue) to the callback. If the object has no corresponding
  21400. // Def, the callback will never be called.
  21401. exports.eachField = function(object, callback, context) {
  21402. getFieldNames(object).forEach(function(name) {
  21403. callback.call(this, name, getFieldValue(object, name));
  21404. }, context);
  21405. };
  21406. // Similar to eachField, except that iteration stops as soon as the
  21407. // callback returns a truthy value. Like Array.prototype.some, the final
  21408. // result is either true or false to indicates whether the callback
  21409. // returned true for any element or not.
  21410. exports.someField = function(object, callback, context) {
  21411. return getFieldNames(object).some(function(name) {
  21412. return callback.call(this, name, getFieldValue(object, name));
  21413. }, context);
  21414. };
  21415. // This property will be overridden as true by individual Def instances
  21416. // when they are finalized.
  21417. Object.defineProperty(Dp, "finalized", { value: false });
  21418. Dp.finalize = function() {
  21419. // It's not an error to finalize a type more than once, but only the
  21420. // first call to .finalize does anything.
  21421. if (!this.finalized) {
  21422. var allFields = this.allFields;
  21423. var allSupertypes = this.allSupertypes;
  21424. this.baseNames.forEach(function(name) {
  21425. var def = defCache[name];
  21426. def.finalize();
  21427. extend(allFields, def.allFields);
  21428. extend(allSupertypes, def.allSupertypes);
  21429. });
  21430. // TODO Warn if fields are overridden with incompatible types.
  21431. extend(allFields, this.ownFields);
  21432. allSupertypes[this.typeName] = this;
  21433. this.fieldNames.length = 0;
  21434. for (var fieldName in allFields) {
  21435. if (hasOwn.call(allFields, fieldName) &&
  21436. !allFields[fieldName].hidden) {
  21437. this.fieldNames.push(fieldName);
  21438. }
  21439. }
  21440. // Types are exported only once they have been finalized.
  21441. Object.defineProperty(namedTypes, this.typeName, {
  21442. enumerable: true,
  21443. value: this.type
  21444. });
  21445. Object.defineProperty(this, "finalized", { value: true });
  21446. // A linearization of the inheritance hierarchy.
  21447. populateSupertypeList(this.typeName, this.supertypeList);
  21448. }
  21449. };
  21450. function populateSupertypeList(typeName, list) {
  21451. list.length = 0;
  21452. list.push(typeName);
  21453. var lastSeen = Object.create(null);
  21454. for (var pos = 0; pos < list.length; ++pos) {
  21455. typeName = list[pos];
  21456. var d = defCache[typeName];
  21457. assert.strictEqual(d.finalized, true);
  21458. // If we saw typeName earlier in the breadth-first traversal,
  21459. // delete the last-seen occurrence.
  21460. if (hasOwn.call(lastSeen, typeName)) {
  21461. delete list[lastSeen[typeName]];
  21462. }
  21463. // Record the new index of the last-seen occurrence of typeName.
  21464. lastSeen[typeName] = pos;
  21465. // Enqueue the base names of this type.
  21466. list.push.apply(list, d.baseNames);
  21467. }
  21468. // Compaction loop to remove array holes.
  21469. for (var to = 0, from = to, len = list.length; from < len; ++from) {
  21470. if (hasOwn.call(list, from)) {
  21471. list[to++] = list[from];
  21472. }
  21473. }
  21474. list.length = to;
  21475. }
  21476. function extend(into, from) {
  21477. Object.keys(from).forEach(function(name) {
  21478. into[name] = from[name];
  21479. });
  21480. return into;
  21481. };
  21482. exports.finalize = function() {
  21483. Object.keys(defCache).forEach(function(name) {
  21484. defCache[name].finalize();
  21485. });
  21486. };
  21487. },{"assert":190}],188:[function(require,module,exports){
  21488. var types = require("./lib/types");
  21489. // This core module of AST types captures ES5 as it is parsed today by
  21490. // git://github.com/ariya/esprima.git#master.
  21491. require("./def/core");
  21492. // Feel free to add to or remove from this list of extension modules to
  21493. // configure the precise type hierarchy that you need.
  21494. require("./def/es6");
  21495. require("./def/es7");
  21496. require("./def/mozilla");
  21497. require("./def/e4x");
  21498. require("./def/fb-harmony");
  21499. types.finalize();
  21500. exports.Type = types.Type;
  21501. exports.builtInTypes = types.builtInTypes;
  21502. exports.namedTypes = types.namedTypes;
  21503. exports.builders = types.builders;
  21504. exports.defineMethod = types.defineMethod;
  21505. exports.getFieldNames = types.getFieldNames;
  21506. exports.getFieldValue = types.getFieldValue;
  21507. exports.eachField = types.eachField;
  21508. exports.someField = types.someField;
  21509. exports.getSupertypeNames = types.getSupertypeNames;
  21510. exports.astNodesAreEquivalent = require("./lib/equiv");
  21511. exports.finalize = types.finalize;
  21512. exports.NodePath = require("./lib/node-path");
  21513. exports.PathVisitor = require("./lib/path-visitor");
  21514. exports.visit = exports.PathVisitor.visit;
  21515. },{"./def/core":175,"./def/e4x":176,"./def/es6":177,"./def/es7":178,"./def/fb-harmony":179,"./def/mozilla":180,"./lib/equiv":181,"./lib/node-path":182,"./lib/path-visitor":183,"./lib/types":187}],189:[function(require,module,exports){
  21516. },{}],190:[function(require,module,exports){
  21517. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  21518. //
  21519. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  21520. //
  21521. // Originally from narwhal.js (http://narwhaljs.org)
  21522. // Copyright (c) 2009 Thomas Robinson <280north.com>
  21523. //
  21524. // Permission is hereby granted, free of charge, to any person obtaining a copy
  21525. // of this software and associated documentation files (the 'Software'), to
  21526. // deal in the Software without restriction, including without limitation the
  21527. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  21528. // sell copies of the Software, and to permit persons to whom the Software is
  21529. // furnished to do so, subject to the following conditions:
  21530. //
  21531. // The above copyright notice and this permission notice shall be included in
  21532. // all copies or substantial portions of the Software.
  21533. //
  21534. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21535. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21536. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21537. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  21538. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21539. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21540. // when used in node, this will actually load the util module we depend on
  21541. // versus loading the builtin util module as happens otherwise
  21542. // this is a bug in node module loading as far as I am concerned
  21543. var util = require('util/');
  21544. var pSlice = Array.prototype.slice;
  21545. var hasOwn = Object.prototype.hasOwnProperty;
  21546. // 1. The assert module provides functions that throw
  21547. // AssertionError's when particular conditions are not met. The
  21548. // assert module must conform to the following interface.
  21549. var assert = module.exports = ok;
  21550. // 2. The AssertionError is defined in assert.
  21551. // new assert.AssertionError({ message: message,
  21552. // actual: actual,
  21553. // expected: expected })
  21554. assert.AssertionError = function AssertionError(options) {
  21555. this.name = 'AssertionError';
  21556. this.actual = options.actual;
  21557. this.expected = options.expected;
  21558. this.operator = options.operator;
  21559. if (options.message) {
  21560. this.message = options.message;
  21561. this.generatedMessage = false;
  21562. } else {
  21563. this.message = getMessage(this);
  21564. this.generatedMessage = true;
  21565. }
  21566. var stackStartFunction = options.stackStartFunction || fail;
  21567. if (Error.captureStackTrace) {
  21568. Error.captureStackTrace(this, stackStartFunction);
  21569. }
  21570. else {
  21571. // non v8 browsers so we can have a stacktrace
  21572. var err = new Error();
  21573. if (err.stack) {
  21574. var out = err.stack;
  21575. // try to strip useless frames
  21576. var fn_name = stackStartFunction.name;
  21577. var idx = out.indexOf('\n' + fn_name);
  21578. if (idx >= 0) {
  21579. // once we have located the function frame
  21580. // we need to strip out everything before it (and its line)
  21581. var next_line = out.indexOf('\n', idx + 1);
  21582. out = out.substring(next_line + 1);
  21583. }
  21584. this.stack = out;
  21585. }
  21586. }
  21587. };
  21588. // assert.AssertionError instanceof Error
  21589. util.inherits(assert.AssertionError, Error);
  21590. function replacer(key, value) {
  21591. if (util.isUndefined(value)) {
  21592. return '' + value;
  21593. }
  21594. if (util.isNumber(value) && !isFinite(value)) {
  21595. return value.toString();
  21596. }
  21597. if (util.isFunction(value) || util.isRegExp(value)) {
  21598. return value.toString();
  21599. }
  21600. return value;
  21601. }
  21602. function truncate(s, n) {
  21603. if (util.isString(s)) {
  21604. return s.length < n ? s : s.slice(0, n);
  21605. } else {
  21606. return s;
  21607. }
  21608. }
  21609. function getMessage(self) {
  21610. return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
  21611. self.operator + ' ' +
  21612. truncate(JSON.stringify(self.expected, replacer), 128);
  21613. }
  21614. // At present only the three keys mentioned above are used and
  21615. // understood by the spec. Implementations or sub modules can pass
  21616. // other keys to the AssertionError's constructor - they will be
  21617. // ignored.
  21618. // 3. All of the following functions must throw an AssertionError
  21619. // when a corresponding condition is not met, with a message that
  21620. // may be undefined if not provided. All assertion methods provide
  21621. // both the actual and expected values to the assertion error for
  21622. // display purposes.
  21623. function fail(actual, expected, message, operator, stackStartFunction) {
  21624. throw new assert.AssertionError({
  21625. message: message,
  21626. actual: actual,
  21627. expected: expected,
  21628. operator: operator,
  21629. stackStartFunction: stackStartFunction
  21630. });
  21631. }
  21632. // EXTENSION! allows for well behaved errors defined elsewhere.
  21633. assert.fail = fail;
  21634. // 4. Pure assertion tests whether a value is truthy, as determined
  21635. // by !!guard.
  21636. // assert.ok(guard, message_opt);
  21637. // This statement is equivalent to assert.equal(true, !!guard,
  21638. // message_opt);. To test strictly for the value true, use
  21639. // assert.strictEqual(true, guard, message_opt);.
  21640. function ok(value, message) {
  21641. if (!value) fail(value, true, message, '==', assert.ok);
  21642. }
  21643. assert.ok = ok;
  21644. // 5. The equality assertion tests shallow, coercive equality with
  21645. // ==.
  21646. // assert.equal(actual, expected, message_opt);
  21647. assert.equal = function equal(actual, expected, message) {
  21648. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  21649. };
  21650. // 6. The non-equality assertion tests for whether two objects are not equal
  21651. // with != assert.notEqual(actual, expected, message_opt);
  21652. assert.notEqual = function notEqual(actual, expected, message) {
  21653. if (actual == expected) {
  21654. fail(actual, expected, message, '!=', assert.notEqual);
  21655. }
  21656. };
  21657. // 7. The equivalence assertion tests a deep equality relation.
  21658. // assert.deepEqual(actual, expected, message_opt);
  21659. assert.deepEqual = function deepEqual(actual, expected, message) {
  21660. if (!_deepEqual(actual, expected)) {
  21661. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  21662. }
  21663. };
  21664. function _deepEqual(actual, expected) {
  21665. // 7.1. All identical values are equivalent, as determined by ===.
  21666. if (actual === expected) {
  21667. return true;
  21668. } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
  21669. if (actual.length != expected.length) return false;
  21670. for (var i = 0; i < actual.length; i++) {
  21671. if (actual[i] !== expected[i]) return false;
  21672. }
  21673. return true;
  21674. // 7.2. If the expected value is a Date object, the actual value is
  21675. // equivalent if it is also a Date object that refers to the same time.
  21676. } else if (util.isDate(actual) && util.isDate(expected)) {
  21677. return actual.getTime() === expected.getTime();
  21678. // 7.3 If the expected value is a RegExp object, the actual value is
  21679. // equivalent if it is also a RegExp object with the same source and
  21680. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  21681. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  21682. return actual.source === expected.source &&
  21683. actual.global === expected.global &&
  21684. actual.multiline === expected.multiline &&
  21685. actual.lastIndex === expected.lastIndex &&
  21686. actual.ignoreCase === expected.ignoreCase;
  21687. // 7.4. Other pairs that do not both pass typeof value == 'object',
  21688. // equivalence is determined by ==.
  21689. } else if (!util.isObject(actual) && !util.isObject(expected)) {
  21690. return actual == expected;
  21691. // 7.5 For all other Object pairs, including Array objects, equivalence is
  21692. // determined by having the same number of owned properties (as verified
  21693. // with Object.prototype.hasOwnProperty.call), the same set of keys
  21694. // (although not necessarily the same order), equivalent values for every
  21695. // corresponding key, and an identical 'prototype' property. Note: this
  21696. // accounts for both named and indexed properties on Arrays.
  21697. } else {
  21698. return objEquiv(actual, expected);
  21699. }
  21700. }
  21701. function isArguments(object) {
  21702. return Object.prototype.toString.call(object) == '[object Arguments]';
  21703. }
  21704. function objEquiv(a, b) {
  21705. if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
  21706. return false;
  21707. // an identical 'prototype' property.
  21708. if (a.prototype !== b.prototype) return false;
  21709. // if one is a primitive, the other must be same
  21710. if (util.isPrimitive(a) || util.isPrimitive(b)) {
  21711. return a === b;
  21712. }
  21713. var aIsArgs = isArguments(a),
  21714. bIsArgs = isArguments(b);
  21715. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  21716. return false;
  21717. if (aIsArgs) {
  21718. a = pSlice.call(a);
  21719. b = pSlice.call(b);
  21720. return _deepEqual(a, b);
  21721. }
  21722. var ka = objectKeys(a),
  21723. kb = objectKeys(b),
  21724. key, i;
  21725. // having the same number of owned properties (keys incorporates
  21726. // hasOwnProperty)
  21727. if (ka.length != kb.length)
  21728. return false;
  21729. //the same set of keys (although not necessarily the same order),
  21730. ka.sort();
  21731. kb.sort();
  21732. //~~~cheap key test
  21733. for (i = ka.length - 1; i >= 0; i--) {
  21734. if (ka[i] != kb[i])
  21735. return false;
  21736. }
  21737. //equivalent values for every corresponding key, and
  21738. //~~~possibly expensive deep test
  21739. for (i = ka.length - 1; i >= 0; i--) {
  21740. key = ka[i];
  21741. if (!_deepEqual(a[key], b[key])) return false;
  21742. }
  21743. return true;
  21744. }
  21745. // 8. The non-equivalence assertion tests for any deep inequality.
  21746. // assert.notDeepEqual(actual, expected, message_opt);
  21747. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  21748. if (_deepEqual(actual, expected)) {
  21749. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  21750. }
  21751. };
  21752. // 9. The strict equality assertion tests strict equality, as determined by ===.
  21753. // assert.strictEqual(actual, expected, message_opt);
  21754. assert.strictEqual = function strictEqual(actual, expected, message) {
  21755. if (actual !== expected) {
  21756. fail(actual, expected, message, '===', assert.strictEqual);
  21757. }
  21758. };
  21759. // 10. The strict non-equality assertion tests for strict inequality, as
  21760. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  21761. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  21762. if (actual === expected) {
  21763. fail(actual, expected, message, '!==', assert.notStrictEqual);
  21764. }
  21765. };
  21766. function expectedException(actual, expected) {
  21767. if (!actual || !expected) {
  21768. return false;
  21769. }
  21770. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  21771. return expected.test(actual);
  21772. } else if (actual instanceof expected) {
  21773. return true;
  21774. } else if (expected.call({}, actual) === true) {
  21775. return true;
  21776. }
  21777. return false;
  21778. }
  21779. function _throws(shouldThrow, block, expected, message) {
  21780. var actual;
  21781. if (util.isString(expected)) {
  21782. message = expected;
  21783. expected = null;
  21784. }
  21785. try {
  21786. block();
  21787. } catch (e) {
  21788. actual = e;
  21789. }
  21790. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  21791. (message ? ' ' + message : '.');
  21792. if (shouldThrow && !actual) {
  21793. fail(actual, expected, 'Missing expected exception' + message);
  21794. }
  21795. if (!shouldThrow && expectedException(actual, expected)) {
  21796. fail(actual, expected, 'Got unwanted exception' + message);
  21797. }
  21798. if ((shouldThrow && actual && expected &&
  21799. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  21800. throw actual;
  21801. }
  21802. }
  21803. // 11. Expected to throw an error:
  21804. // assert.throws(block, Error_opt, message_opt);
  21805. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  21806. _throws.apply(this, [true].concat(pSlice.call(arguments)));
  21807. };
  21808. // EXTENSION! This is annoying to write outside this module.
  21809. assert.doesNotThrow = function(block, /*optional*/message) {
  21810. _throws.apply(this, [false].concat(pSlice.call(arguments)));
  21811. };
  21812. assert.ifError = function(err) { if (err) {throw err;}};
  21813. var objectKeys = Object.keys || function (obj) {
  21814. var keys = [];
  21815. for (var key in obj) {
  21816. if (hasOwn.call(obj, key)) keys.push(key);
  21817. }
  21818. return keys;
  21819. };
  21820. },{"util/":216}],191:[function(require,module,exports){
  21821. arguments[4][189][0].apply(exports,arguments)
  21822. },{"dup":189}],192:[function(require,module,exports){
  21823. /*!
  21824. * The buffer module from node.js, for the browser.
  21825. *
  21826. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  21827. * @license MIT
  21828. */
  21829. var base64 = require('base64-js')
  21830. var ieee754 = require('ieee754')
  21831. var isArray = require('is-array')
  21832. exports.Buffer = Buffer
  21833. exports.SlowBuffer = SlowBuffer
  21834. exports.INSPECT_MAX_BYTES = 50
  21835. Buffer.poolSize = 8192 // not used by this implementation
  21836. var kMaxLength = 0x3fffffff
  21837. var rootParent = {}
  21838. /**
  21839. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  21840. * === true Use Uint8Array implementation (fastest)
  21841. * === false Use Object implementation (most compatible, even IE6)
  21842. *
  21843. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  21844. * Opera 11.6+, iOS 4.2+.
  21845. *
  21846. * Note:
  21847. *
  21848. * - Implementation must support adding new properties to `Uint8Array` instances.
  21849. * Firefox 4-29 lacked support, fixed in Firefox 30+.
  21850. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  21851. *
  21852. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  21853. *
  21854. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  21855. * incorrect length in some situations.
  21856. *
  21857. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
  21858. * get the Object implementation, which is slower but will work correctly.
  21859. */
  21860. Buffer.TYPED_ARRAY_SUPPORT = (function () {
  21861. try {
  21862. var buf = new ArrayBuffer(0)
  21863. var arr = new Uint8Array(buf)
  21864. arr.foo = function () { return 42 }
  21865. return arr.foo() === 42 && // typed array instances can be augmented
  21866. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  21867. new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  21868. } catch (e) {
  21869. return false
  21870. }
  21871. })()
  21872. /**
  21873. * Class: Buffer
  21874. * =============
  21875. *
  21876. * The Buffer constructor returns instances of `Uint8Array` that are augmented
  21877. * with function properties for all the node `Buffer` API functions. We use
  21878. * `Uint8Array` so that square bracket notation works as expected -- it returns
  21879. * a single octet.
  21880. *
  21881. * By augmenting the instances, we can avoid modifying the `Uint8Array`
  21882. * prototype.
  21883. */
  21884. function Buffer (subject, encoding) {
  21885. var self = this
  21886. if (!(self instanceof Buffer)) return new Buffer(subject, encoding)
  21887. var type = typeof subject
  21888. var length
  21889. if (type === 'number') {
  21890. length = +subject
  21891. } else if (type === 'string') {
  21892. length = Buffer.byteLength(subject, encoding)
  21893. } else if (type === 'object' && subject !== null) {
  21894. // assume object is array-like
  21895. if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data
  21896. length = +subject.length
  21897. } else {
  21898. throw new TypeError('must start with number, buffer, array or string')
  21899. }
  21900. if (length > kMaxLength) {
  21901. throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' +
  21902. kMaxLength.toString(16) + ' bytes')
  21903. }
  21904. if (length < 0) length = 0
  21905. else length >>>= 0 // coerce to uint32
  21906. if (Buffer.TYPED_ARRAY_SUPPORT) {
  21907. // Preferred: Return an augmented `Uint8Array` instance for best performance
  21908. self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this
  21909. } else {
  21910. // Fallback: Return THIS instance of Buffer (created by `new`)
  21911. self.length = length
  21912. self._isBuffer = true
  21913. }
  21914. var i
  21915. if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
  21916. // Speed optimization -- use set if we're copying from a typed array
  21917. self._set(subject)
  21918. } else if (isArrayish(subject)) {
  21919. // Treat array-ish objects as a byte array
  21920. if (Buffer.isBuffer(subject)) {
  21921. for (i = 0; i < length; i++) {
  21922. self[i] = subject.readUInt8(i)
  21923. }
  21924. } else {
  21925. for (i = 0; i < length; i++) {
  21926. self[i] = ((subject[i] % 256) + 256) % 256
  21927. }
  21928. }
  21929. } else if (type === 'string') {
  21930. self.write(subject, 0, encoding)
  21931. } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) {
  21932. for (i = 0; i < length; i++) {
  21933. self[i] = 0
  21934. }
  21935. }
  21936. if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent
  21937. return self
  21938. }
  21939. function SlowBuffer (subject, encoding) {
  21940. if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
  21941. var buf = new Buffer(subject, encoding)
  21942. delete buf.parent
  21943. return buf
  21944. }
  21945. Buffer.isBuffer = function isBuffer (b) {
  21946. return !!(b != null && b._isBuffer)
  21947. }
  21948. Buffer.compare = function compare (a, b) {
  21949. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  21950. throw new TypeError('Arguments must be Buffers')
  21951. }
  21952. if (a === b) return 0
  21953. var x = a.length
  21954. var y = b.length
  21955. for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
  21956. if (i !== len) {
  21957. x = a[i]
  21958. y = b[i]
  21959. }
  21960. if (x < y) return -1
  21961. if (y < x) return 1
  21962. return 0
  21963. }
  21964. Buffer.isEncoding = function isEncoding (encoding) {
  21965. switch (String(encoding).toLowerCase()) {
  21966. case 'hex':
  21967. case 'utf8':
  21968. case 'utf-8':
  21969. case 'ascii':
  21970. case 'binary':
  21971. case 'base64':
  21972. case 'raw':
  21973. case 'ucs2':
  21974. case 'ucs-2':
  21975. case 'utf16le':
  21976. case 'utf-16le':
  21977. return true
  21978. default:
  21979. return false
  21980. }
  21981. }
  21982. Buffer.concat = function concat (list, totalLength) {
  21983. if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
  21984. if (list.length === 0) {
  21985. return new Buffer(0)
  21986. } else if (list.length === 1) {
  21987. return list[0]
  21988. }
  21989. var i
  21990. if (totalLength === undefined) {
  21991. totalLength = 0
  21992. for (i = 0; i < list.length; i++) {
  21993. totalLength += list[i].length
  21994. }
  21995. }
  21996. var buf = new Buffer(totalLength)
  21997. var pos = 0
  21998. for (i = 0; i < list.length; i++) {
  21999. var item = list[i]
  22000. item.copy(buf, pos)
  22001. pos += item.length
  22002. }
  22003. return buf
  22004. }
  22005. Buffer.byteLength = function byteLength (str, encoding) {
  22006. var ret
  22007. str = str + ''
  22008. switch (encoding || 'utf8') {
  22009. case 'ascii':
  22010. case 'binary':
  22011. case 'raw':
  22012. ret = str.length
  22013. break
  22014. case 'ucs2':
  22015. case 'ucs-2':
  22016. case 'utf16le':
  22017. case 'utf-16le':
  22018. ret = str.length * 2
  22019. break
  22020. case 'hex':
  22021. ret = str.length >>> 1
  22022. break
  22023. case 'utf8':
  22024. case 'utf-8':
  22025. ret = utf8ToBytes(str).length
  22026. break
  22027. case 'base64':
  22028. ret = base64ToBytes(str).length
  22029. break
  22030. default:
  22031. ret = str.length
  22032. }
  22033. return ret
  22034. }
  22035. // pre-set for values that may exist in the future
  22036. Buffer.prototype.length = undefined
  22037. Buffer.prototype.parent = undefined
  22038. // toString(encoding, start=0, end=buffer.length)
  22039. Buffer.prototype.toString = function toString (encoding, start, end) {
  22040. var loweredCase = false
  22041. start = start >>> 0
  22042. end = end === undefined || end === Infinity ? this.length : end >>> 0
  22043. if (!encoding) encoding = 'utf8'
  22044. if (start < 0) start = 0
  22045. if (end > this.length) end = this.length
  22046. if (end <= start) return ''
  22047. while (true) {
  22048. switch (encoding) {
  22049. case 'hex':
  22050. return hexSlice(this, start, end)
  22051. case 'utf8':
  22052. case 'utf-8':
  22053. return utf8Slice(this, start, end)
  22054. case 'ascii':
  22055. return asciiSlice(this, start, end)
  22056. case 'binary':
  22057. return binarySlice(this, start, end)
  22058. case 'base64':
  22059. return base64Slice(this, start, end)
  22060. case 'ucs2':
  22061. case 'ucs-2':
  22062. case 'utf16le':
  22063. case 'utf-16le':
  22064. return utf16leSlice(this, start, end)
  22065. default:
  22066. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  22067. encoding = (encoding + '').toLowerCase()
  22068. loweredCase = true
  22069. }
  22070. }
  22071. }
  22072. Buffer.prototype.equals = function equals (b) {
  22073. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  22074. if (this === b) return true
  22075. return Buffer.compare(this, b) === 0
  22076. }
  22077. Buffer.prototype.inspect = function inspect () {
  22078. var str = ''
  22079. var max = exports.INSPECT_MAX_BYTES
  22080. if (this.length > 0) {
  22081. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  22082. if (this.length > max) str += ' ... '
  22083. }
  22084. return '<Buffer ' + str + '>'
  22085. }
  22086. Buffer.prototype.compare = function compare (b) {
  22087. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  22088. if (this === b) return 0
  22089. return Buffer.compare(this, b)
  22090. }
  22091. Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
  22092. if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
  22093. else if (byteOffset < -0x80000000) byteOffset = -0x80000000
  22094. byteOffset >>= 0
  22095. if (this.length === 0) return -1
  22096. if (byteOffset >= this.length) return -1
  22097. // Negative offsets start from the end of the buffer
  22098. if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  22099. if (typeof val === 'string') {
  22100. if (val.length === 0) return -1 // special case: looking for empty string always fails
  22101. return String.prototype.indexOf.call(this, val, byteOffset)
  22102. }
  22103. if (Buffer.isBuffer(val)) {
  22104. return arrayIndexOf(this, val, byteOffset)
  22105. }
  22106. if (typeof val === 'number') {
  22107. if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  22108. return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  22109. }
  22110. return arrayIndexOf(this, [ val ], byteOffset)
  22111. }
  22112. function arrayIndexOf (arr, val, byteOffset) {
  22113. var foundIndex = -1
  22114. for (var i = 0; byteOffset + i < arr.length; i++) {
  22115. if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
  22116. if (foundIndex === -1) foundIndex = i
  22117. if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
  22118. } else {
  22119. foundIndex = -1
  22120. }
  22121. }
  22122. return -1
  22123. }
  22124. throw new TypeError('val must be string, number or Buffer')
  22125. }
  22126. // `get` will be removed in Node 0.13+
  22127. Buffer.prototype.get = function get (offset) {
  22128. console.log('.get() is deprecated. Access using array indexes instead.')
  22129. return this.readUInt8(offset)
  22130. }
  22131. // `set` will be removed in Node 0.13+
  22132. Buffer.prototype.set = function set (v, offset) {
  22133. console.log('.set() is deprecated. Access using array indexes instead.')
  22134. return this.writeUInt8(v, offset)
  22135. }
  22136. function hexWrite (buf, string, offset, length) {
  22137. offset = Number(offset) || 0
  22138. var remaining = buf.length - offset
  22139. if (!length) {
  22140. length = remaining
  22141. } else {
  22142. length = Number(length)
  22143. if (length > remaining) {
  22144. length = remaining
  22145. }
  22146. }
  22147. // must be an even number of digits
  22148. var strLen = string.length
  22149. if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  22150. if (length > strLen / 2) {
  22151. length = strLen / 2
  22152. }
  22153. for (var i = 0; i < length; i++) {
  22154. var parsed = parseInt(string.substr(i * 2, 2), 16)
  22155. if (isNaN(parsed)) throw new Error('Invalid hex string')
  22156. buf[offset + i] = parsed
  22157. }
  22158. return i
  22159. }
  22160. function utf8Write (buf, string, offset, length) {
  22161. var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  22162. return charsWritten
  22163. }
  22164. function asciiWrite (buf, string, offset, length) {
  22165. var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
  22166. return charsWritten
  22167. }
  22168. function binaryWrite (buf, string, offset, length) {
  22169. return asciiWrite(buf, string, offset, length)
  22170. }
  22171. function base64Write (buf, string, offset, length) {
  22172. var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
  22173. return charsWritten
  22174. }
  22175. function utf16leWrite (buf, string, offset, length) {
  22176. var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  22177. return charsWritten
  22178. }
  22179. Buffer.prototype.write = function write (string, offset, length, encoding) {
  22180. // Support both (string, offset, length, encoding)
  22181. // and the legacy (string, encoding, offset, length)
  22182. if (isFinite(offset)) {
  22183. if (!isFinite(length)) {
  22184. encoding = length
  22185. length = undefined
  22186. }
  22187. } else { // legacy
  22188. var swap = encoding
  22189. encoding = offset
  22190. offset = length
  22191. length = swap
  22192. }
  22193. offset = Number(offset) || 0
  22194. if (length < 0 || offset < 0 || offset > this.length) {
  22195. throw new RangeError('attempt to write outside buffer bounds')
  22196. }
  22197. var remaining = this.length - offset
  22198. if (!length) {
  22199. length = remaining
  22200. } else {
  22201. length = Number(length)
  22202. if (length > remaining) {
  22203. length = remaining
  22204. }
  22205. }
  22206. encoding = String(encoding || 'utf8').toLowerCase()
  22207. var ret
  22208. switch (encoding) {
  22209. case 'hex':
  22210. ret = hexWrite(this, string, offset, length)
  22211. break
  22212. case 'utf8':
  22213. case 'utf-8':
  22214. ret = utf8Write(this, string, offset, length)
  22215. break
  22216. case 'ascii':
  22217. ret = asciiWrite(this, string, offset, length)
  22218. break
  22219. case 'binary':
  22220. ret = binaryWrite(this, string, offset, length)
  22221. break
  22222. case 'base64':
  22223. ret = base64Write(this, string, offset, length)
  22224. break
  22225. case 'ucs2':
  22226. case 'ucs-2':
  22227. case 'utf16le':
  22228. case 'utf-16le':
  22229. ret = utf16leWrite(this, string, offset, length)
  22230. break
  22231. default:
  22232. throw new TypeError('Unknown encoding: ' + encoding)
  22233. }
  22234. return ret
  22235. }
  22236. Buffer.prototype.toJSON = function toJSON () {
  22237. return {
  22238. type: 'Buffer',
  22239. data: Array.prototype.slice.call(this._arr || this, 0)
  22240. }
  22241. }
  22242. function base64Slice (buf, start, end) {
  22243. if (start === 0 && end === buf.length) {
  22244. return base64.fromByteArray(buf)
  22245. } else {
  22246. return base64.fromByteArray(buf.slice(start, end))
  22247. }
  22248. }
  22249. function utf8Slice (buf, start, end) {
  22250. var res = ''
  22251. var tmp = ''
  22252. end = Math.min(buf.length, end)
  22253. for (var i = start; i < end; i++) {
  22254. if (buf[i] <= 0x7F) {
  22255. res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
  22256. tmp = ''
  22257. } else {
  22258. tmp += '%' + buf[i].toString(16)
  22259. }
  22260. }
  22261. return res + decodeUtf8Char(tmp)
  22262. }
  22263. function asciiSlice (buf, start, end) {
  22264. var ret = ''
  22265. end = Math.min(buf.length, end)
  22266. for (var i = start; i < end; i++) {
  22267. ret += String.fromCharCode(buf[i] & 0x7F)
  22268. }
  22269. return ret
  22270. }
  22271. function binarySlice (buf, start, end) {
  22272. var ret = ''
  22273. end = Math.min(buf.length, end)
  22274. for (var i = start; i < end; i++) {
  22275. ret += String.fromCharCode(buf[i])
  22276. }
  22277. return ret
  22278. }
  22279. function hexSlice (buf, start, end) {
  22280. var len = buf.length
  22281. if (!start || start < 0) start = 0
  22282. if (!end || end < 0 || end > len) end = len
  22283. var out = ''
  22284. for (var i = start; i < end; i++) {
  22285. out += toHex(buf[i])
  22286. }
  22287. return out
  22288. }
  22289. function utf16leSlice (buf, start, end) {
  22290. var bytes = buf.slice(start, end)
  22291. var res = ''
  22292. for (var i = 0; i < bytes.length; i += 2) {
  22293. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  22294. }
  22295. return res
  22296. }
  22297. Buffer.prototype.slice = function slice (start, end) {
  22298. var len = this.length
  22299. start = ~~start
  22300. end = end === undefined ? len : ~~end
  22301. if (start < 0) {
  22302. start += len
  22303. if (start < 0) start = 0
  22304. } else if (start > len) {
  22305. start = len
  22306. }
  22307. if (end < 0) {
  22308. end += len
  22309. if (end < 0) end = 0
  22310. } else if (end > len) {
  22311. end = len
  22312. }
  22313. if (end < start) end = start
  22314. var newBuf
  22315. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22316. newBuf = Buffer._augment(this.subarray(start, end))
  22317. } else {
  22318. var sliceLen = end - start
  22319. newBuf = new Buffer(sliceLen, undefined)
  22320. for (var i = 0; i < sliceLen; i++) {
  22321. newBuf[i] = this[i + start]
  22322. }
  22323. }
  22324. if (newBuf.length) newBuf.parent = this.parent || this
  22325. return newBuf
  22326. }
  22327. /*
  22328. * Need to make sure that buffer isn't trying to write out of bounds.
  22329. */
  22330. function checkOffset (offset, ext, length) {
  22331. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  22332. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  22333. }
  22334. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  22335. offset = offset >>> 0
  22336. byteLength = byteLength >>> 0
  22337. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22338. var val = this[offset]
  22339. var mul = 1
  22340. var i = 0
  22341. while (++i < byteLength && (mul *= 0x100)) {
  22342. val += this[offset + i] * mul
  22343. }
  22344. return val
  22345. }
  22346. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  22347. offset = offset >>> 0
  22348. byteLength = byteLength >>> 0
  22349. if (!noAssert) {
  22350. checkOffset(offset, byteLength, this.length)
  22351. }
  22352. var val = this[offset + --byteLength]
  22353. var mul = 1
  22354. while (byteLength > 0 && (mul *= 0x100)) {
  22355. val += this[offset + --byteLength] * mul
  22356. }
  22357. return val
  22358. }
  22359. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  22360. if (!noAssert) checkOffset(offset, 1, this.length)
  22361. return this[offset]
  22362. }
  22363. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  22364. if (!noAssert) checkOffset(offset, 2, this.length)
  22365. return this[offset] | (this[offset + 1] << 8)
  22366. }
  22367. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  22368. if (!noAssert) checkOffset(offset, 2, this.length)
  22369. return (this[offset] << 8) | this[offset + 1]
  22370. }
  22371. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  22372. if (!noAssert) checkOffset(offset, 4, this.length)
  22373. return ((this[offset]) |
  22374. (this[offset + 1] << 8) |
  22375. (this[offset + 2] << 16)) +
  22376. (this[offset + 3] * 0x1000000)
  22377. }
  22378. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  22379. if (!noAssert) checkOffset(offset, 4, this.length)
  22380. return (this[offset] * 0x1000000) +
  22381. ((this[offset + 1] << 16) |
  22382. (this[offset + 2] << 8) |
  22383. this[offset + 3])
  22384. }
  22385. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  22386. offset = offset >>> 0
  22387. byteLength = byteLength >>> 0
  22388. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22389. var val = this[offset]
  22390. var mul = 1
  22391. var i = 0
  22392. while (++i < byteLength && (mul *= 0x100)) {
  22393. val += this[offset + i] * mul
  22394. }
  22395. mul *= 0x80
  22396. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  22397. return val
  22398. }
  22399. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  22400. offset = offset >>> 0
  22401. byteLength = byteLength >>> 0
  22402. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22403. var i = byteLength
  22404. var mul = 1
  22405. var val = this[offset + --i]
  22406. while (i > 0 && (mul *= 0x100)) {
  22407. val += this[offset + --i] * mul
  22408. }
  22409. mul *= 0x80
  22410. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  22411. return val
  22412. }
  22413. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  22414. if (!noAssert) checkOffset(offset, 1, this.length)
  22415. if (!(this[offset] & 0x80)) return (this[offset])
  22416. return ((0xff - this[offset] + 1) * -1)
  22417. }
  22418. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  22419. if (!noAssert) checkOffset(offset, 2, this.length)
  22420. var val = this[offset] | (this[offset + 1] << 8)
  22421. return (val & 0x8000) ? val | 0xFFFF0000 : val
  22422. }
  22423. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  22424. if (!noAssert) checkOffset(offset, 2, this.length)
  22425. var val = this[offset + 1] | (this[offset] << 8)
  22426. return (val & 0x8000) ? val | 0xFFFF0000 : val
  22427. }
  22428. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  22429. if (!noAssert) checkOffset(offset, 4, this.length)
  22430. return (this[offset]) |
  22431. (this[offset + 1] << 8) |
  22432. (this[offset + 2] << 16) |
  22433. (this[offset + 3] << 24)
  22434. }
  22435. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  22436. if (!noAssert) checkOffset(offset, 4, this.length)
  22437. return (this[offset] << 24) |
  22438. (this[offset + 1] << 16) |
  22439. (this[offset + 2] << 8) |
  22440. (this[offset + 3])
  22441. }
  22442. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  22443. if (!noAssert) checkOffset(offset, 4, this.length)
  22444. return ieee754.read(this, offset, true, 23, 4)
  22445. }
  22446. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  22447. if (!noAssert) checkOffset(offset, 4, this.length)
  22448. return ieee754.read(this, offset, false, 23, 4)
  22449. }
  22450. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  22451. if (!noAssert) checkOffset(offset, 8, this.length)
  22452. return ieee754.read(this, offset, true, 52, 8)
  22453. }
  22454. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  22455. if (!noAssert) checkOffset(offset, 8, this.length)
  22456. return ieee754.read(this, offset, false, 52, 8)
  22457. }
  22458. function checkInt (buf, value, offset, ext, max, min) {
  22459. if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
  22460. if (value > max || value < min) throw new RangeError('value is out of bounds')
  22461. if (offset + ext > buf.length) throw new RangeError('index out of range')
  22462. }
  22463. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  22464. value = +value
  22465. offset = offset >>> 0
  22466. byteLength = byteLength >>> 0
  22467. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  22468. var mul = 1
  22469. var i = 0
  22470. this[offset] = value & 0xFF
  22471. while (++i < byteLength && (mul *= 0x100)) {
  22472. this[offset + i] = (value / mul) >>> 0 & 0xFF
  22473. }
  22474. return offset + byteLength
  22475. }
  22476. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  22477. value = +value
  22478. offset = offset >>> 0
  22479. byteLength = byteLength >>> 0
  22480. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  22481. var i = byteLength - 1
  22482. var mul = 1
  22483. this[offset + i] = value & 0xFF
  22484. while (--i >= 0 && (mul *= 0x100)) {
  22485. this[offset + i] = (value / mul) >>> 0 & 0xFF
  22486. }
  22487. return offset + byteLength
  22488. }
  22489. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  22490. value = +value
  22491. offset = offset >>> 0
  22492. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  22493. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  22494. this[offset] = value
  22495. return offset + 1
  22496. }
  22497. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  22498. if (value < 0) value = 0xffff + value + 1
  22499. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
  22500. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  22501. (littleEndian ? i : 1 - i) * 8
  22502. }
  22503. }
  22504. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  22505. value = +value
  22506. offset = offset >>> 0
  22507. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  22508. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22509. this[offset] = value
  22510. this[offset + 1] = (value >>> 8)
  22511. } else {
  22512. objectWriteUInt16(this, value, offset, true)
  22513. }
  22514. return offset + 2
  22515. }
  22516. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  22517. value = +value
  22518. offset = offset >>> 0
  22519. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  22520. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22521. this[offset] = (value >>> 8)
  22522. this[offset + 1] = value
  22523. } else {
  22524. objectWriteUInt16(this, value, offset, false)
  22525. }
  22526. return offset + 2
  22527. }
  22528. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  22529. if (value < 0) value = 0xffffffff + value + 1
  22530. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
  22531. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  22532. }
  22533. }
  22534. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  22535. value = +value
  22536. offset = offset >>> 0
  22537. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  22538. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22539. this[offset + 3] = (value >>> 24)
  22540. this[offset + 2] = (value >>> 16)
  22541. this[offset + 1] = (value >>> 8)
  22542. this[offset] = value
  22543. } else {
  22544. objectWriteUInt32(this, value, offset, true)
  22545. }
  22546. return offset + 4
  22547. }
  22548. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  22549. value = +value
  22550. offset = offset >>> 0
  22551. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  22552. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22553. this[offset] = (value >>> 24)
  22554. this[offset + 1] = (value >>> 16)
  22555. this[offset + 2] = (value >>> 8)
  22556. this[offset + 3] = value
  22557. } else {
  22558. objectWriteUInt32(this, value, offset, false)
  22559. }
  22560. return offset + 4
  22561. }
  22562. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  22563. value = +value
  22564. offset = offset >>> 0
  22565. if (!noAssert) {
  22566. checkInt(
  22567. this, value, offset, byteLength,
  22568. Math.pow(2, 8 * byteLength - 1) - 1,
  22569. -Math.pow(2, 8 * byteLength - 1)
  22570. )
  22571. }
  22572. var i = 0
  22573. var mul = 1
  22574. var sub = value < 0 ? 1 : 0
  22575. this[offset] = value & 0xFF
  22576. while (++i < byteLength && (mul *= 0x100)) {
  22577. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  22578. }
  22579. return offset + byteLength
  22580. }
  22581. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  22582. value = +value
  22583. offset = offset >>> 0
  22584. if (!noAssert) {
  22585. checkInt(
  22586. this, value, offset, byteLength,
  22587. Math.pow(2, 8 * byteLength - 1) - 1,
  22588. -Math.pow(2, 8 * byteLength - 1)
  22589. )
  22590. }
  22591. var i = byteLength - 1
  22592. var mul = 1
  22593. var sub = value < 0 ? 1 : 0
  22594. this[offset + i] = value & 0xFF
  22595. while (--i >= 0 && (mul *= 0x100)) {
  22596. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  22597. }
  22598. return offset + byteLength
  22599. }
  22600. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  22601. value = +value
  22602. offset = offset >>> 0
  22603. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  22604. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  22605. if (value < 0) value = 0xff + value + 1
  22606. this[offset] = value
  22607. return offset + 1
  22608. }
  22609. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  22610. value = +value
  22611. offset = offset >>> 0
  22612. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  22613. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22614. this[offset] = value
  22615. this[offset + 1] = (value >>> 8)
  22616. } else {
  22617. objectWriteUInt16(this, value, offset, true)
  22618. }
  22619. return offset + 2
  22620. }
  22621. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  22622. value = +value
  22623. offset = offset >>> 0
  22624. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  22625. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22626. this[offset] = (value >>> 8)
  22627. this[offset + 1] = value
  22628. } else {
  22629. objectWriteUInt16(this, value, offset, false)
  22630. }
  22631. return offset + 2
  22632. }
  22633. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  22634. value = +value
  22635. offset = offset >>> 0
  22636. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  22637. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22638. this[offset] = value
  22639. this[offset + 1] = (value >>> 8)
  22640. this[offset + 2] = (value >>> 16)
  22641. this[offset + 3] = (value >>> 24)
  22642. } else {
  22643. objectWriteUInt32(this, value, offset, true)
  22644. }
  22645. return offset + 4
  22646. }
  22647. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  22648. value = +value
  22649. offset = offset >>> 0
  22650. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  22651. if (value < 0) value = 0xffffffff + value + 1
  22652. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22653. this[offset] = (value >>> 24)
  22654. this[offset + 1] = (value >>> 16)
  22655. this[offset + 2] = (value >>> 8)
  22656. this[offset + 3] = value
  22657. } else {
  22658. objectWriteUInt32(this, value, offset, false)
  22659. }
  22660. return offset + 4
  22661. }
  22662. function checkIEEE754 (buf, value, offset, ext, max, min) {
  22663. if (value > max || value < min) throw new RangeError('value is out of bounds')
  22664. if (offset + ext > buf.length) throw new RangeError('index out of range')
  22665. if (offset < 0) throw new RangeError('index out of range')
  22666. }
  22667. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  22668. if (!noAssert) {
  22669. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  22670. }
  22671. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  22672. return offset + 4
  22673. }
  22674. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  22675. return writeFloat(this, value, offset, true, noAssert)
  22676. }
  22677. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  22678. return writeFloat(this, value, offset, false, noAssert)
  22679. }
  22680. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  22681. if (!noAssert) {
  22682. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  22683. }
  22684. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  22685. return offset + 8
  22686. }
  22687. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  22688. return writeDouble(this, value, offset, true, noAssert)
  22689. }
  22690. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  22691. return writeDouble(this, value, offset, false, noAssert)
  22692. }
  22693. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  22694. Buffer.prototype.copy = function copy (target, target_start, start, end) {
  22695. if (!start) start = 0
  22696. if (!end && end !== 0) end = this.length
  22697. if (target_start >= target.length) target_start = target.length
  22698. if (!target_start) target_start = 0
  22699. if (end > 0 && end < start) end = start
  22700. // Copy 0 bytes; we're done
  22701. if (end === start) return 0
  22702. if (target.length === 0 || this.length === 0) return 0
  22703. // Fatal error conditions
  22704. if (target_start < 0) {
  22705. throw new RangeError('targetStart out of bounds')
  22706. }
  22707. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  22708. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  22709. // Are we oob?
  22710. if (end > this.length) end = this.length
  22711. if (target.length - target_start < end - start) {
  22712. end = target.length - target_start + start
  22713. }
  22714. var len = end - start
  22715. if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  22716. for (var i = 0; i < len; i++) {
  22717. target[i + target_start] = this[i + start]
  22718. }
  22719. } else {
  22720. target._set(this.subarray(start, start + len), target_start)
  22721. }
  22722. return len
  22723. }
  22724. // fill(value, start=0, end=buffer.length)
  22725. Buffer.prototype.fill = function fill (value, start, end) {
  22726. if (!value) value = 0
  22727. if (!start) start = 0
  22728. if (!end) end = this.length
  22729. if (end < start) throw new RangeError('end < start')
  22730. // Fill 0 bytes; we're done
  22731. if (end === start) return
  22732. if (this.length === 0) return
  22733. if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
  22734. if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
  22735. var i
  22736. if (typeof value === 'number') {
  22737. for (i = start; i < end; i++) {
  22738. this[i] = value
  22739. }
  22740. } else {
  22741. var bytes = utf8ToBytes(value.toString())
  22742. var len = bytes.length
  22743. for (i = start; i < end; i++) {
  22744. this[i] = bytes[i % len]
  22745. }
  22746. }
  22747. return this
  22748. }
  22749. /**
  22750. * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  22751. * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  22752. */
  22753. Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
  22754. if (typeof Uint8Array !== 'undefined') {
  22755. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22756. return (new Buffer(this)).buffer
  22757. } else {
  22758. var buf = new Uint8Array(this.length)
  22759. for (var i = 0, len = buf.length; i < len; i += 1) {
  22760. buf[i] = this[i]
  22761. }
  22762. return buf.buffer
  22763. }
  22764. } else {
  22765. throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
  22766. }
  22767. }
  22768. // HELPER FUNCTIONS
  22769. // ================
  22770. var BP = Buffer.prototype
  22771. /**
  22772. * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  22773. */
  22774. Buffer._augment = function _augment (arr) {
  22775. arr.constructor = Buffer
  22776. arr._isBuffer = true
  22777. // save reference to original Uint8Array set method before overwriting
  22778. arr._set = arr.set
  22779. // deprecated, will be removed in node 0.13+
  22780. arr.get = BP.get
  22781. arr.set = BP.set
  22782. arr.write = BP.write
  22783. arr.toString = BP.toString
  22784. arr.toLocaleString = BP.toString
  22785. arr.toJSON = BP.toJSON
  22786. arr.equals = BP.equals
  22787. arr.compare = BP.compare
  22788. arr.indexOf = BP.indexOf
  22789. arr.copy = BP.copy
  22790. arr.slice = BP.slice
  22791. arr.readUIntLE = BP.readUIntLE
  22792. arr.readUIntBE = BP.readUIntBE
  22793. arr.readUInt8 = BP.readUInt8
  22794. arr.readUInt16LE = BP.readUInt16LE
  22795. arr.readUInt16BE = BP.readUInt16BE
  22796. arr.readUInt32LE = BP.readUInt32LE
  22797. arr.readUInt32BE = BP.readUInt32BE
  22798. arr.readIntLE = BP.readIntLE
  22799. arr.readIntBE = BP.readIntBE
  22800. arr.readInt8 = BP.readInt8
  22801. arr.readInt16LE = BP.readInt16LE
  22802. arr.readInt16BE = BP.readInt16BE
  22803. arr.readInt32LE = BP.readInt32LE
  22804. arr.readInt32BE = BP.readInt32BE
  22805. arr.readFloatLE = BP.readFloatLE
  22806. arr.readFloatBE = BP.readFloatBE
  22807. arr.readDoubleLE = BP.readDoubleLE
  22808. arr.readDoubleBE = BP.readDoubleBE
  22809. arr.writeUInt8 = BP.writeUInt8
  22810. arr.writeUIntLE = BP.writeUIntLE
  22811. arr.writeUIntBE = BP.writeUIntBE
  22812. arr.writeUInt16LE = BP.writeUInt16LE
  22813. arr.writeUInt16BE = BP.writeUInt16BE
  22814. arr.writeUInt32LE = BP.writeUInt32LE
  22815. arr.writeUInt32BE = BP.writeUInt32BE
  22816. arr.writeIntLE = BP.writeIntLE
  22817. arr.writeIntBE = BP.writeIntBE
  22818. arr.writeInt8 = BP.writeInt8
  22819. arr.writeInt16LE = BP.writeInt16LE
  22820. arr.writeInt16BE = BP.writeInt16BE
  22821. arr.writeInt32LE = BP.writeInt32LE
  22822. arr.writeInt32BE = BP.writeInt32BE
  22823. arr.writeFloatLE = BP.writeFloatLE
  22824. arr.writeFloatBE = BP.writeFloatBE
  22825. arr.writeDoubleLE = BP.writeDoubleLE
  22826. arr.writeDoubleBE = BP.writeDoubleBE
  22827. arr.fill = BP.fill
  22828. arr.inspect = BP.inspect
  22829. arr.toArrayBuffer = BP.toArrayBuffer
  22830. return arr
  22831. }
  22832. var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
  22833. function base64clean (str) {
  22834. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  22835. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  22836. // Node converts strings with length < 2 to ''
  22837. if (str.length < 2) return ''
  22838. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  22839. while (str.length % 4 !== 0) {
  22840. str = str + '='
  22841. }
  22842. return str
  22843. }
  22844. function stringtrim (str) {
  22845. if (str.trim) return str.trim()
  22846. return str.replace(/^\s+|\s+$/g, '')
  22847. }
  22848. function isArrayish (subject) {
  22849. return isArray(subject) || Buffer.isBuffer(subject) ||
  22850. subject && typeof subject === 'object' &&
  22851. typeof subject.length === 'number'
  22852. }
  22853. function toHex (n) {
  22854. if (n < 16) return '0' + n.toString(16)
  22855. return n.toString(16)
  22856. }
  22857. function utf8ToBytes (string, units) {
  22858. units = units || Infinity
  22859. var codePoint
  22860. var length = string.length
  22861. var leadSurrogate = null
  22862. var bytes = []
  22863. var i = 0
  22864. for (; i < length; i++) {
  22865. codePoint = string.charCodeAt(i)
  22866. // is surrogate component
  22867. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  22868. // last char was a lead
  22869. if (leadSurrogate) {
  22870. // 2 leads in a row
  22871. if (codePoint < 0xDC00) {
  22872. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22873. leadSurrogate = codePoint
  22874. continue
  22875. } else {
  22876. // valid surrogate pair
  22877. codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
  22878. leadSurrogate = null
  22879. }
  22880. } else {
  22881. // no lead yet
  22882. if (codePoint > 0xDBFF) {
  22883. // unexpected trail
  22884. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22885. continue
  22886. } else if (i + 1 === length) {
  22887. // unpaired lead
  22888. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22889. continue
  22890. } else {
  22891. // valid lead
  22892. leadSurrogate = codePoint
  22893. continue
  22894. }
  22895. }
  22896. } else if (leadSurrogate) {
  22897. // valid bmp char, but last char was a lead
  22898. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22899. leadSurrogate = null
  22900. }
  22901. // encode utf8
  22902. if (codePoint < 0x80) {
  22903. if ((units -= 1) < 0) break
  22904. bytes.push(codePoint)
  22905. } else if (codePoint < 0x800) {
  22906. if ((units -= 2) < 0) break
  22907. bytes.push(
  22908. codePoint >> 0x6 | 0xC0,
  22909. codePoint & 0x3F | 0x80
  22910. )
  22911. } else if (codePoint < 0x10000) {
  22912. if ((units -= 3) < 0) break
  22913. bytes.push(
  22914. codePoint >> 0xC | 0xE0,
  22915. codePoint >> 0x6 & 0x3F | 0x80,
  22916. codePoint & 0x3F | 0x80
  22917. )
  22918. } else if (codePoint < 0x200000) {
  22919. if ((units -= 4) < 0) break
  22920. bytes.push(
  22921. codePoint >> 0x12 | 0xF0,
  22922. codePoint >> 0xC & 0x3F | 0x80,
  22923. codePoint >> 0x6 & 0x3F | 0x80,
  22924. codePoint & 0x3F | 0x80
  22925. )
  22926. } else {
  22927. throw new Error('Invalid code point')
  22928. }
  22929. }
  22930. return bytes
  22931. }
  22932. function asciiToBytes (str) {
  22933. var byteArray = []
  22934. for (var i = 0; i < str.length; i++) {
  22935. // Node's code seems to be doing this and not & 0x7F..
  22936. byteArray.push(str.charCodeAt(i) & 0xFF)
  22937. }
  22938. return byteArray
  22939. }
  22940. function utf16leToBytes (str, units) {
  22941. var c, hi, lo
  22942. var byteArray = []
  22943. for (var i = 0; i < str.length; i++) {
  22944. if ((units -= 2) < 0) break
  22945. c = str.charCodeAt(i)
  22946. hi = c >> 8
  22947. lo = c % 256
  22948. byteArray.push(lo)
  22949. byteArray.push(hi)
  22950. }
  22951. return byteArray
  22952. }
  22953. function base64ToBytes (str) {
  22954. return base64.toByteArray(base64clean(str))
  22955. }
  22956. function blitBuffer (src, dst, offset, length) {
  22957. for (var i = 0; i < length; i++) {
  22958. if ((i + offset >= dst.length) || (i >= src.length)) break
  22959. dst[i + offset] = src[i]
  22960. }
  22961. return i
  22962. }
  22963. function decodeUtf8Char (str) {
  22964. try {
  22965. return decodeURIComponent(str)
  22966. } catch (err) {
  22967. return String.fromCharCode(0xFFFD) // UTF 8 invalid char
  22968. }
  22969. }
  22970. },{"base64-js":193,"ieee754":194,"is-array":195}],193:[function(require,module,exports){
  22971. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  22972. ;(function (exports) {
  22973. 'use strict';
  22974. var Arr = (typeof Uint8Array !== 'undefined')
  22975. ? Uint8Array
  22976. : Array
  22977. var PLUS = '+'.charCodeAt(0)
  22978. var SLASH = '/'.charCodeAt(0)
  22979. var NUMBER = '0'.charCodeAt(0)
  22980. var LOWER = 'a'.charCodeAt(0)
  22981. var UPPER = 'A'.charCodeAt(0)
  22982. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  22983. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  22984. function decode (elt) {
  22985. var code = elt.charCodeAt(0)
  22986. if (code === PLUS ||
  22987. code === PLUS_URL_SAFE)
  22988. return 62 // '+'
  22989. if (code === SLASH ||
  22990. code === SLASH_URL_SAFE)
  22991. return 63 // '/'
  22992. if (code < NUMBER)
  22993. return -1 //no match
  22994. if (code < NUMBER + 10)
  22995. return code - NUMBER + 26 + 26
  22996. if (code < UPPER + 26)
  22997. return code - UPPER
  22998. if (code < LOWER + 26)
  22999. return code - LOWER + 26
  23000. }
  23001. function b64ToByteArray (b64) {
  23002. var i, j, l, tmp, placeHolders, arr
  23003. if (b64.length % 4 > 0) {
  23004. throw new Error('Invalid string. Length must be a multiple of 4')
  23005. }
  23006. // the number of equal signs (place holders)
  23007. // if there are two placeholders, than the two characters before it
  23008. // represent one byte
  23009. // if there is only one, then the three characters before it represent 2 bytes
  23010. // this is just a cheap hack to not do indexOf twice
  23011. var len = b64.length
  23012. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  23013. // base64 is 4/3 + up to two characters of the original data
  23014. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  23015. // if there are placeholders, only get up to the last complete 4 chars
  23016. l = placeHolders > 0 ? b64.length - 4 : b64.length
  23017. var L = 0
  23018. function push (v) {
  23019. arr[L++] = v
  23020. }
  23021. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  23022. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  23023. push((tmp & 0xFF0000) >> 16)
  23024. push((tmp & 0xFF00) >> 8)
  23025. push(tmp & 0xFF)
  23026. }
  23027. if (placeHolders === 2) {
  23028. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  23029. push(tmp & 0xFF)
  23030. } else if (placeHolders === 1) {
  23031. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  23032. push((tmp >> 8) & 0xFF)
  23033. push(tmp & 0xFF)
  23034. }
  23035. return arr
  23036. }
  23037. function uint8ToBase64 (uint8) {
  23038. var i,
  23039. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  23040. output = "",
  23041. temp, length
  23042. function encode (num) {
  23043. return lookup.charAt(num)
  23044. }
  23045. function tripletToBase64 (num) {
  23046. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  23047. }
  23048. // go through the array every three bytes, we'll deal with trailing stuff later
  23049. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  23050. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  23051. output += tripletToBase64(temp)
  23052. }
  23053. // pad the end with zeros, but make sure to not forget the extra bytes
  23054. switch (extraBytes) {
  23055. case 1:
  23056. temp = uint8[uint8.length - 1]
  23057. output += encode(temp >> 2)
  23058. output += encode((temp << 4) & 0x3F)
  23059. output += '=='
  23060. break
  23061. case 2:
  23062. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  23063. output += encode(temp >> 10)
  23064. output += encode((temp >> 4) & 0x3F)
  23065. output += encode((temp << 2) & 0x3F)
  23066. output += '='
  23067. break
  23068. }
  23069. return output
  23070. }
  23071. exports.toByteArray = b64ToByteArray
  23072. exports.fromByteArray = uint8ToBase64
  23073. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  23074. },{}],194:[function(require,module,exports){
  23075. exports.read = function(buffer, offset, isLE, mLen, nBytes) {
  23076. var e, m,
  23077. eLen = nBytes * 8 - mLen - 1,
  23078. eMax = (1 << eLen) - 1,
  23079. eBias = eMax >> 1,
  23080. nBits = -7,
  23081. i = isLE ? (nBytes - 1) : 0,
  23082. d = isLE ? -1 : 1,
  23083. s = buffer[offset + i];
  23084. i += d;
  23085. e = s & ((1 << (-nBits)) - 1);
  23086. s >>= (-nBits);
  23087. nBits += eLen;
  23088. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
  23089. m = e & ((1 << (-nBits)) - 1);
  23090. e >>= (-nBits);
  23091. nBits += mLen;
  23092. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
  23093. if (e === 0) {
  23094. e = 1 - eBias;
  23095. } else if (e === eMax) {
  23096. return m ? NaN : ((s ? -1 : 1) * Infinity);
  23097. } else {
  23098. m = m + Math.pow(2, mLen);
  23099. e = e - eBias;
  23100. }
  23101. return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
  23102. };
  23103. exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
  23104. var e, m, c,
  23105. eLen = nBytes * 8 - mLen - 1,
  23106. eMax = (1 << eLen) - 1,
  23107. eBias = eMax >> 1,
  23108. rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
  23109. i = isLE ? 0 : (nBytes - 1),
  23110. d = isLE ? 1 : -1,
  23111. s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  23112. value = Math.abs(value);
  23113. if (isNaN(value) || value === Infinity) {
  23114. m = isNaN(value) ? 1 : 0;
  23115. e = eMax;
  23116. } else {
  23117. e = Math.floor(Math.log(value) / Math.LN2);
  23118. if (value * (c = Math.pow(2, -e)) < 1) {
  23119. e--;
  23120. c *= 2;
  23121. }
  23122. if (e + eBias >= 1) {
  23123. value += rt / c;
  23124. } else {
  23125. value += rt * Math.pow(2, 1 - eBias);
  23126. }
  23127. if (value * c >= 2) {
  23128. e++;
  23129. c /= 2;
  23130. }
  23131. if (e + eBias >= eMax) {
  23132. m = 0;
  23133. e = eMax;
  23134. } else if (e + eBias >= 1) {
  23135. m = (value * c - 1) * Math.pow(2, mLen);
  23136. e = e + eBias;
  23137. } else {
  23138. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  23139. e = 0;
  23140. }
  23141. }
  23142. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
  23143. e = (e << mLen) | m;
  23144. eLen += mLen;
  23145. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
  23146. buffer[offset + i - d] |= s * 128;
  23147. };
  23148. },{}],195:[function(require,module,exports){
  23149. /**
  23150. * isArray
  23151. */
  23152. var isArray = Array.isArray;
  23153. /**
  23154. * toString
  23155. */
  23156. var str = Object.prototype.toString;
  23157. /**
  23158. * Whether or not the given `val`
  23159. * is an array.
  23160. *
  23161. * example:
  23162. *
  23163. * isArray([]);
  23164. * // > true
  23165. * isArray(arguments);
  23166. * // > false
  23167. * isArray('');
  23168. * // > false
  23169. *
  23170. * @param {mixed} val
  23171. * @return {bool}
  23172. */
  23173. module.exports = isArray || function (val) {
  23174. return !! val && '[object Array]' == str.call(val);
  23175. };
  23176. },{}],196:[function(require,module,exports){
  23177. // Copyright Joyent, Inc. and other Node contributors.
  23178. //
  23179. // Permission is hereby granted, free of charge, to any person obtaining a
  23180. // copy of this software and associated documentation files (the
  23181. // "Software"), to deal in the Software without restriction, including
  23182. // without limitation the rights to use, copy, modify, merge, publish,
  23183. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23184. // persons to whom the Software is furnished to do so, subject to the
  23185. // following conditions:
  23186. //
  23187. // The above copyright notice and this permission notice shall be included
  23188. // in all copies or substantial portions of the Software.
  23189. //
  23190. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23191. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23192. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23193. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23194. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23195. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23196. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23197. function EventEmitter() {
  23198. this._events = this._events || {};
  23199. this._maxListeners = this._maxListeners || undefined;
  23200. }
  23201. module.exports = EventEmitter;
  23202. // Backwards-compat with node 0.10.x
  23203. EventEmitter.EventEmitter = EventEmitter;
  23204. EventEmitter.prototype._events = undefined;
  23205. EventEmitter.prototype._maxListeners = undefined;
  23206. // By default EventEmitters will print a warning if more than 10 listeners are
  23207. // added to it. This is a useful default which helps finding memory leaks.
  23208. EventEmitter.defaultMaxListeners = 10;
  23209. // Obviously not all Emitters should be limited to 10. This function allows
  23210. // that to be increased. Set to zero for unlimited.
  23211. EventEmitter.prototype.setMaxListeners = function(n) {
  23212. if (!isNumber(n) || n < 0 || isNaN(n))
  23213. throw TypeError('n must be a positive number');
  23214. this._maxListeners = n;
  23215. return this;
  23216. };
  23217. EventEmitter.prototype.emit = function(type) {
  23218. var er, handler, len, args, i, listeners;
  23219. if (!this._events)
  23220. this._events = {};
  23221. // If there is no 'error' event listener then throw.
  23222. if (type === 'error') {
  23223. if (!this._events.error ||
  23224. (isObject(this._events.error) && !this._events.error.length)) {
  23225. er = arguments[1];
  23226. if (er instanceof Error) {
  23227. throw er; // Unhandled 'error' event
  23228. }
  23229. throw TypeError('Uncaught, unspecified "error" event.');
  23230. }
  23231. }
  23232. handler = this._events[type];
  23233. if (isUndefined(handler))
  23234. return false;
  23235. if (isFunction(handler)) {
  23236. switch (arguments.length) {
  23237. // fast cases
  23238. case 1:
  23239. handler.call(this);
  23240. break;
  23241. case 2:
  23242. handler.call(this, arguments[1]);
  23243. break;
  23244. case 3:
  23245. handler.call(this, arguments[1], arguments[2]);
  23246. break;
  23247. // slower
  23248. default:
  23249. len = arguments.length;
  23250. args = new Array(len - 1);
  23251. for (i = 1; i < len; i++)
  23252. args[i - 1] = arguments[i];
  23253. handler.apply(this, args);
  23254. }
  23255. } else if (isObject(handler)) {
  23256. len = arguments.length;
  23257. args = new Array(len - 1);
  23258. for (i = 1; i < len; i++)
  23259. args[i - 1] = arguments[i];
  23260. listeners = handler.slice();
  23261. len = listeners.length;
  23262. for (i = 0; i < len; i++)
  23263. listeners[i].apply(this, args);
  23264. }
  23265. return true;
  23266. };
  23267. EventEmitter.prototype.addListener = function(type, listener) {
  23268. var m;
  23269. if (!isFunction(listener))
  23270. throw TypeError('listener must be a function');
  23271. if (!this._events)
  23272. this._events = {};
  23273. // To avoid recursion in the case that type === "newListener"! Before
  23274. // adding it to the listeners, first emit "newListener".
  23275. if (this._events.newListener)
  23276. this.emit('newListener', type,
  23277. isFunction(listener.listener) ?
  23278. listener.listener : listener);
  23279. if (!this._events[type])
  23280. // Optimize the case of one listener. Don't need the extra array object.
  23281. this._events[type] = listener;
  23282. else if (isObject(this._events[type]))
  23283. // If we've already got an array, just append.
  23284. this._events[type].push(listener);
  23285. else
  23286. // Adding the second element, need to change to array.
  23287. this._events[type] = [this._events[type], listener];
  23288. // Check for listener leak
  23289. if (isObject(this._events[type]) && !this._events[type].warned) {
  23290. var m;
  23291. if (!isUndefined(this._maxListeners)) {
  23292. m = this._maxListeners;
  23293. } else {
  23294. m = EventEmitter.defaultMaxListeners;
  23295. }
  23296. if (m && m > 0 && this._events[type].length > m) {
  23297. this._events[type].warned = true;
  23298. console.error('(node) warning: possible EventEmitter memory ' +
  23299. 'leak detected. %d listeners added. ' +
  23300. 'Use emitter.setMaxListeners() to increase limit.',
  23301. this._events[type].length);
  23302. if (typeof console.trace === 'function') {
  23303. // not supported in IE 10
  23304. console.trace();
  23305. }
  23306. }
  23307. }
  23308. return this;
  23309. };
  23310. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  23311. EventEmitter.prototype.once = function(type, listener) {
  23312. if (!isFunction(listener))
  23313. throw TypeError('listener must be a function');
  23314. var fired = false;
  23315. function g() {
  23316. this.removeListener(type, g);
  23317. if (!fired) {
  23318. fired = true;
  23319. listener.apply(this, arguments);
  23320. }
  23321. }
  23322. g.listener = listener;
  23323. this.on(type, g);
  23324. return this;
  23325. };
  23326. // emits a 'removeListener' event iff the listener was removed
  23327. EventEmitter.prototype.removeListener = function(type, listener) {
  23328. var list, position, length, i;
  23329. if (!isFunction(listener))
  23330. throw TypeError('listener must be a function');
  23331. if (!this._events || !this._events[type])
  23332. return this;
  23333. list = this._events[type];
  23334. length = list.length;
  23335. position = -1;
  23336. if (list === listener ||
  23337. (isFunction(list.listener) && list.listener === listener)) {
  23338. delete this._events[type];
  23339. if (this._events.removeListener)
  23340. this.emit('removeListener', type, listener);
  23341. } else if (isObject(list)) {
  23342. for (i = length; i-- > 0;) {
  23343. if (list[i] === listener ||
  23344. (list[i].listener && list[i].listener === listener)) {
  23345. position = i;
  23346. break;
  23347. }
  23348. }
  23349. if (position < 0)
  23350. return this;
  23351. if (list.length === 1) {
  23352. list.length = 0;
  23353. delete this._events[type];
  23354. } else {
  23355. list.splice(position, 1);
  23356. }
  23357. if (this._events.removeListener)
  23358. this.emit('removeListener', type, listener);
  23359. }
  23360. return this;
  23361. };
  23362. EventEmitter.prototype.removeAllListeners = function(type) {
  23363. var key, listeners;
  23364. if (!this._events)
  23365. return this;
  23366. // not listening for removeListener, no need to emit
  23367. if (!this._events.removeListener) {
  23368. if (arguments.length === 0)
  23369. this._events = {};
  23370. else if (this._events[type])
  23371. delete this._events[type];
  23372. return this;
  23373. }
  23374. // emit removeListener for all listeners on all events
  23375. if (arguments.length === 0) {
  23376. for (key in this._events) {
  23377. if (key === 'removeListener') continue;
  23378. this.removeAllListeners(key);
  23379. }
  23380. this.removeAllListeners('removeListener');
  23381. this._events = {};
  23382. return this;
  23383. }
  23384. listeners = this._events[type];
  23385. if (isFunction(listeners)) {
  23386. this.removeListener(type, listeners);
  23387. } else {
  23388. // LIFO order
  23389. while (listeners.length)
  23390. this.removeListener(type, listeners[listeners.length - 1]);
  23391. }
  23392. delete this._events[type];
  23393. return this;
  23394. };
  23395. EventEmitter.prototype.listeners = function(type) {
  23396. var ret;
  23397. if (!this._events || !this._events[type])
  23398. ret = [];
  23399. else if (isFunction(this._events[type]))
  23400. ret = [this._events[type]];
  23401. else
  23402. ret = this._events[type].slice();
  23403. return ret;
  23404. };
  23405. EventEmitter.listenerCount = function(emitter, type) {
  23406. var ret;
  23407. if (!emitter._events || !emitter._events[type])
  23408. ret = 0;
  23409. else if (isFunction(emitter._events[type]))
  23410. ret = 1;
  23411. else
  23412. ret = emitter._events[type].length;
  23413. return ret;
  23414. };
  23415. function isFunction(arg) {
  23416. return typeof arg === 'function';
  23417. }
  23418. function isNumber(arg) {
  23419. return typeof arg === 'number';
  23420. }
  23421. function isObject(arg) {
  23422. return typeof arg === 'object' && arg !== null;
  23423. }
  23424. function isUndefined(arg) {
  23425. return arg === void 0;
  23426. }
  23427. },{}],197:[function(require,module,exports){
  23428. if (typeof Object.create === 'function') {
  23429. // implementation from standard node.js 'util' module
  23430. module.exports = function inherits(ctor, superCtor) {
  23431. ctor.super_ = superCtor
  23432. ctor.prototype = Object.create(superCtor.prototype, {
  23433. constructor: {
  23434. value: ctor,
  23435. enumerable: false,
  23436. writable: true,
  23437. configurable: true
  23438. }
  23439. });
  23440. };
  23441. } else {
  23442. // old school shim for old browsers
  23443. module.exports = function inherits(ctor, superCtor) {
  23444. ctor.super_ = superCtor
  23445. var TempCtor = function () {}
  23446. TempCtor.prototype = superCtor.prototype
  23447. ctor.prototype = new TempCtor()
  23448. ctor.prototype.constructor = ctor
  23449. }
  23450. }
  23451. },{}],198:[function(require,module,exports){
  23452. module.exports = Array.isArray || function (arr) {
  23453. return Object.prototype.toString.call(arr) == '[object Array]';
  23454. };
  23455. },{}],199:[function(require,module,exports){
  23456. (function (process){
  23457. // Copyright Joyent, Inc. and other Node contributors.
  23458. //
  23459. // Permission is hereby granted, free of charge, to any person obtaining a
  23460. // copy of this software and associated documentation files (the
  23461. // "Software"), to deal in the Software without restriction, including
  23462. // without limitation the rights to use, copy, modify, merge, publish,
  23463. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23464. // persons to whom the Software is furnished to do so, subject to the
  23465. // following conditions:
  23466. //
  23467. // The above copyright notice and this permission notice shall be included
  23468. // in all copies or substantial portions of the Software.
  23469. //
  23470. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23471. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23472. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23473. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23474. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23475. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23476. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23477. // resolves . and .. elements in a path array with directory names there
  23478. // must be no slashes, empty elements, or device names (c:\) in the array
  23479. // (so also no leading and trailing slashes - it does not distinguish
  23480. // relative and absolute paths)
  23481. function normalizeArray(parts, allowAboveRoot) {
  23482. // if the path tries to go above the root, `up` ends up > 0
  23483. var up = 0;
  23484. for (var i = parts.length - 1; i >= 0; i--) {
  23485. var last = parts[i];
  23486. if (last === '.') {
  23487. parts.splice(i, 1);
  23488. } else if (last === '..') {
  23489. parts.splice(i, 1);
  23490. up++;
  23491. } else if (up) {
  23492. parts.splice(i, 1);
  23493. up--;
  23494. }
  23495. }
  23496. // if the path is allowed to go above the root, restore leading ..s
  23497. if (allowAboveRoot) {
  23498. for (; up--; up) {
  23499. parts.unshift('..');
  23500. }
  23501. }
  23502. return parts;
  23503. }
  23504. // Split a filename into [root, dir, basename, ext], unix version
  23505. // 'root' is just a slash, or nothing.
  23506. var splitPathRe =
  23507. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  23508. var splitPath = function(filename) {
  23509. return splitPathRe.exec(filename).slice(1);
  23510. };
  23511. // path.resolve([from ...], to)
  23512. // posix version
  23513. exports.resolve = function() {
  23514. var resolvedPath = '',
  23515. resolvedAbsolute = false;
  23516. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  23517. var path = (i >= 0) ? arguments[i] : process.cwd();
  23518. // Skip empty and invalid entries
  23519. if (typeof path !== 'string') {
  23520. throw new TypeError('Arguments to path.resolve must be strings');
  23521. } else if (!path) {
  23522. continue;
  23523. }
  23524. resolvedPath = path + '/' + resolvedPath;
  23525. resolvedAbsolute = path.charAt(0) === '/';
  23526. }
  23527. // At this point the path should be resolved to a full absolute path, but
  23528. // handle relative paths to be safe (might happen when process.cwd() fails)
  23529. // Normalize the path
  23530. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  23531. return !!p;
  23532. }), !resolvedAbsolute).join('/');
  23533. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  23534. };
  23535. // path.normalize(path)
  23536. // posix version
  23537. exports.normalize = function(path) {
  23538. var isAbsolute = exports.isAbsolute(path),
  23539. trailingSlash = substr(path, -1) === '/';
  23540. // Normalize the path
  23541. path = normalizeArray(filter(path.split('/'), function(p) {
  23542. return !!p;
  23543. }), !isAbsolute).join('/');
  23544. if (!path && !isAbsolute) {
  23545. path = '.';
  23546. }
  23547. if (path && trailingSlash) {
  23548. path += '/';
  23549. }
  23550. return (isAbsolute ? '/' : '') + path;
  23551. };
  23552. // posix version
  23553. exports.isAbsolute = function(path) {
  23554. return path.charAt(0) === '/';
  23555. };
  23556. // posix version
  23557. exports.join = function() {
  23558. var paths = Array.prototype.slice.call(arguments, 0);
  23559. return exports.normalize(filter(paths, function(p, index) {
  23560. if (typeof p !== 'string') {
  23561. throw new TypeError('Arguments to path.join must be strings');
  23562. }
  23563. return p;
  23564. }).join('/'));
  23565. };
  23566. // path.relative(from, to)
  23567. // posix version
  23568. exports.relative = function(from, to) {
  23569. from = exports.resolve(from).substr(1);
  23570. to = exports.resolve(to).substr(1);
  23571. function trim(arr) {
  23572. var start = 0;
  23573. for (; start < arr.length; start++) {
  23574. if (arr[start] !== '') break;
  23575. }
  23576. var end = arr.length - 1;
  23577. for (; end >= 0; end--) {
  23578. if (arr[end] !== '') break;
  23579. }
  23580. if (start > end) return [];
  23581. return arr.slice(start, end - start + 1);
  23582. }
  23583. var fromParts = trim(from.split('/'));
  23584. var toParts = trim(to.split('/'));
  23585. var length = Math.min(fromParts.length, toParts.length);
  23586. var samePartsLength = length;
  23587. for (var i = 0; i < length; i++) {
  23588. if (fromParts[i] !== toParts[i]) {
  23589. samePartsLength = i;
  23590. break;
  23591. }
  23592. }
  23593. var outputParts = [];
  23594. for (var i = samePartsLength; i < fromParts.length; i++) {
  23595. outputParts.push('..');
  23596. }
  23597. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  23598. return outputParts.join('/');
  23599. };
  23600. exports.sep = '/';
  23601. exports.delimiter = ':';
  23602. exports.dirname = function(path) {
  23603. var result = splitPath(path),
  23604. root = result[0],
  23605. dir = result[1];
  23606. if (!root && !dir) {
  23607. // No dirname whatsoever
  23608. return '.';
  23609. }
  23610. if (dir) {
  23611. // It has a dirname, strip trailing slash
  23612. dir = dir.substr(0, dir.length - 1);
  23613. }
  23614. return root + dir;
  23615. };
  23616. exports.basename = function(path, ext) {
  23617. var f = splitPath(path)[2];
  23618. // TODO: make this comparison case-insensitive on windows?
  23619. if (ext && f.substr(-1 * ext.length) === ext) {
  23620. f = f.substr(0, f.length - ext.length);
  23621. }
  23622. return f;
  23623. };
  23624. exports.extname = function(path) {
  23625. return splitPath(path)[3];
  23626. };
  23627. function filter (xs, f) {
  23628. if (xs.filter) return xs.filter(f);
  23629. var res = [];
  23630. for (var i = 0; i < xs.length; i++) {
  23631. if (f(xs[i], i, xs)) res.push(xs[i]);
  23632. }
  23633. return res;
  23634. }
  23635. // String.prototype.substr - negative index don't work in IE8
  23636. var substr = 'ab'.substr(-1) === 'b'
  23637. ? function (str, start, len) { return str.substr(start, len) }
  23638. : function (str, start, len) {
  23639. if (start < 0) start = str.length + start;
  23640. return str.substr(start, len);
  23641. }
  23642. ;
  23643. }).call(this,require('_process'))
  23644. },{"_process":200}],200:[function(require,module,exports){
  23645. // shim for using process in browser
  23646. var process = module.exports = {};
  23647. var queue = [];
  23648. var draining = false;
  23649. function drainQueue() {
  23650. if (draining) {
  23651. return;
  23652. }
  23653. draining = true;
  23654. var currentQueue;
  23655. var len = queue.length;
  23656. while(len) {
  23657. currentQueue = queue;
  23658. queue = [];
  23659. var i = -1;
  23660. while (++i < len) {
  23661. currentQueue[i]();
  23662. }
  23663. len = queue.length;
  23664. }
  23665. draining = false;
  23666. }
  23667. process.nextTick = function (fun) {
  23668. queue.push(fun);
  23669. if (!draining) {
  23670. setTimeout(drainQueue, 0);
  23671. }
  23672. };
  23673. process.title = 'browser';
  23674. process.browser = true;
  23675. process.env = {};
  23676. process.argv = [];
  23677. process.version = ''; // empty string to avoid regexp issues
  23678. process.versions = {};
  23679. function noop() {}
  23680. process.on = noop;
  23681. process.addListener = noop;
  23682. process.once = noop;
  23683. process.off = noop;
  23684. process.removeListener = noop;
  23685. process.removeAllListeners = noop;
  23686. process.emit = noop;
  23687. process.binding = function (name) {
  23688. throw new Error('process.binding is not supported');
  23689. };
  23690. // TODO(shtylman)
  23691. process.cwd = function () { return '/' };
  23692. process.chdir = function (dir) {
  23693. throw new Error('process.chdir is not supported');
  23694. };
  23695. process.umask = function() { return 0; };
  23696. },{}],201:[function(require,module,exports){
  23697. module.exports = require("./lib/_stream_duplex.js")
  23698. },{"./lib/_stream_duplex.js":202}],202:[function(require,module,exports){
  23699. (function (process){
  23700. // Copyright Joyent, Inc. and other Node contributors.
  23701. //
  23702. // Permission is hereby granted, free of charge, to any person obtaining a
  23703. // copy of this software and associated documentation files (the
  23704. // "Software"), to deal in the Software without restriction, including
  23705. // without limitation the rights to use, copy, modify, merge, publish,
  23706. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23707. // persons to whom the Software is furnished to do so, subject to the
  23708. // following conditions:
  23709. //
  23710. // The above copyright notice and this permission notice shall be included
  23711. // in all copies or substantial portions of the Software.
  23712. //
  23713. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23714. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23715. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23716. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23717. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23718. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23719. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23720. // a duplex stream is just a stream that is both readable and writable.
  23721. // Since JS doesn't have multiple prototypal inheritance, this class
  23722. // prototypally inherits from Readable, and then parasitically from
  23723. // Writable.
  23724. module.exports = Duplex;
  23725. /*<replacement>*/
  23726. var objectKeys = Object.keys || function (obj) {
  23727. var keys = [];
  23728. for (var key in obj) keys.push(key);
  23729. return keys;
  23730. }
  23731. /*</replacement>*/
  23732. /*<replacement>*/
  23733. var util = require('core-util-is');
  23734. util.inherits = require('inherits');
  23735. /*</replacement>*/
  23736. var Readable = require('./_stream_readable');
  23737. var Writable = require('./_stream_writable');
  23738. util.inherits(Duplex, Readable);
  23739. forEach(objectKeys(Writable.prototype), function(method) {
  23740. if (!Duplex.prototype[method])
  23741. Duplex.prototype[method] = Writable.prototype[method];
  23742. });
  23743. function Duplex(options) {
  23744. if (!(this instanceof Duplex))
  23745. return new Duplex(options);
  23746. Readable.call(this, options);
  23747. Writable.call(this, options);
  23748. if (options && options.readable === false)
  23749. this.readable = false;
  23750. if (options && options.writable === false)
  23751. this.writable = false;
  23752. this.allowHalfOpen = true;
  23753. if (options && options.allowHalfOpen === false)
  23754. this.allowHalfOpen = false;
  23755. this.once('end', onend);
  23756. }
  23757. // the no-half-open enforcer
  23758. function onend() {
  23759. // if we allow half-open state, or if the writable side ended,
  23760. // then we're ok.
  23761. if (this.allowHalfOpen || this._writableState.ended)
  23762. return;
  23763. // no more data can be written.
  23764. // But allow more writes to happen in this tick.
  23765. process.nextTick(this.end.bind(this));
  23766. }
  23767. function forEach (xs, f) {
  23768. for (var i = 0, l = xs.length; i < l; i++) {
  23769. f(xs[i], i);
  23770. }
  23771. }
  23772. }).call(this,require('_process'))
  23773. },{"./_stream_readable":204,"./_stream_writable":206,"_process":200,"core-util-is":207,"inherits":197}],203:[function(require,module,exports){
  23774. // Copyright Joyent, Inc. and other Node contributors.
  23775. //
  23776. // Permission is hereby granted, free of charge, to any person obtaining a
  23777. // copy of this software and associated documentation files (the
  23778. // "Software"), to deal in the Software without restriction, including
  23779. // without limitation the rights to use, copy, modify, merge, publish,
  23780. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23781. // persons to whom the Software is furnished to do so, subject to the
  23782. // following conditions:
  23783. //
  23784. // The above copyright notice and this permission notice shall be included
  23785. // in all copies or substantial portions of the Software.
  23786. //
  23787. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23788. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23789. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23790. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23791. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23792. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23793. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23794. // a passthrough stream.
  23795. // basically just the most minimal sort of Transform stream.
  23796. // Every written chunk gets output as-is.
  23797. module.exports = PassThrough;
  23798. var Transform = require('./_stream_transform');
  23799. /*<replacement>*/
  23800. var util = require('core-util-is');
  23801. util.inherits = require('inherits');
  23802. /*</replacement>*/
  23803. util.inherits(PassThrough, Transform);
  23804. function PassThrough(options) {
  23805. if (!(this instanceof PassThrough))
  23806. return new PassThrough(options);
  23807. Transform.call(this, options);
  23808. }
  23809. PassThrough.prototype._transform = function(chunk, encoding, cb) {
  23810. cb(null, chunk);
  23811. };
  23812. },{"./_stream_transform":205,"core-util-is":207,"inherits":197}],204:[function(require,module,exports){
  23813. (function (process){
  23814. // Copyright Joyent, Inc. and other Node contributors.
  23815. //
  23816. // Permission is hereby granted, free of charge, to any person obtaining a
  23817. // copy of this software and associated documentation files (the
  23818. // "Software"), to deal in the Software without restriction, including
  23819. // without limitation the rights to use, copy, modify, merge, publish,
  23820. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23821. // persons to whom the Software is furnished to do so, subject to the
  23822. // following conditions:
  23823. //
  23824. // The above copyright notice and this permission notice shall be included
  23825. // in all copies or substantial portions of the Software.
  23826. //
  23827. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23828. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23829. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23830. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23831. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23832. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23833. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23834. module.exports = Readable;
  23835. /*<replacement>*/
  23836. var isArray = require('isarray');
  23837. /*</replacement>*/
  23838. /*<replacement>*/
  23839. var Buffer = require('buffer').Buffer;
  23840. /*</replacement>*/
  23841. Readable.ReadableState = ReadableState;
  23842. var EE = require('events').EventEmitter;
  23843. /*<replacement>*/
  23844. if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
  23845. return emitter.listeners(type).length;
  23846. };
  23847. /*</replacement>*/
  23848. var Stream = require('stream');
  23849. /*<replacement>*/
  23850. var util = require('core-util-is');
  23851. util.inherits = require('inherits');
  23852. /*</replacement>*/
  23853. var StringDecoder;
  23854. /*<replacement>*/
  23855. var debug = require('util');
  23856. if (debug && debug.debuglog) {
  23857. debug = debug.debuglog('stream');
  23858. } else {
  23859. debug = function () {};
  23860. }
  23861. /*</replacement>*/
  23862. util.inherits(Readable, Stream);
  23863. function ReadableState(options, stream) {
  23864. var Duplex = require('./_stream_duplex');
  23865. options = options || {};
  23866. // the point at which it stops calling _read() to fill the buffer
  23867. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  23868. var hwm = options.highWaterMark;
  23869. var defaultHwm = options.objectMode ? 16 : 16 * 1024;
  23870. this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
  23871. // cast to ints.
  23872. this.highWaterMark = ~~this.highWaterMark;
  23873. this.buffer = [];
  23874. this.length = 0;
  23875. this.pipes = null;
  23876. this.pipesCount = 0;
  23877. this.flowing = null;
  23878. this.ended = false;
  23879. this.endEmitted = false;
  23880. this.reading = false;
  23881. // a flag to be able to tell if the onwrite cb is called immediately,
  23882. // or on a later tick. We set this to true at first, because any
  23883. // actions that shouldn't happen until "later" should generally also
  23884. // not happen before the first write call.
  23885. this.sync = true;
  23886. // whenever we return null, then we set a flag to say
  23887. // that we're awaiting a 'readable' event emission.
  23888. this.needReadable = false;
  23889. this.emittedReadable = false;
  23890. this.readableListening = false;
  23891. // object stream flag. Used to make read(n) ignore n and to
  23892. // make all the buffer merging and length checks go away
  23893. this.objectMode = !!options.objectMode;
  23894. if (stream instanceof Duplex)
  23895. this.objectMode = this.objectMode || !!options.readableObjectMode;
  23896. // Crypto is kind of old and crusty. Historically, its default string
  23897. // encoding is 'binary' so we have to make this configurable.
  23898. // Everything else in the universe uses 'utf8', though.
  23899. this.defaultEncoding = options.defaultEncoding || 'utf8';
  23900. // when piping, we only care about 'readable' events that happen
  23901. // after read()ing all the bytes and not getting any pushback.
  23902. this.ranOut = false;
  23903. // the number of writers that are awaiting a drain event in .pipe()s
  23904. this.awaitDrain = 0;
  23905. // if true, a maybeReadMore has been scheduled
  23906. this.readingMore = false;
  23907. this.decoder = null;
  23908. this.encoding = null;
  23909. if (options.encoding) {
  23910. if (!StringDecoder)
  23911. StringDecoder = require('string_decoder/').StringDecoder;
  23912. this.decoder = new StringDecoder(options.encoding);
  23913. this.encoding = options.encoding;
  23914. }
  23915. }
  23916. function Readable(options) {
  23917. var Duplex = require('./_stream_duplex');
  23918. if (!(this instanceof Readable))
  23919. return new Readable(options);
  23920. this._readableState = new ReadableState(options, this);
  23921. // legacy
  23922. this.readable = true;
  23923. Stream.call(this);
  23924. }
  23925. // Manually shove something into the read() buffer.
  23926. // This returns true if the highWaterMark has not been hit yet,
  23927. // similar to how Writable.write() returns true if you should
  23928. // write() some more.
  23929. Readable.prototype.push = function(chunk, encoding) {
  23930. var state = this._readableState;
  23931. if (util.isString(chunk) && !state.objectMode) {
  23932. encoding = encoding || state.defaultEncoding;
  23933. if (encoding !== state.encoding) {
  23934. chunk = new Buffer(chunk, encoding);
  23935. encoding = '';
  23936. }
  23937. }
  23938. return readableAddChunk(this, state, chunk, encoding, false);
  23939. };
  23940. // Unshift should *always* be something directly out of read()
  23941. Readable.prototype.unshift = function(chunk) {
  23942. var state = this._readableState;
  23943. return readableAddChunk(this, state, chunk, '', true);
  23944. };
  23945. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  23946. var er = chunkInvalid(state, chunk);
  23947. if (er) {
  23948. stream.emit('error', er);
  23949. } else if (util.isNullOrUndefined(chunk)) {
  23950. state.reading = false;
  23951. if (!state.ended)
  23952. onEofChunk(stream, state);
  23953. } else if (state.objectMode || chunk && chunk.length > 0) {
  23954. if (state.ended && !addToFront) {
  23955. var e = new Error('stream.push() after EOF');
  23956. stream.emit('error', e);
  23957. } else if (state.endEmitted && addToFront) {
  23958. var e = new Error('stream.unshift() after end event');
  23959. stream.emit('error', e);
  23960. } else {
  23961. if (state.decoder && !addToFront && !encoding)
  23962. chunk = state.decoder.write(chunk);
  23963. if (!addToFront)
  23964. state.reading = false;
  23965. // if we want the data now, just emit it.
  23966. if (state.flowing && state.length === 0 && !state.sync) {
  23967. stream.emit('data', chunk);
  23968. stream.read(0);
  23969. } else {
  23970. // update the buffer info.
  23971. state.length += state.objectMode ? 1 : chunk.length;
  23972. if (addToFront)
  23973. state.buffer.unshift(chunk);
  23974. else
  23975. state.buffer.push(chunk);
  23976. if (state.needReadable)
  23977. emitReadable(stream);
  23978. }
  23979. maybeReadMore(stream, state);
  23980. }
  23981. } else if (!addToFront) {
  23982. state.reading = false;
  23983. }
  23984. return needMoreData(state);
  23985. }
  23986. // if it's past the high water mark, we can push in some more.
  23987. // Also, if we have no data yet, we can stand some
  23988. // more bytes. This is to work around cases where hwm=0,
  23989. // such as the repl. Also, if the push() triggered a
  23990. // readable event, and the user called read(largeNumber) such that
  23991. // needReadable was set, then we ought to push more, so that another
  23992. // 'readable' event will be triggered.
  23993. function needMoreData(state) {
  23994. return !state.ended &&
  23995. (state.needReadable ||
  23996. state.length < state.highWaterMark ||
  23997. state.length === 0);
  23998. }
  23999. // backwards compatibility.
  24000. Readable.prototype.setEncoding = function(enc) {
  24001. if (!StringDecoder)
  24002. StringDecoder = require('string_decoder/').StringDecoder;
  24003. this._readableState.decoder = new StringDecoder(enc);
  24004. this._readableState.encoding = enc;
  24005. return this;
  24006. };
  24007. // Don't raise the hwm > 128MB
  24008. var MAX_HWM = 0x800000;
  24009. function roundUpToNextPowerOf2(n) {
  24010. if (n >= MAX_HWM) {
  24011. n = MAX_HWM;
  24012. } else {
  24013. // Get the next highest power of 2
  24014. n--;
  24015. for (var p = 1; p < 32; p <<= 1) n |= n >> p;
  24016. n++;
  24017. }
  24018. return n;
  24019. }
  24020. function howMuchToRead(n, state) {
  24021. if (state.length === 0 && state.ended)
  24022. return 0;
  24023. if (state.objectMode)
  24024. return n === 0 ? 0 : 1;
  24025. if (isNaN(n) || util.isNull(n)) {
  24026. // only flow one buffer at a time
  24027. if (state.flowing && state.buffer.length)
  24028. return state.buffer[0].length;
  24029. else
  24030. return state.length;
  24031. }
  24032. if (n <= 0)
  24033. return 0;
  24034. // If we're asking for more than the target buffer level,
  24035. // then raise the water mark. Bump up to the next highest
  24036. // power of 2, to prevent increasing it excessively in tiny
  24037. // amounts.
  24038. if (n > state.highWaterMark)
  24039. state.highWaterMark = roundUpToNextPowerOf2(n);
  24040. // don't have that much. return null, unless we've ended.
  24041. if (n > state.length) {
  24042. if (!state.ended) {
  24043. state.needReadable = true;
  24044. return 0;
  24045. } else
  24046. return state.length;
  24047. }
  24048. return n;
  24049. }
  24050. // you can override either this method, or the async _read(n) below.
  24051. Readable.prototype.read = function(n) {
  24052. debug('read', n);
  24053. var state = this._readableState;
  24054. var nOrig = n;
  24055. if (!util.isNumber(n) || n > 0)
  24056. state.emittedReadable = false;
  24057. // if we're doing read(0) to trigger a readable event, but we
  24058. // already have a bunch of data in the buffer, then just trigger
  24059. // the 'readable' event and move on.
  24060. if (n === 0 &&
  24061. state.needReadable &&
  24062. (state.length >= state.highWaterMark || state.ended)) {
  24063. debug('read: emitReadable', state.length, state.ended);
  24064. if (state.length === 0 && state.ended)
  24065. endReadable(this);
  24066. else
  24067. emitReadable(this);
  24068. return null;
  24069. }
  24070. n = howMuchToRead(n, state);
  24071. // if we've ended, and we're now clear, then finish it up.
  24072. if (n === 0 && state.ended) {
  24073. if (state.length === 0)
  24074. endReadable(this);
  24075. return null;
  24076. }
  24077. // All the actual chunk generation logic needs to be
  24078. // *below* the call to _read. The reason is that in certain
  24079. // synthetic stream cases, such as passthrough streams, _read
  24080. // may be a completely synchronous operation which may change
  24081. // the state of the read buffer, providing enough data when
  24082. // before there was *not* enough.
  24083. //
  24084. // So, the steps are:
  24085. // 1. Figure out what the state of things will be after we do
  24086. // a read from the buffer.
  24087. //
  24088. // 2. If that resulting state will trigger a _read, then call _read.
  24089. // Note that this may be asynchronous, or synchronous. Yes, it is
  24090. // deeply ugly to write APIs this way, but that still doesn't mean
  24091. // that the Readable class should behave improperly, as streams are
  24092. // designed to be sync/async agnostic.
  24093. // Take note if the _read call is sync or async (ie, if the read call
  24094. // has returned yet), so that we know whether or not it's safe to emit
  24095. // 'readable' etc.
  24096. //
  24097. // 3. Actually pull the requested chunks out of the buffer and return.
  24098. // if we need a readable event, then we need to do some reading.
  24099. var doRead = state.needReadable;
  24100. debug('need readable', doRead);
  24101. // if we currently have less than the highWaterMark, then also read some
  24102. if (state.length === 0 || state.length - n < state.highWaterMark) {
  24103. doRead = true;
  24104. debug('length less than watermark', doRead);
  24105. }
  24106. // however, if we've ended, then there's no point, and if we're already
  24107. // reading, then it's unnecessary.
  24108. if (state.ended || state.reading) {
  24109. doRead = false;
  24110. debug('reading or ended', doRead);
  24111. }
  24112. if (doRead) {
  24113. debug('do read');
  24114. state.reading = true;
  24115. state.sync = true;
  24116. // if the length is currently zero, then we *need* a readable event.
  24117. if (state.length === 0)
  24118. state.needReadable = true;
  24119. // call internal read method
  24120. this._read(state.highWaterMark);
  24121. state.sync = false;
  24122. }
  24123. // If _read pushed data synchronously, then `reading` will be false,
  24124. // and we need to re-evaluate how much data we can return to the user.
  24125. if (doRead && !state.reading)
  24126. n = howMuchToRead(nOrig, state);
  24127. var ret;
  24128. if (n > 0)
  24129. ret = fromList(n, state);
  24130. else
  24131. ret = null;
  24132. if (util.isNull(ret)) {
  24133. state.needReadable = true;
  24134. n = 0;
  24135. }
  24136. state.length -= n;
  24137. // If we have nothing in the buffer, then we want to know
  24138. // as soon as we *do* get something into the buffer.
  24139. if (state.length === 0 && !state.ended)
  24140. state.needReadable = true;
  24141. // If we tried to read() past the EOF, then emit end on the next tick.
  24142. if (nOrig !== n && state.ended && state.length === 0)
  24143. endReadable(this);
  24144. if (!util.isNull(ret))
  24145. this.emit('data', ret);
  24146. return ret;
  24147. };
  24148. function chunkInvalid(state, chunk) {
  24149. var er = null;
  24150. if (!util.isBuffer(chunk) &&
  24151. !util.isString(chunk) &&
  24152. !util.isNullOrUndefined(chunk) &&
  24153. !state.objectMode) {
  24154. er = new TypeError('Invalid non-string/buffer chunk');
  24155. }
  24156. return er;
  24157. }
  24158. function onEofChunk(stream, state) {
  24159. if (state.decoder && !state.ended) {
  24160. var chunk = state.decoder.end();
  24161. if (chunk && chunk.length) {
  24162. state.buffer.push(chunk);
  24163. state.length += state.objectMode ? 1 : chunk.length;
  24164. }
  24165. }
  24166. state.ended = true;
  24167. // emit 'readable' now to make sure it gets picked up.
  24168. emitReadable(stream);
  24169. }
  24170. // Don't emit readable right away in sync mode, because this can trigger
  24171. // another read() call => stack overflow. This way, it might trigger
  24172. // a nextTick recursion warning, but that's not so bad.
  24173. function emitReadable(stream) {
  24174. var state = stream._readableState;
  24175. state.needReadable = false;
  24176. if (!state.emittedReadable) {
  24177. debug('emitReadable', state.flowing);
  24178. state.emittedReadable = true;
  24179. if (state.sync)
  24180. process.nextTick(function() {
  24181. emitReadable_(stream);
  24182. });
  24183. else
  24184. emitReadable_(stream);
  24185. }
  24186. }
  24187. function emitReadable_(stream) {
  24188. debug('emit readable');
  24189. stream.emit('readable');
  24190. flow(stream);
  24191. }
  24192. // at this point, the user has presumably seen the 'readable' event,
  24193. // and called read() to consume some data. that may have triggered
  24194. // in turn another _read(n) call, in which case reading = true if
  24195. // it's in progress.
  24196. // However, if we're not ended, or reading, and the length < hwm,
  24197. // then go ahead and try to read some more preemptively.
  24198. function maybeReadMore(stream, state) {
  24199. if (!state.readingMore) {
  24200. state.readingMore = true;
  24201. process.nextTick(function() {
  24202. maybeReadMore_(stream, state);
  24203. });
  24204. }
  24205. }
  24206. function maybeReadMore_(stream, state) {
  24207. var len = state.length;
  24208. while (!state.reading && !state.flowing && !state.ended &&
  24209. state.length < state.highWaterMark) {
  24210. debug('maybeReadMore read 0');
  24211. stream.read(0);
  24212. if (len === state.length)
  24213. // didn't get any data, stop spinning.
  24214. break;
  24215. else
  24216. len = state.length;
  24217. }
  24218. state.readingMore = false;
  24219. }
  24220. // abstract method. to be overridden in specific implementation classes.
  24221. // call cb(er, data) where data is <= n in length.
  24222. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  24223. // arbitrary, and perhaps not very meaningful.
  24224. Readable.prototype._read = function(n) {
  24225. this.emit('error', new Error('not implemented'));
  24226. };
  24227. Readable.prototype.pipe = function(dest, pipeOpts) {
  24228. var src = this;
  24229. var state = this._readableState;
  24230. switch (state.pipesCount) {
  24231. case 0:
  24232. state.pipes = dest;
  24233. break;
  24234. case 1:
  24235. state.pipes = [state.pipes, dest];
  24236. break;
  24237. default:
  24238. state.pipes.push(dest);
  24239. break;
  24240. }
  24241. state.pipesCount += 1;
  24242. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  24243. var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
  24244. dest !== process.stdout &&
  24245. dest !== process.stderr;
  24246. var endFn = doEnd ? onend : cleanup;
  24247. if (state.endEmitted)
  24248. process.nextTick(endFn);
  24249. else
  24250. src.once('end', endFn);
  24251. dest.on('unpipe', onunpipe);
  24252. function onunpipe(readable) {
  24253. debug('onunpipe');
  24254. if (readable === src) {
  24255. cleanup();
  24256. }
  24257. }
  24258. function onend() {
  24259. debug('onend');
  24260. dest.end();
  24261. }
  24262. // when the dest drains, it reduces the awaitDrain counter
  24263. // on the source. This would be more elegant with a .once()
  24264. // handler in flow(), but adding and removing repeatedly is
  24265. // too slow.
  24266. var ondrain = pipeOnDrain(src);
  24267. dest.on('drain', ondrain);
  24268. function cleanup() {
  24269. debug('cleanup');
  24270. // cleanup event handlers once the pipe is broken
  24271. dest.removeListener('close', onclose);
  24272. dest.removeListener('finish', onfinish);
  24273. dest.removeListener('drain', ondrain);
  24274. dest.removeListener('error', onerror);
  24275. dest.removeListener('unpipe', onunpipe);
  24276. src.removeListener('end', onend);
  24277. src.removeListener('end', cleanup);
  24278. src.removeListener('data', ondata);
  24279. // if the reader is waiting for a drain event from this
  24280. // specific writer, then it would cause it to never start
  24281. // flowing again.
  24282. // So, if this is awaiting a drain, then we just call it now.
  24283. // If we don't know, then assume that we are waiting for one.
  24284. if (state.awaitDrain &&
  24285. (!dest._writableState || dest._writableState.needDrain))
  24286. ondrain();
  24287. }
  24288. src.on('data', ondata);
  24289. function ondata(chunk) {
  24290. debug('ondata');
  24291. var ret = dest.write(chunk);
  24292. if (false === ret) {
  24293. debug('false write response, pause',
  24294. src._readableState.awaitDrain);
  24295. src._readableState.awaitDrain++;
  24296. src.pause();
  24297. }
  24298. }
  24299. // if the dest has an error, then stop piping into it.
  24300. // however, don't suppress the throwing behavior for this.
  24301. function onerror(er) {
  24302. debug('onerror', er);
  24303. unpipe();
  24304. dest.removeListener('error', onerror);
  24305. if (EE.listenerCount(dest, 'error') === 0)
  24306. dest.emit('error', er);
  24307. }
  24308. // This is a brutally ugly hack to make sure that our error handler
  24309. // is attached before any userland ones. NEVER DO THIS.
  24310. if (!dest._events || !dest._events.error)
  24311. dest.on('error', onerror);
  24312. else if (isArray(dest._events.error))
  24313. dest._events.error.unshift(onerror);
  24314. else
  24315. dest._events.error = [onerror, dest._events.error];
  24316. // Both close and finish should trigger unpipe, but only once.
  24317. function onclose() {
  24318. dest.removeListener('finish', onfinish);
  24319. unpipe();
  24320. }
  24321. dest.once('close', onclose);
  24322. function onfinish() {
  24323. debug('onfinish');
  24324. dest.removeListener('close', onclose);
  24325. unpipe();
  24326. }
  24327. dest.once('finish', onfinish);
  24328. function unpipe() {
  24329. debug('unpipe');
  24330. src.unpipe(dest);
  24331. }
  24332. // tell the dest that it's being piped to
  24333. dest.emit('pipe', src);
  24334. // start the flow if it hasn't been started already.
  24335. if (!state.flowing) {
  24336. debug('pipe resume');
  24337. src.resume();
  24338. }
  24339. return dest;
  24340. };
  24341. function pipeOnDrain(src) {
  24342. return function() {
  24343. var state = src._readableState;
  24344. debug('pipeOnDrain', state.awaitDrain);
  24345. if (state.awaitDrain)
  24346. state.awaitDrain--;
  24347. if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
  24348. state.flowing = true;
  24349. flow(src);
  24350. }
  24351. };
  24352. }
  24353. Readable.prototype.unpipe = function(dest) {
  24354. var state = this._readableState;
  24355. // if we're not piping anywhere, then do nothing.
  24356. if (state.pipesCount === 0)
  24357. return this;
  24358. // just one destination. most common case.
  24359. if (state.pipesCount === 1) {
  24360. // passed in one, but it's not the right one.
  24361. if (dest && dest !== state.pipes)
  24362. return this;
  24363. if (!dest)
  24364. dest = state.pipes;
  24365. // got a match.
  24366. state.pipes = null;
  24367. state.pipesCount = 0;
  24368. state.flowing = false;
  24369. if (dest)
  24370. dest.emit('unpipe', this);
  24371. return this;
  24372. }
  24373. // slow case. multiple pipe destinations.
  24374. if (!dest) {
  24375. // remove all.
  24376. var dests = state.pipes;
  24377. var len = state.pipesCount;
  24378. state.pipes = null;
  24379. state.pipesCount = 0;
  24380. state.flowing = false;
  24381. for (var i = 0; i < len; i++)
  24382. dests[i].emit('unpipe', this);
  24383. return this;
  24384. }
  24385. // try to find the right one.
  24386. var i = indexOf(state.pipes, dest);
  24387. if (i === -1)
  24388. return this;
  24389. state.pipes.splice(i, 1);
  24390. state.pipesCount -= 1;
  24391. if (state.pipesCount === 1)
  24392. state.pipes = state.pipes[0];
  24393. dest.emit('unpipe', this);
  24394. return this;
  24395. };
  24396. // set up data events if they are asked for
  24397. // Ensure readable listeners eventually get something
  24398. Readable.prototype.on = function(ev, fn) {
  24399. var res = Stream.prototype.on.call(this, ev, fn);
  24400. // If listening to data, and it has not explicitly been paused,
  24401. // then call resume to start the flow of data on the next tick.
  24402. if (ev === 'data' && false !== this._readableState.flowing) {
  24403. this.resume();
  24404. }
  24405. if (ev === 'readable' && this.readable) {
  24406. var state = this._readableState;
  24407. if (!state.readableListening) {
  24408. state.readableListening = true;
  24409. state.emittedReadable = false;
  24410. state.needReadable = true;
  24411. if (!state.reading) {
  24412. var self = this;
  24413. process.nextTick(function() {
  24414. debug('readable nexttick read 0');
  24415. self.read(0);
  24416. });
  24417. } else if (state.length) {
  24418. emitReadable(this, state);
  24419. }
  24420. }
  24421. }
  24422. return res;
  24423. };
  24424. Readable.prototype.addListener = Readable.prototype.on;
  24425. // pause() and resume() are remnants of the legacy readable stream API
  24426. // If the user uses them, then switch into old mode.
  24427. Readable.prototype.resume = function() {
  24428. var state = this._readableState;
  24429. if (!state.flowing) {
  24430. debug('resume');
  24431. state.flowing = true;
  24432. if (!state.reading) {
  24433. debug('resume read 0');
  24434. this.read(0);
  24435. }
  24436. resume(this, state);
  24437. }
  24438. return this;
  24439. };
  24440. function resume(stream, state) {
  24441. if (!state.resumeScheduled) {
  24442. state.resumeScheduled = true;
  24443. process.nextTick(function() {
  24444. resume_(stream, state);
  24445. });
  24446. }
  24447. }
  24448. function resume_(stream, state) {
  24449. state.resumeScheduled = false;
  24450. stream.emit('resume');
  24451. flow(stream);
  24452. if (state.flowing && !state.reading)
  24453. stream.read(0);
  24454. }
  24455. Readable.prototype.pause = function() {
  24456. debug('call pause flowing=%j', this._readableState.flowing);
  24457. if (false !== this._readableState.flowing) {
  24458. debug('pause');
  24459. this._readableState.flowing = false;
  24460. this.emit('pause');
  24461. }
  24462. return this;
  24463. };
  24464. function flow(stream) {
  24465. var state = stream._readableState;
  24466. debug('flow', state.flowing);
  24467. if (state.flowing) {
  24468. do {
  24469. var chunk = stream.read();
  24470. } while (null !== chunk && state.flowing);
  24471. }
  24472. }
  24473. // wrap an old-style stream as the async data source.
  24474. // This is *not* part of the readable stream interface.
  24475. // It is an ugly unfortunate mess of history.
  24476. Readable.prototype.wrap = function(stream) {
  24477. var state = this._readableState;
  24478. var paused = false;
  24479. var self = this;
  24480. stream.on('end', function() {
  24481. debug('wrapped end');
  24482. if (state.decoder && !state.ended) {
  24483. var chunk = state.decoder.end();
  24484. if (chunk && chunk.length)
  24485. self.push(chunk);
  24486. }
  24487. self.push(null);
  24488. });
  24489. stream.on('data', function(chunk) {
  24490. debug('wrapped data');
  24491. if (state.decoder)
  24492. chunk = state.decoder.write(chunk);
  24493. if (!chunk || !state.objectMode && !chunk.length)
  24494. return;
  24495. var ret = self.push(chunk);
  24496. if (!ret) {
  24497. paused = true;
  24498. stream.pause();
  24499. }
  24500. });
  24501. // proxy all the other methods.
  24502. // important when wrapping filters and duplexes.
  24503. for (var i in stream) {
  24504. if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
  24505. this[i] = function(method) { return function() {
  24506. return stream[method].apply(stream, arguments);
  24507. }}(i);
  24508. }
  24509. }
  24510. // proxy certain important events.
  24511. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  24512. forEach(events, function(ev) {
  24513. stream.on(ev, self.emit.bind(self, ev));
  24514. });
  24515. // when we try to consume some more bytes, simply unpause the
  24516. // underlying stream.
  24517. self._read = function(n) {
  24518. debug('wrapped _read', n);
  24519. if (paused) {
  24520. paused = false;
  24521. stream.resume();
  24522. }
  24523. };
  24524. return self;
  24525. };
  24526. // exposed for testing purposes only.
  24527. Readable._fromList = fromList;
  24528. // Pluck off n bytes from an array of buffers.
  24529. // Length is the combined lengths of all the buffers in the list.
  24530. function fromList(n, state) {
  24531. var list = state.buffer;
  24532. var length = state.length;
  24533. var stringMode = !!state.decoder;
  24534. var objectMode = !!state.objectMode;
  24535. var ret;
  24536. // nothing in the list, definitely empty.
  24537. if (list.length === 0)
  24538. return null;
  24539. if (length === 0)
  24540. ret = null;
  24541. else if (objectMode)
  24542. ret = list.shift();
  24543. else if (!n || n >= length) {
  24544. // read it all, truncate the array.
  24545. if (stringMode)
  24546. ret = list.join('');
  24547. else
  24548. ret = Buffer.concat(list, length);
  24549. list.length = 0;
  24550. } else {
  24551. // read just some of it.
  24552. if (n < list[0].length) {
  24553. // just take a part of the first list item.
  24554. // slice is the same for buffers and strings.
  24555. var buf = list[0];
  24556. ret = buf.slice(0, n);
  24557. list[0] = buf.slice(n);
  24558. } else if (n === list[0].length) {
  24559. // first list is a perfect match
  24560. ret = list.shift();
  24561. } else {
  24562. // complex case.
  24563. // we have enough to cover it, but it spans past the first buffer.
  24564. if (stringMode)
  24565. ret = '';
  24566. else
  24567. ret = new Buffer(n);
  24568. var c = 0;
  24569. for (var i = 0, l = list.length; i < l && c < n; i++) {
  24570. var buf = list[0];
  24571. var cpy = Math.min(n - c, buf.length);
  24572. if (stringMode)
  24573. ret += buf.slice(0, cpy);
  24574. else
  24575. buf.copy(ret, c, 0, cpy);
  24576. if (cpy < buf.length)
  24577. list[0] = buf.slice(cpy);
  24578. else
  24579. list.shift();
  24580. c += cpy;
  24581. }
  24582. }
  24583. }
  24584. return ret;
  24585. }
  24586. function endReadable(stream) {
  24587. var state = stream._readableState;
  24588. // If we get here before consuming all the bytes, then that is a
  24589. // bug in node. Should never happen.
  24590. if (state.length > 0)
  24591. throw new Error('endReadable called on non-empty stream');
  24592. if (!state.endEmitted) {
  24593. state.ended = true;
  24594. process.nextTick(function() {
  24595. // Check that we didn't get one last unshift.
  24596. if (!state.endEmitted && state.length === 0) {
  24597. state.endEmitted = true;
  24598. stream.readable = false;
  24599. stream.emit('end');
  24600. }
  24601. });
  24602. }
  24603. }
  24604. function forEach (xs, f) {
  24605. for (var i = 0, l = xs.length; i < l; i++) {
  24606. f(xs[i], i);
  24607. }
  24608. }
  24609. function indexOf (xs, x) {
  24610. for (var i = 0, l = xs.length; i < l; i++) {
  24611. if (xs[i] === x) return i;
  24612. }
  24613. return -1;
  24614. }
  24615. }).call(this,require('_process'))
  24616. },{"./_stream_duplex":202,"_process":200,"buffer":192,"core-util-is":207,"events":196,"inherits":197,"isarray":198,"stream":212,"string_decoder/":213,"util":191}],205:[function(require,module,exports){
  24617. // Copyright Joyent, Inc. and other Node contributors.
  24618. //
  24619. // Permission is hereby granted, free of charge, to any person obtaining a
  24620. // copy of this software and associated documentation files (the
  24621. // "Software"), to deal in the Software without restriction, including
  24622. // without limitation the rights to use, copy, modify, merge, publish,
  24623. // distribute, sublicense, and/or sell copies of the Software, and to permit
  24624. // persons to whom the Software is furnished to do so, subject to the
  24625. // following conditions:
  24626. //
  24627. // The above copyright notice and this permission notice shall be included
  24628. // in all copies or substantial portions of the Software.
  24629. //
  24630. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24631. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24632. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  24633. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24634. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24635. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24636. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  24637. // a transform stream is a readable/writable stream where you do
  24638. // something with the data. Sometimes it's called a "filter",
  24639. // but that's not a great name for it, since that implies a thing where
  24640. // some bits pass through, and others are simply ignored. (That would
  24641. // be a valid example of a transform, of course.)
  24642. //
  24643. // While the output is causally related to the input, it's not a
  24644. // necessarily symmetric or synchronous transformation. For example,
  24645. // a zlib stream might take multiple plain-text writes(), and then
  24646. // emit a single compressed chunk some time in the future.
  24647. //
  24648. // Here's how this works:
  24649. //
  24650. // The Transform stream has all the aspects of the readable and writable
  24651. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  24652. // internally, and returns false if there's a lot of pending writes
  24653. // buffered up. When you call read(), that calls _read(n) until
  24654. // there's enough pending readable data buffered up.
  24655. //
  24656. // In a transform stream, the written data is placed in a buffer. When
  24657. // _read(n) is called, it transforms the queued up data, calling the
  24658. // buffered _write cb's as it consumes chunks. If consuming a single
  24659. // written chunk would result in multiple output chunks, then the first
  24660. // outputted bit calls the readcb, and subsequent chunks just go into
  24661. // the read buffer, and will cause it to emit 'readable' if necessary.
  24662. //
  24663. // This way, back-pressure is actually determined by the reading side,
  24664. // since _read has to be called to start processing a new chunk. However,
  24665. // a pathological inflate type of transform can cause excessive buffering
  24666. // here. For example, imagine a stream where every byte of input is
  24667. // interpreted as an integer from 0-255, and then results in that many
  24668. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  24669. // 1kb of data being output. In this case, you could write a very small
  24670. // amount of input, and end up with a very large amount of output. In
  24671. // such a pathological inflating mechanism, there'd be no way to tell
  24672. // the system to stop doing the transform. A single 4MB write could
  24673. // cause the system to run out of memory.
  24674. //
  24675. // However, even in such a pathological case, only a single written chunk
  24676. // would be consumed, and then the rest would wait (un-transformed) until
  24677. // the results of the previous transformed chunk were consumed.
  24678. module.exports = Transform;
  24679. var Duplex = require('./_stream_duplex');
  24680. /*<replacement>*/
  24681. var util = require('core-util-is');
  24682. util.inherits = require('inherits');
  24683. /*</replacement>*/
  24684. util.inherits(Transform, Duplex);
  24685. function TransformState(options, stream) {
  24686. this.afterTransform = function(er, data) {
  24687. return afterTransform(stream, er, data);
  24688. };
  24689. this.needTransform = false;
  24690. this.transforming = false;
  24691. this.writecb = null;
  24692. this.writechunk = null;
  24693. }
  24694. function afterTransform(stream, er, data) {
  24695. var ts = stream._transformState;
  24696. ts.transforming = false;
  24697. var cb = ts.writecb;
  24698. if (!cb)
  24699. return stream.emit('error', new Error('no writecb in Transform class'));
  24700. ts.writechunk = null;
  24701. ts.writecb = null;
  24702. if (!util.isNullOrUndefined(data))
  24703. stream.push(data);
  24704. if (cb)
  24705. cb(er);
  24706. var rs = stream._readableState;
  24707. rs.reading = false;
  24708. if (rs.needReadable || rs.length < rs.highWaterMark) {
  24709. stream._read(rs.highWaterMark);
  24710. }
  24711. }
  24712. function Transform(options) {
  24713. if (!(this instanceof Transform))
  24714. return new Transform(options);
  24715. Duplex.call(this, options);
  24716. this._transformState = new TransformState(options, this);
  24717. // when the writable side finishes, then flush out anything remaining.
  24718. var stream = this;
  24719. // start out asking for a readable event once data is transformed.
  24720. this._readableState.needReadable = true;
  24721. // we have implemented the _read method, and done the other things
  24722. // that Readable wants before the first _read call, so unset the
  24723. // sync guard flag.
  24724. this._readableState.sync = false;
  24725. this.once('prefinish', function() {
  24726. if (util.isFunction(this._flush))
  24727. this._flush(function(er) {
  24728. done(stream, er);
  24729. });
  24730. else
  24731. done(stream);
  24732. });
  24733. }
  24734. Transform.prototype.push = function(chunk, encoding) {
  24735. this._transformState.needTransform = false;
  24736. return Duplex.prototype.push.call(this, chunk, encoding);
  24737. };
  24738. // This is the part where you do stuff!
  24739. // override this function in implementation classes.
  24740. // 'chunk' is an input chunk.
  24741. //
  24742. // Call `push(newChunk)` to pass along transformed output
  24743. // to the readable side. You may call 'push' zero or more times.
  24744. //
  24745. // Call `cb(err)` when you are done with this chunk. If you pass
  24746. // an error, then that'll put the hurt on the whole operation. If you
  24747. // never call cb(), then you'll never get another chunk.
  24748. Transform.prototype._transform = function(chunk, encoding, cb) {
  24749. throw new Error('not implemented');
  24750. };
  24751. Transform.prototype._write = function(chunk, encoding, cb) {
  24752. var ts = this._transformState;
  24753. ts.writecb = cb;
  24754. ts.writechunk = chunk;
  24755. ts.writeencoding = encoding;
  24756. if (!ts.transforming) {
  24757. var rs = this._readableState;
  24758. if (ts.needTransform ||
  24759. rs.needReadable ||
  24760. rs.length < rs.highWaterMark)
  24761. this._read(rs.highWaterMark);
  24762. }
  24763. };
  24764. // Doesn't matter what the args are here.
  24765. // _transform does all the work.
  24766. // That we got here means that the readable side wants more data.
  24767. Transform.prototype._read = function(n) {
  24768. var ts = this._transformState;
  24769. if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
  24770. ts.transforming = true;
  24771. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  24772. } else {
  24773. // mark that we need a transform, so that any data that comes in
  24774. // will get processed, now that we've asked for it.
  24775. ts.needTransform = true;
  24776. }
  24777. };
  24778. function done(stream, er) {
  24779. if (er)
  24780. return stream.emit('error', er);
  24781. // if there's nothing in the write buffer, then that means
  24782. // that nothing more will ever be provided
  24783. var ws = stream._writableState;
  24784. var ts = stream._transformState;
  24785. if (ws.length)
  24786. throw new Error('calling transform done when ws.length != 0');
  24787. if (ts.transforming)
  24788. throw new Error('calling transform done when still transforming');
  24789. return stream.push(null);
  24790. }
  24791. },{"./_stream_duplex":202,"core-util-is":207,"inherits":197}],206:[function(require,module,exports){
  24792. (function (process){
  24793. // Copyright Joyent, Inc. and other Node contributors.
  24794. //
  24795. // Permission is hereby granted, free of charge, to any person obtaining a
  24796. // copy of this software and associated documentation files (the
  24797. // "Software"), to deal in the Software without restriction, including
  24798. // without limitation the rights to use, copy, modify, merge, publish,
  24799. // distribute, sublicense, and/or sell copies of the Software, and to permit
  24800. // persons to whom the Software is furnished to do so, subject to the
  24801. // following conditions:
  24802. //
  24803. // The above copyright notice and this permission notice shall be included
  24804. // in all copies or substantial portions of the Software.
  24805. //
  24806. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24807. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24808. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  24809. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24810. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24811. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24812. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  24813. // A bit simpler than readable streams.
  24814. // Implement an async ._write(chunk, cb), and it'll handle all
  24815. // the drain event emission and buffering.
  24816. module.exports = Writable;
  24817. /*<replacement>*/
  24818. var Buffer = require('buffer').Buffer;
  24819. /*</replacement>*/
  24820. Writable.WritableState = WritableState;
  24821. /*<replacement>*/
  24822. var util = require('core-util-is');
  24823. util.inherits = require('inherits');
  24824. /*</replacement>*/
  24825. var Stream = require('stream');
  24826. util.inherits(Writable, Stream);
  24827. function WriteReq(chunk, encoding, cb) {
  24828. this.chunk = chunk;
  24829. this.encoding = encoding;
  24830. this.callback = cb;
  24831. }
  24832. function WritableState(options, stream) {
  24833. var Duplex = require('./_stream_duplex');
  24834. options = options || {};
  24835. // the point at which write() starts returning false
  24836. // Note: 0 is a valid value, means that we always return false if
  24837. // the entire buffer is not flushed immediately on write()
  24838. var hwm = options.highWaterMark;
  24839. var defaultHwm = options.objectMode ? 16 : 16 * 1024;
  24840. this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
  24841. // object stream flag to indicate whether or not this stream
  24842. // contains buffers or objects.
  24843. this.objectMode = !!options.objectMode;
  24844. if (stream instanceof Duplex)
  24845. this.objectMode = this.objectMode || !!options.writableObjectMode;
  24846. // cast to ints.
  24847. this.highWaterMark = ~~this.highWaterMark;
  24848. this.needDrain = false;
  24849. // at the start of calling end()
  24850. this.ending = false;
  24851. // when end() has been called, and returned
  24852. this.ended = false;
  24853. // when 'finish' is emitted
  24854. this.finished = false;
  24855. // should we decode strings into buffers before passing to _write?
  24856. // this is here so that some node-core streams can optimize string
  24857. // handling at a lower level.
  24858. var noDecode = options.decodeStrings === false;
  24859. this.decodeStrings = !noDecode;
  24860. // Crypto is kind of old and crusty. Historically, its default string
  24861. // encoding is 'binary' so we have to make this configurable.
  24862. // Everything else in the universe uses 'utf8', though.
  24863. this.defaultEncoding = options.defaultEncoding || 'utf8';
  24864. // not an actual buffer we keep track of, but a measurement
  24865. // of how much we're waiting to get pushed to some underlying
  24866. // socket or file.
  24867. this.length = 0;
  24868. // a flag to see when we're in the middle of a write.
  24869. this.writing = false;
  24870. // when true all writes will be buffered until .uncork() call
  24871. this.corked = 0;
  24872. // a flag to be able to tell if the onwrite cb is called immediately,
  24873. // or on a later tick. We set this to true at first, because any
  24874. // actions that shouldn't happen until "later" should generally also
  24875. // not happen before the first write call.
  24876. this.sync = true;
  24877. // a flag to know if we're processing previously buffered items, which
  24878. // may call the _write() callback in the same tick, so that we don't
  24879. // end up in an overlapped onwrite situation.
  24880. this.bufferProcessing = false;
  24881. // the callback that's passed to _write(chunk,cb)
  24882. this.onwrite = function(er) {
  24883. onwrite(stream, er);
  24884. };
  24885. // the callback that the user supplies to write(chunk,encoding,cb)
  24886. this.writecb = null;
  24887. // the amount that is being written when _write is called.
  24888. this.writelen = 0;
  24889. this.buffer = [];
  24890. // number of pending user-supplied write callbacks
  24891. // this must be 0 before 'finish' can be emitted
  24892. this.pendingcb = 0;
  24893. // emit prefinish if the only thing we're waiting for is _write cbs
  24894. // This is relevant for synchronous Transform streams
  24895. this.prefinished = false;
  24896. // True if the error was already emitted and should not be thrown again
  24897. this.errorEmitted = false;
  24898. }
  24899. function Writable(options) {
  24900. var Duplex = require('./_stream_duplex');
  24901. // Writable ctor is applied to Duplexes, though they're not
  24902. // instanceof Writable, they're instanceof Readable.
  24903. if (!(this instanceof Writable) && !(this instanceof Duplex))
  24904. return new Writable(options);
  24905. this._writableState = new WritableState(options, this);
  24906. // legacy.
  24907. this.writable = true;
  24908. Stream.call(this);
  24909. }
  24910. // Otherwise people can pipe Writable streams, which is just wrong.
  24911. Writable.prototype.pipe = function() {
  24912. this.emit('error', new Error('Cannot pipe. Not readable.'));
  24913. };
  24914. function writeAfterEnd(stream, state, cb) {
  24915. var er = new Error('write after end');
  24916. // TODO: defer error events consistently everywhere, not just the cb
  24917. stream.emit('error', er);
  24918. process.nextTick(function() {
  24919. cb(er);
  24920. });
  24921. }
  24922. // If we get something that is not a buffer, string, null, or undefined,
  24923. // and we're not in objectMode, then that's an error.
  24924. // Otherwise stream chunks are all considered to be of length=1, and the
  24925. // watermarks determine how many objects to keep in the buffer, rather than
  24926. // how many bytes or characters.
  24927. function validChunk(stream, state, chunk, cb) {
  24928. var valid = true;
  24929. if (!util.isBuffer(chunk) &&
  24930. !util.isString(chunk) &&
  24931. !util.isNullOrUndefined(chunk) &&
  24932. !state.objectMode) {
  24933. var er = new TypeError('Invalid non-string/buffer chunk');
  24934. stream.emit('error', er);
  24935. process.nextTick(function() {
  24936. cb(er);
  24937. });
  24938. valid = false;
  24939. }
  24940. return valid;
  24941. }
  24942. Writable.prototype.write = function(chunk, encoding, cb) {
  24943. var state = this._writableState;
  24944. var ret = false;
  24945. if (util.isFunction(encoding)) {
  24946. cb = encoding;
  24947. encoding = null;
  24948. }
  24949. if (util.isBuffer(chunk))
  24950. encoding = 'buffer';
  24951. else if (!encoding)
  24952. encoding = state.defaultEncoding;
  24953. if (!util.isFunction(cb))
  24954. cb = function() {};
  24955. if (state.ended)
  24956. writeAfterEnd(this, state, cb);
  24957. else if (validChunk(this, state, chunk, cb)) {
  24958. state.pendingcb++;
  24959. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  24960. }
  24961. return ret;
  24962. };
  24963. Writable.prototype.cork = function() {
  24964. var state = this._writableState;
  24965. state.corked++;
  24966. };
  24967. Writable.prototype.uncork = function() {
  24968. var state = this._writableState;
  24969. if (state.corked) {
  24970. state.corked--;
  24971. if (!state.writing &&
  24972. !state.corked &&
  24973. !state.finished &&
  24974. !state.bufferProcessing &&
  24975. state.buffer.length)
  24976. clearBuffer(this, state);
  24977. }
  24978. };
  24979. function decodeChunk(state, chunk, encoding) {
  24980. if (!state.objectMode &&
  24981. state.decodeStrings !== false &&
  24982. util.isString(chunk)) {
  24983. chunk = new Buffer(chunk, encoding);
  24984. }
  24985. return chunk;
  24986. }
  24987. // if we're already writing something, then just put this
  24988. // in the queue, and wait our turn. Otherwise, call _write
  24989. // If we return false, then we need a drain event, so set that flag.
  24990. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  24991. chunk = decodeChunk(state, chunk, encoding);
  24992. if (util.isBuffer(chunk))
  24993. encoding = 'buffer';
  24994. var len = state.objectMode ? 1 : chunk.length;
  24995. state.length += len;
  24996. var ret = state.length < state.highWaterMark;
  24997. // we must ensure that previous needDrain will not be reset to false.
  24998. if (!ret)
  24999. state.needDrain = true;
  25000. if (state.writing || state.corked)
  25001. state.buffer.push(new WriteReq(chunk, encoding, cb));
  25002. else
  25003. doWrite(stream, state, false, len, chunk, encoding, cb);
  25004. return ret;
  25005. }
  25006. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  25007. state.writelen = len;
  25008. state.writecb = cb;
  25009. state.writing = true;
  25010. state.sync = true;
  25011. if (writev)
  25012. stream._writev(chunk, state.onwrite);
  25013. else
  25014. stream._write(chunk, encoding, state.onwrite);
  25015. state.sync = false;
  25016. }
  25017. function onwriteError(stream, state, sync, er, cb) {
  25018. if (sync)
  25019. process.nextTick(function() {
  25020. state.pendingcb--;
  25021. cb(er);
  25022. });
  25023. else {
  25024. state.pendingcb--;
  25025. cb(er);
  25026. }
  25027. stream._writableState.errorEmitted = true;
  25028. stream.emit('error', er);
  25029. }
  25030. function onwriteStateUpdate(state) {
  25031. state.writing = false;
  25032. state.writecb = null;
  25033. state.length -= state.writelen;
  25034. state.writelen = 0;
  25035. }
  25036. function onwrite(stream, er) {
  25037. var state = stream._writableState;
  25038. var sync = state.sync;
  25039. var cb = state.writecb;
  25040. onwriteStateUpdate(state);
  25041. if (er)
  25042. onwriteError(stream, state, sync, er, cb);
  25043. else {
  25044. // Check if we're actually ready to finish, but don't emit yet
  25045. var finished = needFinish(stream, state);
  25046. if (!finished &&
  25047. !state.corked &&
  25048. !state.bufferProcessing &&
  25049. state.buffer.length) {
  25050. clearBuffer(stream, state);
  25051. }
  25052. if (sync) {
  25053. process.nextTick(function() {
  25054. afterWrite(stream, state, finished, cb);
  25055. });
  25056. } else {
  25057. afterWrite(stream, state, finished, cb);
  25058. }
  25059. }
  25060. }
  25061. function afterWrite(stream, state, finished, cb) {
  25062. if (!finished)
  25063. onwriteDrain(stream, state);
  25064. state.pendingcb--;
  25065. cb();
  25066. finishMaybe(stream, state);
  25067. }
  25068. // Must force callback to be called on nextTick, so that we don't
  25069. // emit 'drain' before the write() consumer gets the 'false' return
  25070. // value, and has a chance to attach a 'drain' listener.
  25071. function onwriteDrain(stream, state) {
  25072. if (state.length === 0 && state.needDrain) {
  25073. state.needDrain = false;
  25074. stream.emit('drain');
  25075. }
  25076. }
  25077. // if there's something in the buffer waiting, then process it
  25078. function clearBuffer(stream, state) {
  25079. state.bufferProcessing = true;
  25080. if (stream._writev && state.buffer.length > 1) {
  25081. // Fast case, write everything using _writev()
  25082. var cbs = [];
  25083. for (var c = 0; c < state.buffer.length; c++)
  25084. cbs.push(state.buffer[c].callback);
  25085. // count the one we are adding, as well.
  25086. // TODO(isaacs) clean this up
  25087. state.pendingcb++;
  25088. doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
  25089. for (var i = 0; i < cbs.length; i++) {
  25090. state.pendingcb--;
  25091. cbs[i](err);
  25092. }
  25093. });
  25094. // Clear buffer
  25095. state.buffer = [];
  25096. } else {
  25097. // Slow case, write chunks one-by-one
  25098. for (var c = 0; c < state.buffer.length; c++) {
  25099. var entry = state.buffer[c];
  25100. var chunk = entry.chunk;
  25101. var encoding = entry.encoding;
  25102. var cb = entry.callback;
  25103. var len = state.objectMode ? 1 : chunk.length;
  25104. doWrite(stream, state, false, len, chunk, encoding, cb);
  25105. // if we didn't call the onwrite immediately, then
  25106. // it means that we need to wait until it does.
  25107. // also, that means that the chunk and cb are currently
  25108. // being processed, so move the buffer counter past them.
  25109. if (state.writing) {
  25110. c++;
  25111. break;
  25112. }
  25113. }
  25114. if (c < state.buffer.length)
  25115. state.buffer = state.buffer.slice(c);
  25116. else
  25117. state.buffer.length = 0;
  25118. }
  25119. state.bufferProcessing = false;
  25120. }
  25121. Writable.prototype._write = function(chunk, encoding, cb) {
  25122. cb(new Error('not implemented'));
  25123. };
  25124. Writable.prototype._writev = null;
  25125. Writable.prototype.end = function(chunk, encoding, cb) {
  25126. var state = this._writableState;
  25127. if (util.isFunction(chunk)) {
  25128. cb = chunk;
  25129. chunk = null;
  25130. encoding = null;
  25131. } else if (util.isFunction(encoding)) {
  25132. cb = encoding;
  25133. encoding = null;
  25134. }
  25135. if (!util.isNullOrUndefined(chunk))
  25136. this.write(chunk, encoding);
  25137. // .end() fully uncorks
  25138. if (state.corked) {
  25139. state.corked = 1;
  25140. this.uncork();
  25141. }
  25142. // ignore unnecessary end() calls.
  25143. if (!state.ending && !state.finished)
  25144. endWritable(this, state, cb);
  25145. };
  25146. function needFinish(stream, state) {
  25147. return (state.ending &&
  25148. state.length === 0 &&
  25149. !state.finished &&
  25150. !state.writing);
  25151. }
  25152. function prefinish(stream, state) {
  25153. if (!state.prefinished) {
  25154. state.prefinished = true;
  25155. stream.emit('prefinish');
  25156. }
  25157. }
  25158. function finishMaybe(stream, state) {
  25159. var need = needFinish(stream, state);
  25160. if (need) {
  25161. if (state.pendingcb === 0) {
  25162. prefinish(stream, state);
  25163. state.finished = true;
  25164. stream.emit('finish');
  25165. } else
  25166. prefinish(stream, state);
  25167. }
  25168. return need;
  25169. }
  25170. function endWritable(stream, state, cb) {
  25171. state.ending = true;
  25172. finishMaybe(stream, state);
  25173. if (cb) {
  25174. if (state.finished)
  25175. process.nextTick(cb);
  25176. else
  25177. stream.once('finish', cb);
  25178. }
  25179. state.ended = true;
  25180. }
  25181. }).call(this,require('_process'))
  25182. },{"./_stream_duplex":202,"_process":200,"buffer":192,"core-util-is":207,"inherits":197,"stream":212}],207:[function(require,module,exports){
  25183. (function (Buffer){
  25184. // Copyright Joyent, Inc. and other Node contributors.
  25185. //
  25186. // Permission is hereby granted, free of charge, to any person obtaining a
  25187. // copy of this software and associated documentation files (the
  25188. // "Software"), to deal in the Software without restriction, including
  25189. // without limitation the rights to use, copy, modify, merge, publish,
  25190. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25191. // persons to whom the Software is furnished to do so, subject to the
  25192. // following conditions:
  25193. //
  25194. // The above copyright notice and this permission notice shall be included
  25195. // in all copies or substantial portions of the Software.
  25196. //
  25197. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25198. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25199. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25200. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25201. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25202. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25203. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25204. // NOTE: These type checking functions intentionally don't use `instanceof`
  25205. // because it is fragile and can be easily faked with `Object.create()`.
  25206. function isArray(ar) {
  25207. return Array.isArray(ar);
  25208. }
  25209. exports.isArray = isArray;
  25210. function isBoolean(arg) {
  25211. return typeof arg === 'boolean';
  25212. }
  25213. exports.isBoolean = isBoolean;
  25214. function isNull(arg) {
  25215. return arg === null;
  25216. }
  25217. exports.isNull = isNull;
  25218. function isNullOrUndefined(arg) {
  25219. return arg == null;
  25220. }
  25221. exports.isNullOrUndefined = isNullOrUndefined;
  25222. function isNumber(arg) {
  25223. return typeof arg === 'number';
  25224. }
  25225. exports.isNumber = isNumber;
  25226. function isString(arg) {
  25227. return typeof arg === 'string';
  25228. }
  25229. exports.isString = isString;
  25230. function isSymbol(arg) {
  25231. return typeof arg === 'symbol';
  25232. }
  25233. exports.isSymbol = isSymbol;
  25234. function isUndefined(arg) {
  25235. return arg === void 0;
  25236. }
  25237. exports.isUndefined = isUndefined;
  25238. function isRegExp(re) {
  25239. return isObject(re) && objectToString(re) === '[object RegExp]';
  25240. }
  25241. exports.isRegExp = isRegExp;
  25242. function isObject(arg) {
  25243. return typeof arg === 'object' && arg !== null;
  25244. }
  25245. exports.isObject = isObject;
  25246. function isDate(d) {
  25247. return isObject(d) && objectToString(d) === '[object Date]';
  25248. }
  25249. exports.isDate = isDate;
  25250. function isError(e) {
  25251. return isObject(e) &&
  25252. (objectToString(e) === '[object Error]' || e instanceof Error);
  25253. }
  25254. exports.isError = isError;
  25255. function isFunction(arg) {
  25256. return typeof arg === 'function';
  25257. }
  25258. exports.isFunction = isFunction;
  25259. function isPrimitive(arg) {
  25260. return arg === null ||
  25261. typeof arg === 'boolean' ||
  25262. typeof arg === 'number' ||
  25263. typeof arg === 'string' ||
  25264. typeof arg === 'symbol' || // ES6 symbol
  25265. typeof arg === 'undefined';
  25266. }
  25267. exports.isPrimitive = isPrimitive;
  25268. function isBuffer(arg) {
  25269. return Buffer.isBuffer(arg);
  25270. }
  25271. exports.isBuffer = isBuffer;
  25272. function objectToString(o) {
  25273. return Object.prototype.toString.call(o);
  25274. }
  25275. }).call(this,require("buffer").Buffer)
  25276. },{"buffer":192}],208:[function(require,module,exports){
  25277. module.exports = require("./lib/_stream_passthrough.js")
  25278. },{"./lib/_stream_passthrough.js":203}],209:[function(require,module,exports){
  25279. exports = module.exports = require('./lib/_stream_readable.js');
  25280. exports.Stream = require('stream');
  25281. exports.Readable = exports;
  25282. exports.Writable = require('./lib/_stream_writable.js');
  25283. exports.Duplex = require('./lib/_stream_duplex.js');
  25284. exports.Transform = require('./lib/_stream_transform.js');
  25285. exports.PassThrough = require('./lib/_stream_passthrough.js');
  25286. },{"./lib/_stream_duplex.js":202,"./lib/_stream_passthrough.js":203,"./lib/_stream_readable.js":204,"./lib/_stream_transform.js":205,"./lib/_stream_writable.js":206,"stream":212}],210:[function(require,module,exports){
  25287. module.exports = require("./lib/_stream_transform.js")
  25288. },{"./lib/_stream_transform.js":205}],211:[function(require,module,exports){
  25289. module.exports = require("./lib/_stream_writable.js")
  25290. },{"./lib/_stream_writable.js":206}],212:[function(require,module,exports){
  25291. // Copyright Joyent, Inc. and other Node contributors.
  25292. //
  25293. // Permission is hereby granted, free of charge, to any person obtaining a
  25294. // copy of this software and associated documentation files (the
  25295. // "Software"), to deal in the Software without restriction, including
  25296. // without limitation the rights to use, copy, modify, merge, publish,
  25297. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25298. // persons to whom the Software is furnished to do so, subject to the
  25299. // following conditions:
  25300. //
  25301. // The above copyright notice and this permission notice shall be included
  25302. // in all copies or substantial portions of the Software.
  25303. //
  25304. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25305. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25306. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25307. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25308. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25309. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25310. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25311. module.exports = Stream;
  25312. var EE = require('events').EventEmitter;
  25313. var inherits = require('inherits');
  25314. inherits(Stream, EE);
  25315. Stream.Readable = require('readable-stream/readable.js');
  25316. Stream.Writable = require('readable-stream/writable.js');
  25317. Stream.Duplex = require('readable-stream/duplex.js');
  25318. Stream.Transform = require('readable-stream/transform.js');
  25319. Stream.PassThrough = require('readable-stream/passthrough.js');
  25320. // Backwards-compat with node 0.4.x
  25321. Stream.Stream = Stream;
  25322. // old-style streams. Note that the pipe method (the only relevant
  25323. // part of this class) is overridden in the Readable class.
  25324. function Stream() {
  25325. EE.call(this);
  25326. }
  25327. Stream.prototype.pipe = function(dest, options) {
  25328. var source = this;
  25329. function ondata(chunk) {
  25330. if (dest.writable) {
  25331. if (false === dest.write(chunk) && source.pause) {
  25332. source.pause();
  25333. }
  25334. }
  25335. }
  25336. source.on('data', ondata);
  25337. function ondrain() {
  25338. if (source.readable && source.resume) {
  25339. source.resume();
  25340. }
  25341. }
  25342. dest.on('drain', ondrain);
  25343. // If the 'end' option is not supplied, dest.end() will be called when
  25344. // source gets the 'end' or 'close' events. Only dest.end() once.
  25345. if (!dest._isStdio && (!options || options.end !== false)) {
  25346. source.on('end', onend);
  25347. source.on('close', onclose);
  25348. }
  25349. var didOnEnd = false;
  25350. function onend() {
  25351. if (didOnEnd) return;
  25352. didOnEnd = true;
  25353. dest.end();
  25354. }
  25355. function onclose() {
  25356. if (didOnEnd) return;
  25357. didOnEnd = true;
  25358. if (typeof dest.destroy === 'function') dest.destroy();
  25359. }
  25360. // don't leave dangling pipes when there are errors.
  25361. function onerror(er) {
  25362. cleanup();
  25363. if (EE.listenerCount(this, 'error') === 0) {
  25364. throw er; // Unhandled stream error in pipe.
  25365. }
  25366. }
  25367. source.on('error', onerror);
  25368. dest.on('error', onerror);
  25369. // remove all the event listeners that were added.
  25370. function cleanup() {
  25371. source.removeListener('data', ondata);
  25372. dest.removeListener('drain', ondrain);
  25373. source.removeListener('end', onend);
  25374. source.removeListener('close', onclose);
  25375. source.removeListener('error', onerror);
  25376. dest.removeListener('error', onerror);
  25377. source.removeListener('end', cleanup);
  25378. source.removeListener('close', cleanup);
  25379. dest.removeListener('close', cleanup);
  25380. }
  25381. source.on('end', cleanup);
  25382. source.on('close', cleanup);
  25383. dest.on('close', cleanup);
  25384. dest.emit('pipe', source);
  25385. // Allow for unix-like usage: A.pipe(B).pipe(C)
  25386. return dest;
  25387. };
  25388. },{"events":196,"inherits":197,"readable-stream/duplex.js":201,"readable-stream/passthrough.js":208,"readable-stream/readable.js":209,"readable-stream/transform.js":210,"readable-stream/writable.js":211}],213:[function(require,module,exports){
  25389. // Copyright Joyent, Inc. and other Node contributors.
  25390. //
  25391. // Permission is hereby granted, free of charge, to any person obtaining a
  25392. // copy of this software and associated documentation files (the
  25393. // "Software"), to deal in the Software without restriction, including
  25394. // without limitation the rights to use, copy, modify, merge, publish,
  25395. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25396. // persons to whom the Software is furnished to do so, subject to the
  25397. // following conditions:
  25398. //
  25399. // The above copyright notice and this permission notice shall be included
  25400. // in all copies or substantial portions of the Software.
  25401. //
  25402. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25403. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25404. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25405. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25406. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25407. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25408. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25409. var Buffer = require('buffer').Buffer;
  25410. var isBufferEncoding = Buffer.isEncoding
  25411. || function(encoding) {
  25412. switch (encoding && encoding.toLowerCase()) {
  25413. case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
  25414. default: return false;
  25415. }
  25416. }
  25417. function assertEncoding(encoding) {
  25418. if (encoding && !isBufferEncoding(encoding)) {
  25419. throw new Error('Unknown encoding: ' + encoding);
  25420. }
  25421. }
  25422. // StringDecoder provides an interface for efficiently splitting a series of
  25423. // buffers into a series of JS strings without breaking apart multi-byte
  25424. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  25425. //
  25426. // @TODO Handling all encodings inside a single object makes it very difficult
  25427. // to reason about this code, so it should be split up in the future.
  25428. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  25429. // points as used by CESU-8.
  25430. var StringDecoder = exports.StringDecoder = function(encoding) {
  25431. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  25432. assertEncoding(encoding);
  25433. switch (this.encoding) {
  25434. case 'utf8':
  25435. // CESU-8 represents each of Surrogate Pair by 3-bytes
  25436. this.surrogateSize = 3;
  25437. break;
  25438. case 'ucs2':
  25439. case 'utf16le':
  25440. // UTF-16 represents each of Surrogate Pair by 2-bytes
  25441. this.surrogateSize = 2;
  25442. this.detectIncompleteChar = utf16DetectIncompleteChar;
  25443. break;
  25444. case 'base64':
  25445. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  25446. this.surrogateSize = 3;
  25447. this.detectIncompleteChar = base64DetectIncompleteChar;
  25448. break;
  25449. default:
  25450. this.write = passThroughWrite;
  25451. return;
  25452. }
  25453. // Enough space to store all bytes of a single character. UTF-8 needs 4
  25454. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  25455. this.charBuffer = new Buffer(6);
  25456. // Number of bytes received for the current incomplete multi-byte character.
  25457. this.charReceived = 0;
  25458. // Number of bytes expected for the current incomplete multi-byte character.
  25459. this.charLength = 0;
  25460. };
  25461. // write decodes the given buffer and returns it as JS string that is
  25462. // guaranteed to not contain any partial multi-byte characters. Any partial
  25463. // character found at the end of the buffer is buffered up, and will be
  25464. // returned when calling write again with the remaining bytes.
  25465. //
  25466. // Note: Converting a Buffer containing an orphan surrogate to a String
  25467. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  25468. // Buffer#write) will replace incomplete surrogates with the unicode
  25469. // replacement character. See https://codereview.chromium.org/121173009/ .
  25470. StringDecoder.prototype.write = function(buffer) {
  25471. var charStr = '';
  25472. // if our last write ended with an incomplete multibyte character
  25473. while (this.charLength) {
  25474. // determine how many remaining bytes this buffer has to offer for this char
  25475. var available = (buffer.length >= this.charLength - this.charReceived) ?
  25476. this.charLength - this.charReceived :
  25477. buffer.length;
  25478. // add the new bytes to the char buffer
  25479. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  25480. this.charReceived += available;
  25481. if (this.charReceived < this.charLength) {
  25482. // still not enough chars in this buffer? wait for more ...
  25483. return '';
  25484. }
  25485. // remove bytes belonging to the current character from the buffer
  25486. buffer = buffer.slice(available, buffer.length);
  25487. // get the character that was split
  25488. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  25489. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  25490. var charCode = charStr.charCodeAt(charStr.length - 1);
  25491. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  25492. this.charLength += this.surrogateSize;
  25493. charStr = '';
  25494. continue;
  25495. }
  25496. this.charReceived = this.charLength = 0;
  25497. // if there are no more bytes in this buffer, just emit our char
  25498. if (buffer.length === 0) {
  25499. return charStr;
  25500. }
  25501. break;
  25502. }
  25503. // determine and set charLength / charReceived
  25504. this.detectIncompleteChar(buffer);
  25505. var end = buffer.length;
  25506. if (this.charLength) {
  25507. // buffer the incomplete character bytes we got
  25508. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  25509. end -= this.charReceived;
  25510. }
  25511. charStr += buffer.toString(this.encoding, 0, end);
  25512. var end = charStr.length - 1;
  25513. var charCode = charStr.charCodeAt(end);
  25514. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  25515. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  25516. var size = this.surrogateSize;
  25517. this.charLength += size;
  25518. this.charReceived += size;
  25519. this.charBuffer.copy(this.charBuffer, size, 0, size);
  25520. buffer.copy(this.charBuffer, 0, 0, size);
  25521. return charStr.substring(0, end);
  25522. }
  25523. // or just emit the charStr
  25524. return charStr;
  25525. };
  25526. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  25527. // the end of the given buffer. If so, it sets this.charLength to the byte
  25528. // length that character, and sets this.charReceived to the number of bytes
  25529. // that are available for this character.
  25530. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  25531. // determine how many bytes we have to check at the end of this buffer
  25532. var i = (buffer.length >= 3) ? 3 : buffer.length;
  25533. // Figure out if one of the last i bytes of our buffer announces an
  25534. // incomplete char.
  25535. for (; i > 0; i--) {
  25536. var c = buffer[buffer.length - i];
  25537. // See http://en.wikipedia.org/wiki/UTF-8#Description
  25538. // 110XXXXX
  25539. if (i == 1 && c >> 5 == 0x06) {
  25540. this.charLength = 2;
  25541. break;
  25542. }
  25543. // 1110XXXX
  25544. if (i <= 2 && c >> 4 == 0x0E) {
  25545. this.charLength = 3;
  25546. break;
  25547. }
  25548. // 11110XXX
  25549. if (i <= 3 && c >> 3 == 0x1E) {
  25550. this.charLength = 4;
  25551. break;
  25552. }
  25553. }
  25554. this.charReceived = i;
  25555. };
  25556. StringDecoder.prototype.end = function(buffer) {
  25557. var res = '';
  25558. if (buffer && buffer.length)
  25559. res = this.write(buffer);
  25560. if (this.charReceived) {
  25561. var cr = this.charReceived;
  25562. var buf = this.charBuffer;
  25563. var enc = this.encoding;
  25564. res += buf.slice(0, cr).toString(enc);
  25565. }
  25566. return res;
  25567. };
  25568. function passThroughWrite(buffer) {
  25569. return buffer.toString(this.encoding);
  25570. }
  25571. function utf16DetectIncompleteChar(buffer) {
  25572. this.charReceived = buffer.length % 2;
  25573. this.charLength = this.charReceived ? 2 : 0;
  25574. }
  25575. function base64DetectIncompleteChar(buffer) {
  25576. this.charReceived = buffer.length % 3;
  25577. this.charLength = this.charReceived ? 3 : 0;
  25578. }
  25579. },{"buffer":192}],214:[function(require,module,exports){
  25580. exports.isatty = function () { return false; };
  25581. function ReadStream() {
  25582. throw new Error('tty.ReadStream is not implemented');
  25583. }
  25584. exports.ReadStream = ReadStream;
  25585. function WriteStream() {
  25586. throw new Error('tty.ReadStream is not implemented');
  25587. }
  25588. exports.WriteStream = WriteStream;
  25589. },{}],215:[function(require,module,exports){
  25590. module.exports = function isBuffer(arg) {
  25591. return arg && typeof arg === 'object'
  25592. && typeof arg.copy === 'function'
  25593. && typeof arg.fill === 'function'
  25594. && typeof arg.readUInt8 === 'function';
  25595. }
  25596. },{}],216:[function(require,module,exports){
  25597. (function (process,global){
  25598. // Copyright Joyent, Inc. and other Node contributors.
  25599. //
  25600. // Permission is hereby granted, free of charge, to any person obtaining a
  25601. // copy of this software and associated documentation files (the
  25602. // "Software"), to deal in the Software without restriction, including
  25603. // without limitation the rights to use, copy, modify, merge, publish,
  25604. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25605. // persons to whom the Software is furnished to do so, subject to the
  25606. // following conditions:
  25607. //
  25608. // The above copyright notice and this permission notice shall be included
  25609. // in all copies or substantial portions of the Software.
  25610. //
  25611. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25612. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25613. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25614. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25615. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25616. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25617. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25618. var formatRegExp = /%[sdj%]/g;
  25619. exports.format = function(f) {
  25620. if (!isString(f)) {
  25621. var objects = [];
  25622. for (var i = 0; i < arguments.length; i++) {
  25623. objects.push(inspect(arguments[i]));
  25624. }
  25625. return objects.join(' ');
  25626. }
  25627. var i = 1;
  25628. var args = arguments;
  25629. var len = args.length;
  25630. var str = String(f).replace(formatRegExp, function(x) {
  25631. if (x === '%%') return '%';
  25632. if (i >= len) return x;
  25633. switch (x) {
  25634. case '%s': return String(args[i++]);
  25635. case '%d': return Number(args[i++]);
  25636. case '%j':
  25637. try {
  25638. return JSON.stringify(args[i++]);
  25639. } catch (_) {
  25640. return '[Circular]';
  25641. }
  25642. default:
  25643. return x;
  25644. }
  25645. });
  25646. for (var x = args[i]; i < len; x = args[++i]) {
  25647. if (isNull(x) || !isObject(x)) {
  25648. str += ' ' + x;
  25649. } else {
  25650. str += ' ' + inspect(x);
  25651. }
  25652. }
  25653. return str;
  25654. };
  25655. // Mark that a method should not be used.
  25656. // Returns a modified function which warns once by default.
  25657. // If --no-deprecation is set, then it is a no-op.
  25658. exports.deprecate = function(fn, msg) {
  25659. // Allow for deprecating things in the process of starting up.
  25660. if (isUndefined(global.process)) {
  25661. return function() {
  25662. return exports.deprecate(fn, msg).apply(this, arguments);
  25663. };
  25664. }
  25665. if (process.noDeprecation === true) {
  25666. return fn;
  25667. }
  25668. var warned = false;
  25669. function deprecated() {
  25670. if (!warned) {
  25671. if (process.throwDeprecation) {
  25672. throw new Error(msg);
  25673. } else if (process.traceDeprecation) {
  25674. console.trace(msg);
  25675. } else {
  25676. console.error(msg);
  25677. }
  25678. warned = true;
  25679. }
  25680. return fn.apply(this, arguments);
  25681. }
  25682. return deprecated;
  25683. };
  25684. var debugs = {};
  25685. var debugEnviron;
  25686. exports.debuglog = function(set) {
  25687. if (isUndefined(debugEnviron))
  25688. debugEnviron = process.env.NODE_DEBUG || '';
  25689. set = set.toUpperCase();
  25690. if (!debugs[set]) {
  25691. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  25692. var pid = process.pid;
  25693. debugs[set] = function() {
  25694. var msg = exports.format.apply(exports, arguments);
  25695. console.error('%s %d: %s', set, pid, msg);
  25696. };
  25697. } else {
  25698. debugs[set] = function() {};
  25699. }
  25700. }
  25701. return debugs[set];
  25702. };
  25703. /**
  25704. * Echos the value of a value. Trys to print the value out
  25705. * in the best way possible given the different types.
  25706. *
  25707. * @param {Object} obj The object to print out.
  25708. * @param {Object} opts Optional options object that alters the output.
  25709. */
  25710. /* legacy: obj, showHidden, depth, colors*/
  25711. function inspect(obj, opts) {
  25712. // default options
  25713. var ctx = {
  25714. seen: [],
  25715. stylize: stylizeNoColor
  25716. };
  25717. // legacy...
  25718. if (arguments.length >= 3) ctx.depth = arguments[2];
  25719. if (arguments.length >= 4) ctx.colors = arguments[3];
  25720. if (isBoolean(opts)) {
  25721. // legacy...
  25722. ctx.showHidden = opts;
  25723. } else if (opts) {
  25724. // got an "options" object
  25725. exports._extend(ctx, opts);
  25726. }
  25727. // set default options
  25728. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  25729. if (isUndefined(ctx.depth)) ctx.depth = 2;
  25730. if (isUndefined(ctx.colors)) ctx.colors = false;
  25731. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  25732. if (ctx.colors) ctx.stylize = stylizeWithColor;
  25733. return formatValue(ctx, obj, ctx.depth);
  25734. }
  25735. exports.inspect = inspect;
  25736. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  25737. inspect.colors = {
  25738. 'bold' : [1, 22],
  25739. 'italic' : [3, 23],
  25740. 'underline' : [4, 24],
  25741. 'inverse' : [7, 27],
  25742. 'white' : [37, 39],
  25743. 'grey' : [90, 39],
  25744. 'black' : [30, 39],
  25745. 'blue' : [34, 39],
  25746. 'cyan' : [36, 39],
  25747. 'green' : [32, 39],
  25748. 'magenta' : [35, 39],
  25749. 'red' : [31, 39],
  25750. 'yellow' : [33, 39]
  25751. };
  25752. // Don't use 'blue' not visible on cmd.exe
  25753. inspect.styles = {
  25754. 'special': 'cyan',
  25755. 'number': 'yellow',
  25756. 'boolean': 'yellow',
  25757. 'undefined': 'grey',
  25758. 'null': 'bold',
  25759. 'string': 'green',
  25760. 'date': 'magenta',
  25761. // "name": intentionally not styling
  25762. 'regexp': 'red'
  25763. };
  25764. function stylizeWithColor(str, styleType) {
  25765. var style = inspect.styles[styleType];
  25766. if (style) {
  25767. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  25768. '\u001b[' + inspect.colors[style][1] + 'm';
  25769. } else {
  25770. return str;
  25771. }
  25772. }
  25773. function stylizeNoColor(str, styleType) {
  25774. return str;
  25775. }
  25776. function arrayToHash(array) {
  25777. var hash = {};
  25778. array.forEach(function(val, idx) {
  25779. hash[val] = true;
  25780. });
  25781. return hash;
  25782. }
  25783. function formatValue(ctx, value, recurseTimes) {
  25784. // Provide a hook for user-specified inspect functions.
  25785. // Check that value is an object with an inspect function on it
  25786. if (ctx.customInspect &&
  25787. value &&
  25788. isFunction(value.inspect) &&
  25789. // Filter out the util module, it's inspect function is special
  25790. value.inspect !== exports.inspect &&
  25791. // Also filter out any prototype objects using the circular check.
  25792. !(value.constructor && value.constructor.prototype === value)) {
  25793. var ret = value.inspect(recurseTimes, ctx);
  25794. if (!isString(ret)) {
  25795. ret = formatValue(ctx, ret, recurseTimes);
  25796. }
  25797. return ret;
  25798. }
  25799. // Primitive types cannot have properties
  25800. var primitive = formatPrimitive(ctx, value);
  25801. if (primitive) {
  25802. return primitive;
  25803. }
  25804. // Look up the keys of the object.
  25805. var keys = Object.keys(value);
  25806. var visibleKeys = arrayToHash(keys);
  25807. if (ctx.showHidden) {
  25808. keys = Object.getOwnPropertyNames(value);
  25809. }
  25810. // IE doesn't make error fields non-enumerable
  25811. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  25812. if (isError(value)
  25813. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  25814. return formatError(value);
  25815. }
  25816. // Some type of object without properties can be shortcutted.
  25817. if (keys.length === 0) {
  25818. if (isFunction(value)) {
  25819. var name = value.name ? ': ' + value.name : '';
  25820. return ctx.stylize('[Function' + name + ']', 'special');
  25821. }
  25822. if (isRegExp(value)) {
  25823. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  25824. }
  25825. if (isDate(value)) {
  25826. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  25827. }
  25828. if (isError(value)) {
  25829. return formatError(value);
  25830. }
  25831. }
  25832. var base = '', array = false, braces = ['{', '}'];
  25833. // Make Array say that they are Array
  25834. if (isArray(value)) {
  25835. array = true;
  25836. braces = ['[', ']'];
  25837. }
  25838. // Make functions say that they are functions
  25839. if (isFunction(value)) {
  25840. var n = value.name ? ': ' + value.name : '';
  25841. base = ' [Function' + n + ']';
  25842. }
  25843. // Make RegExps say that they are RegExps
  25844. if (isRegExp(value)) {
  25845. base = ' ' + RegExp.prototype.toString.call(value);
  25846. }
  25847. // Make dates with properties first say the date
  25848. if (isDate(value)) {
  25849. base = ' ' + Date.prototype.toUTCString.call(value);
  25850. }
  25851. // Make error with message first say the error
  25852. if (isError(value)) {
  25853. base = ' ' + formatError(value);
  25854. }
  25855. if (keys.length === 0 && (!array || value.length == 0)) {
  25856. return braces[0] + base + braces[1];
  25857. }
  25858. if (recurseTimes < 0) {
  25859. if (isRegExp(value)) {
  25860. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  25861. } else {
  25862. return ctx.stylize('[Object]', 'special');
  25863. }
  25864. }
  25865. ctx.seen.push(value);
  25866. var output;
  25867. if (array) {
  25868. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  25869. } else {
  25870. output = keys.map(function(key) {
  25871. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  25872. });
  25873. }
  25874. ctx.seen.pop();
  25875. return reduceToSingleString(output, base, braces);
  25876. }
  25877. function formatPrimitive(ctx, value) {
  25878. if (isUndefined(value))
  25879. return ctx.stylize('undefined', 'undefined');
  25880. if (isString(value)) {
  25881. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  25882. .replace(/'/g, "\\'")
  25883. .replace(/\\"/g, '"') + '\'';
  25884. return ctx.stylize(simple, 'string');
  25885. }
  25886. if (isNumber(value))
  25887. return ctx.stylize('' + value, 'number');
  25888. if (isBoolean(value))
  25889. return ctx.stylize('' + value, 'boolean');
  25890. // For some reason typeof null is "object", so special case here.
  25891. if (isNull(value))
  25892. return ctx.stylize('null', 'null');
  25893. }
  25894. function formatError(value) {
  25895. return '[' + Error.prototype.toString.call(value) + ']';
  25896. }
  25897. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  25898. var output = [];
  25899. for (var i = 0, l = value.length; i < l; ++i) {
  25900. if (hasOwnProperty(value, String(i))) {
  25901. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  25902. String(i), true));
  25903. } else {
  25904. output.push('');
  25905. }
  25906. }
  25907. keys.forEach(function(key) {
  25908. if (!key.match(/^\d+$/)) {
  25909. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  25910. key, true));
  25911. }
  25912. });
  25913. return output;
  25914. }
  25915. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  25916. var name, str, desc;
  25917. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  25918. if (desc.get) {
  25919. if (desc.set) {
  25920. str = ctx.stylize('[Getter/Setter]', 'special');
  25921. } else {
  25922. str = ctx.stylize('[Getter]', 'special');
  25923. }
  25924. } else {
  25925. if (desc.set) {
  25926. str = ctx.stylize('[Setter]', 'special');
  25927. }
  25928. }
  25929. if (!hasOwnProperty(visibleKeys, key)) {
  25930. name = '[' + key + ']';
  25931. }
  25932. if (!str) {
  25933. if (ctx.seen.indexOf(desc.value) < 0) {
  25934. if (isNull(recurseTimes)) {
  25935. str = formatValue(ctx, desc.value, null);
  25936. } else {
  25937. str = formatValue(ctx, desc.value, recurseTimes - 1);
  25938. }
  25939. if (str.indexOf('\n') > -1) {
  25940. if (array) {
  25941. str = str.split('\n').map(function(line) {
  25942. return ' ' + line;
  25943. }).join('\n').substr(2);
  25944. } else {
  25945. str = '\n' + str.split('\n').map(function(line) {
  25946. return ' ' + line;
  25947. }).join('\n');
  25948. }
  25949. }
  25950. } else {
  25951. str = ctx.stylize('[Circular]', 'special');
  25952. }
  25953. }
  25954. if (isUndefined(name)) {
  25955. if (array && key.match(/^\d+$/)) {
  25956. return str;
  25957. }
  25958. name = JSON.stringify('' + key);
  25959. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  25960. name = name.substr(1, name.length - 2);
  25961. name = ctx.stylize(name, 'name');
  25962. } else {
  25963. name = name.replace(/'/g, "\\'")
  25964. .replace(/\\"/g, '"')
  25965. .replace(/(^"|"$)/g, "'");
  25966. name = ctx.stylize(name, 'string');
  25967. }
  25968. }
  25969. return name + ': ' + str;
  25970. }
  25971. function reduceToSingleString(output, base, braces) {
  25972. var numLinesEst = 0;
  25973. var length = output.reduce(function(prev, cur) {
  25974. numLinesEst++;
  25975. if (cur.indexOf('\n') >= 0) numLinesEst++;
  25976. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  25977. }, 0);
  25978. if (length > 60) {
  25979. return braces[0] +
  25980. (base === '' ? '' : base + '\n ') +
  25981. ' ' +
  25982. output.join(',\n ') +
  25983. ' ' +
  25984. braces[1];
  25985. }
  25986. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  25987. }
  25988. // NOTE: These type checking functions intentionally don't use `instanceof`
  25989. // because it is fragile and can be easily faked with `Object.create()`.
  25990. function isArray(ar) {
  25991. return Array.isArray(ar);
  25992. }
  25993. exports.isArray = isArray;
  25994. function isBoolean(arg) {
  25995. return typeof arg === 'boolean';
  25996. }
  25997. exports.isBoolean = isBoolean;
  25998. function isNull(arg) {
  25999. return arg === null;
  26000. }
  26001. exports.isNull = isNull;
  26002. function isNullOrUndefined(arg) {
  26003. return arg == null;
  26004. }
  26005. exports.isNullOrUndefined = isNullOrUndefined;
  26006. function isNumber(arg) {
  26007. return typeof arg === 'number';
  26008. }
  26009. exports.isNumber = isNumber;
  26010. function isString(arg) {
  26011. return typeof arg === 'string';
  26012. }
  26013. exports.isString = isString;
  26014. function isSymbol(arg) {
  26015. return typeof arg === 'symbol';
  26016. }
  26017. exports.isSymbol = isSymbol;
  26018. function isUndefined(arg) {
  26019. return arg === void 0;
  26020. }
  26021. exports.isUndefined = isUndefined;
  26022. function isRegExp(re) {
  26023. return isObject(re) && objectToString(re) === '[object RegExp]';
  26024. }
  26025. exports.isRegExp = isRegExp;
  26026. function isObject(arg) {
  26027. return typeof arg === 'object' && arg !== null;
  26028. }
  26029. exports.isObject = isObject;
  26030. function isDate(d) {
  26031. return isObject(d) && objectToString(d) === '[object Date]';
  26032. }
  26033. exports.isDate = isDate;
  26034. function isError(e) {
  26035. return isObject(e) &&
  26036. (objectToString(e) === '[object Error]' || e instanceof Error);
  26037. }
  26038. exports.isError = isError;
  26039. function isFunction(arg) {
  26040. return typeof arg === 'function';
  26041. }
  26042. exports.isFunction = isFunction;
  26043. function isPrimitive(arg) {
  26044. return arg === null ||
  26045. typeof arg === 'boolean' ||
  26046. typeof arg === 'number' ||
  26047. typeof arg === 'string' ||
  26048. typeof arg === 'symbol' || // ES6 symbol
  26049. typeof arg === 'undefined';
  26050. }
  26051. exports.isPrimitive = isPrimitive;
  26052. exports.isBuffer = require('./support/isBuffer');
  26053. function objectToString(o) {
  26054. return Object.prototype.toString.call(o);
  26055. }
  26056. function pad(n) {
  26057. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  26058. }
  26059. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  26060. 'Oct', 'Nov', 'Dec'];
  26061. // 26 Feb 16:19:34
  26062. function timestamp() {
  26063. var d = new Date();
  26064. var time = [pad(d.getHours()),
  26065. pad(d.getMinutes()),
  26066. pad(d.getSeconds())].join(':');
  26067. return [d.getDate(), months[d.getMonth()], time].join(' ');
  26068. }
  26069. // log is just a thin wrapper to console.log that prepends a timestamp
  26070. exports.log = function() {
  26071. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  26072. };
  26073. /**
  26074. * Inherit the prototype methods from one constructor into another.
  26075. *
  26076. * The Function.prototype.inherits from lang.js rewritten as a standalone
  26077. * function (not on Function.prototype). NOTE: If this file is to be loaded
  26078. * during bootstrapping this function needs to be rewritten using some native
  26079. * functions as prototype setup using normal JavaScript does not work as
  26080. * expected during bootstrapping (see mirror.js in r114903).
  26081. *
  26082. * @param {function} ctor Constructor function which needs to inherit the
  26083. * prototype.
  26084. * @param {function} superCtor Constructor function to inherit prototype from.
  26085. */
  26086. exports.inherits = require('inherits');
  26087. exports._extend = function(origin, add) {
  26088. // Don't do anything if add isn't an object
  26089. if (!add || !isObject(add)) return origin;
  26090. var keys = Object.keys(add);
  26091. var i = keys.length;
  26092. while (i--) {
  26093. origin[keys[i]] = add[keys[i]];
  26094. }
  26095. return origin;
  26096. };
  26097. function hasOwnProperty(obj, prop) {
  26098. return Object.prototype.hasOwnProperty.call(obj, prop);
  26099. }
  26100. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  26101. },{"./support/isBuffer":215,"_process":200,"inherits":197}],217:[function(require,module,exports){
  26102. (function (process){
  26103. 'use strict';
  26104. var escapeStringRegexp = require('escape-string-regexp');
  26105. var ansiStyles = require('ansi-styles');
  26106. var stripAnsi = require('strip-ansi');
  26107. var hasAnsi = require('has-ansi');
  26108. var supportsColor = require('supports-color');
  26109. var defineProps = Object.defineProperties;
  26110. function Chalk(options) {
  26111. // detect mode if not set manually
  26112. this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
  26113. }
  26114. // use bright blue on Windows as the normal blue color is illegible
  26115. if (process.platform === 'win32') {
  26116. ansiStyles.blue.open = '\u001b[94m';
  26117. }
  26118. function build(_styles) {
  26119. var builder = function builder() {
  26120. return applyStyle.apply(builder, arguments);
  26121. };
  26122. builder._styles = _styles;
  26123. builder.enabled = this.enabled;
  26124. // __proto__ is used because we must return a function, but there is
  26125. // no way to create a function with a different prototype.
  26126. builder.__proto__ = proto;
  26127. return builder;
  26128. }
  26129. var styles = (function () {
  26130. var ret = {};
  26131. Object.keys(ansiStyles).forEach(function (key) {
  26132. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  26133. ret[key] = {
  26134. get: function () {
  26135. return build.call(this, this._styles.concat(key));
  26136. }
  26137. };
  26138. });
  26139. return ret;
  26140. })();
  26141. var proto = defineProps(function chalk() {}, styles);
  26142. function applyStyle() {
  26143. // support varags, but simply cast to string in case there's only one arg
  26144. var args = arguments;
  26145. var argsLen = args.length;
  26146. var str = argsLen !== 0 && String(arguments[0]);
  26147. if (argsLen > 1) {
  26148. // don't slice `arguments`, it prevents v8 optimizations
  26149. for (var a = 1; a < argsLen; a++) {
  26150. str += ' ' + args[a];
  26151. }
  26152. }
  26153. if (!this.enabled || !str) {
  26154. return str;
  26155. }
  26156. /*jshint validthis: true */
  26157. var nestedStyles = this._styles;
  26158. var i = nestedStyles.length;
  26159. while (i--) {
  26160. var code = ansiStyles[nestedStyles[i]];
  26161. // Replace any instances already present with a re-opening code
  26162. // otherwise only the part of the string until said closing code
  26163. // will be colored, and the rest will simply be 'plain'.
  26164. str = code.open + str.replace(code.closeRe, code.open) + code.close;
  26165. }
  26166. return str;
  26167. }
  26168. function init() {
  26169. var ret = {};
  26170. Object.keys(styles).forEach(function (name) {
  26171. ret[name] = {
  26172. get: function () {
  26173. return build.call(this, [name]);
  26174. }
  26175. };
  26176. });
  26177. return ret;
  26178. }
  26179. defineProps(Chalk.prototype, init());
  26180. module.exports = new Chalk();
  26181. module.exports.styles = ansiStyles;
  26182. module.exports.hasColor = hasAnsi;
  26183. module.exports.stripColor = stripAnsi;
  26184. module.exports.supportsColor = supportsColor;
  26185. }).call(this,require('_process'))
  26186. },{"_process":200,"ansi-styles":218,"escape-string-regexp":219,"has-ansi":220,"strip-ansi":222,"supports-color":224}],218:[function(require,module,exports){
  26187. 'use strict';
  26188. var styles = module.exports = {
  26189. modifiers: {
  26190. reset: [0, 0],
  26191. bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
  26192. dim: [2, 22],
  26193. italic: [3, 23],
  26194. underline: [4, 24],
  26195. inverse: [7, 27],
  26196. hidden: [8, 28],
  26197. strikethrough: [9, 29]
  26198. },
  26199. colors: {
  26200. black: [30, 39],
  26201. red: [31, 39],
  26202. green: [32, 39],
  26203. yellow: [33, 39],
  26204. blue: [34, 39],
  26205. magenta: [35, 39],
  26206. cyan: [36, 39],
  26207. white: [37, 39],
  26208. gray: [90, 39]
  26209. },
  26210. bgColors: {
  26211. bgBlack: [40, 49],
  26212. bgRed: [41, 49],
  26213. bgGreen: [42, 49],
  26214. bgYellow: [43, 49],
  26215. bgBlue: [44, 49],
  26216. bgMagenta: [45, 49],
  26217. bgCyan: [46, 49],
  26218. bgWhite: [47, 49]
  26219. }
  26220. };
  26221. // fix humans
  26222. styles.colors.grey = styles.colors.gray;
  26223. Object.keys(styles).forEach(function (groupName) {
  26224. var group = styles[groupName];
  26225. Object.keys(group).forEach(function (styleName) {
  26226. var style = group[styleName];
  26227. styles[styleName] = group[styleName] = {
  26228. open: '\u001b[' + style[0] + 'm',
  26229. close: '\u001b[' + style[1] + 'm'
  26230. };
  26231. });
  26232. Object.defineProperty(styles, groupName, {
  26233. value: group,
  26234. enumerable: false
  26235. });
  26236. });
  26237. },{}],219:[function(require,module,exports){
  26238. 'use strict';
  26239. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  26240. module.exports = function (str) {
  26241. if (typeof str !== 'string') {
  26242. throw new TypeError('Expected a string');
  26243. }
  26244. return str.replace(matchOperatorsRe, '\\$&');
  26245. };
  26246. },{}],220:[function(require,module,exports){
  26247. 'use strict';
  26248. var ansiRegex = require('ansi-regex');
  26249. var re = new RegExp(ansiRegex().source); // remove the `g` flag
  26250. module.exports = re.test.bind(re);
  26251. },{"ansi-regex":221}],221:[function(require,module,exports){
  26252. 'use strict';
  26253. module.exports = function () {
  26254. return /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/g;
  26255. };
  26256. },{}],222:[function(require,module,exports){
  26257. 'use strict';
  26258. var ansiRegex = require('ansi-regex')();
  26259. module.exports = function (str) {
  26260. return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
  26261. };
  26262. },{"ansi-regex":223}],223:[function(require,module,exports){
  26263. arguments[4][221][0].apply(exports,arguments)
  26264. },{"dup":221}],224:[function(require,module,exports){
  26265. (function (process){
  26266. 'use strict';
  26267. var argv = process.argv;
  26268. module.exports = (function () {
  26269. if ('FORCE_COLOR' in process.env) {
  26270. return true;
  26271. }
  26272. if (argv.indexOf('--no-color') !== -1 ||
  26273. argv.indexOf('--no-colors') !== -1 ||
  26274. argv.indexOf('--color=false') !== -1) {
  26275. return false;
  26276. }
  26277. if (argv.indexOf('--color') !== -1 ||
  26278. argv.indexOf('--colors') !== -1 ||
  26279. argv.indexOf('--color=true') !== -1 ||
  26280. argv.indexOf('--color=always') !== -1) {
  26281. return true;
  26282. }
  26283. if (process.stdout && !process.stdout.isTTY) {
  26284. return false;
  26285. }
  26286. if (process.platform === 'win32') {
  26287. return true;
  26288. }
  26289. if ('COLORTERM' in process.env) {
  26290. return true;
  26291. }
  26292. if (process.env.TERM === 'dumb') {
  26293. return false;
  26294. }
  26295. if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
  26296. return true;
  26297. }
  26298. return false;
  26299. })();
  26300. }).call(this,require('_process'))
  26301. },{"_process":200}],225:[function(require,module,exports){
  26302. (function (Buffer){
  26303. 'use strict';
  26304. var fs = require('fs');
  26305. var path = require('path');
  26306. var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
  26307. var mapFileCommentRx =
  26308. // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
  26309. /(?:\/\/[@#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
  26310. function decodeBase64(base64) {
  26311. return new Buffer(base64, 'base64').toString();
  26312. }
  26313. function stripComment(sm) {
  26314. return sm.split(',').pop();
  26315. }
  26316. function readFromFileMap(sm, dir) {
  26317. // NOTE: this will only work on the server since it attempts to read the map file
  26318. var r = mapFileCommentRx.exec(sm);
  26319. mapFileCommentRx.lastIndex = 0;
  26320. // for some odd reason //# .. captures in 1 and /* .. */ in 2
  26321. var filename = r[1] || r[2];
  26322. var filepath = path.join(dir, filename);
  26323. try {
  26324. return fs.readFileSync(filepath, 'utf8');
  26325. } catch (e) {
  26326. throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
  26327. }
  26328. }
  26329. function Converter (sm, opts) {
  26330. opts = opts || {};
  26331. if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
  26332. if (opts.hasComment) sm = stripComment(sm);
  26333. if (opts.isEncoded) sm = decodeBase64(sm);
  26334. if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
  26335. this.sourcemap = sm;
  26336. }
  26337. function convertFromLargeSource(content){
  26338. var lines = content.split('\n');
  26339. var line;
  26340. // find first line which contains a source map starting at end of content
  26341. for (var i = lines.length - 1; i > 0; i--) {
  26342. line = lines[i]
  26343. if (~line.indexOf('sourceMappingURL=data:')) return exports.fromComment(line);
  26344. }
  26345. }
  26346. Converter.prototype.toJSON = function (space) {
  26347. return JSON.stringify(this.sourcemap, null, space);
  26348. };
  26349. Converter.prototype.toBase64 = function () {
  26350. var json = this.toJSON();
  26351. return new Buffer(json).toString('base64');
  26352. };
  26353. Converter.prototype.toComment = function (options) {
  26354. var base64 = this.toBase64();
  26355. var data = 'sourceMappingURL=data:application/json;base64,' + base64;
  26356. return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
  26357. };
  26358. // returns copy instead of original
  26359. Converter.prototype.toObject = function () {
  26360. return JSON.parse(this.toJSON());
  26361. };
  26362. Converter.prototype.addProperty = function (key, value) {
  26363. if (this.sourcemap.hasOwnProperty(key)) throw new Error('property %s already exists on the sourcemap, use set property instead');
  26364. return this.setProperty(key, value);
  26365. };
  26366. Converter.prototype.setProperty = function (key, value) {
  26367. this.sourcemap[key] = value;
  26368. return this;
  26369. };
  26370. Converter.prototype.getProperty = function (key) {
  26371. return this.sourcemap[key];
  26372. };
  26373. exports.fromObject = function (obj) {
  26374. return new Converter(obj);
  26375. };
  26376. exports.fromJSON = function (json) {
  26377. return new Converter(json, { isJSON: true });
  26378. };
  26379. exports.fromBase64 = function (base64) {
  26380. return new Converter(base64, { isEncoded: true });
  26381. };
  26382. exports.fromComment = function (comment) {
  26383. comment = comment
  26384. .replace(/^\/\*/g, '//')
  26385. .replace(/\*\/$/g, '');
  26386. return new Converter(comment, { isEncoded: true, hasComment: true });
  26387. };
  26388. exports.fromMapFileComment = function (comment, dir) {
  26389. return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
  26390. };
  26391. // Finds last sourcemap comment in file or returns null if none was found
  26392. exports.fromSource = function (content, largeSource) {
  26393. if (largeSource) return convertFromLargeSource(content);
  26394. var m = content.match(commentRx);
  26395. commentRx.lastIndex = 0;
  26396. return m ? exports.fromComment(m.pop()) : null;
  26397. };
  26398. // Finds last sourcemap comment in file or returns null if none was found
  26399. exports.fromMapFileSource = function (content, dir) {
  26400. var m = content.match(mapFileCommentRx);
  26401. mapFileCommentRx.lastIndex = 0;
  26402. return m ? exports.fromMapFileComment(m.pop(), dir) : null;
  26403. };
  26404. exports.removeComments = function (src) {
  26405. commentRx.lastIndex = 0;
  26406. return src.replace(commentRx, '');
  26407. };
  26408. exports.removeMapFileComments = function (src) {
  26409. mapFileCommentRx.lastIndex = 0;
  26410. return src.replace(mapFileCommentRx, '');
  26411. };
  26412. Object.defineProperty(exports, 'commentRegex', {
  26413. get: function getCommentRegex () {
  26414. commentRx.lastIndex = 0;
  26415. return commentRx;
  26416. }
  26417. });
  26418. Object.defineProperty(exports, 'mapFileCommentRegex', {
  26419. get: function getMapFileCommentRegex () {
  26420. mapFileCommentRx.lastIndex = 0;
  26421. return mapFileCommentRx;
  26422. }
  26423. });
  26424. }).call(this,require("buffer").Buffer)
  26425. },{"buffer":192,"fs":189,"path":199}],226:[function(require,module,exports){
  26426. 'use strict';
  26427. // false -> Array#indexOf
  26428. // true -> Array#includes
  26429. var $ = require('./$');
  26430. module.exports = function(IS_INCLUDES){
  26431. return function(el /*, fromIndex = 0 */){
  26432. var O = $.toObject(this)
  26433. , length = $.toLength(O.length)
  26434. , index = $.toIndex(arguments[1], length)
  26435. , value;
  26436. if(IS_INCLUDES && el != el)while(length > index){
  26437. value = O[index++];
  26438. if(value != value)return true;
  26439. } else for(;length > index; index++)if(IS_INCLUDES || index in O){
  26440. if(O[index] === el)return IS_INCLUDES || index;
  26441. } return !IS_INCLUDES && -1;
  26442. };
  26443. };
  26444. },{"./$":245}],227:[function(require,module,exports){
  26445. 'use strict';
  26446. // 0 -> Array#forEach
  26447. // 1 -> Array#map
  26448. // 2 -> Array#filter
  26449. // 3 -> Array#some
  26450. // 4 -> Array#every
  26451. // 5 -> Array#find
  26452. // 6 -> Array#findIndex
  26453. var $ = require('./$')
  26454. , ctx = require('./$.ctx');
  26455. module.exports = function(TYPE){
  26456. var IS_MAP = TYPE == 1
  26457. , IS_FILTER = TYPE == 2
  26458. , IS_SOME = TYPE == 3
  26459. , IS_EVERY = TYPE == 4
  26460. , IS_FIND_INDEX = TYPE == 6
  26461. , NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  26462. return function(callbackfn/*, that = undefined */){
  26463. var O = Object($.assertDefined(this))
  26464. , self = $.ES5Object(O)
  26465. , f = ctx(callbackfn, arguments[1], 3)
  26466. , length = $.toLength(self.length)
  26467. , index = 0
  26468. , result = IS_MAP ? Array(length) : IS_FILTER ? [] : undefined
  26469. , val, res;
  26470. for(;length > index; index++)if(NO_HOLES || index in self){
  26471. val = self[index];
  26472. res = f(val, index, O);
  26473. if(TYPE){
  26474. if(IS_MAP)result[index] = res; // map
  26475. else if(res)switch(TYPE){
  26476. case 3: return true; // some
  26477. case 5: return val; // find
  26478. case 6: return index; // findIndex
  26479. case 2: result.push(val); // filter
  26480. } else if(IS_EVERY)return false; // every
  26481. }
  26482. }
  26483. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  26484. };
  26485. };
  26486. },{"./$":245,"./$.ctx":235}],228:[function(require,module,exports){
  26487. var $ = require('./$');
  26488. function assert(condition, msg1, msg2){
  26489. if(!condition)throw TypeError(msg2 ? msg1 + msg2 : msg1);
  26490. }
  26491. assert.def = $.assertDefined;
  26492. assert.fn = function(it){
  26493. if(!$.isFunction(it))throw TypeError(it + ' is not a function!');
  26494. return it;
  26495. };
  26496. assert.obj = function(it){
  26497. if(!$.isObject(it))throw TypeError(it + ' is not an object!');
  26498. return it;
  26499. };
  26500. assert.inst = function(it, Constructor, name){
  26501. if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!");
  26502. return it;
  26503. };
  26504. module.exports = assert;
  26505. },{"./$":245}],229:[function(require,module,exports){
  26506. var $ = require('./$')
  26507. , enumKeys = require('./$.enum-keys');
  26508. // 19.1.2.1 Object.assign(target, source, ...)
  26509. /* eslint-disable no-unused-vars */
  26510. module.exports = Object.assign || function assign(target, source){
  26511. /* eslint-enable no-unused-vars */
  26512. var T = Object($.assertDefined(target))
  26513. , l = arguments.length
  26514. , i = 1;
  26515. while(l > i){
  26516. var S = $.ES5Object(arguments[i++])
  26517. , keys = enumKeys(S)
  26518. , length = keys.length
  26519. , j = 0
  26520. , key;
  26521. while(length > j)T[key = keys[j++]] = S[key];
  26522. }
  26523. return T;
  26524. };
  26525. },{"./$":245,"./$.enum-keys":237}],230:[function(require,module,exports){
  26526. var $ = require('./$')
  26527. , TAG = require('./$.wks')('toStringTag')
  26528. , toString = {}.toString;
  26529. function cof(it){
  26530. return toString.call(it).slice(8, -1);
  26531. }
  26532. cof.classof = function(it){
  26533. var O, T;
  26534. return it == undefined ? it === undefined ? 'Undefined' : 'Null'
  26535. : typeof (T = (O = Object(it))[TAG]) == 'string' ? T : cof(O);
  26536. };
  26537. cof.set = function(it, tag, stat){
  26538. if(it && !$.has(it = stat ? it : it.prototype, TAG))$.hide(it, TAG, tag);
  26539. };
  26540. module.exports = cof;
  26541. },{"./$":245,"./$.wks":256}],231:[function(require,module,exports){
  26542. 'use strict';
  26543. var $ = require('./$')
  26544. , ctx = require('./$.ctx')
  26545. , safe = require('./$.uid').safe
  26546. , assert = require('./$.assert')
  26547. , forOf = require('./$.for-of')
  26548. , step = require('./$.iter').step
  26549. , has = $.has
  26550. , set = $.set
  26551. , isObject = $.isObject
  26552. , hide = $.hide
  26553. , isFrozen = Object.isFrozen || $.core.Object.isFrozen
  26554. , ID = safe('id')
  26555. , O1 = safe('O1')
  26556. , LAST = safe('last')
  26557. , FIRST = safe('first')
  26558. , ITER = safe('iter')
  26559. , SIZE = $.DESC ? safe('size') : 'size'
  26560. , id = 0;
  26561. function fastKey(it, create){
  26562. // return primitive with prefix
  26563. if(!isObject(it))return (typeof it == 'string' ? 'S' : 'P') + it;
  26564. // can't set id to frozen object
  26565. if(isFrozen(it))return 'F';
  26566. if(!has(it, ID)){
  26567. // not necessary to add id
  26568. if(!create)return 'E';
  26569. // add missing object id
  26570. hide(it, ID, ++id);
  26571. // return object id with prefix
  26572. } return 'O' + it[ID];
  26573. }
  26574. function getEntry(that, key){
  26575. // fast case
  26576. var index = fastKey(key), entry;
  26577. if(index != 'F')return that[O1][index];
  26578. // frozen object case
  26579. for(entry = that[FIRST]; entry; entry = entry.n){
  26580. if(entry.k == key)return entry;
  26581. }
  26582. }
  26583. module.exports = {
  26584. getConstructor: function(NAME, IS_MAP, ADDER){
  26585. function C(){
  26586. var that = assert.inst(this, C, NAME)
  26587. , iterable = arguments[0];
  26588. set(that, O1, $.create(null));
  26589. set(that, SIZE, 0);
  26590. set(that, LAST, undefined);
  26591. set(that, FIRST, undefined);
  26592. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  26593. }
  26594. $.mix(C.prototype, {
  26595. // 23.1.3.1 Map.prototype.clear()
  26596. // 23.2.3.2 Set.prototype.clear()
  26597. clear: function clear(){
  26598. for(var that = this, data = that[O1], entry = that[FIRST]; entry; entry = entry.n){
  26599. entry.r = true;
  26600. if(entry.p)entry.p = entry.p.n = undefined;
  26601. delete data[entry.i];
  26602. }
  26603. that[FIRST] = that[LAST] = undefined;
  26604. that[SIZE] = 0;
  26605. },
  26606. // 23.1.3.3 Map.prototype.delete(key)
  26607. // 23.2.3.4 Set.prototype.delete(value)
  26608. 'delete': function(key){
  26609. var that = this
  26610. , entry = getEntry(that, key);
  26611. if(entry){
  26612. var next = entry.n
  26613. , prev = entry.p;
  26614. delete that[O1][entry.i];
  26615. entry.r = true;
  26616. if(prev)prev.n = next;
  26617. if(next)next.p = prev;
  26618. if(that[FIRST] == entry)that[FIRST] = next;
  26619. if(that[LAST] == entry)that[LAST] = prev;
  26620. that[SIZE]--;
  26621. } return !!entry;
  26622. },
  26623. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  26624. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  26625. forEach: function forEach(callbackfn /*, that = undefined */){
  26626. var f = ctx(callbackfn, arguments[1], 3)
  26627. , entry;
  26628. while(entry = entry ? entry.n : this[FIRST]){
  26629. f(entry.v, entry.k, this);
  26630. // revert to the last existing entry
  26631. while(entry && entry.r)entry = entry.p;
  26632. }
  26633. },
  26634. // 23.1.3.7 Map.prototype.has(key)
  26635. // 23.2.3.7 Set.prototype.has(value)
  26636. has: function has(key){
  26637. return !!getEntry(this, key);
  26638. }
  26639. });
  26640. if($.DESC)$.setDesc(C.prototype, 'size', {
  26641. get: function(){
  26642. return assert.def(this[SIZE]);
  26643. }
  26644. });
  26645. return C;
  26646. },
  26647. def: function(that, key, value){
  26648. var entry = getEntry(that, key)
  26649. , prev, index;
  26650. // change existing entry
  26651. if(entry){
  26652. entry.v = value;
  26653. // create new entry
  26654. } else {
  26655. that[LAST] = entry = {
  26656. i: index = fastKey(key, true), // <- index
  26657. k: key, // <- key
  26658. v: value, // <- value
  26659. p: prev = that[LAST], // <- previous entry
  26660. n: undefined, // <- next entry
  26661. r: false // <- removed
  26662. };
  26663. if(!that[FIRST])that[FIRST] = entry;
  26664. if(prev)prev.n = entry;
  26665. that[SIZE]++;
  26666. // add to index
  26667. if(index != 'F')that[O1][index] = entry;
  26668. } return that;
  26669. },
  26670. getEntry: getEntry,
  26671. // add .keys, .values, .entries, [@@iterator]
  26672. // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
  26673. setIter: function(C, NAME, IS_MAP){
  26674. require('./$.iter-define')(C, NAME, function(iterated, kind){
  26675. set(this, ITER, {o: iterated, k: kind});
  26676. }, function(){
  26677. var iter = this[ITER]
  26678. , kind = iter.k
  26679. , entry = iter.l;
  26680. // revert to the last existing entry
  26681. while(entry && entry.r)entry = entry.p;
  26682. // get next entry
  26683. if(!iter.o || !(iter.l = entry = entry ? entry.n : iter.o[FIRST])){
  26684. // or finish the iteration
  26685. iter.o = undefined;
  26686. return step(1);
  26687. }
  26688. // return step by kind
  26689. if(kind == 'keys' )return step(0, entry.k);
  26690. if(kind == 'values')return step(0, entry.v);
  26691. return step(0, [entry.k, entry.v]);
  26692. }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
  26693. }
  26694. };
  26695. },{"./$":245,"./$.assert":228,"./$.ctx":235,"./$.for-of":238,"./$.iter":244,"./$.iter-define":242,"./$.uid":254}],232:[function(require,module,exports){
  26696. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  26697. var $def = require('./$.def')
  26698. , forOf = require('./$.for-of');
  26699. module.exports = function(NAME){
  26700. $def($def.P, NAME, {
  26701. toJSON: function toJSON(){
  26702. var arr = [];
  26703. forOf(this, false, arr.push, arr);
  26704. return arr;
  26705. }
  26706. });
  26707. };
  26708. },{"./$.def":236,"./$.for-of":238}],233:[function(require,module,exports){
  26709. 'use strict';
  26710. var $ = require('./$')
  26711. , safe = require('./$.uid').safe
  26712. , assert = require('./$.assert')
  26713. , forOf = require('./$.for-of')
  26714. , _has = $.has
  26715. , isObject = $.isObject
  26716. , hide = $.hide
  26717. , isFrozen = Object.isFrozen || $.core.Object.isFrozen
  26718. , id = 0
  26719. , ID = safe('id')
  26720. , WEAK = safe('weak')
  26721. , LEAK = safe('leak')
  26722. , method = require('./$.array-methods')
  26723. , find = method(5)
  26724. , findIndex = method(6);
  26725. function findFrozen(store, key){
  26726. return find.call(store.array, function(it){
  26727. return it[0] === key;
  26728. });
  26729. }
  26730. // fallback for frozen keys
  26731. function leakStore(that){
  26732. return that[LEAK] || hide(that, LEAK, {
  26733. array: [],
  26734. get: function(key){
  26735. var entry = findFrozen(this, key);
  26736. if(entry)return entry[1];
  26737. },
  26738. has: function(key){
  26739. return !!findFrozen(this, key);
  26740. },
  26741. set: function(key, value){
  26742. var entry = findFrozen(this, key);
  26743. if(entry)entry[1] = value;
  26744. else this.array.push([key, value]);
  26745. },
  26746. 'delete': function(key){
  26747. var index = findIndex.call(this.array, function(it){
  26748. return it[0] === key;
  26749. });
  26750. if(~index)this.array.splice(index, 1);
  26751. return !!~index;
  26752. }
  26753. })[LEAK];
  26754. }
  26755. module.exports = {
  26756. getConstructor: function(NAME, IS_MAP, ADDER){
  26757. function C(){
  26758. $.set(assert.inst(this, C, NAME), ID, id++);
  26759. var iterable = arguments[0];
  26760. if(iterable != undefined)forOf(iterable, IS_MAP, this[ADDER], this);
  26761. }
  26762. $.mix(C.prototype, {
  26763. // 23.3.3.2 WeakMap.prototype.delete(key)
  26764. // 23.4.3.3 WeakSet.prototype.delete(value)
  26765. 'delete': function(key){
  26766. if(!isObject(key))return false;
  26767. if(isFrozen(key))return leakStore(this)['delete'](key);
  26768. return _has(key, WEAK) && _has(key[WEAK], this[ID]) && delete key[WEAK][this[ID]];
  26769. },
  26770. // 23.3.3.4 WeakMap.prototype.has(key)
  26771. // 23.4.3.4 WeakSet.prototype.has(value)
  26772. has: function has(key){
  26773. if(!isObject(key))return false;
  26774. if(isFrozen(key))return leakStore(this).has(key);
  26775. return _has(key, WEAK) && _has(key[WEAK], this[ID]);
  26776. }
  26777. });
  26778. return C;
  26779. },
  26780. def: function(that, key, value){
  26781. if(isFrozen(assert.obj(key))){
  26782. leakStore(that).set(key, value);
  26783. } else {
  26784. _has(key, WEAK) || hide(key, WEAK, {});
  26785. key[WEAK][that[ID]] = value;
  26786. } return that;
  26787. },
  26788. leakStore: leakStore,
  26789. WEAK: WEAK,
  26790. ID: ID
  26791. };
  26792. },{"./$":245,"./$.array-methods":227,"./$.assert":228,"./$.for-of":238,"./$.uid":254}],234:[function(require,module,exports){
  26793. 'use strict';
  26794. var $ = require('./$')
  26795. , $def = require('./$.def')
  26796. , BUGGY = require('./$.iter').BUGGY
  26797. , forOf = require('./$.for-of')
  26798. , species = require('./$.species')
  26799. , assertInstance = require('./$.assert').inst;
  26800. module.exports = function(NAME, methods, common, IS_MAP, IS_WEAK){
  26801. var Base = $.g[NAME]
  26802. , C = Base
  26803. , ADDER = IS_MAP ? 'set' : 'add'
  26804. , proto = C && C.prototype
  26805. , O = {};
  26806. function fixMethod(KEY, CHAIN){
  26807. var method = proto[KEY];
  26808. if($.FW)proto[KEY] = function(a, b){
  26809. var result = method.call(this, a === 0 ? 0 : a, b);
  26810. return CHAIN ? this : result;
  26811. };
  26812. }
  26813. if(!$.isFunction(C) || !(IS_WEAK || !BUGGY && proto.forEach && proto.entries)){
  26814. // create collection constructor
  26815. C = common.getConstructor(NAME, IS_MAP, ADDER);
  26816. $.mix(C.prototype, methods);
  26817. } else {
  26818. var inst = new C
  26819. , chain = inst[ADDER](IS_WEAK ? {} : -0, 1)
  26820. , buggyZero;
  26821. // wrap for init collections from iterable
  26822. if(!require('./$.iter-detect')(function(iter){ new C(iter); })){ // eslint-disable-line no-new
  26823. C = function(){
  26824. assertInstance(this, C, NAME);
  26825. var that = new Base
  26826. , iterable = arguments[0];
  26827. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  26828. return that;
  26829. };
  26830. C.prototype = proto;
  26831. if($.FW)proto.constructor = C;
  26832. }
  26833. IS_WEAK || inst.forEach(function(val, key){
  26834. buggyZero = 1 / key === -Infinity;
  26835. });
  26836. // fix converting -0 key to +0
  26837. if(buggyZero){
  26838. fixMethod('delete');
  26839. fixMethod('has');
  26840. IS_MAP && fixMethod('get');
  26841. }
  26842. // + fix .add & .set for chaining
  26843. if(buggyZero || chain !== inst)fixMethod(ADDER, true);
  26844. }
  26845. require('./$.cof').set(C, NAME);
  26846. O[NAME] = C;
  26847. $def($def.G + $def.W + $def.F * (C != Base), O);
  26848. species(C);
  26849. species($.core[NAME]); // for wrapper
  26850. if(!IS_WEAK)common.setIter(C, NAME, IS_MAP);
  26851. return C;
  26852. };
  26853. },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.for-of":238,"./$.iter":244,"./$.iter-detect":243,"./$.species":251}],235:[function(require,module,exports){
  26854. // Optional / simple context binding
  26855. var assertFunction = require('./$.assert').fn;
  26856. module.exports = function(fn, that, length){
  26857. assertFunction(fn);
  26858. if(~length && that === undefined)return fn;
  26859. switch(length){
  26860. case 1: return function(a){
  26861. return fn.call(that, a);
  26862. };
  26863. case 2: return function(a, b){
  26864. return fn.call(that, a, b);
  26865. };
  26866. case 3: return function(a, b, c){
  26867. return fn.call(that, a, b, c);
  26868. };
  26869. } return function(/* ...args */){
  26870. return fn.apply(that, arguments);
  26871. };
  26872. };
  26873. },{"./$.assert":228}],236:[function(require,module,exports){
  26874. var $ = require('./$')
  26875. , global = $.g
  26876. , core = $.core
  26877. , isFunction = $.isFunction;
  26878. function ctx(fn, that){
  26879. return function(){
  26880. return fn.apply(that, arguments);
  26881. };
  26882. }
  26883. global.core = core;
  26884. // type bitmap
  26885. $def.F = 1; // forced
  26886. $def.G = 2; // global
  26887. $def.S = 4; // static
  26888. $def.P = 8; // proto
  26889. $def.B = 16; // bind
  26890. $def.W = 32; // wrap
  26891. function $def(type, name, source){
  26892. var key, own, out, exp
  26893. , isGlobal = type & $def.G
  26894. , target = isGlobal ? global : type & $def.S
  26895. ? global[name] : (global[name] || {}).prototype
  26896. , exports = isGlobal ? core : core[name] || (core[name] = {});
  26897. if(isGlobal)source = name;
  26898. for(key in source){
  26899. // contains in native
  26900. own = !(type & $def.F) && target && key in target;
  26901. // export native or passed
  26902. out = (own ? target : source)[key];
  26903. // bind timers to global for call from export context
  26904. if(type & $def.B && own)exp = ctx(out, global);
  26905. else exp = type & $def.P && isFunction(out) ? ctx(Function.call, out) : out;
  26906. // extend global
  26907. if(target && !own){
  26908. if(isGlobal)target[key] = out;
  26909. else delete target[key] && $.hide(target, key, out);
  26910. }
  26911. // export
  26912. if(exports[key] != out)$.hide(exports, key, exp);
  26913. }
  26914. }
  26915. module.exports = $def;
  26916. },{"./$":245}],237:[function(require,module,exports){
  26917. var $ = require('./$');
  26918. module.exports = function(it){
  26919. var keys = $.getKeys(it)
  26920. , getDesc = $.getDesc
  26921. , getSymbols = $.getSymbols;
  26922. if(getSymbols)$.each.call(getSymbols(it), function(key){
  26923. if(getDesc(it, key).enumerable)keys.push(key);
  26924. });
  26925. return keys;
  26926. };
  26927. },{"./$":245}],238:[function(require,module,exports){
  26928. var ctx = require('./$.ctx')
  26929. , get = require('./$.iter').get
  26930. , call = require('./$.iter-call');
  26931. module.exports = function(iterable, entries, fn, that){
  26932. var iterator = get(iterable)
  26933. , f = ctx(fn, that, entries ? 2 : 1)
  26934. , step;
  26935. while(!(step = iterator.next()).done){
  26936. if(call(iterator, f, step.value, entries) === false){
  26937. return call.close(iterator);
  26938. }
  26939. }
  26940. };
  26941. },{"./$.ctx":235,"./$.iter":244,"./$.iter-call":241}],239:[function(require,module,exports){
  26942. module.exports = function($){
  26943. $.FW = true;
  26944. $.path = $.g;
  26945. return $;
  26946. };
  26947. },{}],240:[function(require,module,exports){
  26948. // Fast apply
  26949. // http://jsperf.lnkit.com/fast-apply/5
  26950. module.exports = function(fn, args, that){
  26951. var un = that === undefined;
  26952. switch(args.length){
  26953. case 0: return un ? fn()
  26954. : fn.call(that);
  26955. case 1: return un ? fn(args[0])
  26956. : fn.call(that, args[0]);
  26957. case 2: return un ? fn(args[0], args[1])
  26958. : fn.call(that, args[0], args[1]);
  26959. case 3: return un ? fn(args[0], args[1], args[2])
  26960. : fn.call(that, args[0], args[1], args[2]);
  26961. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  26962. : fn.call(that, args[0], args[1], args[2], args[3]);
  26963. case 5: return un ? fn(args[0], args[1], args[2], args[3], args[4])
  26964. : fn.call(that, args[0], args[1], args[2], args[3], args[4]);
  26965. } return fn.apply(that, args);
  26966. };
  26967. },{}],241:[function(require,module,exports){
  26968. var assertObject = require('./$.assert').obj;
  26969. function close(iterator){
  26970. var ret = iterator['return'];
  26971. if(ret !== undefined)assertObject(ret.call(iterator));
  26972. }
  26973. function call(iterator, fn, value, entries){
  26974. try {
  26975. return entries ? fn(assertObject(value)[0], value[1]) : fn(value);
  26976. } catch(e){
  26977. close(iterator);
  26978. throw e;
  26979. }
  26980. }
  26981. call.close = close;
  26982. module.exports = call;
  26983. },{"./$.assert":228}],242:[function(require,module,exports){
  26984. var $def = require('./$.def')
  26985. , $ = require('./$')
  26986. , cof = require('./$.cof')
  26987. , $iter = require('./$.iter')
  26988. , SYMBOL_ITERATOR = require('./$.wks')('iterator')
  26989. , FF_ITERATOR = '@@iterator'
  26990. , VALUES = 'values'
  26991. , Iterators = $iter.Iterators;
  26992. module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){
  26993. $iter.create(Constructor, NAME, next);
  26994. function createMethod(kind){
  26995. return function(){
  26996. return new Constructor(this, kind);
  26997. };
  26998. }
  26999. var TAG = NAME + ' Iterator'
  27000. , proto = Base.prototype
  27001. , _native = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
  27002. , _default = _native || createMethod(DEFAULT)
  27003. , methods, key;
  27004. // Fix native
  27005. if(_native){
  27006. var IteratorPrototype = $.getProto(_default.call(new Base));
  27007. // Set @@toStringTag to native iterators
  27008. cof.set(IteratorPrototype, TAG, true);
  27009. // FF fix
  27010. if($.FW && $.has(proto, FF_ITERATOR))$iter.set(IteratorPrototype, $.that);
  27011. }
  27012. // Define iterator
  27013. if($.FW)$iter.set(proto, _default);
  27014. // Plug for library
  27015. Iterators[NAME] = _default;
  27016. Iterators[TAG] = $.that;
  27017. if(DEFAULT){
  27018. methods = {
  27019. keys: IS_SET ? _default : createMethod('keys'),
  27020. values: DEFAULT == VALUES ? _default : createMethod(VALUES),
  27021. entries: DEFAULT != VALUES ? _default : createMethod('entries')
  27022. };
  27023. if(FORCE)for(key in methods){
  27024. if(!(key in proto))$.hide(proto, key, methods[key]);
  27025. } else $def($def.P + $def.F * $iter.BUGGY, NAME, methods);
  27026. }
  27027. };
  27028. },{"./$":245,"./$.cof":230,"./$.def":236,"./$.iter":244,"./$.wks":256}],243:[function(require,module,exports){
  27029. var SYMBOL_ITERATOR = require('./$.wks')('iterator')
  27030. , SAFE_CLOSING = false;
  27031. try {
  27032. var riter = [7][SYMBOL_ITERATOR]();
  27033. riter['return'] = function(){ SAFE_CLOSING = true; };
  27034. Array.from(riter, function(){ throw 2; });
  27035. } catch(e){ /* empty */ }
  27036. module.exports = function(exec){
  27037. if(!SAFE_CLOSING)return false;
  27038. var safe = false;
  27039. try {
  27040. var arr = [7]
  27041. , iter = arr[SYMBOL_ITERATOR]();
  27042. iter.next = function(){ safe = true; };
  27043. arr[SYMBOL_ITERATOR] = function(){ return iter; };
  27044. exec(arr);
  27045. } catch(e){ /* empty */ }
  27046. return safe;
  27047. };
  27048. },{"./$.wks":256}],244:[function(require,module,exports){
  27049. 'use strict';
  27050. var $ = require('./$')
  27051. , cof = require('./$.cof')
  27052. , assertObject = require('./$.assert').obj
  27053. , SYMBOL_ITERATOR = require('./$.wks')('iterator')
  27054. , FF_ITERATOR = '@@iterator'
  27055. , Iterators = {}
  27056. , IteratorPrototype = {};
  27057. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  27058. setIterator(IteratorPrototype, $.that);
  27059. function setIterator(O, value){
  27060. $.hide(O, SYMBOL_ITERATOR, value);
  27061. // Add iterator for FF iterator protocol
  27062. if(FF_ITERATOR in [])$.hide(O, FF_ITERATOR, value);
  27063. }
  27064. module.exports = {
  27065. // Safari has buggy iterators w/o `next`
  27066. BUGGY: 'keys' in [] && !('next' in [].keys()),
  27067. Iterators: Iterators,
  27068. step: function(done, value){
  27069. return {value: value, done: !!done};
  27070. },
  27071. is: function(it){
  27072. var O = Object(it)
  27073. , Symbol = $.g.Symbol
  27074. , SYM = Symbol && Symbol.iterator || FF_ITERATOR;
  27075. return SYM in O || SYMBOL_ITERATOR in O || $.has(Iterators, cof.classof(O));
  27076. },
  27077. get: function(it){
  27078. var Symbol = $.g.Symbol
  27079. , ext = it[Symbol && Symbol.iterator || FF_ITERATOR]
  27080. , getIter = ext || it[SYMBOL_ITERATOR] || Iterators[cof.classof(it)];
  27081. return assertObject(getIter.call(it));
  27082. },
  27083. set: setIterator,
  27084. create: function(Constructor, NAME, next, proto){
  27085. Constructor.prototype = $.create(proto || IteratorPrototype, {next: $.desc(1, next)});
  27086. cof.set(Constructor, NAME + ' Iterator');
  27087. }
  27088. };
  27089. },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.wks":256}],245:[function(require,module,exports){
  27090. 'use strict';
  27091. var global = typeof self != 'undefined' ? self : Function('return this')()
  27092. , core = {}
  27093. , defineProperty = Object.defineProperty
  27094. , hasOwnProperty = {}.hasOwnProperty
  27095. , ceil = Math.ceil
  27096. , floor = Math.floor
  27097. , max = Math.max
  27098. , min = Math.min;
  27099. // The engine works fine with descriptors? Thank's IE8 for his funny defineProperty.
  27100. var DESC = !!function(){
  27101. try {
  27102. return defineProperty({}, 'a', {get: function(){ return 2; }}).a == 2;
  27103. } catch(e){ /* empty */ }
  27104. }();
  27105. var hide = createDefiner(1);
  27106. // 7.1.4 ToInteger
  27107. function toInteger(it){
  27108. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  27109. }
  27110. function desc(bitmap, value){
  27111. return {
  27112. enumerable : !(bitmap & 1),
  27113. configurable: !(bitmap & 2),
  27114. writable : !(bitmap & 4),
  27115. value : value
  27116. };
  27117. }
  27118. function simpleSet(object, key, value){
  27119. object[key] = value;
  27120. return object;
  27121. }
  27122. function createDefiner(bitmap){
  27123. return DESC ? function(object, key, value){
  27124. return $.setDesc(object, key, desc(bitmap, value));
  27125. } : simpleSet;
  27126. }
  27127. function isObject(it){
  27128. return it !== null && (typeof it == 'object' || typeof it == 'function');
  27129. }
  27130. function isFunction(it){
  27131. return typeof it == 'function';
  27132. }
  27133. function assertDefined(it){
  27134. if(it == undefined)throw TypeError("Can't call method on " + it);
  27135. return it;
  27136. }
  27137. var $ = module.exports = require('./$.fw')({
  27138. g: global,
  27139. core: core,
  27140. html: global.document && document.documentElement,
  27141. // http://jsperf.com/core-js-isobject
  27142. isObject: isObject,
  27143. isFunction: isFunction,
  27144. it: function(it){
  27145. return it;
  27146. },
  27147. that: function(){
  27148. return this;
  27149. },
  27150. // 7.1.4 ToInteger
  27151. toInteger: toInteger,
  27152. // 7.1.15 ToLength
  27153. toLength: function(it){
  27154. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  27155. },
  27156. toIndex: function(index, length){
  27157. index = toInteger(index);
  27158. return index < 0 ? max(index + length, 0) : min(index, length);
  27159. },
  27160. has: function(it, key){
  27161. return hasOwnProperty.call(it, key);
  27162. },
  27163. create: Object.create,
  27164. getProto: Object.getPrototypeOf,
  27165. DESC: DESC,
  27166. desc: desc,
  27167. getDesc: Object.getOwnPropertyDescriptor,
  27168. setDesc: defineProperty,
  27169. setDescs: Object.defineProperties,
  27170. getKeys: Object.keys,
  27171. getNames: Object.getOwnPropertyNames,
  27172. getSymbols: Object.getOwnPropertySymbols,
  27173. assertDefined: assertDefined,
  27174. // Dummy, fix for not array-like ES3 string in es5 module
  27175. ES5Object: Object,
  27176. toObject: function(it){
  27177. return $.ES5Object(assertDefined(it));
  27178. },
  27179. hide: hide,
  27180. def: createDefiner(0),
  27181. set: global.Symbol ? simpleSet : hide,
  27182. mix: function(target, src){
  27183. for(var key in src)hide(target, key, src[key]);
  27184. return target;
  27185. },
  27186. each: [].forEach
  27187. });
  27188. /* eslint-disable no-undef */
  27189. if(typeof __e != 'undefined')__e = core;
  27190. if(typeof __g != 'undefined')__g = global;
  27191. },{"./$.fw":239}],246:[function(require,module,exports){
  27192. var $ = require('./$');
  27193. module.exports = function(object, el){
  27194. var O = $.toObject(object)
  27195. , keys = $.getKeys(O)
  27196. , length = keys.length
  27197. , index = 0
  27198. , key;
  27199. while(length > index)if(O[key = keys[index++]] === el)return key;
  27200. };
  27201. },{"./$":245}],247:[function(require,module,exports){
  27202. var $ = require('./$')
  27203. , assertObject = require('./$.assert').obj;
  27204. module.exports = function ownKeys(it){
  27205. assertObject(it);
  27206. var keys = $.getNames(it)
  27207. , getSymbols = $.getSymbols;
  27208. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  27209. };
  27210. },{"./$":245,"./$.assert":228}],248:[function(require,module,exports){
  27211. 'use strict';
  27212. var $ = require('./$')
  27213. , invoke = require('./$.invoke')
  27214. , assertFunction = require('./$.assert').fn;
  27215. module.exports = function(/* ...pargs */){
  27216. var fn = assertFunction(this)
  27217. , length = arguments.length
  27218. , pargs = Array(length)
  27219. , i = 0
  27220. , _ = $.path._
  27221. , holder = false;
  27222. while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
  27223. return function(/* ...args */){
  27224. var that = this
  27225. , _length = arguments.length
  27226. , j = 0, k = 0, args;
  27227. if(!holder && !_length)return invoke(fn, pargs, that);
  27228. args = pargs.slice();
  27229. if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
  27230. while(_length > k)args.push(arguments[k++]);
  27231. return invoke(fn, args, that);
  27232. };
  27233. };
  27234. },{"./$":245,"./$.assert":228,"./$.invoke":240}],249:[function(require,module,exports){
  27235. 'use strict';
  27236. module.exports = function(regExp, replace, isStatic){
  27237. var replacer = replace === Object(replace) ? function(part){
  27238. return replace[part];
  27239. } : replace;
  27240. return function(it){
  27241. return String(isStatic ? it : this).replace(regExp, replacer);
  27242. };
  27243. };
  27244. },{}],250:[function(require,module,exports){
  27245. // Works with __proto__ only. Old v8 can't work with null proto objects.
  27246. /* eslint-disable no-proto */
  27247. var $ = require('./$')
  27248. , assert = require('./$.assert');
  27249. function check(O, proto){
  27250. assert.obj(O);
  27251. assert(proto === null || $.isObject(proto), proto, ": can't set as prototype!");
  27252. }
  27253. module.exports = {
  27254. set: Object.setPrototypeOf || ('__proto__' in {} // eslint-disable-line
  27255. ? function(buggy, set){
  27256. try {
  27257. set = require('./$.ctx')(Function.call, $.getDesc(Object.prototype, '__proto__').set, 2);
  27258. set({}, []);
  27259. } catch(e){ buggy = true; }
  27260. return function setPrototypeOf(O, proto){
  27261. check(O, proto);
  27262. if(buggy)O.__proto__ = proto;
  27263. else set(O, proto);
  27264. return O;
  27265. };
  27266. }()
  27267. : undefined),
  27268. check: check
  27269. };
  27270. },{"./$":245,"./$.assert":228,"./$.ctx":235}],251:[function(require,module,exports){
  27271. var $ = require('./$')
  27272. , SPECIES = require('./$.wks')('species');
  27273. module.exports = function(C){
  27274. if($.DESC && !(SPECIES in C))$.setDesc(C, SPECIES, {
  27275. configurable: true,
  27276. get: $.that
  27277. });
  27278. };
  27279. },{"./$":245,"./$.wks":256}],252:[function(require,module,exports){
  27280. 'use strict';
  27281. // true -> String#at
  27282. // false -> String#codePointAt
  27283. var $ = require('./$');
  27284. module.exports = function(TO_STRING){
  27285. return function(pos){
  27286. var s = String($.assertDefined(this))
  27287. , i = $.toInteger(pos)
  27288. , l = s.length
  27289. , a, b;
  27290. if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
  27291. a = s.charCodeAt(i);
  27292. return a < 0xd800 || a > 0xdbff || i + 1 === l
  27293. || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  27294. ? TO_STRING ? s.charAt(i) : a
  27295. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  27296. };
  27297. };
  27298. },{"./$":245}],253:[function(require,module,exports){
  27299. 'use strict';
  27300. var $ = require('./$')
  27301. , ctx = require('./$.ctx')
  27302. , cof = require('./$.cof')
  27303. , invoke = require('./$.invoke')
  27304. , global = $.g
  27305. , isFunction = $.isFunction
  27306. , html = $.html
  27307. , document = global.document
  27308. , process = global.process
  27309. , setTask = global.setImmediate
  27310. , clearTask = global.clearImmediate
  27311. , postMessage = global.postMessage
  27312. , addEventListener = global.addEventListener
  27313. , MessageChannel = global.MessageChannel
  27314. , counter = 0
  27315. , queue = {}
  27316. , ONREADYSTATECHANGE = 'onreadystatechange'
  27317. , defer, channel, port;
  27318. function run(){
  27319. var id = +this;
  27320. if($.has(queue, id)){
  27321. var fn = queue[id];
  27322. delete queue[id];
  27323. fn();
  27324. }
  27325. }
  27326. function listner(event){
  27327. run.call(event.data);
  27328. }
  27329. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  27330. if(!isFunction(setTask) || !isFunction(clearTask)){
  27331. setTask = function(fn){
  27332. var args = [], i = 1;
  27333. while(arguments.length > i)args.push(arguments[i++]);
  27334. queue[++counter] = function(){
  27335. invoke(isFunction(fn) ? fn : Function(fn), args);
  27336. };
  27337. defer(counter);
  27338. return counter;
  27339. };
  27340. clearTask = function(id){
  27341. delete queue[id];
  27342. };
  27343. // Node.js 0.8-
  27344. if(cof(process) == 'process'){
  27345. defer = function(id){
  27346. process.nextTick(ctx(run, id, 1));
  27347. };
  27348. // Modern browsers, skip implementation for WebWorkers
  27349. // IE8 has postMessage, but it's sync & typeof its postMessage is object
  27350. } else if(addEventListener && isFunction(postMessage) && !global.importScripts){
  27351. defer = function(id){
  27352. postMessage(id, '*');
  27353. };
  27354. addEventListener('message', listner, false);
  27355. // WebWorkers
  27356. } else if(isFunction(MessageChannel)){
  27357. channel = new MessageChannel;
  27358. port = channel.port2;
  27359. channel.port1.onmessage = listner;
  27360. defer = ctx(port.postMessage, port, 1);
  27361. // IE8-
  27362. } else if(document && ONREADYSTATECHANGE in document.createElement('script')){
  27363. defer = function(id){
  27364. html.appendChild(document.createElement('script'))[ONREADYSTATECHANGE] = function(){
  27365. html.removeChild(this);
  27366. run.call(id);
  27367. };
  27368. };
  27369. // Rest old browsers
  27370. } else {
  27371. defer = function(id){
  27372. setTimeout(ctx(run, id, 1), 0);
  27373. };
  27374. }
  27375. }
  27376. module.exports = {
  27377. set: setTask,
  27378. clear: clearTask
  27379. };
  27380. },{"./$":245,"./$.cof":230,"./$.ctx":235,"./$.invoke":240}],254:[function(require,module,exports){
  27381. var sid = 0;
  27382. function uid(key){
  27383. return 'Symbol(' + key + ')_' + (++sid + Math.random()).toString(36);
  27384. }
  27385. uid.safe = require('./$').g.Symbol || uid;
  27386. module.exports = uid;
  27387. },{"./$":245}],255:[function(require,module,exports){
  27388. // 22.1.3.31 Array.prototype[@@unscopables]
  27389. var $ = require('./$')
  27390. , UNSCOPABLES = require('./$.wks')('unscopables');
  27391. if($.FW && !(UNSCOPABLES in []))$.hide(Array.prototype, UNSCOPABLES, {});
  27392. module.exports = function(key){
  27393. if($.FW)[][UNSCOPABLES][key] = true;
  27394. };
  27395. },{"./$":245,"./$.wks":256}],256:[function(require,module,exports){
  27396. var global = require('./$').g
  27397. , store = {};
  27398. module.exports = function(name){
  27399. return store[name] || (store[name] =
  27400. global.Symbol && global.Symbol[name] || require('./$.uid').safe('Symbol.' + name));
  27401. };
  27402. },{"./$":245,"./$.uid":254}],257:[function(require,module,exports){
  27403. var $ = require('./$')
  27404. , cof = require('./$.cof')
  27405. , $def = require('./$.def')
  27406. , invoke = require('./$.invoke')
  27407. , arrayMethod = require('./$.array-methods')
  27408. , IE_PROTO = require('./$.uid').safe('__proto__')
  27409. , assert = require('./$.assert')
  27410. , assertObject = assert.obj
  27411. , ObjectProto = Object.prototype
  27412. , A = []
  27413. , slice = A.slice
  27414. , indexOf = A.indexOf
  27415. , classof = cof.classof
  27416. , has = $.has
  27417. , defineProperty = $.setDesc
  27418. , getOwnDescriptor = $.getDesc
  27419. , defineProperties = $.setDescs
  27420. , isFunction = $.isFunction
  27421. , toObject = $.toObject
  27422. , toLength = $.toLength
  27423. , IE8_DOM_DEFINE = false;
  27424. if(!$.DESC){
  27425. try {
  27426. IE8_DOM_DEFINE = defineProperty(document.createElement('div'), 'x',
  27427. {get: function(){ return 8; }}
  27428. ).x == 8;
  27429. } catch(e){ /* empty */ }
  27430. $.setDesc = function(O, P, Attributes){
  27431. if(IE8_DOM_DEFINE)try {
  27432. return defineProperty(O, P, Attributes);
  27433. } catch(e){ /* empty */ }
  27434. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  27435. if('value' in Attributes)assertObject(O)[P] = Attributes.value;
  27436. return O;
  27437. };
  27438. $.getDesc = function(O, P){
  27439. if(IE8_DOM_DEFINE)try {
  27440. return getOwnDescriptor(O, P);
  27441. } catch(e){ /* empty */ }
  27442. if(has(O, P))return $.desc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]);
  27443. };
  27444. $.setDescs = defineProperties = function(O, Properties){
  27445. assertObject(O);
  27446. var keys = $.getKeys(Properties)
  27447. , length = keys.length
  27448. , i = 0
  27449. , P;
  27450. while(length > i)$.setDesc(O, P = keys[i++], Properties[P]);
  27451. return O;
  27452. };
  27453. }
  27454. $def($def.S + $def.F * !$.DESC, 'Object', {
  27455. // 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P)
  27456. getOwnPropertyDescriptor: $.getDesc,
  27457. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  27458. defineProperty: $.setDesc,
  27459. // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
  27460. defineProperties: defineProperties
  27461. });
  27462. // IE 8- don't enum bug keys
  27463. var keys1 = ('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' +
  27464. 'toLocaleString,toString,valueOf').split(',')
  27465. // Additional keys for getOwnPropertyNames
  27466. , keys2 = keys1.concat('length', 'prototype')
  27467. , keysLen1 = keys1.length;
  27468. // Create object with `null` prototype: use iframe Object with cleared prototype
  27469. var createDict = function(){
  27470. // Thrash, waste and sodomy: IE GC bug
  27471. var iframe = document.createElement('iframe')
  27472. , i = keysLen1
  27473. , gt = '>'
  27474. , iframeDocument;
  27475. iframe.style.display = 'none';
  27476. $.html.appendChild(iframe);
  27477. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  27478. // createDict = iframe.contentWindow.Object;
  27479. // html.removeChild(iframe);
  27480. iframeDocument = iframe.contentWindow.document;
  27481. iframeDocument.open();
  27482. iframeDocument.write('<script>document.F=Object</script' + gt);
  27483. iframeDocument.close();
  27484. createDict = iframeDocument.F;
  27485. while(i--)delete createDict.prototype[keys1[i]];
  27486. return createDict();
  27487. };
  27488. function createGetKeys(names, length){
  27489. return function(object){
  27490. var O = toObject(object)
  27491. , i = 0
  27492. , result = []
  27493. , key;
  27494. for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
  27495. // Don't enum bug & hidden keys
  27496. while(length > i)if(has(O, key = names[i++])){
  27497. ~indexOf.call(result, key) || result.push(key);
  27498. }
  27499. return result;
  27500. };
  27501. }
  27502. function isPrimitive(it){ return !$.isObject(it); }
  27503. function Empty(){}
  27504. $def($def.S, 'Object', {
  27505. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  27506. getPrototypeOf: $.getProto = $.getProto || function(O){
  27507. O = Object(assert.def(O));
  27508. if(has(O, IE_PROTO))return O[IE_PROTO];
  27509. if(isFunction(O.constructor) && O instanceof O.constructor){
  27510. return O.constructor.prototype;
  27511. } return O instanceof Object ? ObjectProto : null;
  27512. },
  27513. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  27514. getOwnPropertyNames: $.getNames = $.getNames || createGetKeys(keys2, keys2.length, true),
  27515. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  27516. create: $.create = $.create || function(O, /*?*/Properties){
  27517. var result;
  27518. if(O !== null){
  27519. Empty.prototype = assertObject(O);
  27520. result = new Empty();
  27521. Empty.prototype = null;
  27522. // add "__proto__" for Object.getPrototypeOf shim
  27523. result[IE_PROTO] = O;
  27524. } else result = createDict();
  27525. return Properties === undefined ? result : defineProperties(result, Properties);
  27526. },
  27527. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  27528. keys: $.getKeys = $.getKeys || createGetKeys(keys1, keysLen1, false),
  27529. // 19.1.2.17 / 15.2.3.8 Object.seal(O)
  27530. seal: $.it, // <- cap
  27531. // 19.1.2.5 / 15.2.3.9 Object.freeze(O)
  27532. freeze: $.it, // <- cap
  27533. // 19.1.2.15 / 15.2.3.10 Object.preventExtensions(O)
  27534. preventExtensions: $.it, // <- cap
  27535. // 19.1.2.13 / 15.2.3.11 Object.isSealed(O)
  27536. isSealed: isPrimitive, // <- cap
  27537. // 19.1.2.12 / 15.2.3.12 Object.isFrozen(O)
  27538. isFrozen: isPrimitive, // <- cap
  27539. // 19.1.2.11 / 15.2.3.13 Object.isExtensible(O)
  27540. isExtensible: $.isObject // <- cap
  27541. });
  27542. // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
  27543. $def($def.P, 'Function', {
  27544. bind: function(that /*, args... */){
  27545. var fn = assert.fn(this)
  27546. , partArgs = slice.call(arguments, 1);
  27547. function bound(/* args... */){
  27548. var args = partArgs.concat(slice.call(arguments));
  27549. return invoke(fn, args, this instanceof bound ? $.create(fn.prototype) : that);
  27550. }
  27551. if(fn.prototype)bound.prototype = fn.prototype;
  27552. return bound;
  27553. }
  27554. });
  27555. // Fix for not array-like ES3 string
  27556. function arrayMethodFix(fn){
  27557. return function(){
  27558. return fn.apply($.ES5Object(this), arguments);
  27559. };
  27560. }
  27561. if(!(0 in Object('z') && 'z'[0] == 'z')){
  27562. $.ES5Object = function(it){
  27563. return cof(it) == 'String' ? it.split('') : Object(it);
  27564. };
  27565. }
  27566. $def($def.P + $def.F * ($.ES5Object != Object), 'Array', {
  27567. slice: arrayMethodFix(slice),
  27568. join: arrayMethodFix(A.join)
  27569. });
  27570. // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
  27571. $def($def.S, 'Array', {
  27572. isArray: function(arg){
  27573. return cof(arg) == 'Array';
  27574. }
  27575. });
  27576. function createArrayReduce(isRight){
  27577. return function(callbackfn, memo){
  27578. assert.fn(callbackfn);
  27579. var O = toObject(this)
  27580. , length = toLength(O.length)
  27581. , index = isRight ? length - 1 : 0
  27582. , i = isRight ? -1 : 1;
  27583. if(arguments.length < 2)for(;;){
  27584. if(index in O){
  27585. memo = O[index];
  27586. index += i;
  27587. break;
  27588. }
  27589. index += i;
  27590. assert(isRight ? index >= 0 : length > index, 'Reduce of empty array with no initial value');
  27591. }
  27592. for(;isRight ? index >= 0 : length > index; index += i)if(index in O){
  27593. memo = callbackfn(memo, O[index], index, this);
  27594. }
  27595. return memo;
  27596. };
  27597. }
  27598. $def($def.P, 'Array', {
  27599. // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
  27600. forEach: $.each = $.each || arrayMethod(0),
  27601. // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
  27602. map: arrayMethod(1),
  27603. // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
  27604. filter: arrayMethod(2),
  27605. // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
  27606. some: arrayMethod(3),
  27607. // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
  27608. every: arrayMethod(4),
  27609. // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
  27610. reduce: createArrayReduce(false),
  27611. // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
  27612. reduceRight: createArrayReduce(true),
  27613. // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
  27614. indexOf: indexOf = indexOf || require('./$.array-includes')(false),
  27615. // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
  27616. lastIndexOf: function(el, fromIndex /* = @[*-1] */){
  27617. var O = toObject(this)
  27618. , length = toLength(O.length)
  27619. , index = length - 1;
  27620. if(arguments.length > 1)index = Math.min(index, $.toInteger(fromIndex));
  27621. if(index < 0)index = toLength(length + index);
  27622. for(;index >= 0; index--)if(index in O)if(O[index] === el)return index;
  27623. return -1;
  27624. }
  27625. });
  27626. // 21.1.3.25 / 15.5.4.20 String.prototype.trim()
  27627. $def($def.P, 'String', {trim: require('./$.replacer')(/^\s*([\s\S]*\S)?\s*$/, '$1')});
  27628. // 20.3.3.1 / 15.9.4.4 Date.now()
  27629. $def($def.S, 'Date', {now: function(){
  27630. return +new Date;
  27631. }});
  27632. function lz(num){
  27633. return num > 9 ? num : '0' + num;
  27634. }
  27635. // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
  27636. // PhantomJS and old webkit had a broken Date implementation.
  27637. var date = new Date(-5e13 - 1)
  27638. , brokenDate = !(date.toISOString && date.toISOString() == '0385-07-25T07:06:39.999Z');
  27639. $def($def.P + $def.F * brokenDate, 'Date', {toISOString: function(){
  27640. if(!isFinite(this))throw RangeError('Invalid time value');
  27641. var d = this
  27642. , y = d.getUTCFullYear()
  27643. , m = d.getUTCMilliseconds()
  27644. , s = y < 0 ? '-' : y > 9999 ? '+' : '';
  27645. return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
  27646. '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
  27647. 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
  27648. ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
  27649. }});
  27650. if(classof(function(){ return arguments; }()) == 'Object')cof.classof = function(it){
  27651. var tag = classof(it);
  27652. return tag == 'Object' && isFunction(it.callee) ? 'Arguments' : tag;
  27653. };
  27654. },{"./$":245,"./$.array-includes":226,"./$.array-methods":227,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.invoke":240,"./$.replacer":249,"./$.uid":254}],258:[function(require,module,exports){
  27655. 'use strict';
  27656. var $ = require('./$')
  27657. , $def = require('./$.def')
  27658. , toIndex = $.toIndex;
  27659. $def($def.P, 'Array', {
  27660. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  27661. copyWithin: function copyWithin(target/* = 0 */, start /* = 0, end = @length */){
  27662. var O = Object($.assertDefined(this))
  27663. , len = $.toLength(O.length)
  27664. , to = toIndex(target, len)
  27665. , from = toIndex(start, len)
  27666. , end = arguments[2]
  27667. , fin = end === undefined ? len : toIndex(end, len)
  27668. , count = Math.min(fin - from, len - to)
  27669. , inc = 1;
  27670. if(from < to && to < from + count){
  27671. inc = -1;
  27672. from = from + count - 1;
  27673. to = to + count - 1;
  27674. }
  27675. while(count-- > 0){
  27676. if(from in O)O[to] = O[from];
  27677. else delete O[to];
  27678. to += inc;
  27679. from += inc;
  27680. } return O;
  27681. }
  27682. });
  27683. require('./$.unscope')('copyWithin');
  27684. },{"./$":245,"./$.def":236,"./$.unscope":255}],259:[function(require,module,exports){
  27685. 'use strict';
  27686. var $ = require('./$')
  27687. , $def = require('./$.def')
  27688. , toIndex = $.toIndex;
  27689. $def($def.P, 'Array', {
  27690. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  27691. fill: function fill(value /*, start = 0, end = @length */){
  27692. var O = Object($.assertDefined(this))
  27693. , length = $.toLength(O.length)
  27694. , index = toIndex(arguments[1], length)
  27695. , end = arguments[2]
  27696. , endPos = end === undefined ? length : toIndex(end, length);
  27697. while(endPos > index)O[index++] = value;
  27698. return O;
  27699. }
  27700. });
  27701. require('./$.unscope')('fill');
  27702. },{"./$":245,"./$.def":236,"./$.unscope":255}],260:[function(require,module,exports){
  27703. var $def = require('./$.def');
  27704. $def($def.P, 'Array', {
  27705. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  27706. findIndex: require('./$.array-methods')(6)
  27707. });
  27708. require('./$.unscope')('findIndex');
  27709. },{"./$.array-methods":227,"./$.def":236,"./$.unscope":255}],261:[function(require,module,exports){
  27710. var $def = require('./$.def');
  27711. $def($def.P, 'Array', {
  27712. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  27713. find: require('./$.array-methods')(5)
  27714. });
  27715. require('./$.unscope')('find');
  27716. },{"./$.array-methods":227,"./$.def":236,"./$.unscope":255}],262:[function(require,module,exports){
  27717. var $ = require('./$')
  27718. , ctx = require('./$.ctx')
  27719. , $def = require('./$.def')
  27720. , $iter = require('./$.iter')
  27721. , call = require('./$.iter-call');
  27722. $def($def.S + $def.F * !require('./$.iter-detect')(function(iter){ Array.from(iter); }), 'Array', {
  27723. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  27724. from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  27725. var O = Object($.assertDefined(arrayLike))
  27726. , mapfn = arguments[1]
  27727. , mapping = mapfn !== undefined
  27728. , f = mapping ? ctx(mapfn, arguments[2], 2) : undefined
  27729. , index = 0
  27730. , length, result, step, iterator;
  27731. if($iter.is(O)){
  27732. iterator = $iter.get(O);
  27733. // strange IE quirks mode bug -> use typeof instead of isFunction
  27734. result = new (typeof this == 'function' ? this : Array);
  27735. for(; !(step = iterator.next()).done; index++){
  27736. result[index] = mapping ? call(iterator, f, [step.value, index], true) : step.value;
  27737. }
  27738. } else {
  27739. // strange IE quirks mode bug -> use typeof instead of isFunction
  27740. result = new (typeof this == 'function' ? this : Array)(length = $.toLength(O.length));
  27741. for(; length > index; index++){
  27742. result[index] = mapping ? f(O[index], index) : O[index];
  27743. }
  27744. }
  27745. result.length = index;
  27746. return result;
  27747. }
  27748. });
  27749. },{"./$":245,"./$.ctx":235,"./$.def":236,"./$.iter":244,"./$.iter-call":241,"./$.iter-detect":243}],263:[function(require,module,exports){
  27750. var $ = require('./$')
  27751. , setUnscope = require('./$.unscope')
  27752. , ITER = require('./$.uid').safe('iter')
  27753. , $iter = require('./$.iter')
  27754. , step = $iter.step
  27755. , Iterators = $iter.Iterators;
  27756. // 22.1.3.4 Array.prototype.entries()
  27757. // 22.1.3.13 Array.prototype.keys()
  27758. // 22.1.3.29 Array.prototype.values()
  27759. // 22.1.3.30 Array.prototype[@@iterator]()
  27760. require('./$.iter-define')(Array, 'Array', function(iterated, kind){
  27761. $.set(this, ITER, {o: $.toObject(iterated), i: 0, k: kind});
  27762. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  27763. }, function(){
  27764. var iter = this[ITER]
  27765. , O = iter.o
  27766. , kind = iter.k
  27767. , index = iter.i++;
  27768. if(!O || index >= O.length){
  27769. iter.o = undefined;
  27770. return step(1);
  27771. }
  27772. if(kind == 'keys' )return step(0, index);
  27773. if(kind == 'values')return step(0, O[index]);
  27774. return step(0, [index, O[index]]);
  27775. }, 'values');
  27776. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  27777. Iterators.Arguments = Iterators.Array;
  27778. setUnscope('keys');
  27779. setUnscope('values');
  27780. setUnscope('entries');
  27781. },{"./$":245,"./$.iter":244,"./$.iter-define":242,"./$.uid":254,"./$.unscope":255}],264:[function(require,module,exports){
  27782. var $def = require('./$.def');
  27783. $def($def.S, 'Array', {
  27784. // 22.1.2.3 Array.of( ...items)
  27785. of: function of(/* ...args */){
  27786. var index = 0
  27787. , length = arguments.length
  27788. // strange IE quirks mode bug -> use typeof instead of isFunction
  27789. , result = new (typeof this == 'function' ? this : Array)(length);
  27790. while(length > index)result[index] = arguments[index++];
  27791. result.length = length;
  27792. return result;
  27793. }
  27794. });
  27795. },{"./$.def":236}],265:[function(require,module,exports){
  27796. require('./$.species')(Array);
  27797. },{"./$.species":251}],266:[function(require,module,exports){
  27798. 'use strict';
  27799. var $ = require('./$')
  27800. , NAME = 'name'
  27801. , setDesc = $.setDesc
  27802. , FunctionProto = Function.prototype;
  27803. // 19.2.4.2 name
  27804. NAME in FunctionProto || $.FW && $.DESC && setDesc(FunctionProto, NAME, {
  27805. configurable: true,
  27806. get: function(){
  27807. var match = String(this).match(/^\s*function ([^ (]*)/)
  27808. , name = match ? match[1] : '';
  27809. $.has(this, NAME) || setDesc(this, NAME, $.desc(5, name));
  27810. return name;
  27811. },
  27812. set: function(value){
  27813. $.has(this, NAME) || setDesc(this, NAME, $.desc(0, value));
  27814. }
  27815. });
  27816. },{"./$":245}],267:[function(require,module,exports){
  27817. 'use strict';
  27818. var strong = require('./$.collection-strong');
  27819. // 23.1 Map Objects
  27820. require('./$.collection')('Map', {
  27821. // 23.1.3.6 Map.prototype.get(key)
  27822. get: function get(key){
  27823. var entry = strong.getEntry(this, key);
  27824. return entry && entry.v;
  27825. },
  27826. // 23.1.3.9 Map.prototype.set(key, value)
  27827. set: function set(key, value){
  27828. return strong.def(this, key === 0 ? 0 : key, value);
  27829. }
  27830. }, strong, true);
  27831. },{"./$.collection":234,"./$.collection-strong":231}],268:[function(require,module,exports){
  27832. var Infinity = 1 / 0
  27833. , $def = require('./$.def')
  27834. , E = Math.E
  27835. , pow = Math.pow
  27836. , abs = Math.abs
  27837. , exp = Math.exp
  27838. , log = Math.log
  27839. , sqrt = Math.sqrt
  27840. , ceil = Math.ceil
  27841. , floor = Math.floor
  27842. , EPSILON = pow(2, -52)
  27843. , EPSILON32 = pow(2, -23)
  27844. , MAX32 = pow(2, 127) * (2 - EPSILON32)
  27845. , MIN32 = pow(2, -126);
  27846. function roundTiesToEven(n){
  27847. return n + 1 / EPSILON - 1 / EPSILON;
  27848. }
  27849. // 20.2.2.28 Math.sign(x)
  27850. function sign(x){
  27851. return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
  27852. }
  27853. // 20.2.2.5 Math.asinh(x)
  27854. function asinh(x){
  27855. return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
  27856. }
  27857. // 20.2.2.14 Math.expm1(x)
  27858. function expm1(x){
  27859. return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;
  27860. }
  27861. $def($def.S, 'Math', {
  27862. // 20.2.2.3 Math.acosh(x)
  27863. acosh: function acosh(x){
  27864. return (x = +x) < 1 ? NaN : isFinite(x) ? log(x / E + sqrt(x + 1) * sqrt(x - 1) / E) + 1 : x;
  27865. },
  27866. // 20.2.2.5 Math.asinh(x)
  27867. asinh: asinh,
  27868. // 20.2.2.7 Math.atanh(x)
  27869. atanh: function atanh(x){
  27870. return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;
  27871. },
  27872. // 20.2.2.9 Math.cbrt(x)
  27873. cbrt: function cbrt(x){
  27874. return sign(x = +x) * pow(abs(x), 1 / 3);
  27875. },
  27876. // 20.2.2.11 Math.clz32(x)
  27877. clz32: function clz32(x){
  27878. return (x >>>= 0) ? 31 - floor(log(x + 0.5) * Math.LOG2E) : 32;
  27879. },
  27880. // 20.2.2.12 Math.cosh(x)
  27881. cosh: function cosh(x){
  27882. return (exp(x = +x) + exp(-x)) / 2;
  27883. },
  27884. // 20.2.2.14 Math.expm1(x)
  27885. expm1: expm1,
  27886. // 20.2.2.16 Math.fround(x)
  27887. fround: function fround(x){
  27888. var $abs = abs(x)
  27889. , $sign = sign(x)
  27890. , a, result;
  27891. if($abs < MIN32)return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
  27892. a = (1 + EPSILON32 / EPSILON) * $abs;
  27893. result = a - (a - $abs);
  27894. if(result > MAX32 || result != result)return $sign * Infinity;
  27895. return $sign * result;
  27896. },
  27897. // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
  27898. hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
  27899. var sum = 0
  27900. , len1 = arguments.length
  27901. , len2 = len1
  27902. , args = Array(len1)
  27903. , larg = -Infinity
  27904. , arg;
  27905. while(len1--){
  27906. arg = args[len1] = +arguments[len1];
  27907. if(arg == Infinity || arg == -Infinity)return Infinity;
  27908. if(arg > larg)larg = arg;
  27909. }
  27910. larg = arg || 1;
  27911. while(len2--)sum += pow(args[len2] / larg, 2);
  27912. return larg * sqrt(sum);
  27913. },
  27914. // 20.2.2.18 Math.imul(x, y)
  27915. imul: function imul(x, y){
  27916. var UInt16 = 0xffff
  27917. , xn = +x
  27918. , yn = +y
  27919. , xl = UInt16 & xn
  27920. , yl = UInt16 & yn;
  27921. return 0 | xl * yl + ((UInt16 & xn >>> 16) * yl + xl * (UInt16 & yn >>> 16) << 16 >>> 0);
  27922. },
  27923. // 20.2.2.20 Math.log1p(x)
  27924. log1p: function log1p(x){
  27925. return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);
  27926. },
  27927. // 20.2.2.21 Math.log10(x)
  27928. log10: function log10(x){
  27929. return log(x) / Math.LN10;
  27930. },
  27931. // 20.2.2.22 Math.log2(x)
  27932. log2: function log2(x){
  27933. return log(x) / Math.LN2;
  27934. },
  27935. // 20.2.2.28 Math.sign(x)
  27936. sign: sign,
  27937. // 20.2.2.30 Math.sinh(x)
  27938. sinh: function sinh(x){
  27939. return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
  27940. },
  27941. // 20.2.2.33 Math.tanh(x)
  27942. tanh: function tanh(x){
  27943. var a = expm1(x = +x)
  27944. , b = expm1(-x);
  27945. return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
  27946. },
  27947. // 20.2.2.34 Math.trunc(x)
  27948. trunc: function trunc(it){
  27949. return (it > 0 ? floor : ceil)(it);
  27950. }
  27951. });
  27952. },{"./$.def":236}],269:[function(require,module,exports){
  27953. 'use strict';
  27954. var $ = require('./$')
  27955. , isObject = $.isObject
  27956. , isFunction = $.isFunction
  27957. , NUMBER = 'Number'
  27958. , Number = $.g[NUMBER]
  27959. , Base = Number
  27960. , proto = Number.prototype;
  27961. function toPrimitive(it){
  27962. var fn, val;
  27963. if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
  27964. if(isFunction(fn = it.toString) && !isObject(val = fn.call(it)))return val;
  27965. throw TypeError("Can't convert object to number");
  27966. }
  27967. function toNumber(it){
  27968. if(isObject(it))it = toPrimitive(it);
  27969. if(typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48){
  27970. var binary = false;
  27971. switch(it.charCodeAt(1)){
  27972. case 66 : case 98 : binary = true;
  27973. case 79 : case 111 : return parseInt(it.slice(2), binary ? 2 : 8);
  27974. }
  27975. } return +it;
  27976. }
  27977. if($.FW && !(Number('0o1') && Number('0b1'))){
  27978. Number = function Number(it){
  27979. return this instanceof Number ? new Base(toNumber(it)) : toNumber(it);
  27980. };
  27981. $.each.call($.DESC ? $.getNames(Base) : (
  27982. // ES3:
  27983. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  27984. // ES6 (in case, if modules with ES6 Number statics required before):
  27985. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  27986. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  27987. ).split(','), function(key){
  27988. if($.has(Base, key) && !$.has(Number, key)){
  27989. $.setDesc(Number, key, $.getDesc(Base, key));
  27990. }
  27991. }
  27992. );
  27993. Number.prototype = proto;
  27994. proto.constructor = Number;
  27995. $.hide($.g, NUMBER, Number);
  27996. }
  27997. },{"./$":245}],270:[function(require,module,exports){
  27998. var $ = require('./$')
  27999. , $def = require('./$.def')
  28000. , abs = Math.abs
  28001. , floor = Math.floor
  28002. , _isFinite = $.g.isFinite
  28003. , MAX_SAFE_INTEGER = 0x1fffffffffffff; // pow(2, 53) - 1 == 9007199254740991;
  28004. function isInteger(it){
  28005. return !$.isObject(it) && _isFinite(it) && floor(it) === it;
  28006. }
  28007. $def($def.S, 'Number', {
  28008. // 20.1.2.1 Number.EPSILON
  28009. EPSILON: Math.pow(2, -52),
  28010. // 20.1.2.2 Number.isFinite(number)
  28011. isFinite: function isFinite(it){
  28012. return typeof it == 'number' && _isFinite(it);
  28013. },
  28014. // 20.1.2.3 Number.isInteger(number)
  28015. isInteger: isInteger,
  28016. // 20.1.2.4 Number.isNaN(number)
  28017. isNaN: function isNaN(number){
  28018. return number != number;
  28019. },
  28020. // 20.1.2.5 Number.isSafeInteger(number)
  28021. isSafeInteger: function isSafeInteger(number){
  28022. return isInteger(number) && abs(number) <= MAX_SAFE_INTEGER;
  28023. },
  28024. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  28025. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER,
  28026. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  28027. MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER,
  28028. // 20.1.2.12 Number.parseFloat(string)
  28029. parseFloat: parseFloat,
  28030. // 20.1.2.13 Number.parseInt(string, radix)
  28031. parseInt: parseInt
  28032. });
  28033. },{"./$":245,"./$.def":236}],271:[function(require,module,exports){
  28034. // 19.1.3.1 Object.assign(target, source)
  28035. var $def = require('./$.def');
  28036. $def($def.S, 'Object', {assign: require('./$.assign')});
  28037. },{"./$.assign":229,"./$.def":236}],272:[function(require,module,exports){
  28038. // 19.1.3.10 Object.is(value1, value2)
  28039. var $def = require('./$.def');
  28040. $def($def.S, 'Object', {
  28041. is: function is(x, y){
  28042. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  28043. }
  28044. });
  28045. },{"./$.def":236}],273:[function(require,module,exports){
  28046. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  28047. var $def = require('./$.def');
  28048. $def($def.S, 'Object', {setPrototypeOf: require('./$.set-proto').set});
  28049. },{"./$.def":236,"./$.set-proto":250}],274:[function(require,module,exports){
  28050. var $ = require('./$')
  28051. , $def = require('./$.def')
  28052. , isObject = $.isObject
  28053. , toObject = $.toObject;
  28054. function wrapObjectMethod(METHOD, MODE){
  28055. var fn = ($.core.Object || {})[METHOD] || Object[METHOD]
  28056. , f = 0
  28057. , o = {};
  28058. o[METHOD] = MODE == 1 ? function(it){
  28059. return isObject(it) ? fn(it) : it;
  28060. } : MODE == 2 ? function(it){
  28061. return isObject(it) ? fn(it) : true;
  28062. } : MODE == 3 ? function(it){
  28063. return isObject(it) ? fn(it) : false;
  28064. } : MODE == 4 ? function getOwnPropertyDescriptor(it, key){
  28065. return fn(toObject(it), key);
  28066. } : MODE == 5 ? function getPrototypeOf(it){
  28067. return fn(Object($.assertDefined(it)));
  28068. } : function(it){
  28069. return fn(toObject(it));
  28070. };
  28071. try {
  28072. fn('z');
  28073. } catch(e){
  28074. f = 1;
  28075. }
  28076. $def($def.S + $def.F * f, 'Object', o);
  28077. }
  28078. wrapObjectMethod('freeze', 1);
  28079. wrapObjectMethod('seal', 1);
  28080. wrapObjectMethod('preventExtensions', 1);
  28081. wrapObjectMethod('isFrozen', 2);
  28082. wrapObjectMethod('isSealed', 2);
  28083. wrapObjectMethod('isExtensible', 3);
  28084. wrapObjectMethod('getOwnPropertyDescriptor', 4);
  28085. wrapObjectMethod('getPrototypeOf', 5);
  28086. wrapObjectMethod('keys');
  28087. wrapObjectMethod('getOwnPropertyNames');
  28088. },{"./$":245,"./$.def":236}],275:[function(require,module,exports){
  28089. 'use strict';
  28090. // 19.1.3.6 Object.prototype.toString()
  28091. var $ = require('./$')
  28092. , cof = require('./$.cof')
  28093. , tmp = {};
  28094. tmp[require('./$.wks')('toStringTag')] = 'z';
  28095. if($.FW && cof(tmp) != 'z')$.hide(Object.prototype, 'toString', function toString(){
  28096. return '[object ' + cof.classof(this) + ']';
  28097. });
  28098. },{"./$":245,"./$.cof":230,"./$.wks":256}],276:[function(require,module,exports){
  28099. 'use strict';
  28100. var $ = require('./$')
  28101. , ctx = require('./$.ctx')
  28102. , cof = require('./$.cof')
  28103. , $def = require('./$.def')
  28104. , assert = require('./$.assert')
  28105. , forOf = require('./$.for-of')
  28106. , setProto = require('./$.set-proto').set
  28107. , species = require('./$.species')
  28108. , SPECIES = require('./$.wks')('species')
  28109. , RECORD = require('./$.uid').safe('record')
  28110. , PROMISE = 'Promise'
  28111. , global = $.g
  28112. , process = global.process
  28113. , asap = process && process.nextTick || require('./$.task').set
  28114. , P = global[PROMISE]
  28115. , isFunction = $.isFunction
  28116. , isObject = $.isObject
  28117. , assertFunction = assert.fn
  28118. , assertObject = assert.obj
  28119. , test;
  28120. var useNative = isFunction(P) && isFunction(P.resolve) &&
  28121. P.resolve(test = new P(function(){})) == test;
  28122. // actual Firefox has broken subclass support, test that
  28123. function P2(x){
  28124. var self = new P(x);
  28125. setProto(self, P2.prototype);
  28126. return self;
  28127. }
  28128. if(useNative){
  28129. try { // protect against bad/buggy Object.setPrototype
  28130. setProto(P2, P);
  28131. P2.prototype = $.create(P.prototype, {constructor: {value: P2}});
  28132. if(!(P2.resolve(5).then(function(){}) instanceof P2)){
  28133. useNative = false;
  28134. }
  28135. } catch(e){ useNative = false; }
  28136. }
  28137. // helpers
  28138. function getConstructor(C){
  28139. var S = assertObject(C)[SPECIES];
  28140. return S != undefined ? S : C;
  28141. }
  28142. function isThenable(it){
  28143. var then;
  28144. if(isObject(it))then = it.then;
  28145. return isFunction(then) ? then : false;
  28146. }
  28147. function notify(record){
  28148. var chain = record.c;
  28149. if(chain.length)asap(function(){
  28150. var value = record.v
  28151. , ok = record.s == 1
  28152. , i = 0;
  28153. while(chain.length > i)!function(react){
  28154. var cb = ok ? react.ok : react.fail
  28155. , ret, then;
  28156. try {
  28157. if(cb){
  28158. if(!ok)record.h = true;
  28159. ret = cb === true ? value : cb(value);
  28160. if(ret === react.P){
  28161. react.rej(TypeError('Promise-chain cycle'));
  28162. } else if(then = isThenable(ret)){
  28163. then.call(ret, react.res, react.rej);
  28164. } else react.res(ret);
  28165. } else react.rej(value);
  28166. } catch(err){
  28167. react.rej(err);
  28168. }
  28169. }(chain[i++]);
  28170. chain.length = 0;
  28171. });
  28172. }
  28173. function isUnhandled(promise){
  28174. var record = promise[RECORD]
  28175. , chain = record.a
  28176. , i = 0
  28177. , react;
  28178. if(record.h)return false;
  28179. while(chain.length > i){
  28180. react = chain[i++];
  28181. if(react.fail || !isUnhandled(react.P))return false;
  28182. } return true;
  28183. }
  28184. function $reject(value){
  28185. var record = this
  28186. , promise;
  28187. if(record.d)return;
  28188. record.d = true;
  28189. record = record.r || record; // unwrap
  28190. record.v = value;
  28191. record.s = 2;
  28192. asap(function(){
  28193. setTimeout(function(){
  28194. if(isUnhandled(promise = record.p)){
  28195. if(cof(process) == 'process'){
  28196. process.emit('unhandledRejection', value, promise);
  28197. } else if(global.console && isFunction(console.error)){
  28198. console.error('Unhandled promise rejection', value);
  28199. }
  28200. }
  28201. }, 1);
  28202. });
  28203. notify(record);
  28204. }
  28205. function $resolve(value){
  28206. var record = this
  28207. , then, wrapper;
  28208. if(record.d)return;
  28209. record.d = true;
  28210. record = record.r || record; // unwrap
  28211. try {
  28212. if(then = isThenable(value)){
  28213. wrapper = {r: record, d: false}; // wrap
  28214. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  28215. } else {
  28216. record.v = value;
  28217. record.s = 1;
  28218. notify(record);
  28219. }
  28220. } catch(err){
  28221. $reject.call(wrapper || {r: record, d: false}, err); // wrap
  28222. }
  28223. }
  28224. // constructor polyfill
  28225. if(!useNative){
  28226. // 25.4.3.1 Promise(executor)
  28227. P = function Promise(executor){
  28228. assertFunction(executor);
  28229. var record = {
  28230. p: assert.inst(this, P, PROMISE), // <- promise
  28231. c: [], // <- awaiting reactions
  28232. a: [], // <- all reactions
  28233. s: 0, // <- state
  28234. d: false, // <- done
  28235. v: undefined, // <- value
  28236. h: false // <- handled rejection
  28237. };
  28238. $.hide(this, RECORD, record);
  28239. try {
  28240. executor(ctx($resolve, record, 1), ctx($reject, record, 1));
  28241. } catch(err){
  28242. $reject.call(record, err);
  28243. }
  28244. };
  28245. $.mix(P.prototype, {
  28246. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  28247. then: function then(onFulfilled, onRejected){
  28248. var S = assertObject(assertObject(this).constructor)[SPECIES];
  28249. var react = {
  28250. ok: isFunction(onFulfilled) ? onFulfilled : true,
  28251. fail: isFunction(onRejected) ? onRejected : false
  28252. };
  28253. var promise = react.P = new (S != undefined ? S : P)(function(res, rej){
  28254. react.res = assertFunction(res);
  28255. react.rej = assertFunction(rej);
  28256. });
  28257. var record = this[RECORD];
  28258. record.a.push(react);
  28259. record.c.push(react);
  28260. record.s && notify(record);
  28261. return promise;
  28262. },
  28263. // 25.4.5.1 Promise.prototype.catch(onRejected)
  28264. 'catch': function(onRejected){
  28265. return this.then(undefined, onRejected);
  28266. }
  28267. });
  28268. }
  28269. // export
  28270. $def($def.G + $def.W + $def.F * !useNative, {Promise: P});
  28271. cof.set(P, PROMISE);
  28272. species(P);
  28273. species($.core[PROMISE]); // for wrapper
  28274. // statics
  28275. $def($def.S + $def.F * !useNative, PROMISE, {
  28276. // 25.4.4.5 Promise.reject(r)
  28277. reject: function reject(r){
  28278. return new (getConstructor(this))(function(res, rej){
  28279. rej(r);
  28280. });
  28281. },
  28282. // 25.4.4.6 Promise.resolve(x)
  28283. resolve: function resolve(x){
  28284. return isObject(x) && RECORD in x && $.getProto(x) === this.prototype
  28285. ? x : new (getConstructor(this))(function(res){
  28286. res(x);
  28287. });
  28288. }
  28289. });
  28290. $def($def.S + $def.F * !(useNative && require('./$.iter-detect')(function(iter){
  28291. P.all(iter)['catch'](function(){});
  28292. })), PROMISE, {
  28293. // 25.4.4.1 Promise.all(iterable)
  28294. all: function all(iterable){
  28295. var C = getConstructor(this)
  28296. , values = [];
  28297. return new C(function(res, rej){
  28298. forOf(iterable, false, values.push, values);
  28299. var remaining = values.length
  28300. , results = Array(remaining);
  28301. if(remaining)$.each.call(values, function(promise, index){
  28302. C.resolve(promise).then(function(value){
  28303. results[index] = value;
  28304. --remaining || res(results);
  28305. }, rej);
  28306. });
  28307. else res(results);
  28308. });
  28309. },
  28310. // 25.4.4.4 Promise.race(iterable)
  28311. race: function race(iterable){
  28312. var C = getConstructor(this);
  28313. return new C(function(res, rej){
  28314. forOf(iterable, false, function(promise){
  28315. C.resolve(promise).then(res, rej);
  28316. });
  28317. });
  28318. }
  28319. });
  28320. },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.ctx":235,"./$.def":236,"./$.for-of":238,"./$.iter-detect":243,"./$.set-proto":250,"./$.species":251,"./$.task":253,"./$.uid":254,"./$.wks":256}],277:[function(require,module,exports){
  28321. var $ = require('./$')
  28322. , $def = require('./$.def')
  28323. , setProto = require('./$.set-proto')
  28324. , $iter = require('./$.iter')
  28325. , ITER = require('./$.uid').safe('iter')
  28326. , step = $iter.step
  28327. , assert = require('./$.assert')
  28328. , isObject = $.isObject
  28329. , getDesc = $.getDesc
  28330. , setDesc = $.setDesc
  28331. , getProto = $.getProto
  28332. , apply = Function.apply
  28333. , assertObject = assert.obj
  28334. , _isExtensible = Object.isExtensible || $.it;
  28335. function Enumerate(iterated){
  28336. $.set(this, ITER, {o: iterated, k: undefined, i: 0});
  28337. }
  28338. $iter.create(Enumerate, 'Object', function(){
  28339. var iter = this[ITER]
  28340. , keys = iter.k
  28341. , key;
  28342. if(keys == undefined){
  28343. iter.k = keys = [];
  28344. for(key in iter.o)keys.push(key);
  28345. }
  28346. do {
  28347. if(iter.i >= keys.length)return step(1);
  28348. } while(!((key = keys[iter.i++]) in iter.o));
  28349. return step(0, key);
  28350. });
  28351. function wrap(fn){
  28352. return function(it){
  28353. assertObject(it);
  28354. try {
  28355. fn.apply(undefined, arguments);
  28356. return true;
  28357. } catch(e){
  28358. return false;
  28359. }
  28360. };
  28361. }
  28362. function get(target, propertyKey/*, receiver*/){
  28363. var receiver = arguments.length < 3 ? target : arguments[2]
  28364. , desc = getDesc(assertObject(target), propertyKey), proto;
  28365. if(desc)return $.has(desc, 'value')
  28366. ? desc.value
  28367. : desc.get === undefined
  28368. ? undefined
  28369. : desc.get.call(receiver);
  28370. return isObject(proto = getProto(target))
  28371. ? get(proto, propertyKey, receiver)
  28372. : undefined;
  28373. }
  28374. function set(target, propertyKey, V/*, receiver*/){
  28375. var receiver = arguments.length < 4 ? target : arguments[3]
  28376. , ownDesc = getDesc(assertObject(target), propertyKey)
  28377. , existingDescriptor, proto;
  28378. if(!ownDesc){
  28379. if(isObject(proto = getProto(target))){
  28380. return set(proto, propertyKey, V, receiver);
  28381. }
  28382. ownDesc = $.desc(0);
  28383. }
  28384. if($.has(ownDesc, 'value')){
  28385. if(ownDesc.writable === false || !isObject(receiver))return false;
  28386. existingDescriptor = getDesc(receiver, propertyKey) || $.desc(0);
  28387. existingDescriptor.value = V;
  28388. setDesc(receiver, propertyKey, existingDescriptor);
  28389. return true;
  28390. }
  28391. return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
  28392. }
  28393. var reflect = {
  28394. // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
  28395. apply: require('./$.ctx')(Function.call, apply, 3),
  28396. // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
  28397. construct: function construct(target, argumentsList /*, newTarget*/){
  28398. var proto = assert.fn(arguments.length < 3 ? target : arguments[2]).prototype
  28399. , instance = $.create(isObject(proto) ? proto : Object.prototype)
  28400. , result = apply.call(target, instance, argumentsList);
  28401. return isObject(result) ? result : instance;
  28402. },
  28403. // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
  28404. defineProperty: wrap(setDesc),
  28405. // 26.1.4 Reflect.deleteProperty(target, propertyKey)
  28406. deleteProperty: function deleteProperty(target, propertyKey){
  28407. var desc = getDesc(assertObject(target), propertyKey);
  28408. return desc && !desc.configurable ? false : delete target[propertyKey];
  28409. },
  28410. // 26.1.5 Reflect.enumerate(target)
  28411. enumerate: function enumerate(target){
  28412. return new Enumerate(assertObject(target));
  28413. },
  28414. // 26.1.6 Reflect.get(target, propertyKey [, receiver])
  28415. get: get,
  28416. // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
  28417. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey){
  28418. return getDesc(assertObject(target), propertyKey);
  28419. },
  28420. // 26.1.8 Reflect.getPrototypeOf(target)
  28421. getPrototypeOf: function getPrototypeOf(target){
  28422. return getProto(assertObject(target));
  28423. },
  28424. // 26.1.9 Reflect.has(target, propertyKey)
  28425. has: function has(target, propertyKey){
  28426. return propertyKey in target;
  28427. },
  28428. // 26.1.10 Reflect.isExtensible(target)
  28429. isExtensible: function isExtensible(target){
  28430. return !!_isExtensible(assertObject(target));
  28431. },
  28432. // 26.1.11 Reflect.ownKeys(target)
  28433. ownKeys: require('./$.own-keys'),
  28434. // 26.1.12 Reflect.preventExtensions(target)
  28435. preventExtensions: wrap(Object.preventExtensions || $.it),
  28436. // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
  28437. set: set
  28438. };
  28439. // 26.1.14 Reflect.setPrototypeOf(target, proto)
  28440. if(setProto)reflect.setPrototypeOf = function setPrototypeOf(target, proto){
  28441. setProto.check(target, proto);
  28442. try {
  28443. setProto.set(target, proto);
  28444. return true;
  28445. } catch(e){
  28446. return false;
  28447. }
  28448. };
  28449. $def($def.G, {Reflect: {}});
  28450. $def($def.S, 'Reflect', reflect);
  28451. },{"./$":245,"./$.assert":228,"./$.ctx":235,"./$.def":236,"./$.iter":244,"./$.own-keys":247,"./$.set-proto":250,"./$.uid":254}],278:[function(require,module,exports){
  28452. var $ = require('./$')
  28453. , cof = require('./$.cof')
  28454. , RegExp = $.g.RegExp
  28455. , Base = RegExp
  28456. , proto = RegExp.prototype;
  28457. function regExpBroken() {
  28458. try {
  28459. var a = /a/g;
  28460. // "new" creates a new object
  28461. if (a === new RegExp(a)) { return true; }
  28462. // RegExp allows a regex with flags as the pattern
  28463. return RegExp(/a/g, 'i') != '/a/i';
  28464. } catch(e) {
  28465. return true;
  28466. }
  28467. }
  28468. if($.FW && $.DESC){
  28469. if(regExpBroken()) {
  28470. RegExp = function RegExp(pattern, flags){
  28471. return new Base(cof(pattern) == 'RegExp' ? pattern.source : pattern,
  28472. flags === undefined ? pattern.flags : flags);
  28473. };
  28474. $.each.call($.getNames(Base), function(key){
  28475. key in RegExp || $.setDesc(RegExp, key, {
  28476. configurable: true,
  28477. get: function(){ return Base[key]; },
  28478. set: function(it){ Base[key] = it; }
  28479. });
  28480. });
  28481. proto.constructor = RegExp;
  28482. RegExp.prototype = proto;
  28483. $.hide($.g, 'RegExp', RegExp);
  28484. }
  28485. // 21.2.5.3 get RegExp.prototype.flags()
  28486. if(/./g.flags != 'g')$.setDesc(proto, 'flags', {
  28487. configurable: true,
  28488. get: require('./$.replacer')(/^.*\/(\w*)$/, '$1')
  28489. });
  28490. }
  28491. require('./$.species')(RegExp);
  28492. },{"./$":245,"./$.cof":230,"./$.replacer":249,"./$.species":251}],279:[function(require,module,exports){
  28493. 'use strict';
  28494. var strong = require('./$.collection-strong');
  28495. // 23.2 Set Objects
  28496. require('./$.collection')('Set', {
  28497. // 23.2.3.1 Set.prototype.add(value)
  28498. add: function add(value){
  28499. return strong.def(this, value = value === 0 ? 0 : value, value);
  28500. }
  28501. }, strong);
  28502. },{"./$.collection":234,"./$.collection-strong":231}],280:[function(require,module,exports){
  28503. var $def = require('./$.def');
  28504. $def($def.P, 'String', {
  28505. // 21.1.3.3 String.prototype.codePointAt(pos)
  28506. codePointAt: require('./$.string-at')(false)
  28507. });
  28508. },{"./$.def":236,"./$.string-at":252}],281:[function(require,module,exports){
  28509. 'use strict';
  28510. var $ = require('./$')
  28511. , cof = require('./$.cof')
  28512. , $def = require('./$.def')
  28513. , toLength = $.toLength;
  28514. $def($def.P, 'String', {
  28515. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  28516. endsWith: function endsWith(searchString /*, endPosition = @length */){
  28517. if(cof(searchString) == 'RegExp')throw TypeError();
  28518. var that = String($.assertDefined(this))
  28519. , endPosition = arguments[1]
  28520. , len = toLength(that.length)
  28521. , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  28522. searchString += '';
  28523. return that.slice(end - searchString.length, end) === searchString;
  28524. }
  28525. });
  28526. },{"./$":245,"./$.cof":230,"./$.def":236}],282:[function(require,module,exports){
  28527. var $def = require('./$.def')
  28528. , toIndex = require('./$').toIndex
  28529. , fromCharCode = String.fromCharCode;
  28530. $def($def.S, 'String', {
  28531. // 21.1.2.2 String.fromCodePoint(...codePoints)
  28532. fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
  28533. var res = []
  28534. , len = arguments.length
  28535. , i = 0
  28536. , code;
  28537. while(len > i){
  28538. code = +arguments[i++];
  28539. if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
  28540. res.push(code < 0x10000
  28541. ? fromCharCode(code)
  28542. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  28543. );
  28544. } return res.join('');
  28545. }
  28546. });
  28547. },{"./$":245,"./$.def":236}],283:[function(require,module,exports){
  28548. 'use strict';
  28549. var $ = require('./$')
  28550. , cof = require('./$.cof')
  28551. , $def = require('./$.def');
  28552. $def($def.P, 'String', {
  28553. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  28554. includes: function includes(searchString /*, position = 0 */){
  28555. if(cof(searchString) == 'RegExp')throw TypeError();
  28556. return !!~String($.assertDefined(this)).indexOf(searchString, arguments[1]);
  28557. }
  28558. });
  28559. },{"./$":245,"./$.cof":230,"./$.def":236}],284:[function(require,module,exports){
  28560. var set = require('./$').set
  28561. , at = require('./$.string-at')(true)
  28562. , ITER = require('./$.uid').safe('iter')
  28563. , $iter = require('./$.iter')
  28564. , step = $iter.step;
  28565. // 21.1.3.27 String.prototype[@@iterator]()
  28566. require('./$.iter-define')(String, 'String', function(iterated){
  28567. set(this, ITER, {o: String(iterated), i: 0});
  28568. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  28569. }, function(){
  28570. var iter = this[ITER]
  28571. , O = iter.o
  28572. , index = iter.i
  28573. , point;
  28574. if(index >= O.length)return step(1);
  28575. point = at.call(O, index);
  28576. iter.i += point.length;
  28577. return step(0, point);
  28578. });
  28579. },{"./$":245,"./$.iter":244,"./$.iter-define":242,"./$.string-at":252,"./$.uid":254}],285:[function(require,module,exports){
  28580. var $ = require('./$')
  28581. , $def = require('./$.def');
  28582. $def($def.S, 'String', {
  28583. // 21.1.2.4 String.raw(callSite, ...substitutions)
  28584. raw: function raw(callSite){
  28585. var tpl = $.toObject(callSite.raw)
  28586. , len = $.toLength(tpl.length)
  28587. , sln = arguments.length
  28588. , res = []
  28589. , i = 0;
  28590. while(len > i){
  28591. res.push(String(tpl[i++]));
  28592. if(i < sln)res.push(String(arguments[i]));
  28593. } return res.join('');
  28594. }
  28595. });
  28596. },{"./$":245,"./$.def":236}],286:[function(require,module,exports){
  28597. 'use strict';
  28598. var $ = require('./$')
  28599. , $def = require('./$.def');
  28600. $def($def.P, 'String', {
  28601. // 21.1.3.13 String.prototype.repeat(count)
  28602. repeat: function repeat(count){
  28603. var str = String($.assertDefined(this))
  28604. , res = ''
  28605. , n = $.toInteger(count);
  28606. if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
  28607. for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
  28608. return res;
  28609. }
  28610. });
  28611. },{"./$":245,"./$.def":236}],287:[function(require,module,exports){
  28612. 'use strict';
  28613. var $ = require('./$')
  28614. , cof = require('./$.cof')
  28615. , $def = require('./$.def');
  28616. $def($def.P, 'String', {
  28617. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  28618. startsWith: function startsWith(searchString /*, position = 0 */){
  28619. if(cof(searchString) == 'RegExp')throw TypeError();
  28620. var that = String($.assertDefined(this))
  28621. , index = $.toLength(Math.min(arguments[1], that.length));
  28622. searchString += '';
  28623. return that.slice(index, index + searchString.length) === searchString;
  28624. }
  28625. });
  28626. },{"./$":245,"./$.cof":230,"./$.def":236}],288:[function(require,module,exports){
  28627. 'use strict';
  28628. // ECMAScript 6 symbols shim
  28629. var $ = require('./$')
  28630. , setTag = require('./$.cof').set
  28631. , uid = require('./$.uid')
  28632. , $def = require('./$.def')
  28633. , keyOf = require('./$.keyof')
  28634. , enumKeys = require('./$.enum-keys')
  28635. , assertObject = require('./$.assert').obj
  28636. , has = $.has
  28637. , $create = $.create
  28638. , getDesc = $.getDesc
  28639. , setDesc = $.setDesc
  28640. , desc = $.desc
  28641. , getNames = $.getNames
  28642. , toObject = $.toObject
  28643. , Symbol = $.g.Symbol
  28644. , setter = false
  28645. , TAG = uid('tag')
  28646. , HIDDEN = uid('hidden')
  28647. , SymbolRegistry = {}
  28648. , AllSymbols = {}
  28649. , useNative = $.isFunction(Symbol);
  28650. function wrap(tag){
  28651. var sym = AllSymbols[tag] = $.set($create(Symbol.prototype), TAG, tag);
  28652. $.DESC && setter && setDesc(Object.prototype, tag, {
  28653. configurable: true,
  28654. set: function(value){
  28655. if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
  28656. setDesc(this, tag, desc(1, value));
  28657. }
  28658. });
  28659. return sym;
  28660. }
  28661. function defineProperty(it, key, D){
  28662. if(D && has(AllSymbols, key)){
  28663. if(!D.enumerable){
  28664. if(!has(it, HIDDEN))setDesc(it, HIDDEN, desc(1, {}));
  28665. it[HIDDEN][key] = true;
  28666. } else {
  28667. if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
  28668. D.enumerable = false;
  28669. }
  28670. } return setDesc(it, key, D);
  28671. }
  28672. function defineProperties(it, P){
  28673. assertObject(it);
  28674. var keys = enumKeys(P = toObject(P))
  28675. , i = 0
  28676. , l = keys.length
  28677. , key;
  28678. while(l > i)defineProperty(it, key = keys[i++], P[key]);
  28679. return it;
  28680. }
  28681. function create(it, P){
  28682. return P === undefined ? $create(it) : defineProperties($create(it), P);
  28683. }
  28684. function getOwnPropertyDescriptor(it, key){
  28685. var D = getDesc(it = toObject(it), key);
  28686. if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
  28687. return D;
  28688. }
  28689. function getOwnPropertyNames(it){
  28690. var names = getNames(toObject(it))
  28691. , result = []
  28692. , i = 0
  28693. , key;
  28694. while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key);
  28695. return result;
  28696. }
  28697. function getOwnPropertySymbols(it){
  28698. var names = getNames(toObject(it))
  28699. , result = []
  28700. , i = 0
  28701. , key;
  28702. while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);
  28703. return result;
  28704. }
  28705. // 19.4.1.1 Symbol([description])
  28706. if(!useNative){
  28707. Symbol = function Symbol(description){
  28708. if(this instanceof Symbol)throw TypeError('Symbol is not a constructor');
  28709. return wrap(uid(description));
  28710. };
  28711. $.hide(Symbol.prototype, 'toString', function(){
  28712. return this[TAG];
  28713. });
  28714. $.create = create;
  28715. $.setDesc = defineProperty;
  28716. $.getDesc = getOwnPropertyDescriptor;
  28717. $.setDescs = defineProperties;
  28718. $.getNames = getOwnPropertyNames;
  28719. $.getSymbols = getOwnPropertySymbols;
  28720. }
  28721. var symbolStatics = {
  28722. // 19.4.2.1 Symbol.for(key)
  28723. 'for': function(key){
  28724. return has(SymbolRegistry, key += '')
  28725. ? SymbolRegistry[key]
  28726. : SymbolRegistry[key] = Symbol(key);
  28727. },
  28728. // 19.4.2.5 Symbol.keyFor(sym)
  28729. keyFor: function keyFor(key){
  28730. return keyOf(SymbolRegistry, key);
  28731. },
  28732. useSetter: function(){ setter = true; },
  28733. useSimple: function(){ setter = false; }
  28734. };
  28735. // 19.4.2.2 Symbol.hasInstance
  28736. // 19.4.2.3 Symbol.isConcatSpreadable
  28737. // 19.4.2.4 Symbol.iterator
  28738. // 19.4.2.6 Symbol.match
  28739. // 19.4.2.8 Symbol.replace
  28740. // 19.4.2.9 Symbol.search
  28741. // 19.4.2.10 Symbol.species
  28742. // 19.4.2.11 Symbol.split
  28743. // 19.4.2.12 Symbol.toPrimitive
  28744. // 19.4.2.13 Symbol.toStringTag
  28745. // 19.4.2.14 Symbol.unscopables
  28746. $.each.call((
  28747. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,' +
  28748. 'species,split,toPrimitive,toStringTag,unscopables'
  28749. ).split(','), function(it){
  28750. var sym = require('./$.wks')(it);
  28751. symbolStatics[it] = useNative ? sym : wrap(sym);
  28752. }
  28753. );
  28754. setter = true;
  28755. $def($def.G + $def.W, {Symbol: Symbol});
  28756. $def($def.S, 'Symbol', symbolStatics);
  28757. $def($def.S + $def.F * !useNative, 'Object', {
  28758. // 19.1.2.2 Object.create(O [, Properties])
  28759. create: create,
  28760. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  28761. defineProperty: defineProperty,
  28762. // 19.1.2.3 Object.defineProperties(O, Properties)
  28763. defineProperties: defineProperties,
  28764. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  28765. getOwnPropertyDescriptor: getOwnPropertyDescriptor,
  28766. // 19.1.2.7 Object.getOwnPropertyNames(O)
  28767. getOwnPropertyNames: getOwnPropertyNames,
  28768. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  28769. getOwnPropertySymbols: getOwnPropertySymbols
  28770. });
  28771. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  28772. setTag(Symbol, 'Symbol');
  28773. // 20.2.1.9 Math[@@toStringTag]
  28774. setTag(Math, 'Math', true);
  28775. // 24.3.3 JSON[@@toStringTag]
  28776. setTag($.g.JSON, 'JSON', true);
  28777. },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.enum-keys":237,"./$.keyof":246,"./$.uid":254,"./$.wks":256}],289:[function(require,module,exports){
  28778. 'use strict';
  28779. var $ = require('./$')
  28780. , weak = require('./$.collection-weak')
  28781. , leakStore = weak.leakStore
  28782. , ID = weak.ID
  28783. , WEAK = weak.WEAK
  28784. , has = $.has
  28785. , isObject = $.isObject
  28786. , isFrozen = Object.isFrozen || $.core.Object.isFrozen
  28787. , tmp = {};
  28788. // 23.3 WeakMap Objects
  28789. var WeakMap = require('./$.collection')('WeakMap', {
  28790. // 23.3.3.3 WeakMap.prototype.get(key)
  28791. get: function get(key){
  28792. if(isObject(key)){
  28793. if(isFrozen(key))return leakStore(this).get(key);
  28794. if(has(key, WEAK))return key[WEAK][this[ID]];
  28795. }
  28796. },
  28797. // 23.3.3.5 WeakMap.prototype.set(key, value)
  28798. set: function set(key, value){
  28799. return weak.def(this, key, value);
  28800. }
  28801. }, weak, true, true);
  28802. // IE11 WeakMap frozen keys fix
  28803. if($.FW && new WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
  28804. $.each.call(['delete', 'has', 'get', 'set'], function(key){
  28805. var method = WeakMap.prototype[key];
  28806. WeakMap.prototype[key] = function(a, b){
  28807. // store frozen objects on leaky map
  28808. if(isObject(a) && isFrozen(a)){
  28809. var result = leakStore(this)[key](a, b);
  28810. return key == 'set' ? this : result;
  28811. // store all the rest on native weakmap
  28812. } return method.call(this, a, b);
  28813. };
  28814. });
  28815. }
  28816. },{"./$":245,"./$.collection":234,"./$.collection-weak":233}],290:[function(require,module,exports){
  28817. 'use strict';
  28818. var weak = require('./$.collection-weak');
  28819. // 23.4 WeakSet Objects
  28820. require('./$.collection')('WeakSet', {
  28821. // 23.4.3.1 WeakSet.prototype.add(value)
  28822. add: function add(value){
  28823. return weak.def(this, value, true);
  28824. }
  28825. }, weak, false, true);
  28826. },{"./$.collection":234,"./$.collection-weak":233}],291:[function(require,module,exports){
  28827. // https://github.com/domenic/Array.prototype.includes
  28828. var $def = require('./$.def');
  28829. $def($def.P, 'Array', {
  28830. includes: require('./$.array-includes')(true)
  28831. });
  28832. require('./$.unscope')('includes');
  28833. },{"./$.array-includes":226,"./$.def":236,"./$.unscope":255}],292:[function(require,module,exports){
  28834. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  28835. require('./$.collection-to-json')('Map');
  28836. },{"./$.collection-to-json":232}],293:[function(require,module,exports){
  28837. // https://gist.github.com/WebReflection/9353781
  28838. var $ = require('./$')
  28839. , $def = require('./$.def')
  28840. , ownKeys = require('./$.own-keys');
  28841. $def($def.S, 'Object', {
  28842. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
  28843. var O = $.toObject(object)
  28844. , result = {};
  28845. $.each.call(ownKeys(O), function(key){
  28846. $.setDesc(result, key, $.desc(0, $.getDesc(O, key)));
  28847. });
  28848. return result;
  28849. }
  28850. });
  28851. },{"./$":245,"./$.def":236,"./$.own-keys":247}],294:[function(require,module,exports){
  28852. // http://goo.gl/XkBrjD
  28853. var $ = require('./$')
  28854. , $def = require('./$.def');
  28855. function createObjectToArray(isEntries){
  28856. return function(object){
  28857. var O = $.toObject(object)
  28858. , keys = $.getKeys(O)
  28859. , length = keys.length
  28860. , i = 0
  28861. , result = Array(length)
  28862. , key;
  28863. if(isEntries)while(length > i)result[i] = [key = keys[i++], O[key]];
  28864. else while(length > i)result[i] = O[keys[i++]];
  28865. return result;
  28866. };
  28867. }
  28868. $def($def.S, 'Object', {
  28869. values: createObjectToArray(false),
  28870. entries: createObjectToArray(true)
  28871. });
  28872. },{"./$":245,"./$.def":236}],295:[function(require,module,exports){
  28873. // https://gist.github.com/kangax/9698100
  28874. var $def = require('./$.def');
  28875. $def($def.S, 'RegExp', {
  28876. escape: require('./$.replacer')(/([\\\-[\]{}()*+?.,^$|])/g, '\\$1', true)
  28877. });
  28878. },{"./$.def":236,"./$.replacer":249}],296:[function(require,module,exports){
  28879. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  28880. require('./$.collection-to-json')('Set');
  28881. },{"./$.collection-to-json":232}],297:[function(require,module,exports){
  28882. // https://github.com/mathiasbynens/String.prototype.at
  28883. var $def = require('./$.def');
  28884. $def($def.P, 'String', {
  28885. at: require('./$.string-at')(true)
  28886. });
  28887. },{"./$.def":236,"./$.string-at":252}],298:[function(require,module,exports){
  28888. // JavaScript 1.6 / Strawman array statics shim
  28889. var $ = require('./$')
  28890. , $def = require('./$.def')
  28891. , $Array = $.core.Array || Array
  28892. , statics = {};
  28893. function setStatics(keys, length){
  28894. $.each.call(keys.split(','), function(key){
  28895. if(length == undefined && key in $Array)statics[key] = $Array[key];
  28896. else if(key in [])statics[key] = require('./$.ctx')(Function.call, [][key], length);
  28897. });
  28898. }
  28899. setStatics('pop,reverse,shift,keys,values,entries', 1);
  28900. setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3);
  28901. setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' +
  28902. 'reduce,reduceRight,copyWithin,fill,turn');
  28903. $def($def.S, 'Array', statics);
  28904. },{"./$":245,"./$.ctx":235,"./$.def":236}],299:[function(require,module,exports){
  28905. require('./es6.array.iterator');
  28906. var $ = require('./$')
  28907. , Iterators = require('./$.iter').Iterators
  28908. , ITERATOR = require('./$.wks')('iterator')
  28909. , ArrayValues = Iterators.Array
  28910. , NodeList = $.g.NodeList;
  28911. if($.FW && NodeList && !(ITERATOR in NodeList.prototype)){
  28912. $.hide(NodeList.prototype, ITERATOR, ArrayValues);
  28913. }
  28914. Iterators.NodeList = ArrayValues;
  28915. },{"./$":245,"./$.iter":244,"./$.wks":256,"./es6.array.iterator":263}],300:[function(require,module,exports){
  28916. var $def = require('./$.def')
  28917. , $task = require('./$.task');
  28918. $def($def.G + $def.B, {
  28919. setImmediate: $task.set,
  28920. clearImmediate: $task.clear
  28921. });
  28922. },{"./$.def":236,"./$.task":253}],301:[function(require,module,exports){
  28923. // ie9- setTimeout & setInterval additional parameters fix
  28924. var $ = require('./$')
  28925. , $def = require('./$.def')
  28926. , invoke = require('./$.invoke')
  28927. , partial = require('./$.partial')
  28928. , navigator = $.g.navigator
  28929. , MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
  28930. function wrap(set){
  28931. return MSIE ? function(fn, time /*, ...args */){
  28932. return set(invoke(
  28933. partial,
  28934. [].slice.call(arguments, 2),
  28935. $.isFunction(fn) ? fn : Function(fn)
  28936. ), time);
  28937. } : set;
  28938. }
  28939. $def($def.G + $def.B + $def.F * MSIE, {
  28940. setTimeout: wrap($.g.setTimeout),
  28941. setInterval: wrap($.g.setInterval)
  28942. });
  28943. },{"./$":245,"./$.def":236,"./$.invoke":240,"./$.partial":248}],302:[function(require,module,exports){
  28944. require('./modules/es5');
  28945. require('./modules/es6.symbol');
  28946. require('./modules/es6.object.assign');
  28947. require('./modules/es6.object.is');
  28948. require('./modules/es6.object.set-prototype-of');
  28949. require('./modules/es6.object.to-string');
  28950. require('./modules/es6.object.statics-accept-primitives');
  28951. require('./modules/es6.function.name');
  28952. require('./modules/es6.number.constructor');
  28953. require('./modules/es6.number.statics');
  28954. require('./modules/es6.math');
  28955. require('./modules/es6.string.from-code-point');
  28956. require('./modules/es6.string.raw');
  28957. require('./modules/es6.string.iterator');
  28958. require('./modules/es6.string.code-point-at');
  28959. require('./modules/es6.string.ends-with');
  28960. require('./modules/es6.string.includes');
  28961. require('./modules/es6.string.repeat');
  28962. require('./modules/es6.string.starts-with');
  28963. require('./modules/es6.array.from');
  28964. require('./modules/es6.array.of');
  28965. require('./modules/es6.array.iterator');
  28966. require('./modules/es6.array.species');
  28967. require('./modules/es6.array.copy-within');
  28968. require('./modules/es6.array.fill');
  28969. require('./modules/es6.array.find');
  28970. require('./modules/es6.array.find-index');
  28971. require('./modules/es6.regexp');
  28972. require('./modules/es6.promise');
  28973. require('./modules/es6.map');
  28974. require('./modules/es6.set');
  28975. require('./modules/es6.weak-map');
  28976. require('./modules/es6.weak-set');
  28977. require('./modules/es6.reflect');
  28978. require('./modules/es7.array.includes');
  28979. require('./modules/es7.string.at');
  28980. require('./modules/es7.regexp.escape');
  28981. require('./modules/es7.object.get-own-property-descriptors');
  28982. require('./modules/es7.object.to-array');
  28983. require('./modules/es7.map.to-json');
  28984. require('./modules/es7.set.to-json');
  28985. require('./modules/js.array.statics');
  28986. require('./modules/web.timers');
  28987. require('./modules/web.immediate');
  28988. require('./modules/web.dom.iterable');
  28989. module.exports = require('./modules/$').core;
  28990. },{"./modules/$":245,"./modules/es5":257,"./modules/es6.array.copy-within":258,"./modules/es6.array.fill":259,"./modules/es6.array.find":261,"./modules/es6.array.find-index":260,"./modules/es6.array.from":262,"./modules/es6.array.iterator":263,"./modules/es6.array.of":264,"./modules/es6.array.species":265,"./modules/es6.function.name":266,"./modules/es6.map":267,"./modules/es6.math":268,"./modules/es6.number.constructor":269,"./modules/es6.number.statics":270,"./modules/es6.object.assign":271,"./modules/es6.object.is":272,"./modules/es6.object.set-prototype-of":273,"./modules/es6.object.statics-accept-primitives":274,"./modules/es6.object.to-string":275,"./modules/es6.promise":276,"./modules/es6.reflect":277,"./modules/es6.regexp":278,"./modules/es6.set":279,"./modules/es6.string.code-point-at":280,"./modules/es6.string.ends-with":281,"./modules/es6.string.from-code-point":282,"./modules/es6.string.includes":283,"./modules/es6.string.iterator":284,"./modules/es6.string.raw":285,"./modules/es6.string.repeat":286,"./modules/es6.string.starts-with":287,"./modules/es6.symbol":288,"./modules/es6.weak-map":289,"./modules/es6.weak-set":290,"./modules/es7.array.includes":291,"./modules/es7.map.to-json":292,"./modules/es7.object.get-own-property-descriptors":293,"./modules/es7.object.to-array":294,"./modules/es7.regexp.escape":295,"./modules/es7.set.to-json":296,"./modules/es7.string.at":297,"./modules/js.array.statics":298,"./modules/web.dom.iterable":299,"./modules/web.immediate":300,"./modules/web.timers":301}],303:[function(require,module,exports){
  28991. /**
  28992. * This is the common logic for both the Node.js and web browser
  28993. * implementations of `debug()`.
  28994. *
  28995. * Expose `debug()` as the module.
  28996. */
  28997. exports = module.exports = debug;
  28998. exports.coerce = coerce;
  28999. exports.disable = disable;
  29000. exports.enable = enable;
  29001. exports.enabled = enabled;
  29002. exports.humanize = require('ms');
  29003. /**
  29004. * The currently active debug mode names, and names to skip.
  29005. */
  29006. exports.names = [];
  29007. exports.skips = [];
  29008. /**
  29009. * Map of special "%n" handling functions, for the debug "format" argument.
  29010. *
  29011. * Valid key names are a single, lowercased letter, i.e. "n".
  29012. */
  29013. exports.formatters = {};
  29014. /**
  29015. * Previously assigned color.
  29016. */
  29017. var prevColor = 0;
  29018. /**
  29019. * Previous log timestamp.
  29020. */
  29021. var prevTime;
  29022. /**
  29023. * Select a color.
  29024. *
  29025. * @return {Number}
  29026. * @api private
  29027. */
  29028. function selectColor() {
  29029. return exports.colors[prevColor++ % exports.colors.length];
  29030. }
  29031. /**
  29032. * Create a debugger with the given `namespace`.
  29033. *
  29034. * @param {String} namespace
  29035. * @return {Function}
  29036. * @api public
  29037. */
  29038. function debug(namespace) {
  29039. // define the `disabled` version
  29040. function disabled() {
  29041. }
  29042. disabled.enabled = false;
  29043. // define the `enabled` version
  29044. function enabled() {
  29045. var self = enabled;
  29046. // set `diff` timestamp
  29047. var curr = +new Date();
  29048. var ms = curr - (prevTime || curr);
  29049. self.diff = ms;
  29050. self.prev = prevTime;
  29051. self.curr = curr;
  29052. prevTime = curr;
  29053. // add the `color` if not set
  29054. if (null == self.useColors) self.useColors = exports.useColors();
  29055. if (null == self.color && self.useColors) self.color = selectColor();
  29056. var args = Array.prototype.slice.call(arguments);
  29057. args[0] = exports.coerce(args[0]);
  29058. if ('string' !== typeof args[0]) {
  29059. // anything else let's inspect with %o
  29060. args = ['%o'].concat(args);
  29061. }
  29062. // apply any `formatters` transformations
  29063. var index = 0;
  29064. args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
  29065. // if we encounter an escaped % then don't increase the array index
  29066. if (match === '%%') return match;
  29067. index++;
  29068. var formatter = exports.formatters[format];
  29069. if ('function' === typeof formatter) {
  29070. var val = args[index];
  29071. match = formatter.call(self, val);
  29072. // now we need to remove `args[index]` since it's inlined in the `format`
  29073. args.splice(index, 1);
  29074. index--;
  29075. }
  29076. return match;
  29077. });
  29078. if ('function' === typeof exports.formatArgs) {
  29079. args = exports.formatArgs.apply(self, args);
  29080. }
  29081. var logFn = enabled.log || exports.log || console.log.bind(console);
  29082. logFn.apply(self, args);
  29083. }
  29084. enabled.enabled = true;
  29085. var fn = exports.enabled(namespace) ? enabled : disabled;
  29086. fn.namespace = namespace;
  29087. return fn;
  29088. }
  29089. /**
  29090. * Enables a debug mode by namespaces. This can include modes
  29091. * separated by a colon and wildcards.
  29092. *
  29093. * @param {String} namespaces
  29094. * @api public
  29095. */
  29096. function enable(namespaces) {
  29097. exports.save(namespaces);
  29098. var split = (namespaces || '').split(/[\s,]+/);
  29099. var len = split.length;
  29100. for (var i = 0; i < len; i++) {
  29101. if (!split[i]) continue; // ignore empty strings
  29102. namespaces = split[i].replace(/\*/g, '.*?');
  29103. if (namespaces[0] === '-') {
  29104. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  29105. } else {
  29106. exports.names.push(new RegExp('^' + namespaces + '$'));
  29107. }
  29108. }
  29109. }
  29110. /**
  29111. * Disable debug output.
  29112. *
  29113. * @api public
  29114. */
  29115. function disable() {
  29116. exports.enable('');
  29117. }
  29118. /**
  29119. * Returns true if the given mode name is enabled, false otherwise.
  29120. *
  29121. * @param {String} name
  29122. * @return {Boolean}
  29123. * @api public
  29124. */
  29125. function enabled(name) {
  29126. var i, len;
  29127. for (i = 0, len = exports.skips.length; i < len; i++) {
  29128. if (exports.skips[i].test(name)) {
  29129. return false;
  29130. }
  29131. }
  29132. for (i = 0, len = exports.names.length; i < len; i++) {
  29133. if (exports.names[i].test(name)) {
  29134. return true;
  29135. }
  29136. }
  29137. return false;
  29138. }
  29139. /**
  29140. * Coerce `val`.
  29141. *
  29142. * @param {Mixed} val
  29143. * @return {Mixed}
  29144. * @api private
  29145. */
  29146. function coerce(val) {
  29147. if (val instanceof Error) return val.stack || val.message;
  29148. return val;
  29149. }
  29150. },{"ms":305}],304:[function(require,module,exports){
  29151. (function (process){
  29152. /**
  29153. * Module dependencies.
  29154. */
  29155. var tty = require('tty');
  29156. var util = require('util');
  29157. /**
  29158. * This is the Node.js implementation of `debug()`.
  29159. *
  29160. * Expose `debug()` as the module.
  29161. */
  29162. exports = module.exports = require('./debug');
  29163. exports.log = log;
  29164. exports.formatArgs = formatArgs;
  29165. exports.save = save;
  29166. exports.load = load;
  29167. exports.useColors = useColors;
  29168. /**
  29169. * Colors.
  29170. */
  29171. exports.colors = [6, 2, 3, 4, 5, 1];
  29172. /**
  29173. * The file descriptor to write the `debug()` calls to.
  29174. * Set the `DEBUG_FD` env variable to override with another value. i.e.:
  29175. *
  29176. * $ DEBUG_FD=3 node script.js 3>debug.log
  29177. */
  29178. var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
  29179. var stream = 1 === fd ? process.stdout :
  29180. 2 === fd ? process.stderr :
  29181. createWritableStdioStream(fd);
  29182. /**
  29183. * Is stdout a TTY? Colored output is enabled when `true`.
  29184. */
  29185. function useColors() {
  29186. var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
  29187. if (0 === debugColors.length) {
  29188. return tty.isatty(fd);
  29189. } else {
  29190. return '0' !== debugColors
  29191. && 'no' !== debugColors
  29192. && 'false' !== debugColors
  29193. && 'disabled' !== debugColors;
  29194. }
  29195. }
  29196. /**
  29197. * Map %o to `util.inspect()`, since Node doesn't do that out of the box.
  29198. */
  29199. var inspect = (4 === util.inspect.length ?
  29200. // node <= 0.8.x
  29201. function (v, colors) {
  29202. return util.inspect(v, void 0, void 0, colors);
  29203. } :
  29204. // node > 0.8.x
  29205. function (v, colors) {
  29206. return util.inspect(v, { colors: colors });
  29207. }
  29208. );
  29209. exports.formatters.o = function(v) {
  29210. return inspect(v, this.useColors)
  29211. .replace(/\s*\n\s*/g, ' ');
  29212. };
  29213. /**
  29214. * Adds ANSI color escape codes if enabled.
  29215. *
  29216. * @api public
  29217. */
  29218. function formatArgs() {
  29219. var args = arguments;
  29220. var useColors = this.useColors;
  29221. var name = this.namespace;
  29222. if (useColors) {
  29223. var c = this.color;
  29224. args[0] = ' \u001b[3' + c + ';1m' + name + ' '
  29225. + '\u001b[0m'
  29226. + args[0] + '\u001b[3' + c + 'm'
  29227. + ' +' + exports.humanize(this.diff) + '\u001b[0m';
  29228. } else {
  29229. args[0] = new Date().toUTCString()
  29230. + ' ' + name + ' ' + args[0];
  29231. }
  29232. return args;
  29233. }
  29234. /**
  29235. * Invokes `console.error()` with the specified arguments.
  29236. */
  29237. function log() {
  29238. return stream.write(util.format.apply(this, arguments) + '\n');
  29239. }
  29240. /**
  29241. * Save `namespaces`.
  29242. *
  29243. * @param {String} namespaces
  29244. * @api private
  29245. */
  29246. function save(namespaces) {
  29247. if (null == namespaces) {
  29248. // If you set a process.env field to null or undefined, it gets cast to the
  29249. // string 'null' or 'undefined'. Just delete instead.
  29250. delete process.env.DEBUG;
  29251. } else {
  29252. process.env.DEBUG = namespaces;
  29253. }
  29254. }
  29255. /**
  29256. * Load `namespaces`.
  29257. *
  29258. * @return {String} returns the previously persisted debug modes
  29259. * @api private
  29260. */
  29261. function load() {
  29262. return process.env.DEBUG;
  29263. }
  29264. /**
  29265. * Copied from `node/src/node.js`.
  29266. *
  29267. * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
  29268. * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
  29269. */
  29270. function createWritableStdioStream (fd) {
  29271. var stream;
  29272. var tty_wrap = process.binding('tty_wrap');
  29273. // Note stream._type is used for test-module-load-list.js
  29274. switch (tty_wrap.guessHandleType(fd)) {
  29275. case 'TTY':
  29276. stream = new tty.WriteStream(fd);
  29277. stream._type = 'tty';
  29278. // Hack to have stream not keep the event loop alive.
  29279. // See https://github.com/joyent/node/issues/1726
  29280. if (stream._handle && stream._handle.unref) {
  29281. stream._handle.unref();
  29282. }
  29283. break;
  29284. case 'FILE':
  29285. var fs = require('fs');
  29286. stream = new fs.SyncWriteStream(fd, { autoClose: false });
  29287. stream._type = 'fs';
  29288. break;
  29289. case 'PIPE':
  29290. case 'TCP':
  29291. var net = require('net');
  29292. stream = new net.Socket({
  29293. fd: fd,
  29294. readable: false,
  29295. writable: true
  29296. });
  29297. // FIXME Should probably have an option in net.Socket to create a
  29298. // stream from an existing fd which is writable only. But for now
  29299. // we'll just add this hack and set the `readable` member to false.
  29300. // Test: ./node test/fixtures/echo.js < /etc/passwd
  29301. stream.readable = false;
  29302. stream.read = null;
  29303. stream._type = 'pipe';
  29304. // FIXME Hack to have stream not keep the event loop alive.
  29305. // See https://github.com/joyent/node/issues/1726
  29306. if (stream._handle && stream._handle.unref) {
  29307. stream._handle.unref();
  29308. }
  29309. break;
  29310. default:
  29311. // Probably an error on in uv_guess_handle()
  29312. throw new Error('Implement me. Unknown stream file type!');
  29313. }
  29314. // For supporting legacy API we put the FD here.
  29315. stream.fd = fd;
  29316. stream._isStdio = true;
  29317. return stream;
  29318. }
  29319. /**
  29320. * Enable namespaces listed in `process.env.DEBUG` initially.
  29321. */
  29322. exports.enable(load());
  29323. }).call(this,require('_process'))
  29324. },{"./debug":303,"_process":200,"fs":189,"net":189,"tty":214,"util":216}],305:[function(require,module,exports){
  29325. /**
  29326. * Helpers.
  29327. */
  29328. var s = 1000;
  29329. var m = s * 60;
  29330. var h = m * 60;
  29331. var d = h * 24;
  29332. var y = d * 365.25;
  29333. /**
  29334. * Parse or format the given `val`.
  29335. *
  29336. * Options:
  29337. *
  29338. * - `long` verbose formatting [false]
  29339. *
  29340. * @param {String|Number} val
  29341. * @param {Object} options
  29342. * @return {String|Number}
  29343. * @api public
  29344. */
  29345. module.exports = function(val, options){
  29346. options = options || {};
  29347. if ('string' == typeof val) return parse(val);
  29348. return options.long
  29349. ? long(val)
  29350. : short(val);
  29351. };
  29352. /**
  29353. * Parse the given `str` and return milliseconds.
  29354. *
  29355. * @param {String} str
  29356. * @return {Number}
  29357. * @api private
  29358. */
  29359. function parse(str) {
  29360. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
  29361. if (!match) return;
  29362. var n = parseFloat(match[1]);
  29363. var type = (match[2] || 'ms').toLowerCase();
  29364. switch (type) {
  29365. case 'years':
  29366. case 'year':
  29367. case 'yrs':
  29368. case 'yr':
  29369. case 'y':
  29370. return n * y;
  29371. case 'days':
  29372. case 'day':
  29373. case 'd':
  29374. return n * d;
  29375. case 'hours':
  29376. case 'hour':
  29377. case 'hrs':
  29378. case 'hr':
  29379. case 'h':
  29380. return n * h;
  29381. case 'minutes':
  29382. case 'minute':
  29383. case 'mins':
  29384. case 'min':
  29385. case 'm':
  29386. return n * m;
  29387. case 'seconds':
  29388. case 'second':
  29389. case 'secs':
  29390. case 'sec':
  29391. case 's':
  29392. return n * s;
  29393. case 'milliseconds':
  29394. case 'millisecond':
  29395. case 'msecs':
  29396. case 'msec':
  29397. case 'ms':
  29398. return n;
  29399. }
  29400. }
  29401. /**
  29402. * Short format for `ms`.
  29403. *
  29404. * @param {Number} ms
  29405. * @return {String}
  29406. * @api private
  29407. */
  29408. function short(ms) {
  29409. if (ms >= d) return Math.round(ms / d) + 'd';
  29410. if (ms >= h) return Math.round(ms / h) + 'h';
  29411. if (ms >= m) return Math.round(ms / m) + 'm';
  29412. if (ms >= s) return Math.round(ms / s) + 's';
  29413. return ms + 'ms';
  29414. }
  29415. /**
  29416. * Long format for `ms`.
  29417. *
  29418. * @param {Number} ms
  29419. * @return {String}
  29420. * @api private
  29421. */
  29422. function long(ms) {
  29423. return plural(ms, d, 'day')
  29424. || plural(ms, h, 'hour')
  29425. || plural(ms, m, 'minute')
  29426. || plural(ms, s, 'second')
  29427. || ms + ' ms';
  29428. }
  29429. /**
  29430. * Pluralization helper.
  29431. */
  29432. function plural(ms, n, name) {
  29433. if (ms < n) return;
  29434. if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
  29435. return Math.ceil(ms / n) + ' ' + name + 's';
  29436. }
  29437. },{}],306:[function(require,module,exports){
  29438. 'use strict';
  29439. var repeating = require('repeating');
  29440. // detect either spaces or tabs but not both to properly handle tabs
  29441. // for indentation and spaces for alignment
  29442. var INDENT_RE = /^(?:( )+|\t+)/;
  29443. function getMostUsed(indents) {
  29444. var result = 0;
  29445. var maxUsed = 0;
  29446. var maxWeight = 0;
  29447. for (var n in indents) {
  29448. var indent = indents[n];
  29449. var u = indent[0];
  29450. var w = indent[1];
  29451. if (u > maxUsed || u === maxUsed && w > maxWeight) {
  29452. maxUsed = u;
  29453. maxWeight = w;
  29454. result = +n;
  29455. }
  29456. }
  29457. return result;
  29458. }
  29459. module.exports = function (str) {
  29460. if (typeof str !== 'string') {
  29461. throw new TypeError('Expected a string');
  29462. }
  29463. // used to see if tabs or spaces are the most used
  29464. var tabs = 0;
  29465. var spaces = 0;
  29466. // remember the size of previous line's indentation
  29467. var prev = 0;
  29468. // remember how many indents/unindents as occurred for a given size
  29469. // and how much lines follow a given indentation
  29470. //
  29471. // indents = {
  29472. // 3: [1, 0],
  29473. // 4: [1, 5],
  29474. // 5: [1, 0],
  29475. // 12: [1, 0],
  29476. // }
  29477. var indents = {};
  29478. // pointer to the array of last used indent
  29479. var current;
  29480. // whether the last action was an indent (opposed to an unindent)
  29481. var isIndent;
  29482. str.split(/\n/g).forEach(function (line) {
  29483. if (!line) {
  29484. // ignore empty lines
  29485. return;
  29486. }
  29487. var indent;
  29488. var matches = line.match(INDENT_RE);
  29489. if (!matches) {
  29490. indent = 0;
  29491. } else {
  29492. indent = matches[0].length;
  29493. if (matches[1]) {
  29494. spaces++;
  29495. } else {
  29496. tabs++;
  29497. }
  29498. }
  29499. var diff = indent - prev;
  29500. prev = indent;
  29501. if (diff) {
  29502. // an indent or unindent has been detected
  29503. isIndent = diff > 0;
  29504. current = indents[isIndent ? diff : -diff];
  29505. if (current) {
  29506. current[0]++;
  29507. } else {
  29508. current = indents[diff] = [1, 0];
  29509. }
  29510. } else if (current) {
  29511. // if the last action was an indent, increment the weight
  29512. current[1] += +isIndent;
  29513. }
  29514. });
  29515. var amount = getMostUsed(indents);
  29516. var type;
  29517. var actual;
  29518. if (!amount) {
  29519. type = null;
  29520. actual = '';
  29521. } else if (spaces >= tabs) {
  29522. type = 'space';
  29523. actual = repeating(' ', amount);
  29524. } else {
  29525. type = 'tab';
  29526. actual = repeating('\t', amount);
  29527. }
  29528. return {
  29529. amount: amount,
  29530. type: type,
  29531. indent: actual
  29532. };
  29533. };
  29534. },{"repeating":479}],307:[function(require,module,exports){
  29535. /* vim: set sw=4 sts=4 : */
  29536. (function () {
  29537. var estraverse = require('estraverse');
  29538. var parser = require('./parser');
  29539. var isArray = Array.isArray || function isArray(array) {
  29540. return {}.toString.call(array) === '[object Array]';
  29541. };
  29542. function esqueryModule() {
  29543. /**
  29544. * Get the value of a property which may be multiple levels down in the object.
  29545. */
  29546. function getPath(obj, key) {
  29547. var i, keys = key.split(".");
  29548. for (i = 0; i < keys.length; i++) {
  29549. if (obj == null) { return obj; }
  29550. obj = obj[keys[i]];
  29551. }
  29552. return obj;
  29553. }
  29554. /**
  29555. * Determine whether `node` can be reached by following `path`, starting at `ancestor`.
  29556. */
  29557. function inPath(node, ancestor, path) {
  29558. var field, remainingPath, i;
  29559. if (path.length === 0) { return node === ancestor; }
  29560. if (ancestor == null) { return false; }
  29561. field = ancestor[path[0]];
  29562. remainingPath = path.slice(1);
  29563. if (isArray(field)) {
  29564. for (i = 0, l = field.length; i < l; ++i) {
  29565. if (inPath(node, field[i], remainingPath)) { return true; }
  29566. }
  29567. return false;
  29568. } else {
  29569. return inPath(node, field, remainingPath);
  29570. }
  29571. }
  29572. /**
  29573. * Given a `node` and its ancestors, determine if `node` is matched by `selector`.
  29574. */
  29575. function matches(node, selector, ancestry) {
  29576. var path, ancestor, i, l, p;
  29577. if (!selector) { return true; }
  29578. if (!node) { return false; }
  29579. if (!ancestry) { ancestry = []; }
  29580. switch(selector.type) {
  29581. case 'wildcard':
  29582. return true;
  29583. case 'identifier':
  29584. return selector.value.toLowerCase() === node.type.toLowerCase();
  29585. case 'field':
  29586. path = selector.name.split('.');
  29587. ancestor = ancestry[path.length - 1];
  29588. return inPath(node, ancestor, path);
  29589. case 'matches':
  29590. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  29591. if (matches(node, selector.selectors[i], ancestry)) { return true; }
  29592. }
  29593. return false;
  29594. case 'compound':
  29595. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  29596. if (!matches(node, selector.selectors[i], ancestry)) { return false; }
  29597. }
  29598. return true;
  29599. case 'not':
  29600. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  29601. if (matches(node, selector.selectors[i], ancestry)) { return false; }
  29602. }
  29603. return true;
  29604. case 'child':
  29605. if (matches(node, selector.right, ancestry)) {
  29606. return matches(ancestry[0], selector.left, ancestry.slice(1));
  29607. }
  29608. return false;
  29609. case 'descendant':
  29610. if (matches(node, selector.right, ancestry)) {
  29611. for (i = 0, l = ancestry.length; i < l; ++i) {
  29612. if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) {
  29613. return true;
  29614. }
  29615. }
  29616. }
  29617. return false;
  29618. case 'attribute':
  29619. p = getPath(node, selector.name);
  29620. switch (selector.operator) {
  29621. case null:
  29622. case void 0:
  29623. return p != null;
  29624. case '=':
  29625. switch (selector.value.type) {
  29626. case 'regexp': return selector.value.value.test(p);
  29627. case 'literal': return '' + selector.value.value === '' + p;
  29628. case 'type': return selector.value.value === typeof p;
  29629. }
  29630. case '!=':
  29631. switch (selector.value.type) {
  29632. case 'regexp': return !selector.value.value.test(p);
  29633. case 'literal': return '' + selector.value.value !== '' + p;
  29634. case 'type': return selector.value.value !== typeof p;
  29635. }
  29636. case '<=': return p <= selector.value.value;
  29637. case '<': return p < selector.value.value;
  29638. case '>': return p > selector.value.value;
  29639. case '>=': return p >= selector.value.value;
  29640. }
  29641. case 'sibling':
  29642. return matches(node, selector.right, ancestry) &&
  29643. sibling(node, selector.left, ancestry) ||
  29644. matches(node, selector.left, ancestry) &&
  29645. sibling(node, selector.right, ancestry);
  29646. case 'adjacent':
  29647. return matches(node, selector.right, ancestry) &&
  29648. adjacent(node, selector.left, ancestry) ||
  29649. matches(node, selector.left, ancestry) &&
  29650. adjacent(node, selector.right, ancestry);
  29651. case 'nth-child':
  29652. return matches(node, selector.right, ancestry) &&
  29653. nthChild(node, ancestry, function (length) {
  29654. return selector.index.value - 1;
  29655. });
  29656. case 'nth-last-child':
  29657. return matches(node, selector.right, ancestry) &&
  29658. nthChild(node, ancestry, function (length) {
  29659. return length - selector.index.value;
  29660. });
  29661. case 'class':
  29662. if(!node.type) return false;
  29663. switch(selector.name.toLowerCase()){
  29664. case 'statement':
  29665. if(node.type.slice(-9) === 'Statement') return true;
  29666. // fallthrough: interface Declaration <: Statement { }
  29667. case 'declaration':
  29668. return node.type.slice(-11) === 'Declaration';
  29669. case 'pattern':
  29670. if(node.type.slice(-7) === 'Pattern') return true;
  29671. // fallthrough: interface Expression <: Node, Pattern { }
  29672. case 'expression':
  29673. return node.type.slice(-10) === 'Expression' ||
  29674. node.type === 'Literal' ||
  29675. node.type === 'Identifier';
  29676. case 'function':
  29677. return node.type.slice(0, 8) === 'Function' ||
  29678. node.type === 'ArrowFunctionExpression';
  29679. }
  29680. throw new Error('Unknown class name: ' + selector.name);
  29681. }
  29682. throw new Error('Unknown selector type: ' + selector.type);
  29683. }
  29684. /*
  29685. * Determines if the given node has a sibling that matches the given selector.
  29686. */
  29687. function sibling(node, selector, ancestry) {
  29688. var parent = ancestry[0], listProp, keys, i, l, k, m;
  29689. if (!parent) { return false; }
  29690. keys = estraverse.VisitorKeys[parent.type];
  29691. for (i = 0, l = keys.length; i < l; ++i) {
  29692. listProp = parent[keys[i]];
  29693. if (isArray(listProp)) {
  29694. for (k = 0, m = listProp.length; k < m; ++k) {
  29695. if (listProp[k] !== node && matches(listProp[k], selector, ancestry)) {
  29696. return true;
  29697. }
  29698. }
  29699. }
  29700. }
  29701. return false;
  29702. }
  29703. /*
  29704. * Determines if the given node has an asjacent sibling that matches the given selector.
  29705. */
  29706. function adjacent(node, selector, ancestry) {
  29707. var parent = ancestry[0], listProp, keys, i, l, idx;
  29708. if (!parent) { return false; }
  29709. keys = estraverse.VisitorKeys[parent.type];
  29710. for (i = 0, l = keys.length; i < l; ++i) {
  29711. listProp = parent[keys[i]];
  29712. if (isArray(listProp)) {
  29713. idx = listProp.indexOf(node);
  29714. if (idx < 0) { continue; }
  29715. if (idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
  29716. return true;
  29717. }
  29718. if (idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
  29719. return true;
  29720. }
  29721. }
  29722. }
  29723. return false;
  29724. }
  29725. /*
  29726. * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length.
  29727. */
  29728. function nthChild(node, ancestry, idxFn) {
  29729. var parent = ancestry[0], listProp, keys, i, l, idx;
  29730. if (!parent) { return false; }
  29731. keys = estraverse.VisitorKeys[parent.type];
  29732. for (i = 0, l = keys.length; i < l; ++i) {
  29733. listProp = parent[keys[i]];
  29734. if (isArray(listProp)) {
  29735. idx = listProp.indexOf(node);
  29736. if (idx >= 0 && idx === idxFn(listProp.length)) { return true; }
  29737. }
  29738. }
  29739. return false;
  29740. }
  29741. /*
  29742. * For each selector node marked as a subject, find the portion of the selector that the subject must match.
  29743. */
  29744. function subjects(selector, ancestor) {
  29745. var results, p;
  29746. if (selector == null || typeof selector != 'object') { return []; }
  29747. if (ancestor == null) { ancestor = selector; }
  29748. results = selector.subject ? [ancestor] : [];
  29749. for(p in selector) {
  29750. if(!{}.hasOwnProperty.call(selector, p)) { continue; }
  29751. [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor));
  29752. }
  29753. return results;
  29754. }
  29755. /**
  29756. * From a JS AST and a selector AST, collect all JS AST nodes that match the selector.
  29757. */
  29758. function match(ast, selector) {
  29759. var ancestry = [], results = [], altSubjects, i, l, k, m;
  29760. if (!selector) { return results; }
  29761. altSubjects = subjects(selector);
  29762. estraverse.traverse(ast, {
  29763. enter: function (node, parent) {
  29764. if (parent != null) { ancestry.unshift(parent); }
  29765. if (matches(node, selector, ancestry)) {
  29766. if (altSubjects.length) {
  29767. for (i = 0, l = altSubjects.length; i < l; ++i) {
  29768. if (matches(node, altSubjects[i], ancestry)) { results.push(node); }
  29769. for (k = 0, m = ancestry.length; k < m; ++k) {
  29770. if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
  29771. results.push(ancestry[k]);
  29772. }
  29773. }
  29774. }
  29775. } else {
  29776. results.push(node);
  29777. }
  29778. }
  29779. },
  29780. leave: function () { ancestry.shift(); }
  29781. });
  29782. return results;
  29783. }
  29784. /**
  29785. * Parse a selector string and return its AST.
  29786. */
  29787. function parse(selector) {
  29788. return parser.parse(selector);
  29789. }
  29790. /**
  29791. * Query the code AST using the selector string.
  29792. */
  29793. function query(ast, selector) {
  29794. return match(ast, parse(selector));
  29795. }
  29796. query.parse = parse;
  29797. query.match = match;
  29798. query.matches = matches;
  29799. return query.query = query;
  29800. }
  29801. if (typeof define === "function" && define.amd) {
  29802. define(esqueryModule);
  29803. } else if (typeof module !== 'undefined' && module.exports) {
  29804. module.exports = esqueryModule();
  29805. } else {
  29806. this.esquery = esqueryModule();
  29807. }
  29808. })();
  29809. },{"./parser":308,"estraverse":309}],308:[function(require,module,exports){
  29810. var result = (function(){
  29811. /*
  29812. * Generated by PEG.js 0.7.0.
  29813. *
  29814. * http://pegjs.majda.cz/
  29815. */
  29816. function quote(s) {
  29817. /*
  29818. * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
  29819. * string literal except for the closing quote character, backslash,
  29820. * carriage return, line separator, paragraph separator, and line feed.
  29821. * Any character may appear in the form of an escape sequence.
  29822. *
  29823. * For portability, we also escape escape all control and non-ASCII
  29824. * characters. Note that "\0" and "\v" escape sequences are not used
  29825. * because JSHint does not like the first and IE the second.
  29826. */
  29827. return '"' + s
  29828. .replace(/\\/g, '\\\\') // backslash
  29829. .replace(/"/g, '\\"') // closing quote character
  29830. .replace(/\x08/g, '\\b') // backspace
  29831. .replace(/\t/g, '\\t') // horizontal tab
  29832. .replace(/\n/g, '\\n') // line feed
  29833. .replace(/\f/g, '\\f') // form feed
  29834. .replace(/\r/g, '\\r') // carriage return
  29835. .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
  29836. + '"';
  29837. }
  29838. var result = {
  29839. /*
  29840. * Parses the input with a generated parser. If the parsing is successfull,
  29841. * returns a value explicitly or implicitly specified by the grammar from
  29842. * which the parser was generated (see |PEG.buildParser|). If the parsing is
  29843. * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
  29844. */
  29845. parse: function(input, startRule) {
  29846. var parseFunctions = {
  29847. "start": parse_start,
  29848. "_": parse__,
  29849. "identifierName": parse_identifierName,
  29850. "binaryOp": parse_binaryOp,
  29851. "selectors": parse_selectors,
  29852. "selector": parse_selector,
  29853. "sequence": parse_sequence,
  29854. "atom": parse_atom,
  29855. "wildcard": parse_wildcard,
  29856. "identifier": parse_identifier,
  29857. "attr": parse_attr,
  29858. "attrOps": parse_attrOps,
  29859. "attrEqOps": parse_attrEqOps,
  29860. "attrName": parse_attrName,
  29861. "attrValue": parse_attrValue,
  29862. "string": parse_string,
  29863. "number": parse_number,
  29864. "path": parse_path,
  29865. "type": parse_type,
  29866. "regex": parse_regex,
  29867. "field": parse_field,
  29868. "negation": parse_negation,
  29869. "matches": parse_matches,
  29870. "firstChild": parse_firstChild,
  29871. "lastChild": parse_lastChild,
  29872. "nthChild": parse_nthChild,
  29873. "nthLastChild": parse_nthLastChild,
  29874. "class": parse_class
  29875. };
  29876. if (startRule !== undefined) {
  29877. if (parseFunctions[startRule] === undefined) {
  29878. throw new Error("Invalid rule name: " + quote(startRule) + ".");
  29879. }
  29880. } else {
  29881. startRule = "start";
  29882. }
  29883. var pos = 0;
  29884. var reportFailures = 0;
  29885. var rightmostFailuresPos = 0;
  29886. var rightmostFailuresExpected = [];
  29887. var cache = {};
  29888. function padLeft(input, padding, length) {
  29889. var result = input;
  29890. var padLength = length - input.length;
  29891. for (var i = 0; i < padLength; i++) {
  29892. result = padding + result;
  29893. }
  29894. return result;
  29895. }
  29896. function escape(ch) {
  29897. var charCode = ch.charCodeAt(0);
  29898. var escapeChar;
  29899. var length;
  29900. if (charCode <= 0xFF) {
  29901. escapeChar = 'x';
  29902. length = 2;
  29903. } else {
  29904. escapeChar = 'u';
  29905. length = 4;
  29906. }
  29907. return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
  29908. }
  29909. function matchFailed(failure) {
  29910. if (pos < rightmostFailuresPos) {
  29911. return;
  29912. }
  29913. if (pos > rightmostFailuresPos) {
  29914. rightmostFailuresPos = pos;
  29915. rightmostFailuresExpected = [];
  29916. }
  29917. rightmostFailuresExpected.push(failure);
  29918. }
  29919. function parse_start() {
  29920. var cacheKey = "start@" + pos;
  29921. var cachedResult = cache[cacheKey];
  29922. if (cachedResult) {
  29923. pos = cachedResult.nextPos;
  29924. return cachedResult.result;
  29925. }
  29926. var result0, result1, result2;
  29927. var pos0, pos1;
  29928. pos0 = pos;
  29929. pos1 = pos;
  29930. result0 = parse__();
  29931. if (result0 !== null) {
  29932. result1 = parse_selectors();
  29933. if (result1 !== null) {
  29934. result2 = parse__();
  29935. if (result2 !== null) {
  29936. result0 = [result0, result1, result2];
  29937. } else {
  29938. result0 = null;
  29939. pos = pos1;
  29940. }
  29941. } else {
  29942. result0 = null;
  29943. pos = pos1;
  29944. }
  29945. } else {
  29946. result0 = null;
  29947. pos = pos1;
  29948. }
  29949. if (result0 !== null) {
  29950. result0 = (function(offset, ss) { return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss }; })(pos0, result0[1]);
  29951. }
  29952. if (result0 === null) {
  29953. pos = pos0;
  29954. }
  29955. if (result0 === null) {
  29956. pos0 = pos;
  29957. result0 = parse__();
  29958. if (result0 !== null) {
  29959. result0 = (function(offset) { return void 0; })(pos0);
  29960. }
  29961. if (result0 === null) {
  29962. pos = pos0;
  29963. }
  29964. }
  29965. cache[cacheKey] = {
  29966. nextPos: pos,
  29967. result: result0
  29968. };
  29969. return result0;
  29970. }
  29971. function parse__() {
  29972. var cacheKey = "_@" + pos;
  29973. var cachedResult = cache[cacheKey];
  29974. if (cachedResult) {
  29975. pos = cachedResult.nextPos;
  29976. return cachedResult.result;
  29977. }
  29978. var result0, result1;
  29979. result0 = [];
  29980. if (input.charCodeAt(pos) === 32) {
  29981. result1 = " ";
  29982. pos++;
  29983. } else {
  29984. result1 = null;
  29985. if (reportFailures === 0) {
  29986. matchFailed("\" \"");
  29987. }
  29988. }
  29989. while (result1 !== null) {
  29990. result0.push(result1);
  29991. if (input.charCodeAt(pos) === 32) {
  29992. result1 = " ";
  29993. pos++;
  29994. } else {
  29995. result1 = null;
  29996. if (reportFailures === 0) {
  29997. matchFailed("\" \"");
  29998. }
  29999. }
  30000. }
  30001. cache[cacheKey] = {
  30002. nextPos: pos,
  30003. result: result0
  30004. };
  30005. return result0;
  30006. }
  30007. function parse_identifierName() {
  30008. var cacheKey = "identifierName@" + pos;
  30009. var cachedResult = cache[cacheKey];
  30010. if (cachedResult) {
  30011. pos = cachedResult.nextPos;
  30012. return cachedResult.result;
  30013. }
  30014. var result0, result1;
  30015. var pos0;
  30016. pos0 = pos;
  30017. if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
  30018. result1 = input.charAt(pos);
  30019. pos++;
  30020. } else {
  30021. result1 = null;
  30022. if (reportFailures === 0) {
  30023. matchFailed("[^ [\\],():#!=><~+.]");
  30024. }
  30025. }
  30026. if (result1 !== null) {
  30027. result0 = [];
  30028. while (result1 !== null) {
  30029. result0.push(result1);
  30030. if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
  30031. result1 = input.charAt(pos);
  30032. pos++;
  30033. } else {
  30034. result1 = null;
  30035. if (reportFailures === 0) {
  30036. matchFailed("[^ [\\],():#!=><~+.]");
  30037. }
  30038. }
  30039. }
  30040. } else {
  30041. result0 = null;
  30042. }
  30043. if (result0 !== null) {
  30044. result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
  30045. }
  30046. if (result0 === null) {
  30047. pos = pos0;
  30048. }
  30049. cache[cacheKey] = {
  30050. nextPos: pos,
  30051. result: result0
  30052. };
  30053. return result0;
  30054. }
  30055. function parse_binaryOp() {
  30056. var cacheKey = "binaryOp@" + pos;
  30057. var cachedResult = cache[cacheKey];
  30058. if (cachedResult) {
  30059. pos = cachedResult.nextPos;
  30060. return cachedResult.result;
  30061. }
  30062. var result0, result1, result2;
  30063. var pos0, pos1;
  30064. pos0 = pos;
  30065. pos1 = pos;
  30066. result0 = parse__();
  30067. if (result0 !== null) {
  30068. if (input.charCodeAt(pos) === 62) {
  30069. result1 = ">";
  30070. pos++;
  30071. } else {
  30072. result1 = null;
  30073. if (reportFailures === 0) {
  30074. matchFailed("\">\"");
  30075. }
  30076. }
  30077. if (result1 !== null) {
  30078. result2 = parse__();
  30079. if (result2 !== null) {
  30080. result0 = [result0, result1, result2];
  30081. } else {
  30082. result0 = null;
  30083. pos = pos1;
  30084. }
  30085. } else {
  30086. result0 = null;
  30087. pos = pos1;
  30088. }
  30089. } else {
  30090. result0 = null;
  30091. pos = pos1;
  30092. }
  30093. if (result0 !== null) {
  30094. result0 = (function(offset) { return 'child'; })(pos0);
  30095. }
  30096. if (result0 === null) {
  30097. pos = pos0;
  30098. }
  30099. if (result0 === null) {
  30100. pos0 = pos;
  30101. pos1 = pos;
  30102. result0 = parse__();
  30103. if (result0 !== null) {
  30104. if (input.charCodeAt(pos) === 126) {
  30105. result1 = "~";
  30106. pos++;
  30107. } else {
  30108. result1 = null;
  30109. if (reportFailures === 0) {
  30110. matchFailed("\"~\"");
  30111. }
  30112. }
  30113. if (result1 !== null) {
  30114. result2 = parse__();
  30115. if (result2 !== null) {
  30116. result0 = [result0, result1, result2];
  30117. } else {
  30118. result0 = null;
  30119. pos = pos1;
  30120. }
  30121. } else {
  30122. result0 = null;
  30123. pos = pos1;
  30124. }
  30125. } else {
  30126. result0 = null;
  30127. pos = pos1;
  30128. }
  30129. if (result0 !== null) {
  30130. result0 = (function(offset) { return 'sibling'; })(pos0);
  30131. }
  30132. if (result0 === null) {
  30133. pos = pos0;
  30134. }
  30135. if (result0 === null) {
  30136. pos0 = pos;
  30137. pos1 = pos;
  30138. result0 = parse__();
  30139. if (result0 !== null) {
  30140. if (input.charCodeAt(pos) === 43) {
  30141. result1 = "+";
  30142. pos++;
  30143. } else {
  30144. result1 = null;
  30145. if (reportFailures === 0) {
  30146. matchFailed("\"+\"");
  30147. }
  30148. }
  30149. if (result1 !== null) {
  30150. result2 = parse__();
  30151. if (result2 !== null) {
  30152. result0 = [result0, result1, result2];
  30153. } else {
  30154. result0 = null;
  30155. pos = pos1;
  30156. }
  30157. } else {
  30158. result0 = null;
  30159. pos = pos1;
  30160. }
  30161. } else {
  30162. result0 = null;
  30163. pos = pos1;
  30164. }
  30165. if (result0 !== null) {
  30166. result0 = (function(offset) { return 'adjacent'; })(pos0);
  30167. }
  30168. if (result0 === null) {
  30169. pos = pos0;
  30170. }
  30171. if (result0 === null) {
  30172. pos0 = pos;
  30173. pos1 = pos;
  30174. if (input.charCodeAt(pos) === 32) {
  30175. result0 = " ";
  30176. pos++;
  30177. } else {
  30178. result0 = null;
  30179. if (reportFailures === 0) {
  30180. matchFailed("\" \"");
  30181. }
  30182. }
  30183. if (result0 !== null) {
  30184. result1 = parse__();
  30185. if (result1 !== null) {
  30186. result0 = [result0, result1];
  30187. } else {
  30188. result0 = null;
  30189. pos = pos1;
  30190. }
  30191. } else {
  30192. result0 = null;
  30193. pos = pos1;
  30194. }
  30195. if (result0 !== null) {
  30196. result0 = (function(offset) { return 'descendant'; })(pos0);
  30197. }
  30198. if (result0 === null) {
  30199. pos = pos0;
  30200. }
  30201. }
  30202. }
  30203. }
  30204. cache[cacheKey] = {
  30205. nextPos: pos,
  30206. result: result0
  30207. };
  30208. return result0;
  30209. }
  30210. function parse_selectors() {
  30211. var cacheKey = "selectors@" + pos;
  30212. var cachedResult = cache[cacheKey];
  30213. if (cachedResult) {
  30214. pos = cachedResult.nextPos;
  30215. return cachedResult.result;
  30216. }
  30217. var result0, result1, result2, result3, result4, result5;
  30218. var pos0, pos1, pos2;
  30219. pos0 = pos;
  30220. pos1 = pos;
  30221. result0 = parse_selector();
  30222. if (result0 !== null) {
  30223. result1 = [];
  30224. pos2 = pos;
  30225. result2 = parse__();
  30226. if (result2 !== null) {
  30227. if (input.charCodeAt(pos) === 44) {
  30228. result3 = ",";
  30229. pos++;
  30230. } else {
  30231. result3 = null;
  30232. if (reportFailures === 0) {
  30233. matchFailed("\",\"");
  30234. }
  30235. }
  30236. if (result3 !== null) {
  30237. result4 = parse__();
  30238. if (result4 !== null) {
  30239. result5 = parse_selector();
  30240. if (result5 !== null) {
  30241. result2 = [result2, result3, result4, result5];
  30242. } else {
  30243. result2 = null;
  30244. pos = pos2;
  30245. }
  30246. } else {
  30247. result2 = null;
  30248. pos = pos2;
  30249. }
  30250. } else {
  30251. result2 = null;
  30252. pos = pos2;
  30253. }
  30254. } else {
  30255. result2 = null;
  30256. pos = pos2;
  30257. }
  30258. while (result2 !== null) {
  30259. result1.push(result2);
  30260. pos2 = pos;
  30261. result2 = parse__();
  30262. if (result2 !== null) {
  30263. if (input.charCodeAt(pos) === 44) {
  30264. result3 = ",";
  30265. pos++;
  30266. } else {
  30267. result3 = null;
  30268. if (reportFailures === 0) {
  30269. matchFailed("\",\"");
  30270. }
  30271. }
  30272. if (result3 !== null) {
  30273. result4 = parse__();
  30274. if (result4 !== null) {
  30275. result5 = parse_selector();
  30276. if (result5 !== null) {
  30277. result2 = [result2, result3, result4, result5];
  30278. } else {
  30279. result2 = null;
  30280. pos = pos2;
  30281. }
  30282. } else {
  30283. result2 = null;
  30284. pos = pos2;
  30285. }
  30286. } else {
  30287. result2 = null;
  30288. pos = pos2;
  30289. }
  30290. } else {
  30291. result2 = null;
  30292. pos = pos2;
  30293. }
  30294. }
  30295. if (result1 !== null) {
  30296. result0 = [result0, result1];
  30297. } else {
  30298. result0 = null;
  30299. pos = pos1;
  30300. }
  30301. } else {
  30302. result0 = null;
  30303. pos = pos1;
  30304. }
  30305. if (result0 !== null) {
  30306. result0 = (function(offset, s, ss) {
  30307. return [s].concat(ss.map(function (s) { return s[3]; }));
  30308. })(pos0, result0[0], result0[1]);
  30309. }
  30310. if (result0 === null) {
  30311. pos = pos0;
  30312. }
  30313. cache[cacheKey] = {
  30314. nextPos: pos,
  30315. result: result0
  30316. };
  30317. return result0;
  30318. }
  30319. function parse_selector() {
  30320. var cacheKey = "selector@" + pos;
  30321. var cachedResult = cache[cacheKey];
  30322. if (cachedResult) {
  30323. pos = cachedResult.nextPos;
  30324. return cachedResult.result;
  30325. }
  30326. var result0, result1, result2, result3;
  30327. var pos0, pos1, pos2;
  30328. pos0 = pos;
  30329. pos1 = pos;
  30330. result0 = parse_sequence();
  30331. if (result0 !== null) {
  30332. result1 = [];
  30333. pos2 = pos;
  30334. result2 = parse_binaryOp();
  30335. if (result2 !== null) {
  30336. result3 = parse_sequence();
  30337. if (result3 !== null) {
  30338. result2 = [result2, result3];
  30339. } else {
  30340. result2 = null;
  30341. pos = pos2;
  30342. }
  30343. } else {
  30344. result2 = null;
  30345. pos = pos2;
  30346. }
  30347. while (result2 !== null) {
  30348. result1.push(result2);
  30349. pos2 = pos;
  30350. result2 = parse_binaryOp();
  30351. if (result2 !== null) {
  30352. result3 = parse_sequence();
  30353. if (result3 !== null) {
  30354. result2 = [result2, result3];
  30355. } else {
  30356. result2 = null;
  30357. pos = pos2;
  30358. }
  30359. } else {
  30360. result2 = null;
  30361. pos = pos2;
  30362. }
  30363. }
  30364. if (result1 !== null) {
  30365. result0 = [result0, result1];
  30366. } else {
  30367. result0 = null;
  30368. pos = pos1;
  30369. }
  30370. } else {
  30371. result0 = null;
  30372. pos = pos1;
  30373. }
  30374. if (result0 !== null) {
  30375. result0 = (function(offset, a, ops) {
  30376. return ops.reduce(function (memo, rhs) {
  30377. return { type: rhs[0], left: memo, right: rhs[1] };
  30378. }, a);
  30379. })(pos0, result0[0], result0[1]);
  30380. }
  30381. if (result0 === null) {
  30382. pos = pos0;
  30383. }
  30384. cache[cacheKey] = {
  30385. nextPos: pos,
  30386. result: result0
  30387. };
  30388. return result0;
  30389. }
  30390. function parse_sequence() {
  30391. var cacheKey = "sequence@" + pos;
  30392. var cachedResult = cache[cacheKey];
  30393. if (cachedResult) {
  30394. pos = cachedResult.nextPos;
  30395. return cachedResult.result;
  30396. }
  30397. var result0, result1, result2;
  30398. var pos0, pos1;
  30399. pos0 = pos;
  30400. pos1 = pos;
  30401. if (input.charCodeAt(pos) === 33) {
  30402. result0 = "!";
  30403. pos++;
  30404. } else {
  30405. result0 = null;
  30406. if (reportFailures === 0) {
  30407. matchFailed("\"!\"");
  30408. }
  30409. }
  30410. result0 = result0 !== null ? result0 : "";
  30411. if (result0 !== null) {
  30412. result2 = parse_atom();
  30413. if (result2 !== null) {
  30414. result1 = [];
  30415. while (result2 !== null) {
  30416. result1.push(result2);
  30417. result2 = parse_atom();
  30418. }
  30419. } else {
  30420. result1 = null;
  30421. }
  30422. if (result1 !== null) {
  30423. result0 = [result0, result1];
  30424. } else {
  30425. result0 = null;
  30426. pos = pos1;
  30427. }
  30428. } else {
  30429. result0 = null;
  30430. pos = pos1;
  30431. }
  30432. if (result0 !== null) {
  30433. result0 = (function(offset, subject, as) {
  30434. var b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
  30435. if(subject) b.subject = true;
  30436. return b;
  30437. })(pos0, result0[0], result0[1]);
  30438. }
  30439. if (result0 === null) {
  30440. pos = pos0;
  30441. }
  30442. cache[cacheKey] = {
  30443. nextPos: pos,
  30444. result: result0
  30445. };
  30446. return result0;
  30447. }
  30448. function parse_atom() {
  30449. var cacheKey = "atom@" + pos;
  30450. var cachedResult = cache[cacheKey];
  30451. if (cachedResult) {
  30452. pos = cachedResult.nextPos;
  30453. return cachedResult.result;
  30454. }
  30455. var result0;
  30456. result0 = parse_wildcard();
  30457. if (result0 === null) {
  30458. result0 = parse_identifier();
  30459. if (result0 === null) {
  30460. result0 = parse_attr();
  30461. if (result0 === null) {
  30462. result0 = parse_field();
  30463. if (result0 === null) {
  30464. result0 = parse_negation();
  30465. if (result0 === null) {
  30466. result0 = parse_matches();
  30467. if (result0 === null) {
  30468. result0 = parse_firstChild();
  30469. if (result0 === null) {
  30470. result0 = parse_lastChild();
  30471. if (result0 === null) {
  30472. result0 = parse_nthChild();
  30473. if (result0 === null) {
  30474. result0 = parse_nthLastChild();
  30475. if (result0 === null) {
  30476. result0 = parse_class();
  30477. }
  30478. }
  30479. }
  30480. }
  30481. }
  30482. }
  30483. }
  30484. }
  30485. }
  30486. }
  30487. cache[cacheKey] = {
  30488. nextPos: pos,
  30489. result: result0
  30490. };
  30491. return result0;
  30492. }
  30493. function parse_wildcard() {
  30494. var cacheKey = "wildcard@" + pos;
  30495. var cachedResult = cache[cacheKey];
  30496. if (cachedResult) {
  30497. pos = cachedResult.nextPos;
  30498. return cachedResult.result;
  30499. }
  30500. var result0;
  30501. var pos0;
  30502. pos0 = pos;
  30503. if (input.charCodeAt(pos) === 42) {
  30504. result0 = "*";
  30505. pos++;
  30506. } else {
  30507. result0 = null;
  30508. if (reportFailures === 0) {
  30509. matchFailed("\"*\"");
  30510. }
  30511. }
  30512. if (result0 !== null) {
  30513. result0 = (function(offset, a) { return { type: 'wildcard', value: a }; })(pos0, result0);
  30514. }
  30515. if (result0 === null) {
  30516. pos = pos0;
  30517. }
  30518. cache[cacheKey] = {
  30519. nextPos: pos,
  30520. result: result0
  30521. };
  30522. return result0;
  30523. }
  30524. function parse_identifier() {
  30525. var cacheKey = "identifier@" + pos;
  30526. var cachedResult = cache[cacheKey];
  30527. if (cachedResult) {
  30528. pos = cachedResult.nextPos;
  30529. return cachedResult.result;
  30530. }
  30531. var result0, result1;
  30532. var pos0, pos1;
  30533. pos0 = pos;
  30534. pos1 = pos;
  30535. if (input.charCodeAt(pos) === 35) {
  30536. result0 = "#";
  30537. pos++;
  30538. } else {
  30539. result0 = null;
  30540. if (reportFailures === 0) {
  30541. matchFailed("\"#\"");
  30542. }
  30543. }
  30544. result0 = result0 !== null ? result0 : "";
  30545. if (result0 !== null) {
  30546. result1 = parse_identifierName();
  30547. if (result1 !== null) {
  30548. result0 = [result0, result1];
  30549. } else {
  30550. result0 = null;
  30551. pos = pos1;
  30552. }
  30553. } else {
  30554. result0 = null;
  30555. pos = pos1;
  30556. }
  30557. if (result0 !== null) {
  30558. result0 = (function(offset, i) { return { type: 'identifier', value: i }; })(pos0, result0[1]);
  30559. }
  30560. if (result0 === null) {
  30561. pos = pos0;
  30562. }
  30563. cache[cacheKey] = {
  30564. nextPos: pos,
  30565. result: result0
  30566. };
  30567. return result0;
  30568. }
  30569. function parse_attr() {
  30570. var cacheKey = "attr@" + pos;
  30571. var cachedResult = cache[cacheKey];
  30572. if (cachedResult) {
  30573. pos = cachedResult.nextPos;
  30574. return cachedResult.result;
  30575. }
  30576. var result0, result1, result2, result3, result4;
  30577. var pos0, pos1;
  30578. pos0 = pos;
  30579. pos1 = pos;
  30580. if (input.charCodeAt(pos) === 91) {
  30581. result0 = "[";
  30582. pos++;
  30583. } else {
  30584. result0 = null;
  30585. if (reportFailures === 0) {
  30586. matchFailed("\"[\"");
  30587. }
  30588. }
  30589. if (result0 !== null) {
  30590. result1 = parse__();
  30591. if (result1 !== null) {
  30592. result2 = parse_attrValue();
  30593. if (result2 !== null) {
  30594. result3 = parse__();
  30595. if (result3 !== null) {
  30596. if (input.charCodeAt(pos) === 93) {
  30597. result4 = "]";
  30598. pos++;
  30599. } else {
  30600. result4 = null;
  30601. if (reportFailures === 0) {
  30602. matchFailed("\"]\"");
  30603. }
  30604. }
  30605. if (result4 !== null) {
  30606. result0 = [result0, result1, result2, result3, result4];
  30607. } else {
  30608. result0 = null;
  30609. pos = pos1;
  30610. }
  30611. } else {
  30612. result0 = null;
  30613. pos = pos1;
  30614. }
  30615. } else {
  30616. result0 = null;
  30617. pos = pos1;
  30618. }
  30619. } else {
  30620. result0 = null;
  30621. pos = pos1;
  30622. }
  30623. } else {
  30624. result0 = null;
  30625. pos = pos1;
  30626. }
  30627. if (result0 !== null) {
  30628. result0 = (function(offset, v) { return v; })(pos0, result0[2]);
  30629. }
  30630. if (result0 === null) {
  30631. pos = pos0;
  30632. }
  30633. cache[cacheKey] = {
  30634. nextPos: pos,
  30635. result: result0
  30636. };
  30637. return result0;
  30638. }
  30639. function parse_attrOps() {
  30640. var cacheKey = "attrOps@" + pos;
  30641. var cachedResult = cache[cacheKey];
  30642. if (cachedResult) {
  30643. pos = cachedResult.nextPos;
  30644. return cachedResult.result;
  30645. }
  30646. var result0, result1;
  30647. var pos0, pos1;
  30648. pos0 = pos;
  30649. pos1 = pos;
  30650. if (/^[><!]/.test(input.charAt(pos))) {
  30651. result0 = input.charAt(pos);
  30652. pos++;
  30653. } else {
  30654. result0 = null;
  30655. if (reportFailures === 0) {
  30656. matchFailed("[><!]");
  30657. }
  30658. }
  30659. result0 = result0 !== null ? result0 : "";
  30660. if (result0 !== null) {
  30661. if (input.charCodeAt(pos) === 61) {
  30662. result1 = "=";
  30663. pos++;
  30664. } else {
  30665. result1 = null;
  30666. if (reportFailures === 0) {
  30667. matchFailed("\"=\"");
  30668. }
  30669. }
  30670. if (result1 !== null) {
  30671. result0 = [result0, result1];
  30672. } else {
  30673. result0 = null;
  30674. pos = pos1;
  30675. }
  30676. } else {
  30677. result0 = null;
  30678. pos = pos1;
  30679. }
  30680. if (result0 !== null) {
  30681. result0 = (function(offset, a) { return a + '='; })(pos0, result0[0]);
  30682. }
  30683. if (result0 === null) {
  30684. pos = pos0;
  30685. }
  30686. if (result0 === null) {
  30687. if (/^[><]/.test(input.charAt(pos))) {
  30688. result0 = input.charAt(pos);
  30689. pos++;
  30690. } else {
  30691. result0 = null;
  30692. if (reportFailures === 0) {
  30693. matchFailed("[><]");
  30694. }
  30695. }
  30696. }
  30697. cache[cacheKey] = {
  30698. nextPos: pos,
  30699. result: result0
  30700. };
  30701. return result0;
  30702. }
  30703. function parse_attrEqOps() {
  30704. var cacheKey = "attrEqOps@" + pos;
  30705. var cachedResult = cache[cacheKey];
  30706. if (cachedResult) {
  30707. pos = cachedResult.nextPos;
  30708. return cachedResult.result;
  30709. }
  30710. var result0, result1;
  30711. var pos0, pos1;
  30712. pos0 = pos;
  30713. pos1 = pos;
  30714. if (input.charCodeAt(pos) === 33) {
  30715. result0 = "!";
  30716. pos++;
  30717. } else {
  30718. result0 = null;
  30719. if (reportFailures === 0) {
  30720. matchFailed("\"!\"");
  30721. }
  30722. }
  30723. result0 = result0 !== null ? result0 : "";
  30724. if (result0 !== null) {
  30725. if (input.charCodeAt(pos) === 61) {
  30726. result1 = "=";
  30727. pos++;
  30728. } else {
  30729. result1 = null;
  30730. if (reportFailures === 0) {
  30731. matchFailed("\"=\"");
  30732. }
  30733. }
  30734. if (result1 !== null) {
  30735. result0 = [result0, result1];
  30736. } else {
  30737. result0 = null;
  30738. pos = pos1;
  30739. }
  30740. } else {
  30741. result0 = null;
  30742. pos = pos1;
  30743. }
  30744. if (result0 !== null) {
  30745. result0 = (function(offset, a) { return a + '='; })(pos0, result0[0]);
  30746. }
  30747. if (result0 === null) {
  30748. pos = pos0;
  30749. }
  30750. cache[cacheKey] = {
  30751. nextPos: pos,
  30752. result: result0
  30753. };
  30754. return result0;
  30755. }
  30756. function parse_attrName() {
  30757. var cacheKey = "attrName@" + pos;
  30758. var cachedResult = cache[cacheKey];
  30759. if (cachedResult) {
  30760. pos = cachedResult.nextPos;
  30761. return cachedResult.result;
  30762. }
  30763. var result0, result1;
  30764. var pos0;
  30765. pos0 = pos;
  30766. result1 = parse_identifierName();
  30767. if (result1 === null) {
  30768. if (input.charCodeAt(pos) === 46) {
  30769. result1 = ".";
  30770. pos++;
  30771. } else {
  30772. result1 = null;
  30773. if (reportFailures === 0) {
  30774. matchFailed("\".\"");
  30775. }
  30776. }
  30777. }
  30778. if (result1 !== null) {
  30779. result0 = [];
  30780. while (result1 !== null) {
  30781. result0.push(result1);
  30782. result1 = parse_identifierName();
  30783. if (result1 === null) {
  30784. if (input.charCodeAt(pos) === 46) {
  30785. result1 = ".";
  30786. pos++;
  30787. } else {
  30788. result1 = null;
  30789. if (reportFailures === 0) {
  30790. matchFailed("\".\"");
  30791. }
  30792. }
  30793. }
  30794. }
  30795. } else {
  30796. result0 = null;
  30797. }
  30798. if (result0 !== null) {
  30799. result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
  30800. }
  30801. if (result0 === null) {
  30802. pos = pos0;
  30803. }
  30804. cache[cacheKey] = {
  30805. nextPos: pos,
  30806. result: result0
  30807. };
  30808. return result0;
  30809. }
  30810. function parse_attrValue() {
  30811. var cacheKey = "attrValue@" + pos;
  30812. var cachedResult = cache[cacheKey];
  30813. if (cachedResult) {
  30814. pos = cachedResult.nextPos;
  30815. return cachedResult.result;
  30816. }
  30817. var result0, result1, result2, result3, result4;
  30818. var pos0, pos1;
  30819. pos0 = pos;
  30820. pos1 = pos;
  30821. result0 = parse_attrName();
  30822. if (result0 !== null) {
  30823. result1 = parse__();
  30824. if (result1 !== null) {
  30825. result2 = parse_attrEqOps();
  30826. if (result2 !== null) {
  30827. result3 = parse__();
  30828. if (result3 !== null) {
  30829. result4 = parse_type();
  30830. if (result4 === null) {
  30831. result4 = parse_regex();
  30832. }
  30833. if (result4 !== null) {
  30834. result0 = [result0, result1, result2, result3, result4];
  30835. } else {
  30836. result0 = null;
  30837. pos = pos1;
  30838. }
  30839. } else {
  30840. result0 = null;
  30841. pos = pos1;
  30842. }
  30843. } else {
  30844. result0 = null;
  30845. pos = pos1;
  30846. }
  30847. } else {
  30848. result0 = null;
  30849. pos = pos1;
  30850. }
  30851. } else {
  30852. result0 = null;
  30853. pos = pos1;
  30854. }
  30855. if (result0 !== null) {
  30856. result0 = (function(offset, name, op, value) {
  30857. return { type: 'attribute', name: name, operator: op, value: value };
  30858. })(pos0, result0[0], result0[2], result0[4]);
  30859. }
  30860. if (result0 === null) {
  30861. pos = pos0;
  30862. }
  30863. if (result0 === null) {
  30864. pos0 = pos;
  30865. pos1 = pos;
  30866. result0 = parse_attrName();
  30867. if (result0 !== null) {
  30868. result1 = parse__();
  30869. if (result1 !== null) {
  30870. result2 = parse_attrOps();
  30871. if (result2 !== null) {
  30872. result3 = parse__();
  30873. if (result3 !== null) {
  30874. result4 = parse_string();
  30875. if (result4 === null) {
  30876. result4 = parse_number();
  30877. if (result4 === null) {
  30878. result4 = parse_path();
  30879. }
  30880. }
  30881. if (result4 !== null) {
  30882. result0 = [result0, result1, result2, result3, result4];
  30883. } else {
  30884. result0 = null;
  30885. pos = pos1;
  30886. }
  30887. } else {
  30888. result0 = null;
  30889. pos = pos1;
  30890. }
  30891. } else {
  30892. result0 = null;
  30893. pos = pos1;
  30894. }
  30895. } else {
  30896. result0 = null;
  30897. pos = pos1;
  30898. }
  30899. } else {
  30900. result0 = null;
  30901. pos = pos1;
  30902. }
  30903. if (result0 !== null) {
  30904. result0 = (function(offset, name, op, value) {
  30905. return { type: 'attribute', name: name, operator: op, value: value };
  30906. })(pos0, result0[0], result0[2], result0[4]);
  30907. }
  30908. if (result0 === null) {
  30909. pos = pos0;
  30910. }
  30911. if (result0 === null) {
  30912. pos0 = pos;
  30913. result0 = parse_attrName();
  30914. if (result0 !== null) {
  30915. result0 = (function(offset, name) { return { type: 'attribute', name: name }; })(pos0, result0);
  30916. }
  30917. if (result0 === null) {
  30918. pos = pos0;
  30919. }
  30920. }
  30921. }
  30922. cache[cacheKey] = {
  30923. nextPos: pos,
  30924. result: result0
  30925. };
  30926. return result0;
  30927. }
  30928. function parse_string() {
  30929. var cacheKey = "string@" + pos;
  30930. var cachedResult = cache[cacheKey];
  30931. if (cachedResult) {
  30932. pos = cachedResult.nextPos;
  30933. return cachedResult.result;
  30934. }
  30935. var result0, result1, result2, result3;
  30936. var pos0, pos1, pos2, pos3;
  30937. pos0 = pos;
  30938. pos1 = pos;
  30939. if (input.charCodeAt(pos) === 34) {
  30940. result0 = "\"";
  30941. pos++;
  30942. } else {
  30943. result0 = null;
  30944. if (reportFailures === 0) {
  30945. matchFailed("\"\\\"\"");
  30946. }
  30947. }
  30948. if (result0 !== null) {
  30949. result1 = [];
  30950. if (/^[^\\"]/.test(input.charAt(pos))) {
  30951. result2 = input.charAt(pos);
  30952. pos++;
  30953. } else {
  30954. result2 = null;
  30955. if (reportFailures === 0) {
  30956. matchFailed("[^\\\\\"]");
  30957. }
  30958. }
  30959. if (result2 === null) {
  30960. pos2 = pos;
  30961. pos3 = pos;
  30962. if (input.charCodeAt(pos) === 92) {
  30963. result2 = "\\";
  30964. pos++;
  30965. } else {
  30966. result2 = null;
  30967. if (reportFailures === 0) {
  30968. matchFailed("\"\\\\\"");
  30969. }
  30970. }
  30971. if (result2 !== null) {
  30972. if (input.length > pos) {
  30973. result3 = input.charAt(pos);
  30974. pos++;
  30975. } else {
  30976. result3 = null;
  30977. if (reportFailures === 0) {
  30978. matchFailed("any character");
  30979. }
  30980. }
  30981. if (result3 !== null) {
  30982. result2 = [result2, result3];
  30983. } else {
  30984. result2 = null;
  30985. pos = pos3;
  30986. }
  30987. } else {
  30988. result2 = null;
  30989. pos = pos3;
  30990. }
  30991. if (result2 !== null) {
  30992. result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
  30993. }
  30994. if (result2 === null) {
  30995. pos = pos2;
  30996. }
  30997. }
  30998. while (result2 !== null) {
  30999. result1.push(result2);
  31000. if (/^[^\\"]/.test(input.charAt(pos))) {
  31001. result2 = input.charAt(pos);
  31002. pos++;
  31003. } else {
  31004. result2 = null;
  31005. if (reportFailures === 0) {
  31006. matchFailed("[^\\\\\"]");
  31007. }
  31008. }
  31009. if (result2 === null) {
  31010. pos2 = pos;
  31011. pos3 = pos;
  31012. if (input.charCodeAt(pos) === 92) {
  31013. result2 = "\\";
  31014. pos++;
  31015. } else {
  31016. result2 = null;
  31017. if (reportFailures === 0) {
  31018. matchFailed("\"\\\\\"");
  31019. }
  31020. }
  31021. if (result2 !== null) {
  31022. if (input.length > pos) {
  31023. result3 = input.charAt(pos);
  31024. pos++;
  31025. } else {
  31026. result3 = null;
  31027. if (reportFailures === 0) {
  31028. matchFailed("any character");
  31029. }
  31030. }
  31031. if (result3 !== null) {
  31032. result2 = [result2, result3];
  31033. } else {
  31034. result2 = null;
  31035. pos = pos3;
  31036. }
  31037. } else {
  31038. result2 = null;
  31039. pos = pos3;
  31040. }
  31041. if (result2 !== null) {
  31042. result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
  31043. }
  31044. if (result2 === null) {
  31045. pos = pos2;
  31046. }
  31047. }
  31048. }
  31049. if (result1 !== null) {
  31050. if (input.charCodeAt(pos) === 34) {
  31051. result2 = "\"";
  31052. pos++;
  31053. } else {
  31054. result2 = null;
  31055. if (reportFailures === 0) {
  31056. matchFailed("\"\\\"\"");
  31057. }
  31058. }
  31059. if (result2 !== null) {
  31060. result0 = [result0, result1, result2];
  31061. } else {
  31062. result0 = null;
  31063. pos = pos1;
  31064. }
  31065. } else {
  31066. result0 = null;
  31067. pos = pos1;
  31068. }
  31069. } else {
  31070. result0 = null;
  31071. pos = pos1;
  31072. }
  31073. if (result0 !== null) {
  31074. result0 = (function(offset, d) {
  31075. return { type: 'literal', value: strUnescape(d.join('')) };
  31076. })(pos0, result0[1]);
  31077. }
  31078. if (result0 === null) {
  31079. pos = pos0;
  31080. }
  31081. if (result0 === null) {
  31082. pos0 = pos;
  31083. pos1 = pos;
  31084. if (input.charCodeAt(pos) === 39) {
  31085. result0 = "'";
  31086. pos++;
  31087. } else {
  31088. result0 = null;
  31089. if (reportFailures === 0) {
  31090. matchFailed("\"'\"");
  31091. }
  31092. }
  31093. if (result0 !== null) {
  31094. result1 = [];
  31095. if (/^[^\\']/.test(input.charAt(pos))) {
  31096. result2 = input.charAt(pos);
  31097. pos++;
  31098. } else {
  31099. result2 = null;
  31100. if (reportFailures === 0) {
  31101. matchFailed("[^\\\\']");
  31102. }
  31103. }
  31104. if (result2 === null) {
  31105. pos2 = pos;
  31106. pos3 = pos;
  31107. if (input.charCodeAt(pos) === 92) {
  31108. result2 = "\\";
  31109. pos++;
  31110. } else {
  31111. result2 = null;
  31112. if (reportFailures === 0) {
  31113. matchFailed("\"\\\\\"");
  31114. }
  31115. }
  31116. if (result2 !== null) {
  31117. if (input.length > pos) {
  31118. result3 = input.charAt(pos);
  31119. pos++;
  31120. } else {
  31121. result3 = null;
  31122. if (reportFailures === 0) {
  31123. matchFailed("any character");
  31124. }
  31125. }
  31126. if (result3 !== null) {
  31127. result2 = [result2, result3];
  31128. } else {
  31129. result2 = null;
  31130. pos = pos3;
  31131. }
  31132. } else {
  31133. result2 = null;
  31134. pos = pos3;
  31135. }
  31136. if (result2 !== null) {
  31137. result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
  31138. }
  31139. if (result2 === null) {
  31140. pos = pos2;
  31141. }
  31142. }
  31143. while (result2 !== null) {
  31144. result1.push(result2);
  31145. if (/^[^\\']/.test(input.charAt(pos))) {
  31146. result2 = input.charAt(pos);
  31147. pos++;
  31148. } else {
  31149. result2 = null;
  31150. if (reportFailures === 0) {
  31151. matchFailed("[^\\\\']");
  31152. }
  31153. }
  31154. if (result2 === null) {
  31155. pos2 = pos;
  31156. pos3 = pos;
  31157. if (input.charCodeAt(pos) === 92) {
  31158. result2 = "\\";
  31159. pos++;
  31160. } else {
  31161. result2 = null;
  31162. if (reportFailures === 0) {
  31163. matchFailed("\"\\\\\"");
  31164. }
  31165. }
  31166. if (result2 !== null) {
  31167. if (input.length > pos) {
  31168. result3 = input.charAt(pos);
  31169. pos++;
  31170. } else {
  31171. result3 = null;
  31172. if (reportFailures === 0) {
  31173. matchFailed("any character");
  31174. }
  31175. }
  31176. if (result3 !== null) {
  31177. result2 = [result2, result3];
  31178. } else {
  31179. result2 = null;
  31180. pos = pos3;
  31181. }
  31182. } else {
  31183. result2 = null;
  31184. pos = pos3;
  31185. }
  31186. if (result2 !== null) {
  31187. result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
  31188. }
  31189. if (result2 === null) {
  31190. pos = pos2;
  31191. }
  31192. }
  31193. }
  31194. if (result1 !== null) {
  31195. if (input.charCodeAt(pos) === 39) {
  31196. result2 = "'";
  31197. pos++;
  31198. } else {
  31199. result2 = null;
  31200. if (reportFailures === 0) {
  31201. matchFailed("\"'\"");
  31202. }
  31203. }
  31204. if (result2 !== null) {
  31205. result0 = [result0, result1, result2];
  31206. } else {
  31207. result0 = null;
  31208. pos = pos1;
  31209. }
  31210. } else {
  31211. result0 = null;
  31212. pos = pos1;
  31213. }
  31214. } else {
  31215. result0 = null;
  31216. pos = pos1;
  31217. }
  31218. if (result0 !== null) {
  31219. result0 = (function(offset, d) {
  31220. return { type: 'literal', value: strUnescape(d.join('')) };
  31221. })(pos0, result0[1]);
  31222. }
  31223. if (result0 === null) {
  31224. pos = pos0;
  31225. }
  31226. }
  31227. cache[cacheKey] = {
  31228. nextPos: pos,
  31229. result: result0
  31230. };
  31231. return result0;
  31232. }
  31233. function parse_number() {
  31234. var cacheKey = "number@" + pos;
  31235. var cachedResult = cache[cacheKey];
  31236. if (cachedResult) {
  31237. pos = cachedResult.nextPos;
  31238. return cachedResult.result;
  31239. }
  31240. var result0, result1, result2;
  31241. var pos0, pos1, pos2;
  31242. pos0 = pos;
  31243. pos1 = pos;
  31244. pos2 = pos;
  31245. result0 = [];
  31246. if (/^[0-9]/.test(input.charAt(pos))) {
  31247. result1 = input.charAt(pos);
  31248. pos++;
  31249. } else {
  31250. result1 = null;
  31251. if (reportFailures === 0) {
  31252. matchFailed("[0-9]");
  31253. }
  31254. }
  31255. while (result1 !== null) {
  31256. result0.push(result1);
  31257. if (/^[0-9]/.test(input.charAt(pos))) {
  31258. result1 = input.charAt(pos);
  31259. pos++;
  31260. } else {
  31261. result1 = null;
  31262. if (reportFailures === 0) {
  31263. matchFailed("[0-9]");
  31264. }
  31265. }
  31266. }
  31267. if (result0 !== null) {
  31268. if (input.charCodeAt(pos) === 46) {
  31269. result1 = ".";
  31270. pos++;
  31271. } else {
  31272. result1 = null;
  31273. if (reportFailures === 0) {
  31274. matchFailed("\".\"");
  31275. }
  31276. }
  31277. if (result1 !== null) {
  31278. result0 = [result0, result1];
  31279. } else {
  31280. result0 = null;
  31281. pos = pos2;
  31282. }
  31283. } else {
  31284. result0 = null;
  31285. pos = pos2;
  31286. }
  31287. result0 = result0 !== null ? result0 : "";
  31288. if (result0 !== null) {
  31289. if (/^[0-9]/.test(input.charAt(pos))) {
  31290. result2 = input.charAt(pos);
  31291. pos++;
  31292. } else {
  31293. result2 = null;
  31294. if (reportFailures === 0) {
  31295. matchFailed("[0-9]");
  31296. }
  31297. }
  31298. if (result2 !== null) {
  31299. result1 = [];
  31300. while (result2 !== null) {
  31301. result1.push(result2);
  31302. if (/^[0-9]/.test(input.charAt(pos))) {
  31303. result2 = input.charAt(pos);
  31304. pos++;
  31305. } else {
  31306. result2 = null;
  31307. if (reportFailures === 0) {
  31308. matchFailed("[0-9]");
  31309. }
  31310. }
  31311. }
  31312. } else {
  31313. result1 = null;
  31314. }
  31315. if (result1 !== null) {
  31316. result0 = [result0, result1];
  31317. } else {
  31318. result0 = null;
  31319. pos = pos1;
  31320. }
  31321. } else {
  31322. result0 = null;
  31323. pos = pos1;
  31324. }
  31325. if (result0 !== null) {
  31326. result0 = (function(offset, a, b) {
  31327. return { type: 'literal', value: parseFloat((a ? a.join('') : '') + b.join('')) };
  31328. })(pos0, result0[0], result0[1]);
  31329. }
  31330. if (result0 === null) {
  31331. pos = pos0;
  31332. }
  31333. cache[cacheKey] = {
  31334. nextPos: pos,
  31335. result: result0
  31336. };
  31337. return result0;
  31338. }
  31339. function parse_path() {
  31340. var cacheKey = "path@" + pos;
  31341. var cachedResult = cache[cacheKey];
  31342. if (cachedResult) {
  31343. pos = cachedResult.nextPos;
  31344. return cachedResult.result;
  31345. }
  31346. var result0;
  31347. var pos0;
  31348. pos0 = pos;
  31349. result0 = parse_identifierName();
  31350. if (result0 !== null) {
  31351. result0 = (function(offset, i) { return { type: 'literal', value: i }; })(pos0, result0);
  31352. }
  31353. if (result0 === null) {
  31354. pos = pos0;
  31355. }
  31356. cache[cacheKey] = {
  31357. nextPos: pos,
  31358. result: result0
  31359. };
  31360. return result0;
  31361. }
  31362. function parse_type() {
  31363. var cacheKey = "type@" + pos;
  31364. var cachedResult = cache[cacheKey];
  31365. if (cachedResult) {
  31366. pos = cachedResult.nextPos;
  31367. return cachedResult.result;
  31368. }
  31369. var result0, result1, result2, result3, result4;
  31370. var pos0, pos1;
  31371. pos0 = pos;
  31372. pos1 = pos;
  31373. if (input.substr(pos, 5) === "type(") {
  31374. result0 = "type(";
  31375. pos += 5;
  31376. } else {
  31377. result0 = null;
  31378. if (reportFailures === 0) {
  31379. matchFailed("\"type(\"");
  31380. }
  31381. }
  31382. if (result0 !== null) {
  31383. result1 = parse__();
  31384. if (result1 !== null) {
  31385. if (/^[^ )]/.test(input.charAt(pos))) {
  31386. result3 = input.charAt(pos);
  31387. pos++;
  31388. } else {
  31389. result3 = null;
  31390. if (reportFailures === 0) {
  31391. matchFailed("[^ )]");
  31392. }
  31393. }
  31394. if (result3 !== null) {
  31395. result2 = [];
  31396. while (result3 !== null) {
  31397. result2.push(result3);
  31398. if (/^[^ )]/.test(input.charAt(pos))) {
  31399. result3 = input.charAt(pos);
  31400. pos++;
  31401. } else {
  31402. result3 = null;
  31403. if (reportFailures === 0) {
  31404. matchFailed("[^ )]");
  31405. }
  31406. }
  31407. }
  31408. } else {
  31409. result2 = null;
  31410. }
  31411. if (result2 !== null) {
  31412. result3 = parse__();
  31413. if (result3 !== null) {
  31414. if (input.charCodeAt(pos) === 41) {
  31415. result4 = ")";
  31416. pos++;
  31417. } else {
  31418. result4 = null;
  31419. if (reportFailures === 0) {
  31420. matchFailed("\")\"");
  31421. }
  31422. }
  31423. if (result4 !== null) {
  31424. result0 = [result0, result1, result2, result3, result4];
  31425. } else {
  31426. result0 = null;
  31427. pos = pos1;
  31428. }
  31429. } else {
  31430. result0 = null;
  31431. pos = pos1;
  31432. }
  31433. } else {
  31434. result0 = null;
  31435. pos = pos1;
  31436. }
  31437. } else {
  31438. result0 = null;
  31439. pos = pos1;
  31440. }
  31441. } else {
  31442. result0 = null;
  31443. pos = pos1;
  31444. }
  31445. if (result0 !== null) {
  31446. result0 = (function(offset, t) { return { type: 'type', value: t.join('') }; })(pos0, result0[2]);
  31447. }
  31448. if (result0 === null) {
  31449. pos = pos0;
  31450. }
  31451. cache[cacheKey] = {
  31452. nextPos: pos,
  31453. result: result0
  31454. };
  31455. return result0;
  31456. }
  31457. function parse_regex() {
  31458. var cacheKey = "regex@" + pos;
  31459. var cachedResult = cache[cacheKey];
  31460. if (cachedResult) {
  31461. pos = cachedResult.nextPos;
  31462. return cachedResult.result;
  31463. }
  31464. var result0, result1, result2;
  31465. var pos0, pos1;
  31466. pos0 = pos;
  31467. pos1 = pos;
  31468. if (input.charCodeAt(pos) === 47) {
  31469. result0 = "/";
  31470. pos++;
  31471. } else {
  31472. result0 = null;
  31473. if (reportFailures === 0) {
  31474. matchFailed("\"/\"");
  31475. }
  31476. }
  31477. if (result0 !== null) {
  31478. if (/^[^\/]/.test(input.charAt(pos))) {
  31479. result2 = input.charAt(pos);
  31480. pos++;
  31481. } else {
  31482. result2 = null;
  31483. if (reportFailures === 0) {
  31484. matchFailed("[^\\/]");
  31485. }
  31486. }
  31487. if (result2 !== null) {
  31488. result1 = [];
  31489. while (result2 !== null) {
  31490. result1.push(result2);
  31491. if (/^[^\/]/.test(input.charAt(pos))) {
  31492. result2 = input.charAt(pos);
  31493. pos++;
  31494. } else {
  31495. result2 = null;
  31496. if (reportFailures === 0) {
  31497. matchFailed("[^\\/]");
  31498. }
  31499. }
  31500. }
  31501. } else {
  31502. result1 = null;
  31503. }
  31504. if (result1 !== null) {
  31505. if (input.charCodeAt(pos) === 47) {
  31506. result2 = "/";
  31507. pos++;
  31508. } else {
  31509. result2 = null;
  31510. if (reportFailures === 0) {
  31511. matchFailed("\"/\"");
  31512. }
  31513. }
  31514. if (result2 !== null) {
  31515. result0 = [result0, result1, result2];
  31516. } else {
  31517. result0 = null;
  31518. pos = pos1;
  31519. }
  31520. } else {
  31521. result0 = null;
  31522. pos = pos1;
  31523. }
  31524. } else {
  31525. result0 = null;
  31526. pos = pos1;
  31527. }
  31528. if (result0 !== null) {
  31529. result0 = (function(offset, d) { return { type: 'regexp', value: new RegExp(d.join('')) }; })(pos0, result0[1]);
  31530. }
  31531. if (result0 === null) {
  31532. pos = pos0;
  31533. }
  31534. cache[cacheKey] = {
  31535. nextPos: pos,
  31536. result: result0
  31537. };
  31538. return result0;
  31539. }
  31540. function parse_field() {
  31541. var cacheKey = "field@" + pos;
  31542. var cachedResult = cache[cacheKey];
  31543. if (cachedResult) {
  31544. pos = cachedResult.nextPos;
  31545. return cachedResult.result;
  31546. }
  31547. var result0, result1, result2, result3, result4;
  31548. var pos0, pos1, pos2;
  31549. pos0 = pos;
  31550. pos1 = pos;
  31551. if (input.charCodeAt(pos) === 46) {
  31552. result0 = ".";
  31553. pos++;
  31554. } else {
  31555. result0 = null;
  31556. if (reportFailures === 0) {
  31557. matchFailed("\".\"");
  31558. }
  31559. }
  31560. if (result0 !== null) {
  31561. result1 = parse_identifierName();
  31562. if (result1 !== null) {
  31563. result2 = [];
  31564. pos2 = pos;
  31565. if (input.charCodeAt(pos) === 46) {
  31566. result3 = ".";
  31567. pos++;
  31568. } else {
  31569. result3 = null;
  31570. if (reportFailures === 0) {
  31571. matchFailed("\".\"");
  31572. }
  31573. }
  31574. if (result3 !== null) {
  31575. result4 = parse_identifierName();
  31576. if (result4 !== null) {
  31577. result3 = [result3, result4];
  31578. } else {
  31579. result3 = null;
  31580. pos = pos2;
  31581. }
  31582. } else {
  31583. result3 = null;
  31584. pos = pos2;
  31585. }
  31586. while (result3 !== null) {
  31587. result2.push(result3);
  31588. pos2 = pos;
  31589. if (input.charCodeAt(pos) === 46) {
  31590. result3 = ".";
  31591. pos++;
  31592. } else {
  31593. result3 = null;
  31594. if (reportFailures === 0) {
  31595. matchFailed("\".\"");
  31596. }
  31597. }
  31598. if (result3 !== null) {
  31599. result4 = parse_identifierName();
  31600. if (result4 !== null) {
  31601. result3 = [result3, result4];
  31602. } else {
  31603. result3 = null;
  31604. pos = pos2;
  31605. }
  31606. } else {
  31607. result3 = null;
  31608. pos = pos2;
  31609. }
  31610. }
  31611. if (result2 !== null) {
  31612. result0 = [result0, result1, result2];
  31613. } else {
  31614. result0 = null;
  31615. pos = pos1;
  31616. }
  31617. } else {
  31618. result0 = null;
  31619. pos = pos1;
  31620. }
  31621. } else {
  31622. result0 = null;
  31623. pos = pos1;
  31624. }
  31625. if (result0 !== null) {
  31626. result0 = (function(offset, i, is) {
  31627. return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
  31628. })(pos0, result0[1], result0[2]);
  31629. }
  31630. if (result0 === null) {
  31631. pos = pos0;
  31632. }
  31633. cache[cacheKey] = {
  31634. nextPos: pos,
  31635. result: result0
  31636. };
  31637. return result0;
  31638. }
  31639. function parse_negation() {
  31640. var cacheKey = "negation@" + pos;
  31641. var cachedResult = cache[cacheKey];
  31642. if (cachedResult) {
  31643. pos = cachedResult.nextPos;
  31644. return cachedResult.result;
  31645. }
  31646. var result0, result1, result2, result3, result4;
  31647. var pos0, pos1;
  31648. pos0 = pos;
  31649. pos1 = pos;
  31650. if (input.substr(pos, 5) === ":not(") {
  31651. result0 = ":not(";
  31652. pos += 5;
  31653. } else {
  31654. result0 = null;
  31655. if (reportFailures === 0) {
  31656. matchFailed("\":not(\"");
  31657. }
  31658. }
  31659. if (result0 !== null) {
  31660. result1 = parse__();
  31661. if (result1 !== null) {
  31662. result2 = parse_selectors();
  31663. if (result2 !== null) {
  31664. result3 = parse__();
  31665. if (result3 !== null) {
  31666. if (input.charCodeAt(pos) === 41) {
  31667. result4 = ")";
  31668. pos++;
  31669. } else {
  31670. result4 = null;
  31671. if (reportFailures === 0) {
  31672. matchFailed("\")\"");
  31673. }
  31674. }
  31675. if (result4 !== null) {
  31676. result0 = [result0, result1, result2, result3, result4];
  31677. } else {
  31678. result0 = null;
  31679. pos = pos1;
  31680. }
  31681. } else {
  31682. result0 = null;
  31683. pos = pos1;
  31684. }
  31685. } else {
  31686. result0 = null;
  31687. pos = pos1;
  31688. }
  31689. } else {
  31690. result0 = null;
  31691. pos = pos1;
  31692. }
  31693. } else {
  31694. result0 = null;
  31695. pos = pos1;
  31696. }
  31697. if (result0 !== null) {
  31698. result0 = (function(offset, ss) { return { type: 'not', selectors: ss }; })(pos0, result0[2]);
  31699. }
  31700. if (result0 === null) {
  31701. pos = pos0;
  31702. }
  31703. cache[cacheKey] = {
  31704. nextPos: pos,
  31705. result: result0
  31706. };
  31707. return result0;
  31708. }
  31709. function parse_matches() {
  31710. var cacheKey = "matches@" + pos;
  31711. var cachedResult = cache[cacheKey];
  31712. if (cachedResult) {
  31713. pos = cachedResult.nextPos;
  31714. return cachedResult.result;
  31715. }
  31716. var result0, result1, result2, result3, result4;
  31717. var pos0, pos1;
  31718. pos0 = pos;
  31719. pos1 = pos;
  31720. if (input.substr(pos, 9) === ":matches(") {
  31721. result0 = ":matches(";
  31722. pos += 9;
  31723. } else {
  31724. result0 = null;
  31725. if (reportFailures === 0) {
  31726. matchFailed("\":matches(\"");
  31727. }
  31728. }
  31729. if (result0 !== null) {
  31730. result1 = parse__();
  31731. if (result1 !== null) {
  31732. result2 = parse_selectors();
  31733. if (result2 !== null) {
  31734. result3 = parse__();
  31735. if (result3 !== null) {
  31736. if (input.charCodeAt(pos) === 41) {
  31737. result4 = ")";
  31738. pos++;
  31739. } else {
  31740. result4 = null;
  31741. if (reportFailures === 0) {
  31742. matchFailed("\")\"");
  31743. }
  31744. }
  31745. if (result4 !== null) {
  31746. result0 = [result0, result1, result2, result3, result4];
  31747. } else {
  31748. result0 = null;
  31749. pos = pos1;
  31750. }
  31751. } else {
  31752. result0 = null;
  31753. pos = pos1;
  31754. }
  31755. } else {
  31756. result0 = null;
  31757. pos = pos1;
  31758. }
  31759. } else {
  31760. result0 = null;
  31761. pos = pos1;
  31762. }
  31763. } else {
  31764. result0 = null;
  31765. pos = pos1;
  31766. }
  31767. if (result0 !== null) {
  31768. result0 = (function(offset, ss) { return { type: 'matches', selectors: ss }; })(pos0, result0[2]);
  31769. }
  31770. if (result0 === null) {
  31771. pos = pos0;
  31772. }
  31773. cache[cacheKey] = {
  31774. nextPos: pos,
  31775. result: result0
  31776. };
  31777. return result0;
  31778. }
  31779. function parse_firstChild() {
  31780. var cacheKey = "firstChild@" + pos;
  31781. var cachedResult = cache[cacheKey];
  31782. if (cachedResult) {
  31783. pos = cachedResult.nextPos;
  31784. return cachedResult.result;
  31785. }
  31786. var result0;
  31787. var pos0;
  31788. pos0 = pos;
  31789. if (input.substr(pos, 12) === ":first-child") {
  31790. result0 = ":first-child";
  31791. pos += 12;
  31792. } else {
  31793. result0 = null;
  31794. if (reportFailures === 0) {
  31795. matchFailed("\":first-child\"");
  31796. }
  31797. }
  31798. if (result0 !== null) {
  31799. result0 = (function(offset) { return nth(1); })(pos0);
  31800. }
  31801. if (result0 === null) {
  31802. pos = pos0;
  31803. }
  31804. cache[cacheKey] = {
  31805. nextPos: pos,
  31806. result: result0
  31807. };
  31808. return result0;
  31809. }
  31810. function parse_lastChild() {
  31811. var cacheKey = "lastChild@" + pos;
  31812. var cachedResult = cache[cacheKey];
  31813. if (cachedResult) {
  31814. pos = cachedResult.nextPos;
  31815. return cachedResult.result;
  31816. }
  31817. var result0;
  31818. var pos0;
  31819. pos0 = pos;
  31820. if (input.substr(pos, 11) === ":last-child") {
  31821. result0 = ":last-child";
  31822. pos += 11;
  31823. } else {
  31824. result0 = null;
  31825. if (reportFailures === 0) {
  31826. matchFailed("\":last-child\"");
  31827. }
  31828. }
  31829. if (result0 !== null) {
  31830. result0 = (function(offset) { return nthLast(1); })(pos0);
  31831. }
  31832. if (result0 === null) {
  31833. pos = pos0;
  31834. }
  31835. cache[cacheKey] = {
  31836. nextPos: pos,
  31837. result: result0
  31838. };
  31839. return result0;
  31840. }
  31841. function parse_nthChild() {
  31842. var cacheKey = "nthChild@" + pos;
  31843. var cachedResult = cache[cacheKey];
  31844. if (cachedResult) {
  31845. pos = cachedResult.nextPos;
  31846. return cachedResult.result;
  31847. }
  31848. var result0, result1, result2, result3, result4;
  31849. var pos0, pos1;
  31850. pos0 = pos;
  31851. pos1 = pos;
  31852. if (input.substr(pos, 11) === ":nth-child(") {
  31853. result0 = ":nth-child(";
  31854. pos += 11;
  31855. } else {
  31856. result0 = null;
  31857. if (reportFailures === 0) {
  31858. matchFailed("\":nth-child(\"");
  31859. }
  31860. }
  31861. if (result0 !== null) {
  31862. result1 = parse__();
  31863. if (result1 !== null) {
  31864. if (/^[0-9]/.test(input.charAt(pos))) {
  31865. result3 = input.charAt(pos);
  31866. pos++;
  31867. } else {
  31868. result3 = null;
  31869. if (reportFailures === 0) {
  31870. matchFailed("[0-9]");
  31871. }
  31872. }
  31873. if (result3 !== null) {
  31874. result2 = [];
  31875. while (result3 !== null) {
  31876. result2.push(result3);
  31877. if (/^[0-9]/.test(input.charAt(pos))) {
  31878. result3 = input.charAt(pos);
  31879. pos++;
  31880. } else {
  31881. result3 = null;
  31882. if (reportFailures === 0) {
  31883. matchFailed("[0-9]");
  31884. }
  31885. }
  31886. }
  31887. } else {
  31888. result2 = null;
  31889. }
  31890. if (result2 !== null) {
  31891. result3 = parse__();
  31892. if (result3 !== null) {
  31893. if (input.charCodeAt(pos) === 41) {
  31894. result4 = ")";
  31895. pos++;
  31896. } else {
  31897. result4 = null;
  31898. if (reportFailures === 0) {
  31899. matchFailed("\")\"");
  31900. }
  31901. }
  31902. if (result4 !== null) {
  31903. result0 = [result0, result1, result2, result3, result4];
  31904. } else {
  31905. result0 = null;
  31906. pos = pos1;
  31907. }
  31908. } else {
  31909. result0 = null;
  31910. pos = pos1;
  31911. }
  31912. } else {
  31913. result0 = null;
  31914. pos = pos1;
  31915. }
  31916. } else {
  31917. result0 = null;
  31918. pos = pos1;
  31919. }
  31920. } else {
  31921. result0 = null;
  31922. pos = pos1;
  31923. }
  31924. if (result0 !== null) {
  31925. result0 = (function(offset, n) { return nth(parseInt(n.join(''), 10)); })(pos0, result0[2]);
  31926. }
  31927. if (result0 === null) {
  31928. pos = pos0;
  31929. }
  31930. cache[cacheKey] = {
  31931. nextPos: pos,
  31932. result: result0
  31933. };
  31934. return result0;
  31935. }
  31936. function parse_nthLastChild() {
  31937. var cacheKey = "nthLastChild@" + pos;
  31938. var cachedResult = cache[cacheKey];
  31939. if (cachedResult) {
  31940. pos = cachedResult.nextPos;
  31941. return cachedResult.result;
  31942. }
  31943. var result0, result1, result2, result3, result4;
  31944. var pos0, pos1;
  31945. pos0 = pos;
  31946. pos1 = pos;
  31947. if (input.substr(pos, 16) === ":nth-last-child(") {
  31948. result0 = ":nth-last-child(";
  31949. pos += 16;
  31950. } else {
  31951. result0 = null;
  31952. if (reportFailures === 0) {
  31953. matchFailed("\":nth-last-child(\"");
  31954. }
  31955. }
  31956. if (result0 !== null) {
  31957. result1 = parse__();
  31958. if (result1 !== null) {
  31959. if (/^[0-9]/.test(input.charAt(pos))) {
  31960. result3 = input.charAt(pos);
  31961. pos++;
  31962. } else {
  31963. result3 = null;
  31964. if (reportFailures === 0) {
  31965. matchFailed("[0-9]");
  31966. }
  31967. }
  31968. if (result3 !== null) {
  31969. result2 = [];
  31970. while (result3 !== null) {
  31971. result2.push(result3);
  31972. if (/^[0-9]/.test(input.charAt(pos))) {
  31973. result3 = input.charAt(pos);
  31974. pos++;
  31975. } else {
  31976. result3 = null;
  31977. if (reportFailures === 0) {
  31978. matchFailed("[0-9]");
  31979. }
  31980. }
  31981. }
  31982. } else {
  31983. result2 = null;
  31984. }
  31985. if (result2 !== null) {
  31986. result3 = parse__();
  31987. if (result3 !== null) {
  31988. if (input.charCodeAt(pos) === 41) {
  31989. result4 = ")";
  31990. pos++;
  31991. } else {
  31992. result4 = null;
  31993. if (reportFailures === 0) {
  31994. matchFailed("\")\"");
  31995. }
  31996. }
  31997. if (result4 !== null) {
  31998. result0 = [result0, result1, result2, result3, result4];
  31999. } else {
  32000. result0 = null;
  32001. pos = pos1;
  32002. }
  32003. } else {
  32004. result0 = null;
  32005. pos = pos1;
  32006. }
  32007. } else {
  32008. result0 = null;
  32009. pos = pos1;
  32010. }
  32011. } else {
  32012. result0 = null;
  32013. pos = pos1;
  32014. }
  32015. } else {
  32016. result0 = null;
  32017. pos = pos1;
  32018. }
  32019. if (result0 !== null) {
  32020. result0 = (function(offset, n) { return nthLast(parseInt(n.join(''), 10)); })(pos0, result0[2]);
  32021. }
  32022. if (result0 === null) {
  32023. pos = pos0;
  32024. }
  32025. cache[cacheKey] = {
  32026. nextPos: pos,
  32027. result: result0
  32028. };
  32029. return result0;
  32030. }
  32031. function parse_class() {
  32032. var cacheKey = "class@" + pos;
  32033. var cachedResult = cache[cacheKey];
  32034. if (cachedResult) {
  32035. pos = cachedResult.nextPos;
  32036. return cachedResult.result;
  32037. }
  32038. var result0, result1;
  32039. var pos0, pos1;
  32040. pos0 = pos;
  32041. pos1 = pos;
  32042. if (input.charCodeAt(pos) === 58) {
  32043. result0 = ":";
  32044. pos++;
  32045. } else {
  32046. result0 = null;
  32047. if (reportFailures === 0) {
  32048. matchFailed("\":\"");
  32049. }
  32050. }
  32051. if (result0 !== null) {
  32052. if (input.substr(pos, 9).toLowerCase() === "statement") {
  32053. result1 = input.substr(pos, 9);
  32054. pos += 9;
  32055. } else {
  32056. result1 = null;
  32057. if (reportFailures === 0) {
  32058. matchFailed("\"statement\"");
  32059. }
  32060. }
  32061. if (result1 === null) {
  32062. if (input.substr(pos, 10).toLowerCase() === "expression") {
  32063. result1 = input.substr(pos, 10);
  32064. pos += 10;
  32065. } else {
  32066. result1 = null;
  32067. if (reportFailures === 0) {
  32068. matchFailed("\"expression\"");
  32069. }
  32070. }
  32071. if (result1 === null) {
  32072. if (input.substr(pos, 11).toLowerCase() === "declaration") {
  32073. result1 = input.substr(pos, 11);
  32074. pos += 11;
  32075. } else {
  32076. result1 = null;
  32077. if (reportFailures === 0) {
  32078. matchFailed("\"declaration\"");
  32079. }
  32080. }
  32081. if (result1 === null) {
  32082. if (input.substr(pos, 8).toLowerCase() === "function") {
  32083. result1 = input.substr(pos, 8);
  32084. pos += 8;
  32085. } else {
  32086. result1 = null;
  32087. if (reportFailures === 0) {
  32088. matchFailed("\"function\"");
  32089. }
  32090. }
  32091. if (result1 === null) {
  32092. if (input.substr(pos, 7).toLowerCase() === "pattern") {
  32093. result1 = input.substr(pos, 7);
  32094. pos += 7;
  32095. } else {
  32096. result1 = null;
  32097. if (reportFailures === 0) {
  32098. matchFailed("\"pattern\"");
  32099. }
  32100. }
  32101. }
  32102. }
  32103. }
  32104. }
  32105. if (result1 !== null) {
  32106. result0 = [result0, result1];
  32107. } else {
  32108. result0 = null;
  32109. pos = pos1;
  32110. }
  32111. } else {
  32112. result0 = null;
  32113. pos = pos1;
  32114. }
  32115. if (result0 !== null) {
  32116. result0 = (function(offset, c) {
  32117. return { type: 'class', name: c };
  32118. })(pos0, result0[1]);
  32119. }
  32120. if (result0 === null) {
  32121. pos = pos0;
  32122. }
  32123. cache[cacheKey] = {
  32124. nextPos: pos,
  32125. result: result0
  32126. };
  32127. return result0;
  32128. }
  32129. function cleanupExpected(expected) {
  32130. expected.sort();
  32131. var lastExpected = null;
  32132. var cleanExpected = [];
  32133. for (var i = 0; i < expected.length; i++) {
  32134. if (expected[i] !== lastExpected) {
  32135. cleanExpected.push(expected[i]);
  32136. lastExpected = expected[i];
  32137. }
  32138. }
  32139. return cleanExpected;
  32140. }
  32141. function computeErrorPosition() {
  32142. /*
  32143. * The first idea was to use |String.split| to break the input up to the
  32144. * error position along newlines and derive the line and column from
  32145. * there. However IE's |split| implementation is so broken that it was
  32146. * enough to prevent it.
  32147. */
  32148. var line = 1;
  32149. var column = 1;
  32150. var seenCR = false;
  32151. for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
  32152. var ch = input.charAt(i);
  32153. if (ch === "\n") {
  32154. if (!seenCR) { line++; }
  32155. column = 1;
  32156. seenCR = false;
  32157. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  32158. line++;
  32159. column = 1;
  32160. seenCR = true;
  32161. } else {
  32162. column++;
  32163. seenCR = false;
  32164. }
  32165. }
  32166. return { line: line, column: column };
  32167. }
  32168. function nth(n) { return { type: 'nth-child', index: { type: 'literal', value: n } }; }
  32169. function nthLast(n) { return { type: 'nth-last-child', index: { type: 'literal', value: n } }; }
  32170. function strUnescape(s) {
  32171. return s.replace(/\\(.)/g, function(match, ch) {
  32172. switch(ch) {
  32173. case 'a': return '\a';
  32174. case 'b': return '\b';
  32175. case 'f': return '\f';
  32176. case 'n': return '\n';
  32177. case 'r': return '\r';
  32178. case 't': return '\t';
  32179. case 'v': return '\v';
  32180. default: return ch;
  32181. }
  32182. });
  32183. }
  32184. var result = parseFunctions[startRule]();
  32185. /*
  32186. * The parser is now in one of the following three states:
  32187. *
  32188. * 1. The parser successfully parsed the whole input.
  32189. *
  32190. * - |result !== null|
  32191. * - |pos === input.length|
  32192. * - |rightmostFailuresExpected| may or may not contain something
  32193. *
  32194. * 2. The parser successfully parsed only a part of the input.
  32195. *
  32196. * - |result !== null|
  32197. * - |pos < input.length|
  32198. * - |rightmostFailuresExpected| may or may not contain something
  32199. *
  32200. * 3. The parser did not successfully parse any part of the input.
  32201. *
  32202. * - |result === null|
  32203. * - |pos === 0|
  32204. * - |rightmostFailuresExpected| contains at least one failure
  32205. *
  32206. * All code following this comment (including called functions) must
  32207. * handle these states.
  32208. */
  32209. if (result === null || pos !== input.length) {
  32210. var offset = Math.max(pos, rightmostFailuresPos);
  32211. var found = offset < input.length ? input.charAt(offset) : null;
  32212. var errorPosition = computeErrorPosition();
  32213. throw new this.SyntaxError(
  32214. cleanupExpected(rightmostFailuresExpected),
  32215. found,
  32216. offset,
  32217. errorPosition.line,
  32218. errorPosition.column
  32219. );
  32220. }
  32221. return result;
  32222. },
  32223. /* Returns the parser source code. */
  32224. toSource: function() { return this._source; }
  32225. };
  32226. /* Thrown when a parser encounters a syntax error. */
  32227. result.SyntaxError = function(expected, found, offset, line, column) {
  32228. function buildMessage(expected, found) {
  32229. var expectedHumanized, foundHumanized;
  32230. switch (expected.length) {
  32231. case 0:
  32232. expectedHumanized = "end of input";
  32233. break;
  32234. case 1:
  32235. expectedHumanized = expected[0];
  32236. break;
  32237. default:
  32238. expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
  32239. + " or "
  32240. + expected[expected.length - 1];
  32241. }
  32242. foundHumanized = found ? quote(found) : "end of input";
  32243. return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
  32244. }
  32245. this.name = "SyntaxError";
  32246. this.expected = expected;
  32247. this.found = found;
  32248. this.message = buildMessage(expected, found);
  32249. this.offset = offset;
  32250. this.line = line;
  32251. this.column = column;
  32252. };
  32253. result.SyntaxError.prototype = Error.prototype;
  32254. return result;
  32255. })();
  32256. if (typeof define === "function" && define.amd) { define(function(){ return result; }); } else if (typeof module !== "undefined" && module.exports) { module.exports = result; } else { this.esquery = result; }
  32257. },{}],309:[function(require,module,exports){
  32258. /*
  32259. Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
  32260. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  32261. Redistribution and use in source and binary forms, with or without
  32262. modification, are permitted provided that the following conditions are met:
  32263. * Redistributions of source code must retain the above copyright
  32264. notice, this list of conditions and the following disclaimer.
  32265. * Redistributions in binary form must reproduce the above copyright
  32266. notice, this list of conditions and the following disclaimer in the
  32267. documentation and/or other materials provided with the distribution.
  32268. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  32269. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32270. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32271. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  32272. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  32273. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  32274. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  32275. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32276. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  32277. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32278. */
  32279. /*jslint vars:false, bitwise:true*/
  32280. /*jshint indent:4*/
  32281. /*global exports:true*/
  32282. (function clone(exports) {
  32283. 'use strict';
  32284. var Syntax,
  32285. isArray,
  32286. VisitorOption,
  32287. VisitorKeys,
  32288. objectCreate,
  32289. objectKeys,
  32290. BREAK,
  32291. SKIP,
  32292. REMOVE;
  32293. function ignoreJSHintError() { }
  32294. isArray = Array.isArray;
  32295. if (!isArray) {
  32296. isArray = function isArray(array) {
  32297. return Object.prototype.toString.call(array) === '[object Array]';
  32298. };
  32299. }
  32300. function deepCopy(obj) {
  32301. var ret = {}, key, val;
  32302. for (key in obj) {
  32303. if (obj.hasOwnProperty(key)) {
  32304. val = obj[key];
  32305. if (typeof val === 'object' && val !== null) {
  32306. ret[key] = deepCopy(val);
  32307. } else {
  32308. ret[key] = val;
  32309. }
  32310. }
  32311. }
  32312. return ret;
  32313. }
  32314. function shallowCopy(obj) {
  32315. var ret = {}, key;
  32316. for (key in obj) {
  32317. if (obj.hasOwnProperty(key)) {
  32318. ret[key] = obj[key];
  32319. }
  32320. }
  32321. return ret;
  32322. }
  32323. ignoreJSHintError(shallowCopy);
  32324. // based on LLVM libc++ upper_bound / lower_bound
  32325. // MIT License
  32326. function upperBound(array, func) {
  32327. var diff, len, i, current;
  32328. len = array.length;
  32329. i = 0;
  32330. while (len) {
  32331. diff = len >>> 1;
  32332. current = i + diff;
  32333. if (func(array[current])) {
  32334. len = diff;
  32335. } else {
  32336. i = current + 1;
  32337. len -= diff + 1;
  32338. }
  32339. }
  32340. return i;
  32341. }
  32342. function lowerBound(array, func) {
  32343. var diff, len, i, current;
  32344. len = array.length;
  32345. i = 0;
  32346. while (len) {
  32347. diff = len >>> 1;
  32348. current = i + diff;
  32349. if (func(array[current])) {
  32350. i = current + 1;
  32351. len -= diff + 1;
  32352. } else {
  32353. len = diff;
  32354. }
  32355. }
  32356. return i;
  32357. }
  32358. ignoreJSHintError(lowerBound);
  32359. objectCreate = Object.create || (function () {
  32360. function F() { }
  32361. return function (o) {
  32362. F.prototype = o;
  32363. return new F();
  32364. };
  32365. })();
  32366. objectKeys = Object.keys || function (o) {
  32367. var keys = [], key;
  32368. for (key in o) {
  32369. keys.push(key);
  32370. }
  32371. return keys;
  32372. };
  32373. function extend(to, from) {
  32374. var keys = objectKeys(from), key, i, len;
  32375. for (i = 0, len = keys.length; i < len; i += 1) {
  32376. key = keys[i];
  32377. to[key] = from[key];
  32378. }
  32379. return to;
  32380. }
  32381. Syntax = {
  32382. AssignmentExpression: 'AssignmentExpression',
  32383. AssignmentPattern: 'AssignmentPattern',
  32384. ArrayExpression: 'ArrayExpression',
  32385. ArrayPattern: 'ArrayPattern',
  32386. ArrowFunctionExpression: 'ArrowFunctionExpression',
  32387. AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
  32388. BlockStatement: 'BlockStatement',
  32389. BinaryExpression: 'BinaryExpression',
  32390. BreakStatement: 'BreakStatement',
  32391. CallExpression: 'CallExpression',
  32392. CatchClause: 'CatchClause',
  32393. ClassBody: 'ClassBody',
  32394. ClassDeclaration: 'ClassDeclaration',
  32395. ClassExpression: 'ClassExpression',
  32396. ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
  32397. ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
  32398. ConditionalExpression: 'ConditionalExpression',
  32399. ContinueStatement: 'ContinueStatement',
  32400. DebuggerStatement: 'DebuggerStatement',
  32401. DirectiveStatement: 'DirectiveStatement',
  32402. DoWhileStatement: 'DoWhileStatement',
  32403. EmptyStatement: 'EmptyStatement',
  32404. ExportAllDeclaration: 'ExportAllDeclaration',
  32405. ExportDefaultDeclaration: 'ExportDefaultDeclaration',
  32406. ExportNamedDeclaration: 'ExportNamedDeclaration',
  32407. ExportSpecifier: 'ExportSpecifier',
  32408. ExpressionStatement: 'ExpressionStatement',
  32409. ForStatement: 'ForStatement',
  32410. ForInStatement: 'ForInStatement',
  32411. ForOfStatement: 'ForOfStatement',
  32412. FunctionDeclaration: 'FunctionDeclaration',
  32413. FunctionExpression: 'FunctionExpression',
  32414. GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
  32415. Identifier: 'Identifier',
  32416. IfStatement: 'IfStatement',
  32417. ImportDeclaration: 'ImportDeclaration',
  32418. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  32419. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  32420. ImportSpecifier: 'ImportSpecifier',
  32421. Literal: 'Literal',
  32422. LabeledStatement: 'LabeledStatement',
  32423. LogicalExpression: 'LogicalExpression',
  32424. MemberExpression: 'MemberExpression',
  32425. MetaProperty: 'MetaProperty',
  32426. MethodDefinition: 'MethodDefinition',
  32427. ModuleSpecifier: 'ModuleSpecifier',
  32428. NewExpression: 'NewExpression',
  32429. ObjectExpression: 'ObjectExpression',
  32430. ObjectPattern: 'ObjectPattern',
  32431. Program: 'Program',
  32432. Property: 'Property',
  32433. RestElement: 'RestElement',
  32434. ReturnStatement: 'ReturnStatement',
  32435. SequenceExpression: 'SequenceExpression',
  32436. SpreadElement: 'SpreadElement',
  32437. Super: 'Super',
  32438. SwitchStatement: 'SwitchStatement',
  32439. SwitchCase: 'SwitchCase',
  32440. TaggedTemplateExpression: 'TaggedTemplateExpression',
  32441. TemplateElement: 'TemplateElement',
  32442. TemplateLiteral: 'TemplateLiteral',
  32443. ThisExpression: 'ThisExpression',
  32444. ThrowStatement: 'ThrowStatement',
  32445. TryStatement: 'TryStatement',
  32446. UnaryExpression: 'UnaryExpression',
  32447. UpdateExpression: 'UpdateExpression',
  32448. VariableDeclaration: 'VariableDeclaration',
  32449. VariableDeclarator: 'VariableDeclarator',
  32450. WhileStatement: 'WhileStatement',
  32451. WithStatement: 'WithStatement',
  32452. YieldExpression: 'YieldExpression'
  32453. };
  32454. VisitorKeys = {
  32455. AssignmentExpression: ['left', 'right'],
  32456. AssignmentPattern: ['left', 'right'],
  32457. ArrayExpression: ['elements'],
  32458. ArrayPattern: ['elements'],
  32459. ArrowFunctionExpression: ['params', 'body'],
  32460. AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
  32461. BlockStatement: ['body'],
  32462. BinaryExpression: ['left', 'right'],
  32463. BreakStatement: ['label'],
  32464. CallExpression: ['callee', 'arguments'],
  32465. CatchClause: ['param', 'body'],
  32466. ClassBody: ['body'],
  32467. ClassDeclaration: ['id', 'superClass', 'body'],
  32468. ClassExpression: ['id', 'superClass', 'body'],
  32469. ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
  32470. ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  32471. ConditionalExpression: ['test', 'consequent', 'alternate'],
  32472. ContinueStatement: ['label'],
  32473. DebuggerStatement: [],
  32474. DirectiveStatement: [],
  32475. DoWhileStatement: ['body', 'test'],
  32476. EmptyStatement: [],
  32477. ExportAllDeclaration: ['source'],
  32478. ExportDefaultDeclaration: ['declaration'],
  32479. ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
  32480. ExportSpecifier: ['exported', 'local'],
  32481. ExpressionStatement: ['expression'],
  32482. ForStatement: ['init', 'test', 'update', 'body'],
  32483. ForInStatement: ['left', 'right', 'body'],
  32484. ForOfStatement: ['left', 'right', 'body'],
  32485. FunctionDeclaration: ['id', 'params', 'body'],
  32486. FunctionExpression: ['id', 'params', 'body'],
  32487. GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  32488. Identifier: [],
  32489. IfStatement: ['test', 'consequent', 'alternate'],
  32490. ImportDeclaration: ['specifiers', 'source'],
  32491. ImportDefaultSpecifier: ['local'],
  32492. ImportNamespaceSpecifier: ['local'],
  32493. ImportSpecifier: ['imported', 'local'],
  32494. Literal: [],
  32495. LabeledStatement: ['label', 'body'],
  32496. LogicalExpression: ['left', 'right'],
  32497. MemberExpression: ['object', 'property'],
  32498. MetaProperty: ['meta', 'property'],
  32499. MethodDefinition: ['key', 'value'],
  32500. ModuleSpecifier: [],
  32501. NewExpression: ['callee', 'arguments'],
  32502. ObjectExpression: ['properties'],
  32503. ObjectPattern: ['properties'],
  32504. Program: ['body'],
  32505. Property: ['key', 'value'],
  32506. RestElement: [ 'argument' ],
  32507. ReturnStatement: ['argument'],
  32508. SequenceExpression: ['expressions'],
  32509. SpreadElement: ['argument'],
  32510. Super: [],
  32511. SwitchStatement: ['discriminant', 'cases'],
  32512. SwitchCase: ['test', 'consequent'],
  32513. TaggedTemplateExpression: ['tag', 'quasi'],
  32514. TemplateElement: [],
  32515. TemplateLiteral: ['quasis', 'expressions'],
  32516. ThisExpression: [],
  32517. ThrowStatement: ['argument'],
  32518. TryStatement: ['block', 'handler', 'finalizer'],
  32519. UnaryExpression: ['argument'],
  32520. UpdateExpression: ['argument'],
  32521. VariableDeclaration: ['declarations'],
  32522. VariableDeclarator: ['id', 'init'],
  32523. WhileStatement: ['test', 'body'],
  32524. WithStatement: ['object', 'body'],
  32525. YieldExpression: ['argument']
  32526. };
  32527. // unique id
  32528. BREAK = {};
  32529. SKIP = {};
  32530. REMOVE = {};
  32531. VisitorOption = {
  32532. Break: BREAK,
  32533. Skip: SKIP,
  32534. Remove: REMOVE
  32535. };
  32536. function Reference(parent, key) {
  32537. this.parent = parent;
  32538. this.key = key;
  32539. }
  32540. Reference.prototype.replace = function replace(node) {
  32541. this.parent[this.key] = node;
  32542. };
  32543. Reference.prototype.remove = function remove() {
  32544. if (isArray(this.parent)) {
  32545. this.parent.splice(this.key, 1);
  32546. return true;
  32547. } else {
  32548. this.replace(null);
  32549. return false;
  32550. }
  32551. };
  32552. function Element(node, path, wrap, ref) {
  32553. this.node = node;
  32554. this.path = path;
  32555. this.wrap = wrap;
  32556. this.ref = ref;
  32557. }
  32558. function Controller() { }
  32559. // API:
  32560. // return property path array from root to current node
  32561. Controller.prototype.path = function path() {
  32562. var i, iz, j, jz, result, element;
  32563. function addToPath(result, path) {
  32564. if (isArray(path)) {
  32565. for (j = 0, jz = path.length; j < jz; ++j) {
  32566. result.push(path[j]);
  32567. }
  32568. } else {
  32569. result.push(path);
  32570. }
  32571. }
  32572. // root node
  32573. if (!this.__current.path) {
  32574. return null;
  32575. }
  32576. // first node is sentinel, second node is root element
  32577. result = [];
  32578. for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
  32579. element = this.__leavelist[i];
  32580. addToPath(result, element.path);
  32581. }
  32582. addToPath(result, this.__current.path);
  32583. return result;
  32584. };
  32585. // API:
  32586. // return type of current node
  32587. Controller.prototype.type = function () {
  32588. var node = this.current();
  32589. return node.type || this.__current.wrap;
  32590. };
  32591. // API:
  32592. // return array of parent elements
  32593. Controller.prototype.parents = function parents() {
  32594. var i, iz, result;
  32595. // first node is sentinel
  32596. result = [];
  32597. for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
  32598. result.push(this.__leavelist[i].node);
  32599. }
  32600. return result;
  32601. };
  32602. // API:
  32603. // return current node
  32604. Controller.prototype.current = function current() {
  32605. return this.__current.node;
  32606. };
  32607. Controller.prototype.__execute = function __execute(callback, element) {
  32608. var previous, result;
  32609. result = undefined;
  32610. previous = this.__current;
  32611. this.__current = element;
  32612. this.__state = null;
  32613. if (callback) {
  32614. result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
  32615. }
  32616. this.__current = previous;
  32617. return result;
  32618. };
  32619. // API:
  32620. // notify control skip / break
  32621. Controller.prototype.notify = function notify(flag) {
  32622. this.__state = flag;
  32623. };
  32624. // API:
  32625. // skip child nodes of current node
  32626. Controller.prototype.skip = function () {
  32627. this.notify(SKIP);
  32628. };
  32629. // API:
  32630. // break traversals
  32631. Controller.prototype['break'] = function () {
  32632. this.notify(BREAK);
  32633. };
  32634. // API:
  32635. // remove node
  32636. Controller.prototype.remove = function () {
  32637. this.notify(REMOVE);
  32638. };
  32639. Controller.prototype.__initialize = function(root, visitor) {
  32640. this.visitor = visitor;
  32641. this.root = root;
  32642. this.__worklist = [];
  32643. this.__leavelist = [];
  32644. this.__current = null;
  32645. this.__state = null;
  32646. this.__fallback = visitor.fallback === 'iteration';
  32647. this.__keys = VisitorKeys;
  32648. if (visitor.keys) {
  32649. this.__keys = extend(objectCreate(this.__keys), visitor.keys);
  32650. }
  32651. };
  32652. function isNode(node) {
  32653. if (node == null) {
  32654. return false;
  32655. }
  32656. return typeof node === 'object' && typeof node.type === 'string';
  32657. }
  32658. function isProperty(nodeType, key) {
  32659. return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
  32660. }
  32661. Controller.prototype.traverse = function traverse(root, visitor) {
  32662. var worklist,
  32663. leavelist,
  32664. element,
  32665. node,
  32666. nodeType,
  32667. ret,
  32668. key,
  32669. current,
  32670. current2,
  32671. candidates,
  32672. candidate,
  32673. sentinel;
  32674. this.__initialize(root, visitor);
  32675. sentinel = {};
  32676. // reference
  32677. worklist = this.__worklist;
  32678. leavelist = this.__leavelist;
  32679. // initialize
  32680. worklist.push(new Element(root, null, null, null));
  32681. leavelist.push(new Element(null, null, null, null));
  32682. while (worklist.length) {
  32683. element = worklist.pop();
  32684. if (element === sentinel) {
  32685. element = leavelist.pop();
  32686. ret = this.__execute(visitor.leave, element);
  32687. if (this.__state === BREAK || ret === BREAK) {
  32688. return;
  32689. }
  32690. continue;
  32691. }
  32692. if (element.node) {
  32693. ret = this.__execute(visitor.enter, element);
  32694. if (this.__state === BREAK || ret === BREAK) {
  32695. return;
  32696. }
  32697. worklist.push(sentinel);
  32698. leavelist.push(element);
  32699. if (this.__state === SKIP || ret === SKIP) {
  32700. continue;
  32701. }
  32702. node = element.node;
  32703. nodeType = element.wrap || node.type;
  32704. candidates = this.__keys[nodeType];
  32705. if (!candidates) {
  32706. if (this.__fallback) {
  32707. candidates = objectKeys(node);
  32708. } else {
  32709. throw new Error('Unknown node type ' + nodeType + '.');
  32710. }
  32711. }
  32712. current = candidates.length;
  32713. while ((current -= 1) >= 0) {
  32714. key = candidates[current];
  32715. candidate = node[key];
  32716. if (!candidate) {
  32717. continue;
  32718. }
  32719. if (isArray(candidate)) {
  32720. current2 = candidate.length;
  32721. while ((current2 -= 1) >= 0) {
  32722. if (!candidate[current2]) {
  32723. continue;
  32724. }
  32725. if (isProperty(nodeType, candidates[current])) {
  32726. element = new Element(candidate[current2], [key, current2], 'Property', null);
  32727. } else if (isNode(candidate[current2])) {
  32728. element = new Element(candidate[current2], [key, current2], null, null);
  32729. } else {
  32730. continue;
  32731. }
  32732. worklist.push(element);
  32733. }
  32734. } else if (isNode(candidate)) {
  32735. worklist.push(new Element(candidate, key, null, null));
  32736. }
  32737. }
  32738. }
  32739. }
  32740. };
  32741. Controller.prototype.replace = function replace(root, visitor) {
  32742. function removeElem(element) {
  32743. var i,
  32744. key,
  32745. nextElem,
  32746. parent;
  32747. if (element.ref.remove()) {
  32748. // When the reference is an element of an array.
  32749. key = element.ref.key;
  32750. parent = element.ref.parent;
  32751. // If removed from array, then decrease following items' keys.
  32752. i = worklist.length;
  32753. while (i--) {
  32754. nextElem = worklist[i];
  32755. if (nextElem.ref && nextElem.ref.parent === parent) {
  32756. if (nextElem.ref.key < key) {
  32757. break;
  32758. }
  32759. --nextElem.ref.key;
  32760. }
  32761. }
  32762. }
  32763. }
  32764. var worklist,
  32765. leavelist,
  32766. node,
  32767. nodeType,
  32768. target,
  32769. element,
  32770. current,
  32771. current2,
  32772. candidates,
  32773. candidate,
  32774. sentinel,
  32775. outer,
  32776. key;
  32777. this.__initialize(root, visitor);
  32778. sentinel = {};
  32779. // reference
  32780. worklist = this.__worklist;
  32781. leavelist = this.__leavelist;
  32782. // initialize
  32783. outer = {
  32784. root: root
  32785. };
  32786. element = new Element(root, null, null, new Reference(outer, 'root'));
  32787. worklist.push(element);
  32788. leavelist.push(element);
  32789. while (worklist.length) {
  32790. element = worklist.pop();
  32791. if (element === sentinel) {
  32792. element = leavelist.pop();
  32793. target = this.__execute(visitor.leave, element);
  32794. // node may be replaced with null,
  32795. // so distinguish between undefined and null in this place
  32796. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  32797. // replace
  32798. element.ref.replace(target);
  32799. }
  32800. if (this.__state === REMOVE || target === REMOVE) {
  32801. removeElem(element);
  32802. }
  32803. if (this.__state === BREAK || target === BREAK) {
  32804. return outer.root;
  32805. }
  32806. continue;
  32807. }
  32808. target = this.__execute(visitor.enter, element);
  32809. // node may be replaced with null,
  32810. // so distinguish between undefined and null in this place
  32811. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  32812. // replace
  32813. element.ref.replace(target);
  32814. element.node = target;
  32815. }
  32816. if (this.__state === REMOVE || target === REMOVE) {
  32817. removeElem(element);
  32818. element.node = null;
  32819. }
  32820. if (this.__state === BREAK || target === BREAK) {
  32821. return outer.root;
  32822. }
  32823. // node may be null
  32824. node = element.node;
  32825. if (!node) {
  32826. continue;
  32827. }
  32828. worklist.push(sentinel);
  32829. leavelist.push(element);
  32830. if (this.__state === SKIP || target === SKIP) {
  32831. continue;
  32832. }
  32833. nodeType = element.wrap || node.type;
  32834. candidates = this.__keys[nodeType];
  32835. if (!candidates) {
  32836. if (this.__fallback) {
  32837. candidates = objectKeys(node);
  32838. } else {
  32839. throw new Error('Unknown node type ' + nodeType + '.');
  32840. }
  32841. }
  32842. current = candidates.length;
  32843. while ((current -= 1) >= 0) {
  32844. key = candidates[current];
  32845. candidate = node[key];
  32846. if (!candidate) {
  32847. continue;
  32848. }
  32849. if (isArray(candidate)) {
  32850. current2 = candidate.length;
  32851. while ((current2 -= 1) >= 0) {
  32852. if (!candidate[current2]) {
  32853. continue;
  32854. }
  32855. if (isProperty(nodeType, candidates[current])) {
  32856. element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
  32857. } else if (isNode(candidate[current2])) {
  32858. element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
  32859. } else {
  32860. continue;
  32861. }
  32862. worklist.push(element);
  32863. }
  32864. } else if (isNode(candidate)) {
  32865. worklist.push(new Element(candidate, key, null, new Reference(node, key)));
  32866. }
  32867. }
  32868. }
  32869. return outer.root;
  32870. };
  32871. function traverse(root, visitor) {
  32872. var controller = new Controller();
  32873. return controller.traverse(root, visitor);
  32874. }
  32875. function replace(root, visitor) {
  32876. var controller = new Controller();
  32877. return controller.replace(root, visitor);
  32878. }
  32879. function extendCommentRange(comment, tokens) {
  32880. var target;
  32881. target = upperBound(tokens, function search(token) {
  32882. return token.range[0] > comment.range[0];
  32883. });
  32884. comment.extendedRange = [comment.range[0], comment.range[1]];
  32885. if (target !== tokens.length) {
  32886. comment.extendedRange[1] = tokens[target].range[0];
  32887. }
  32888. target -= 1;
  32889. if (target >= 0) {
  32890. comment.extendedRange[0] = tokens[target].range[1];
  32891. }
  32892. return comment;
  32893. }
  32894. function attachComments(tree, providedComments, tokens) {
  32895. // At first, we should calculate extended comment ranges.
  32896. var comments = [], comment, len, i, cursor;
  32897. if (!tree.range) {
  32898. throw new Error('attachComments needs range information');
  32899. }
  32900. // tokens array is empty, we attach comments to tree as 'leadingComments'
  32901. if (!tokens.length) {
  32902. if (providedComments.length) {
  32903. for (i = 0, len = providedComments.length; i < len; i += 1) {
  32904. comment = deepCopy(providedComments[i]);
  32905. comment.extendedRange = [0, tree.range[0]];
  32906. comments.push(comment);
  32907. }
  32908. tree.leadingComments = comments;
  32909. }
  32910. return tree;
  32911. }
  32912. for (i = 0, len = providedComments.length; i < len; i += 1) {
  32913. comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
  32914. }
  32915. // This is based on John Freeman's implementation.
  32916. cursor = 0;
  32917. traverse(tree, {
  32918. enter: function (node) {
  32919. var comment;
  32920. while (cursor < comments.length) {
  32921. comment = comments[cursor];
  32922. if (comment.extendedRange[1] > node.range[0]) {
  32923. break;
  32924. }
  32925. if (comment.extendedRange[1] === node.range[0]) {
  32926. if (!node.leadingComments) {
  32927. node.leadingComments = [];
  32928. }
  32929. node.leadingComments.push(comment);
  32930. comments.splice(cursor, 1);
  32931. } else {
  32932. cursor += 1;
  32933. }
  32934. }
  32935. // already out of owned node
  32936. if (cursor === comments.length) {
  32937. return VisitorOption.Break;
  32938. }
  32939. if (comments[cursor].extendedRange[0] > node.range[1]) {
  32940. return VisitorOption.Skip;
  32941. }
  32942. }
  32943. });
  32944. cursor = 0;
  32945. traverse(tree, {
  32946. leave: function (node) {
  32947. var comment;
  32948. while (cursor < comments.length) {
  32949. comment = comments[cursor];
  32950. if (node.range[1] < comment.extendedRange[0]) {
  32951. break;
  32952. }
  32953. if (node.range[1] === comment.extendedRange[0]) {
  32954. if (!node.trailingComments) {
  32955. node.trailingComments = [];
  32956. }
  32957. node.trailingComments.push(comment);
  32958. comments.splice(cursor, 1);
  32959. } else {
  32960. cursor += 1;
  32961. }
  32962. }
  32963. // already out of owned node
  32964. if (cursor === comments.length) {
  32965. return VisitorOption.Break;
  32966. }
  32967. if (comments[cursor].extendedRange[0] > node.range[1]) {
  32968. return VisitorOption.Skip;
  32969. }
  32970. }
  32971. });
  32972. return tree;
  32973. }
  32974. exports.version = require('./package.json').version;
  32975. exports.Syntax = Syntax;
  32976. exports.traverse = traverse;
  32977. exports.replace = replace;
  32978. exports.attachComments = attachComments;
  32979. exports.VisitorKeys = VisitorKeys;
  32980. exports.VisitorOption = VisitorOption;
  32981. exports.Controller = Controller;
  32982. exports.cloneEnvironment = function () { return clone({}); };
  32983. return exports;
  32984. }(exports));
  32985. /* vim: set sw=4 ts=4 et tw=80 : */
  32986. },{"./package.json":310}],310:[function(require,module,exports){
  32987. module.exports={
  32988. "name": "estraverse",
  32989. "description": "ECMAScript JS AST traversal functions",
  32990. "homepage": "https://github.com/estools/estraverse",
  32991. "main": "estraverse.js",
  32992. "version": "4.1.0",
  32993. "engines": {
  32994. "node": ">=0.10.0"
  32995. },
  32996. "maintainers": [
  32997. {
  32998. "name": "constellation",
  32999. "email": "utatane.tea@gmail.com"
  33000. },
  33001. {
  33002. "name": "michaelficarra",
  33003. "email": "npm@michael.ficarra.me"
  33004. }
  33005. ],
  33006. "repository": {
  33007. "type": "git",
  33008. "url": "git+ssh://git@github.com/estools/estraverse.git"
  33009. },
  33010. "devDependencies": {
  33011. "chai": "^2.1.1",
  33012. "coffee-script": "^1.8.0",
  33013. "espree": "^1.11.0",
  33014. "gulp": "^3.8.10",
  33015. "gulp-bump": "^0.2.2",
  33016. "gulp-filter": "^2.0.0",
  33017. "gulp-git": "^1.0.1",
  33018. "gulp-tag-version": "^1.2.1",
  33019. "jshint": "^2.5.6",
  33020. "mocha": "^2.1.0"
  33021. },
  33022. "licenses": [
  33023. {
  33024. "type": "BSD",
  33025. "url": "http://github.com/estools/estraverse/raw/master/LICENSE.BSD"
  33026. }
  33027. ],
  33028. "scripts": {
  33029. "test": "npm run-script lint && npm run-script unit-test",
  33030. "lint": "jshint estraverse.js",
  33031. "unit-test": "mocha --compilers coffee:coffee-script/register"
  33032. },
  33033. "gitHead": "347d52996336719b5910c7ffb5ff3ea8ecb87cf3",
  33034. "bugs": {
  33035. "url": "https://github.com/estools/estraverse/issues"
  33036. },
  33037. "_id": "estraverse@4.1.0",
  33038. "_shasum": "40f23a76092041be6467d7f235c933b670766e05",
  33039. "_from": "estraverse@>=4.0.0 <5.0.0",
  33040. "_npmVersion": "2.8.3",
  33041. "_nodeVersion": "1.8.1",
  33042. "_npmUser": {
  33043. "name": "constellation",
  33044. "email": "utatane.tea@gmail.com"
  33045. },
  33046. "dist": {
  33047. "shasum": "40f23a76092041be6467d7f235c933b670766e05",
  33048. "tarball": "http://registry.npmjs.org/estraverse/-/estraverse-4.1.0.tgz"
  33049. },
  33050. "directories": {},
  33051. "_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.1.0.tgz"
  33052. }
  33053. },{}],311:[function(require,module,exports){
  33054. /*
  33055. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  33056. Redistribution and use in source and binary forms, with or without
  33057. modification, are permitted provided that the following conditions are met:
  33058. * Redistributions of source code must retain the above copyright
  33059. notice, this list of conditions and the following disclaimer.
  33060. * Redistributions in binary form must reproduce the above copyright
  33061. notice, this list of conditions and the following disclaimer in the
  33062. documentation and/or other materials provided with the distribution.
  33063. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  33064. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33065. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33066. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  33067. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  33068. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33069. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  33070. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33071. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  33072. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33073. */
  33074. (function () {
  33075. 'use strict';
  33076. function isExpression(node) {
  33077. if (node == null) { return false; }
  33078. switch (node.type) {
  33079. case 'ArrayExpression':
  33080. case 'AssignmentExpression':
  33081. case 'BinaryExpression':
  33082. case 'CallExpression':
  33083. case 'ConditionalExpression':
  33084. case 'FunctionExpression':
  33085. case 'Identifier':
  33086. case 'Literal':
  33087. case 'LogicalExpression':
  33088. case 'MemberExpression':
  33089. case 'NewExpression':
  33090. case 'ObjectExpression':
  33091. case 'SequenceExpression':
  33092. case 'ThisExpression':
  33093. case 'UnaryExpression':
  33094. case 'UpdateExpression':
  33095. return true;
  33096. }
  33097. return false;
  33098. }
  33099. function isIterationStatement(node) {
  33100. if (node == null) { return false; }
  33101. switch (node.type) {
  33102. case 'DoWhileStatement':
  33103. case 'ForInStatement':
  33104. case 'ForStatement':
  33105. case 'WhileStatement':
  33106. return true;
  33107. }
  33108. return false;
  33109. }
  33110. function isStatement(node) {
  33111. if (node == null) { return false; }
  33112. switch (node.type) {
  33113. case 'BlockStatement':
  33114. case 'BreakStatement':
  33115. case 'ContinueStatement':
  33116. case 'DebuggerStatement':
  33117. case 'DoWhileStatement':
  33118. case 'EmptyStatement':
  33119. case 'ExpressionStatement':
  33120. case 'ForInStatement':
  33121. case 'ForStatement':
  33122. case 'IfStatement':
  33123. case 'LabeledStatement':
  33124. case 'ReturnStatement':
  33125. case 'SwitchStatement':
  33126. case 'ThrowStatement':
  33127. case 'TryStatement':
  33128. case 'VariableDeclaration':
  33129. case 'WhileStatement':
  33130. case 'WithStatement':
  33131. return true;
  33132. }
  33133. return false;
  33134. }
  33135. function isSourceElement(node) {
  33136. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  33137. }
  33138. function trailingStatement(node) {
  33139. switch (node.type) {
  33140. case 'IfStatement':
  33141. if (node.alternate != null) {
  33142. return node.alternate;
  33143. }
  33144. return node.consequent;
  33145. case 'LabeledStatement':
  33146. case 'ForStatement':
  33147. case 'ForInStatement':
  33148. case 'WhileStatement':
  33149. case 'WithStatement':
  33150. return node.body;
  33151. }
  33152. return null;
  33153. }
  33154. function isProblematicIfStatement(node) {
  33155. var current;
  33156. if (node.type !== 'IfStatement') {
  33157. return false;
  33158. }
  33159. if (node.alternate == null) {
  33160. return false;
  33161. }
  33162. current = node.consequent;
  33163. do {
  33164. if (current.type === 'IfStatement') {
  33165. if (current.alternate == null) {
  33166. return true;
  33167. }
  33168. }
  33169. current = trailingStatement(current);
  33170. } while (current);
  33171. return false;
  33172. }
  33173. module.exports = {
  33174. isExpression: isExpression,
  33175. isStatement: isStatement,
  33176. isIterationStatement: isIterationStatement,
  33177. isSourceElement: isSourceElement,
  33178. isProblematicIfStatement: isProblematicIfStatement,
  33179. trailingStatement: trailingStatement
  33180. };
  33181. }());
  33182. /* vim: set sw=4 ts=4 et tw=80 : */
  33183. },{}],312:[function(require,module,exports){
  33184. /*
  33185. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  33186. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  33187. Redistribution and use in source and binary forms, with or without
  33188. modification, are permitted provided that the following conditions are met:
  33189. * Redistributions of source code must retain the above copyright
  33190. notice, this list of conditions and the following disclaimer.
  33191. * Redistributions in binary form must reproduce the above copyright
  33192. notice, this list of conditions and the following disclaimer in the
  33193. documentation and/or other materials provided with the distribution.
  33194. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33195. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33196. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33197. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  33198. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  33199. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33200. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  33201. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33202. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  33203. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33204. */
  33205. (function () {
  33206. 'use strict';
  33207. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
  33208. // See `tools/generate-identifier-regex.js`.
  33209. ES5Regex = {
  33210. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  33211. 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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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]/,
  33212. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  33213. 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-\u08B2\u08E4-\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\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\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\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\u0D57\u0D60-\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-\u13F4\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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-\uFE2D\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]/
  33214. };
  33215. ES6Regex = {
  33216. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  33217. 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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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\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\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]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\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]|\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]|\uD87E[\uDC00-\uDE1D]/,
  33218. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  33219. 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-\u08B2\u08E4-\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\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\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\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\u0D57\u0D60-\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-\u13F4\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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-\uFE2D\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\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\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]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\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]|\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]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\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]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  33220. };
  33221. function isDecimalDigit(ch) {
  33222. return 0x30 <= ch && ch <= 0x39; // 0..9
  33223. }
  33224. function isHexDigit(ch) {
  33225. return 0x30 <= ch && ch <= 0x39 || // 0..9
  33226. 0x61 <= ch && ch <= 0x66 || // a..f
  33227. 0x41 <= ch && ch <= 0x46; // A..F
  33228. }
  33229. function isOctalDigit(ch) {
  33230. return ch >= 0x30 && ch <= 0x37; // 0..7
  33231. }
  33232. // 7.2 White Space
  33233. NON_ASCII_WHITESPACES = [
  33234. 0x1680, 0x180E,
  33235. 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A,
  33236. 0x202F, 0x205F,
  33237. 0x3000,
  33238. 0xFEFF
  33239. ];
  33240. function isWhiteSpace(ch) {
  33241. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 ||
  33242. ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  33243. }
  33244. // 7.3 Line Terminators
  33245. function isLineTerminator(ch) {
  33246. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  33247. }
  33248. // 7.6 Identifier Names and Identifiers
  33249. function fromCodePoint(cp) {
  33250. if (cp <= 0xFFFF) { return String.fromCharCode(cp); }
  33251. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  33252. var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00);
  33253. return cu1 + cu2;
  33254. }
  33255. IDENTIFIER_START = new Array(0x80);
  33256. for(ch = 0; ch < 0x80; ++ch) {
  33257. IDENTIFIER_START[ch] =
  33258. ch >= 0x61 && ch <= 0x7A || // a..z
  33259. ch >= 0x41 && ch <= 0x5A || // A..Z
  33260. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  33261. }
  33262. IDENTIFIER_PART = new Array(0x80);
  33263. for(ch = 0; ch < 0x80; ++ch) {
  33264. IDENTIFIER_PART[ch] =
  33265. ch >= 0x61 && ch <= 0x7A || // a..z
  33266. ch >= 0x41 && ch <= 0x5A || // A..Z
  33267. ch >= 0x30 && ch <= 0x39 || // 0..9
  33268. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  33269. }
  33270. function isIdentifierStartES5(ch) {
  33271. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  33272. }
  33273. function isIdentifierPartES5(ch) {
  33274. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  33275. }
  33276. function isIdentifierStartES6(ch) {
  33277. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  33278. }
  33279. function isIdentifierPartES6(ch) {
  33280. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  33281. }
  33282. module.exports = {
  33283. isDecimalDigit: isDecimalDigit,
  33284. isHexDigit: isHexDigit,
  33285. isOctalDigit: isOctalDigit,
  33286. isWhiteSpace: isWhiteSpace,
  33287. isLineTerminator: isLineTerminator,
  33288. isIdentifierStartES5: isIdentifierStartES5,
  33289. isIdentifierPartES5: isIdentifierPartES5,
  33290. isIdentifierStartES6: isIdentifierStartES6,
  33291. isIdentifierPartES6: isIdentifierPartES6
  33292. };
  33293. }());
  33294. /* vim: set sw=4 ts=4 et tw=80 : */
  33295. },{}],313:[function(require,module,exports){
  33296. /*
  33297. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  33298. Redistribution and use in source and binary forms, with or without
  33299. modification, are permitted provided that the following conditions are met:
  33300. * Redistributions of source code must retain the above copyright
  33301. notice, this list of conditions and the following disclaimer.
  33302. * Redistributions in binary form must reproduce the above copyright
  33303. notice, this list of conditions and the following disclaimer in the
  33304. documentation and/or other materials provided with the distribution.
  33305. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33306. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33307. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33308. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  33309. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  33310. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33311. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  33312. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33313. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  33314. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33315. */
  33316. (function () {
  33317. 'use strict';
  33318. var code = require('./code');
  33319. function isStrictModeReservedWordES6(id) {
  33320. switch (id) {
  33321. case 'implements':
  33322. case 'interface':
  33323. case 'package':
  33324. case 'private':
  33325. case 'protected':
  33326. case 'public':
  33327. case 'static':
  33328. case 'let':
  33329. return true;
  33330. default:
  33331. return false;
  33332. }
  33333. }
  33334. function isKeywordES5(id, strict) {
  33335. // yield should not be treated as keyword under non-strict mode.
  33336. if (!strict && id === 'yield') {
  33337. return false;
  33338. }
  33339. return isKeywordES6(id, strict);
  33340. }
  33341. function isKeywordES6(id, strict) {
  33342. if (strict && isStrictModeReservedWordES6(id)) {
  33343. return true;
  33344. }
  33345. switch (id.length) {
  33346. case 2:
  33347. return (id === 'if') || (id === 'in') || (id === 'do');
  33348. case 3:
  33349. return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
  33350. case 4:
  33351. return (id === 'this') || (id === 'else') || (id === 'case') ||
  33352. (id === 'void') || (id === 'with') || (id === 'enum');
  33353. case 5:
  33354. return (id === 'while') || (id === 'break') || (id === 'catch') ||
  33355. (id === 'throw') || (id === 'const') || (id === 'yield') ||
  33356. (id === 'class') || (id === 'super');
  33357. case 6:
  33358. return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
  33359. (id === 'switch') || (id === 'export') || (id === 'import');
  33360. case 7:
  33361. return (id === 'default') || (id === 'finally') || (id === 'extends');
  33362. case 8:
  33363. return (id === 'function') || (id === 'continue') || (id === 'debugger');
  33364. case 10:
  33365. return (id === 'instanceof');
  33366. default:
  33367. return false;
  33368. }
  33369. }
  33370. function isReservedWordES5(id, strict) {
  33371. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  33372. }
  33373. function isReservedWordES6(id, strict) {
  33374. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  33375. }
  33376. function isRestrictedWord(id) {
  33377. return id === 'eval' || id === 'arguments';
  33378. }
  33379. function isIdentifierNameES5(id) {
  33380. var i, iz, ch;
  33381. if (id.length === 0) { return false; }
  33382. ch = id.charCodeAt(0);
  33383. if (!code.isIdentifierStartES5(ch)) {
  33384. return false;
  33385. }
  33386. for (i = 1, iz = id.length; i < iz; ++i) {
  33387. ch = id.charCodeAt(i);
  33388. if (!code.isIdentifierPartES5(ch)) {
  33389. return false;
  33390. }
  33391. }
  33392. return true;
  33393. }
  33394. function decodeUtf16(lead, trail) {
  33395. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  33396. }
  33397. function isIdentifierNameES6(id) {
  33398. var i, iz, ch, lowCh, check;
  33399. if (id.length === 0) { return false; }
  33400. check = code.isIdentifierStartES6;
  33401. for (i = 0, iz = id.length; i < iz; ++i) {
  33402. ch = id.charCodeAt(i);
  33403. if (0xD800 <= ch && ch <= 0xDBFF) {
  33404. ++i;
  33405. if (i >= iz) { return false; }
  33406. lowCh = id.charCodeAt(i);
  33407. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  33408. return false;
  33409. }
  33410. ch = decodeUtf16(ch, lowCh);
  33411. }
  33412. if (!check(ch)) {
  33413. return false;
  33414. }
  33415. check = code.isIdentifierPartES6;
  33416. }
  33417. return true;
  33418. }
  33419. function isIdentifierES5(id, strict) {
  33420. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  33421. }
  33422. function isIdentifierES6(id, strict) {
  33423. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  33424. }
  33425. module.exports = {
  33426. isKeywordES5: isKeywordES5,
  33427. isKeywordES6: isKeywordES6,
  33428. isReservedWordES5: isReservedWordES5,
  33429. isReservedWordES6: isReservedWordES6,
  33430. isRestrictedWord: isRestrictedWord,
  33431. isIdentifierNameES5: isIdentifierNameES5,
  33432. isIdentifierNameES6: isIdentifierNameES6,
  33433. isIdentifierES5: isIdentifierES5,
  33434. isIdentifierES6: isIdentifierES6
  33435. };
  33436. }());
  33437. /* vim: set sw=4 ts=4 et tw=80 : */
  33438. },{"./code":312}],314:[function(require,module,exports){
  33439. /*
  33440. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  33441. Redistribution and use in source and binary forms, with or without
  33442. modification, are permitted provided that the following conditions are met:
  33443. * Redistributions of source code must retain the above copyright
  33444. notice, this list of conditions and the following disclaimer.
  33445. * Redistributions in binary form must reproduce the above copyright
  33446. notice, this list of conditions and the following disclaimer in the
  33447. documentation and/or other materials provided with the distribution.
  33448. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33449. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33450. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33451. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  33452. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  33453. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33454. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  33455. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33456. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  33457. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33458. */
  33459. (function () {
  33460. 'use strict';
  33461. exports.ast = require('./ast');
  33462. exports.code = require('./code');
  33463. exports.keyword = require('./keyword');
  33464. }());
  33465. /* vim: set sw=4 ts=4 et tw=80 : */
  33466. },{"./ast":311,"./code":312,"./keyword":313}],315:[function(require,module,exports){
  33467. module.exports={
  33468. "builtin": {
  33469. "Array": false,
  33470. "ArrayBuffer": false,
  33471. "Boolean": false,
  33472. "constructor": false,
  33473. "Date": false,
  33474. "decodeURI": false,
  33475. "decodeURIComponent": false,
  33476. "encodeURI": false,
  33477. "encodeURIComponent": false,
  33478. "Error": false,
  33479. "eval": false,
  33480. "EvalError": false,
  33481. "Float32Array": false,
  33482. "Float64Array": false,
  33483. "Function": false,
  33484. "hasOwnProperty": false,
  33485. "Infinity": false,
  33486. "Int16Array": false,
  33487. "Int32Array": false,
  33488. "Int8Array": false,
  33489. "isFinite": false,
  33490. "isNaN": false,
  33491. "isPrototypeOf": false,
  33492. "JSON": false,
  33493. "Map": false,
  33494. "Math": false,
  33495. "NaN": false,
  33496. "Number": false,
  33497. "Object": false,
  33498. "parseFloat": false,
  33499. "parseInt": false,
  33500. "Promise": false,
  33501. "propertyIsEnumerable": false,
  33502. "Proxy": false,
  33503. "RangeError": false,
  33504. "ReferenceError": false,
  33505. "Reflect": false,
  33506. "RegExp": false,
  33507. "Set": false,
  33508. "String": false,
  33509. "Symbol": false,
  33510. "SyntaxError": false,
  33511. "System": false,
  33512. "toLocaleString": false,
  33513. "toString": false,
  33514. "TypeError": false,
  33515. "Uint16Array": false,
  33516. "Uint32Array": false,
  33517. "Uint8Array": false,
  33518. "Uint8ClampedArray": false,
  33519. "undefined": false,
  33520. "URIError": false,
  33521. "valueOf": false,
  33522. "WeakMap": false,
  33523. "WeakSet": false
  33524. },
  33525. "nonstandard": {
  33526. "escape": false,
  33527. "unescape": false
  33528. },
  33529. "browser": {
  33530. "addEventListener": false,
  33531. "alert": false,
  33532. "applicationCache": false,
  33533. "atob": false,
  33534. "Audio": false,
  33535. "AudioProcessingEvent": false,
  33536. "BeforeUnloadEvent": false,
  33537. "Blob": false,
  33538. "blur": false,
  33539. "btoa": false,
  33540. "cancelAnimationFrame": false,
  33541. "CanvasGradient": false,
  33542. "CanvasPattern": false,
  33543. "CanvasRenderingContext2D": false,
  33544. "clearInterval": false,
  33545. "clearTimeout": false,
  33546. "close": false,
  33547. "closed": false,
  33548. "CloseEvent": false,
  33549. "Comment": false,
  33550. "CompositionEvent": false,
  33551. "confirm": false,
  33552. "console": false,
  33553. "crypto": false,
  33554. "CSS": false,
  33555. "CustomEvent": false,
  33556. "DataView": false,
  33557. "Debug": false,
  33558. "defaultStatus": false,
  33559. "devicePixelRatio": false,
  33560. "dispatchEvent": false,
  33561. "document": false,
  33562. "Document": false,
  33563. "DocumentFragment": false,
  33564. "DOMParser": false,
  33565. "DragEvent": false,
  33566. "Element": false,
  33567. "ElementTimeControl": false,
  33568. "ErrorEvent": false,
  33569. "event": false,
  33570. "Event": false,
  33571. "FileReader": false,
  33572. "fetch": false,
  33573. "find": false,
  33574. "focus": false,
  33575. "FocusEvent": false,
  33576. "FormData": false,
  33577. "frameElement": false,
  33578. "frames": false,
  33579. "GamepadEvent": false,
  33580. "getComputedStyle": false,
  33581. "getSelection": false,
  33582. "HashChangeEvent": false,
  33583. "Headers": false,
  33584. "history": false,
  33585. "HTMLAnchorElement": false,
  33586. "HTMLBaseElement": false,
  33587. "HTMLBlockquoteElement": false,
  33588. "HTMLBodyElement": false,
  33589. "HTMLBRElement": false,
  33590. "HTMLButtonElement": false,
  33591. "HTMLCanvasElement": false,
  33592. "HTMLDirectoryElement": false,
  33593. "HTMLDivElement": false,
  33594. "HTMLDListElement": false,
  33595. "HTMLElement": false,
  33596. "HTMLFieldSetElement": false,
  33597. "HTMLFontElement": false,
  33598. "HTMLFormElement": false,
  33599. "HTMLFrameElement": false,
  33600. "HTMLFrameSetElement": false,
  33601. "HTMLHeadElement": false,
  33602. "HTMLHeadingElement": false,
  33603. "HTMLHRElement": false,
  33604. "HTMLHtmlElement": false,
  33605. "HTMLIFrameElement": false,
  33606. "HTMLImageElement": false,
  33607. "HTMLInputElement": false,
  33608. "HTMLIsIndexElement": false,
  33609. "HTMLLabelElement": false,
  33610. "HTMLLayerElement": false,
  33611. "HTMLLegendElement": false,
  33612. "HTMLLIElement": false,
  33613. "HTMLLinkElement": false,
  33614. "HTMLMapElement": false,
  33615. "HTMLMenuElement": false,
  33616. "HTMLMetaElement": false,
  33617. "HTMLModElement": false,
  33618. "HTMLObjectElement": false,
  33619. "HTMLOListElement": false,
  33620. "HTMLOptGroupElement": false,
  33621. "HTMLOptionElement": false,
  33622. "HTMLParagraphElement": false,
  33623. "HTMLParamElement": false,
  33624. "HTMLPreElement": false,
  33625. "HTMLQuoteElement": false,
  33626. "HTMLScriptElement": false,
  33627. "HTMLSelectElement": false,
  33628. "HTMLStyleElement": false,
  33629. "HTMLTableCaptionElement": false,
  33630. "HTMLTableCellElement": false,
  33631. "HTMLTableColElement": false,
  33632. "HTMLTableElement": false,
  33633. "HTMLTableRowElement": false,
  33634. "HTMLTableSectionElement": false,
  33635. "HTMLTextAreaElement": false,
  33636. "HTMLTitleElement": false,
  33637. "HTMLUListElement": false,
  33638. "HTMLVideoElement": false,
  33639. "IDBCursor": false,
  33640. "IDBCursorWithValue": false,
  33641. "IDBDatabase": false,
  33642. "IDBEnvironment": false,
  33643. "IDBFactory": false,
  33644. "IDBIndex": false,
  33645. "IDBKeyRange": false,
  33646. "IDBObjectStore": false,
  33647. "IDBOpenDBRequest": false,
  33648. "IDBRequest": false,
  33649. "IDBTransaction": false,
  33650. "IDBVersionChangeEvent": false,
  33651. "Image": false,
  33652. "indexedDB": false,
  33653. "innerHeight": false,
  33654. "innerWidth": false,
  33655. "InputEvent": false,
  33656. "Intl": false,
  33657. "KeyboardEvent": false,
  33658. "length": false,
  33659. "localStorage": false,
  33660. "location": false,
  33661. "matchMedia": false,
  33662. "MessageChannel": false,
  33663. "MessageEvent": false,
  33664. "MessagePort": false,
  33665. "MouseEvent": false,
  33666. "moveBy": false,
  33667. "moveTo": false,
  33668. "MutationObserver": false,
  33669. "name": false,
  33670. "navigator": false,
  33671. "Node": false,
  33672. "NodeFilter": false,
  33673. "NodeList": false,
  33674. "Notification": false,
  33675. "OfflineAudioCompletionEvent": false,
  33676. "onbeforeunload": true,
  33677. "onblur": true,
  33678. "onerror": true,
  33679. "onfocus": true,
  33680. "onload": true,
  33681. "onresize": true,
  33682. "onunload": true,
  33683. "open": false,
  33684. "openDatabase": false,
  33685. "opener": false,
  33686. "opera": false,
  33687. "Option": false,
  33688. "outerHeight": false,
  33689. "outerWidth": false,
  33690. "PageTransitionEvent": false,
  33691. "pageXOffset": false,
  33692. "pageYOffset": false,
  33693. "parent": false,
  33694. "PopStateEvent": false,
  33695. "postMessage": false,
  33696. "print": false,
  33697. "ProgressEvent": false,
  33698. "prompt": false,
  33699. "Range": false,
  33700. "Request": false,
  33701. "Response": false,
  33702. "removeEventListener": false,
  33703. "requestAnimationFrame": false,
  33704. "resizeBy": false,
  33705. "resizeTo": false,
  33706. "screen": false,
  33707. "screenX": false,
  33708. "screenY": false,
  33709. "scroll": false,
  33710. "scrollbars": false,
  33711. "scrollBy": false,
  33712. "scrollTo": false,
  33713. "scrollX": false,
  33714. "scrollY": false,
  33715. "self": false,
  33716. "sessionStorage": false,
  33717. "setInterval": false,
  33718. "setTimeout": false,
  33719. "SharedWorker": false,
  33720. "showModalDialog": false,
  33721. "status": false,
  33722. "stop": false,
  33723. "StorageEvent": false,
  33724. "SVGAElement": false,
  33725. "SVGAltGlyphDefElement": false,
  33726. "SVGAltGlyphElement": false,
  33727. "SVGAltGlyphItemElement": false,
  33728. "SVGAngle": false,
  33729. "SVGAnimateColorElement": false,
  33730. "SVGAnimatedAngle": false,
  33731. "SVGAnimatedBoolean": false,
  33732. "SVGAnimatedEnumeration": false,
  33733. "SVGAnimatedInteger": false,
  33734. "SVGAnimatedLength": false,
  33735. "SVGAnimatedLengthList": false,
  33736. "SVGAnimatedNumber": false,
  33737. "SVGAnimatedNumberList": false,
  33738. "SVGAnimatedPathData": false,
  33739. "SVGAnimatedPoints": false,
  33740. "SVGAnimatedPreserveAspectRatio": false,
  33741. "SVGAnimatedRect": false,
  33742. "SVGAnimatedString": false,
  33743. "SVGAnimatedTransformList": false,
  33744. "SVGAnimateElement": false,
  33745. "SVGAnimateMotionElement": false,
  33746. "SVGAnimateTransformElement": false,
  33747. "SVGAnimationElement": false,
  33748. "SVGCircleElement": false,
  33749. "SVGClipPathElement": false,
  33750. "SVGColor": false,
  33751. "SVGColorProfileElement": false,
  33752. "SVGColorProfileRule": false,
  33753. "SVGComponentTransferFunctionElement": false,
  33754. "SVGCSSRule": false,
  33755. "SVGCursorElement": false,
  33756. "SVGDefsElement": false,
  33757. "SVGDescElement": false,
  33758. "SVGDocument": false,
  33759. "SVGElement": false,
  33760. "SVGElementInstance": false,
  33761. "SVGElementInstanceList": false,
  33762. "SVGEllipseElement": false,
  33763. "SVGEvent": false,
  33764. "SVGExternalResourcesRequired": false,
  33765. "SVGFEBlendElement": false,
  33766. "SVGFEColorMatrixElement": false,
  33767. "SVGFEComponentTransferElement": false,
  33768. "SVGFECompositeElement": false,
  33769. "SVGFEConvolveMatrixElement": false,
  33770. "SVGFEDiffuseLightingElement": false,
  33771. "SVGFEDisplacementMapElement": false,
  33772. "SVGFEDistantLightElement": false,
  33773. "SVGFEFloodElement": false,
  33774. "SVGFEFuncAElement": false,
  33775. "SVGFEFuncBElement": false,
  33776. "SVGFEFuncGElement": false,
  33777. "SVGFEFuncRElement": false,
  33778. "SVGFEGaussianBlurElement": false,
  33779. "SVGFEImageElement": false,
  33780. "SVGFEMergeElement": false,
  33781. "SVGFEMergeNodeElement": false,
  33782. "SVGFEMorphologyElement": false,
  33783. "SVGFEOffsetElement": false,
  33784. "SVGFEPointLightElement": false,
  33785. "SVGFESpecularLightingElement": false,
  33786. "SVGFESpotLightElement": false,
  33787. "SVGFETileElement": false,
  33788. "SVGFETurbulenceElement": false,
  33789. "SVGFilterElement": false,
  33790. "SVGFilterPrimitiveStandardAttributes": false,
  33791. "SVGFitToViewBox": false,
  33792. "SVGFontElement": false,
  33793. "SVGFontFaceElement": false,
  33794. "SVGFontFaceFormatElement": false,
  33795. "SVGFontFaceNameElement": false,
  33796. "SVGFontFaceSrcElement": false,
  33797. "SVGFontFaceUriElement": false,
  33798. "SVGForeignObjectElement": false,
  33799. "SVGGElement": false,
  33800. "SVGGlyphElement": false,
  33801. "SVGGlyphRefElement": false,
  33802. "SVGGradientElement": false,
  33803. "SVGHKernElement": false,
  33804. "SVGICCColor": false,
  33805. "SVGImageElement": false,
  33806. "SVGLangSpace": false,
  33807. "SVGLength": false,
  33808. "SVGLengthList": false,
  33809. "SVGLinearGradientElement": false,
  33810. "SVGLineElement": false,
  33811. "SVGLocatable": false,
  33812. "SVGMarkerElement": false,
  33813. "SVGMaskElement": false,
  33814. "SVGMatrix": false,
  33815. "SVGMetadataElement": false,
  33816. "SVGMissingGlyphElement": false,
  33817. "SVGMPathElement": false,
  33818. "SVGNumber": false,
  33819. "SVGNumberList": false,
  33820. "SVGPaint": false,
  33821. "SVGPathElement": false,
  33822. "SVGPathSeg": false,
  33823. "SVGPathSegArcAbs": false,
  33824. "SVGPathSegArcRel": false,
  33825. "SVGPathSegClosePath": false,
  33826. "SVGPathSegCurvetoCubicAbs": false,
  33827. "SVGPathSegCurvetoCubicRel": false,
  33828. "SVGPathSegCurvetoCubicSmoothAbs": false,
  33829. "SVGPathSegCurvetoCubicSmoothRel": false,
  33830. "SVGPathSegCurvetoQuadraticAbs": false,
  33831. "SVGPathSegCurvetoQuadraticRel": false,
  33832. "SVGPathSegCurvetoQuadraticSmoothAbs": false,
  33833. "SVGPathSegCurvetoQuadraticSmoothRel": false,
  33834. "SVGPathSegLinetoAbs": false,
  33835. "SVGPathSegLinetoHorizontalAbs": false,
  33836. "SVGPathSegLinetoHorizontalRel": false,
  33837. "SVGPathSegLinetoRel": false,
  33838. "SVGPathSegLinetoVerticalAbs": false,
  33839. "SVGPathSegLinetoVerticalRel": false,
  33840. "SVGPathSegList": false,
  33841. "SVGPathSegMovetoAbs": false,
  33842. "SVGPathSegMovetoRel": false,
  33843. "SVGPatternElement": false,
  33844. "SVGPoint": false,
  33845. "SVGPointList": false,
  33846. "SVGPolygonElement": false,
  33847. "SVGPolylineElement": false,
  33848. "SVGPreserveAspectRatio": false,
  33849. "SVGRadialGradientElement": false,
  33850. "SVGRect": false,
  33851. "SVGRectElement": false,
  33852. "SVGRenderingIntent": false,
  33853. "SVGScriptElement": false,
  33854. "SVGSetElement": false,
  33855. "SVGStopElement": false,
  33856. "SVGStringList": false,
  33857. "SVGStylable": false,
  33858. "SVGStyleElement": false,
  33859. "SVGSVGElement": false,
  33860. "SVGSwitchElement": false,
  33861. "SVGSymbolElement": false,
  33862. "SVGTests": false,
  33863. "SVGTextContentElement": false,
  33864. "SVGTextElement": false,
  33865. "SVGTextPathElement": false,
  33866. "SVGTextPositioningElement": false,
  33867. "SVGTitleElement": false,
  33868. "SVGTransform": false,
  33869. "SVGTransformable": false,
  33870. "SVGTransformList": false,
  33871. "SVGTRefElement": false,
  33872. "SVGTSpanElement": false,
  33873. "SVGUnitTypes": false,
  33874. "SVGURIReference": false,
  33875. "SVGUseElement": false,
  33876. "SVGViewElement": false,
  33877. "SVGViewSpec": false,
  33878. "SVGVKernElement": false,
  33879. "SVGZoomAndPan": false,
  33880. "Text": false,
  33881. "TextDecoder": false,
  33882. "TextEncoder": false,
  33883. "TimeEvent": false,
  33884. "top": false,
  33885. "TouchEvent": false,
  33886. "UIEvent": false,
  33887. "URL": false,
  33888. "WebGLActiveInfo": false,
  33889. "WebGLBuffer": false,
  33890. "WebGLContextEvent": false,
  33891. "WebGLFramebuffer": false,
  33892. "WebGLProgram": false,
  33893. "WebGLRenderbuffer": false,
  33894. "WebGLRenderingContext": false,
  33895. "WebGLShader": false,
  33896. "WebGLShaderPrecisionFormat": false,
  33897. "WebGLTexture": false,
  33898. "WebGLUniformLocation": false,
  33899. "WebSocket": false,
  33900. "WheelEvent": false,
  33901. "window": false,
  33902. "Window": false,
  33903. "Worker": false,
  33904. "XDomainRequest": false,
  33905. "XMLHttpRequest": false,
  33906. "XMLSerializer": false,
  33907. "XPathEvaluator": false,
  33908. "XPathException": false,
  33909. "XPathExpression": false,
  33910. "XPathNamespace": false,
  33911. "XPathNSResolver": false,
  33912. "XPathResult": false
  33913. },
  33914. "worker": {
  33915. "importScripts": true,
  33916. "postMessage": true,
  33917. "self": true
  33918. },
  33919. "node": {
  33920. "__dirname": false,
  33921. "__filename": false,
  33922. "arguments": false,
  33923. "Buffer": false,
  33924. "clearImmediate": false,
  33925. "clearInterval": false,
  33926. "clearTimeout": false,
  33927. "console": false,
  33928. "DataView": false,
  33929. "exports": true,
  33930. "GLOBAL": false,
  33931. "global": false,
  33932. "module": false,
  33933. "process": false,
  33934. "require": false,
  33935. "setImmediate": false,
  33936. "setInterval": false,
  33937. "setTimeout": false
  33938. },
  33939. "amd": {
  33940. "define": false,
  33941. "require": false
  33942. },
  33943. "mocha": {
  33944. "after": false,
  33945. "afterEach": false,
  33946. "before": false,
  33947. "beforeEach": false,
  33948. "context": false,
  33949. "describe": false,
  33950. "it": false,
  33951. "setup": false,
  33952. "specify": false,
  33953. "suite": false,
  33954. "suiteSetup": false,
  33955. "suiteTeardown": false,
  33956. "teardown": false,
  33957. "test": false,
  33958. "xcontext": false,
  33959. "xdescribe": false,
  33960. "xit": false,
  33961. "xspecify": false
  33962. },
  33963. "jasmine": {
  33964. "afterAll": false,
  33965. "afterEach": false,
  33966. "beforeAll": false,
  33967. "beforeEach": false,
  33968. "describe": false,
  33969. "expect": false,
  33970. "fail": false,
  33971. "fdescribe": false,
  33972. "fit": false,
  33973. "it": false,
  33974. "jasmine": false,
  33975. "pending": false,
  33976. "runs": false,
  33977. "spyOn": false,
  33978. "waits": false,
  33979. "waitsFor": false,
  33980. "xdescribe": false,
  33981. "xit": false
  33982. },
  33983. "qunit": {
  33984. "asyncTest": false,
  33985. "deepEqual": false,
  33986. "equal": false,
  33987. "expect": false,
  33988. "module": false,
  33989. "notDeepEqual": false,
  33990. "notEqual": false,
  33991. "notPropEqual": false,
  33992. "notStrictEqual": false,
  33993. "ok": false,
  33994. "propEqual": false,
  33995. "QUnit": false,
  33996. "raises": false,
  33997. "start": false,
  33998. "stop": false,
  33999. "strictEqual": false,
  34000. "test": false,
  34001. "throws": false
  34002. },
  34003. "phantomjs": {
  34004. "console": true,
  34005. "exports": true,
  34006. "phantom": true,
  34007. "require": true,
  34008. "WebPage": true
  34009. },
  34010. "couch": {
  34011. "emit": false,
  34012. "exports": false,
  34013. "getRow": false,
  34014. "log": false,
  34015. "module": false,
  34016. "provides": false,
  34017. "require": false,
  34018. "respond": false,
  34019. "send": false,
  34020. "start": false,
  34021. "sum": false
  34022. },
  34023. "rhino": {
  34024. "defineClass": false,
  34025. "deserialize": false,
  34026. "gc": false,
  34027. "help": false,
  34028. "importClass": false,
  34029. "importPackage": false,
  34030. "java": false,
  34031. "load": false,
  34032. "loadClass": false,
  34033. "Packages": false,
  34034. "print": false,
  34035. "quit": false,
  34036. "readFile": false,
  34037. "readUrl": false,
  34038. "runCommand": false,
  34039. "seal": false,
  34040. "serialize": false,
  34041. "spawn": false,
  34042. "sync": false,
  34043. "toint32": false,
  34044. "version": false
  34045. },
  34046. "wsh": {
  34047. "ActiveXObject": true,
  34048. "Enumerator": true,
  34049. "GetObject": true,
  34050. "ScriptEngine": true,
  34051. "ScriptEngineBuildVersion": true,
  34052. "ScriptEngineMajorVersion": true,
  34053. "ScriptEngineMinorVersion": true,
  34054. "VBArray": true,
  34055. "WScript": true,
  34056. "WSH": true,
  34057. "XDomainRequest": true
  34058. },
  34059. "jquery": {
  34060. "$": false,
  34061. "jQuery": false
  34062. },
  34063. "yui": {
  34064. "Y": false,
  34065. "YUI": false,
  34066. "YUI_config": false
  34067. },
  34068. "shelljs": {
  34069. "cat": false,
  34070. "cd": false,
  34071. "chmod": false,
  34072. "config": false,
  34073. "cp": false,
  34074. "dirs": false,
  34075. "echo": false,
  34076. "env": false,
  34077. "error": false,
  34078. "exec": false,
  34079. "exit": false,
  34080. "find": false,
  34081. "grep": false,
  34082. "ls": false,
  34083. "mkdir": false,
  34084. "mv": false,
  34085. "popd": false,
  34086. "pushd": false,
  34087. "pwd": false,
  34088. "rm": false,
  34089. "sed": false,
  34090. "target": false,
  34091. "tempdir": false,
  34092. "test": false,
  34093. "which": false
  34094. },
  34095. "prototypejs": {
  34096. "$": false,
  34097. "$$": false,
  34098. "$A": false,
  34099. "$break": false,
  34100. "$continue": false,
  34101. "$F": false,
  34102. "$H": false,
  34103. "$R": false,
  34104. "$w": false,
  34105. "Abstract": false,
  34106. "Ajax": false,
  34107. "Autocompleter": false,
  34108. "Builder": false,
  34109. "Class": false,
  34110. "Control": false,
  34111. "Draggable": false,
  34112. "Draggables": false,
  34113. "Droppables": false,
  34114. "Effect": false,
  34115. "Element": false,
  34116. "Enumerable": false,
  34117. "Event": false,
  34118. "Field": false,
  34119. "Form": false,
  34120. "Hash": false,
  34121. "Insertion": false,
  34122. "ObjectRange": false,
  34123. "PeriodicalExecuter": false,
  34124. "Position": false,
  34125. "Prototype": false,
  34126. "Scriptaculous": false,
  34127. "Selector": false,
  34128. "Sortable": false,
  34129. "SortableObserver": false,
  34130. "Sound": false,
  34131. "Template": false,
  34132. "Toggle": false,
  34133. "Try": false
  34134. },
  34135. "meteor": {
  34136. "$": false,
  34137. "_": false,
  34138. "Accounts": false,
  34139. "App": false,
  34140. "Assets": false,
  34141. "Blaze": false,
  34142. "check": false,
  34143. "Cordova": false,
  34144. "DDP": false,
  34145. "DDPServer": false,
  34146. "Deps": false,
  34147. "EJSON": false,
  34148. "Email": false,
  34149. "HTTP": false,
  34150. "Log": false,
  34151. "Match": false,
  34152. "Meteor": false,
  34153. "Mongo": false,
  34154. "MongoInternals": false,
  34155. "Npm": false,
  34156. "Package": false,
  34157. "Plugin": false,
  34158. "process": false,
  34159. "Random": false,
  34160. "ReactiveDict": false,
  34161. "ReactiveVar": false,
  34162. "Router": false,
  34163. "Session": false,
  34164. "share": false,
  34165. "Spacebars": false,
  34166. "Template": false,
  34167. "Tinytest": false,
  34168. "Tracker": false,
  34169. "UI": false,
  34170. "Utils": false,
  34171. "WebApp": false,
  34172. "WebAppInternals": false
  34173. },
  34174. "mongo": {
  34175. "_isWindows": false,
  34176. "_rand": false,
  34177. "BulkWriteResult": false,
  34178. "cat": false,
  34179. "cd": false,
  34180. "connect": false,
  34181. "db": false,
  34182. "getHostName": false,
  34183. "getMemInfo": false,
  34184. "hostname": false,
  34185. "listFiles": false,
  34186. "load": false,
  34187. "ls": false,
  34188. "md5sumFile": false,
  34189. "mkdir": false,
  34190. "Mongo": false,
  34191. "ObjectId": false,
  34192. "PlanCache": false,
  34193. "pwd": false,
  34194. "quit": false,
  34195. "removeFile": false,
  34196. "rs": false,
  34197. "sh": false,
  34198. "UUID": false,
  34199. "version": false,
  34200. "WriteResult": false
  34201. },
  34202. "applescript": {
  34203. "$": false,
  34204. "Application": false,
  34205. "Automation": false,
  34206. "console": false,
  34207. "delay": false,
  34208. "Library": false,
  34209. "ObjC": false,
  34210. "ObjectSpecifier": false,
  34211. "Path": false,
  34212. "Progress": false,
  34213. "Ref": false
  34214. }
  34215. }
  34216. },{}],316:[function(require,module,exports){
  34217. module.exports = require('./globals.json');
  34218. },{"./globals.json":315}],317:[function(require,module,exports){
  34219. // https://github.com/paulmillr/es6-shim
  34220. // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isinteger
  34221. var isNaN = require("is-nan");
  34222. var isFinite = require("is-finite");
  34223. module.exports = Number.isInteger || function(val) {
  34224. return typeof val === "number" &&
  34225. ! isNaN(val) &&
  34226. isFinite(val) &&
  34227. parseInt(val, 10) === val;
  34228. };
  34229. },{"is-finite":318,"is-nan":319}],318:[function(require,module,exports){
  34230. 'use strict';
  34231. module.exports = Number.isFinite || function (val) {
  34232. // Number.isNaN() => val !== val
  34233. if (typeof val !== 'number' || val !== val || val === Infinity || val === -Infinity) {
  34234. return false;
  34235. }
  34236. return true;
  34237. };
  34238. },{}],319:[function(require,module,exports){
  34239. "use strict";
  34240. /* https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isnan */
  34241. module.exports = function isNaN(value) {
  34242. return value !== value;
  34243. };
  34244. },{}],320:[function(require,module,exports){
  34245. // Copyright 2014, 2015 Simon Lydell
  34246. // X11 (“MIT”) Licensed. (See LICENSE.)
  34247. // This regex comes from regex.coffee, and is inserted here by generate-index.js
  34248. // (run `npm run build`).
  34249. module.exports = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\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]{1,6}\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-*\/%&|^]|<{1,2}|>{1,3}|!=?|={1,2})=?|[?:~]|[;,.[\](){}])|(\s+)|(^$|[\s\S])/g
  34250. module.exports.matchToToken = function(match) {
  34251. token = {type: "invalid", value: match[0]}
  34252. if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
  34253. else if (match[ 5]) token.type = "comment"
  34254. else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
  34255. else if (match[ 8]) token.type = "regex"
  34256. else if (match[ 9]) token.type = "number"
  34257. else if (match[10]) token.type = "name"
  34258. else if (match[11]) token.type = "punctuator"
  34259. else if (match[12]) token.type = "whitespace"
  34260. return token
  34261. }
  34262. },{}],321:[function(require,module,exports){
  34263. // intentionally commented out as it makes it slower...
  34264. //'use strict';
  34265. var arr = [];
  34266. var charCodeCache = [];
  34267. module.exports = function (a, b) {
  34268. if (a === b) {
  34269. return 0;
  34270. }
  34271. var aLen = a.length;
  34272. var bLen = b.length;
  34273. if (aLen === 0) {
  34274. return bLen;
  34275. }
  34276. if (bLen === 0) {
  34277. return aLen;
  34278. }
  34279. var bCharCode;
  34280. var ret;
  34281. var tmp;
  34282. var tmp2;
  34283. var i = 0;
  34284. var j = 0;
  34285. while (i < aLen) {
  34286. charCodeCache[i] = a.charCodeAt(i);
  34287. arr[i] = ++i;
  34288. }
  34289. while (j < bLen) {
  34290. bCharCode = b.charCodeAt(j);
  34291. tmp = j++;
  34292. ret = j;
  34293. for (i = 0; i < aLen; i++) {
  34294. tmp2 = bCharCode === charCodeCache[i] ? tmp : tmp + 1;
  34295. tmp = arr[i];
  34296. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  34297. }
  34298. }
  34299. return ret;
  34300. };
  34301. },{}],322:[function(require,module,exports){
  34302. // Copyright 2014, 2015 Simon Lydell
  34303. // X11 (“MIT”) Licensed. (See LICENSE.)
  34304. var leftPad = require("left-pad")
  34305. function get(options, key, defaultValue) {
  34306. return (key in options ? options[key] : defaultValue)
  34307. }
  34308. function lineNumbers(code, options) {
  34309. var getOption = get.bind(null, options || {})
  34310. var transform = getOption("transform", Function.prototype)
  34311. var padding = getOption("padding", " ")
  34312. var before = getOption("before", " ")
  34313. var after = getOption("after", " | ")
  34314. var start = getOption("start", 1)
  34315. var isArray = Array.isArray(code)
  34316. var lines = (isArray ? code : code.split("\n"))
  34317. var end = start + lines.length - 1
  34318. var width = String(end).length
  34319. var numbered = lines.map(function(line, index) {
  34320. var number = start + index
  34321. var params = {before: before, number: number, width: width, after: after,
  34322. line: line}
  34323. transform(params)
  34324. return params.before + leftPad(params.number, width, padding) +
  34325. params.after + params.line
  34326. })
  34327. return (isArray ? numbered : numbered.join("\n"))
  34328. }
  34329. module.exports = lineNumbers
  34330. },{"left-pad":323}],323:[function(require,module,exports){
  34331. module.exports = leftpad;
  34332. function leftpad (str, len, ch) {
  34333. str = String(str);
  34334. var i = -1;
  34335. ch || (ch = ' ');
  34336. len = len - str.length;
  34337. while (++i < len) {
  34338. str = ch + str;
  34339. }
  34340. return str;
  34341. }
  34342. },{}],324:[function(require,module,exports){
  34343. /**
  34344. * Creates an array with all falsey values removed. The values `false`, `null`,
  34345. * `0`, `""`, `undefined`, and `NaN` are falsey.
  34346. *
  34347. * @static
  34348. * @memberOf _
  34349. * @category Array
  34350. * @param {Array} array The array to compact.
  34351. * @returns {Array} Returns the new array of filtered values.
  34352. * @example
  34353. *
  34354. * _.compact([0, 1, false, 2, '', 3]);
  34355. * // => [1, 2, 3]
  34356. */
  34357. function compact(array) {
  34358. var index = -1,
  34359. length = array ? array.length : 0,
  34360. resIndex = -1,
  34361. result = [];
  34362. while (++index < length) {
  34363. var value = array[index];
  34364. if (value) {
  34365. result[++resIndex] = value;
  34366. }
  34367. }
  34368. return result;
  34369. }
  34370. module.exports = compact;
  34371. },{}],325:[function(require,module,exports){
  34372. var baseFlatten = require('../internal/baseFlatten'),
  34373. isIterateeCall = require('../internal/isIterateeCall');
  34374. /**
  34375. * Flattens a nested array. If `isDeep` is `true` the array is recursively
  34376. * flattened, otherwise it is only flattened a single level.
  34377. *
  34378. * @static
  34379. * @memberOf _
  34380. * @category Array
  34381. * @param {Array} array The array to flatten.
  34382. * @param {boolean} [isDeep] Specify a deep flatten.
  34383. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
  34384. * @returns {Array} Returns the new flattened array.
  34385. * @example
  34386. *
  34387. * _.flatten([1, [2, 3, [4]]]);
  34388. * // => [1, 2, 3, [4]]
  34389. *
  34390. * // using `isDeep`
  34391. * _.flatten([1, [2, 3, [4]]], true);
  34392. * // => [1, 2, 3, 4]
  34393. */
  34394. function flatten(array, isDeep, guard) {
  34395. var length = array ? array.length : 0;
  34396. if (guard && isIterateeCall(array, isDeep, guard)) {
  34397. isDeep = false;
  34398. }
  34399. return length ? baseFlatten(array, isDeep) : [];
  34400. }
  34401. module.exports = flatten;
  34402. },{"../internal/baseFlatten":352,"../internal/isIterateeCall":394}],326:[function(require,module,exports){
  34403. /**
  34404. * Gets the last element of `array`.
  34405. *
  34406. * @static
  34407. * @memberOf _
  34408. * @category Array
  34409. * @param {Array} array The array to query.
  34410. * @returns {*} Returns the last element of `array`.
  34411. * @example
  34412. *
  34413. * _.last([1, 2, 3]);
  34414. * // => 3
  34415. */
  34416. function last(array) {
  34417. var length = array ? array.length : 0;
  34418. return length ? array[length - 1] : undefined;
  34419. }
  34420. module.exports = last;
  34421. },{}],327:[function(require,module,exports){
  34422. var baseIndexOf = require('../internal/baseIndexOf');
  34423. /** Used for native method references. */
  34424. var arrayProto = Array.prototype;
  34425. /** Native method references. */
  34426. var splice = arrayProto.splice;
  34427. /**
  34428. * Removes all provided values from `array` using `SameValueZero` for equality
  34429. * comparisons.
  34430. *
  34431. * **Notes:**
  34432. * - Unlike `_.without`, this method mutates `array`
  34433. * - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
  34434. * comparisons are like strict equality comparisons, e.g. `===`, except
  34435. * that `NaN` matches `NaN`
  34436. *
  34437. * @static
  34438. * @memberOf _
  34439. * @category Array
  34440. * @param {Array} array The array to modify.
  34441. * @param {...*} [values] The values to remove.
  34442. * @returns {Array} Returns `array`.
  34443. * @example
  34444. *
  34445. * var array = [1, 2, 3, 1, 2, 3];
  34446. *
  34447. * _.pull(array, 2, 3);
  34448. * console.log(array);
  34449. * // => [1, 1]
  34450. */
  34451. function pull() {
  34452. var args = arguments,
  34453. array = args[0];
  34454. if (!(array && array.length)) {
  34455. return array;
  34456. }
  34457. var index = 0,
  34458. indexOf = baseIndexOf,
  34459. length = args.length;
  34460. while (++index < length) {
  34461. var fromIndex = 0,
  34462. value = args[index];
  34463. while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
  34464. splice.call(array, fromIndex, 1);
  34465. }
  34466. }
  34467. return array;
  34468. }
  34469. module.exports = pull;
  34470. },{"../internal/baseIndexOf":358}],328:[function(require,module,exports){
  34471. var baseCallback = require('../internal/baseCallback'),
  34472. baseUniq = require('../internal/baseUniq'),
  34473. isIterateeCall = require('../internal/isIterateeCall'),
  34474. sortedUniq = require('../internal/sortedUniq');
  34475. /**
  34476. * Creates a duplicate-value-free version of an array using `SameValueZero`
  34477. * for equality comparisons. Providing `true` for `isSorted` performs a faster
  34478. * search algorithm for sorted arrays. If an iteratee function is provided it
  34479. * is invoked for each value in the array to generate the criterion by which
  34480. * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
  34481. * with three arguments: (value, index, array).
  34482. *
  34483. * If a property name is provided for `iteratee` the created `_.property`
  34484. * style callback returns the property value of the given element.
  34485. *
  34486. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  34487. * style callback returns `true` for elements that have a matching property
  34488. * value, else `false`.
  34489. *
  34490. * If an object is provided for `iteratee` the created `_.matches` style
  34491. * callback returns `true` for elements that have the properties of the given
  34492. * object, else `false`.
  34493. *
  34494. * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
  34495. * comparisons are like strict equality comparisons, e.g. `===`, except that
  34496. * `NaN` matches `NaN`.
  34497. *
  34498. * @static
  34499. * @memberOf _
  34500. * @alias unique
  34501. * @category Array
  34502. * @param {Array} array The array to inspect.
  34503. * @param {boolean} [isSorted] Specify the array is sorted.
  34504. * @param {Function|Object|string} [iteratee] The function invoked per iteration.
  34505. * @param {*} [thisArg] The `this` binding of `iteratee`.
  34506. * @returns {Array} Returns the new duplicate-value-free array.
  34507. * @example
  34508. *
  34509. * _.uniq([1, 2, 1]);
  34510. * // => [1, 2]
  34511. *
  34512. * // using `isSorted`
  34513. * _.uniq([1, 1, 2], true);
  34514. * // => [1, 2]
  34515. *
  34516. * // using an iteratee function
  34517. * _.uniq([1, 2.5, 1.5, 2], function(n) {
  34518. * return this.floor(n);
  34519. * }, Math);
  34520. * // => [1, 2.5]
  34521. *
  34522. * // using the `_.property` callback shorthand
  34523. * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  34524. * // => [{ 'x': 1 }, { 'x': 2 }]
  34525. */
  34526. function uniq(array, isSorted, iteratee, thisArg) {
  34527. var length = array ? array.length : 0;
  34528. if (!length) {
  34529. return [];
  34530. }
  34531. if (isSorted != null && typeof isSorted != 'boolean') {
  34532. thisArg = iteratee;
  34533. iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
  34534. isSorted = false;
  34535. }
  34536. iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3);
  34537. return (isSorted)
  34538. ? sortedUniq(array, iteratee)
  34539. : baseUniq(array, iteratee);
  34540. }
  34541. module.exports = uniq;
  34542. },{"../internal/baseCallback":346,"../internal/baseUniq":373,"../internal/isIterateeCall":394,"../internal/sortedUniq":400}],329:[function(require,module,exports){
  34543. module.exports = require('./includes');
  34544. },{"./includes":332}],330:[function(require,module,exports){
  34545. module.exports = require('./forEach');
  34546. },{"./forEach":331}],331:[function(require,module,exports){
  34547. var arrayEach = require('../internal/arrayEach'),
  34548. baseEach = require('../internal/baseEach'),
  34549. createForEach = require('../internal/createForEach');
  34550. /**
  34551. * Iterates over elements of `collection` invoking `iteratee` for each element.
  34552. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  34553. * (value, index|key, collection). Iterator functions may exit iteration early
  34554. * by explicitly returning `false`.
  34555. *
  34556. * **Note:** As with other "Collections" methods, objects with a `length` property
  34557. * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
  34558. * may be used for object iteration.
  34559. *
  34560. * @static
  34561. * @memberOf _
  34562. * @alias each
  34563. * @category Collection
  34564. * @param {Array|Object|string} collection The collection to iterate over.
  34565. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  34566. * @param {*} [thisArg] The `this` binding of `iteratee`.
  34567. * @returns {Array|Object|string} Returns `collection`.
  34568. * @example
  34569. *
  34570. * _([1, 2]).forEach(function(n) {
  34571. * console.log(n);
  34572. * }).value();
  34573. * // => logs each value from left to right and returns the array
  34574. *
  34575. * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
  34576. * console.log(n, key);
  34577. * });
  34578. * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
  34579. */
  34580. var forEach = createForEach(arrayEach, baseEach);
  34581. module.exports = forEach;
  34582. },{"../internal/arrayEach":340,"../internal/baseEach":350,"../internal/createForEach":384}],332:[function(require,module,exports){
  34583. var baseIndexOf = require('../internal/baseIndexOf'),
  34584. isArray = require('../lang/isArray'),
  34585. isIterateeCall = require('../internal/isIterateeCall'),
  34586. isLength = require('../internal/isLength'),
  34587. isString = require('../lang/isString'),
  34588. values = require('../object/values');
  34589. /* Native method references for those with the same name as other `lodash` methods. */
  34590. var nativeMax = Math.max;
  34591. /**
  34592. * Checks if `value` is in `collection` using `SameValueZero` for equality
  34593. * comparisons. If `fromIndex` is negative, it is used as the offset from
  34594. * the end of `collection`.
  34595. *
  34596. * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
  34597. * comparisons are like strict equality comparisons, e.g. `===`, except that
  34598. * `NaN` matches `NaN`.
  34599. *
  34600. * @static
  34601. * @memberOf _
  34602. * @alias contains, include
  34603. * @category Collection
  34604. * @param {Array|Object|string} collection The collection to search.
  34605. * @param {*} target The value to search for.
  34606. * @param {number} [fromIndex=0] The index to search from.
  34607. * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
  34608. * @returns {boolean} Returns `true` if a matching element is found, else `false`.
  34609. * @example
  34610. *
  34611. * _.includes([1, 2, 3], 1);
  34612. * // => true
  34613. *
  34614. * _.includes([1, 2, 3], 1, 2);
  34615. * // => false
  34616. *
  34617. * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
  34618. * // => true
  34619. *
  34620. * _.includes('pebbles', 'eb');
  34621. * // => true
  34622. */
  34623. function includes(collection, target, fromIndex, guard) {
  34624. var length = collection ? collection.length : 0;
  34625. if (!isLength(length)) {
  34626. collection = values(collection);
  34627. length = collection.length;
  34628. }
  34629. if (!length) {
  34630. return false;
  34631. }
  34632. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  34633. fromIndex = 0;
  34634. } else {
  34635. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  34636. }
  34637. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  34638. ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
  34639. : (baseIndexOf(collection, target, fromIndex) > -1);
  34640. }
  34641. module.exports = includes;
  34642. },{"../internal/baseIndexOf":358,"../internal/isIterateeCall":394,"../internal/isLength":395,"../lang/isArray":405,"../lang/isString":414,"../object/values":424}],333:[function(require,module,exports){
  34643. var arrayMap = require('../internal/arrayMap'),
  34644. baseCallback = require('../internal/baseCallback'),
  34645. baseMap = require('../internal/baseMap'),
  34646. isArray = require('../lang/isArray');
  34647. /**
  34648. * Creates an array of values by running each element in `collection` through
  34649. * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
  34650. * arguments: (value, index|key, collection).
  34651. *
  34652. * If a property name is provided for `iteratee` the created `_.property`
  34653. * style callback returns the property value of the given element.
  34654. *
  34655. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  34656. * style callback returns `true` for elements that have a matching property
  34657. * value, else `false`.
  34658. *
  34659. * If an object is provided for `iteratee` the created `_.matches` style
  34660. * callback returns `true` for elements that have the properties of the given
  34661. * object, else `false`.
  34662. *
  34663. * Many lodash methods are guarded to work as interatees for methods like
  34664. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  34665. *
  34666. * The guarded methods are:
  34667. * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
  34668. * `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
  34669. * `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
  34670. * `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
  34671. *
  34672. * @static
  34673. * @memberOf _
  34674. * @alias collect
  34675. * @category Collection
  34676. * @param {Array|Object|string} collection The collection to iterate over.
  34677. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  34678. * per iteration.
  34679. * create a `_.property` or `_.matches` style callback respectively.
  34680. * @param {*} [thisArg] The `this` binding of `iteratee`.
  34681. * @returns {Array} Returns the new mapped array.
  34682. * @example
  34683. *
  34684. * function timesThree(n) {
  34685. * return n * 3;
  34686. * }
  34687. *
  34688. * _.map([1, 2], timesThree);
  34689. * // => [3, 6]
  34690. *
  34691. * _.map({ 'a': 1, 'b': 2 }, timesThree);
  34692. * // => [3, 6] (iteration order is not guaranteed)
  34693. *
  34694. * var users = [
  34695. * { 'user': 'barney' },
  34696. * { 'user': 'fred' }
  34697. * ];
  34698. *
  34699. * // using the `_.property` callback shorthand
  34700. * _.map(users, 'user');
  34701. * // => ['barney', 'fred']
  34702. */
  34703. function map(collection, iteratee, thisArg) {
  34704. var func = isArray(collection) ? arrayMap : baseMap;
  34705. iteratee = baseCallback(iteratee, thisArg, 3);
  34706. return func(collection, iteratee);
  34707. }
  34708. module.exports = map;
  34709. },{"../internal/arrayMap":341,"../internal/baseCallback":346,"../internal/baseMap":363,"../lang/isArray":405}],334:[function(require,module,exports){
  34710. var arrayReduceRight = require('../internal/arrayReduceRight'),
  34711. baseEachRight = require('../internal/baseEachRight'),
  34712. createReduce = require('../internal/createReduce');
  34713. /**
  34714. * This method is like `_.reduce` except that it iterates over elements of
  34715. * `collection` from right to left.
  34716. *
  34717. * @static
  34718. * @memberOf _
  34719. * @alias foldr
  34720. * @category Collection
  34721. * @param {Array|Object|string} collection The collection to iterate over.
  34722. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  34723. * @param {*} [accumulator] The initial value.
  34724. * @param {*} [thisArg] The `this` binding of `iteratee`.
  34725. * @returns {*} Returns the accumulated value.
  34726. * @example
  34727. *
  34728. * var array = [[0, 1], [2, 3], [4, 5]];
  34729. *
  34730. * _.reduceRight(array, function(flattened, other) {
  34731. * return flattened.concat(other);
  34732. * }, []);
  34733. * // => [4, 5, 2, 3, 0, 1]
  34734. */
  34735. var reduceRight = createReduce(arrayReduceRight, baseEachRight);
  34736. module.exports = reduceRight;
  34737. },{"../internal/arrayReduceRight":342,"../internal/baseEachRight":351,"../internal/createReduce":385}],335:[function(require,module,exports){
  34738. var arraySome = require('../internal/arraySome'),
  34739. baseCallback = require('../internal/baseCallback'),
  34740. baseSome = require('../internal/baseSome'),
  34741. isArray = require('../lang/isArray'),
  34742. isIterateeCall = require('../internal/isIterateeCall');
  34743. /**
  34744. * Checks if `predicate` returns truthy for **any** element of `collection`.
  34745. * The function returns as soon as it finds a passing value and does not iterate
  34746. * over the entire collection. The predicate is bound to `thisArg` and invoked
  34747. * with three arguments: (value, index|key, collection).
  34748. *
  34749. * If a property name is provided for `predicate` the created `_.property`
  34750. * style callback returns the property value of the given element.
  34751. *
  34752. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  34753. * style callback returns `true` for elements that have a matching property
  34754. * value, else `false`.
  34755. *
  34756. * If an object is provided for `predicate` the created `_.matches` style
  34757. * callback returns `true` for elements that have the properties of the given
  34758. * object, else `false`.
  34759. *
  34760. * @static
  34761. * @memberOf _
  34762. * @alias any
  34763. * @category Collection
  34764. * @param {Array|Object|string} collection The collection to iterate over.
  34765. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  34766. * per iteration.
  34767. * @param {*} [thisArg] The `this` binding of `predicate`.
  34768. * @returns {boolean} Returns `true` if any element passes the predicate check,
  34769. * else `false`.
  34770. * @example
  34771. *
  34772. * _.some([null, 0, 'yes', false], Boolean);
  34773. * // => true
  34774. *
  34775. * var users = [
  34776. * { 'user': 'barney', 'active': true },
  34777. * { 'user': 'fred', 'active': false }
  34778. * ];
  34779. *
  34780. * // using the `_.matches` callback shorthand
  34781. * _.some(users, { 'user': 'barney', 'active': false });
  34782. * // => false
  34783. *
  34784. * // using the `_.matchesProperty` callback shorthand
  34785. * _.some(users, 'active', false);
  34786. * // => true
  34787. *
  34788. * // using the `_.property` callback shorthand
  34789. * _.some(users, 'active');
  34790. * // => true
  34791. */
  34792. function some(collection, predicate, thisArg) {
  34793. var func = isArray(collection) ? arraySome : baseSome;
  34794. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  34795. predicate = null;
  34796. }
  34797. if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
  34798. predicate = baseCallback(predicate, thisArg, 3);
  34799. }
  34800. return func(collection, predicate);
  34801. }
  34802. module.exports = some;
  34803. },{"../internal/arraySome":343,"../internal/baseCallback":346,"../internal/baseSome":370,"../internal/isIterateeCall":394,"../lang/isArray":405}],336:[function(require,module,exports){
  34804. var baseCallback = require('../internal/baseCallback'),
  34805. baseEach = require('../internal/baseEach'),
  34806. baseSortBy = require('../internal/baseSortBy'),
  34807. compareAscending = require('../internal/compareAscending'),
  34808. isIterateeCall = require('../internal/isIterateeCall'),
  34809. isLength = require('../internal/isLength');
  34810. /**
  34811. * Creates an array of elements, sorted in ascending order by the results of
  34812. * running each element in a collection through `iteratee`. This method performs
  34813. * a stable sort, that is, it preserves the original sort order of equal elements.
  34814. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  34815. * (value, index|key, collection).
  34816. *
  34817. * If a property name is provided for `iteratee` the created `_.property`
  34818. * style callback returns the property value of the given element.
  34819. *
  34820. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  34821. * style callback returns `true` for elements that have a matching property
  34822. * value, else `false`.
  34823. *
  34824. * If an object is provided for `iteratee` the created `_.matches` style
  34825. * callback returns `true` for elements that have the properties of the given
  34826. * object, else `false`.
  34827. *
  34828. * @static
  34829. * @memberOf _
  34830. * @category Collection
  34831. * @param {Array|Object|string} collection The collection to iterate over.
  34832. * @param {Array|Function|Object|string} [iteratee=_.identity] The function
  34833. * invoked per iteration. If a property name or an object is provided it is
  34834. * used to create a `_.property` or `_.matches` style callback respectively.
  34835. * @param {*} [thisArg] The `this` binding of `iteratee`.
  34836. * @returns {Array} Returns the new sorted array.
  34837. * @example
  34838. *
  34839. * _.sortBy([1, 2, 3], function(n) {
  34840. * return Math.sin(n);
  34841. * });
  34842. * // => [3, 1, 2]
  34843. *
  34844. * _.sortBy([1, 2, 3], function(n) {
  34845. * return this.sin(n);
  34846. * }, Math);
  34847. * // => [3, 1, 2]
  34848. *
  34849. * var users = [
  34850. * { 'user': 'fred' },
  34851. * { 'user': 'pebbles' },
  34852. * { 'user': 'barney' }
  34853. * ];
  34854. *
  34855. * // using the `_.property` callback shorthand
  34856. * _.pluck(_.sortBy(users, 'user'), 'user');
  34857. * // => ['barney', 'fred', 'pebbles']
  34858. */
  34859. function sortBy(collection, iteratee, thisArg) {
  34860. if (collection == null) {
  34861. return [];
  34862. }
  34863. var index = -1,
  34864. length = collection.length,
  34865. result = isLength(length) ? Array(length) : [];
  34866. if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
  34867. iteratee = null;
  34868. }
  34869. iteratee = baseCallback(iteratee, thisArg, 3);
  34870. baseEach(collection, function(value, key, collection) {
  34871. result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value };
  34872. });
  34873. return baseSortBy(result, compareAscending);
  34874. }
  34875. module.exports = sortBy;
  34876. },{"../internal/baseCallback":346,"../internal/baseEach":350,"../internal/baseSortBy":371,"../internal/compareAscending":379,"../internal/isIterateeCall":394,"../internal/isLength":395}],337:[function(require,module,exports){
  34877. /** Used as the `TypeError` message for "Functions" methods. */
  34878. var FUNC_ERROR_TEXT = 'Expected a function';
  34879. /* Native method references for those with the same name as other `lodash` methods. */
  34880. var nativeMax = Math.max;
  34881. /**
  34882. * Creates a function that invokes `func` with the `this` binding of the
  34883. * created function and arguments from `start` and beyond provided as an array.
  34884. *
  34885. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
  34886. *
  34887. * @static
  34888. * @memberOf _
  34889. * @category Function
  34890. * @param {Function} func The function to apply a rest parameter to.
  34891. * @param {number} [start=func.length-1] The start position of the rest parameter.
  34892. * @returns {Function} Returns the new function.
  34893. * @example
  34894. *
  34895. * var say = _.restParam(function(what, names) {
  34896. * return what + ' ' + _.initial(names).join(', ') +
  34897. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  34898. * });
  34899. *
  34900. * say('hello', 'fred', 'barney', 'pebbles');
  34901. * // => 'hello fred, barney, & pebbles'
  34902. */
  34903. function restParam(func, start) {
  34904. if (typeof func != 'function') {
  34905. throw new TypeError(FUNC_ERROR_TEXT);
  34906. }
  34907. start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
  34908. return function() {
  34909. var args = arguments,
  34910. index = -1,
  34911. length = nativeMax(args.length - start, 0),
  34912. rest = Array(length);
  34913. while (++index < length) {
  34914. rest[index] = args[start + index];
  34915. }
  34916. switch (start) {
  34917. case 0: return func.call(this, rest);
  34918. case 1: return func.call(this, args[0], rest);
  34919. case 2: return func.call(this, args[0], args[1], rest);
  34920. }
  34921. var otherArgs = Array(start + 1);
  34922. index = -1;
  34923. while (++index < start) {
  34924. otherArgs[index] = args[index];
  34925. }
  34926. otherArgs[start] = rest;
  34927. return func.apply(this, otherArgs);
  34928. };
  34929. }
  34930. module.exports = restParam;
  34931. },{}],338:[function(require,module,exports){
  34932. (function (global){
  34933. var cachePush = require('./cachePush'),
  34934. isNative = require('../lang/isNative');
  34935. /** Native method references. */
  34936. var Set = isNative(Set = global.Set) && Set;
  34937. /* Native method references for those with the same name as other `lodash` methods. */
  34938. var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
  34939. /**
  34940. *
  34941. * Creates a cache object to store unique values.
  34942. *
  34943. * @private
  34944. * @param {Array} [values] The values to cache.
  34945. */
  34946. function SetCache(values) {
  34947. var length = values ? values.length : 0;
  34948. this.data = { 'hash': nativeCreate(null), 'set': new Set };
  34949. while (length--) {
  34950. this.push(values[length]);
  34951. }
  34952. }
  34953. // Add functions to the `Set` cache.
  34954. SetCache.prototype.push = cachePush;
  34955. module.exports = SetCache;
  34956. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  34957. },{"../lang/isNative":409,"./cachePush":378}],339:[function(require,module,exports){
  34958. /**
  34959. * Copies the values of `source` to `array`.
  34960. *
  34961. * @private
  34962. * @param {Array} source The array to copy values from.
  34963. * @param {Array} [array=[]] The array to copy values to.
  34964. * @returns {Array} Returns `array`.
  34965. */
  34966. function arrayCopy(source, array) {
  34967. var index = -1,
  34968. length = source.length;
  34969. array || (array = Array(length));
  34970. while (++index < length) {
  34971. array[index] = source[index];
  34972. }
  34973. return array;
  34974. }
  34975. module.exports = arrayCopy;
  34976. },{}],340:[function(require,module,exports){
  34977. /**
  34978. * A specialized version of `_.forEach` for arrays without support for callback
  34979. * shorthands and `this` binding.
  34980. *
  34981. * @private
  34982. * @param {Array} array The array to iterate over.
  34983. * @param {Function} iteratee The function invoked per iteration.
  34984. * @returns {Array} Returns `array`.
  34985. */
  34986. function arrayEach(array, iteratee) {
  34987. var index = -1,
  34988. length = array.length;
  34989. while (++index < length) {
  34990. if (iteratee(array[index], index, array) === false) {
  34991. break;
  34992. }
  34993. }
  34994. return array;
  34995. }
  34996. module.exports = arrayEach;
  34997. },{}],341:[function(require,module,exports){
  34998. /**
  34999. * A specialized version of `_.map` for arrays without support for callback
  35000. * shorthands and `this` binding.
  35001. *
  35002. * @private
  35003. * @param {Array} array The array to iterate over.
  35004. * @param {Function} iteratee The function invoked per iteration.
  35005. * @returns {Array} Returns the new mapped array.
  35006. */
  35007. function arrayMap(array, iteratee) {
  35008. var index = -1,
  35009. length = array.length,
  35010. result = Array(length);
  35011. while (++index < length) {
  35012. result[index] = iteratee(array[index], index, array);
  35013. }
  35014. return result;
  35015. }
  35016. module.exports = arrayMap;
  35017. },{}],342:[function(require,module,exports){
  35018. /**
  35019. * A specialized version of `_.reduceRight` for arrays without support for
  35020. * callback shorthands and `this` binding.
  35021. *
  35022. * @private
  35023. * @param {Array} array The array to iterate over.
  35024. * @param {Function} iteratee The function invoked per iteration.
  35025. * @param {*} [accumulator] The initial value.
  35026. * @param {boolean} [initFromArray] Specify using the last element of `array`
  35027. * as the initial value.
  35028. * @returns {*} Returns the accumulated value.
  35029. */
  35030. function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
  35031. var length = array.length;
  35032. if (initFromArray && length) {
  35033. accumulator = array[--length];
  35034. }
  35035. while (length--) {
  35036. accumulator = iteratee(accumulator, array[length], length, array);
  35037. }
  35038. return accumulator;
  35039. }
  35040. module.exports = arrayReduceRight;
  35041. },{}],343:[function(require,module,exports){
  35042. /**
  35043. * A specialized version of `_.some` for arrays without support for callback
  35044. * shorthands and `this` binding.
  35045. *
  35046. * @private
  35047. * @param {Array} array The array to iterate over.
  35048. * @param {Function} predicate The function invoked per iteration.
  35049. * @returns {boolean} Returns `true` if any element passes the predicate check,
  35050. * else `false`.
  35051. */
  35052. function arraySome(array, predicate) {
  35053. var index = -1,
  35054. length = array.length;
  35055. while (++index < length) {
  35056. if (predicate(array[index], index, array)) {
  35057. return true;
  35058. }
  35059. }
  35060. return false;
  35061. }
  35062. module.exports = arraySome;
  35063. },{}],344:[function(require,module,exports){
  35064. /**
  35065. * Used by `_.defaults` to customize its `_.assign` use.
  35066. *
  35067. * @private
  35068. * @param {*} objectValue The destination object property value.
  35069. * @param {*} sourceValue The source object property value.
  35070. * @returns {*} Returns the value to assign to the destination object.
  35071. */
  35072. function assignDefaults(objectValue, sourceValue) {
  35073. return typeof objectValue == 'undefined' ? sourceValue : objectValue;
  35074. }
  35075. module.exports = assignDefaults;
  35076. },{}],345:[function(require,module,exports){
  35077. var baseCopy = require('./baseCopy'),
  35078. keys = require('../object/keys');
  35079. /**
  35080. * The base implementation of `_.assign` without support for argument juggling,
  35081. * multiple sources, and `this` binding `customizer` functions.
  35082. *
  35083. * @private
  35084. * @param {Object} object The destination object.
  35085. * @param {Object} source The source object.
  35086. * @param {Function} [customizer] The function to customize assigning values.
  35087. * @returns {Object} Returns the destination object.
  35088. */
  35089. function baseAssign(object, source, customizer) {
  35090. var props = keys(source);
  35091. if (!customizer) {
  35092. return baseCopy(source, object, props);
  35093. }
  35094. var index = -1,
  35095. length = props.length;
  35096. while (++index < length) {
  35097. var key = props[index],
  35098. value = object[key],
  35099. result = customizer(value, source[key], key, object, source);
  35100. if ((result === result ? (result !== value) : (value === value)) ||
  35101. (typeof value == 'undefined' && !(key in object))) {
  35102. object[key] = result;
  35103. }
  35104. }
  35105. return object;
  35106. }
  35107. module.exports = baseAssign;
  35108. },{"../object/keys":421,"./baseCopy":349}],346:[function(require,module,exports){
  35109. var baseMatches = require('./baseMatches'),
  35110. baseMatchesProperty = require('./baseMatchesProperty'),
  35111. baseProperty = require('./baseProperty'),
  35112. bindCallback = require('./bindCallback'),
  35113. identity = require('../utility/identity');
  35114. /**
  35115. * The base implementation of `_.callback` which supports specifying the
  35116. * number of arguments to provide to `func`.
  35117. *
  35118. * @private
  35119. * @param {*} [func=_.identity] The value to convert to a callback.
  35120. * @param {*} [thisArg] The `this` binding of `func`.
  35121. * @param {number} [argCount] The number of arguments to provide to `func`.
  35122. * @returns {Function} Returns the callback.
  35123. */
  35124. function baseCallback(func, thisArg, argCount) {
  35125. var type = typeof func;
  35126. if (type == 'function') {
  35127. return typeof thisArg == 'undefined'
  35128. ? func
  35129. : bindCallback(func, thisArg, argCount);
  35130. }
  35131. if (func == null) {
  35132. return identity;
  35133. }
  35134. if (type == 'object') {
  35135. return baseMatches(func);
  35136. }
  35137. return typeof thisArg == 'undefined'
  35138. ? baseProperty(func + '')
  35139. : baseMatchesProperty(func + '', thisArg);
  35140. }
  35141. module.exports = baseCallback;
  35142. },{"../utility/identity":429,"./baseMatches":364,"./baseMatchesProperty":365,"./baseProperty":368,"./bindCallback":375}],347:[function(require,module,exports){
  35143. var arrayCopy = require('./arrayCopy'),
  35144. arrayEach = require('./arrayEach'),
  35145. baseCopy = require('./baseCopy'),
  35146. baseForOwn = require('./baseForOwn'),
  35147. initCloneArray = require('./initCloneArray'),
  35148. initCloneByTag = require('./initCloneByTag'),
  35149. initCloneObject = require('./initCloneObject'),
  35150. isArray = require('../lang/isArray'),
  35151. isObject = require('../lang/isObject'),
  35152. keys = require('../object/keys');
  35153. /** `Object#toString` result references. */
  35154. var argsTag = '[object Arguments]',
  35155. arrayTag = '[object Array]',
  35156. boolTag = '[object Boolean]',
  35157. dateTag = '[object Date]',
  35158. errorTag = '[object Error]',
  35159. funcTag = '[object Function]',
  35160. mapTag = '[object Map]',
  35161. numberTag = '[object Number]',
  35162. objectTag = '[object Object]',
  35163. regexpTag = '[object RegExp]',
  35164. setTag = '[object Set]',
  35165. stringTag = '[object String]',
  35166. weakMapTag = '[object WeakMap]';
  35167. var arrayBufferTag = '[object ArrayBuffer]',
  35168. float32Tag = '[object Float32Array]',
  35169. float64Tag = '[object Float64Array]',
  35170. int8Tag = '[object Int8Array]',
  35171. int16Tag = '[object Int16Array]',
  35172. int32Tag = '[object Int32Array]',
  35173. uint8Tag = '[object Uint8Array]',
  35174. uint8ClampedTag = '[object Uint8ClampedArray]',
  35175. uint16Tag = '[object Uint16Array]',
  35176. uint32Tag = '[object Uint32Array]';
  35177. /** Used to identify `toStringTag` values supported by `_.clone`. */
  35178. var cloneableTags = {};
  35179. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  35180. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  35181. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  35182. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  35183. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  35184. cloneableTags[numberTag] = cloneableTags[objectTag] =
  35185. cloneableTags[regexpTag] = cloneableTags[stringTag] =
  35186. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  35187. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  35188. cloneableTags[errorTag] = cloneableTags[funcTag] =
  35189. cloneableTags[mapTag] = cloneableTags[setTag] =
  35190. cloneableTags[weakMapTag] = false;
  35191. /** Used for native method references. */
  35192. var objectProto = Object.prototype;
  35193. /**
  35194. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  35195. * of values.
  35196. */
  35197. var objToString = objectProto.toString;
  35198. /**
  35199. * The base implementation of `_.clone` without support for argument juggling
  35200. * and `this` binding `customizer` functions.
  35201. *
  35202. * @private
  35203. * @param {*} value The value to clone.
  35204. * @param {boolean} [isDeep] Specify a deep clone.
  35205. * @param {Function} [customizer] The function to customize cloning values.
  35206. * @param {string} [key] The key of `value`.
  35207. * @param {Object} [object] The object `value` belongs to.
  35208. * @param {Array} [stackA=[]] Tracks traversed source objects.
  35209. * @param {Array} [stackB=[]] Associates clones with source counterparts.
  35210. * @returns {*} Returns the cloned value.
  35211. */
  35212. function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
  35213. var result;
  35214. if (customizer) {
  35215. result = object ? customizer(value, key, object) : customizer(value);
  35216. }
  35217. if (typeof result != 'undefined') {
  35218. return result;
  35219. }
  35220. if (!isObject(value)) {
  35221. return value;
  35222. }
  35223. var isArr = isArray(value);
  35224. if (isArr) {
  35225. result = initCloneArray(value);
  35226. if (!isDeep) {
  35227. return arrayCopy(value, result);
  35228. }
  35229. } else {
  35230. var tag = objToString.call(value),
  35231. isFunc = tag == funcTag;
  35232. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  35233. result = initCloneObject(isFunc ? {} : value);
  35234. if (!isDeep) {
  35235. return baseCopy(value, result, keys(value));
  35236. }
  35237. } else {
  35238. return cloneableTags[tag]
  35239. ? initCloneByTag(value, tag, isDeep)
  35240. : (object ? value : {});
  35241. }
  35242. }
  35243. // Check for circular references and return corresponding clone.
  35244. stackA || (stackA = []);
  35245. stackB || (stackB = []);
  35246. var length = stackA.length;
  35247. while (length--) {
  35248. if (stackA[length] == value) {
  35249. return stackB[length];
  35250. }
  35251. }
  35252. // Add the source value to the stack of traversed objects and associate it with its clone.
  35253. stackA.push(value);
  35254. stackB.push(result);
  35255. // Recursively populate clone (susceptible to call stack limits).
  35256. (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
  35257. result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
  35258. });
  35259. return result;
  35260. }
  35261. module.exports = baseClone;
  35262. },{"../lang/isArray":405,"../lang/isObject":411,"../object/keys":421,"./arrayCopy":339,"./arrayEach":340,"./baseCopy":349,"./baseForOwn":355,"./initCloneArray":390,"./initCloneByTag":391,"./initCloneObject":392}],348:[function(require,module,exports){
  35263. /**
  35264. * The base implementation of `compareAscending` which compares values and
  35265. * sorts them in ascending order without guaranteeing a stable sort.
  35266. *
  35267. * @private
  35268. * @param {*} value The value to compare to `other`.
  35269. * @param {*} other The value to compare to `value`.
  35270. * @returns {number} Returns the sort order indicator for `value`.
  35271. */
  35272. function baseCompareAscending(value, other) {
  35273. if (value !== other) {
  35274. var valIsReflexive = value === value,
  35275. othIsReflexive = other === other;
  35276. if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) {
  35277. return 1;
  35278. }
  35279. if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) {
  35280. return -1;
  35281. }
  35282. }
  35283. return 0;
  35284. }
  35285. module.exports = baseCompareAscending;
  35286. },{}],349:[function(require,module,exports){
  35287. /**
  35288. * Copies the properties of `source` to `object`.
  35289. *
  35290. * @private
  35291. * @param {Object} source The object to copy properties from.
  35292. * @param {Object} [object={}] The object to copy properties to.
  35293. * @param {Array} props The property names to copy.
  35294. * @returns {Object} Returns `object`.
  35295. */
  35296. function baseCopy(source, object, props) {
  35297. if (!props) {
  35298. props = object;
  35299. object = {};
  35300. }
  35301. var index = -1,
  35302. length = props.length;
  35303. while (++index < length) {
  35304. var key = props[index];
  35305. object[key] = source[key];
  35306. }
  35307. return object;
  35308. }
  35309. module.exports = baseCopy;
  35310. },{}],350:[function(require,module,exports){
  35311. var baseForOwn = require('./baseForOwn'),
  35312. createBaseEach = require('./createBaseEach');
  35313. /**
  35314. * The base implementation of `_.forEach` without support for callback
  35315. * shorthands and `this` binding.
  35316. *
  35317. * @private
  35318. * @param {Array|Object|string} collection The collection to iterate over.
  35319. * @param {Function} iteratee The function invoked per iteration.
  35320. * @returns {Array|Object|string} Returns `collection`.
  35321. */
  35322. var baseEach = createBaseEach(baseForOwn);
  35323. module.exports = baseEach;
  35324. },{"./baseForOwn":355,"./createBaseEach":381}],351:[function(require,module,exports){
  35325. var baseForOwnRight = require('./baseForOwnRight'),
  35326. createBaseEach = require('./createBaseEach');
  35327. /**
  35328. * The base implementation of `_.forEachRight` without support for callback
  35329. * shorthands and `this` binding.
  35330. *
  35331. * @private
  35332. * @param {Array|Object|string} collection The collection to iterate over.
  35333. * @param {Function} iteratee The function invoked per iteration.
  35334. * @returns {Array|Object|string} Returns `collection`.
  35335. */
  35336. var baseEachRight = createBaseEach(baseForOwnRight, true);
  35337. module.exports = baseEachRight;
  35338. },{"./baseForOwnRight":356,"./createBaseEach":381}],352:[function(require,module,exports){
  35339. var isArguments = require('../lang/isArguments'),
  35340. isArray = require('../lang/isArray'),
  35341. isLength = require('./isLength'),
  35342. isObjectLike = require('./isObjectLike');
  35343. /**
  35344. * The base implementation of `_.flatten` with added support for restricting
  35345. * flattening and specifying the start index.
  35346. *
  35347. * @private
  35348. * @param {Array} array The array to flatten.
  35349. * @param {boolean} isDeep Specify a deep flatten.
  35350. * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
  35351. * @returns {Array} Returns the new flattened array.
  35352. */
  35353. function baseFlatten(array, isDeep, isStrict) {
  35354. var index = -1,
  35355. length = array.length,
  35356. resIndex = -1,
  35357. result = [];
  35358. while (++index < length) {
  35359. var value = array[index];
  35360. if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
  35361. if (isDeep) {
  35362. // Recursively flatten arrays (susceptible to call stack limits).
  35363. value = baseFlatten(value, isDeep, isStrict);
  35364. }
  35365. var valIndex = -1,
  35366. valLength = value.length;
  35367. result.length += valLength;
  35368. while (++valIndex < valLength) {
  35369. result[++resIndex] = value[valIndex];
  35370. }
  35371. } else if (!isStrict) {
  35372. result[++resIndex] = value;
  35373. }
  35374. }
  35375. return result;
  35376. }
  35377. module.exports = baseFlatten;
  35378. },{"../lang/isArguments":404,"../lang/isArray":405,"./isLength":395,"./isObjectLike":396}],353:[function(require,module,exports){
  35379. var createBaseFor = require('./createBaseFor');
  35380. /**
  35381. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  35382. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  35383. * each property. Iterator functions may exit iteration early by explicitly
  35384. * returning `false`.
  35385. *
  35386. * @private
  35387. * @param {Object} object The object to iterate over.
  35388. * @param {Function} iteratee The function invoked per iteration.
  35389. * @param {Function} keysFunc The function to get the keys of `object`.
  35390. * @returns {Object} Returns `object`.
  35391. */
  35392. var baseFor = createBaseFor();
  35393. module.exports = baseFor;
  35394. },{"./createBaseFor":382}],354:[function(require,module,exports){
  35395. var baseFor = require('./baseFor'),
  35396. keysIn = require('../object/keysIn');
  35397. /**
  35398. * The base implementation of `_.forIn` without support for callback
  35399. * shorthands and `this` binding.
  35400. *
  35401. * @private
  35402. * @param {Object} object The object to iterate over.
  35403. * @param {Function} iteratee The function invoked per iteration.
  35404. * @returns {Object} Returns `object`.
  35405. */
  35406. function baseForIn(object, iteratee) {
  35407. return baseFor(object, iteratee, keysIn);
  35408. }
  35409. module.exports = baseForIn;
  35410. },{"../object/keysIn":422,"./baseFor":353}],355:[function(require,module,exports){
  35411. var baseFor = require('./baseFor'),
  35412. keys = require('../object/keys');
  35413. /**
  35414. * The base implementation of `_.forOwn` without support for callback
  35415. * shorthands and `this` binding.
  35416. *
  35417. * @private
  35418. * @param {Object} object The object to iterate over.
  35419. * @param {Function} iteratee The function invoked per iteration.
  35420. * @returns {Object} Returns `object`.
  35421. */
  35422. function baseForOwn(object, iteratee) {
  35423. return baseFor(object, iteratee, keys);
  35424. }
  35425. module.exports = baseForOwn;
  35426. },{"../object/keys":421,"./baseFor":353}],356:[function(require,module,exports){
  35427. var baseForRight = require('./baseForRight'),
  35428. keys = require('../object/keys');
  35429. /**
  35430. * The base implementation of `_.forOwnRight` without support for callback
  35431. * shorthands and `this` binding.
  35432. *
  35433. * @private
  35434. * @param {Object} object The object to iterate over.
  35435. * @param {Function} iteratee The function invoked per iteration.
  35436. * @returns {Object} Returns `object`.
  35437. */
  35438. function baseForOwnRight(object, iteratee) {
  35439. return baseForRight(object, iteratee, keys);
  35440. }
  35441. module.exports = baseForOwnRight;
  35442. },{"../object/keys":421,"./baseForRight":357}],357:[function(require,module,exports){
  35443. var createBaseFor = require('./createBaseFor');
  35444. /**
  35445. * This function is like `baseFor` except that it iterates over properties
  35446. * in the opposite order.
  35447. *
  35448. * @private
  35449. * @param {Object} object The object to iterate over.
  35450. * @param {Function} iteratee The function invoked per iteration.
  35451. * @param {Function} keysFunc The function to get the keys of `object`.
  35452. * @returns {Object} Returns `object`.
  35453. */
  35454. var baseForRight = createBaseFor(true);
  35455. module.exports = baseForRight;
  35456. },{"./createBaseFor":382}],358:[function(require,module,exports){
  35457. var indexOfNaN = require('./indexOfNaN');
  35458. /**
  35459. * The base implementation of `_.indexOf` without support for binary searches.
  35460. *
  35461. * @private
  35462. * @param {Array} array The array to search.
  35463. * @param {*} value The value to search for.
  35464. * @param {number} fromIndex The index to search from.
  35465. * @returns {number} Returns the index of the matched value, else `-1`.
  35466. */
  35467. function baseIndexOf(array, value, fromIndex) {
  35468. if (value !== value) {
  35469. return indexOfNaN(array, fromIndex);
  35470. }
  35471. var index = fromIndex - 1,
  35472. length = array.length;
  35473. while (++index < length) {
  35474. if (array[index] === value) {
  35475. return index;
  35476. }
  35477. }
  35478. return -1;
  35479. }
  35480. module.exports = baseIndexOf;
  35481. },{"./indexOfNaN":389}],359:[function(require,module,exports){
  35482. var baseIsEqualDeep = require('./baseIsEqualDeep');
  35483. /**
  35484. * The base implementation of `_.isEqual` without support for `this` binding
  35485. * `customizer` functions.
  35486. *
  35487. * @private
  35488. * @param {*} value The value to compare.
  35489. * @param {*} other The other value to compare.
  35490. * @param {Function} [customizer] The function to customize comparing values.
  35491. * @param {boolean} [isLoose] Specify performing partial comparisons.
  35492. * @param {Array} [stackA] Tracks traversed `value` objects.
  35493. * @param {Array} [stackB] Tracks traversed `other` objects.
  35494. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  35495. */
  35496. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  35497. // Exit early for identical values.
  35498. if (value === other) {
  35499. // Treat `+0` vs. `-0` as not equal.
  35500. return value !== 0 || (1 / value == 1 / other);
  35501. }
  35502. var valType = typeof value,
  35503. othType = typeof other;
  35504. // Exit early for unlike primitive values.
  35505. if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
  35506. value == null || other == null) {
  35507. // Return `false` unless both values are `NaN`.
  35508. return value !== value && other !== other;
  35509. }
  35510. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  35511. }
  35512. module.exports = baseIsEqual;
  35513. },{"./baseIsEqualDeep":360}],360:[function(require,module,exports){
  35514. var equalArrays = require('./equalArrays'),
  35515. equalByTag = require('./equalByTag'),
  35516. equalObjects = require('./equalObjects'),
  35517. isArray = require('../lang/isArray'),
  35518. isTypedArray = require('../lang/isTypedArray');
  35519. /** `Object#toString` result references. */
  35520. var argsTag = '[object Arguments]',
  35521. arrayTag = '[object Array]',
  35522. funcTag = '[object Function]',
  35523. objectTag = '[object Object]';
  35524. /** Used for native method references. */
  35525. var objectProto = Object.prototype;
  35526. /** Used to check objects for own properties. */
  35527. var hasOwnProperty = objectProto.hasOwnProperty;
  35528. /**
  35529. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  35530. * of values.
  35531. */
  35532. var objToString = objectProto.toString;
  35533. /**
  35534. * A specialized version of `baseIsEqual` for arrays and objects which performs
  35535. * deep comparisons and tracks traversed objects enabling objects with circular
  35536. * references to be compared.
  35537. *
  35538. * @private
  35539. * @param {Object} object The object to compare.
  35540. * @param {Object} other The other object to compare.
  35541. * @param {Function} equalFunc The function to determine equivalents of values.
  35542. * @param {Function} [customizer] The function to customize comparing objects.
  35543. * @param {boolean} [isLoose] Specify performing partial comparisons.
  35544. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  35545. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  35546. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  35547. */
  35548. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  35549. var objIsArr = isArray(object),
  35550. othIsArr = isArray(other),
  35551. objTag = arrayTag,
  35552. othTag = arrayTag;
  35553. if (!objIsArr) {
  35554. objTag = objToString.call(object);
  35555. if (objTag == argsTag) {
  35556. objTag = objectTag;
  35557. } else if (objTag != objectTag) {
  35558. objIsArr = isTypedArray(object);
  35559. }
  35560. }
  35561. if (!othIsArr) {
  35562. othTag = objToString.call(other);
  35563. if (othTag == argsTag) {
  35564. othTag = objectTag;
  35565. } else if (othTag != objectTag) {
  35566. othIsArr = isTypedArray(other);
  35567. }
  35568. }
  35569. var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)),
  35570. othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)),
  35571. isSameTag = objTag == othTag;
  35572. if (isSameTag && !(objIsArr || objIsObj)) {
  35573. return equalByTag(object, other, objTag);
  35574. }
  35575. if (isLoose) {
  35576. if (!isSameTag && !(objIsObj && othIsObj)) {
  35577. return false;
  35578. }
  35579. } else {
  35580. var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  35581. othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  35582. if (valWrapped || othWrapped) {
  35583. return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  35584. }
  35585. if (!isSameTag) {
  35586. return false;
  35587. }
  35588. }
  35589. // Assume cyclic values are equal.
  35590. // For more information on detecting circular references see https://es5.github.io/#JO.
  35591. stackA || (stackA = []);
  35592. stackB || (stackB = []);
  35593. var length = stackA.length;
  35594. while (length--) {
  35595. if (stackA[length] == object) {
  35596. return stackB[length] == other;
  35597. }
  35598. }
  35599. // Add `object` and `other` to the stack of traversed objects.
  35600. stackA.push(object);
  35601. stackB.push(other);
  35602. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  35603. stackA.pop();
  35604. stackB.pop();
  35605. return result;
  35606. }
  35607. module.exports = baseIsEqualDeep;
  35608. },{"../lang/isArray":405,"../lang/isTypedArray":415,"./equalArrays":386,"./equalByTag":387,"./equalObjects":388}],361:[function(require,module,exports){
  35609. /**
  35610. * The base implementation of `_.isFunction` without support for environments
  35611. * with incorrect `typeof` results.
  35612. *
  35613. * @private
  35614. * @param {*} value The value to check.
  35615. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  35616. */
  35617. function baseIsFunction(value) {
  35618. // Avoid a Chakra JIT bug in compatibility modes of IE 11.
  35619. // See https://github.com/jashkenas/underscore/issues/1621 for more details.
  35620. return typeof value == 'function' || false;
  35621. }
  35622. module.exports = baseIsFunction;
  35623. },{}],362:[function(require,module,exports){
  35624. var baseIsEqual = require('./baseIsEqual');
  35625. /**
  35626. * The base implementation of `_.isMatch` without support for callback
  35627. * shorthands and `this` binding.
  35628. *
  35629. * @private
  35630. * @param {Object} object The object to inspect.
  35631. * @param {Array} props The source property names to match.
  35632. * @param {Array} values The source values to match.
  35633. * @param {Array} strictCompareFlags Strict comparison flags for source values.
  35634. * @param {Function} [customizer] The function to customize comparing objects.
  35635. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  35636. */
  35637. function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
  35638. var index = -1,
  35639. length = props.length,
  35640. noCustomizer = !customizer;
  35641. while (++index < length) {
  35642. if ((noCustomizer && strictCompareFlags[index])
  35643. ? values[index] !== object[props[index]]
  35644. : !(props[index] in object)
  35645. ) {
  35646. return false;
  35647. }
  35648. }
  35649. index = -1;
  35650. while (++index < length) {
  35651. var key = props[index],
  35652. objValue = object[key],
  35653. srcValue = values[index];
  35654. if (noCustomizer && strictCompareFlags[index]) {
  35655. var result = typeof objValue != 'undefined' || (key in object);
  35656. } else {
  35657. result = customizer ? customizer(objValue, srcValue, key) : undefined;
  35658. if (typeof result == 'undefined') {
  35659. result = baseIsEqual(srcValue, objValue, customizer, true);
  35660. }
  35661. }
  35662. if (!result) {
  35663. return false;
  35664. }
  35665. }
  35666. return true;
  35667. }
  35668. module.exports = baseIsMatch;
  35669. },{"./baseIsEqual":359}],363:[function(require,module,exports){
  35670. var baseEach = require('./baseEach');
  35671. /**
  35672. * The base implementation of `_.map` without support for callback shorthands
  35673. * and `this` binding.
  35674. *
  35675. * @private
  35676. * @param {Array|Object|string} collection The collection to iterate over.
  35677. * @param {Function} iteratee The function invoked per iteration.
  35678. * @returns {Array} Returns the new mapped array.
  35679. */
  35680. function baseMap(collection, iteratee) {
  35681. var result = [];
  35682. baseEach(collection, function(value, key, collection) {
  35683. result.push(iteratee(value, key, collection));
  35684. });
  35685. return result;
  35686. }
  35687. module.exports = baseMap;
  35688. },{"./baseEach":350}],364:[function(require,module,exports){
  35689. var baseIsMatch = require('./baseIsMatch'),
  35690. constant = require('../utility/constant'),
  35691. isStrictComparable = require('./isStrictComparable'),
  35692. keys = require('../object/keys'),
  35693. toObject = require('./toObject');
  35694. /**
  35695. * The base implementation of `_.matches` which does not clone `source`.
  35696. *
  35697. * @private
  35698. * @param {Object} source The object of property values to match.
  35699. * @returns {Function} Returns the new function.
  35700. */
  35701. function baseMatches(source) {
  35702. var props = keys(source),
  35703. length = props.length;
  35704. if (!length) {
  35705. return constant(true);
  35706. }
  35707. if (length == 1) {
  35708. var key = props[0],
  35709. value = source[key];
  35710. if (isStrictComparable(value)) {
  35711. return function(object) {
  35712. return object != null && object[key] === value &&
  35713. (typeof value != 'undefined' || (key in toObject(object)));
  35714. };
  35715. }
  35716. }
  35717. var values = Array(length),
  35718. strictCompareFlags = Array(length);
  35719. while (length--) {
  35720. value = source[props[length]];
  35721. values[length] = value;
  35722. strictCompareFlags[length] = isStrictComparable(value);
  35723. }
  35724. return function(object) {
  35725. return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
  35726. };
  35727. }
  35728. module.exports = baseMatches;
  35729. },{"../object/keys":421,"../utility/constant":428,"./baseIsMatch":362,"./isStrictComparable":397,"./toObject":401}],365:[function(require,module,exports){
  35730. var baseIsEqual = require('./baseIsEqual'),
  35731. isStrictComparable = require('./isStrictComparable'),
  35732. toObject = require('./toObject');
  35733. /**
  35734. * The base implementation of `_.matchesProperty` which does not coerce `key`
  35735. * to a string.
  35736. *
  35737. * @private
  35738. * @param {string} key The key of the property to get.
  35739. * @param {*} value The value to compare.
  35740. * @returns {Function} Returns the new function.
  35741. */
  35742. function baseMatchesProperty(key, value) {
  35743. if (isStrictComparable(value)) {
  35744. return function(object) {
  35745. return object != null && object[key] === value &&
  35746. (typeof value != 'undefined' || (key in toObject(object)));
  35747. };
  35748. }
  35749. return function(object) {
  35750. return object != null && baseIsEqual(value, object[key], null, true);
  35751. };
  35752. }
  35753. module.exports = baseMatchesProperty;
  35754. },{"./baseIsEqual":359,"./isStrictComparable":397,"./toObject":401}],366:[function(require,module,exports){
  35755. var arrayEach = require('./arrayEach'),
  35756. baseForOwn = require('./baseForOwn'),
  35757. baseMergeDeep = require('./baseMergeDeep'),
  35758. isArray = require('../lang/isArray'),
  35759. isLength = require('./isLength'),
  35760. isObject = require('../lang/isObject'),
  35761. isObjectLike = require('./isObjectLike'),
  35762. isTypedArray = require('../lang/isTypedArray');
  35763. /**
  35764. * The base implementation of `_.merge` without support for argument juggling,
  35765. * multiple sources, and `this` binding `customizer` functions.
  35766. *
  35767. * @private
  35768. * @param {Object} object The destination object.
  35769. * @param {Object} source The source object.
  35770. * @param {Function} [customizer] The function to customize merging properties.
  35771. * @param {Array} [stackA=[]] Tracks traversed source objects.
  35772. * @param {Array} [stackB=[]] Associates values with source counterparts.
  35773. * @returns {Object} Returns the destination object.
  35774. */
  35775. function baseMerge(object, source, customizer, stackA, stackB) {
  35776. if (!isObject(object)) {
  35777. return object;
  35778. }
  35779. var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
  35780. (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
  35781. if (isObjectLike(srcValue)) {
  35782. stackA || (stackA = []);
  35783. stackB || (stackB = []);
  35784. return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  35785. }
  35786. var value = object[key],
  35787. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  35788. isCommon = typeof result == 'undefined';
  35789. if (isCommon) {
  35790. result = srcValue;
  35791. }
  35792. if ((isSrcArr || typeof result != 'undefined') &&
  35793. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  35794. object[key] = result;
  35795. }
  35796. });
  35797. return object;
  35798. }
  35799. module.exports = baseMerge;
  35800. },{"../lang/isArray":405,"../lang/isObject":411,"../lang/isTypedArray":415,"./arrayEach":340,"./baseForOwn":355,"./baseMergeDeep":367,"./isLength":395,"./isObjectLike":396}],367:[function(require,module,exports){
  35801. var arrayCopy = require('./arrayCopy'),
  35802. isArguments = require('../lang/isArguments'),
  35803. isArray = require('../lang/isArray'),
  35804. isLength = require('./isLength'),
  35805. isPlainObject = require('../lang/isPlainObject'),
  35806. isTypedArray = require('../lang/isTypedArray'),
  35807. toPlainObject = require('../lang/toPlainObject');
  35808. /**
  35809. * A specialized version of `baseMerge` for arrays and objects which performs
  35810. * deep merges and tracks traversed objects enabling objects with circular
  35811. * references to be merged.
  35812. *
  35813. * @private
  35814. * @param {Object} object The destination object.
  35815. * @param {Object} source The source object.
  35816. * @param {string} key The key of the value to merge.
  35817. * @param {Function} mergeFunc The function to merge values.
  35818. * @param {Function} [customizer] The function to customize merging properties.
  35819. * @param {Array} [stackA=[]] Tracks traversed source objects.
  35820. * @param {Array} [stackB=[]] Associates values with source counterparts.
  35821. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  35822. */
  35823. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  35824. var length = stackA.length,
  35825. srcValue = source[key];
  35826. while (length--) {
  35827. if (stackA[length] == srcValue) {
  35828. object[key] = stackB[length];
  35829. return;
  35830. }
  35831. }
  35832. var value = object[key],
  35833. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  35834. isCommon = typeof result == 'undefined';
  35835. if (isCommon) {
  35836. result = srcValue;
  35837. if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
  35838. result = isArray(value)
  35839. ? value
  35840. : ((value && value.length) ? arrayCopy(value) : []);
  35841. }
  35842. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  35843. result = isArguments(value)
  35844. ? toPlainObject(value)
  35845. : (isPlainObject(value) ? value : {});
  35846. }
  35847. else {
  35848. isCommon = false;
  35849. }
  35850. }
  35851. // Add the source value to the stack of traversed objects and associate
  35852. // it with its merged value.
  35853. stackA.push(srcValue);
  35854. stackB.push(result);
  35855. if (isCommon) {
  35856. // Recursively merge objects and arrays (susceptible to call stack limits).
  35857. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  35858. } else if (result === result ? (result !== value) : (value === value)) {
  35859. object[key] = result;
  35860. }
  35861. }
  35862. module.exports = baseMergeDeep;
  35863. },{"../lang/isArguments":404,"../lang/isArray":405,"../lang/isPlainObject":412,"../lang/isTypedArray":415,"../lang/toPlainObject":416,"./arrayCopy":339,"./isLength":395}],368:[function(require,module,exports){
  35864. /**
  35865. * The base implementation of `_.property` which does not coerce `key` to a string.
  35866. *
  35867. * @private
  35868. * @param {string} key The key of the property to get.
  35869. * @returns {Function} Returns the new function.
  35870. */
  35871. function baseProperty(key) {
  35872. return function(object) {
  35873. return object == null ? undefined : object[key];
  35874. };
  35875. }
  35876. module.exports = baseProperty;
  35877. },{}],369:[function(require,module,exports){
  35878. /**
  35879. * The base implementation of `_.reduce` and `_.reduceRight` without support
  35880. * for callback shorthands and `this` binding, which iterates over `collection`
  35881. * using the provided `eachFunc`.
  35882. *
  35883. * @private
  35884. * @param {Array|Object|string} collection The collection to iterate over.
  35885. * @param {Function} iteratee The function invoked per iteration.
  35886. * @param {*} accumulator The initial value.
  35887. * @param {boolean} initFromCollection Specify using the first or last element
  35888. * of `collection` as the initial value.
  35889. * @param {Function} eachFunc The function to iterate over `collection`.
  35890. * @returns {*} Returns the accumulated value.
  35891. */
  35892. function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
  35893. eachFunc(collection, function(value, index, collection) {
  35894. accumulator = initFromCollection
  35895. ? (initFromCollection = false, value)
  35896. : iteratee(accumulator, value, index, collection);
  35897. });
  35898. return accumulator;
  35899. }
  35900. module.exports = baseReduce;
  35901. },{}],370:[function(require,module,exports){
  35902. var baseEach = require('./baseEach');
  35903. /**
  35904. * The base implementation of `_.some` without support for callback shorthands
  35905. * and `this` binding.
  35906. *
  35907. * @private
  35908. * @param {Array|Object|string} collection The collection to iterate over.
  35909. * @param {Function} predicate The function invoked per iteration.
  35910. * @returns {boolean} Returns `true` if any element passes the predicate check,
  35911. * else `false`.
  35912. */
  35913. function baseSome(collection, predicate) {
  35914. var result;
  35915. baseEach(collection, function(value, index, collection) {
  35916. result = predicate(value, index, collection);
  35917. return !result;
  35918. });
  35919. return !!result;
  35920. }
  35921. module.exports = baseSome;
  35922. },{"./baseEach":350}],371:[function(require,module,exports){
  35923. /**
  35924. * The base implementation of `_.sortBy` which uses `comparer` to define
  35925. * the sort order of `array` and replaces criteria objects with their
  35926. * corresponding values.
  35927. *
  35928. * @private
  35929. * @param {Array} array The array to sort.
  35930. * @param {Function} comparer The function to define sort order.
  35931. * @returns {Array} Returns `array`.
  35932. */
  35933. function baseSortBy(array, comparer) {
  35934. var length = array.length;
  35935. array.sort(comparer);
  35936. while (length--) {
  35937. array[length] = array[length].value;
  35938. }
  35939. return array;
  35940. }
  35941. module.exports = baseSortBy;
  35942. },{}],372:[function(require,module,exports){
  35943. /**
  35944. * Converts `value` to a string if it is not one. An empty string is returned
  35945. * for `null` or `undefined` values.
  35946. *
  35947. * @private
  35948. * @param {*} value The value to process.
  35949. * @returns {string} Returns the string.
  35950. */
  35951. function baseToString(value) {
  35952. if (typeof value == 'string') {
  35953. return value;
  35954. }
  35955. return value == null ? '' : (value + '');
  35956. }
  35957. module.exports = baseToString;
  35958. },{}],373:[function(require,module,exports){
  35959. var baseIndexOf = require('./baseIndexOf'),
  35960. cacheIndexOf = require('./cacheIndexOf'),
  35961. createCache = require('./createCache');
  35962. /**
  35963. * The base implementation of `_.uniq` without support for callback shorthands
  35964. * and `this` binding.
  35965. *
  35966. * @private
  35967. * @param {Array} array The array to inspect.
  35968. * @param {Function} [iteratee] The function invoked per iteration.
  35969. * @returns {Array} Returns the new duplicate-value-free array.
  35970. */
  35971. function baseUniq(array, iteratee) {
  35972. var index = -1,
  35973. indexOf = baseIndexOf,
  35974. length = array.length,
  35975. isCommon = true,
  35976. isLarge = isCommon && length >= 200,
  35977. seen = isLarge ? createCache() : null,
  35978. result = [];
  35979. if (seen) {
  35980. indexOf = cacheIndexOf;
  35981. isCommon = false;
  35982. } else {
  35983. isLarge = false;
  35984. seen = iteratee ? [] : result;
  35985. }
  35986. outer:
  35987. while (++index < length) {
  35988. var value = array[index],
  35989. computed = iteratee ? iteratee(value, index, array) : value;
  35990. if (isCommon && value === value) {
  35991. var seenIndex = seen.length;
  35992. while (seenIndex--) {
  35993. if (seen[seenIndex] === computed) {
  35994. continue outer;
  35995. }
  35996. }
  35997. if (iteratee) {
  35998. seen.push(computed);
  35999. }
  36000. result.push(value);
  36001. }
  36002. else if (indexOf(seen, computed, 0) < 0) {
  36003. if (iteratee || isLarge) {
  36004. seen.push(computed);
  36005. }
  36006. result.push(value);
  36007. }
  36008. }
  36009. return result;
  36010. }
  36011. module.exports = baseUniq;
  36012. },{"./baseIndexOf":358,"./cacheIndexOf":377,"./createCache":383}],374:[function(require,module,exports){
  36013. /**
  36014. * The base implementation of `_.values` and `_.valuesIn` which creates an
  36015. * array of `object` property values corresponding to the property names
  36016. * returned by `keysFunc`.
  36017. *
  36018. * @private
  36019. * @param {Object} object The object to query.
  36020. * @param {Array} props The property names to get values for.
  36021. * @returns {Object} Returns the array of property values.
  36022. */
  36023. function baseValues(object, props) {
  36024. var index = -1,
  36025. length = props.length,
  36026. result = Array(length);
  36027. while (++index < length) {
  36028. result[index] = object[props[index]];
  36029. }
  36030. return result;
  36031. }
  36032. module.exports = baseValues;
  36033. },{}],375:[function(require,module,exports){
  36034. var identity = require('../utility/identity');
  36035. /**
  36036. * A specialized version of `baseCallback` which only supports `this` binding
  36037. * and specifying the number of arguments to provide to `func`.
  36038. *
  36039. * @private
  36040. * @param {Function} func The function to bind.
  36041. * @param {*} thisArg The `this` binding of `func`.
  36042. * @param {number} [argCount] The number of arguments to provide to `func`.
  36043. * @returns {Function} Returns the callback.
  36044. */
  36045. function bindCallback(func, thisArg, argCount) {
  36046. if (typeof func != 'function') {
  36047. return identity;
  36048. }
  36049. if (typeof thisArg == 'undefined') {
  36050. return func;
  36051. }
  36052. switch (argCount) {
  36053. case 1: return function(value) {
  36054. return func.call(thisArg, value);
  36055. };
  36056. case 3: return function(value, index, collection) {
  36057. return func.call(thisArg, value, index, collection);
  36058. };
  36059. case 4: return function(accumulator, value, index, collection) {
  36060. return func.call(thisArg, accumulator, value, index, collection);
  36061. };
  36062. case 5: return function(value, other, key, object, source) {
  36063. return func.call(thisArg, value, other, key, object, source);
  36064. };
  36065. }
  36066. return function() {
  36067. return func.apply(thisArg, arguments);
  36068. };
  36069. }
  36070. module.exports = bindCallback;
  36071. },{"../utility/identity":429}],376:[function(require,module,exports){
  36072. (function (global){
  36073. var constant = require('../utility/constant'),
  36074. isNative = require('../lang/isNative');
  36075. /** Native method references. */
  36076. var ArrayBuffer = isNative(ArrayBuffer = global.ArrayBuffer) && ArrayBuffer,
  36077. bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
  36078. floor = Math.floor,
  36079. Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array;
  36080. /** Used to clone array buffers. */
  36081. var Float64Array = (function() {
  36082. // Safari 5 errors when using an array buffer to initialize a typed array
  36083. // where the array buffer's `byteLength` is not a multiple of the typed
  36084. // array's `BYTES_PER_ELEMENT`.
  36085. try {
  36086. var func = isNative(func = global.Float64Array) && func,
  36087. result = new func(new ArrayBuffer(10), 0, 1) && func;
  36088. } catch(e) {}
  36089. return result;
  36090. }());
  36091. /** Used as the size, in bytes, of each `Float64Array` element. */
  36092. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  36093. /**
  36094. * Creates a clone of the given array buffer.
  36095. *
  36096. * @private
  36097. * @param {ArrayBuffer} buffer The array buffer to clone.
  36098. * @returns {ArrayBuffer} Returns the cloned array buffer.
  36099. */
  36100. function bufferClone(buffer) {
  36101. return bufferSlice.call(buffer, 0);
  36102. }
  36103. if (!bufferSlice) {
  36104. // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`.
  36105. bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
  36106. var byteLength = buffer.byteLength,
  36107. floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
  36108. offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
  36109. result = new ArrayBuffer(byteLength);
  36110. if (floatLength) {
  36111. var view = new Float64Array(result, 0, floatLength);
  36112. view.set(new Float64Array(buffer, 0, floatLength));
  36113. }
  36114. if (byteLength != offset) {
  36115. view = new Uint8Array(result, offset);
  36116. view.set(new Uint8Array(buffer, offset));
  36117. }
  36118. return result;
  36119. };
  36120. }
  36121. module.exports = bufferClone;
  36122. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  36123. },{"../lang/isNative":409,"../utility/constant":428}],377:[function(require,module,exports){
  36124. var isObject = require('../lang/isObject');
  36125. /**
  36126. * Checks if `value` is in `cache` mimicking the return signature of
  36127. * `_.indexOf` by returning `0` if the value is found, else `-1`.
  36128. *
  36129. * @private
  36130. * @param {Object} cache The cache to search.
  36131. * @param {*} value The value to search for.
  36132. * @returns {number} Returns `0` if `value` is found, else `-1`.
  36133. */
  36134. function cacheIndexOf(cache, value) {
  36135. var data = cache.data,
  36136. result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
  36137. return result ? 0 : -1;
  36138. }
  36139. module.exports = cacheIndexOf;
  36140. },{"../lang/isObject":411}],378:[function(require,module,exports){
  36141. var isObject = require('../lang/isObject');
  36142. /**
  36143. * Adds `value` to the cache.
  36144. *
  36145. * @private
  36146. * @name push
  36147. * @memberOf SetCache
  36148. * @param {*} value The value to cache.
  36149. */
  36150. function cachePush(value) {
  36151. var data = this.data;
  36152. if (typeof value == 'string' || isObject(value)) {
  36153. data.set.add(value);
  36154. } else {
  36155. data.hash[value] = true;
  36156. }
  36157. }
  36158. module.exports = cachePush;
  36159. },{"../lang/isObject":411}],379:[function(require,module,exports){
  36160. var baseCompareAscending = require('./baseCompareAscending');
  36161. /**
  36162. * Used by `_.sortBy` to compare transformed elements of a collection and stable
  36163. * sort them in ascending order.
  36164. *
  36165. * @private
  36166. * @param {Object} object The object to compare to `other`.
  36167. * @param {Object} other The object to compare to `object`.
  36168. * @returns {number} Returns the sort order indicator for `object`.
  36169. */
  36170. function compareAscending(object, other) {
  36171. return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
  36172. }
  36173. module.exports = compareAscending;
  36174. },{"./baseCompareAscending":348}],380:[function(require,module,exports){
  36175. var bindCallback = require('./bindCallback'),
  36176. isIterateeCall = require('./isIterateeCall');
  36177. /**
  36178. * Creates a function that assigns properties of source object(s) to a given
  36179. * destination object.
  36180. *
  36181. * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
  36182. *
  36183. * @private
  36184. * @param {Function} assigner The function to assign values.
  36185. * @returns {Function} Returns the new assigner function.
  36186. */
  36187. function createAssigner(assigner) {
  36188. return function() {
  36189. var args = arguments,
  36190. length = args.length,
  36191. object = args[0];
  36192. if (length < 2 || object == null) {
  36193. return object;
  36194. }
  36195. var customizer = args[length - 2],
  36196. thisArg = args[length - 1],
  36197. guard = args[3];
  36198. if (length > 3 && typeof customizer == 'function') {
  36199. customizer = bindCallback(customizer, thisArg, 5);
  36200. length -= 2;
  36201. } else {
  36202. customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null;
  36203. length -= (customizer ? 1 : 0);
  36204. }
  36205. if (guard && isIterateeCall(args[1], args[2], guard)) {
  36206. customizer = length == 3 ? null : customizer;
  36207. length = 2;
  36208. }
  36209. var index = 0;
  36210. while (++index < length) {
  36211. var source = args[index];
  36212. if (source) {
  36213. assigner(object, source, customizer);
  36214. }
  36215. }
  36216. return object;
  36217. };
  36218. }
  36219. module.exports = createAssigner;
  36220. },{"./bindCallback":375,"./isIterateeCall":394}],381:[function(require,module,exports){
  36221. var isLength = require('./isLength'),
  36222. toObject = require('./toObject');
  36223. /**
  36224. * Creates a `baseEach` or `baseEachRight` function.
  36225. *
  36226. * @private
  36227. * @param {Function} eachFunc The function to iterate over a collection.
  36228. * @param {boolean} [fromRight] Specify iterating from right to left.
  36229. * @returns {Function} Returns the new base function.
  36230. */
  36231. function createBaseEach(eachFunc, fromRight) {
  36232. return function(collection, iteratee) {
  36233. var length = collection ? collection.length : 0;
  36234. if (!isLength(length)) {
  36235. return eachFunc(collection, iteratee);
  36236. }
  36237. var index = fromRight ? length : -1,
  36238. iterable = toObject(collection);
  36239. while ((fromRight ? index-- : ++index < length)) {
  36240. if (iteratee(iterable[index], index, iterable) === false) {
  36241. break;
  36242. }
  36243. }
  36244. return collection;
  36245. };
  36246. }
  36247. module.exports = createBaseEach;
  36248. },{"./isLength":395,"./toObject":401}],382:[function(require,module,exports){
  36249. var toObject = require('./toObject');
  36250. /**
  36251. * Creates a base function for `_.forIn` or `_.forInRight`.
  36252. *
  36253. * @private
  36254. * @param {boolean} [fromRight] Specify iterating from right to left.
  36255. * @returns {Function} Returns the new base function.
  36256. */
  36257. function createBaseFor(fromRight) {
  36258. return function(object, iteratee, keysFunc) {
  36259. var iterable = toObject(object),
  36260. props = keysFunc(object),
  36261. length = props.length,
  36262. index = fromRight ? length : -1;
  36263. while ((fromRight ? index-- : ++index < length)) {
  36264. var key = props[index];
  36265. if (iteratee(iterable[key], key, iterable) === false) {
  36266. break;
  36267. }
  36268. }
  36269. return object;
  36270. };
  36271. }
  36272. module.exports = createBaseFor;
  36273. },{"./toObject":401}],383:[function(require,module,exports){
  36274. (function (global){
  36275. var SetCache = require('./SetCache'),
  36276. constant = require('../utility/constant'),
  36277. isNative = require('../lang/isNative');
  36278. /** Native method references. */
  36279. var Set = isNative(Set = global.Set) && Set;
  36280. /* Native method references for those with the same name as other `lodash` methods. */
  36281. var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
  36282. /**
  36283. * Creates a `Set` cache object to optimize linear searches of large arrays.
  36284. *
  36285. * @private
  36286. * @param {Array} [values] The values to cache.
  36287. * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
  36288. */
  36289. var createCache = !(nativeCreate && Set) ? constant(null) : function(values) {
  36290. return new SetCache(values);
  36291. };
  36292. module.exports = createCache;
  36293. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  36294. },{"../lang/isNative":409,"../utility/constant":428,"./SetCache":338}],384:[function(require,module,exports){
  36295. var bindCallback = require('./bindCallback'),
  36296. isArray = require('../lang/isArray');
  36297. /**
  36298. * Creates a function for `_.forEach` or `_.forEachRight`.
  36299. *
  36300. * @private
  36301. * @param {Function} arrayFunc The function to iterate over an array.
  36302. * @param {Function} eachFunc The function to iterate over a collection.
  36303. * @returns {Function} Returns the new each function.
  36304. */
  36305. function createForEach(arrayFunc, eachFunc) {
  36306. return function(collection, iteratee, thisArg) {
  36307. return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
  36308. ? arrayFunc(collection, iteratee)
  36309. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  36310. };
  36311. }
  36312. module.exports = createForEach;
  36313. },{"../lang/isArray":405,"./bindCallback":375}],385:[function(require,module,exports){
  36314. var baseCallback = require('./baseCallback'),
  36315. baseReduce = require('./baseReduce'),
  36316. isArray = require('../lang/isArray');
  36317. /**
  36318. * Creates a function for `_.reduce` or `_.reduceRight`.
  36319. *
  36320. * @private
  36321. * @param {Function} arrayFunc The function to iterate over an array.
  36322. * @param {Function} eachFunc The function to iterate over a collection.
  36323. * @returns {Function} Returns the new each function.
  36324. */
  36325. function createReduce(arrayFunc, eachFunc) {
  36326. return function(collection, iteratee, accumulator, thisArg) {
  36327. var initFromArray = arguments.length < 3;
  36328. return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
  36329. ? arrayFunc(collection, iteratee, accumulator, initFromArray)
  36330. : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
  36331. };
  36332. }
  36333. module.exports = createReduce;
  36334. },{"../lang/isArray":405,"./baseCallback":346,"./baseReduce":369}],386:[function(require,module,exports){
  36335. /**
  36336. * A specialized version of `baseIsEqualDeep` for arrays with support for
  36337. * partial deep comparisons.
  36338. *
  36339. * @private
  36340. * @param {Array} array The array to compare.
  36341. * @param {Array} other The other array to compare.
  36342. * @param {Function} equalFunc The function to determine equivalents of values.
  36343. * @param {Function} [customizer] The function to customize comparing arrays.
  36344. * @param {boolean} [isLoose] Specify performing partial comparisons.
  36345. * @param {Array} [stackA] Tracks traversed `value` objects.
  36346. * @param {Array} [stackB] Tracks traversed `other` objects.
  36347. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  36348. */
  36349. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  36350. var index = -1,
  36351. arrLength = array.length,
  36352. othLength = other.length,
  36353. result = true;
  36354. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  36355. return false;
  36356. }
  36357. // Deep compare the contents, ignoring non-numeric properties.
  36358. while (result && ++index < arrLength) {
  36359. var arrValue = array[index],
  36360. othValue = other[index];
  36361. result = undefined;
  36362. if (customizer) {
  36363. result = isLoose
  36364. ? customizer(othValue, arrValue, index)
  36365. : customizer(arrValue, othValue, index);
  36366. }
  36367. if (typeof result == 'undefined') {
  36368. // Recursively compare arrays (susceptible to call stack limits).
  36369. if (isLoose) {
  36370. var othIndex = othLength;
  36371. while (othIndex--) {
  36372. othValue = other[othIndex];
  36373. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  36374. if (result) {
  36375. break;
  36376. }
  36377. }
  36378. } else {
  36379. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  36380. }
  36381. }
  36382. }
  36383. return !!result;
  36384. }
  36385. module.exports = equalArrays;
  36386. },{}],387:[function(require,module,exports){
  36387. /** `Object#toString` result references. */
  36388. var boolTag = '[object Boolean]',
  36389. dateTag = '[object Date]',
  36390. errorTag = '[object Error]',
  36391. numberTag = '[object Number]',
  36392. regexpTag = '[object RegExp]',
  36393. stringTag = '[object String]';
  36394. /**
  36395. * A specialized version of `baseIsEqualDeep` for comparing objects of
  36396. * the same `toStringTag`.
  36397. *
  36398. * **Note:** This function only supports comparing values with tags of
  36399. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  36400. *
  36401. * @private
  36402. * @param {Object} value The object to compare.
  36403. * @param {Object} other The other object to compare.
  36404. * @param {string} tag The `toStringTag` of the objects to compare.
  36405. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  36406. */
  36407. function equalByTag(object, other, tag) {
  36408. switch (tag) {
  36409. case boolTag:
  36410. case dateTag:
  36411. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  36412. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  36413. return +object == +other;
  36414. case errorTag:
  36415. return object.name == other.name && object.message == other.message;
  36416. case numberTag:
  36417. // Treat `NaN` vs. `NaN` as equal.
  36418. return (object != +object)
  36419. ? other != +other
  36420. // But, treat `-0` vs. `+0` as not equal.
  36421. : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
  36422. case regexpTag:
  36423. case stringTag:
  36424. // Coerce regexes to strings and treat strings primitives and string
  36425. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  36426. return object == (other + '');
  36427. }
  36428. return false;
  36429. }
  36430. module.exports = equalByTag;
  36431. },{}],388:[function(require,module,exports){
  36432. var keys = require('../object/keys');
  36433. /** Used for native method references. */
  36434. var objectProto = Object.prototype;
  36435. /** Used to check objects for own properties. */
  36436. var hasOwnProperty = objectProto.hasOwnProperty;
  36437. /**
  36438. * A specialized version of `baseIsEqualDeep` for objects with support for
  36439. * partial deep comparisons.
  36440. *
  36441. * @private
  36442. * @param {Object} object The object to compare.
  36443. * @param {Object} other The other object to compare.
  36444. * @param {Function} equalFunc The function to determine equivalents of values.
  36445. * @param {Function} [customizer] The function to customize comparing values.
  36446. * @param {boolean} [isLoose] Specify performing partial comparisons.
  36447. * @param {Array} [stackA] Tracks traversed `value` objects.
  36448. * @param {Array} [stackB] Tracks traversed `other` objects.
  36449. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  36450. */
  36451. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  36452. var objProps = keys(object),
  36453. objLength = objProps.length,
  36454. othProps = keys(other),
  36455. othLength = othProps.length;
  36456. if (objLength != othLength && !isLoose) {
  36457. return false;
  36458. }
  36459. var skipCtor = isLoose,
  36460. index = -1;
  36461. while (++index < objLength) {
  36462. var key = objProps[index],
  36463. result = isLoose ? key in other : hasOwnProperty.call(other, key);
  36464. if (result) {
  36465. var objValue = object[key],
  36466. othValue = other[key];
  36467. result = undefined;
  36468. if (customizer) {
  36469. result = isLoose
  36470. ? customizer(othValue, objValue, key)
  36471. : customizer(objValue, othValue, key);
  36472. }
  36473. if (typeof result == 'undefined') {
  36474. // Recursively compare objects (susceptible to call stack limits).
  36475. result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
  36476. }
  36477. }
  36478. if (!result) {
  36479. return false;
  36480. }
  36481. skipCtor || (skipCtor = key == 'constructor');
  36482. }
  36483. if (!skipCtor) {
  36484. var objCtor = object.constructor,
  36485. othCtor = other.constructor;
  36486. // Non `Object` object instances with different constructors are not equal.
  36487. if (objCtor != othCtor &&
  36488. ('constructor' in object && 'constructor' in other) &&
  36489. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  36490. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  36491. return false;
  36492. }
  36493. }
  36494. return true;
  36495. }
  36496. module.exports = equalObjects;
  36497. },{"../object/keys":421}],389:[function(require,module,exports){
  36498. /**
  36499. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  36500. *
  36501. * @private
  36502. * @param {Array} array The array to search.
  36503. * @param {number} fromIndex The index to search from.
  36504. * @param {boolean} [fromRight] Specify iterating from right to left.
  36505. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  36506. */
  36507. function indexOfNaN(array, fromIndex, fromRight) {
  36508. var length = array.length,
  36509. index = fromIndex + (fromRight ? 0 : -1);
  36510. while ((fromRight ? index-- : ++index < length)) {
  36511. var other = array[index];
  36512. if (other !== other) {
  36513. return index;
  36514. }
  36515. }
  36516. return -1;
  36517. }
  36518. module.exports = indexOfNaN;
  36519. },{}],390:[function(require,module,exports){
  36520. /** Used for native method references. */
  36521. var objectProto = Object.prototype;
  36522. /** Used to check objects for own properties. */
  36523. var hasOwnProperty = objectProto.hasOwnProperty;
  36524. /**
  36525. * Initializes an array clone.
  36526. *
  36527. * @private
  36528. * @param {Array} array The array to clone.
  36529. * @returns {Array} Returns the initialized clone.
  36530. */
  36531. function initCloneArray(array) {
  36532. var length = array.length,
  36533. result = new array.constructor(length);
  36534. // Add array properties assigned by `RegExp#exec`.
  36535. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  36536. result.index = array.index;
  36537. result.input = array.input;
  36538. }
  36539. return result;
  36540. }
  36541. module.exports = initCloneArray;
  36542. },{}],391:[function(require,module,exports){
  36543. var bufferClone = require('./bufferClone');
  36544. /** `Object#toString` result references. */
  36545. var boolTag = '[object Boolean]',
  36546. dateTag = '[object Date]',
  36547. numberTag = '[object Number]',
  36548. regexpTag = '[object RegExp]',
  36549. stringTag = '[object String]';
  36550. var arrayBufferTag = '[object ArrayBuffer]',
  36551. float32Tag = '[object Float32Array]',
  36552. float64Tag = '[object Float64Array]',
  36553. int8Tag = '[object Int8Array]',
  36554. int16Tag = '[object Int16Array]',
  36555. int32Tag = '[object Int32Array]',
  36556. uint8Tag = '[object Uint8Array]',
  36557. uint8ClampedTag = '[object Uint8ClampedArray]',
  36558. uint16Tag = '[object Uint16Array]',
  36559. uint32Tag = '[object Uint32Array]';
  36560. /** Used to match `RegExp` flags from their coerced string values. */
  36561. var reFlags = /\w*$/;
  36562. /**
  36563. * Initializes an object clone based on its `toStringTag`.
  36564. *
  36565. * **Note:** This function only supports cloning values with tags of
  36566. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  36567. *
  36568. *
  36569. * @private
  36570. * @param {Object} object The object to clone.
  36571. * @param {string} tag The `toStringTag` of the object to clone.
  36572. * @param {boolean} [isDeep] Specify a deep clone.
  36573. * @returns {Object} Returns the initialized clone.
  36574. */
  36575. function initCloneByTag(object, tag, isDeep) {
  36576. var Ctor = object.constructor;
  36577. switch (tag) {
  36578. case arrayBufferTag:
  36579. return bufferClone(object);
  36580. case boolTag:
  36581. case dateTag:
  36582. return new Ctor(+object);
  36583. case float32Tag: case float64Tag:
  36584. case int8Tag: case int16Tag: case int32Tag:
  36585. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  36586. var buffer = object.buffer;
  36587. return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
  36588. case numberTag:
  36589. case stringTag:
  36590. return new Ctor(object);
  36591. case regexpTag:
  36592. var result = new Ctor(object.source, reFlags.exec(object));
  36593. result.lastIndex = object.lastIndex;
  36594. }
  36595. return result;
  36596. }
  36597. module.exports = initCloneByTag;
  36598. },{"./bufferClone":376}],392:[function(require,module,exports){
  36599. /**
  36600. * Initializes an object clone.
  36601. *
  36602. * @private
  36603. * @param {Object} object The object to clone.
  36604. * @returns {Object} Returns the initialized clone.
  36605. */
  36606. function initCloneObject(object) {
  36607. var Ctor = object.constructor;
  36608. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  36609. Ctor = Object;
  36610. }
  36611. return new Ctor;
  36612. }
  36613. module.exports = initCloneObject;
  36614. },{}],393:[function(require,module,exports){
  36615. /**
  36616. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  36617. * of an array-like value.
  36618. */
  36619. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  36620. /**
  36621. * Checks if `value` is a valid array-like index.
  36622. *
  36623. * @private
  36624. * @param {*} value The value to check.
  36625. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  36626. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  36627. */
  36628. function isIndex(value, length) {
  36629. value = +value;
  36630. length = length == null ? MAX_SAFE_INTEGER : length;
  36631. return value > -1 && value % 1 == 0 && value < length;
  36632. }
  36633. module.exports = isIndex;
  36634. },{}],394:[function(require,module,exports){
  36635. var isIndex = require('./isIndex'),
  36636. isLength = require('./isLength'),
  36637. isObject = require('../lang/isObject');
  36638. /**
  36639. * Checks if the provided arguments are from an iteratee call.
  36640. *
  36641. * @private
  36642. * @param {*} value The potential iteratee value argument.
  36643. * @param {*} index The potential iteratee index or key argument.
  36644. * @param {*} object The potential iteratee object argument.
  36645. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  36646. */
  36647. function isIterateeCall(value, index, object) {
  36648. if (!isObject(object)) {
  36649. return false;
  36650. }
  36651. var type = typeof index;
  36652. if (type == 'number') {
  36653. var length = object.length,
  36654. prereq = isLength(length) && isIndex(index, length);
  36655. } else {
  36656. prereq = type == 'string' && index in object;
  36657. }
  36658. if (prereq) {
  36659. var other = object[index];
  36660. return value === value ? (value === other) : (other !== other);
  36661. }
  36662. return false;
  36663. }
  36664. module.exports = isIterateeCall;
  36665. },{"../lang/isObject":411,"./isIndex":393,"./isLength":395}],395:[function(require,module,exports){
  36666. /**
  36667. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  36668. * of an array-like value.
  36669. */
  36670. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  36671. /**
  36672. * Checks if `value` is a valid array-like length.
  36673. *
  36674. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  36675. *
  36676. * @private
  36677. * @param {*} value The value to check.
  36678. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  36679. */
  36680. function isLength(value) {
  36681. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  36682. }
  36683. module.exports = isLength;
  36684. },{}],396:[function(require,module,exports){
  36685. /**
  36686. * Checks if `value` is object-like.
  36687. *
  36688. * @private
  36689. * @param {*} value The value to check.
  36690. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  36691. */
  36692. function isObjectLike(value) {
  36693. return !!value && typeof value == 'object';
  36694. }
  36695. module.exports = isObjectLike;
  36696. },{}],397:[function(require,module,exports){
  36697. var isObject = require('../lang/isObject');
  36698. /**
  36699. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  36700. *
  36701. * @private
  36702. * @param {*} value The value to check.
  36703. * @returns {boolean} Returns `true` if `value` if suitable for strict
  36704. * equality comparisons, else `false`.
  36705. */
  36706. function isStrictComparable(value) {
  36707. return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
  36708. }
  36709. module.exports = isStrictComparable;
  36710. },{"../lang/isObject":411}],398:[function(require,module,exports){
  36711. var baseForIn = require('./baseForIn'),
  36712. isObjectLike = require('./isObjectLike');
  36713. /** `Object#toString` result references. */
  36714. var objectTag = '[object Object]';
  36715. /** Used for native method references. */
  36716. var objectProto = Object.prototype;
  36717. /** Used to check objects for own properties. */
  36718. var hasOwnProperty = objectProto.hasOwnProperty;
  36719. /**
  36720. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  36721. * of values.
  36722. */
  36723. var objToString = objectProto.toString;
  36724. /**
  36725. * A fallback implementation of `_.isPlainObject` which checks if `value`
  36726. * is an object created by the `Object` constructor or has a `[[Prototype]]`
  36727. * of `null`.
  36728. *
  36729. * @private
  36730. * @param {*} value The value to check.
  36731. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  36732. */
  36733. function shimIsPlainObject(value) {
  36734. var Ctor;
  36735. // Exit early for non `Object` objects.
  36736. if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
  36737. (!hasOwnProperty.call(value, 'constructor') &&
  36738. (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  36739. return false;
  36740. }
  36741. // IE < 9 iterates inherited properties before own properties. If the first
  36742. // iterated property is an object's own property then there are no inherited
  36743. // enumerable properties.
  36744. var result;
  36745. // In most environments an object's own properties are iterated before
  36746. // its inherited properties. If the last iterated property is an object's
  36747. // own property then there are no inherited enumerable properties.
  36748. baseForIn(value, function(subValue, key) {
  36749. result = key;
  36750. });
  36751. return typeof result == 'undefined' || hasOwnProperty.call(value, result);
  36752. }
  36753. module.exports = shimIsPlainObject;
  36754. },{"./baseForIn":354,"./isObjectLike":396}],399:[function(require,module,exports){
  36755. var isArguments = require('../lang/isArguments'),
  36756. isArray = require('../lang/isArray'),
  36757. isIndex = require('./isIndex'),
  36758. isLength = require('./isLength'),
  36759. keysIn = require('../object/keysIn'),
  36760. support = require('../support');
  36761. /** Used for native method references. */
  36762. var objectProto = Object.prototype;
  36763. /** Used to check objects for own properties. */
  36764. var hasOwnProperty = objectProto.hasOwnProperty;
  36765. /**
  36766. * A fallback implementation of `Object.keys` which creates an array of the
  36767. * own enumerable property names of `object`.
  36768. *
  36769. * @private
  36770. * @param {Object} object The object to inspect.
  36771. * @returns {Array} Returns the array of property names.
  36772. */
  36773. function shimKeys(object) {
  36774. var props = keysIn(object),
  36775. propsLength = props.length,
  36776. length = propsLength && object.length;
  36777. var allowIndexes = length && isLength(length) &&
  36778. (isArray(object) || (support.nonEnumArgs && isArguments(object)));
  36779. var index = -1,
  36780. result = [];
  36781. while (++index < propsLength) {
  36782. var key = props[index];
  36783. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  36784. result.push(key);
  36785. }
  36786. }
  36787. return result;
  36788. }
  36789. module.exports = shimKeys;
  36790. },{"../lang/isArguments":404,"../lang/isArray":405,"../object/keysIn":422,"../support":427,"./isIndex":393,"./isLength":395}],400:[function(require,module,exports){
  36791. /**
  36792. * An implementation of `_.uniq` optimized for sorted arrays without support
  36793. * for callback shorthands and `this` binding.
  36794. *
  36795. * @private
  36796. * @param {Array} array The array to inspect.
  36797. * @param {Function} [iteratee] The function invoked per iteration.
  36798. * @returns {Array} Returns the new duplicate-value-free array.
  36799. */
  36800. function sortedUniq(array, iteratee) {
  36801. var seen,
  36802. index = -1,
  36803. length = array.length,
  36804. resIndex = -1,
  36805. result = [];
  36806. while (++index < length) {
  36807. var value = array[index],
  36808. computed = iteratee ? iteratee(value, index, array) : value;
  36809. if (!index || seen !== computed) {
  36810. seen = computed;
  36811. result[++resIndex] = value;
  36812. }
  36813. }
  36814. return result;
  36815. }
  36816. module.exports = sortedUniq;
  36817. },{}],401:[function(require,module,exports){
  36818. var isObject = require('../lang/isObject');
  36819. /**
  36820. * Converts `value` to an object if it is not one.
  36821. *
  36822. * @private
  36823. * @param {*} value The value to process.
  36824. * @returns {Object} Returns the object.
  36825. */
  36826. function toObject(value) {
  36827. return isObject(value) ? value : Object(value);
  36828. }
  36829. module.exports = toObject;
  36830. },{"../lang/isObject":411}],402:[function(require,module,exports){
  36831. var baseClone = require('../internal/baseClone'),
  36832. bindCallback = require('../internal/bindCallback'),
  36833. isIterateeCall = require('../internal/isIterateeCall');
  36834. /**
  36835. * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
  36836. * otherwise they are assigned by reference. If `customizer` is provided it is
  36837. * invoked to produce the cloned values. If `customizer` returns `undefined`
  36838. * cloning is handled by the method instead. The `customizer` is bound to
  36839. * `thisArg` and invoked with two argument; (value [, index|key, object]).
  36840. *
  36841. * **Note:** This method is loosely based on the
  36842. * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
  36843. * The enumerable properties of `arguments` objects and objects created by
  36844. * constructors other than `Object` are cloned to plain `Object` objects. An
  36845. * empty object is returned for uncloneable values such as functions, DOM nodes,
  36846. * Maps, Sets, and WeakMaps.
  36847. *
  36848. * @static
  36849. * @memberOf _
  36850. * @category Lang
  36851. * @param {*} value The value to clone.
  36852. * @param {boolean} [isDeep] Specify a deep clone.
  36853. * @param {Function} [customizer] The function to customize cloning values.
  36854. * @param {*} [thisArg] The `this` binding of `customizer`.
  36855. * @returns {*} Returns the cloned value.
  36856. * @example
  36857. *
  36858. * var users = [
  36859. * { 'user': 'barney' },
  36860. * { 'user': 'fred' }
  36861. * ];
  36862. *
  36863. * var shallow = _.clone(users);
  36864. * shallow[0] === users[0];
  36865. * // => true
  36866. *
  36867. * var deep = _.clone(users, true);
  36868. * deep[0] === users[0];
  36869. * // => false
  36870. *
  36871. * // using a customizer callback
  36872. * var el = _.clone(document.body, function(value) {
  36873. * if (_.isElement(value)) {
  36874. * return value.cloneNode(false);
  36875. * }
  36876. * });
  36877. *
  36878. * el === document.body
  36879. * // => false
  36880. * el.nodeName
  36881. * // => BODY
  36882. * el.childNodes.length;
  36883. * // => 0
  36884. */
  36885. function clone(value, isDeep, customizer, thisArg) {
  36886. if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
  36887. isDeep = false;
  36888. }
  36889. else if (typeof isDeep == 'function') {
  36890. thisArg = customizer;
  36891. customizer = isDeep;
  36892. isDeep = false;
  36893. }
  36894. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  36895. return baseClone(value, isDeep, customizer);
  36896. }
  36897. module.exports = clone;
  36898. },{"../internal/baseClone":347,"../internal/bindCallback":375,"../internal/isIterateeCall":394}],403:[function(require,module,exports){
  36899. var baseClone = require('../internal/baseClone'),
  36900. bindCallback = require('../internal/bindCallback');
  36901. /**
  36902. * Creates a deep clone of `value`. If `customizer` is provided it is invoked
  36903. * to produce the cloned values. If `customizer` returns `undefined` cloning
  36904. * is handled by the method instead. The `customizer` is bound to `thisArg`
  36905. * and invoked with two argument; (value [, index|key, object]).
  36906. *
  36907. * **Note:** This method is loosely based on the
  36908. * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
  36909. * The enumerable properties of `arguments` objects and objects created by
  36910. * constructors other than `Object` are cloned to plain `Object` objects. An
  36911. * empty object is returned for uncloneable values such as functions, DOM nodes,
  36912. * Maps, Sets, and WeakMaps.
  36913. *
  36914. * @static
  36915. * @memberOf _
  36916. * @category Lang
  36917. * @param {*} value The value to deep clone.
  36918. * @param {Function} [customizer] The function to customize cloning values.
  36919. * @param {*} [thisArg] The `this` binding of `customizer`.
  36920. * @returns {*} Returns the deep cloned value.
  36921. * @example
  36922. *
  36923. * var users = [
  36924. * { 'user': 'barney' },
  36925. * { 'user': 'fred' }
  36926. * ];
  36927. *
  36928. * var deep = _.cloneDeep(users);
  36929. * deep[0] === users[0];
  36930. * // => false
  36931. *
  36932. * // using a customizer callback
  36933. * var el = _.cloneDeep(document.body, function(value) {
  36934. * if (_.isElement(value)) {
  36935. * return value.cloneNode(true);
  36936. * }
  36937. * });
  36938. *
  36939. * el === document.body
  36940. * // => false
  36941. * el.nodeName
  36942. * // => BODY
  36943. * el.childNodes.length;
  36944. * // => 20
  36945. */
  36946. function cloneDeep(value, customizer, thisArg) {
  36947. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  36948. return baseClone(value, true, customizer);
  36949. }
  36950. module.exports = cloneDeep;
  36951. },{"../internal/baseClone":347,"../internal/bindCallback":375}],404:[function(require,module,exports){
  36952. var isLength = require('../internal/isLength'),
  36953. isObjectLike = require('../internal/isObjectLike');
  36954. /** `Object#toString` result references. */
  36955. var argsTag = '[object Arguments]';
  36956. /** Used for native method references. */
  36957. var objectProto = Object.prototype;
  36958. /**
  36959. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  36960. * of values.
  36961. */
  36962. var objToString = objectProto.toString;
  36963. /**
  36964. * Checks if `value` is classified as an `arguments` object.
  36965. *
  36966. * @static
  36967. * @memberOf _
  36968. * @category Lang
  36969. * @param {*} value The value to check.
  36970. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  36971. * @example
  36972. *
  36973. * _.isArguments(function() { return arguments; }());
  36974. * // => true
  36975. *
  36976. * _.isArguments([1, 2, 3]);
  36977. * // => false
  36978. */
  36979. function isArguments(value) {
  36980. var length = isObjectLike(value) ? value.length : undefined;
  36981. return isLength(length) && objToString.call(value) == argsTag;
  36982. }
  36983. module.exports = isArguments;
  36984. },{"../internal/isLength":395,"../internal/isObjectLike":396}],405:[function(require,module,exports){
  36985. var isLength = require('../internal/isLength'),
  36986. isNative = require('./isNative'),
  36987. isObjectLike = require('../internal/isObjectLike');
  36988. /** `Object#toString` result references. */
  36989. var arrayTag = '[object Array]';
  36990. /** Used for native method references. */
  36991. var objectProto = Object.prototype;
  36992. /**
  36993. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  36994. * of values.
  36995. */
  36996. var objToString = objectProto.toString;
  36997. /* Native method references for those with the same name as other `lodash` methods. */
  36998. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray;
  36999. /**
  37000. * Checks if `value` is classified as an `Array` object.
  37001. *
  37002. * @static
  37003. * @memberOf _
  37004. * @category Lang
  37005. * @param {*} value The value to check.
  37006. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37007. * @example
  37008. *
  37009. * _.isArray([1, 2, 3]);
  37010. * // => true
  37011. *
  37012. * _.isArray(function() { return arguments; }());
  37013. * // => false
  37014. */
  37015. var isArray = nativeIsArray || function(value) {
  37016. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  37017. };
  37018. module.exports = isArray;
  37019. },{"../internal/isLength":395,"../internal/isObjectLike":396,"./isNative":409}],406:[function(require,module,exports){
  37020. var isObjectLike = require('../internal/isObjectLike');
  37021. /** `Object#toString` result references. */
  37022. var boolTag = '[object Boolean]';
  37023. /** Used for native method references. */
  37024. var objectProto = Object.prototype;
  37025. /**
  37026. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37027. * of values.
  37028. */
  37029. var objToString = objectProto.toString;
  37030. /**
  37031. * Checks if `value` is classified as a boolean primitive or object.
  37032. *
  37033. * @static
  37034. * @memberOf _
  37035. * @category Lang
  37036. * @param {*} value The value to check.
  37037. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37038. * @example
  37039. *
  37040. * _.isBoolean(false);
  37041. * // => true
  37042. *
  37043. * _.isBoolean(null);
  37044. * // => false
  37045. */
  37046. function isBoolean(value) {
  37047. return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);
  37048. }
  37049. module.exports = isBoolean;
  37050. },{"../internal/isObjectLike":396}],407:[function(require,module,exports){
  37051. var isArguments = require('./isArguments'),
  37052. isArray = require('./isArray'),
  37053. isFunction = require('./isFunction'),
  37054. isLength = require('../internal/isLength'),
  37055. isObjectLike = require('../internal/isObjectLike'),
  37056. isString = require('./isString'),
  37057. keys = require('../object/keys');
  37058. /**
  37059. * Checks if `value` is empty. A value is considered empty unless it is an
  37060. * `arguments` object, array, string, or jQuery-like collection with a length
  37061. * greater than `0` or an object with own enumerable properties.
  37062. *
  37063. * @static
  37064. * @memberOf _
  37065. * @category Lang
  37066. * @param {Array|Object|string} value The value to inspect.
  37067. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  37068. * @example
  37069. *
  37070. * _.isEmpty(null);
  37071. * // => true
  37072. *
  37073. * _.isEmpty(true);
  37074. * // => true
  37075. *
  37076. * _.isEmpty(1);
  37077. * // => true
  37078. *
  37079. * _.isEmpty([1, 2, 3]);
  37080. * // => false
  37081. *
  37082. * _.isEmpty({ 'a': 1 });
  37083. * // => false
  37084. */
  37085. function isEmpty(value) {
  37086. if (value == null) {
  37087. return true;
  37088. }
  37089. var length = value.length;
  37090. if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
  37091. (isObjectLike(value) && isFunction(value.splice)))) {
  37092. return !length;
  37093. }
  37094. return !keys(value).length;
  37095. }
  37096. module.exports = isEmpty;
  37097. },{"../internal/isLength":395,"../internal/isObjectLike":396,"../object/keys":421,"./isArguments":404,"./isArray":405,"./isFunction":408,"./isString":414}],408:[function(require,module,exports){
  37098. (function (global){
  37099. var baseIsFunction = require('../internal/baseIsFunction'),
  37100. isNative = require('./isNative');
  37101. /** `Object#toString` result references. */
  37102. var funcTag = '[object Function]';
  37103. /** Used for native method references. */
  37104. var objectProto = Object.prototype;
  37105. /**
  37106. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37107. * of values.
  37108. */
  37109. var objToString = objectProto.toString;
  37110. /** Native method references. */
  37111. var Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array;
  37112. /**
  37113. * Checks if `value` is classified as a `Function` object.
  37114. *
  37115. * @static
  37116. * @memberOf _
  37117. * @category Lang
  37118. * @param {*} value The value to check.
  37119. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37120. * @example
  37121. *
  37122. * _.isFunction(_);
  37123. * // => true
  37124. *
  37125. * _.isFunction(/abc/);
  37126. * // => false
  37127. */
  37128. var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
  37129. // The use of `Object#toString` avoids issues with the `typeof` operator
  37130. // in older versions of Chrome and Safari which return 'function' for regexes
  37131. // and Safari 8 equivalents which return 'object' for typed array constructors.
  37132. return objToString.call(value) == funcTag;
  37133. };
  37134. module.exports = isFunction;
  37135. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37136. },{"../internal/baseIsFunction":361,"./isNative":409}],409:[function(require,module,exports){
  37137. var escapeRegExp = require('../string/escapeRegExp'),
  37138. isObjectLike = require('../internal/isObjectLike');
  37139. /** `Object#toString` result references. */
  37140. var funcTag = '[object Function]';
  37141. /** Used to detect host constructors (Safari > 5). */
  37142. var reHostCtor = /^\[object .+?Constructor\]$/;
  37143. /** Used for native method references. */
  37144. var objectProto = Object.prototype;
  37145. /** Used to resolve the decompiled source of functions. */
  37146. var fnToString = Function.prototype.toString;
  37147. /**
  37148. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37149. * of values.
  37150. */
  37151. var objToString = objectProto.toString;
  37152. /** Used to detect if a method is native. */
  37153. var reNative = RegExp('^' +
  37154. escapeRegExp(objToString)
  37155. .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  37156. );
  37157. /**
  37158. * Checks if `value` is a native function.
  37159. *
  37160. * @static
  37161. * @memberOf _
  37162. * @category Lang
  37163. * @param {*} value The value to check.
  37164. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  37165. * @example
  37166. *
  37167. * _.isNative(Array.prototype.push);
  37168. * // => true
  37169. *
  37170. * _.isNative(_);
  37171. * // => false
  37172. */
  37173. function isNative(value) {
  37174. if (value == null) {
  37175. return false;
  37176. }
  37177. if (objToString.call(value) == funcTag) {
  37178. return reNative.test(fnToString.call(value));
  37179. }
  37180. return isObjectLike(value) && reHostCtor.test(value);
  37181. }
  37182. module.exports = isNative;
  37183. },{"../internal/isObjectLike":396,"../string/escapeRegExp":425}],410:[function(require,module,exports){
  37184. var isObjectLike = require('../internal/isObjectLike');
  37185. /** `Object#toString` result references. */
  37186. var numberTag = '[object Number]';
  37187. /** Used for native method references. */
  37188. var objectProto = Object.prototype;
  37189. /**
  37190. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37191. * of values.
  37192. */
  37193. var objToString = objectProto.toString;
  37194. /**
  37195. * Checks if `value` is classified as a `Number` primitive or object.
  37196. *
  37197. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
  37198. * as numbers, use the `_.isFinite` method.
  37199. *
  37200. * @static
  37201. * @memberOf _
  37202. * @category Lang
  37203. * @param {*} value The value to check.
  37204. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37205. * @example
  37206. *
  37207. * _.isNumber(8.4);
  37208. * // => true
  37209. *
  37210. * _.isNumber(NaN);
  37211. * // => true
  37212. *
  37213. * _.isNumber('8.4');
  37214. * // => false
  37215. */
  37216. function isNumber(value) {
  37217. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  37218. }
  37219. module.exports = isNumber;
  37220. },{"../internal/isObjectLike":396}],411:[function(require,module,exports){
  37221. /**
  37222. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  37223. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  37224. *
  37225. * @static
  37226. * @memberOf _
  37227. * @category Lang
  37228. * @param {*} value The value to check.
  37229. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  37230. * @example
  37231. *
  37232. * _.isObject({});
  37233. * // => true
  37234. *
  37235. * _.isObject([1, 2, 3]);
  37236. * // => true
  37237. *
  37238. * _.isObject(1);
  37239. * // => false
  37240. */
  37241. function isObject(value) {
  37242. // Avoid a V8 JIT bug in Chrome 19-20.
  37243. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  37244. var type = typeof value;
  37245. return type == 'function' || (!!value && type == 'object');
  37246. }
  37247. module.exports = isObject;
  37248. },{}],412:[function(require,module,exports){
  37249. var isNative = require('./isNative'),
  37250. shimIsPlainObject = require('../internal/shimIsPlainObject');
  37251. /** `Object#toString` result references. */
  37252. var objectTag = '[object Object]';
  37253. /** Used for native method references. */
  37254. var objectProto = Object.prototype;
  37255. /**
  37256. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37257. * of values.
  37258. */
  37259. var objToString = objectProto.toString;
  37260. /** Native method references. */
  37261. var getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf;
  37262. /**
  37263. * Checks if `value` is a plain object, that is, an object created by the
  37264. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  37265. *
  37266. * **Note:** This method assumes objects created by the `Object` constructor
  37267. * have no inherited enumerable properties.
  37268. *
  37269. * @static
  37270. * @memberOf _
  37271. * @category Lang
  37272. * @param {*} value The value to check.
  37273. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  37274. * @example
  37275. *
  37276. * function Foo() {
  37277. * this.a = 1;
  37278. * }
  37279. *
  37280. * _.isPlainObject(new Foo);
  37281. * // => false
  37282. *
  37283. * _.isPlainObject([1, 2, 3]);
  37284. * // => false
  37285. *
  37286. * _.isPlainObject({ 'x': 0, 'y': 0 });
  37287. * // => true
  37288. *
  37289. * _.isPlainObject(Object.create(null));
  37290. * // => true
  37291. */
  37292. var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
  37293. if (!(value && objToString.call(value) == objectTag)) {
  37294. return false;
  37295. }
  37296. var valueOf = value.valueOf,
  37297. objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
  37298. return objProto
  37299. ? (value == objProto || getPrototypeOf(value) == objProto)
  37300. : shimIsPlainObject(value);
  37301. };
  37302. module.exports = isPlainObject;
  37303. },{"../internal/shimIsPlainObject":398,"./isNative":409}],413:[function(require,module,exports){
  37304. var isObjectLike = require('../internal/isObjectLike');
  37305. /** `Object#toString` result references. */
  37306. var regexpTag = '[object RegExp]';
  37307. /** Used for native method references. */
  37308. var objectProto = Object.prototype;
  37309. /**
  37310. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37311. * of values.
  37312. */
  37313. var objToString = objectProto.toString;
  37314. /**
  37315. * Checks if `value` is classified as a `RegExp` object.
  37316. *
  37317. * @static
  37318. * @memberOf _
  37319. * @category Lang
  37320. * @param {*} value The value to check.
  37321. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37322. * @example
  37323. *
  37324. * _.isRegExp(/abc/);
  37325. * // => true
  37326. *
  37327. * _.isRegExp('/abc/');
  37328. * // => false
  37329. */
  37330. function isRegExp(value) {
  37331. return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
  37332. }
  37333. module.exports = isRegExp;
  37334. },{"../internal/isObjectLike":396}],414:[function(require,module,exports){
  37335. var isObjectLike = require('../internal/isObjectLike');
  37336. /** `Object#toString` result references. */
  37337. var stringTag = '[object String]';
  37338. /** Used for native method references. */
  37339. var objectProto = Object.prototype;
  37340. /**
  37341. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37342. * of values.
  37343. */
  37344. var objToString = objectProto.toString;
  37345. /**
  37346. * Checks if `value` is classified as a `String` primitive or object.
  37347. *
  37348. * @static
  37349. * @memberOf _
  37350. * @category Lang
  37351. * @param {*} value The value to check.
  37352. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37353. * @example
  37354. *
  37355. * _.isString('abc');
  37356. * // => true
  37357. *
  37358. * _.isString(1);
  37359. * // => false
  37360. */
  37361. function isString(value) {
  37362. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  37363. }
  37364. module.exports = isString;
  37365. },{"../internal/isObjectLike":396}],415:[function(require,module,exports){
  37366. var isLength = require('../internal/isLength'),
  37367. isObjectLike = require('../internal/isObjectLike');
  37368. /** `Object#toString` result references. */
  37369. var argsTag = '[object Arguments]',
  37370. arrayTag = '[object Array]',
  37371. boolTag = '[object Boolean]',
  37372. dateTag = '[object Date]',
  37373. errorTag = '[object Error]',
  37374. funcTag = '[object Function]',
  37375. mapTag = '[object Map]',
  37376. numberTag = '[object Number]',
  37377. objectTag = '[object Object]',
  37378. regexpTag = '[object RegExp]',
  37379. setTag = '[object Set]',
  37380. stringTag = '[object String]',
  37381. weakMapTag = '[object WeakMap]';
  37382. var arrayBufferTag = '[object ArrayBuffer]',
  37383. float32Tag = '[object Float32Array]',
  37384. float64Tag = '[object Float64Array]',
  37385. int8Tag = '[object Int8Array]',
  37386. int16Tag = '[object Int16Array]',
  37387. int32Tag = '[object Int32Array]',
  37388. uint8Tag = '[object Uint8Array]',
  37389. uint8ClampedTag = '[object Uint8ClampedArray]',
  37390. uint16Tag = '[object Uint16Array]',
  37391. uint32Tag = '[object Uint32Array]';
  37392. /** Used to identify `toStringTag` values of typed arrays. */
  37393. var typedArrayTags = {};
  37394. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  37395. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  37396. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  37397. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  37398. typedArrayTags[uint32Tag] = true;
  37399. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  37400. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  37401. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  37402. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  37403. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  37404. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  37405. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  37406. /** Used for native method references. */
  37407. var objectProto = Object.prototype;
  37408. /**
  37409. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  37410. * of values.
  37411. */
  37412. var objToString = objectProto.toString;
  37413. /**
  37414. * Checks if `value` is classified as a typed array.
  37415. *
  37416. * @static
  37417. * @memberOf _
  37418. * @category Lang
  37419. * @param {*} value The value to check.
  37420. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  37421. * @example
  37422. *
  37423. * _.isTypedArray(new Uint8Array);
  37424. * // => true
  37425. *
  37426. * _.isTypedArray([]);
  37427. * // => false
  37428. */
  37429. function isTypedArray(value) {
  37430. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  37431. }
  37432. module.exports = isTypedArray;
  37433. },{"../internal/isLength":395,"../internal/isObjectLike":396}],416:[function(require,module,exports){
  37434. var baseCopy = require('../internal/baseCopy'),
  37435. keysIn = require('../object/keysIn');
  37436. /**
  37437. * Converts `value` to a plain object flattening inherited enumerable
  37438. * properties of `value` to own properties of the plain object.
  37439. *
  37440. * @static
  37441. * @memberOf _
  37442. * @category Lang
  37443. * @param {*} value The value to convert.
  37444. * @returns {Object} Returns the converted plain object.
  37445. * @example
  37446. *
  37447. * function Foo() {
  37448. * this.b = 2;
  37449. * }
  37450. *
  37451. * Foo.prototype.c = 3;
  37452. *
  37453. * _.assign({ 'a': 1 }, new Foo);
  37454. * // => { 'a': 1, 'b': 2 }
  37455. *
  37456. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  37457. * // => { 'a': 1, 'b': 2, 'c': 3 }
  37458. */
  37459. function toPlainObject(value) {
  37460. return baseCopy(value, keysIn(value));
  37461. }
  37462. module.exports = toPlainObject;
  37463. },{"../internal/baseCopy":349,"../object/keysIn":422}],417:[function(require,module,exports){
  37464. var baseAssign = require('../internal/baseAssign'),
  37465. createAssigner = require('../internal/createAssigner');
  37466. /**
  37467. * Assigns own enumerable properties of source object(s) to the destination
  37468. * object. Subsequent sources overwrite property assignments of previous sources.
  37469. * If `customizer` is provided it is invoked to produce the assigned values.
  37470. * The `customizer` is bound to `thisArg` and invoked with five arguments:
  37471. * (objectValue, sourceValue, key, object, source).
  37472. *
  37473. * @static
  37474. * @memberOf _
  37475. * @alias extend
  37476. * @category Object
  37477. * @param {Object} object The destination object.
  37478. * @param {...Object} [sources] The source objects.
  37479. * @param {Function} [customizer] The function to customize assigning values.
  37480. * @param {*} [thisArg] The `this` binding of `customizer`.
  37481. * @returns {Object} Returns `object`.
  37482. * @example
  37483. *
  37484. * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
  37485. * // => { 'user': 'fred', 'age': 40 }
  37486. *
  37487. * // using a customizer callback
  37488. * var defaults = _.partialRight(_.assign, function(value, other) {
  37489. * return typeof value == 'undefined' ? other : value;
  37490. * });
  37491. *
  37492. * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  37493. * // => { 'user': 'barney', 'age': 36 }
  37494. */
  37495. var assign = createAssigner(baseAssign);
  37496. module.exports = assign;
  37497. },{"../internal/baseAssign":345,"../internal/createAssigner":380}],418:[function(require,module,exports){
  37498. var assign = require('./assign'),
  37499. assignDefaults = require('../internal/assignDefaults'),
  37500. restParam = require('../function/restParam');
  37501. /**
  37502. * Assigns own enumerable properties of source object(s) to the destination
  37503. * object for all destination properties that resolve to `undefined`. Once a
  37504. * property is set, additional values of the same property are ignored.
  37505. *
  37506. * @static
  37507. * @memberOf _
  37508. * @category Object
  37509. * @param {Object} object The destination object.
  37510. * @param {...Object} [sources] The source objects.
  37511. * @returns {Object} Returns `object`.
  37512. * @example
  37513. *
  37514. * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  37515. * // => { 'user': 'barney', 'age': 36 }
  37516. */
  37517. var defaults = restParam(function(args) {
  37518. var object = args[0];
  37519. if (object == null) {
  37520. return object;
  37521. }
  37522. args.push(assignDefaults);
  37523. return assign.apply(undefined, args);
  37524. });
  37525. module.exports = defaults;
  37526. },{"../function/restParam":337,"../internal/assignDefaults":344,"./assign":417}],419:[function(require,module,exports){
  37527. module.exports = require('./assign');
  37528. },{"./assign":417}],420:[function(require,module,exports){
  37529. /** Used for native method references. */
  37530. var objectProto = Object.prototype;
  37531. /** Used to check objects for own properties. */
  37532. var hasOwnProperty = objectProto.hasOwnProperty;
  37533. /**
  37534. * Checks if `key` exists as a direct property of `object` instead of an
  37535. * inherited property.
  37536. *
  37537. * @static
  37538. * @memberOf _
  37539. * @category Object
  37540. * @param {Object} object The object to inspect.
  37541. * @param {string} key The key to check.
  37542. * @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
  37543. * @example
  37544. *
  37545. * var object = { 'a': 1, 'b': 2, 'c': 3 };
  37546. *
  37547. * _.has(object, 'b');
  37548. * // => true
  37549. */
  37550. function has(object, key) {
  37551. return object ? hasOwnProperty.call(object, key) : false;
  37552. }
  37553. module.exports = has;
  37554. },{}],421:[function(require,module,exports){
  37555. var isLength = require('../internal/isLength'),
  37556. isNative = require('../lang/isNative'),
  37557. isObject = require('../lang/isObject'),
  37558. shimKeys = require('../internal/shimKeys');
  37559. /* Native method references for those with the same name as other `lodash` methods. */
  37560. var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
  37561. /**
  37562. * Creates an array of the own enumerable property names of `object`.
  37563. *
  37564. * **Note:** Non-object values are coerced to objects. See the
  37565. * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
  37566. * for more details.
  37567. *
  37568. * @static
  37569. * @memberOf _
  37570. * @category Object
  37571. * @param {Object} object The object to inspect.
  37572. * @returns {Array} Returns the array of property names.
  37573. * @example
  37574. *
  37575. * function Foo() {
  37576. * this.a = 1;
  37577. * this.b = 2;
  37578. * }
  37579. *
  37580. * Foo.prototype.c = 3;
  37581. *
  37582. * _.keys(new Foo);
  37583. * // => ['a', 'b'] (iteration order is not guaranteed)
  37584. *
  37585. * _.keys('hi');
  37586. * // => ['0', '1']
  37587. */
  37588. var keys = !nativeKeys ? shimKeys : function(object) {
  37589. if (object) {
  37590. var Ctor = object.constructor,
  37591. length = object.length;
  37592. }
  37593. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  37594. (typeof object != 'function' && (length && isLength(length)))) {
  37595. return shimKeys(object);
  37596. }
  37597. return isObject(object) ? nativeKeys(object) : [];
  37598. };
  37599. module.exports = keys;
  37600. },{"../internal/isLength":395,"../internal/shimKeys":399,"../lang/isNative":409,"../lang/isObject":411}],422:[function(require,module,exports){
  37601. var isArguments = require('../lang/isArguments'),
  37602. isArray = require('../lang/isArray'),
  37603. isIndex = require('../internal/isIndex'),
  37604. isLength = require('../internal/isLength'),
  37605. isObject = require('../lang/isObject'),
  37606. support = require('../support');
  37607. /** Used for native method references. */
  37608. var objectProto = Object.prototype;
  37609. /** Used to check objects for own properties. */
  37610. var hasOwnProperty = objectProto.hasOwnProperty;
  37611. /**
  37612. * Creates an array of the own and inherited enumerable property names of `object`.
  37613. *
  37614. * **Note:** Non-object values are coerced to objects.
  37615. *
  37616. * @static
  37617. * @memberOf _
  37618. * @category Object
  37619. * @param {Object} object The object to inspect.
  37620. * @returns {Array} Returns the array of property names.
  37621. * @example
  37622. *
  37623. * function Foo() {
  37624. * this.a = 1;
  37625. * this.b = 2;
  37626. * }
  37627. *
  37628. * Foo.prototype.c = 3;
  37629. *
  37630. * _.keysIn(new Foo);
  37631. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  37632. */
  37633. function keysIn(object) {
  37634. if (object == null) {
  37635. return [];
  37636. }
  37637. if (!isObject(object)) {
  37638. object = Object(object);
  37639. }
  37640. var length = object.length;
  37641. length = (length && isLength(length) &&
  37642. (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
  37643. var Ctor = object.constructor,
  37644. index = -1,
  37645. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  37646. result = Array(length),
  37647. skipIndexes = length > 0;
  37648. while (++index < length) {
  37649. result[index] = (index + '');
  37650. }
  37651. for (var key in object) {
  37652. if (!(skipIndexes && isIndex(key, length)) &&
  37653. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  37654. result.push(key);
  37655. }
  37656. }
  37657. return result;
  37658. }
  37659. module.exports = keysIn;
  37660. },{"../internal/isIndex":393,"../internal/isLength":395,"../lang/isArguments":404,"../lang/isArray":405,"../lang/isObject":411,"../support":427}],423:[function(require,module,exports){
  37661. var baseMerge = require('../internal/baseMerge'),
  37662. createAssigner = require('../internal/createAssigner');
  37663. /**
  37664. * Recursively merges own enumerable properties of the source object(s), that
  37665. * don't resolve to `undefined` into the destination object. Subsequent sources
  37666. * overwrite property assignments of previous sources. If `customizer` is
  37667. * provided it is invoked to produce the merged values of the destination and
  37668. * source properties. If `customizer` returns `undefined` merging is handled
  37669. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  37670. * with five arguments: (objectValue, sourceValue, key, object, source).
  37671. *
  37672. * @static
  37673. * @memberOf _
  37674. * @category Object
  37675. * @param {Object} object The destination object.
  37676. * @param {...Object} [sources] The source objects.
  37677. * @param {Function} [customizer] The function to customize merging properties.
  37678. * @param {*} [thisArg] The `this` binding of `customizer`.
  37679. * @returns {Object} Returns `object`.
  37680. * @example
  37681. *
  37682. * var users = {
  37683. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  37684. * };
  37685. *
  37686. * var ages = {
  37687. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  37688. * };
  37689. *
  37690. * _.merge(users, ages);
  37691. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  37692. *
  37693. * // using a customizer callback
  37694. * var object = {
  37695. * 'fruits': ['apple'],
  37696. * 'vegetables': ['beet']
  37697. * };
  37698. *
  37699. * var other = {
  37700. * 'fruits': ['banana'],
  37701. * 'vegetables': ['carrot']
  37702. * };
  37703. *
  37704. * _.merge(object, other, function(a, b) {
  37705. * if (_.isArray(a)) {
  37706. * return a.concat(b);
  37707. * }
  37708. * });
  37709. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  37710. */
  37711. var merge = createAssigner(baseMerge);
  37712. module.exports = merge;
  37713. },{"../internal/baseMerge":366,"../internal/createAssigner":380}],424:[function(require,module,exports){
  37714. var baseValues = require('../internal/baseValues'),
  37715. keys = require('./keys');
  37716. /**
  37717. * Creates an array of the own enumerable property values of `object`.
  37718. *
  37719. * **Note:** Non-object values are coerced to objects.
  37720. *
  37721. * @static
  37722. * @memberOf _
  37723. * @category Object
  37724. * @param {Object} object The object to query.
  37725. * @returns {Array} Returns the array of property values.
  37726. * @example
  37727. *
  37728. * function Foo() {
  37729. * this.a = 1;
  37730. * this.b = 2;
  37731. * }
  37732. *
  37733. * Foo.prototype.c = 3;
  37734. *
  37735. * _.values(new Foo);
  37736. * // => [1, 2] (iteration order is not guaranteed)
  37737. *
  37738. * _.values('hi');
  37739. * // => ['h', 'i']
  37740. */
  37741. function values(object) {
  37742. return baseValues(object, keys(object));
  37743. }
  37744. module.exports = values;
  37745. },{"../internal/baseValues":374,"./keys":421}],425:[function(require,module,exports){
  37746. var baseToString = require('../internal/baseToString');
  37747. /**
  37748. * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
  37749. * In addition to special characters the forward slash is escaped to allow for
  37750. * easier `eval` use and `Function` compilation.
  37751. */
  37752. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
  37753. reHasRegExpChars = RegExp(reRegExpChars.source);
  37754. /**
  37755. * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",
  37756. * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.
  37757. *
  37758. * @static
  37759. * @memberOf _
  37760. * @category String
  37761. * @param {string} [string=''] The string to escape.
  37762. * @returns {string} Returns the escaped string.
  37763. * @example
  37764. *
  37765. * _.escapeRegExp('[lodash](https://lodash.com/)');
  37766. * // => '\[lodash\]\(https:\/\/lodash\.com\/\)'
  37767. */
  37768. function escapeRegExp(string) {
  37769. string = baseToString(string);
  37770. return (string && reHasRegExpChars.test(string))
  37771. ? string.replace(reRegExpChars, '\\$&')
  37772. : string;
  37773. }
  37774. module.exports = escapeRegExp;
  37775. },{"../internal/baseToString":372}],426:[function(require,module,exports){
  37776. var baseToString = require('../internal/baseToString');
  37777. /* Native method references for those with the same name as other `lodash` methods. */
  37778. var nativeMin = Math.min;
  37779. /**
  37780. * Checks if `string` starts with the given target string.
  37781. *
  37782. * @static
  37783. * @memberOf _
  37784. * @category String
  37785. * @param {string} [string=''] The string to search.
  37786. * @param {string} [target] The string to search for.
  37787. * @param {number} [position=0] The position to search from.
  37788. * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.
  37789. * @example
  37790. *
  37791. * _.startsWith('abc', 'a');
  37792. * // => true
  37793. *
  37794. * _.startsWith('abc', 'b');
  37795. * // => false
  37796. *
  37797. * _.startsWith('abc', 'b', 1);
  37798. * // => true
  37799. */
  37800. function startsWith(string, target, position) {
  37801. string = baseToString(string);
  37802. position = position == null
  37803. ? 0
  37804. : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
  37805. return string.lastIndexOf(target, position) == position;
  37806. }
  37807. module.exports = startsWith;
  37808. },{"../internal/baseToString":372}],427:[function(require,module,exports){
  37809. (function (global){
  37810. /** Used for native method references. */
  37811. var objectProto = Object.prototype;
  37812. /** Used to detect DOM support. */
  37813. var document = (document = global.window) && document.document;
  37814. /** Native method references. */
  37815. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  37816. /**
  37817. * An object environment feature flags.
  37818. *
  37819. * @static
  37820. * @memberOf _
  37821. * @type Object
  37822. */
  37823. var support = {};
  37824. (function(x) {
  37825. /**
  37826. * Detect if functions can be decompiled by `Function#toString`
  37827. * (all but Firefox OS certified apps, older Opera mobile browsers, and
  37828. * the PlayStation 3; forced `false` for Windows 8 apps).
  37829. *
  37830. * @memberOf _.support
  37831. * @type boolean
  37832. */
  37833. support.funcDecomp = /\bthis\b/.test(function() { return this; });
  37834. /**
  37835. * Detect if `Function#name` is supported (all but IE).
  37836. *
  37837. * @memberOf _.support
  37838. * @type boolean
  37839. */
  37840. support.funcNames = typeof Function.name == 'string';
  37841. /**
  37842. * Detect if the DOM is supported.
  37843. *
  37844. * @memberOf _.support
  37845. * @type boolean
  37846. */
  37847. try {
  37848. support.dom = document.createDocumentFragment().nodeType === 11;
  37849. } catch(e) {
  37850. support.dom = false;
  37851. }
  37852. /**
  37853. * Detect if `arguments` object indexes are non-enumerable.
  37854. *
  37855. * In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
  37856. * indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
  37857. * `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
  37858. * checks for indexes that exceed their function's formal parameters with
  37859. * associated values of `0`.
  37860. *
  37861. * @memberOf _.support
  37862. * @type boolean
  37863. */
  37864. try {
  37865. support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
  37866. } catch(e) {
  37867. support.nonEnumArgs = true;
  37868. }
  37869. }(0, 0));
  37870. module.exports = support;
  37871. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37872. },{}],428:[function(require,module,exports){
  37873. /**
  37874. * Creates a function that returns `value`.
  37875. *
  37876. * @static
  37877. * @memberOf _
  37878. * @category Utility
  37879. * @param {*} value The value to return from the new function.
  37880. * @returns {Function} Returns the new function.
  37881. * @example
  37882. *
  37883. * var object = { 'user': 'fred' };
  37884. * var getter = _.constant(object);
  37885. *
  37886. * getter() === object;
  37887. * // => true
  37888. */
  37889. function constant(value) {
  37890. return function() {
  37891. return value;
  37892. };
  37893. }
  37894. module.exports = constant;
  37895. },{}],429:[function(require,module,exports){
  37896. /**
  37897. * This method returns the first argument provided to it.
  37898. *
  37899. * @static
  37900. * @memberOf _
  37901. * @category Utility
  37902. * @param {*} value Any value.
  37903. * @returns {*} Returns `value`.
  37904. * @example
  37905. *
  37906. * var object = { 'user': 'fred' };
  37907. *
  37908. * _.identity(object) === object;
  37909. * // => true
  37910. */
  37911. function identity(value) {
  37912. return value;
  37913. }
  37914. module.exports = identity;
  37915. },{}],430:[function(require,module,exports){
  37916. (function (process){
  37917. module.exports = minimatch
  37918. minimatch.Minimatch = Minimatch
  37919. var isWindows = false
  37920. if (typeof process !== 'undefined' && process.platform === 'win32')
  37921. isWindows = true
  37922. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
  37923. , expand = require("brace-expansion")
  37924. // any single thing other than /
  37925. // don't need to escape / when using new RegExp()
  37926. , qmark = "[^/]"
  37927. // * => any number of characters
  37928. , star = qmark + "*?"
  37929. // ** when dots are allowed. Anything goes, except .. and .
  37930. // not (^ or / followed by one or two dots followed by $ or /),
  37931. // followed by anything, any number of times.
  37932. , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"
  37933. // not a ^ or / followed by a dot,
  37934. // followed by anything, any number of times.
  37935. , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"
  37936. // characters that need to be escaped in RegExp.
  37937. , reSpecials = charSet("().*{}+?[]^$\\!")
  37938. // "abc" -> { a:true, b:true, c:true }
  37939. function charSet (s) {
  37940. return s.split("").reduce(function (set, c) {
  37941. set[c] = true
  37942. return set
  37943. }, {})
  37944. }
  37945. // normalizes slashes.
  37946. var slashSplit = /\/+/
  37947. minimatch.filter = filter
  37948. function filter (pattern, options) {
  37949. options = options || {}
  37950. return function (p, i, list) {
  37951. return minimatch(p, pattern, options)
  37952. }
  37953. }
  37954. function ext (a, b) {
  37955. a = a || {}
  37956. b = b || {}
  37957. var t = {}
  37958. Object.keys(b).forEach(function (k) {
  37959. t[k] = b[k]
  37960. })
  37961. Object.keys(a).forEach(function (k) {
  37962. t[k] = a[k]
  37963. })
  37964. return t
  37965. }
  37966. minimatch.defaults = function (def) {
  37967. if (!def || !Object.keys(def).length) return minimatch
  37968. var orig = minimatch
  37969. var m = function minimatch (p, pattern, options) {
  37970. return orig.minimatch(p, pattern, ext(def, options))
  37971. }
  37972. m.Minimatch = function Minimatch (pattern, options) {
  37973. return new orig.Minimatch(pattern, ext(def, options))
  37974. }
  37975. return m
  37976. }
  37977. Minimatch.defaults = function (def) {
  37978. if (!def || !Object.keys(def).length) return Minimatch
  37979. return minimatch.defaults(def).Minimatch
  37980. }
  37981. function minimatch (p, pattern, options) {
  37982. if (typeof pattern !== "string") {
  37983. throw new TypeError("glob pattern string required")
  37984. }
  37985. if (!options) options = {}
  37986. // shortcut: comments match nothing.
  37987. if (!options.nocomment && pattern.charAt(0) === "#") {
  37988. return false
  37989. }
  37990. // "" only matches ""
  37991. if (pattern.trim() === "") return p === ""
  37992. return new Minimatch(pattern, options).match(p)
  37993. }
  37994. function Minimatch (pattern, options) {
  37995. if (!(this instanceof Minimatch)) {
  37996. return new Minimatch(pattern, options)
  37997. }
  37998. if (typeof pattern !== "string") {
  37999. throw new TypeError("glob pattern string required")
  38000. }
  38001. if (!options) options = {}
  38002. pattern = pattern.trim()
  38003. // windows support: need to use /, not \
  38004. if (isWindows)
  38005. pattern = pattern.split("\\").join("/")
  38006. this.options = options
  38007. this.set = []
  38008. this.pattern = pattern
  38009. this.regexp = null
  38010. this.negate = false
  38011. this.comment = false
  38012. this.empty = false
  38013. // make the set of regexps etc.
  38014. this.make()
  38015. }
  38016. Minimatch.prototype.debug = function() {}
  38017. Minimatch.prototype.make = make
  38018. function make () {
  38019. // don't do it more than once.
  38020. if (this._made) return
  38021. var pattern = this.pattern
  38022. var options = this.options
  38023. // empty patterns and comments match nothing.
  38024. if (!options.nocomment && pattern.charAt(0) === "#") {
  38025. this.comment = true
  38026. return
  38027. }
  38028. if (!pattern) {
  38029. this.empty = true
  38030. return
  38031. }
  38032. // step 1: figure out negation, etc.
  38033. this.parseNegate()
  38034. // step 2: expand braces
  38035. var set = this.globSet = this.braceExpand()
  38036. if (options.debug) this.debug = console.error
  38037. this.debug(this.pattern, set)
  38038. // step 3: now we have a set, so turn each one into a series of path-portion
  38039. // matching patterns.
  38040. // These will be regexps, except in the case of "**", which is
  38041. // set to the GLOBSTAR object for globstar behavior,
  38042. // and will not contain any / characters
  38043. set = this.globParts = set.map(function (s) {
  38044. return s.split(slashSplit)
  38045. })
  38046. this.debug(this.pattern, set)
  38047. // glob --> regexps
  38048. set = set.map(function (s, si, set) {
  38049. return s.map(this.parse, this)
  38050. }, this)
  38051. this.debug(this.pattern, set)
  38052. // filter out everything that didn't compile properly.
  38053. set = set.filter(function (s) {
  38054. return -1 === s.indexOf(false)
  38055. })
  38056. this.debug(this.pattern, set)
  38057. this.set = set
  38058. }
  38059. Minimatch.prototype.parseNegate = parseNegate
  38060. function parseNegate () {
  38061. var pattern = this.pattern
  38062. , negate = false
  38063. , options = this.options
  38064. , negateOffset = 0
  38065. if (options.nonegate) return
  38066. for ( var i = 0, l = pattern.length
  38067. ; i < l && pattern.charAt(i) === "!"
  38068. ; i ++) {
  38069. negate = !negate
  38070. negateOffset ++
  38071. }
  38072. if (negateOffset) this.pattern = pattern.substr(negateOffset)
  38073. this.negate = negate
  38074. }
  38075. // Brace expansion:
  38076. // a{b,c}d -> abd acd
  38077. // a{b,}c -> abc ac
  38078. // a{0..3}d -> a0d a1d a2d a3d
  38079. // a{b,c{d,e}f}g -> abg acdfg acefg
  38080. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  38081. //
  38082. // Invalid sets are not expanded.
  38083. // a{2..}b -> a{2..}b
  38084. // a{b}c -> a{b}c
  38085. minimatch.braceExpand = function (pattern, options) {
  38086. return braceExpand(pattern, options)
  38087. }
  38088. Minimatch.prototype.braceExpand = braceExpand
  38089. function braceExpand (pattern, options) {
  38090. if (!options) {
  38091. if (this instanceof Minimatch)
  38092. options = this.options
  38093. else
  38094. options = {}
  38095. }
  38096. pattern = typeof pattern === "undefined"
  38097. ? this.pattern : pattern
  38098. if (typeof pattern === "undefined") {
  38099. throw new Error("undefined pattern")
  38100. }
  38101. if (options.nobrace ||
  38102. !pattern.match(/\{.*\}/)) {
  38103. // shortcut. no need to expand.
  38104. return [pattern]
  38105. }
  38106. return expand(pattern)
  38107. }
  38108. // parse a component of the expanded set.
  38109. // At this point, no pattern may contain "/" in it
  38110. // so we're going to return a 2d array, where each entry is the full
  38111. // pattern, split on '/', and then turned into a regular expression.
  38112. // A regexp is made at the end which joins each array with an
  38113. // escaped /, and another full one which joins each regexp with |.
  38114. //
  38115. // Following the lead of Bash 4.1, note that "**" only has special meaning
  38116. // when it is the *only* thing in a path portion. Otherwise, any series
  38117. // of * is equivalent to a single *. Globstar behavior is enabled by
  38118. // default, and can be disabled by setting options.noglobstar.
  38119. Minimatch.prototype.parse = parse
  38120. var SUBPARSE = {}
  38121. function parse (pattern, isSub) {
  38122. var options = this.options
  38123. // shortcuts
  38124. if (!options.noglobstar && pattern === "**") return GLOBSTAR
  38125. if (pattern === "") return ""
  38126. var re = ""
  38127. , hasMagic = !!options.nocase
  38128. , escaping = false
  38129. // ? => one single character
  38130. , patternListStack = []
  38131. , plType
  38132. , stateChar
  38133. , inClass = false
  38134. , reClassStart = -1
  38135. , classStart = -1
  38136. // . and .. never match anything that doesn't start with .,
  38137. // even when options.dot is set.
  38138. , patternStart = pattern.charAt(0) === "." ? "" // anything
  38139. // not (start or / followed by . or .. followed by / or end)
  38140. : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"
  38141. : "(?!\\.)"
  38142. , self = this
  38143. function clearStateChar () {
  38144. if (stateChar) {
  38145. // we had some state-tracking character
  38146. // that wasn't consumed by this pass.
  38147. switch (stateChar) {
  38148. case "*":
  38149. re += star
  38150. hasMagic = true
  38151. break
  38152. case "?":
  38153. re += qmark
  38154. hasMagic = true
  38155. break
  38156. default:
  38157. re += "\\"+stateChar
  38158. break
  38159. }
  38160. self.debug('clearStateChar %j %j', stateChar, re)
  38161. stateChar = false
  38162. }
  38163. }
  38164. for ( var i = 0, len = pattern.length, c
  38165. ; (i < len) && (c = pattern.charAt(i))
  38166. ; i ++ ) {
  38167. this.debug("%s\t%s %s %j", pattern, i, re, c)
  38168. // skip over any that are escaped.
  38169. if (escaping && reSpecials[c]) {
  38170. re += "\\" + c
  38171. escaping = false
  38172. continue
  38173. }
  38174. SWITCH: switch (c) {
  38175. case "/":
  38176. // completely not allowed, even escaped.
  38177. // Should already be path-split by now.
  38178. return false
  38179. case "\\":
  38180. clearStateChar()
  38181. escaping = true
  38182. continue
  38183. // the various stateChar values
  38184. // for the "extglob" stuff.
  38185. case "?":
  38186. case "*":
  38187. case "+":
  38188. case "@":
  38189. case "!":
  38190. this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)
  38191. // all of those are literals inside a class, except that
  38192. // the glob [!a] means [^a] in regexp
  38193. if (inClass) {
  38194. this.debug(' in class')
  38195. if (c === "!" && i === classStart + 1) c = "^"
  38196. re += c
  38197. continue
  38198. }
  38199. // if we already have a stateChar, then it means
  38200. // that there was something like ** or +? in there.
  38201. // Handle the stateChar, then proceed with this one.
  38202. self.debug('call clearStateChar %j', stateChar)
  38203. clearStateChar()
  38204. stateChar = c
  38205. // if extglob is disabled, then +(asdf|foo) isn't a thing.
  38206. // just clear the statechar *now*, rather than even diving into
  38207. // the patternList stuff.
  38208. if (options.noext) clearStateChar()
  38209. continue
  38210. case "(":
  38211. if (inClass) {
  38212. re += "("
  38213. continue
  38214. }
  38215. if (!stateChar) {
  38216. re += "\\("
  38217. continue
  38218. }
  38219. plType = stateChar
  38220. patternListStack.push({ type: plType
  38221. , start: i - 1
  38222. , reStart: re.length })
  38223. // negation is (?:(?!js)[^/]*)
  38224. re += stateChar === "!" ? "(?:(?!" : "(?:"
  38225. this.debug('plType %j %j', stateChar, re)
  38226. stateChar = false
  38227. continue
  38228. case ")":
  38229. if (inClass || !patternListStack.length) {
  38230. re += "\\)"
  38231. continue
  38232. }
  38233. clearStateChar()
  38234. hasMagic = true
  38235. re += ")"
  38236. plType = patternListStack.pop().type
  38237. // negation is (?:(?!js)[^/]*)
  38238. // The others are (?:<pattern>)<type>
  38239. switch (plType) {
  38240. case "!":
  38241. re += "[^/]*?)"
  38242. break
  38243. case "?":
  38244. case "+":
  38245. case "*": re += plType
  38246. case "@": break // the default anyway
  38247. }
  38248. continue
  38249. case "|":
  38250. if (inClass || !patternListStack.length || escaping) {
  38251. re += "\\|"
  38252. escaping = false
  38253. continue
  38254. }
  38255. clearStateChar()
  38256. re += "|"
  38257. continue
  38258. // these are mostly the same in regexp and glob
  38259. case "[":
  38260. // swallow any state-tracking char before the [
  38261. clearStateChar()
  38262. if (inClass) {
  38263. re += "\\" + c
  38264. continue
  38265. }
  38266. inClass = true
  38267. classStart = i
  38268. reClassStart = re.length
  38269. re += c
  38270. continue
  38271. case "]":
  38272. // a right bracket shall lose its special
  38273. // meaning and represent itself in
  38274. // a bracket expression if it occurs
  38275. // first in the list. -- POSIX.2 2.8.3.2
  38276. if (i === classStart + 1 || !inClass) {
  38277. re += "\\" + c
  38278. escaping = false
  38279. continue
  38280. }
  38281. // handle the case where we left a class open.
  38282. // "[z-a]" is valid, equivalent to "\[z-a\]"
  38283. if (inClass) {
  38284. // split where the last [ was, make sure we don't have
  38285. // an invalid re. if so, re-walk the contents of the
  38286. // would-be class to re-translate any characters that
  38287. // were passed through as-is
  38288. // TODO: It would probably be faster to determine this
  38289. // without a try/catch and a new RegExp, but it's tricky
  38290. // to do safely. For now, this is safe and works.
  38291. var cs = pattern.substring(classStart + 1, i)
  38292. try {
  38293. new RegExp('[' + cs + ']')
  38294. } catch (er) {
  38295. // not a valid class!
  38296. var sp = this.parse(cs, SUBPARSE)
  38297. re = re.substr(0, reClassStart) + "\\[" + sp[0] + '\\]'
  38298. hasMagic = hasMagic || sp[1]
  38299. inClass = false
  38300. continue
  38301. }
  38302. }
  38303. // finish up the class.
  38304. hasMagic = true
  38305. inClass = false
  38306. re += c
  38307. continue
  38308. default:
  38309. // swallow any state char that wasn't consumed
  38310. clearStateChar()
  38311. if (escaping) {
  38312. // no need
  38313. escaping = false
  38314. } else if (reSpecials[c]
  38315. && !(c === "^" && inClass)) {
  38316. re += "\\"
  38317. }
  38318. re += c
  38319. } // switch
  38320. } // for
  38321. // handle the case where we left a class open.
  38322. // "[abc" is valid, equivalent to "\[abc"
  38323. if (inClass) {
  38324. // split where the last [ was, and escape it
  38325. // this is a huge pita. We now have to re-walk
  38326. // the contents of the would-be class to re-translate
  38327. // any characters that were passed through as-is
  38328. var cs = pattern.substr(classStart + 1)
  38329. , sp = this.parse(cs, SUBPARSE)
  38330. re = re.substr(0, reClassStart) + "\\[" + sp[0]
  38331. hasMagic = hasMagic || sp[1]
  38332. }
  38333. // handle the case where we had a +( thing at the *end*
  38334. // of the pattern.
  38335. // each pattern list stack adds 3 chars, and we need to go through
  38336. // and escape any | chars that were passed through as-is for the regexp.
  38337. // Go through and escape them, taking care not to double-escape any
  38338. // | chars that were already escaped.
  38339. var pl
  38340. while (pl = patternListStack.pop()) {
  38341. var tail = re.slice(pl.reStart + 3)
  38342. // maybe some even number of \, then maybe 1 \, followed by a |
  38343. tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
  38344. if (!$2) {
  38345. // the | isn't already escaped, so escape it.
  38346. $2 = "\\"
  38347. }
  38348. // need to escape all those slashes *again*, without escaping the
  38349. // one that we need for escaping the | character. As it works out,
  38350. // escaping an even number of slashes can be done by simply repeating
  38351. // it exactly after itself. That's why this trick works.
  38352. //
  38353. // I am sorry that you have to see this.
  38354. return $1 + $1 + $2 + "|"
  38355. })
  38356. this.debug("tail=%j\n %s", tail, tail)
  38357. var t = pl.type === "*" ? star
  38358. : pl.type === "?" ? qmark
  38359. : "\\" + pl.type
  38360. hasMagic = true
  38361. re = re.slice(0, pl.reStart)
  38362. + t + "\\("
  38363. + tail
  38364. }
  38365. // handle trailing things that only matter at the very end.
  38366. clearStateChar()
  38367. if (escaping) {
  38368. // trailing \\
  38369. re += "\\\\"
  38370. }
  38371. // only need to apply the nodot start if the re starts with
  38372. // something that could conceivably capture a dot
  38373. var addPatternStart = false
  38374. switch (re.charAt(0)) {
  38375. case ".":
  38376. case "[":
  38377. case "(": addPatternStart = true
  38378. }
  38379. // if the re is not "" at this point, then we need to make sure
  38380. // it doesn't match against an empty path part.
  38381. // Otherwise a/* will match a/, which it should not.
  38382. if (re !== "" && hasMagic) re = "(?=.)" + re
  38383. if (addPatternStart) re = patternStart + re
  38384. // parsing just a piece of a larger pattern.
  38385. if (isSub === SUBPARSE) {
  38386. return [ re, hasMagic ]
  38387. }
  38388. // skip the regexp for non-magical patterns
  38389. // unescape anything in it, though, so that it'll be
  38390. // an exact match against a file etc.
  38391. if (!hasMagic) {
  38392. return globUnescape(pattern)
  38393. }
  38394. var flags = options.nocase ? "i" : ""
  38395. , regExp = new RegExp("^" + re + "$", flags)
  38396. regExp._glob = pattern
  38397. regExp._src = re
  38398. return regExp
  38399. }
  38400. minimatch.makeRe = function (pattern, options) {
  38401. return new Minimatch(pattern, options || {}).makeRe()
  38402. }
  38403. Minimatch.prototype.makeRe = makeRe
  38404. function makeRe () {
  38405. if (this.regexp || this.regexp === false) return this.regexp
  38406. // at this point, this.set is a 2d array of partial
  38407. // pattern strings, or "**".
  38408. //
  38409. // It's better to use .match(). This function shouldn't
  38410. // be used, really, but it's pretty convenient sometimes,
  38411. // when you just want to work with a regex.
  38412. var set = this.set
  38413. if (!set.length) return this.regexp = false
  38414. var options = this.options
  38415. var twoStar = options.noglobstar ? star
  38416. : options.dot ? twoStarDot
  38417. : twoStarNoDot
  38418. , flags = options.nocase ? "i" : ""
  38419. var re = set.map(function (pattern) {
  38420. return pattern.map(function (p) {
  38421. return (p === GLOBSTAR) ? twoStar
  38422. : (typeof p === "string") ? regExpEscape(p)
  38423. : p._src
  38424. }).join("\\\/")
  38425. }).join("|")
  38426. // must match entire pattern
  38427. // ending in a * or ** will make it less strict.
  38428. re = "^(?:" + re + ")$"
  38429. // can match anything, as long as it's not this.
  38430. if (this.negate) re = "^(?!" + re + ").*$"
  38431. try {
  38432. return this.regexp = new RegExp(re, flags)
  38433. } catch (ex) {
  38434. return this.regexp = false
  38435. }
  38436. }
  38437. minimatch.match = function (list, pattern, options) {
  38438. options = options || {}
  38439. var mm = new Minimatch(pattern, options)
  38440. list = list.filter(function (f) {
  38441. return mm.match(f)
  38442. })
  38443. if (mm.options.nonull && !list.length) {
  38444. list.push(pattern)
  38445. }
  38446. return list
  38447. }
  38448. Minimatch.prototype.match = match
  38449. function match (f, partial) {
  38450. this.debug("match", f, this.pattern)
  38451. // short-circuit in the case of busted things.
  38452. // comments, etc.
  38453. if (this.comment) return false
  38454. if (this.empty) return f === ""
  38455. if (f === "/" && partial) return true
  38456. var options = this.options
  38457. // windows: need to use /, not \
  38458. if (isWindows)
  38459. f = f.split("\\").join("/")
  38460. // treat the test path as a set of pathparts.
  38461. f = f.split(slashSplit)
  38462. this.debug(this.pattern, "split", f)
  38463. // just ONE of the pattern sets in this.set needs to match
  38464. // in order for it to be valid. If negating, then just one
  38465. // match means that we have failed.
  38466. // Either way, return on the first hit.
  38467. var set = this.set
  38468. this.debug(this.pattern, "set", set)
  38469. // Find the basename of the path by looking for the last non-empty segment
  38470. var filename;
  38471. for (var i = f.length - 1; i >= 0; i--) {
  38472. filename = f[i]
  38473. if (filename) break
  38474. }
  38475. for (var i = 0, l = set.length; i < l; i ++) {
  38476. var pattern = set[i], file = f
  38477. if (options.matchBase && pattern.length === 1) {
  38478. file = [filename]
  38479. }
  38480. var hit = this.matchOne(file, pattern, partial)
  38481. if (hit) {
  38482. if (options.flipNegate) return true
  38483. return !this.negate
  38484. }
  38485. }
  38486. // didn't get any hits. this is success if it's a negative
  38487. // pattern, failure otherwise.
  38488. if (options.flipNegate) return false
  38489. return this.negate
  38490. }
  38491. // set partial to true to test if, for example,
  38492. // "/a/b" matches the start of "/*/b/*/d"
  38493. // Partial means, if you run out of file before you run
  38494. // out of pattern, then that's fine, as long as all
  38495. // the parts match.
  38496. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  38497. var options = this.options
  38498. this.debug("matchOne",
  38499. { "this": this
  38500. , file: file
  38501. , pattern: pattern })
  38502. this.debug("matchOne", file.length, pattern.length)
  38503. for ( var fi = 0
  38504. , pi = 0
  38505. , fl = file.length
  38506. , pl = pattern.length
  38507. ; (fi < fl) && (pi < pl)
  38508. ; fi ++, pi ++ ) {
  38509. this.debug("matchOne loop")
  38510. var p = pattern[pi]
  38511. , f = file[fi]
  38512. this.debug(pattern, p, f)
  38513. // should be impossible.
  38514. // some invalid regexp stuff in the set.
  38515. if (p === false) return false
  38516. if (p === GLOBSTAR) {
  38517. this.debug('GLOBSTAR', [pattern, p, f])
  38518. // "**"
  38519. // a/**/b/**/c would match the following:
  38520. // a/b/x/y/z/c
  38521. // a/x/y/z/b/c
  38522. // a/b/x/b/x/c
  38523. // a/b/c
  38524. // To do this, take the rest of the pattern after
  38525. // the **, and see if it would match the file remainder.
  38526. // If so, return success.
  38527. // If not, the ** "swallows" a segment, and try again.
  38528. // This is recursively awful.
  38529. //
  38530. // a/**/b/**/c matching a/b/x/y/z/c
  38531. // - a matches a
  38532. // - doublestar
  38533. // - matchOne(b/x/y/z/c, b/**/c)
  38534. // - b matches b
  38535. // - doublestar
  38536. // - matchOne(x/y/z/c, c) -> no
  38537. // - matchOne(y/z/c, c) -> no
  38538. // - matchOne(z/c, c) -> no
  38539. // - matchOne(c, c) yes, hit
  38540. var fr = fi
  38541. , pr = pi + 1
  38542. if (pr === pl) {
  38543. this.debug('** at the end')
  38544. // a ** at the end will just swallow the rest.
  38545. // We have found a match.
  38546. // however, it will not swallow /.x, unless
  38547. // options.dot is set.
  38548. // . and .. are *never* matched by **, for explosively
  38549. // exponential reasons.
  38550. for ( ; fi < fl; fi ++) {
  38551. if (file[fi] === "." || file[fi] === ".." ||
  38552. (!options.dot && file[fi].charAt(0) === ".")) return false
  38553. }
  38554. return true
  38555. }
  38556. // ok, let's see if we can swallow whatever we can.
  38557. WHILE: while (fr < fl) {
  38558. var swallowee = file[fr]
  38559. this.debug('\nglobstar while',
  38560. file, fr, pattern, pr, swallowee)
  38561. // XXX remove this slice. Just pass the start index.
  38562. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  38563. this.debug('globstar found match!', fr, fl, swallowee)
  38564. // found a match.
  38565. return true
  38566. } else {
  38567. // can't swallow "." or ".." ever.
  38568. // can only swallow ".foo" when explicitly asked.
  38569. if (swallowee === "." || swallowee === ".." ||
  38570. (!options.dot && swallowee.charAt(0) === ".")) {
  38571. this.debug("dot detected!", file, fr, pattern, pr)
  38572. break WHILE
  38573. }
  38574. // ** swallows a segment, and continue.
  38575. this.debug('globstar swallow a segment, and continue')
  38576. fr ++
  38577. }
  38578. }
  38579. // no match was found.
  38580. // However, in partial mode, we can't say this is necessarily over.
  38581. // If there's more *pattern* left, then
  38582. if (partial) {
  38583. // ran out of file
  38584. this.debug("\n>>> no match, partial?", file, fr, pattern, pr)
  38585. if (fr === fl) return true
  38586. }
  38587. return false
  38588. }
  38589. // something other than **
  38590. // non-magic patterns just have to match exactly
  38591. // patterns with magic have been turned into regexps.
  38592. var hit
  38593. if (typeof p === "string") {
  38594. if (options.nocase) {
  38595. hit = f.toLowerCase() === p.toLowerCase()
  38596. } else {
  38597. hit = f === p
  38598. }
  38599. this.debug("string match", p, f, hit)
  38600. } else {
  38601. hit = f.match(p)
  38602. this.debug("pattern match", p, f, hit)
  38603. }
  38604. if (!hit) return false
  38605. }
  38606. // Note: ending in / means that we'll get a final ""
  38607. // at the end of the pattern. This can only match a
  38608. // corresponding "" at the end of the file.
  38609. // If the file ends in /, then it can only match a
  38610. // a pattern that ends in /, unless the pattern just
  38611. // doesn't have any more for it. But, a/b/ should *not*
  38612. // match "a/b/*", even though "" matches against the
  38613. // [^/]*? pattern, except in partial mode, where it might
  38614. // simply not be reached yet.
  38615. // However, a/b/ should still satisfy a/*
  38616. // now either we fell off the end of the pattern, or we're done.
  38617. if (fi === fl && pi === pl) {
  38618. // ran out of pattern and filename at the same time.
  38619. // an exact hit!
  38620. return true
  38621. } else if (fi === fl) {
  38622. // ran out of file, but still had pattern left.
  38623. // this is ok if we're doing the match as part of
  38624. // a glob fs traversal.
  38625. return partial
  38626. } else if (pi === pl) {
  38627. // ran out of pattern, still have file left.
  38628. // this is only acceptable if we're on the very last
  38629. // empty segment of a file with a trailing slash.
  38630. // a/* should match a/b/
  38631. var emptyFileEnd = (fi === fl - 1) && (file[fi] === "")
  38632. return emptyFileEnd
  38633. }
  38634. // should be unreachable.
  38635. throw new Error("wtf?")
  38636. }
  38637. // replace stuff like \* with *
  38638. function globUnescape (s) {
  38639. return s.replace(/\\(.)/g, "$1")
  38640. }
  38641. function regExpEscape (s) {
  38642. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
  38643. }
  38644. }).call(this,require('_process'))
  38645. },{"_process":200,"brace-expansion":431}],431:[function(require,module,exports){
  38646. var concatMap = require('concat-map');
  38647. var balanced = require('balanced-match');
  38648. module.exports = expandTop;
  38649. var escSlash = '\0SLASH'+Math.random()+'\0';
  38650. var escOpen = '\0OPEN'+Math.random()+'\0';
  38651. var escClose = '\0CLOSE'+Math.random()+'\0';
  38652. var escComma = '\0COMMA'+Math.random()+'\0';
  38653. var escPeriod = '\0PERIOD'+Math.random()+'\0';
  38654. function numeric(str) {
  38655. return parseInt(str, 10) == str
  38656. ? parseInt(str, 10)
  38657. : str.charCodeAt(0);
  38658. }
  38659. function escapeBraces(str) {
  38660. return str.split('\\\\').join(escSlash)
  38661. .split('\\{').join(escOpen)
  38662. .split('\\}').join(escClose)
  38663. .split('\\,').join(escComma)
  38664. .split('\\.').join(escPeriod);
  38665. }
  38666. function unescapeBraces(str) {
  38667. return str.split(escSlash).join('\\')
  38668. .split(escOpen).join('{')
  38669. .split(escClose).join('}')
  38670. .split(escComma).join(',')
  38671. .split(escPeriod).join('.');
  38672. }
  38673. // Basically just str.split(","), but handling cases
  38674. // where we have nested braced sections, which should be
  38675. // treated as individual members, like {a,{b,c},d}
  38676. function parseCommaParts(str) {
  38677. if (!str)
  38678. return [''];
  38679. var parts = [];
  38680. var m = balanced('{', '}', str);
  38681. if (!m)
  38682. return str.split(',');
  38683. var pre = m.pre;
  38684. var body = m.body;
  38685. var post = m.post;
  38686. var p = pre.split(',');
  38687. p[p.length-1] += '{' + body + '}';
  38688. var postParts = parseCommaParts(post);
  38689. if (post.length) {
  38690. p[p.length-1] += postParts.shift();
  38691. p.push.apply(p, postParts);
  38692. }
  38693. parts.push.apply(parts, p);
  38694. return parts;
  38695. }
  38696. function expandTop(str) {
  38697. if (!str)
  38698. return [];
  38699. return expand(escapeBraces(str), true).map(unescapeBraces);
  38700. }
  38701. function identity(e) {
  38702. return e;
  38703. }
  38704. function embrace(str) {
  38705. return '{' + str + '}';
  38706. }
  38707. function isPadded(el) {
  38708. return /^-?0\d/.test(el);
  38709. }
  38710. function lte(i, y) {
  38711. return i <= y;
  38712. }
  38713. function gte(i, y) {
  38714. return i >= y;
  38715. }
  38716. function expand(str, isTop) {
  38717. var expansions = [];
  38718. var m = balanced('{', '}', str);
  38719. if (!m || /\$$/.test(m.pre)) return [str];
  38720. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  38721. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  38722. var isSequence = isNumericSequence || isAlphaSequence;
  38723. var isOptions = /^(.*,)+(.+)?$/.test(m.body);
  38724. if (!isSequence && !isOptions) {
  38725. // {a},b}
  38726. if (m.post.match(/,.*}/)) {
  38727. str = m.pre + '{' + m.body + escClose + m.post;
  38728. return expand(str);
  38729. }
  38730. return [str];
  38731. }
  38732. var n;
  38733. if (isSequence) {
  38734. n = m.body.split(/\.\./);
  38735. } else {
  38736. n = parseCommaParts(m.body);
  38737. if (n.length === 1) {
  38738. // x{{a,b}}y ==> x{a}y x{b}y
  38739. n = expand(n[0], false).map(embrace);
  38740. if (n.length === 1) {
  38741. var post = m.post.length
  38742. ? expand(m.post, false)
  38743. : [''];
  38744. return post.map(function(p) {
  38745. return m.pre + n[0] + p;
  38746. });
  38747. }
  38748. }
  38749. }
  38750. // at this point, n is the parts, and we know it's not a comma set
  38751. // with a single entry.
  38752. // no need to expand pre, since it is guaranteed to be free of brace-sets
  38753. var pre = m.pre;
  38754. var post = m.post.length
  38755. ? expand(m.post, false)
  38756. : [''];
  38757. var N;
  38758. if (isSequence) {
  38759. var x = numeric(n[0]);
  38760. var y = numeric(n[1]);
  38761. var width = Math.max(n[0].length, n[1].length)
  38762. var incr = n.length == 3
  38763. ? Math.abs(numeric(n[2]))
  38764. : 1;
  38765. var test = lte;
  38766. var reverse = y < x;
  38767. if (reverse) {
  38768. incr *= -1;
  38769. test = gte;
  38770. }
  38771. var pad = n.some(isPadded);
  38772. N = [];
  38773. for (var i = x; test(i, y); i += incr) {
  38774. var c;
  38775. if (isAlphaSequence) {
  38776. c = String.fromCharCode(i);
  38777. if (c === '\\')
  38778. c = '';
  38779. } else {
  38780. c = String(i);
  38781. if (pad) {
  38782. var need = width - c.length;
  38783. if (need > 0) {
  38784. var z = new Array(need + 1).join('0');
  38785. if (i < 0)
  38786. c = '-' + z + c.slice(1);
  38787. else
  38788. c = z + c;
  38789. }
  38790. }
  38791. }
  38792. N.push(c);
  38793. }
  38794. } else {
  38795. N = concatMap(n, function(el) { return expand(el, false) });
  38796. }
  38797. for (var j = 0; j < N.length; j++) {
  38798. for (var k = 0; k < post.length; k++) {
  38799. var expansion = pre + N[j] + post[k];
  38800. if (!isTop || isSequence || expansion)
  38801. expansions.push(expansion);
  38802. }
  38803. }
  38804. return expansions;
  38805. }
  38806. },{"balanced-match":432,"concat-map":433}],432:[function(require,module,exports){
  38807. module.exports = balanced;
  38808. function balanced(a, b, str) {
  38809. var bal = 0;
  38810. var m = {};
  38811. var ended = false;
  38812. for (var i = 0; i < str.length; i++) {
  38813. if (a == str.substr(i, a.length)) {
  38814. if (!('start' in m)) m.start = i;
  38815. bal++;
  38816. }
  38817. else if (b == str.substr(i, b.length) && 'start' in m) {
  38818. ended = true;
  38819. bal--;
  38820. if (!bal) {
  38821. m.end = i;
  38822. m.pre = str.substr(0, m.start);
  38823. m.body = (m.end - m.start > 1)
  38824. ? str.substring(m.start + a.length, m.end)
  38825. : '';
  38826. m.post = str.slice(m.end + b.length);
  38827. return m;
  38828. }
  38829. }
  38830. }
  38831. // if we opened more than we closed, find the one we closed
  38832. if (bal && ended) {
  38833. var start = m.start + a.length;
  38834. m = balanced(a, b, str.substr(start));
  38835. if (m) {
  38836. m.start += start;
  38837. m.end += start;
  38838. m.pre = str.slice(0, start) + m.pre;
  38839. }
  38840. return m;
  38841. }
  38842. }
  38843. },{}],433:[function(require,module,exports){
  38844. module.exports = function (xs, fn) {
  38845. var res = [];
  38846. for (var i = 0; i < xs.length; i++) {
  38847. var x = fn(xs[i], i);
  38848. if (isArray(x)) res.push.apply(res, x);
  38849. else res.push(x);
  38850. }
  38851. return res;
  38852. };
  38853. var isArray = Array.isArray || function (xs) {
  38854. return Object.prototype.toString.call(xs) === '[object Array]';
  38855. };
  38856. },{}],434:[function(require,module,exports){
  38857. (function (process){
  38858. 'use strict';
  38859. function posix(path) {
  38860. return path.charAt(0) === '/';
  38861. };
  38862. function win32(path) {
  38863. // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
  38864. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
  38865. var result = splitDeviceRe.exec(path);
  38866. var device = result[1] || '';
  38867. var isUnc = !!device && device.charAt(1) !== ':';
  38868. // UNC paths are always absolute
  38869. return !!result[2] || isUnc;
  38870. };
  38871. module.exports = process.platform === 'win32' ? win32 : posix;
  38872. module.exports.posix = posix;
  38873. module.exports.win32 = win32;
  38874. }).call(this,require('_process'))
  38875. },{"_process":200}],435:[function(require,module,exports){
  38876. "use strict";
  38877. var originalObject = Object;
  38878. var originalDefProp = Object.defineProperty;
  38879. var originalCreate = Object.create;
  38880. function defProp(obj, name, value) {
  38881. if (originalDefProp) try {
  38882. originalDefProp.call(originalObject, obj, name, { value: value });
  38883. } catch (definePropertyIsBrokenInIE8) {
  38884. obj[name] = value;
  38885. } else {
  38886. obj[name] = value;
  38887. }
  38888. }
  38889. // For functions that will be invoked using .call or .apply, we need to
  38890. // define those methods on the function objects themselves, rather than
  38891. // inheriting them from Function.prototype, so that a malicious or clumsy
  38892. // third party cannot interfere with the functionality of this module by
  38893. // redefining Function.prototype.call or .apply.
  38894. function makeSafeToCall(fun) {
  38895. if (fun) {
  38896. defProp(fun, "call", fun.call);
  38897. defProp(fun, "apply", fun.apply);
  38898. }
  38899. return fun;
  38900. }
  38901. makeSafeToCall(originalDefProp);
  38902. makeSafeToCall(originalCreate);
  38903. var hasOwn = makeSafeToCall(Object.prototype.hasOwnProperty);
  38904. var numToStr = makeSafeToCall(Number.prototype.toString);
  38905. var strSlice = makeSafeToCall(String.prototype.slice);
  38906. var cloner = function(){};
  38907. function create(prototype) {
  38908. if (originalCreate) {
  38909. return originalCreate.call(originalObject, prototype);
  38910. }
  38911. cloner.prototype = prototype || null;
  38912. return new cloner;
  38913. }
  38914. var rand = Math.random;
  38915. var uniqueKeys = create(null);
  38916. function makeUniqueKey() {
  38917. // Collisions are highly unlikely, but this module is in the business of
  38918. // making guarantees rather than safe bets.
  38919. do var uniqueKey = internString(strSlice.call(numToStr.call(rand(), 36), 2));
  38920. while (hasOwn.call(uniqueKeys, uniqueKey));
  38921. return uniqueKeys[uniqueKey] = uniqueKey;
  38922. }
  38923. function internString(str) {
  38924. var obj = {};
  38925. obj[str] = true;
  38926. return Object.keys(obj)[0];
  38927. }
  38928. // External users might find this function useful, but it is not necessary
  38929. // for the typical use of this module.
  38930. defProp(exports, "makeUniqueKey", makeUniqueKey);
  38931. // Object.getOwnPropertyNames is the only way to enumerate non-enumerable
  38932. // properties, so if we wrap it to ignore our secret keys, there should be
  38933. // no way (except guessing) to access those properties.
  38934. var originalGetOPNs = Object.getOwnPropertyNames;
  38935. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  38936. for (var names = originalGetOPNs(object),
  38937. src = 0,
  38938. dst = 0,
  38939. len = names.length;
  38940. src < len;
  38941. ++src) {
  38942. if (!hasOwn.call(uniqueKeys, names[src])) {
  38943. if (src > dst) {
  38944. names[dst] = names[src];
  38945. }
  38946. ++dst;
  38947. }
  38948. }
  38949. names.length = dst;
  38950. return names;
  38951. };
  38952. function defaultCreatorFn(object) {
  38953. return create(null);
  38954. }
  38955. function makeAccessor(secretCreatorFn) {
  38956. var brand = makeUniqueKey();
  38957. var passkey = create(null);
  38958. secretCreatorFn = secretCreatorFn || defaultCreatorFn;
  38959. function register(object) {
  38960. var secret; // Created lazily.
  38961. function vault(key, forget) {
  38962. // Only code that has access to the passkey can retrieve (or forget)
  38963. // the secret object.
  38964. if (key === passkey) {
  38965. return forget
  38966. ? secret = null
  38967. : secret || (secret = secretCreatorFn(object));
  38968. }
  38969. }
  38970. defProp(object, brand, vault);
  38971. }
  38972. function accessor(object) {
  38973. if (!hasOwn.call(object, brand))
  38974. register(object);
  38975. return object[brand](passkey);
  38976. }
  38977. accessor.forget = function(object) {
  38978. if (hasOwn.call(object, brand))
  38979. object[brand](passkey, true);
  38980. };
  38981. return accessor;
  38982. }
  38983. defProp(exports, "makeAccessor", makeAccessor);
  38984. },{}],436:[function(require,module,exports){
  38985. /**
  38986. * Copyright (c) 2014, Facebook, Inc.
  38987. * All rights reserved.
  38988. *
  38989. * This source code is licensed under the BSD-style license found in the
  38990. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  38991. * additional grant of patent rights can be found in the PATENTS file in
  38992. * the same directory.
  38993. */
  38994. var assert = require("assert");
  38995. var types = require("recast").types;
  38996. var isArray = types.builtInTypes.array;
  38997. var b = types.builders;
  38998. var n = types.namedTypes;
  38999. var leap = require("./leap");
  39000. var meta = require("./meta");
  39001. var util = require("./util");
  39002. var runtimeProperty = util.runtimeProperty;
  39003. var hasOwn = Object.prototype.hasOwnProperty;
  39004. function Emitter(contextId) {
  39005. assert.ok(this instanceof Emitter);
  39006. n.Identifier.assert(contextId);
  39007. Object.defineProperties(this, {
  39008. // In order to make sure the context object does not collide with
  39009. // anything in the local scope, we might have to rename it, so we
  39010. // refer to it symbolically instead of just assuming that it will be
  39011. // called "context".
  39012. contextId: { value: contextId },
  39013. // An append-only list of Statements that grows each time this.emit is
  39014. // called.
  39015. listing: { value: [] },
  39016. // A sparse array whose keys correspond to locations in this.listing
  39017. // that have been marked as branch/jump targets.
  39018. marked: { value: [true] },
  39019. // The last location will be marked when this.getDispatchLoop is
  39020. // called.
  39021. finalLoc: { value: loc() },
  39022. // A list of all leap.TryEntry statements emitted.
  39023. tryEntries: { value: [] }
  39024. });
  39025. // The .leapManager property needs to be defined by a separate
  39026. // defineProperties call so that .finalLoc will be visible to the
  39027. // leap.LeapManager constructor.
  39028. Object.defineProperties(this, {
  39029. // Each time we evaluate the body of a loop, we tell this.leapManager
  39030. // to enter a nested loop context that determines the meaning of break
  39031. // and continue statements therein.
  39032. leapManager: { value: new leap.LeapManager(this) }
  39033. });
  39034. }
  39035. var Ep = Emitter.prototype;
  39036. exports.Emitter = Emitter;
  39037. // Offsets into this.listing that could be used as targets for branches or
  39038. // jumps are represented as numeric Literal nodes. This representation has
  39039. // the amazingly convenient benefit of allowing the exact value of the
  39040. // location to be determined at any time, even after generating code that
  39041. // refers to the location.
  39042. function loc() {
  39043. return b.literal(-1);
  39044. }
  39045. // Sets the exact value of the given location to the offset of the next
  39046. // Statement emitted.
  39047. Ep.mark = function(loc) {
  39048. n.Literal.assert(loc);
  39049. var index = this.listing.length;
  39050. if (loc.value === -1) {
  39051. loc.value = index;
  39052. } else {
  39053. // Locations can be marked redundantly, but their values cannot change
  39054. // once set the first time.
  39055. assert.strictEqual(loc.value, index);
  39056. }
  39057. this.marked[index] = true;
  39058. return loc;
  39059. };
  39060. Ep.emit = function(node) {
  39061. if (n.Expression.check(node))
  39062. node = b.expressionStatement(node);
  39063. n.Statement.assert(node);
  39064. this.listing.push(node);
  39065. };
  39066. // Shorthand for emitting assignment statements. This will come in handy
  39067. // for assignments to temporary variables.
  39068. Ep.emitAssign = function(lhs, rhs) {
  39069. this.emit(this.assign(lhs, rhs));
  39070. return lhs;
  39071. };
  39072. // Shorthand for an assignment statement.
  39073. Ep.assign = function(lhs, rhs) {
  39074. return b.expressionStatement(
  39075. b.assignmentExpression("=", lhs, rhs));
  39076. };
  39077. // Convenience function for generating expressions like context.next,
  39078. // context.sent, and context.rval.
  39079. Ep.contextProperty = function(name, computed) {
  39080. return b.memberExpression(
  39081. this.contextId,
  39082. computed ? b.literal(name) : b.identifier(name),
  39083. !!computed
  39084. );
  39085. };
  39086. var volatileContextPropertyNames = {
  39087. prev: true,
  39088. next: true,
  39089. sent: true,
  39090. rval: true
  39091. };
  39092. // A "volatile" context property is a MemberExpression like context.sent
  39093. // that should probably be stored in a temporary variable when there's a
  39094. // possibility the property will get overwritten.
  39095. Ep.isVolatileContextProperty = function(expr) {
  39096. if (n.MemberExpression.check(expr)) {
  39097. if (expr.computed) {
  39098. // If it's a computed property such as context[couldBeAnything],
  39099. // assume the worst in terms of volatility.
  39100. return true;
  39101. }
  39102. if (n.Identifier.check(expr.object) &&
  39103. n.Identifier.check(expr.property) &&
  39104. expr.object.name === this.contextId.name &&
  39105. hasOwn.call(volatileContextPropertyNames,
  39106. expr.property.name)) {
  39107. return true;
  39108. }
  39109. }
  39110. return false;
  39111. };
  39112. // Shorthand for setting context.rval and jumping to `context.stop()`.
  39113. Ep.stop = function(rval) {
  39114. if (rval) {
  39115. this.setReturnValue(rval);
  39116. }
  39117. this.jump(this.finalLoc);
  39118. };
  39119. Ep.setReturnValue = function(valuePath) {
  39120. n.Expression.assert(valuePath.value);
  39121. this.emitAssign(
  39122. this.contextProperty("rval"),
  39123. this.explodeExpression(valuePath)
  39124. );
  39125. };
  39126. Ep.clearPendingException = function(tryLoc, assignee) {
  39127. n.Literal.assert(tryLoc);
  39128. var catchCall = b.callExpression(
  39129. this.contextProperty("catch", true),
  39130. [tryLoc]
  39131. );
  39132. if (assignee) {
  39133. this.emitAssign(assignee, catchCall);
  39134. } else {
  39135. this.emit(catchCall);
  39136. }
  39137. };
  39138. // Emits code for an unconditional jump to the given location, even if the
  39139. // exact value of the location is not yet known.
  39140. Ep.jump = function(toLoc) {
  39141. this.emitAssign(this.contextProperty("next"), toLoc);
  39142. this.emit(b.breakStatement());
  39143. };
  39144. // Conditional jump.
  39145. Ep.jumpIf = function(test, toLoc) {
  39146. n.Expression.assert(test);
  39147. n.Literal.assert(toLoc);
  39148. this.emit(b.ifStatement(
  39149. test,
  39150. b.blockStatement([
  39151. this.assign(this.contextProperty("next"), toLoc),
  39152. b.breakStatement()
  39153. ])
  39154. ));
  39155. };
  39156. // Conditional jump, with the condition negated.
  39157. Ep.jumpIfNot = function(test, toLoc) {
  39158. n.Expression.assert(test);
  39159. n.Literal.assert(toLoc);
  39160. var negatedTest;
  39161. if (n.UnaryExpression.check(test) &&
  39162. test.operator === "!") {
  39163. // Avoid double negation.
  39164. negatedTest = test.argument;
  39165. } else {
  39166. negatedTest = b.unaryExpression("!", test);
  39167. }
  39168. this.emit(b.ifStatement(
  39169. negatedTest,
  39170. b.blockStatement([
  39171. this.assign(this.contextProperty("next"), toLoc),
  39172. b.breakStatement()
  39173. ])
  39174. ));
  39175. };
  39176. // Returns a unique MemberExpression that can be used to store and
  39177. // retrieve temporary values. Since the object of the member expression is
  39178. // the context object, which is presumed to coexist peacefully with all
  39179. // other local variables, and since we just increment `nextTempId`
  39180. // monotonically, uniqueness is assured.
  39181. var nextTempId = 0;
  39182. Ep.makeTempVar = function() {
  39183. return this.contextProperty("t" + nextTempId++);
  39184. };
  39185. Ep.getContextFunction = function(id) {
  39186. return b.functionExpression(
  39187. id || null/*Anonymous*/,
  39188. [this.contextId],
  39189. b.blockStatement([this.getDispatchLoop()]),
  39190. false, // Not a generator anymore!
  39191. false // Nor an expression.
  39192. );
  39193. };
  39194. // Turns this.listing into a loop of the form
  39195. //
  39196. // while (1) switch (context.next) {
  39197. // case 0:
  39198. // ...
  39199. // case n:
  39200. // return context.stop();
  39201. // }
  39202. //
  39203. // Each marked location in this.listing will correspond to one generated
  39204. // case statement.
  39205. Ep.getDispatchLoop = function() {
  39206. var self = this;
  39207. var cases = [];
  39208. var current;
  39209. // If we encounter a break, continue, or return statement in a switch
  39210. // case, we can skip the rest of the statements until the next case.
  39211. var alreadyEnded = false;
  39212. self.listing.forEach(function(stmt, i) {
  39213. if (self.marked.hasOwnProperty(i)) {
  39214. cases.push(b.switchCase(
  39215. b.literal(i),
  39216. current = []));
  39217. alreadyEnded = false;
  39218. }
  39219. if (!alreadyEnded) {
  39220. current.push(stmt);
  39221. if (isSwitchCaseEnder(stmt))
  39222. alreadyEnded = true;
  39223. }
  39224. });
  39225. // Now that we know how many statements there will be in this.listing,
  39226. // we can finally resolve this.finalLoc.value.
  39227. this.finalLoc.value = this.listing.length;
  39228. cases.push(
  39229. b.switchCase(this.finalLoc, [
  39230. // Intentionally fall through to the "end" case...
  39231. ]),
  39232. // So that the runtime can jump to the final location without having
  39233. // to know its offset, we provide the "end" case as a synonym.
  39234. b.switchCase(b.literal("end"), [
  39235. // This will check/clear both context.thrown and context.rval.
  39236. b.returnStatement(
  39237. b.callExpression(this.contextProperty("stop"), [])
  39238. )
  39239. ])
  39240. );
  39241. return b.whileStatement(
  39242. b.literal(1),
  39243. b.switchStatement(
  39244. b.assignmentExpression(
  39245. "=",
  39246. this.contextProperty("prev"),
  39247. this.contextProperty("next")
  39248. ),
  39249. cases
  39250. )
  39251. );
  39252. };
  39253. // See comment above re: alreadyEnded.
  39254. function isSwitchCaseEnder(stmt) {
  39255. return n.BreakStatement.check(stmt)
  39256. || n.ContinueStatement.check(stmt)
  39257. || n.ReturnStatement.check(stmt)
  39258. || n.ThrowStatement.check(stmt);
  39259. }
  39260. Ep.getTryLocsList = function() {
  39261. if (this.tryEntries.length === 0) {
  39262. // To avoid adding a needless [] to the majority of runtime.wrap
  39263. // argument lists, force the caller to handle this case specially.
  39264. return null;
  39265. }
  39266. var lastLocValue = 0;
  39267. return b.arrayExpression(
  39268. this.tryEntries.map(function(tryEntry) {
  39269. var thisLocValue = tryEntry.firstLoc.value;
  39270. assert.ok(thisLocValue >= lastLocValue, "try entries out of order");
  39271. lastLocValue = thisLocValue;
  39272. var ce = tryEntry.catchEntry;
  39273. var fe = tryEntry.finallyEntry;
  39274. var locs = [
  39275. tryEntry.firstLoc,
  39276. // The null here makes a hole in the array.
  39277. ce ? ce.firstLoc : null
  39278. ];
  39279. if (fe) {
  39280. locs[2] = fe.firstLoc;
  39281. locs[3] = fe.afterLoc;
  39282. }
  39283. return b.arrayExpression(locs);
  39284. })
  39285. );
  39286. };
  39287. // All side effects must be realized in order.
  39288. // If any subexpression harbors a leap, all subexpressions must be
  39289. // neutered of side effects.
  39290. // No destructive modification of AST nodes.
  39291. Ep.explode = function(path, ignoreResult) {
  39292. assert.ok(path instanceof types.NodePath);
  39293. var node = path.value;
  39294. var self = this;
  39295. n.Node.assert(node);
  39296. if (n.Statement.check(node))
  39297. return self.explodeStatement(path);
  39298. if (n.Expression.check(node))
  39299. return self.explodeExpression(path, ignoreResult);
  39300. if (n.Declaration.check(node))
  39301. throw getDeclError(node);
  39302. switch (node.type) {
  39303. case "Program":
  39304. return path.get("body").map(
  39305. self.explodeStatement,
  39306. self
  39307. );
  39308. case "VariableDeclarator":
  39309. throw getDeclError(node);
  39310. // These node types should be handled by their parent nodes
  39311. // (ObjectExpression, SwitchStatement, and TryStatement, respectively).
  39312. case "Property":
  39313. case "SwitchCase":
  39314. case "CatchClause":
  39315. throw new Error(
  39316. node.type + " nodes should be handled by their parents");
  39317. default:
  39318. throw new Error(
  39319. "unknown Node of type " +
  39320. JSON.stringify(node.type));
  39321. }
  39322. };
  39323. function getDeclError(node) {
  39324. return new Error(
  39325. "all declarations should have been transformed into " +
  39326. "assignments before the Exploder began its work: " +
  39327. JSON.stringify(node));
  39328. }
  39329. Ep.explodeStatement = function(path, labelId) {
  39330. assert.ok(path instanceof types.NodePath);
  39331. var stmt = path.value;
  39332. var self = this;
  39333. n.Statement.assert(stmt);
  39334. if (labelId) {
  39335. n.Identifier.assert(labelId);
  39336. } else {
  39337. labelId = null;
  39338. }
  39339. // Explode BlockStatement nodes even if they do not contain a yield,
  39340. // because we don't want or need the curly braces.
  39341. if (n.BlockStatement.check(stmt)) {
  39342. return path.get("body").each(
  39343. self.explodeStatement,
  39344. self
  39345. );
  39346. }
  39347. if (!meta.containsLeap(stmt)) {
  39348. // Technically we should be able to avoid emitting the statement
  39349. // altogether if !meta.hasSideEffects(stmt), but that leads to
  39350. // confusing generated code (for instance, `while (true) {}` just
  39351. // disappears) and is probably a more appropriate job for a dedicated
  39352. // dead code elimination pass.
  39353. self.emit(stmt);
  39354. return;
  39355. }
  39356. switch (stmt.type) {
  39357. case "ExpressionStatement":
  39358. self.explodeExpression(path.get("expression"), true);
  39359. break;
  39360. case "LabeledStatement":
  39361. var after = loc();
  39362. // Did you know you can break from any labeled block statement or
  39363. // control structure? Well, you can! Note: when a labeled loop is
  39364. // encountered, the leap.LabeledEntry created here will immediately
  39365. // enclose a leap.LoopEntry on the leap manager's stack, and both
  39366. // entries will have the same label. Though this works just fine, it
  39367. // may seem a bit redundant. In theory, we could check here to
  39368. // determine if stmt knows how to handle its own label; for example,
  39369. // stmt happens to be a WhileStatement and so we know it's going to
  39370. // establish its own LoopEntry when we explode it (below). Then this
  39371. // LabeledEntry would be unnecessary. Alternatively, we might be
  39372. // tempted not to pass stmt.label down into self.explodeStatement,
  39373. // because we've handled the label here, but that's a mistake because
  39374. // labeled loops may contain labeled continue statements, which is not
  39375. // something we can handle in this generic case. All in all, I think a
  39376. // little redundancy greatly simplifies the logic of this case, since
  39377. // it's clear that we handle all possible LabeledStatements correctly
  39378. // here, regardless of whether they interact with the leap manager
  39379. // themselves. Also remember that labels and break/continue-to-label
  39380. // statements are rare, and all of this logic happens at transform
  39381. // time, so it has no additional runtime cost.
  39382. self.leapManager.withEntry(
  39383. new leap.LabeledEntry(after, stmt.label),
  39384. function() {
  39385. self.explodeStatement(path.get("body"), stmt.label);
  39386. }
  39387. );
  39388. self.mark(after);
  39389. break;
  39390. case "WhileStatement":
  39391. var before = loc();
  39392. var after = loc();
  39393. self.mark(before);
  39394. self.jumpIfNot(self.explodeExpression(path.get("test")), after);
  39395. self.leapManager.withEntry(
  39396. new leap.LoopEntry(after, before, labelId),
  39397. function() { self.explodeStatement(path.get("body")); }
  39398. );
  39399. self.jump(before);
  39400. self.mark(after);
  39401. break;
  39402. case "DoWhileStatement":
  39403. var first = loc();
  39404. var test = loc();
  39405. var after = loc();
  39406. self.mark(first);
  39407. self.leapManager.withEntry(
  39408. new leap.LoopEntry(after, test, labelId),
  39409. function() { self.explode(path.get("body")); }
  39410. );
  39411. self.mark(test);
  39412. self.jumpIf(self.explodeExpression(path.get("test")), first);
  39413. self.mark(after);
  39414. break;
  39415. case "ForStatement":
  39416. var head = loc();
  39417. var update = loc();
  39418. var after = loc();
  39419. if (stmt.init) {
  39420. // We pass true here to indicate that if stmt.init is an expression
  39421. // then we do not care about its result.
  39422. self.explode(path.get("init"), true);
  39423. }
  39424. self.mark(head);
  39425. if (stmt.test) {
  39426. self.jumpIfNot(self.explodeExpression(path.get("test")), after);
  39427. } else {
  39428. // No test means continue unconditionally.
  39429. }
  39430. self.leapManager.withEntry(
  39431. new leap.LoopEntry(after, update, labelId),
  39432. function() { self.explodeStatement(path.get("body")); }
  39433. );
  39434. self.mark(update);
  39435. if (stmt.update) {
  39436. // We pass true here to indicate that if stmt.update is an
  39437. // expression then we do not care about its result.
  39438. self.explode(path.get("update"), true);
  39439. }
  39440. self.jump(head);
  39441. self.mark(after);
  39442. break;
  39443. case "ForInStatement":
  39444. n.Identifier.assert(stmt.left);
  39445. var head = loc();
  39446. var after = loc();
  39447. var keyIterNextFn = self.makeTempVar();
  39448. self.emitAssign(
  39449. keyIterNextFn,
  39450. b.callExpression(
  39451. runtimeProperty("keys"),
  39452. [self.explodeExpression(path.get("right"))]
  39453. )
  39454. );
  39455. self.mark(head);
  39456. var keyInfoTmpVar = self.makeTempVar();
  39457. self.jumpIf(
  39458. b.memberExpression(
  39459. b.assignmentExpression(
  39460. "=",
  39461. keyInfoTmpVar,
  39462. b.callExpression(keyIterNextFn, [])
  39463. ),
  39464. b.identifier("done"),
  39465. false
  39466. ),
  39467. after
  39468. );
  39469. self.emitAssign(
  39470. stmt.left,
  39471. b.memberExpression(
  39472. keyInfoTmpVar,
  39473. b.identifier("value"),
  39474. false
  39475. )
  39476. );
  39477. self.leapManager.withEntry(
  39478. new leap.LoopEntry(after, head, labelId),
  39479. function() { self.explodeStatement(path.get("body")); }
  39480. );
  39481. self.jump(head);
  39482. self.mark(after);
  39483. break;
  39484. case "BreakStatement":
  39485. self.emitAbruptCompletion({
  39486. type: "break",
  39487. target: self.leapManager.getBreakLoc(stmt.label)
  39488. });
  39489. break;
  39490. case "ContinueStatement":
  39491. self.emitAbruptCompletion({
  39492. type: "continue",
  39493. target: self.leapManager.getContinueLoc(stmt.label)
  39494. });
  39495. break;
  39496. case "SwitchStatement":
  39497. // Always save the discriminant into a temporary variable in case the
  39498. // test expressions overwrite values like context.sent.
  39499. var disc = self.emitAssign(
  39500. self.makeTempVar(),
  39501. self.explodeExpression(path.get("discriminant"))
  39502. );
  39503. var after = loc();
  39504. var defaultLoc = loc();
  39505. var condition = defaultLoc;
  39506. var caseLocs = [];
  39507. // If there are no cases, .cases might be undefined.
  39508. var cases = stmt.cases || [];
  39509. for (var i = cases.length - 1; i >= 0; --i) {
  39510. var c = cases[i];
  39511. n.SwitchCase.assert(c);
  39512. if (c.test) {
  39513. condition = b.conditionalExpression(
  39514. b.binaryExpression("===", disc, c.test),
  39515. caseLocs[i] = loc(),
  39516. condition
  39517. );
  39518. } else {
  39519. caseLocs[i] = defaultLoc;
  39520. }
  39521. }
  39522. self.jump(self.explodeExpression(
  39523. new types.NodePath(condition, path, "discriminant")
  39524. ));
  39525. self.leapManager.withEntry(
  39526. new leap.SwitchEntry(after),
  39527. function() {
  39528. path.get("cases").each(function(casePath) {
  39529. var c = casePath.value;
  39530. var i = casePath.name;
  39531. self.mark(caseLocs[i]);
  39532. casePath.get("consequent").each(
  39533. self.explodeStatement,
  39534. self
  39535. );
  39536. });
  39537. }
  39538. );
  39539. self.mark(after);
  39540. if (defaultLoc.value === -1) {
  39541. self.mark(defaultLoc);
  39542. assert.strictEqual(after.value, defaultLoc.value);
  39543. }
  39544. break;
  39545. case "IfStatement":
  39546. var elseLoc = stmt.alternate && loc();
  39547. var after = loc();
  39548. self.jumpIfNot(
  39549. self.explodeExpression(path.get("test")),
  39550. elseLoc || after
  39551. );
  39552. self.explodeStatement(path.get("consequent"));
  39553. if (elseLoc) {
  39554. self.jump(after);
  39555. self.mark(elseLoc);
  39556. self.explodeStatement(path.get("alternate"));
  39557. }
  39558. self.mark(after);
  39559. break;
  39560. case "ReturnStatement":
  39561. self.emitAbruptCompletion({
  39562. type: "return",
  39563. value: self.explodeExpression(path.get("argument"))
  39564. });
  39565. break;
  39566. case "WithStatement":
  39567. throw new Error(
  39568. node.type + " not supported in generator functions.");
  39569. case "TryStatement":
  39570. var after = loc();
  39571. var handler = stmt.handler;
  39572. if (!handler && stmt.handlers) {
  39573. handler = stmt.handlers[0] || null;
  39574. }
  39575. var catchLoc = handler && loc();
  39576. var catchEntry = catchLoc && new leap.CatchEntry(
  39577. catchLoc,
  39578. handler.param
  39579. );
  39580. var finallyLoc = stmt.finalizer && loc();
  39581. var finallyEntry = finallyLoc &&
  39582. new leap.FinallyEntry(finallyLoc, after);
  39583. var tryEntry = new leap.TryEntry(
  39584. self.getUnmarkedCurrentLoc(),
  39585. catchEntry,
  39586. finallyEntry
  39587. );
  39588. self.tryEntries.push(tryEntry);
  39589. self.updateContextPrevLoc(tryEntry.firstLoc);
  39590. self.leapManager.withEntry(tryEntry, function() {
  39591. self.explodeStatement(path.get("block"));
  39592. if (catchLoc) {
  39593. if (finallyLoc) {
  39594. // If we have both a catch block and a finally block, then
  39595. // because we emit the catch block first, we need to jump over
  39596. // it to the finally block.
  39597. self.jump(finallyLoc);
  39598. } else {
  39599. // If there is no finally block, then we need to jump over the
  39600. // catch block to the fall-through location.
  39601. self.jump(after);
  39602. }
  39603. self.updateContextPrevLoc(self.mark(catchLoc));
  39604. var bodyPath = path.get("handler", "body");
  39605. var safeParam = self.makeTempVar();
  39606. self.clearPendingException(tryEntry.firstLoc, safeParam);
  39607. var catchScope = bodyPath.scope;
  39608. var catchParamName = handler.param.name;
  39609. n.CatchClause.assert(catchScope.node);
  39610. assert.strictEqual(catchScope.lookup(catchParamName), catchScope);
  39611. types.visit(bodyPath, {
  39612. visitIdentifier: function(path) {
  39613. if (util.isReference(path, catchParamName) &&
  39614. path.scope.lookup(catchParamName) === catchScope) {
  39615. return safeParam;
  39616. }
  39617. this.traverse(path);
  39618. },
  39619. visitFunction: function(path) {
  39620. if (path.scope.declares(catchParamName)) {
  39621. // Don't descend into nested scopes that shadow the catch
  39622. // parameter with their own declarations. This isn't
  39623. // logically necessary because of the path.scope.lookup we
  39624. // do in visitIdentifier, but it saves time.
  39625. return false;
  39626. }
  39627. this.traverse(path);
  39628. }
  39629. });
  39630. self.leapManager.withEntry(catchEntry, function() {
  39631. self.explodeStatement(bodyPath);
  39632. });
  39633. }
  39634. if (finallyLoc) {
  39635. self.updateContextPrevLoc(self.mark(finallyLoc));
  39636. self.leapManager.withEntry(finallyEntry, function() {
  39637. self.explodeStatement(path.get("finalizer"));
  39638. });
  39639. self.emit(b.returnStatement(b.callExpression(
  39640. self.contextProperty("finish"),
  39641. [finallyEntry.firstLoc]
  39642. )));
  39643. }
  39644. });
  39645. self.mark(after);
  39646. break;
  39647. case "ThrowStatement":
  39648. self.emit(b.throwStatement(
  39649. self.explodeExpression(path.get("argument"))
  39650. ));
  39651. break;
  39652. default:
  39653. throw new Error(
  39654. "unknown Statement of type " +
  39655. JSON.stringify(stmt.type));
  39656. }
  39657. };
  39658. Ep.emitAbruptCompletion = function(record) {
  39659. if (!isValidCompletion(record)) {
  39660. assert.ok(
  39661. false,
  39662. "invalid completion record: " +
  39663. JSON.stringify(record)
  39664. );
  39665. }
  39666. assert.notStrictEqual(
  39667. record.type, "normal",
  39668. "normal completions are not abrupt"
  39669. );
  39670. var abruptArgs = [b.literal(record.type)];
  39671. if (record.type === "break" ||
  39672. record.type === "continue") {
  39673. n.Literal.assert(record.target);
  39674. abruptArgs[1] = record.target;
  39675. } else if (record.type === "return" ||
  39676. record.type === "throw") {
  39677. if (record.value) {
  39678. n.Expression.assert(record.value);
  39679. abruptArgs[1] = record.value;
  39680. }
  39681. }
  39682. this.emit(
  39683. b.returnStatement(
  39684. b.callExpression(
  39685. this.contextProperty("abrupt"),
  39686. abruptArgs
  39687. )
  39688. )
  39689. );
  39690. };
  39691. function isValidCompletion(record) {
  39692. var type = record.type;
  39693. if (type === "normal") {
  39694. return !hasOwn.call(record, "target");
  39695. }
  39696. if (type === "break" ||
  39697. type === "continue") {
  39698. return !hasOwn.call(record, "value")
  39699. && n.Literal.check(record.target);
  39700. }
  39701. if (type === "return" ||
  39702. type === "throw") {
  39703. return hasOwn.call(record, "value")
  39704. && !hasOwn.call(record, "target");
  39705. }
  39706. return false;
  39707. }
  39708. // Not all offsets into emitter.listing are potential jump targets. For
  39709. // example, execution typically falls into the beginning of a try block
  39710. // without jumping directly there. This method returns the current offset
  39711. // without marking it, so that a switch case will not necessarily be
  39712. // generated for this offset (I say "not necessarily" because the same
  39713. // location might end up being marked in the process of emitting other
  39714. // statements). There's no logical harm in marking such locations as jump
  39715. // targets, but minimizing the number of switch cases keeps the generated
  39716. // code shorter.
  39717. Ep.getUnmarkedCurrentLoc = function() {
  39718. return b.literal(this.listing.length);
  39719. };
  39720. // The context.prev property takes the value of context.next whenever we
  39721. // evaluate the switch statement discriminant, which is generally good
  39722. // enough for tracking the last location we jumped to, but sometimes
  39723. // context.prev needs to be more precise, such as when we fall
  39724. // successfully out of a try block and into a finally block without
  39725. // jumping. This method exists to update context.prev to the freshest
  39726. // available location. If we were implementing a full interpreter, we
  39727. // would know the location of the current instruction with complete
  39728. // precision at all times, but we don't have that luxury here, as it would
  39729. // be costly and verbose to set context.prev before every statement.
  39730. Ep.updateContextPrevLoc = function(loc) {
  39731. if (loc) {
  39732. n.Literal.assert(loc);
  39733. if (loc.value === -1) {
  39734. // If an uninitialized location literal was passed in, set its value
  39735. // to the current this.listing.length.
  39736. loc.value = this.listing.length;
  39737. } else {
  39738. // Otherwise assert that the location matches the current offset.
  39739. assert.strictEqual(loc.value, this.listing.length);
  39740. }
  39741. } else {
  39742. loc = this.getUnmarkedCurrentLoc();
  39743. }
  39744. // Make sure context.prev is up to date in case we fell into this try
  39745. // statement without jumping to it. TODO Consider avoiding this
  39746. // assignment when we know control must have jumped here.
  39747. this.emitAssign(this.contextProperty("prev"), loc);
  39748. };
  39749. Ep.explodeExpression = function(path, ignoreResult) {
  39750. assert.ok(path instanceof types.NodePath);
  39751. var expr = path.value;
  39752. if (expr) {
  39753. n.Expression.assert(expr);
  39754. } else {
  39755. return expr;
  39756. }
  39757. var self = this;
  39758. var result; // Used optionally by several cases below.
  39759. function finish(expr) {
  39760. n.Expression.assert(expr);
  39761. if (ignoreResult) {
  39762. self.emit(expr);
  39763. } else {
  39764. return expr;
  39765. }
  39766. }
  39767. // If the expression does not contain a leap, then we either emit the
  39768. // expression as a standalone statement or return it whole.
  39769. if (!meta.containsLeap(expr)) {
  39770. return finish(expr);
  39771. }
  39772. // If any child contains a leap (such as a yield or labeled continue or
  39773. // break statement), then any sibling subexpressions will almost
  39774. // certainly have to be exploded in order to maintain the order of their
  39775. // side effects relative to the leaping child(ren).
  39776. var hasLeapingChildren = meta.containsLeap.onlyChildren(expr);
  39777. // In order to save the rest of explodeExpression from a combinatorial
  39778. // trainwreck of special cases, explodeViaTempVar is responsible for
  39779. // deciding when a subexpression needs to be "exploded," which is my
  39780. // very technical term for emitting the subexpression as an assignment
  39781. // to a temporary variable and the substituting the temporary variable
  39782. // for the original subexpression. Think of exploded view diagrams, not
  39783. // Michael Bay movies. The point of exploding subexpressions is to
  39784. // control the precise order in which the generated code realizes the
  39785. // side effects of those subexpressions.
  39786. function explodeViaTempVar(tempVar, childPath, ignoreChildResult) {
  39787. assert.ok(childPath instanceof types.NodePath);
  39788. assert.ok(
  39789. !ignoreChildResult || !tempVar,
  39790. "Ignoring the result of a child expression but forcing it to " +
  39791. "be assigned to a temporary variable?"
  39792. );
  39793. var result = self.explodeExpression(childPath, ignoreChildResult);
  39794. if (ignoreChildResult) {
  39795. // Side effects already emitted above.
  39796. } else if (tempVar || (hasLeapingChildren &&
  39797. (self.isVolatileContextProperty(result) ||
  39798. meta.hasSideEffects(result)))) {
  39799. // If tempVar was provided, then the result will always be assigned
  39800. // to it, even if the result does not otherwise need to be assigned
  39801. // to a temporary variable. When no tempVar is provided, we have
  39802. // the flexibility to decide whether a temporary variable is really
  39803. // necessary. In general, temporary assignment is required only
  39804. // when some other child contains a leap and the child in question
  39805. // is a context property like $ctx.sent that might get overwritten
  39806. // or an expression with side effects that need to occur in proper
  39807. // sequence relative to the leap.
  39808. result = self.emitAssign(
  39809. tempVar || self.makeTempVar(),
  39810. result
  39811. );
  39812. }
  39813. return result;
  39814. }
  39815. // If ignoreResult is true, then we must take full responsibility for
  39816. // emitting the expression with all its side effects, and we should not
  39817. // return a result.
  39818. switch (expr.type) {
  39819. case "MemberExpression":
  39820. return finish(b.memberExpression(
  39821. self.explodeExpression(path.get("object")),
  39822. expr.computed
  39823. ? explodeViaTempVar(null, path.get("property"))
  39824. : expr.property,
  39825. expr.computed
  39826. ));
  39827. case "CallExpression":
  39828. var oldCalleePath = path.get("callee");
  39829. var newCallee = self.explodeExpression(oldCalleePath);
  39830. // If the callee was not previously a MemberExpression, then the
  39831. // CallExpression was "unqualified," meaning its `this` object should
  39832. // be the global object. If the exploded expression has become a
  39833. // MemberExpression, then we need to force it to be unqualified by
  39834. // using the (0, object.property)(...) trick; otherwise, it will
  39835. // receive the object of the MemberExpression as its `this` object.
  39836. if (!n.MemberExpression.check(oldCalleePath.node) &&
  39837. n.MemberExpression.check(newCallee)) {
  39838. newCallee = b.sequenceExpression([
  39839. b.literal(0),
  39840. newCallee
  39841. ]);
  39842. }
  39843. return finish(b.callExpression(
  39844. newCallee,
  39845. path.get("arguments").map(function(argPath) {
  39846. return explodeViaTempVar(null, argPath);
  39847. })
  39848. ));
  39849. case "NewExpression":
  39850. return finish(b.newExpression(
  39851. explodeViaTempVar(null, path.get("callee")),
  39852. path.get("arguments").map(function(argPath) {
  39853. return explodeViaTempVar(null, argPath);
  39854. })
  39855. ));
  39856. case "ObjectExpression":
  39857. return finish(b.objectExpression(
  39858. path.get("properties").map(function(propPath) {
  39859. return b.property(
  39860. propPath.value.kind,
  39861. propPath.value.key,
  39862. explodeViaTempVar(null, propPath.get("value"))
  39863. );
  39864. })
  39865. ));
  39866. case "ArrayExpression":
  39867. return finish(b.arrayExpression(
  39868. path.get("elements").map(function(elemPath) {
  39869. return explodeViaTempVar(null, elemPath);
  39870. })
  39871. ));
  39872. case "SequenceExpression":
  39873. var lastIndex = expr.expressions.length - 1;
  39874. path.get("expressions").each(function(exprPath) {
  39875. if (exprPath.name === lastIndex) {
  39876. result = self.explodeExpression(exprPath, ignoreResult);
  39877. } else {
  39878. self.explodeExpression(exprPath, true);
  39879. }
  39880. });
  39881. return result;
  39882. case "LogicalExpression":
  39883. var after = loc();
  39884. if (!ignoreResult) {
  39885. result = self.makeTempVar();
  39886. }
  39887. var left = explodeViaTempVar(result, path.get("left"));
  39888. if (expr.operator === "&&") {
  39889. self.jumpIfNot(left, after);
  39890. } else {
  39891. assert.strictEqual(expr.operator, "||");
  39892. self.jumpIf(left, after);
  39893. }
  39894. explodeViaTempVar(result, path.get("right"), ignoreResult);
  39895. self.mark(after);
  39896. return result;
  39897. case "ConditionalExpression":
  39898. var elseLoc = loc();
  39899. var after = loc();
  39900. var test = self.explodeExpression(path.get("test"));
  39901. self.jumpIfNot(test, elseLoc);
  39902. if (!ignoreResult) {
  39903. result = self.makeTempVar();
  39904. }
  39905. explodeViaTempVar(result, path.get("consequent"), ignoreResult);
  39906. self.jump(after);
  39907. self.mark(elseLoc);
  39908. explodeViaTempVar(result, path.get("alternate"), ignoreResult);
  39909. self.mark(after);
  39910. return result;
  39911. case "UnaryExpression":
  39912. return finish(b.unaryExpression(
  39913. expr.operator,
  39914. // Can't (and don't need to) break up the syntax of the argument.
  39915. // Think about delete a[b].
  39916. self.explodeExpression(path.get("argument")),
  39917. !!expr.prefix
  39918. ));
  39919. case "BinaryExpression":
  39920. return finish(b.binaryExpression(
  39921. expr.operator,
  39922. explodeViaTempVar(null, path.get("left")),
  39923. explodeViaTempVar(null, path.get("right"))
  39924. ));
  39925. case "AssignmentExpression":
  39926. return finish(b.assignmentExpression(
  39927. expr.operator,
  39928. self.explodeExpression(path.get("left")),
  39929. self.explodeExpression(path.get("right"))
  39930. ));
  39931. case "UpdateExpression":
  39932. return finish(b.updateExpression(
  39933. expr.operator,
  39934. self.explodeExpression(path.get("argument")),
  39935. expr.prefix
  39936. ));
  39937. case "YieldExpression":
  39938. var after = loc();
  39939. var arg = expr.argument && self.explodeExpression(path.get("argument"));
  39940. if (arg && expr.delegate) {
  39941. var result = self.makeTempVar();
  39942. self.emit(b.returnStatement(b.callExpression(
  39943. self.contextProperty("delegateYield"), [
  39944. arg,
  39945. b.literal(result.property.name),
  39946. after
  39947. ]
  39948. )));
  39949. self.mark(after);
  39950. return result;
  39951. }
  39952. self.emitAssign(self.contextProperty("next"), after);
  39953. self.emit(b.returnStatement(arg || null));
  39954. self.mark(after);
  39955. return self.contextProperty("sent");
  39956. default:
  39957. throw new Error(
  39958. "unknown Expression of type " +
  39959. JSON.stringify(expr.type));
  39960. }
  39961. };
  39962. },{"./leap":438,"./meta":439,"./util":440,"assert":190,"recast":469}],437:[function(require,module,exports){
  39963. /**
  39964. * Copyright (c) 2014, Facebook, Inc.
  39965. * All rights reserved.
  39966. *
  39967. * This source code is licensed under the BSD-style license found in the
  39968. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  39969. * additional grant of patent rights can be found in the PATENTS file in
  39970. * the same directory.
  39971. */
  39972. var assert = require("assert");
  39973. var types = require("recast").types;
  39974. var n = types.namedTypes;
  39975. var b = types.builders;
  39976. var hasOwn = Object.prototype.hasOwnProperty;
  39977. // The hoist function takes a FunctionExpression or FunctionDeclaration
  39978. // and replaces any Declaration nodes in its body with assignments, then
  39979. // returns a VariableDeclaration containing just the names of the removed
  39980. // declarations.
  39981. exports.hoist = function(funPath) {
  39982. assert.ok(funPath instanceof types.NodePath);
  39983. n.Function.assert(funPath.value);
  39984. var vars = {};
  39985. function varDeclToExpr(vdec, includeIdentifiers) {
  39986. n.VariableDeclaration.assert(vdec);
  39987. var exprs = [];
  39988. vdec.declarations.forEach(function(dec) {
  39989. vars[dec.id.name] = dec.id;
  39990. if (dec.init) {
  39991. exprs.push(b.assignmentExpression(
  39992. "=", dec.id, dec.init
  39993. ));
  39994. } else if (includeIdentifiers) {
  39995. exprs.push(dec.id);
  39996. }
  39997. });
  39998. if (exprs.length === 0)
  39999. return null;
  40000. if (exprs.length === 1)
  40001. return exprs[0];
  40002. return b.sequenceExpression(exprs);
  40003. }
  40004. types.visit(funPath.get("body"), {
  40005. visitVariableDeclaration: function(path) {
  40006. var expr = varDeclToExpr(path.value, false);
  40007. if (expr === null) {
  40008. path.replace();
  40009. } else {
  40010. // We don't need to traverse this expression any further because
  40011. // there can't be any new declarations inside an expression.
  40012. return b.expressionStatement(expr);
  40013. }
  40014. // Since the original node has been either removed or replaced,
  40015. // avoid traversing it any further.
  40016. return false;
  40017. },
  40018. visitForStatement: function(path) {
  40019. var init = path.value.init;
  40020. if (n.VariableDeclaration.check(init)) {
  40021. path.get("init").replace(varDeclToExpr(init, false));
  40022. }
  40023. this.traverse(path);
  40024. },
  40025. visitForInStatement: function(path) {
  40026. var left = path.value.left;
  40027. if (n.VariableDeclaration.check(left)) {
  40028. path.get("left").replace(varDeclToExpr(left, true));
  40029. }
  40030. this.traverse(path);
  40031. },
  40032. visitFunctionDeclaration: function(path) {
  40033. var node = path.value;
  40034. vars[node.id.name] = node.id;
  40035. var parentNode = path.parent.node;
  40036. var assignment = b.expressionStatement(
  40037. b.assignmentExpression(
  40038. "=",
  40039. node.id,
  40040. b.functionExpression(
  40041. node.id,
  40042. node.params,
  40043. node.body,
  40044. node.generator,
  40045. node.expression
  40046. )
  40047. )
  40048. );
  40049. if (n.BlockStatement.check(path.parent.node)) {
  40050. // Insert the assignment form before the first statement in the
  40051. // enclosing block.
  40052. path.parent.get("body").unshift(assignment);
  40053. // Remove the function declaration now that we've inserted the
  40054. // equivalent assignment form at the beginning of the block.
  40055. path.replace();
  40056. } else {
  40057. // If the parent node is not a block statement, then we can just
  40058. // replace the declaration with the equivalent assignment form
  40059. // without worrying about hoisting it.
  40060. path.replace(assignment);
  40061. }
  40062. // Don't hoist variables out of inner functions.
  40063. return false;
  40064. },
  40065. visitFunctionExpression: function(path) {
  40066. // Don't descend into nested function expressions.
  40067. return false;
  40068. }
  40069. });
  40070. var paramNames = {};
  40071. funPath.get("params").each(function(paramPath) {
  40072. var param = paramPath.value;
  40073. if (n.Identifier.check(param)) {
  40074. paramNames[param.name] = param;
  40075. } else {
  40076. // Variables declared by destructuring parameter patterns will be
  40077. // harmlessly re-declared.
  40078. }
  40079. });
  40080. var declarations = [];
  40081. Object.keys(vars).forEach(function(name) {
  40082. if (!hasOwn.call(paramNames, name)) {
  40083. declarations.push(b.variableDeclarator(vars[name], null));
  40084. }
  40085. });
  40086. if (declarations.length === 0) {
  40087. return null; // Be sure to handle this case!
  40088. }
  40089. return b.variableDeclaration("var", declarations);
  40090. };
  40091. },{"assert":190,"recast":469}],438:[function(require,module,exports){
  40092. /**
  40093. * Copyright (c) 2014, Facebook, Inc.
  40094. * All rights reserved.
  40095. *
  40096. * This source code is licensed under the BSD-style license found in the
  40097. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  40098. * additional grant of patent rights can be found in the PATENTS file in
  40099. * the same directory.
  40100. */
  40101. var assert = require("assert");
  40102. var types = require("recast").types;
  40103. var n = types.namedTypes;
  40104. var b = types.builders;
  40105. var inherits = require("util").inherits;
  40106. var hasOwn = Object.prototype.hasOwnProperty;
  40107. function Entry() {
  40108. assert.ok(this instanceof Entry);
  40109. }
  40110. function FunctionEntry(returnLoc) {
  40111. Entry.call(this);
  40112. n.Literal.assert(returnLoc);
  40113. this.returnLoc = returnLoc;
  40114. }
  40115. inherits(FunctionEntry, Entry);
  40116. exports.FunctionEntry = FunctionEntry;
  40117. function LoopEntry(breakLoc, continueLoc, label) {
  40118. Entry.call(this);
  40119. n.Literal.assert(breakLoc);
  40120. n.Literal.assert(continueLoc);
  40121. if (label) {
  40122. n.Identifier.assert(label);
  40123. } else {
  40124. label = null;
  40125. }
  40126. this.breakLoc = breakLoc;
  40127. this.continueLoc = continueLoc;
  40128. this.label = label;
  40129. }
  40130. inherits(LoopEntry, Entry);
  40131. exports.LoopEntry = LoopEntry;
  40132. function SwitchEntry(breakLoc) {
  40133. Entry.call(this);
  40134. n.Literal.assert(breakLoc);
  40135. this.breakLoc = breakLoc;
  40136. }
  40137. inherits(SwitchEntry, Entry);
  40138. exports.SwitchEntry = SwitchEntry;
  40139. function TryEntry(firstLoc, catchEntry, finallyEntry) {
  40140. Entry.call(this);
  40141. n.Literal.assert(firstLoc);
  40142. if (catchEntry) {
  40143. assert.ok(catchEntry instanceof CatchEntry);
  40144. } else {
  40145. catchEntry = null;
  40146. }
  40147. if (finallyEntry) {
  40148. assert.ok(finallyEntry instanceof FinallyEntry);
  40149. } else {
  40150. finallyEntry = null;
  40151. }
  40152. // Have to have one or the other (or both).
  40153. assert.ok(catchEntry || finallyEntry);
  40154. this.firstLoc = firstLoc;
  40155. this.catchEntry = catchEntry;
  40156. this.finallyEntry = finallyEntry;
  40157. }
  40158. inherits(TryEntry, Entry);
  40159. exports.TryEntry = TryEntry;
  40160. function CatchEntry(firstLoc, paramId) {
  40161. Entry.call(this);
  40162. n.Literal.assert(firstLoc);
  40163. n.Identifier.assert(paramId);
  40164. this.firstLoc = firstLoc;
  40165. this.paramId = paramId;
  40166. }
  40167. inherits(CatchEntry, Entry);
  40168. exports.CatchEntry = CatchEntry;
  40169. function FinallyEntry(firstLoc, afterLoc) {
  40170. Entry.call(this);
  40171. n.Literal.assert(firstLoc);
  40172. n.Literal.assert(afterLoc);
  40173. this.firstLoc = firstLoc;
  40174. this.afterLoc = afterLoc;
  40175. }
  40176. inherits(FinallyEntry, Entry);
  40177. exports.FinallyEntry = FinallyEntry;
  40178. function LabeledEntry(breakLoc, label) {
  40179. Entry.call(this);
  40180. n.Literal.assert(breakLoc);
  40181. n.Identifier.assert(label);
  40182. this.breakLoc = breakLoc;
  40183. this.label = label;
  40184. }
  40185. inherits(LabeledEntry, Entry);
  40186. exports.LabeledEntry = LabeledEntry;
  40187. function LeapManager(emitter) {
  40188. assert.ok(this instanceof LeapManager);
  40189. var Emitter = require("./emit").Emitter;
  40190. assert.ok(emitter instanceof Emitter);
  40191. this.emitter = emitter;
  40192. this.entryStack = [new FunctionEntry(emitter.finalLoc)];
  40193. }
  40194. var LMp = LeapManager.prototype;
  40195. exports.LeapManager = LeapManager;
  40196. LMp.withEntry = function(entry, callback) {
  40197. assert.ok(entry instanceof Entry);
  40198. this.entryStack.push(entry);
  40199. try {
  40200. callback.call(this.emitter);
  40201. } finally {
  40202. var popped = this.entryStack.pop();
  40203. assert.strictEqual(popped, entry);
  40204. }
  40205. };
  40206. LMp._findLeapLocation = function(property, label) {
  40207. for (var i = this.entryStack.length - 1; i >= 0; --i) {
  40208. var entry = this.entryStack[i];
  40209. var loc = entry[property];
  40210. if (loc) {
  40211. if (label) {
  40212. if (entry.label &&
  40213. entry.label.name === label.name) {
  40214. return loc;
  40215. }
  40216. } else if (entry instanceof LabeledEntry) {
  40217. // Ignore LabeledEntry entries unless we are actually breaking to
  40218. // a label.
  40219. } else {
  40220. return loc;
  40221. }
  40222. }
  40223. }
  40224. return null;
  40225. };
  40226. LMp.getBreakLoc = function(label) {
  40227. return this._findLeapLocation("breakLoc", label);
  40228. };
  40229. LMp.getContinueLoc = function(label) {
  40230. return this._findLeapLocation("continueLoc", label);
  40231. };
  40232. },{"./emit":436,"assert":190,"recast":469,"util":216}],439:[function(require,module,exports){
  40233. /**
  40234. * Copyright (c) 2014, Facebook, Inc.
  40235. * All rights reserved.
  40236. *
  40237. * This source code is licensed under the BSD-style license found in the
  40238. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  40239. * additional grant of patent rights can be found in the PATENTS file in
  40240. * the same directory.
  40241. */
  40242. var assert = require("assert");
  40243. var m = require("private").makeAccessor();
  40244. var types = require("recast").types;
  40245. var isArray = types.builtInTypes.array;
  40246. var n = types.namedTypes;
  40247. var hasOwn = Object.prototype.hasOwnProperty;
  40248. function makePredicate(propertyName, knownTypes) {
  40249. function onlyChildren(node) {
  40250. n.Node.assert(node);
  40251. // Assume no side effects until we find out otherwise.
  40252. var result = false;
  40253. function check(child) {
  40254. if (result) {
  40255. // Do nothing.
  40256. } else if (isArray.check(child)) {
  40257. child.some(check);
  40258. } else if (n.Node.check(child)) {
  40259. assert.strictEqual(result, false);
  40260. result = predicate(child);
  40261. }
  40262. return result;
  40263. }
  40264. types.eachField(node, function(name, child) {
  40265. check(child);
  40266. });
  40267. return result;
  40268. }
  40269. function predicate(node) {
  40270. n.Node.assert(node);
  40271. var meta = m(node);
  40272. if (hasOwn.call(meta, propertyName))
  40273. return meta[propertyName];
  40274. // Certain types are "opaque," which means they have no side
  40275. // effects or leaps and we don't care about their subexpressions.
  40276. if (hasOwn.call(opaqueTypes, node.type))
  40277. return meta[propertyName] = false;
  40278. if (hasOwn.call(knownTypes, node.type))
  40279. return meta[propertyName] = true;
  40280. return meta[propertyName] = onlyChildren(node);
  40281. }
  40282. predicate.onlyChildren = onlyChildren;
  40283. return predicate;
  40284. }
  40285. var opaqueTypes = {
  40286. FunctionExpression: true
  40287. };
  40288. // These types potentially have side effects regardless of what side
  40289. // effects their subexpressions have.
  40290. var sideEffectTypes = {
  40291. CallExpression: true, // Anything could happen!
  40292. ForInStatement: true, // Modifies the key variable.
  40293. UnaryExpression: true, // Think delete.
  40294. BinaryExpression: true, // Might invoke .toString() or .valueOf().
  40295. AssignmentExpression: true, // Side-effecting by definition.
  40296. UpdateExpression: true, // Updates are essentially assignments.
  40297. NewExpression: true // Similar to CallExpression.
  40298. };
  40299. // These types are the direct cause of all leaps in control flow.
  40300. var leapTypes = {
  40301. YieldExpression: true,
  40302. BreakStatement: true,
  40303. ContinueStatement: true,
  40304. ReturnStatement: true,
  40305. ThrowStatement: true
  40306. };
  40307. // All leap types are also side effect types.
  40308. for (var type in leapTypes) {
  40309. if (hasOwn.call(leapTypes, type)) {
  40310. sideEffectTypes[type] = leapTypes[type];
  40311. }
  40312. }
  40313. exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes);
  40314. exports.containsLeap = makePredicate("containsLeap", leapTypes);
  40315. },{"assert":190,"private":435,"recast":469}],440:[function(require,module,exports){
  40316. /**
  40317. * Copyright (c) 2014, Facebook, Inc.
  40318. * All rights reserved.
  40319. *
  40320. * This source code is licensed under the BSD-style license found in the
  40321. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  40322. * additional grant of patent rights can be found in the PATENTS file in
  40323. * the same directory.
  40324. */
  40325. var assert = require("assert");
  40326. var types = require("recast").types;
  40327. var n = types.namedTypes;
  40328. var b = types.builders;
  40329. var hasOwn = Object.prototype.hasOwnProperty;
  40330. exports.defaults = function(obj) {
  40331. var len = arguments.length;
  40332. var extension;
  40333. for (var i = 1; i < len; ++i) {
  40334. if ((extension = arguments[i])) {
  40335. for (var key in extension) {
  40336. if (hasOwn.call(extension, key) && !hasOwn.call(obj, key)) {
  40337. obj[key] = extension[key];
  40338. }
  40339. }
  40340. }
  40341. }
  40342. return obj;
  40343. };
  40344. exports.runtimeProperty = function(name) {
  40345. return b.memberExpression(
  40346. b.identifier("regeneratorRuntime"),
  40347. b.identifier(name),
  40348. false
  40349. );
  40350. };
  40351. // Inspired by the isReference function from ast-util:
  40352. // https://github.com/eventualbuddha/ast-util/blob/9bf91c5ce8/lib/index.js#L466-L506
  40353. exports.isReference = function(path, name) {
  40354. var node = path.value;
  40355. if (!n.Identifier.check(node)) {
  40356. return false;
  40357. }
  40358. if (name && node.name !== name) {
  40359. return false;
  40360. }
  40361. var parent = path.parent.value;
  40362. switch (parent.type) {
  40363. case "VariableDeclarator":
  40364. return path.name === "init";
  40365. case "MemberExpression":
  40366. return path.name === "object" || (
  40367. parent.computed && path.name === "property"
  40368. );
  40369. case "FunctionExpression":
  40370. case "FunctionDeclaration":
  40371. case "ArrowFunctionExpression":
  40372. if (path.name === "id") {
  40373. return false;
  40374. }
  40375. if (parent.params === path.parentPath &&
  40376. parent.params[path.name] === node) {
  40377. return false;
  40378. }
  40379. return true;
  40380. case "ClassDeclaration":
  40381. case "ClassExpression":
  40382. return path.name !== "id";
  40383. case "CatchClause":
  40384. return path.name !== "param";
  40385. case "Property":
  40386. case "MethodDefinition":
  40387. return path.name !== "key";
  40388. case "ImportSpecifier":
  40389. case "ImportDefaultSpecifier":
  40390. case "ImportNamespaceSpecifier":
  40391. case "LabeledStatement":
  40392. return false;
  40393. default:
  40394. return true;
  40395. }
  40396. };
  40397. },{"assert":190,"recast":469}],441:[function(require,module,exports){
  40398. /**
  40399. * Copyright (c) 2014, Facebook, Inc.
  40400. * All rights reserved.
  40401. *
  40402. * This source code is licensed under the BSD-style license found in the
  40403. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  40404. * additional grant of patent rights can be found in the PATENTS file in
  40405. * the same directory.
  40406. */
  40407. var assert = require("assert");
  40408. var fs = require("fs");
  40409. var recast = require("recast");
  40410. var types = recast.types;
  40411. var n = types.namedTypes;
  40412. var b = types.builders;
  40413. var isArray = types.builtInTypes.array;
  40414. var isObject = types.builtInTypes.object;
  40415. var NodePath = types.NodePath;
  40416. var hoist = require("./hoist").hoist;
  40417. var Emitter = require("./emit").Emitter;
  40418. var runtimeProperty = require("./util").runtimeProperty;
  40419. var getMarkInfo = require("private").makeAccessor();
  40420. exports.transform = function transform(node, options) {
  40421. options = options || {};
  40422. var path = node instanceof NodePath ? node : new NodePath(node);
  40423. visitor.visit(path, options);
  40424. node = path.value;
  40425. if (options.includeRuntime === true ||
  40426. (options.includeRuntime === 'if used' && visitor.wasChangeReported())) {
  40427. injectRuntime(n.File.check(node) ? node.program : node);
  40428. }
  40429. options.madeChanges = visitor.wasChangeReported();
  40430. return node;
  40431. };
  40432. function injectRuntime(program) {
  40433. n.Program.assert(program);
  40434. // Include the runtime by modifying the AST rather than by concatenating
  40435. // strings. This technique will allow for more accurate source mapping.
  40436. var runtimePath = require("..").runtime.path;
  40437. var runtime = fs.readFileSync(runtimePath, "utf8");
  40438. var runtimeBody = recast.parse(runtime, {
  40439. sourceFileName: runtimePath
  40440. }).program.body;
  40441. var body = program.body;
  40442. body.unshift.apply(body, runtimeBody);
  40443. }
  40444. var visitor = types.PathVisitor.fromMethodsObject({
  40445. reset: function(node, options) {
  40446. this.options = options;
  40447. },
  40448. visitFunction: function(path) {
  40449. // Calling this.traverse(path) first makes for a post-order traversal.
  40450. this.traverse(path);
  40451. var node = path.value;
  40452. var shouldTransformAsync = node.async && !this.options.disableAsync;
  40453. if (!node.generator && !shouldTransformAsync) {
  40454. return;
  40455. }
  40456. this.reportChanged();
  40457. node.generator = false;
  40458. if (node.expression) {
  40459. // Transform expression lambdas into normal functions.
  40460. node.expression = false;
  40461. node.body = b.blockStatement([
  40462. b.returnStatement(node.body)
  40463. ]);
  40464. }
  40465. if (shouldTransformAsync) {
  40466. awaitVisitor.visit(path.get("body"));
  40467. }
  40468. var outerBody = [];
  40469. var innerBody = [];
  40470. var bodyPath = path.get("body", "body");
  40471. bodyPath.each(function(childPath) {
  40472. var node = childPath.value;
  40473. if (node && node._blockHoist != null) {
  40474. outerBody.push(node);
  40475. } else {
  40476. innerBody.push(node);
  40477. }
  40478. });
  40479. if (outerBody.length > 0) {
  40480. // Only replace the inner body if we actually hoisted any statements
  40481. // to the outer body.
  40482. bodyPath.replace(innerBody);
  40483. }
  40484. var outerFnExpr = getOuterFnExpr(path);
  40485. // Note that getOuterFnExpr has the side-effect of ensuring that the
  40486. // function has a name (so node.id will always be an Identifier), even
  40487. // if a temporary name has to be synthesized.
  40488. n.Identifier.assert(node.id);
  40489. var innerFnId = b.identifier(node.id.name + "$");
  40490. var contextId = path.scope.declareTemporary("context$");
  40491. var argsId = path.scope.declareTemporary("args$");
  40492. var shouldAliasArguments = renameArguments(path, argsId);
  40493. var vars = hoist(path);
  40494. if (shouldAliasArguments) {
  40495. vars = vars || b.variableDeclaration("var", []);
  40496. vars.declarations.push(b.variableDeclarator(
  40497. argsId, b.identifier("arguments")
  40498. ));
  40499. }
  40500. var emitter = new Emitter(contextId);
  40501. emitter.explode(path.get("body"));
  40502. if (vars && vars.declarations.length > 0) {
  40503. outerBody.push(vars);
  40504. }
  40505. var wrapArgs = [
  40506. emitter.getContextFunction(innerFnId),
  40507. // Async functions don't care about the outer function because they
  40508. // don't need it to be marked and don't inherit from its .prototype.
  40509. shouldTransformAsync ? b.literal(null) : outerFnExpr,
  40510. b.thisExpression()
  40511. ];
  40512. var tryLocsList = emitter.getTryLocsList();
  40513. if (tryLocsList) {
  40514. wrapArgs.push(tryLocsList);
  40515. }
  40516. var wrapCall = b.callExpression(
  40517. runtimeProperty(shouldTransformAsync ? "async" : "wrap"),
  40518. wrapArgs
  40519. );
  40520. outerBody.push(b.returnStatement(wrapCall));
  40521. node.body = b.blockStatement(outerBody);
  40522. if (shouldTransformAsync) {
  40523. node.async = false;
  40524. return;
  40525. }
  40526. if (n.Expression.check(node)) {
  40527. return b.callExpression(runtimeProperty("mark"), [node]);
  40528. }
  40529. },
  40530. visitForOfStatement: function(path) {
  40531. this.traverse(path);
  40532. var node = path.value;
  40533. var tempIterId = path.scope.declareTemporary("t$");
  40534. var tempIterDecl = b.variableDeclarator(
  40535. tempIterId,
  40536. b.callExpression(
  40537. runtimeProperty("values"),
  40538. [node.right]
  40539. )
  40540. );
  40541. var tempInfoId = path.scope.declareTemporary("t$");
  40542. var tempInfoDecl = b.variableDeclarator(tempInfoId, null);
  40543. var init = node.left;
  40544. var loopId;
  40545. if (n.VariableDeclaration.check(init)) {
  40546. loopId = init.declarations[0].id;
  40547. init.declarations.push(tempIterDecl, tempInfoDecl);
  40548. } else {
  40549. loopId = init;
  40550. init = b.variableDeclaration("var", [
  40551. tempIterDecl,
  40552. tempInfoDecl
  40553. ]);
  40554. }
  40555. n.Identifier.assert(loopId);
  40556. var loopIdAssignExprStmt = b.expressionStatement(
  40557. b.assignmentExpression(
  40558. "=",
  40559. loopId,
  40560. b.memberExpression(
  40561. tempInfoId,
  40562. b.identifier("value"),
  40563. false
  40564. )
  40565. )
  40566. );
  40567. if (n.BlockStatement.check(node.body)) {
  40568. node.body.body.unshift(loopIdAssignExprStmt);
  40569. } else {
  40570. node.body = b.blockStatement([
  40571. loopIdAssignExprStmt,
  40572. node.body
  40573. ]);
  40574. }
  40575. return b.forStatement(
  40576. init,
  40577. b.unaryExpression(
  40578. "!",
  40579. b.memberExpression(
  40580. b.assignmentExpression(
  40581. "=",
  40582. tempInfoId,
  40583. b.callExpression(
  40584. b.memberExpression(
  40585. tempIterId,
  40586. b.identifier("next"),
  40587. false
  40588. ),
  40589. []
  40590. )
  40591. ),
  40592. b.identifier("done"),
  40593. false
  40594. )
  40595. ),
  40596. null,
  40597. node.body
  40598. );
  40599. }
  40600. });
  40601. // Given a NodePath for a Function, return an Expression node that can be
  40602. // used to refer reliably to the function object from inside the function.
  40603. // This expression is essentially a replacement for arguments.callee, with
  40604. // the key advantage that it works in strict mode.
  40605. function getOuterFnExpr(funPath) {
  40606. var node = funPath.value;
  40607. n.Function.assert(node);
  40608. if (!node.async && // Async functions don't need to be marked.
  40609. n.FunctionDeclaration.check(node)) {
  40610. var pp = funPath.parent;
  40611. while (pp && !(n.BlockStatement.check(pp.value) ||
  40612. n.Program.check(pp.value))) {
  40613. pp = pp.parent;
  40614. }
  40615. if (!pp) {
  40616. return node.id;
  40617. }
  40618. var markDecl = getRuntimeMarkDecl(pp);
  40619. var markedArray = markDecl.declarations[0].id;
  40620. var funDeclIdArray = markDecl.declarations[0].init.callee.object;
  40621. n.ArrayExpression.assert(funDeclIdArray);
  40622. var index = funDeclIdArray.elements.length;
  40623. funDeclIdArray.elements.push(node.id);
  40624. return b.memberExpression(
  40625. markedArray,
  40626. b.literal(index),
  40627. true
  40628. );
  40629. }
  40630. return node.id || (
  40631. node.id = funPath.scope.parent.declareTemporary("callee$")
  40632. );
  40633. }
  40634. function getRuntimeMarkDecl(blockPath) {
  40635. assert.ok(blockPath instanceof NodePath);
  40636. var block = blockPath.node;
  40637. isArray.assert(block.body);
  40638. var info = getMarkInfo(block);
  40639. if (info.decl) {
  40640. return info.decl;
  40641. }
  40642. info.decl = b.variableDeclaration("var", [
  40643. b.variableDeclarator(
  40644. blockPath.scope.declareTemporary("marked"),
  40645. b.callExpression(
  40646. b.memberExpression(
  40647. b.arrayExpression([]),
  40648. b.identifier("map"),
  40649. false
  40650. ),
  40651. [runtimeProperty("mark")]
  40652. )
  40653. )
  40654. ]);
  40655. for (var i = 0; i < block.body.length; ++i) {
  40656. if (!shouldNotHoistAbove(blockPath.get("body", i))) {
  40657. break;
  40658. }
  40659. }
  40660. blockPath.get("body").insertAt(i, info.decl);
  40661. return info.decl;
  40662. }
  40663. function shouldNotHoistAbove(stmtPath) {
  40664. var value = stmtPath.value;
  40665. n.Statement.assert(value);
  40666. // If the first statement is a "use strict" declaration, make sure to
  40667. // insert hoisted declarations afterwards.
  40668. return n.ExpressionStatement.check(value) &&
  40669. n.Literal.check(value.expression) &&
  40670. value.expression.value === "use strict";
  40671. }
  40672. function renameArguments(funcPath, argsId) {
  40673. assert.ok(funcPath instanceof types.NodePath);
  40674. var func = funcPath.value;
  40675. var didReplaceArguments = false;
  40676. var hasImplicitArguments = false;
  40677. recast.visit(funcPath, {
  40678. visitFunction: function(path) {
  40679. if (path.value === func) {
  40680. hasImplicitArguments = !path.scope.lookup("arguments");
  40681. this.traverse(path);
  40682. } else {
  40683. return false;
  40684. }
  40685. },
  40686. visitIdentifier: function(path) {
  40687. if (path.value.name === "arguments") {
  40688. var isMemberProperty =
  40689. n.MemberExpression.check(path.parent.node) &&
  40690. path.name === "property" &&
  40691. !path.parent.node.computed;
  40692. if (!isMemberProperty) {
  40693. path.replace(argsId);
  40694. didReplaceArguments = true;
  40695. return false;
  40696. }
  40697. }
  40698. this.traverse(path);
  40699. }
  40700. });
  40701. // If the traversal replaced any arguments identifiers, and those
  40702. // identifiers were free variables, then we need to alias the outer
  40703. // function's arguments object to the variable named by argsId.
  40704. return didReplaceArguments && hasImplicitArguments;
  40705. }
  40706. var awaitVisitor = types.PathVisitor.fromMethodsObject({
  40707. visitFunction: function(path) {
  40708. return false; // Don't descend into nested function scopes.
  40709. },
  40710. visitAwaitExpression: function(path) {
  40711. // Convert await and await* expressions to yield expressions.
  40712. var argument = path.value.argument;
  40713. // If the parser supports await* syntax using a boolean .all property
  40714. // (#171), desugar that syntax to yield Promise.all(argument).
  40715. if (path.value.all) {
  40716. argument = b.callExpression(
  40717. b.memberExpression(
  40718. b.identifier("Promise"),
  40719. b.identifier("all"),
  40720. false
  40721. ),
  40722. [argument]
  40723. );
  40724. }
  40725. return b.yieldExpression(argument, false);
  40726. }
  40727. });
  40728. },{"..":442,"./emit":436,"./hoist":437,"./util":440,"assert":190,"fs":189,"private":435,"recast":469}],442:[function(require,module,exports){
  40729. (function (__dirname){
  40730. /**
  40731. * Copyright (c) 2014, Facebook, Inc.
  40732. * All rights reserved.
  40733. *
  40734. * This source code is licensed under the BSD-style license found in the
  40735. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  40736. * additional grant of patent rights can be found in the PATENTS file in
  40737. * the same directory.
  40738. */
  40739. var assert = require("assert");
  40740. var path = require("path");
  40741. var fs = require("fs");
  40742. var through = require("through");
  40743. var transform = require("./lib/visit").transform;
  40744. var utils = require("./lib/util");
  40745. var recast = require("recast");
  40746. var types = recast.types;
  40747. var genOrAsyncFunExp = /\bfunction\s*\*|\basync\b/;
  40748. var blockBindingExp = /\b(let|const)\s+/;
  40749. function exports(file, options) {
  40750. var data = [];
  40751. return through(write, end);
  40752. function write(buf) {
  40753. data.push(buf);
  40754. }
  40755. function end() {
  40756. this.queue(compile(data.join(""), options).code);
  40757. this.queue(null);
  40758. }
  40759. }
  40760. // To get a writable stream for use as a browserify transform, call
  40761. // require("regenerator")().
  40762. module.exports = exports;
  40763. // To include the runtime globally in the current node process, call
  40764. // require("regenerator").runtime().
  40765. function runtime() {
  40766. require("./runtime");
  40767. }
  40768. exports.runtime = runtime;
  40769. runtime.path = path.join(__dirname, "runtime.js");
  40770. function compile(source, options) {
  40771. options = normalizeOptions(options);
  40772. if (!genOrAsyncFunExp.test(source)) {
  40773. return {
  40774. // Shortcut: no generators or async functions to transform.
  40775. code: (options.includeRuntime === true ? fs.readFileSync(
  40776. path.join(__dirname, "runtime.js"), "utf-8"
  40777. ) + "\n" : "") + source
  40778. };
  40779. }
  40780. var recastOptions = getRecastOptions(options);
  40781. var ast = recast.parse(source, recastOptions);
  40782. var nodePath = new types.NodePath(ast);
  40783. var programPath = nodePath.get("program");
  40784. if (shouldVarify(source, options)) {
  40785. // Transpile let/const into var declarations.
  40786. varifyAst(programPath.node);
  40787. }
  40788. transform(programPath, options);
  40789. return recast.print(nodePath, recastOptions);
  40790. }
  40791. function normalizeOptions(options) {
  40792. options = utils.defaults(options || {}, {
  40793. includeRuntime: false,
  40794. supportBlockBinding: true
  40795. });
  40796. if (!options.esprima) {
  40797. options.esprima = require("esprima-fb");
  40798. }
  40799. assert.ok(
  40800. /harmony/.test(options.esprima.version),
  40801. "Bad esprima version: " + options.esprima.version
  40802. );
  40803. return options;
  40804. }
  40805. function getRecastOptions(options) {
  40806. var recastOptions = {
  40807. range: true
  40808. };
  40809. function copy(name) {
  40810. if (name in options) {
  40811. recastOptions[name] = options[name];
  40812. }
  40813. }
  40814. copy("esprima");
  40815. copy("sourceFileName");
  40816. copy("sourceMapName");
  40817. copy("inputSourceMap");
  40818. copy("sourceRoot");
  40819. return recastOptions;
  40820. }
  40821. function shouldVarify(source, options) {
  40822. var supportBlockBinding = !!options.supportBlockBinding;
  40823. if (supportBlockBinding) {
  40824. if (!blockBindingExp.test(source)) {
  40825. supportBlockBinding = false;
  40826. }
  40827. }
  40828. return supportBlockBinding;
  40829. }
  40830. function varify(source, options) {
  40831. var recastOptions = getRecastOptions(normalizeOptions(options));
  40832. var ast = recast.parse(source, recastOptions);
  40833. varifyAst(ast.program);
  40834. return recast.print(ast, recastOptions).code;
  40835. }
  40836. function varifyAst(ast) {
  40837. types.namedTypes.Program.assert(ast);
  40838. var defsResult = require("defs")(ast, {
  40839. ast: true,
  40840. disallowUnknownReferences: false,
  40841. disallowDuplicated: false,
  40842. disallowVars: false,
  40843. loopClosures: "iife"
  40844. });
  40845. if (defsResult.errors) {
  40846. throw new Error(defsResult.errors.join("\n"))
  40847. }
  40848. return ast;
  40849. }
  40850. // Convenience for just translating let/const to var declarations.
  40851. exports.varify = varify;
  40852. // Transforms a string of source code, returning the { code, map? } result
  40853. // from recast.print.
  40854. exports.compile = compile;
  40855. // To modify an AST directly, call require("regenerator").transform(ast).
  40856. exports.transform = transform;
  40857. }).call(this,"/node_modules/regenerator")
  40858. },{"./lib/util":440,"./lib/visit":441,"./runtime":472,"assert":190,"defs":443,"esprima-fb":458,"fs":189,"path":199,"recast":469,"through":471}],443:[function(require,module,exports){
  40859. "use strict";
  40860. var assert = require("assert");
  40861. var is = require("simple-is");
  40862. var fmt = require("simple-fmt");
  40863. var stringmap = require("stringmap");
  40864. var stringset = require("stringset");
  40865. var alter = require("alter");
  40866. var traverse = require("ast-traverse");
  40867. var breakable = require("breakable");
  40868. var Scope = require("./scope");
  40869. var error = require("./error");
  40870. var getline = error.getline;
  40871. var options = require("./options");
  40872. var Stats = require("./stats");
  40873. var jshint_vars = require("./jshint_globals/vars.js");
  40874. function isConstLet(kind) {
  40875. return is.someof(kind, ["const", "let"]);
  40876. }
  40877. function isVarConstLet(kind) {
  40878. return is.someof(kind, ["var", "const", "let"]);
  40879. }
  40880. function isNonFunctionBlock(node) {
  40881. return node.type === "BlockStatement" && is.noneof(node.$parent.type, ["FunctionDeclaration", "FunctionExpression"]);
  40882. }
  40883. function isForWithConstLet(node) {
  40884. return node.type === "ForStatement" && node.init && node.init.type === "VariableDeclaration" && isConstLet(node.init.kind);
  40885. }
  40886. function isForInOfWithConstLet(node) {
  40887. return isForInOf(node) && node.left.type === "VariableDeclaration" && isConstLet(node.left.kind);
  40888. }
  40889. function isForInOf(node) {
  40890. return is.someof(node.type, ["ForInStatement", "ForOfStatement"]);
  40891. }
  40892. function isFunction(node) {
  40893. return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]);
  40894. }
  40895. function isLoop(node) {
  40896. return is.someof(node.type, ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"]);
  40897. }
  40898. function isReference(node) {
  40899. var parent = node.$parent;
  40900. return node.$refToScope ||
  40901. node.type === "Identifier" &&
  40902. !(parent.type === "VariableDeclarator" && parent.id === node) && // var|let|const $
  40903. !(parent.type === "MemberExpression" && parent.computed === false && parent.property === node) && // obj.$
  40904. !(parent.type === "Property" && parent.key === node) && // {$: ...}
  40905. !(parent.type === "LabeledStatement" && parent.label === node) && // $: ...
  40906. !(parent.type === "CatchClause" && parent.param === node) && // catch($)
  40907. !(isFunction(parent) && parent.id === node) && // function $(..
  40908. !(isFunction(parent) && is.someof(node, parent.params)) && // function f($)..
  40909. true;
  40910. }
  40911. function isLvalue(node) {
  40912. return isReference(node) &&
  40913. ((node.$parent.type === "AssignmentExpression" && node.$parent.left === node) ||
  40914. (node.$parent.type === "UpdateExpression" && node.$parent.argument === node));
  40915. }
  40916. function createScopes(node, parent) {
  40917. assert(!node.$scope);
  40918. node.$parent = parent;
  40919. node.$scope = node.$parent ? node.$parent.$scope : null; // may be overridden
  40920. if (node.type === "Program") {
  40921. // Top-level program is a scope
  40922. // There's no block-scope under it
  40923. node.$scope = new Scope({
  40924. kind: "hoist",
  40925. node: node,
  40926. parent: null,
  40927. });
  40928. } else if (isFunction(node)) {
  40929. // Function is a scope, with params in it
  40930. // There's no block-scope under it
  40931. node.$scope = new Scope({
  40932. kind: "hoist",
  40933. node: node,
  40934. parent: node.$parent.$scope,
  40935. });
  40936. // function has a name
  40937. if (node.id) {
  40938. assert(node.id.type === "Identifier");
  40939. if (node.type === "FunctionDeclaration") {
  40940. // Function name goes in parent scope for declared functions
  40941. node.$parent.$scope.add(node.id.name, "fun", node.id, null);
  40942. } else if (node.type === "FunctionExpression") {
  40943. // Function name goes in function's scope for named function expressions
  40944. node.$scope.add(node.id.name, "fun", node.id, null);
  40945. } else {
  40946. assert(false);
  40947. }
  40948. }
  40949. node.params.forEach(function(param) {
  40950. node.$scope.add(param.name, "param", param, null);
  40951. });
  40952. } else if (node.type === "VariableDeclaration") {
  40953. // Variable declarations names goes in current scope
  40954. assert(isVarConstLet(node.kind));
  40955. node.declarations.forEach(function(declarator) {
  40956. assert(declarator.type === "VariableDeclarator");
  40957. var name = declarator.id.name;
  40958. if (options.disallowVars && node.kind === "var") {
  40959. error(getline(declarator), "var {0} is not allowed (use let or const)", name);
  40960. }
  40961. node.$scope.add(name, node.kind, declarator.id, declarator.range[1]);
  40962. });
  40963. } else if (isForWithConstLet(node) || isForInOfWithConstLet(node)) {
  40964. // For(In/Of) loop with const|let declaration is a scope, with declaration in it
  40965. // There may be a block-scope under it
  40966. node.$scope = new Scope({
  40967. kind: "block",
  40968. node: node,
  40969. parent: node.$parent.$scope,
  40970. });
  40971. } else if (isNonFunctionBlock(node)) {
  40972. // A block node is a scope unless parent is a function
  40973. node.$scope = new Scope({
  40974. kind: "block",
  40975. node: node,
  40976. parent: node.$parent.$scope,
  40977. });
  40978. } else if (node.type === "CatchClause") {
  40979. var identifier = node.param;
  40980. node.$scope = new Scope({
  40981. kind: "catch-block",
  40982. node: node,
  40983. parent: node.$parent.$scope,
  40984. });
  40985. node.$scope.add(identifier.name, "caught", identifier, null);
  40986. // All hoist-scope keeps track of which variables that are propagated through,
  40987. // i.e. an reference inside the scope points to a declaration outside the scope.
  40988. // This is used to mark "taint" the name since adding a new variable in the scope,
  40989. // with a propagated name, would change the meaning of the existing references.
  40990. //
  40991. // catch(e) is special because even though e is a variable in its own scope,
  40992. // we want to make sure that catch(e){let e} is never transformed to
  40993. // catch(e){var e} (but rather var e$0). For that reason we taint the use of e
  40994. // in the closest hoist-scope, i.e. where var e$0 belongs.
  40995. node.$scope.closestHoistScope().markPropagates(identifier.name);
  40996. }
  40997. }
  40998. function createTopScope(programScope, environments, globals) {
  40999. function inject(obj) {
  41000. for (var name in obj) {
  41001. var writeable = obj[name];
  41002. var kind = (writeable ? "var" : "const");
  41003. if (topScope.hasOwn(name)) {
  41004. topScope.remove(name);
  41005. }
  41006. topScope.add(name, kind, {loc: {start: {line: -1}}}, -1);
  41007. }
  41008. }
  41009. var topScope = new Scope({
  41010. kind: "hoist",
  41011. node: {},
  41012. parent: null,
  41013. });
  41014. var complementary = {
  41015. undefined: false,
  41016. Infinity: false,
  41017. console: false,
  41018. };
  41019. inject(complementary);
  41020. inject(jshint_vars.reservedVars);
  41021. inject(jshint_vars.ecmaIdentifiers);
  41022. if (environments) {
  41023. environments.forEach(function(env) {
  41024. if (!jshint_vars[env]) {
  41025. error(-1, 'environment "{0}" not found', env);
  41026. } else {
  41027. inject(jshint_vars[env]);
  41028. }
  41029. });
  41030. }
  41031. if (globals) {
  41032. inject(globals);
  41033. }
  41034. // link it in
  41035. programScope.parent = topScope;
  41036. topScope.children.push(programScope);
  41037. return topScope;
  41038. }
  41039. function setupReferences(ast, allIdentifiers, opts) {
  41040. var analyze = (is.own(opts, "analyze") ? opts.analyze : true);
  41041. function visit(node) {
  41042. if (!isReference(node)) {
  41043. return;
  41044. }
  41045. allIdentifiers.add(node.name);
  41046. var scope = node.$scope.lookup(node.name);
  41047. if (analyze && !scope && options.disallowUnknownReferences) {
  41048. error(getline(node), "reference to unknown global variable {0}", node.name);
  41049. }
  41050. // check const and let for referenced-before-declaration
  41051. if (analyze && scope && is.someof(scope.getKind(node.name), ["const", "let"])) {
  41052. var allowedFromPos = scope.getFromPos(node.name);
  41053. var referencedAtPos = node.range[0];
  41054. assert(is.finitenumber(allowedFromPos));
  41055. assert(is.finitenumber(referencedAtPos));
  41056. if (referencedAtPos < allowedFromPos) {
  41057. if (!node.$scope.hasFunctionScopeBetween(scope)) {
  41058. error(getline(node), "{0} is referenced before its declaration", node.name);
  41059. }
  41060. }
  41061. }
  41062. node.$refToScope = scope;
  41063. }
  41064. traverse(ast, {pre: visit});
  41065. }
  41066. // TODO for loops init and body props are parallel to each other but init scope is outer that of body
  41067. // TODO is this a problem?
  41068. function varify(ast, stats, allIdentifiers, changes) {
  41069. function unique(name) {
  41070. assert(allIdentifiers.has(name));
  41071. for (var cnt = 0; ; cnt++) {
  41072. var genName = name + "$" + String(cnt);
  41073. if (!allIdentifiers.has(genName)) {
  41074. return genName;
  41075. }
  41076. }
  41077. }
  41078. function renameDeclarations(node) {
  41079. if (node.type === "VariableDeclaration" && isConstLet(node.kind)) {
  41080. var hoistScope = node.$scope.closestHoistScope();
  41081. var origScope = node.$scope;
  41082. // text change const|let => var
  41083. changes.push({
  41084. start: node.range[0],
  41085. end: node.range[0] + node.kind.length,
  41086. str: "var",
  41087. });
  41088. node.declarations.forEach(function(declarator) {
  41089. assert(declarator.type === "VariableDeclarator");
  41090. var name = declarator.id.name;
  41091. stats.declarator(node.kind);
  41092. // rename if
  41093. // 1) name already exists in hoistScope, or
  41094. // 2) name is already propagated (passed) through hoistScope or manually tainted
  41095. var rename = (origScope !== hoistScope &&
  41096. (hoistScope.hasOwn(name) || hoistScope.doesPropagate(name)));
  41097. var newName = (rename ? unique(name) : name);
  41098. origScope.remove(name);
  41099. hoistScope.add(newName, "var", declarator.id, declarator.range[1]);
  41100. origScope.moves = origScope.moves || stringmap();
  41101. origScope.moves.set(name, {
  41102. name: newName,
  41103. scope: hoistScope,
  41104. });
  41105. allIdentifiers.add(newName);
  41106. if (newName !== name) {
  41107. stats.rename(name, newName, getline(declarator));
  41108. declarator.id.originalName = name;
  41109. declarator.id.name = newName;
  41110. // textchange var x => var x$1
  41111. changes.push({
  41112. start: declarator.id.range[0],
  41113. end: declarator.id.range[1],
  41114. str: newName,
  41115. });
  41116. }
  41117. });
  41118. // ast change const|let => var
  41119. node.kind = "var";
  41120. }
  41121. }
  41122. function renameReferences(node) {
  41123. if (!node.$refToScope) {
  41124. return;
  41125. }
  41126. var move = node.$refToScope.moves && node.$refToScope.moves.get(node.name);
  41127. if (!move) {
  41128. return;
  41129. }
  41130. node.$refToScope = move.scope;
  41131. if (node.name !== move.name) {
  41132. node.originalName = node.name;
  41133. node.name = move.name;
  41134. if (node.alterop) {
  41135. // node has no range because it is the result of another alter operation
  41136. var existingOp = null;
  41137. for (var i = 0; i < changes.length; i++) {
  41138. var op = changes[i];
  41139. if (op.node === node) {
  41140. existingOp = op;
  41141. break;
  41142. }
  41143. }
  41144. assert(existingOp);
  41145. // modify op
  41146. existingOp.str = move.name;
  41147. } else {
  41148. changes.push({
  41149. start: node.range[0],
  41150. end: node.range[1],
  41151. str: move.name,
  41152. });
  41153. }
  41154. }
  41155. }
  41156. traverse(ast, {pre: renameDeclarations});
  41157. traverse(ast, {pre: renameReferences});
  41158. ast.$scope.traverse({pre: function(scope) {
  41159. delete scope.moves;
  41160. }});
  41161. }
  41162. function detectLoopClosures(ast) {
  41163. traverse(ast, {pre: visit});
  41164. function detectIifyBodyBlockers(body, node) {
  41165. return breakable(function(brk) {
  41166. traverse(body, {pre: function(n) {
  41167. // if we hit an inner function of the loop body, don't traverse further
  41168. if (isFunction(n)) {
  41169. return false;
  41170. }
  41171. var err = true; // reset to false in else-statement below
  41172. var msg = "loop-variable {0} is captured by a loop-closure that can't be transformed due to use of {1} at line {2}";
  41173. if (n.type === "BreakStatement") {
  41174. error(getline(node), msg, node.name, "break", getline(n));
  41175. } else if (n.type === "ContinueStatement") {
  41176. error(getline(node), msg, node.name, "continue", getline(n));
  41177. } else if (n.type === "ReturnStatement") {
  41178. error(getline(node), msg, node.name, "return", getline(n));
  41179. } else if (n.type === "YieldExpression") {
  41180. error(getline(node), msg, node.name, "yield", getline(n));
  41181. } else if (n.type === "Identifier" && n.name === "arguments") {
  41182. error(getline(node), msg, node.name, "arguments", getline(n));
  41183. } else if (n.type === "VariableDeclaration" && n.kind === "var") {
  41184. error(getline(node), msg, node.name, "var", getline(n));
  41185. } else {
  41186. err = false;
  41187. }
  41188. if (err) {
  41189. brk(true); // break traversal
  41190. }
  41191. }});
  41192. return false;
  41193. });
  41194. }
  41195. function visit(node) {
  41196. // forbidden pattern:
  41197. // <any>* <loop> <non-fn>* <constlet-def> <any>* <fn> <any>* <constlet-ref>
  41198. var loopNode = null;
  41199. if (isReference(node) && node.$refToScope && isConstLet(node.$refToScope.getKind(node.name))) {
  41200. // traverse nodes up towards root from constlet-def
  41201. // if we hit a function (before a loop) - ok!
  41202. // if we hit a loop - maybe-ouch
  41203. // if we reach root - ok!
  41204. for (var n = node.$refToScope.node; ; ) {
  41205. if (isFunction(n)) {
  41206. // we're ok (function-local)
  41207. return;
  41208. } else if (isLoop(n)) {
  41209. loopNode = n;
  41210. // maybe not ok (between loop and function)
  41211. break;
  41212. }
  41213. n = n.$parent;
  41214. if (!n) {
  41215. // ok (reached root)
  41216. return;
  41217. }
  41218. }
  41219. assert(isLoop(loopNode));
  41220. // traverse scopes from reference-scope up towards definition-scope
  41221. // if we hit a function, ouch!
  41222. var defScope = node.$refToScope;
  41223. var generateIIFE = (options.loopClosures === "iife");
  41224. for (var s = node.$scope; s; s = s.parent) {
  41225. if (s === defScope) {
  41226. // we're ok
  41227. return;
  41228. } else if (isFunction(s.node)) {
  41229. // not ok (there's a function between the reference and definition)
  41230. // may be transformable via IIFE
  41231. if (!generateIIFE) {
  41232. var msg = "loop-variable {0} is captured by a loop-closure. Tried \"loopClosures\": \"iife\" in defs-config.json?";
  41233. return error(getline(node), msg, node.name);
  41234. }
  41235. // here be dragons
  41236. // for (let x = ..; .. ; ..) { (function(){x})() } is forbidden because of current
  41237. // spec and VM status
  41238. if (loopNode.type === "ForStatement" && defScope.node === loopNode) {
  41239. var declarationNode = defScope.getNode(node.name);
  41240. return error(getline(declarationNode), "Not yet specced ES6 feature. {0} is declared in for-loop header and then captured in loop closure", declarationNode.name);
  41241. }
  41242. // speak now or forever hold your peace
  41243. if (detectIifyBodyBlockers(loopNode.body, node)) {
  41244. // error already generated
  41245. return;
  41246. }
  41247. // mark loop for IIFE-insertion
  41248. loopNode.$iify = true;
  41249. }
  41250. }
  41251. }
  41252. }
  41253. }
  41254. function transformLoopClosures(root, ops, options) {
  41255. function insertOp(pos, str, node) {
  41256. var op = {
  41257. start: pos,
  41258. end: pos,
  41259. str: str,
  41260. }
  41261. if (node) {
  41262. op.node = node;
  41263. }
  41264. ops.push(op);
  41265. }
  41266. traverse(root, {pre: function(node) {
  41267. if (!node.$iify) {
  41268. return;
  41269. }
  41270. var hasBlock = (node.body.type === "BlockStatement");
  41271. var insertHead = (hasBlock ?
  41272. node.body.range[0] + 1 : // just after body {
  41273. node.body.range[0]); // just before existing expression
  41274. var insertFoot = (hasBlock ?
  41275. node.body.range[1] - 1 : // just before body }
  41276. node.body.range[1]); // just after existing expression
  41277. var forInName = (isForInOf(node) && node.left.declarations[0].id.name);;
  41278. var iifeHead = fmt("(function({0}){", forInName ? forInName : "");
  41279. var iifeTail = fmt("}).call(this{0});", forInName ? ", " + forInName : "");
  41280. // modify AST
  41281. var iifeFragment = options.parse(iifeHead + iifeTail);
  41282. var iifeExpressionStatement = iifeFragment.body[0];
  41283. var iifeBlockStatement = iifeExpressionStatement.expression.callee.object.body;
  41284. if (hasBlock) {
  41285. var forBlockStatement = node.body;
  41286. var tmp = forBlockStatement.body;
  41287. forBlockStatement.body = [iifeExpressionStatement];
  41288. iifeBlockStatement.body = tmp;
  41289. } else {
  41290. var tmp$0 = node.body;
  41291. node.body = iifeExpressionStatement;
  41292. iifeBlockStatement.body[0] = tmp$0;
  41293. }
  41294. // create ops
  41295. insertOp(insertHead, iifeHead);
  41296. if (forInName) {
  41297. insertOp(insertFoot, "}).call(this, ");
  41298. var args = iifeExpressionStatement.expression.arguments;
  41299. var iifeArgumentIdentifier = args[1];
  41300. iifeArgumentIdentifier.alterop = true;
  41301. insertOp(insertFoot, forInName, iifeArgumentIdentifier);
  41302. insertOp(insertFoot, ");");
  41303. } else {
  41304. insertOp(insertFoot, iifeTail);
  41305. }
  41306. }});
  41307. }
  41308. function detectConstAssignment(ast) {
  41309. traverse(ast, {pre: function(node) {
  41310. if (isLvalue(node)) {
  41311. var scope = node.$scope.lookup(node.name);
  41312. if (scope && scope.getKind(node.name) === "const") {
  41313. error(getline(node), "can't assign to const variable {0}", node.name);
  41314. }
  41315. }
  41316. }});
  41317. }
  41318. function detectConstantLets(ast) {
  41319. traverse(ast, {pre: function(node) {
  41320. if (isLvalue(node)) {
  41321. var scope = node.$scope.lookup(node.name);
  41322. if (scope) {
  41323. scope.markWrite(node.name);
  41324. }
  41325. }
  41326. }});
  41327. ast.$scope.detectUnmodifiedLets();
  41328. }
  41329. function setupScopeAndReferences(root, opts) {
  41330. // setup scopes
  41331. traverse(root, {pre: createScopes});
  41332. var topScope = createTopScope(root.$scope, options.environments, options.globals);
  41333. // allIdentifiers contains all declared and referenced vars
  41334. // collect all declaration names (including those in topScope)
  41335. var allIdentifiers = stringset();
  41336. topScope.traverse({pre: function(scope) {
  41337. allIdentifiers.addMany(scope.decls.keys());
  41338. }});
  41339. // setup node.$refToScope, check for errors.
  41340. // also collects all referenced names to allIdentifiers
  41341. setupReferences(root, allIdentifiers, opts);
  41342. return allIdentifiers;
  41343. }
  41344. function cleanupTree(root) {
  41345. traverse(root, {pre: function(node) {
  41346. for (var prop in node) {
  41347. if (prop[0] === "$") {
  41348. delete node[prop];
  41349. }
  41350. }
  41351. }});
  41352. }
  41353. function run(src, config) {
  41354. // alter the options singleton with user configuration
  41355. for (var key in config) {
  41356. options[key] = config[key];
  41357. }
  41358. var parsed;
  41359. if (is.object(src)) {
  41360. if (!options.ast) {
  41361. return {
  41362. errors: [
  41363. "Can't produce string output when input is an AST. " +
  41364. "Did you forget to set options.ast = true?"
  41365. ],
  41366. };
  41367. }
  41368. // Received an AST object as src, so no need to parse it.
  41369. parsed = src;
  41370. } else if (is.string(src)) {
  41371. try {
  41372. parsed = options.parse(src, {
  41373. loc: true,
  41374. range: true,
  41375. });
  41376. } catch (e) {
  41377. return {
  41378. errors: [
  41379. fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}",
  41380. e.lineNumber,
  41381. e.column,
  41382. src.split("\n")[e.lineNumber - 1],
  41383. fmt.repeat(" ", e.column - 1) + "^")
  41384. ],
  41385. };
  41386. }
  41387. } else {
  41388. return {
  41389. errors: ["Input was neither an AST object nor a string."],
  41390. };
  41391. }
  41392. var ast = parsed;
  41393. // TODO detect unused variables (never read)
  41394. error.reset();
  41395. var allIdentifiers = setupScopeAndReferences(ast, {});
  41396. // static analysis passes
  41397. detectLoopClosures(ast);
  41398. detectConstAssignment(ast);
  41399. //detectConstantLets(ast);
  41400. var changes = [];
  41401. transformLoopClosures(ast, changes, options);
  41402. //ast.$scope.print(); process.exit(-1);
  41403. if (error.errors.length >= 1) {
  41404. return {
  41405. errors: error.errors,
  41406. };
  41407. }
  41408. if (changes.length > 0) {
  41409. cleanupTree(ast);
  41410. allIdentifiers = setupScopeAndReferences(ast, {analyze: false});
  41411. }
  41412. assert(error.errors.length === 0);
  41413. // change constlet declarations to var, renamed if needed
  41414. // varify modifies the scopes and AST accordingly and
  41415. // returns a list of change fragments (to use with alter)
  41416. var stats = new Stats();
  41417. varify(ast, stats, allIdentifiers, changes);
  41418. if (options.ast) {
  41419. // return the modified AST instead of src code
  41420. // get rid of all added $ properties first, such as $parent and $scope
  41421. cleanupTree(ast);
  41422. return {
  41423. stats: stats,
  41424. ast: ast,
  41425. };
  41426. } else {
  41427. // apply changes produced by varify and return the transformed src
  41428. var transformedSrc = alter(src, changes);
  41429. return {
  41430. stats: stats,
  41431. src: transformedSrc,
  41432. };
  41433. }
  41434. }
  41435. module.exports = run;
  41436. },{"./error":444,"./jshint_globals/vars.js":445,"./options":446,"./scope":447,"./stats":448,"alter":449,"assert":190,"ast-traverse":451,"breakable":452,"simple-fmt":454,"simple-is":455,"stringmap":456,"stringset":457}],444:[function(require,module,exports){
  41437. "use strict";
  41438. var fmt = require("simple-fmt");
  41439. var assert = require("assert");
  41440. function error(line, var_args) {
  41441. assert(arguments.length >= 2);
  41442. var msg = (arguments.length === 2 ?
  41443. String(var_args) : fmt.apply(fmt, Array.prototype.slice.call(arguments, 1)));
  41444. error.errors.push(line === -1 ? msg : fmt("line {0}: {1}", line, msg));
  41445. }
  41446. error.reset = function() {
  41447. error.errors = [];
  41448. };
  41449. error.getline = function(node) {
  41450. if (node && node.loc && node.loc.start) {
  41451. return node.loc.start.line;
  41452. }
  41453. return -1;
  41454. };
  41455. error.reset();
  41456. module.exports = error;
  41457. },{"assert":190,"simple-fmt":454}],445:[function(require,module,exports){
  41458. // jshint -W001
  41459. "use strict";
  41460. // Identifiers provided by the ECMAScript standard.
  41461. exports.reservedVars = {
  41462. arguments : false,
  41463. NaN : false
  41464. };
  41465. exports.ecmaIdentifiers = {
  41466. Array : false,
  41467. Boolean : false,
  41468. Date : false,
  41469. decodeURI : false,
  41470. decodeURIComponent : false,
  41471. encodeURI : false,
  41472. encodeURIComponent : false,
  41473. Error : false,
  41474. "eval" : false,
  41475. EvalError : false,
  41476. Function : false,
  41477. hasOwnProperty : false,
  41478. isFinite : false,
  41479. isNaN : false,
  41480. JSON : false,
  41481. Math : false,
  41482. Map : false,
  41483. Number : false,
  41484. Object : false,
  41485. parseInt : false,
  41486. parseFloat : false,
  41487. RangeError : false,
  41488. ReferenceError : false,
  41489. RegExp : false,
  41490. Set : false,
  41491. String : false,
  41492. SyntaxError : false,
  41493. TypeError : false,
  41494. URIError : false,
  41495. WeakMap : false
  41496. };
  41497. // Global variables commonly provided by a web browser environment.
  41498. exports.browser = {
  41499. ArrayBuffer : false,
  41500. ArrayBufferView : false,
  41501. Audio : false,
  41502. Blob : false,
  41503. addEventListener : false,
  41504. applicationCache : false,
  41505. atob : false,
  41506. blur : false,
  41507. btoa : false,
  41508. clearInterval : false,
  41509. clearTimeout : false,
  41510. close : false,
  41511. closed : false,
  41512. DataView : false,
  41513. DOMParser : false,
  41514. defaultStatus : false,
  41515. document : false,
  41516. Element : false,
  41517. event : false,
  41518. FileReader : false,
  41519. Float32Array : false,
  41520. Float64Array : false,
  41521. FormData : false,
  41522. focus : false,
  41523. frames : false,
  41524. getComputedStyle : false,
  41525. HTMLElement : false,
  41526. HTMLAnchorElement : false,
  41527. HTMLBaseElement : false,
  41528. HTMLBlockquoteElement: false,
  41529. HTMLBodyElement : false,
  41530. HTMLBRElement : false,
  41531. HTMLButtonElement : false,
  41532. HTMLCanvasElement : false,
  41533. HTMLDirectoryElement : false,
  41534. HTMLDivElement : false,
  41535. HTMLDListElement : false,
  41536. HTMLFieldSetElement : false,
  41537. HTMLFontElement : false,
  41538. HTMLFormElement : false,
  41539. HTMLFrameElement : false,
  41540. HTMLFrameSetElement : false,
  41541. HTMLHeadElement : false,
  41542. HTMLHeadingElement : false,
  41543. HTMLHRElement : false,
  41544. HTMLHtmlElement : false,
  41545. HTMLIFrameElement : false,
  41546. HTMLImageElement : false,
  41547. HTMLInputElement : false,
  41548. HTMLIsIndexElement : false,
  41549. HTMLLabelElement : false,
  41550. HTMLLayerElement : false,
  41551. HTMLLegendElement : false,
  41552. HTMLLIElement : false,
  41553. HTMLLinkElement : false,
  41554. HTMLMapElement : false,
  41555. HTMLMenuElement : false,
  41556. HTMLMetaElement : false,
  41557. HTMLModElement : false,
  41558. HTMLObjectElement : false,
  41559. HTMLOListElement : false,
  41560. HTMLOptGroupElement : false,
  41561. HTMLOptionElement : false,
  41562. HTMLParagraphElement : false,
  41563. HTMLParamElement : false,
  41564. HTMLPreElement : false,
  41565. HTMLQuoteElement : false,
  41566. HTMLScriptElement : false,
  41567. HTMLSelectElement : false,
  41568. HTMLStyleElement : false,
  41569. HTMLTableCaptionElement: false,
  41570. HTMLTableCellElement : false,
  41571. HTMLTableColElement : false,
  41572. HTMLTableElement : false,
  41573. HTMLTableRowElement : false,
  41574. HTMLTableSectionElement: false,
  41575. HTMLTextAreaElement : false,
  41576. HTMLTitleElement : false,
  41577. HTMLUListElement : false,
  41578. HTMLVideoElement : false,
  41579. history : false,
  41580. Int16Array : false,
  41581. Int32Array : false,
  41582. Int8Array : false,
  41583. Image : false,
  41584. length : false,
  41585. localStorage : false,
  41586. location : false,
  41587. MessageChannel : false,
  41588. MessageEvent : false,
  41589. MessagePort : false,
  41590. moveBy : false,
  41591. moveTo : false,
  41592. MutationObserver : false,
  41593. name : false,
  41594. Node : false,
  41595. NodeFilter : false,
  41596. navigator : false,
  41597. onbeforeunload : true,
  41598. onblur : true,
  41599. onerror : true,
  41600. onfocus : true,
  41601. onload : true,
  41602. onresize : true,
  41603. onunload : true,
  41604. open : false,
  41605. openDatabase : false,
  41606. opener : false,
  41607. Option : false,
  41608. parent : false,
  41609. print : false,
  41610. removeEventListener : false,
  41611. resizeBy : false,
  41612. resizeTo : false,
  41613. screen : false,
  41614. scroll : false,
  41615. scrollBy : false,
  41616. scrollTo : false,
  41617. sessionStorage : false,
  41618. setInterval : false,
  41619. setTimeout : false,
  41620. SharedWorker : false,
  41621. status : false,
  41622. top : false,
  41623. Uint16Array : false,
  41624. Uint32Array : false,
  41625. Uint8Array : false,
  41626. Uint8ClampedArray : false,
  41627. WebSocket : false,
  41628. window : false,
  41629. Worker : false,
  41630. XMLHttpRequest : false,
  41631. XMLSerializer : false,
  41632. XPathEvaluator : false,
  41633. XPathException : false,
  41634. XPathExpression : false,
  41635. XPathNamespace : false,
  41636. XPathNSResolver : false,
  41637. XPathResult : false
  41638. };
  41639. exports.devel = {
  41640. alert : false,
  41641. confirm: false,
  41642. console: false,
  41643. Debug : false,
  41644. opera : false,
  41645. prompt : false
  41646. };
  41647. exports.worker = {
  41648. importScripts: true,
  41649. postMessage : true,
  41650. self : true
  41651. };
  41652. // Widely adopted global names that are not part of ECMAScript standard
  41653. exports.nonstandard = {
  41654. escape : false,
  41655. unescape: false
  41656. };
  41657. // Globals provided by popular JavaScript environments.
  41658. exports.couch = {
  41659. "require" : false,
  41660. respond : false,
  41661. getRow : false,
  41662. emit : false,
  41663. send : false,
  41664. start : false,
  41665. sum : false,
  41666. log : false,
  41667. exports : false,
  41668. module : false,
  41669. provides : false
  41670. };
  41671. exports.node = {
  41672. __filename : false,
  41673. __dirname : false,
  41674. Buffer : false,
  41675. DataView : false,
  41676. console : false,
  41677. exports : true, // In Node it is ok to exports = module.exports = foo();
  41678. GLOBAL : false,
  41679. global : false,
  41680. module : false,
  41681. process : false,
  41682. require : false,
  41683. setTimeout : false,
  41684. clearTimeout : false,
  41685. setInterval : false,
  41686. clearInterval: false
  41687. };
  41688. exports.phantom = {
  41689. phantom : true,
  41690. require : true,
  41691. WebPage : true
  41692. };
  41693. exports.rhino = {
  41694. defineClass : false,
  41695. deserialize : false,
  41696. gc : false,
  41697. help : false,
  41698. importPackage: false,
  41699. "java" : false,
  41700. load : false,
  41701. loadClass : false,
  41702. print : false,
  41703. quit : false,
  41704. readFile : false,
  41705. readUrl : false,
  41706. runCommand : false,
  41707. seal : false,
  41708. serialize : false,
  41709. spawn : false,
  41710. sync : false,
  41711. toint32 : false,
  41712. version : false
  41713. };
  41714. exports.wsh = {
  41715. ActiveXObject : true,
  41716. Enumerator : true,
  41717. GetObject : true,
  41718. ScriptEngine : true,
  41719. ScriptEngineBuildVersion : true,
  41720. ScriptEngineMajorVersion : true,
  41721. ScriptEngineMinorVersion : true,
  41722. VBArray : true,
  41723. WSH : true,
  41724. WScript : true,
  41725. XDomainRequest : true
  41726. };
  41727. // Globals provided by popular JavaScript libraries.
  41728. exports.dojo = {
  41729. dojo : false,
  41730. dijit : false,
  41731. dojox : false,
  41732. define : false,
  41733. "require": false
  41734. };
  41735. exports.jquery = {
  41736. "$" : false,
  41737. jQuery : false
  41738. };
  41739. exports.mootools = {
  41740. "$" : false,
  41741. "$$" : false,
  41742. Asset : false,
  41743. Browser : false,
  41744. Chain : false,
  41745. Class : false,
  41746. Color : false,
  41747. Cookie : false,
  41748. Core : false,
  41749. Document : false,
  41750. DomReady : false,
  41751. DOMEvent : false,
  41752. DOMReady : false,
  41753. Drag : false,
  41754. Element : false,
  41755. Elements : false,
  41756. Event : false,
  41757. Events : false,
  41758. Fx : false,
  41759. Group : false,
  41760. Hash : false,
  41761. HtmlTable : false,
  41762. Iframe : false,
  41763. IframeShim : false,
  41764. InputValidator: false,
  41765. instanceOf : false,
  41766. Keyboard : false,
  41767. Locale : false,
  41768. Mask : false,
  41769. MooTools : false,
  41770. Native : false,
  41771. Options : false,
  41772. OverText : false,
  41773. Request : false,
  41774. Scroller : false,
  41775. Slick : false,
  41776. Slider : false,
  41777. Sortables : false,
  41778. Spinner : false,
  41779. Swiff : false,
  41780. Tips : false,
  41781. Type : false,
  41782. typeOf : false,
  41783. URI : false,
  41784. Window : false
  41785. };
  41786. exports.prototypejs = {
  41787. "$" : false,
  41788. "$$" : false,
  41789. "$A" : false,
  41790. "$F" : false,
  41791. "$H" : false,
  41792. "$R" : false,
  41793. "$break" : false,
  41794. "$continue" : false,
  41795. "$w" : false,
  41796. Abstract : false,
  41797. Ajax : false,
  41798. Class : false,
  41799. Enumerable : false,
  41800. Element : false,
  41801. Event : false,
  41802. Field : false,
  41803. Form : false,
  41804. Hash : false,
  41805. Insertion : false,
  41806. ObjectRange : false,
  41807. PeriodicalExecuter: false,
  41808. Position : false,
  41809. Prototype : false,
  41810. Selector : false,
  41811. Template : false,
  41812. Toggle : false,
  41813. Try : false,
  41814. Autocompleter : false,
  41815. Builder : false,
  41816. Control : false,
  41817. Draggable : false,
  41818. Draggables : false,
  41819. Droppables : false,
  41820. Effect : false,
  41821. Sortable : false,
  41822. SortableObserver : false,
  41823. Sound : false,
  41824. Scriptaculous : false
  41825. };
  41826. exports.yui = {
  41827. YUI : false,
  41828. Y : false,
  41829. YUI_config: false
  41830. };
  41831. },{}],446:[function(require,module,exports){
  41832. // default configuration
  41833. module.exports = {
  41834. disallowVars: false,
  41835. disallowDuplicated: true,
  41836. disallowUnknownReferences: true,
  41837. parse: require("esprima-fb").parse,
  41838. };
  41839. },{"esprima-fb":453}],447:[function(require,module,exports){
  41840. "use strict";
  41841. var assert = require("assert");
  41842. var stringmap = require("stringmap");
  41843. var stringset = require("stringset");
  41844. var is = require("simple-is");
  41845. var fmt = require("simple-fmt");
  41846. var error = require("./error");
  41847. var getline = error.getline;
  41848. var options = require("./options");
  41849. function Scope(args) {
  41850. assert(is.someof(args.kind, ["hoist", "block", "catch-block"]));
  41851. assert(is.object(args.node));
  41852. assert(args.parent === null || is.object(args.parent));
  41853. // kind === "hoist": function scopes, program scope, injected globals
  41854. // kind === "block": ES6 block scopes
  41855. // kind === "catch-block": catch block scopes
  41856. this.kind = args.kind;
  41857. // the AST node the block corresponds to
  41858. this.node = args.node;
  41859. // parent scope
  41860. this.parent = args.parent;
  41861. // children scopes for easier traversal (populated internally)
  41862. this.children = [];
  41863. // scope declarations. decls[variable_name] = {
  41864. // kind: "fun" for functions,
  41865. // "param" for function parameters,
  41866. // "caught" for catch parameter
  41867. // "var",
  41868. // "const",
  41869. // "let"
  41870. // node: the AST node the declaration corresponds to
  41871. // from: source code index from which it is visible at earliest
  41872. // (only stored for "const", "let" [and "var"] nodes)
  41873. // }
  41874. this.decls = stringmap();
  41875. // names of all declarations within this scope that was ever written
  41876. // TODO move to decls.w?
  41877. // TODO create corresponding read?
  41878. this.written = stringset();
  41879. // names of all variables declared outside this hoist scope but
  41880. // referenced in this scope (immediately or in child).
  41881. // only stored on hoist scopes for efficiency
  41882. // (because we currently generate lots of empty block scopes)
  41883. this.propagates = (this.kind === "hoist" ? stringset() : null);
  41884. // scopes register themselves with their parents for easier traversal
  41885. if (this.parent) {
  41886. this.parent.children.push(this);
  41887. }
  41888. }
  41889. Scope.prototype.print = function(indent) {
  41890. indent = indent || 0;
  41891. var scope = this;
  41892. var names = this.decls.keys().map(function(name) {
  41893. return fmt("{0} [{1}]", name, scope.decls.get(name).kind);
  41894. }).join(", ");
  41895. var propagates = this.propagates ? this.propagates.items().join(", ") : "";
  41896. console.log(fmt("{0}{1}: {2}. propagates: {3}", fmt.repeat(" ", indent), this.node.type, names, propagates));
  41897. this.children.forEach(function(c) {
  41898. c.print(indent + 2);
  41899. });
  41900. };
  41901. Scope.prototype.add = function(name, kind, node, referableFromPos) {
  41902. assert(is.someof(kind, ["fun", "param", "var", "caught", "const", "let"]));
  41903. function isConstLet(kind) {
  41904. return is.someof(kind, ["const", "let"]);
  41905. }
  41906. var scope = this;
  41907. // search nearest hoist-scope for fun, param and var's
  41908. // const, let and caught variables go directly in the scope (which may be hoist, block or catch-block)
  41909. if (is.someof(kind, ["fun", "param", "var"])) {
  41910. while (scope.kind !== "hoist") {
  41911. if (scope.decls.has(name) && isConstLet(scope.decls.get(name).kind)) { // could be caught
  41912. return error(getline(node), "{0} is already declared", name);
  41913. }
  41914. scope = scope.parent;
  41915. }
  41916. }
  41917. // name exists in scope and either new or existing kind is const|let => error
  41918. if (scope.decls.has(name) && (options.disallowDuplicated || isConstLet(scope.decls.get(name).kind) || isConstLet(kind))) {
  41919. return error(getline(node), "{0} is already declared", name);
  41920. }
  41921. var declaration = {
  41922. kind: kind,
  41923. node: node,
  41924. };
  41925. if (referableFromPos) {
  41926. assert(is.someof(kind, ["var", "const", "let"]));
  41927. declaration.from = referableFromPos;
  41928. }
  41929. scope.decls.set(name, declaration);
  41930. };
  41931. Scope.prototype.getKind = function(name) {
  41932. assert(is.string(name));
  41933. var decl = this.decls.get(name);
  41934. return decl ? decl.kind : null;
  41935. };
  41936. Scope.prototype.getNode = function(name) {
  41937. assert(is.string(name));
  41938. var decl = this.decls.get(name);
  41939. return decl ? decl.node : null;
  41940. };
  41941. Scope.prototype.getFromPos = function(name) {
  41942. assert(is.string(name));
  41943. var decl = this.decls.get(name);
  41944. return decl ? decl.from : null;
  41945. };
  41946. Scope.prototype.hasOwn = function(name) {
  41947. return this.decls.has(name);
  41948. };
  41949. Scope.prototype.remove = function(name) {
  41950. return this.decls.remove(name);
  41951. };
  41952. Scope.prototype.doesPropagate = function(name) {
  41953. return this.propagates.has(name);
  41954. };
  41955. Scope.prototype.markPropagates = function(name) {
  41956. this.propagates.add(name);
  41957. };
  41958. Scope.prototype.closestHoistScope = function() {
  41959. var scope = this;
  41960. while (scope.kind !== "hoist") {
  41961. scope = scope.parent;
  41962. }
  41963. return scope;
  41964. };
  41965. Scope.prototype.hasFunctionScopeBetween = function(outer) {
  41966. function isFunction(node) {
  41967. return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]);
  41968. }
  41969. for (var scope = this; scope; scope = scope.parent) {
  41970. if (scope === outer) {
  41971. return false;
  41972. }
  41973. if (isFunction(scope.node)) {
  41974. return true;
  41975. }
  41976. }
  41977. throw new Error("wasn't inner scope of outer");
  41978. };
  41979. Scope.prototype.lookup = function(name) {
  41980. for (var scope = this; scope; scope = scope.parent) {
  41981. if (scope.decls.has(name)) {
  41982. return scope;
  41983. } else if (scope.kind === "hoist") {
  41984. scope.propagates.add(name);
  41985. }
  41986. }
  41987. return null;
  41988. };
  41989. Scope.prototype.markWrite = function(name) {
  41990. assert(is.string(name));
  41991. this.written.add(name);
  41992. };
  41993. // detects let variables that are never modified (ignores top-level)
  41994. Scope.prototype.detectUnmodifiedLets = function() {
  41995. var outmost = this;
  41996. function detect(scope) {
  41997. if (scope !== outmost) {
  41998. scope.decls.keys().forEach(function(name) {
  41999. if (scope.getKind(name) === "let" && !scope.written.has(name)) {
  42000. return error(getline(scope.getNode(name)), "{0} is declared as let but never modified so could be const", name);
  42001. }
  42002. });
  42003. }
  42004. scope.children.forEach(function(childScope) {
  42005. detect(childScope);
  42006. });
  42007. }
  42008. detect(this);
  42009. };
  42010. Scope.prototype.traverse = function(options) {
  42011. options = options || {};
  42012. var pre = options.pre;
  42013. var post = options.post;
  42014. function visit(scope) {
  42015. if (pre) {
  42016. pre(scope);
  42017. }
  42018. scope.children.forEach(function(childScope) {
  42019. visit(childScope);
  42020. });
  42021. if (post) {
  42022. post(scope);
  42023. }
  42024. }
  42025. visit(this);
  42026. };
  42027. module.exports = Scope;
  42028. },{"./error":444,"./options":446,"assert":190,"simple-fmt":454,"simple-is":455,"stringmap":456,"stringset":457}],448:[function(require,module,exports){
  42029. var fmt = require("simple-fmt");
  42030. var is = require("simple-is");
  42031. var assert = require("assert");
  42032. function Stats() {
  42033. this.lets = 0;
  42034. this.consts = 0;
  42035. this.renames = [];
  42036. }
  42037. Stats.prototype.declarator = function(kind) {
  42038. assert(is.someof(kind, ["const", "let"]));
  42039. if (kind === "const") {
  42040. this.consts++;
  42041. } else {
  42042. this.lets++;
  42043. }
  42044. };
  42045. Stats.prototype.rename = function(oldName, newName, line) {
  42046. this.renames.push({
  42047. oldName: oldName,
  42048. newName: newName,
  42049. line: line,
  42050. });
  42051. };
  42052. Stats.prototype.toString = function() {
  42053. // console.log("defs.js stats for file {0}:", filename)
  42054. var renames = this.renames.map(function(r) {
  42055. return r;
  42056. }).sort(function(a, b) {
  42057. return a.line - b.line;
  42058. }); // sort a copy of renames
  42059. var renameStr = renames.map(function(rename) {
  42060. return fmt("\nline {0}: {1} => {2}", rename.line, rename.oldName, rename.newName);
  42061. }).join("");
  42062. var sum = this.consts + this.lets;
  42063. var constlets = (sum === 0 ?
  42064. "can't calculate const coverage (0 consts, 0 lets)" :
  42065. fmt("{0}% const coverage ({1} consts, {2} lets)",
  42066. Math.floor(100 * this.consts / sum), this.consts, this.lets));
  42067. return constlets + renameStr + "\n";
  42068. };
  42069. module.exports = Stats;
  42070. },{"assert":190,"simple-fmt":454,"simple-is":455}],449:[function(require,module,exports){
  42071. // alter.js
  42072. // MIT licensed, see LICENSE file
  42073. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  42074. var assert = require("assert");
  42075. var stableSort = require("stable");
  42076. // fragments is a list of {start: index, end: index, str: string to replace with}
  42077. function alter(str, fragments) {
  42078. "use strict";
  42079. var isArray = Array.isArray || function(v) {
  42080. return Object.prototype.toString.call(v) === "[object Array]";
  42081. };;
  42082. assert(typeof str === "string");
  42083. assert(isArray(fragments));
  42084. // stableSort isn't in-place so no need to copy array first
  42085. var sortedFragments = stableSort(fragments, function(a, b) {
  42086. return a.start - b.start;
  42087. });
  42088. var outs = [];
  42089. var pos = 0;
  42090. for (var i = 0; i < sortedFragments.length; i++) {
  42091. var frag = sortedFragments[i];
  42092. assert(pos <= frag.start);
  42093. assert(frag.start <= frag.end);
  42094. outs.push(str.slice(pos, frag.start));
  42095. outs.push(frag.str);
  42096. pos = frag.end;
  42097. }
  42098. if (pos < str.length) {
  42099. outs.push(str.slice(pos));
  42100. }
  42101. return outs.join("");
  42102. }
  42103. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  42104. module.exports = alter;
  42105. }
  42106. },{"assert":190,"stable":450}],450:[function(require,module,exports){
  42107. //! stable.js 0.1.5, https://github.com/Two-Screen/stable
  42108. //! © 2014 Angry Bytes and contributors. MIT licensed.
  42109. (function() {
  42110. // A stable array sort, because `Array#sort()` is not guaranteed stable.
  42111. // This is an implementation of merge sort, without recursion.
  42112. var stable = function(arr, comp) {
  42113. return exec(arr.slice(), comp);
  42114. };
  42115. stable.inplace = function(arr, comp) {
  42116. var result = exec(arr, comp);
  42117. // This simply copies back if the result isn't in the original array,
  42118. // which happens on an odd number of passes.
  42119. if (result !== arr) {
  42120. pass(result, null, arr.length, arr);
  42121. }
  42122. return arr;
  42123. };
  42124. // Execute the sort using the input array and a second buffer as work space.
  42125. // Returns one of those two, containing the final result.
  42126. function exec(arr, comp) {
  42127. if (typeof(comp) !== 'function') {
  42128. comp = function(a, b) {
  42129. return String(a).localeCompare(b);
  42130. };
  42131. }
  42132. // Short-circuit when there's nothing to sort.
  42133. var len = arr.length;
  42134. if (len <= 1) {
  42135. return arr;
  42136. }
  42137. // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
  42138. // Chunks are the size of the left or right hand in merge sort.
  42139. // Stop when the left-hand covers all of the array.
  42140. var buffer = new Array(len);
  42141. for (var chk = 1; chk < len; chk *= 2) {
  42142. pass(arr, comp, chk, buffer);
  42143. var tmp = arr;
  42144. arr = buffer;
  42145. buffer = tmp;
  42146. }
  42147. return arr;
  42148. }
  42149. // Run a single pass with the given chunk size.
  42150. var pass = function(arr, comp, chk, result) {
  42151. var len = arr.length;
  42152. var i = 0;
  42153. // Step size / double chunk size.
  42154. var dbl = chk * 2;
  42155. // Bounds of the left and right chunks.
  42156. var l, r, e;
  42157. // Iterators over the left and right chunk.
  42158. var li, ri;
  42159. // Iterate over pairs of chunks.
  42160. for (l = 0; l < len; l += dbl) {
  42161. r = l + chk;
  42162. e = r + chk;
  42163. if (r > len) r = len;
  42164. if (e > len) e = len;
  42165. // Iterate both chunks in parallel.
  42166. li = l;
  42167. ri = r;
  42168. while (true) {
  42169. // Compare the chunks.
  42170. if (li < r && ri < e) {
  42171. // This works for a regular `sort()` compatible comparator,
  42172. // but also for a simple comparator like: `a > b`
  42173. if (comp(arr[li], arr[ri]) <= 0) {
  42174. result[i++] = arr[li++];
  42175. }
  42176. else {
  42177. result[i++] = arr[ri++];
  42178. }
  42179. }
  42180. // Nothing to compare, just flush what's left.
  42181. else if (li < r) {
  42182. result[i++] = arr[li++];
  42183. }
  42184. else if (ri < e) {
  42185. result[i++] = arr[ri++];
  42186. }
  42187. // Both iterators are at the chunk ends.
  42188. else {
  42189. break;
  42190. }
  42191. }
  42192. }
  42193. };
  42194. // Export using CommonJS or to the window.
  42195. if (typeof(module) !== 'undefined') {
  42196. module.exports = stable;
  42197. }
  42198. else {
  42199. window.stable = stable;
  42200. }
  42201. })();
  42202. },{}],451:[function(require,module,exports){
  42203. function traverse(root, options) {
  42204. "use strict";
  42205. options = options || {};
  42206. var pre = options.pre;
  42207. var post = options.post;
  42208. var skipProperty = options.skipProperty;
  42209. function visit(node, parent, prop, idx) {
  42210. if (!node || typeof node.type !== "string") {
  42211. return;
  42212. }
  42213. var res = undefined;
  42214. if (pre) {
  42215. res = pre(node, parent, prop, idx);
  42216. }
  42217. if (res !== false) {
  42218. for (var prop in node) {
  42219. if (skipProperty ? skipProperty(prop, node) : prop[0] === "$") {
  42220. continue;
  42221. }
  42222. var child = node[prop];
  42223. if (Array.isArray(child)) {
  42224. for (var i = 0; i < child.length; i++) {
  42225. visit(child[i], node, prop, i);
  42226. }
  42227. } else {
  42228. visit(child, node, prop);
  42229. }
  42230. }
  42231. }
  42232. if (post) {
  42233. post(node, parent, prop, idx);
  42234. }
  42235. }
  42236. visit(root, null);
  42237. };
  42238. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  42239. module.exports = traverse;
  42240. }
  42241. },{}],452:[function(require,module,exports){
  42242. // breakable.js
  42243. // MIT licensed, see LICENSE file
  42244. // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
  42245. var breakable = (function() {
  42246. "use strict";
  42247. function Val(val, brk) {
  42248. this.val = val;
  42249. this.brk = brk;
  42250. }
  42251. function make_brk() {
  42252. return function brk(val) {
  42253. throw new Val(val, brk);
  42254. };
  42255. }
  42256. function breakable(fn) {
  42257. var brk = make_brk();
  42258. try {
  42259. return fn(brk);
  42260. } catch (e) {
  42261. if (e instanceof Val && e.brk === brk) {
  42262. return e.val;
  42263. }
  42264. throw e;
  42265. }
  42266. }
  42267. return breakable;
  42268. })();
  42269. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  42270. module.exports = breakable;
  42271. }
  42272. },{}],453:[function(require,module,exports){
  42273. /*
  42274. Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
  42275. Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
  42276. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  42277. Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
  42278. Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
  42279. Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
  42280. Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
  42281. Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
  42282. Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
  42283. Redistribution and use in source and binary forms, with or without
  42284. modification, are permitted provided that the following conditions are met:
  42285. * Redistributions of source code must retain the above copyright
  42286. notice, this list of conditions and the following disclaimer.
  42287. * Redistributions in binary form must reproduce the above copyright
  42288. notice, this list of conditions and the following disclaimer in the
  42289. documentation and/or other materials provided with the distribution.
  42290. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  42291. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42292. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  42293. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  42294. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  42295. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42296. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  42297. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42298. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  42299. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42300. */
  42301. /*jslint bitwise:true plusplus:true */
  42302. /*global esprima:true, define:true, exports:true, window: true,
  42303. throwError: true, generateStatement: true, peek: true,
  42304. parseAssignmentExpression: true, parseBlock: true,
  42305. parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
  42306. parseDeclareClass: true, parseDeclareFunction: true,
  42307. parseDeclareModule: true, parseDeclareVariable: true,
  42308. parseForStatement: true,
  42309. parseFunctionDeclaration: true, parseFunctionExpression: true,
  42310. parseFunctionSourceElements: true, parseVariableIdentifier: true,
  42311. parseImportSpecifier: true, parseInterface: true,
  42312. parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
  42313. parseSpreadOrAssignmentExpression: true,
  42314. parseStatement: true, parseSourceElement: true, parseConciseBody: true,
  42315. advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
  42316. scanXJSStringLiteral: true, scanXJSIdentifier: true,
  42317. parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
  42318. parseFunctionTypeParam: true,
  42319. parsePrimaryType: true,
  42320. parseTypeAlias: true,
  42321. parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
  42322. parseYieldExpression: true, parseAwaitExpression: true
  42323. */
  42324. (function (root, factory) {
  42325. 'use strict';
  42326. // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
  42327. // Rhino, and plain browser loading.
  42328. if (typeof define === 'function' && define.amd) {
  42329. define(['exports'], factory);
  42330. } else if (typeof exports !== 'undefined') {
  42331. factory(exports);
  42332. } else {
  42333. factory((root.esprima = {}));
  42334. }
  42335. }(this, function (exports) {
  42336. 'use strict';
  42337. var Token,
  42338. TokenName,
  42339. FnExprTokens,
  42340. Syntax,
  42341. PropertyKind,
  42342. Messages,
  42343. Regex,
  42344. SyntaxTreeDelegate,
  42345. XHTMLEntities,
  42346. ClassPropertyType,
  42347. source,
  42348. strict,
  42349. index,
  42350. lineNumber,
  42351. lineStart,
  42352. length,
  42353. delegate,
  42354. lookahead,
  42355. state,
  42356. extra;
  42357. Token = {
  42358. BooleanLiteral: 1,
  42359. EOF: 2,
  42360. Identifier: 3,
  42361. Keyword: 4,
  42362. NullLiteral: 5,
  42363. NumericLiteral: 6,
  42364. Punctuator: 7,
  42365. StringLiteral: 8,
  42366. RegularExpression: 9,
  42367. Template: 10,
  42368. XJSIdentifier: 11,
  42369. XJSText: 12
  42370. };
  42371. TokenName = {};
  42372. TokenName[Token.BooleanLiteral] = 'Boolean';
  42373. TokenName[Token.EOF] = '<end>';
  42374. TokenName[Token.Identifier] = 'Identifier';
  42375. TokenName[Token.Keyword] = 'Keyword';
  42376. TokenName[Token.NullLiteral] = 'Null';
  42377. TokenName[Token.NumericLiteral] = 'Numeric';
  42378. TokenName[Token.Punctuator] = 'Punctuator';
  42379. TokenName[Token.StringLiteral] = 'String';
  42380. TokenName[Token.XJSIdentifier] = 'XJSIdentifier';
  42381. TokenName[Token.XJSText] = 'XJSText';
  42382. TokenName[Token.RegularExpression] = 'RegularExpression';
  42383. // A function following one of those tokens is an expression.
  42384. FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
  42385. 'return', 'case', 'delete', 'throw', 'void',
  42386. // assignment operators
  42387. '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
  42388. '&=', '|=', '^=', ',',
  42389. // binary/unary operators
  42390. '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
  42391. '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
  42392. '<=', '<', '>', '!=', '!=='];
  42393. Syntax = {
  42394. AnyTypeAnnotation: 'AnyTypeAnnotation',
  42395. ArrayExpression: 'ArrayExpression',
  42396. ArrayPattern: 'ArrayPattern',
  42397. ArrayTypeAnnotation: 'ArrayTypeAnnotation',
  42398. ArrowFunctionExpression: 'ArrowFunctionExpression',
  42399. AssignmentExpression: 'AssignmentExpression',
  42400. BinaryExpression: 'BinaryExpression',
  42401. BlockStatement: 'BlockStatement',
  42402. BooleanTypeAnnotation: 'BooleanTypeAnnotation',
  42403. BreakStatement: 'BreakStatement',
  42404. CallExpression: 'CallExpression',
  42405. CatchClause: 'CatchClause',
  42406. ClassBody: 'ClassBody',
  42407. ClassDeclaration: 'ClassDeclaration',
  42408. ClassExpression: 'ClassExpression',
  42409. ClassImplements: 'ClassImplements',
  42410. ClassProperty: 'ClassProperty',
  42411. ComprehensionBlock: 'ComprehensionBlock',
  42412. ComprehensionExpression: 'ComprehensionExpression',
  42413. ConditionalExpression: 'ConditionalExpression',
  42414. ContinueStatement: 'ContinueStatement',
  42415. DebuggerStatement: 'DebuggerStatement',
  42416. DeclareClass: 'DeclareClass',
  42417. DeclareFunction: 'DeclareFunction',
  42418. DeclareModule: 'DeclareModule',
  42419. DeclareVariable: 'DeclareVariable',
  42420. DoWhileStatement: 'DoWhileStatement',
  42421. EmptyStatement: 'EmptyStatement',
  42422. ExportDeclaration: 'ExportDeclaration',
  42423. ExportBatchSpecifier: 'ExportBatchSpecifier',
  42424. ExportSpecifier: 'ExportSpecifier',
  42425. ExpressionStatement: 'ExpressionStatement',
  42426. ForInStatement: 'ForInStatement',
  42427. ForOfStatement: 'ForOfStatement',
  42428. ForStatement: 'ForStatement',
  42429. FunctionDeclaration: 'FunctionDeclaration',
  42430. FunctionExpression: 'FunctionExpression',
  42431. FunctionTypeAnnotation: 'FunctionTypeAnnotation',
  42432. FunctionTypeParam: 'FunctionTypeParam',
  42433. GenericTypeAnnotation: 'GenericTypeAnnotation',
  42434. Identifier: 'Identifier',
  42435. IfStatement: 'IfStatement',
  42436. ImportDeclaration: 'ImportDeclaration',
  42437. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  42438. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  42439. ImportSpecifier: 'ImportSpecifier',
  42440. InterfaceDeclaration: 'InterfaceDeclaration',
  42441. InterfaceExtends: 'InterfaceExtends',
  42442. IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
  42443. LabeledStatement: 'LabeledStatement',
  42444. Literal: 'Literal',
  42445. LogicalExpression: 'LogicalExpression',
  42446. MemberExpression: 'MemberExpression',
  42447. MethodDefinition: 'MethodDefinition',
  42448. ModuleSpecifier: 'ModuleSpecifier',
  42449. NewExpression: 'NewExpression',
  42450. NullableTypeAnnotation: 'NullableTypeAnnotation',
  42451. NumberTypeAnnotation: 'NumberTypeAnnotation',
  42452. ObjectExpression: 'ObjectExpression',
  42453. ObjectPattern: 'ObjectPattern',
  42454. ObjectTypeAnnotation: 'ObjectTypeAnnotation',
  42455. ObjectTypeCallProperty: 'ObjectTypeCallProperty',
  42456. ObjectTypeIndexer: 'ObjectTypeIndexer',
  42457. ObjectTypeProperty: 'ObjectTypeProperty',
  42458. Program: 'Program',
  42459. Property: 'Property',
  42460. QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
  42461. ReturnStatement: 'ReturnStatement',
  42462. SequenceExpression: 'SequenceExpression',
  42463. SpreadElement: 'SpreadElement',
  42464. SpreadProperty: 'SpreadProperty',
  42465. StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
  42466. StringTypeAnnotation: 'StringTypeAnnotation',
  42467. SwitchCase: 'SwitchCase',
  42468. SwitchStatement: 'SwitchStatement',
  42469. TaggedTemplateExpression: 'TaggedTemplateExpression',
  42470. TemplateElement: 'TemplateElement',
  42471. TemplateLiteral: 'TemplateLiteral',
  42472. ThisExpression: 'ThisExpression',
  42473. ThrowStatement: 'ThrowStatement',
  42474. TupleTypeAnnotation: 'TupleTypeAnnotation',
  42475. TryStatement: 'TryStatement',
  42476. TypeAlias: 'TypeAlias',
  42477. TypeAnnotation: 'TypeAnnotation',
  42478. TypeofTypeAnnotation: 'TypeofTypeAnnotation',
  42479. TypeParameterDeclaration: 'TypeParameterDeclaration',
  42480. TypeParameterInstantiation: 'TypeParameterInstantiation',
  42481. UnaryExpression: 'UnaryExpression',
  42482. UnionTypeAnnotation: 'UnionTypeAnnotation',
  42483. UpdateExpression: 'UpdateExpression',
  42484. VariableDeclaration: 'VariableDeclaration',
  42485. VariableDeclarator: 'VariableDeclarator',
  42486. VoidTypeAnnotation: 'VoidTypeAnnotation',
  42487. WhileStatement: 'WhileStatement',
  42488. WithStatement: 'WithStatement',
  42489. XJSIdentifier: 'XJSIdentifier',
  42490. XJSNamespacedName: 'XJSNamespacedName',
  42491. XJSMemberExpression: 'XJSMemberExpression',
  42492. XJSEmptyExpression: 'XJSEmptyExpression',
  42493. XJSExpressionContainer: 'XJSExpressionContainer',
  42494. XJSElement: 'XJSElement',
  42495. XJSClosingElement: 'XJSClosingElement',
  42496. XJSOpeningElement: 'XJSOpeningElement',
  42497. XJSAttribute: 'XJSAttribute',
  42498. XJSSpreadAttribute: 'XJSSpreadAttribute',
  42499. XJSText: 'XJSText',
  42500. YieldExpression: 'YieldExpression',
  42501. AwaitExpression: 'AwaitExpression'
  42502. };
  42503. PropertyKind = {
  42504. Data: 1,
  42505. Get: 2,
  42506. Set: 4
  42507. };
  42508. ClassPropertyType = {
  42509. 'static': 'static',
  42510. prototype: 'prototype'
  42511. };
  42512. // Error messages should be identical to V8.
  42513. Messages = {
  42514. UnexpectedToken: 'Unexpected token %0',
  42515. UnexpectedNumber: 'Unexpected number',
  42516. UnexpectedString: 'Unexpected string',
  42517. UnexpectedIdentifier: 'Unexpected identifier',
  42518. UnexpectedReserved: 'Unexpected reserved word',
  42519. UnexpectedTemplate: 'Unexpected quasi %0',
  42520. UnexpectedEOS: 'Unexpected end of input',
  42521. NewlineAfterThrow: 'Illegal newline after throw',
  42522. InvalidRegExp: 'Invalid regular expression',
  42523. UnterminatedRegExp: 'Invalid regular expression: missing /',
  42524. InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
  42525. InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
  42526. InvalidLHSInForIn: 'Invalid left-hand side in for-in',
  42527. MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
  42528. NoCatchOrFinally: 'Missing catch or finally after try',
  42529. UnknownLabel: 'Undefined label \'%0\'',
  42530. Redeclaration: '%0 \'%1\' has already been declared',
  42531. IllegalContinue: 'Illegal continue statement',
  42532. IllegalBreak: 'Illegal break statement',
  42533. IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
  42534. IllegalReturn: 'Illegal return statement',
  42535. IllegalSpread: 'Illegal spread element',
  42536. StrictModeWith: 'Strict mode code may not include a with statement',
  42537. StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
  42538. StrictVarName: 'Variable name may not be eval or arguments in strict mode',
  42539. StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
  42540. StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
  42541. ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
  42542. DefaultRestParameter: 'Rest parameter can not have a default value',
  42543. ElementAfterSpreadElement: 'Spread must be the final element of an element list',
  42544. PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
  42545. ObjectPatternAsRestParameter: 'Invalid rest parameter',
  42546. ObjectPatternAsSpread: 'Invalid spread argument',
  42547. StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
  42548. StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
  42549. StrictDelete: 'Delete of an unqualified identifier in strict mode.',
  42550. StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
  42551. AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
  42552. AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
  42553. StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
  42554. StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
  42555. StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
  42556. StrictReservedWord: 'Use of future reserved word in strict mode',
  42557. MissingFromClause: 'Missing from clause',
  42558. NoAsAfterImportNamespace: 'Missing as after import *',
  42559. InvalidModuleSpecifier: 'Invalid module specifier',
  42560. NoUnintializedConst: 'Const must be initialized',
  42561. ComprehensionRequiresBlock: 'Comprehension must have at least one block',
  42562. ComprehensionError: 'Comprehension Error',
  42563. EachNotAllowed: 'Each is not supported',
  42564. InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
  42565. ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
  42566. AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
  42567. ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
  42568. 'you are trying to write a function type, but you ended up ' +
  42569. 'writing a grouped type followed by an =>, which is a syntax ' +
  42570. 'error. Remember, function type parameters are named so function ' +
  42571. 'types look like (name1: type1, name2: type2) => returnType. You ' +
  42572. 'probably wrote (type1) => returnType'
  42573. };
  42574. // See also tools/generate-unicode-regex.py.
  42575. Regex = {
  42576. NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\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\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\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\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-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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]'),
  42577. NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\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\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\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\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\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\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\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\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-\u191c\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\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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-\ufe26\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]'),
  42578. LeadingZeros: new RegExp('^0+(?!$)')
  42579. };
  42580. // Ensure the condition is true, otherwise throw an error.
  42581. // This is only to have a better contract semantic, i.e. another safety net
  42582. // to catch a logic error. The condition shall be fulfilled in normal case.
  42583. // Do NOT use this to enforce a certain condition on any user input.
  42584. function assert(condition, message) {
  42585. if (!condition) {
  42586. throw new Error('ASSERT: ' + message);
  42587. }
  42588. }
  42589. function isDecimalDigit(ch) {
  42590. return (ch >= 48 && ch <= 57); // 0..9
  42591. }
  42592. function isHexDigit(ch) {
  42593. return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
  42594. }
  42595. function isOctalDigit(ch) {
  42596. return '01234567'.indexOf(ch) >= 0;
  42597. }
  42598. // 7.2 White Space
  42599. function isWhiteSpace(ch) {
  42600. return (ch === 32) || // space
  42601. (ch === 9) || // tab
  42602. (ch === 0xB) ||
  42603. (ch === 0xC) ||
  42604. (ch === 0xA0) ||
  42605. (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
  42606. }
  42607. // 7.3 Line Terminators
  42608. function isLineTerminator(ch) {
  42609. return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
  42610. }
  42611. // 7.6 Identifier Names and Identifiers
  42612. function isIdentifierStart(ch) {
  42613. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  42614. (ch >= 65 && ch <= 90) || // A..Z
  42615. (ch >= 97 && ch <= 122) || // a..z
  42616. (ch === 92) || // \ (backslash)
  42617. ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
  42618. }
  42619. function isIdentifierPart(ch) {
  42620. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  42621. (ch >= 65 && ch <= 90) || // A..Z
  42622. (ch >= 97 && ch <= 122) || // a..z
  42623. (ch >= 48 && ch <= 57) || // 0..9
  42624. (ch === 92) || // \ (backslash)
  42625. ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
  42626. }
  42627. // 7.6.1.2 Future Reserved Words
  42628. function isFutureReservedWord(id) {
  42629. switch (id) {
  42630. case 'class':
  42631. case 'enum':
  42632. case 'export':
  42633. case 'extends':
  42634. case 'import':
  42635. case 'super':
  42636. return true;
  42637. default:
  42638. return false;
  42639. }
  42640. }
  42641. function isStrictModeReservedWord(id) {
  42642. switch (id) {
  42643. case 'implements':
  42644. case 'interface':
  42645. case 'package':
  42646. case 'private':
  42647. case 'protected':
  42648. case 'public':
  42649. case 'static':
  42650. case 'yield':
  42651. case 'let':
  42652. return true;
  42653. default:
  42654. return false;
  42655. }
  42656. }
  42657. function isRestrictedWord(id) {
  42658. return id === 'eval' || id === 'arguments';
  42659. }
  42660. // 7.6.1.1 Keywords
  42661. function isKeyword(id) {
  42662. if (strict && isStrictModeReservedWord(id)) {
  42663. return true;
  42664. }
  42665. // 'const' is specialized as Keyword in V8.
  42666. // 'yield' is only treated as a keyword in strict mode.
  42667. // 'let' is for compatiblity with SpiderMonkey and ES.next.
  42668. // Some others are from future reserved words.
  42669. switch (id.length) {
  42670. case 2:
  42671. return (id === 'if') || (id === 'in') || (id === 'do');
  42672. case 3:
  42673. return (id === 'var') || (id === 'for') || (id === 'new') ||
  42674. (id === 'try') || (id === 'let');
  42675. case 4:
  42676. return (id === 'this') || (id === 'else') || (id === 'case') ||
  42677. (id === 'void') || (id === 'with') || (id === 'enum');
  42678. case 5:
  42679. return (id === 'while') || (id === 'break') || (id === 'catch') ||
  42680. (id === 'throw') || (id === 'const') ||
  42681. (id === 'class') || (id === 'super');
  42682. case 6:
  42683. return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
  42684. (id === 'switch') || (id === 'export') || (id === 'import');
  42685. case 7:
  42686. return (id === 'default') || (id === 'finally') || (id === 'extends');
  42687. case 8:
  42688. return (id === 'function') || (id === 'continue') || (id === 'debugger');
  42689. case 10:
  42690. return (id === 'instanceof');
  42691. default:
  42692. return false;
  42693. }
  42694. }
  42695. // 7.4 Comments
  42696. function skipComment() {
  42697. var ch, blockComment, lineComment;
  42698. blockComment = false;
  42699. lineComment = false;
  42700. while (index < length) {
  42701. ch = source.charCodeAt(index);
  42702. if (lineComment) {
  42703. ++index;
  42704. if (isLineTerminator(ch)) {
  42705. lineComment = false;
  42706. if (ch === 13 && source.charCodeAt(index) === 10) {
  42707. ++index;
  42708. }
  42709. ++lineNumber;
  42710. lineStart = index;
  42711. }
  42712. } else if (blockComment) {
  42713. if (isLineTerminator(ch)) {
  42714. if (ch === 13) {
  42715. ++index;
  42716. }
  42717. if (ch !== 13 || source.charCodeAt(index) === 10) {
  42718. ++lineNumber;
  42719. ++index;
  42720. lineStart = index;
  42721. if (index >= length) {
  42722. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42723. }
  42724. }
  42725. } else {
  42726. ch = source.charCodeAt(index++);
  42727. if (index >= length) {
  42728. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42729. }
  42730. // Block comment ends with '*/' (char #42, char #47).
  42731. if (ch === 42) {
  42732. ch = source.charCodeAt(index);
  42733. if (ch === 47) {
  42734. ++index;
  42735. blockComment = false;
  42736. }
  42737. }
  42738. }
  42739. } else if (ch === 47) {
  42740. ch = source.charCodeAt(index + 1);
  42741. // Line comment starts with '//' (char #47, char #47).
  42742. if (ch === 47) {
  42743. index += 2;
  42744. lineComment = true;
  42745. } else if (ch === 42) {
  42746. // Block comment starts with '/*' (char #47, char #42).
  42747. index += 2;
  42748. blockComment = true;
  42749. if (index >= length) {
  42750. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42751. }
  42752. } else {
  42753. break;
  42754. }
  42755. } else if (isWhiteSpace(ch)) {
  42756. ++index;
  42757. } else if (isLineTerminator(ch)) {
  42758. ++index;
  42759. if (ch === 13 && source.charCodeAt(index) === 10) {
  42760. ++index;
  42761. }
  42762. ++lineNumber;
  42763. lineStart = index;
  42764. } else {
  42765. break;
  42766. }
  42767. }
  42768. }
  42769. function scanHexEscape(prefix) {
  42770. var i, len, ch, code = 0;
  42771. len = (prefix === 'u') ? 4 : 2;
  42772. for (i = 0; i < len; ++i) {
  42773. if (index < length && isHexDigit(source[index])) {
  42774. ch = source[index++];
  42775. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  42776. } else {
  42777. return '';
  42778. }
  42779. }
  42780. return String.fromCharCode(code);
  42781. }
  42782. function scanUnicodeCodePointEscape() {
  42783. var ch, code, cu1, cu2;
  42784. ch = source[index];
  42785. code = 0;
  42786. // At least, one hex digit is required.
  42787. if (ch === '}') {
  42788. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42789. }
  42790. while (index < length) {
  42791. ch = source[index++];
  42792. if (!isHexDigit(ch)) {
  42793. break;
  42794. }
  42795. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  42796. }
  42797. if (code > 0x10FFFF || ch !== '}') {
  42798. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42799. }
  42800. // UTF-16 Encoding
  42801. if (code <= 0xFFFF) {
  42802. return String.fromCharCode(code);
  42803. }
  42804. cu1 = ((code - 0x10000) >> 10) + 0xD800;
  42805. cu2 = ((code - 0x10000) & 1023) + 0xDC00;
  42806. return String.fromCharCode(cu1, cu2);
  42807. }
  42808. function getEscapedIdentifier() {
  42809. var ch, id;
  42810. ch = source.charCodeAt(index++);
  42811. id = String.fromCharCode(ch);
  42812. // '\u' (char #92, char #117) denotes an escaped character.
  42813. if (ch === 92) {
  42814. if (source.charCodeAt(index) !== 117) {
  42815. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42816. }
  42817. ++index;
  42818. ch = scanHexEscape('u');
  42819. if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
  42820. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42821. }
  42822. id = ch;
  42823. }
  42824. while (index < length) {
  42825. ch = source.charCodeAt(index);
  42826. if (!isIdentifierPart(ch)) {
  42827. break;
  42828. }
  42829. ++index;
  42830. id += String.fromCharCode(ch);
  42831. // '\u' (char #92, char #117) denotes an escaped character.
  42832. if (ch === 92) {
  42833. id = id.substr(0, id.length - 1);
  42834. if (source.charCodeAt(index) !== 117) {
  42835. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42836. }
  42837. ++index;
  42838. ch = scanHexEscape('u');
  42839. if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
  42840. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  42841. }
  42842. id += ch;
  42843. }
  42844. }
  42845. return id;
  42846. }
  42847. function getIdentifier() {
  42848. var start, ch;
  42849. start = index++;
  42850. while (index < length) {
  42851. ch = source.charCodeAt(index);
  42852. if (ch === 92) {
  42853. // Blackslash (char #92) marks Unicode escape sequence.
  42854. index = start;
  42855. return getEscapedIdentifier();
  42856. }
  42857. if (isIdentifierPart(ch)) {
  42858. ++index;
  42859. } else {
  42860. break;
  42861. }
  42862. }
  42863. return source.slice(start, index);
  42864. }
  42865. function scanIdentifier() {
  42866. var start, id, type;
  42867. start = index;
  42868. // Backslash (char #92) starts an escaped character.
  42869. id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
  42870. // There is no keyword or literal with only one character.
  42871. // Thus, it must be an identifier.
  42872. if (id.length === 1) {
  42873. type = Token.Identifier;
  42874. } else if (isKeyword(id)) {
  42875. type = Token.Keyword;
  42876. } else if (id === 'null') {
  42877. type = Token.NullLiteral;
  42878. } else if (id === 'true' || id === 'false') {
  42879. type = Token.BooleanLiteral;
  42880. } else {
  42881. type = Token.Identifier;
  42882. }
  42883. return {
  42884. type: type,
  42885. value: id,
  42886. lineNumber: lineNumber,
  42887. lineStart: lineStart,
  42888. range: [start, index]
  42889. };
  42890. }
  42891. // 7.7 Punctuators
  42892. function scanPunctuator() {
  42893. var start = index,
  42894. code = source.charCodeAt(index),
  42895. code2,
  42896. ch1 = source[index],
  42897. ch2,
  42898. ch3,
  42899. ch4;
  42900. switch (code) {
  42901. // Check for most common single-character punctuators.
  42902. case 40: // ( open bracket
  42903. case 41: // ) close bracket
  42904. case 59: // ; semicolon
  42905. case 44: // , comma
  42906. case 123: // { open curly brace
  42907. case 125: // } close curly brace
  42908. case 91: // [
  42909. case 93: // ]
  42910. case 58: // :
  42911. case 63: // ?
  42912. case 126: // ~
  42913. ++index;
  42914. if (extra.tokenize) {
  42915. if (code === 40) {
  42916. extra.openParenToken = extra.tokens.length;
  42917. } else if (code === 123) {
  42918. extra.openCurlyToken = extra.tokens.length;
  42919. }
  42920. }
  42921. return {
  42922. type: Token.Punctuator,
  42923. value: String.fromCharCode(code),
  42924. lineNumber: lineNumber,
  42925. lineStart: lineStart,
  42926. range: [start, index]
  42927. };
  42928. default:
  42929. code2 = source.charCodeAt(index + 1);
  42930. // '=' (char #61) marks an assignment or comparison operator.
  42931. if (code2 === 61) {
  42932. switch (code) {
  42933. case 37: // %
  42934. case 38: // &
  42935. case 42: // *:
  42936. case 43: // +
  42937. case 45: // -
  42938. case 47: // /
  42939. case 60: // <
  42940. case 62: // >
  42941. case 94: // ^
  42942. case 124: // |
  42943. index += 2;
  42944. return {
  42945. type: Token.Punctuator,
  42946. value: String.fromCharCode(code) + String.fromCharCode(code2),
  42947. lineNumber: lineNumber,
  42948. lineStart: lineStart,
  42949. range: [start, index]
  42950. };
  42951. case 33: // !
  42952. case 61: // =
  42953. index += 2;
  42954. // !== and ===
  42955. if (source.charCodeAt(index) === 61) {
  42956. ++index;
  42957. }
  42958. return {
  42959. type: Token.Punctuator,
  42960. value: source.slice(start, index),
  42961. lineNumber: lineNumber,
  42962. lineStart: lineStart,
  42963. range: [start, index]
  42964. };
  42965. default:
  42966. break;
  42967. }
  42968. }
  42969. break;
  42970. }
  42971. // Peek more characters.
  42972. ch2 = source[index + 1];
  42973. ch3 = source[index + 2];
  42974. ch4 = source[index + 3];
  42975. // 4-character punctuator: >>>=
  42976. if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
  42977. if (ch4 === '=') {
  42978. index += 4;
  42979. return {
  42980. type: Token.Punctuator,
  42981. value: '>>>=',
  42982. lineNumber: lineNumber,
  42983. lineStart: lineStart,
  42984. range: [start, index]
  42985. };
  42986. }
  42987. }
  42988. // 3-character punctuators: === !== >>> <<= >>=
  42989. if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
  42990. index += 3;
  42991. return {
  42992. type: Token.Punctuator,
  42993. value: '>>>',
  42994. lineNumber: lineNumber,
  42995. lineStart: lineStart,
  42996. range: [start, index]
  42997. };
  42998. }
  42999. if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
  43000. index += 3;
  43001. return {
  43002. type: Token.Punctuator,
  43003. value: '<<=',
  43004. lineNumber: lineNumber,
  43005. lineStart: lineStart,
  43006. range: [start, index]
  43007. };
  43008. }
  43009. if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
  43010. index += 3;
  43011. return {
  43012. type: Token.Punctuator,
  43013. value: '>>=',
  43014. lineNumber: lineNumber,
  43015. lineStart: lineStart,
  43016. range: [start, index]
  43017. };
  43018. }
  43019. if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
  43020. index += 3;
  43021. return {
  43022. type: Token.Punctuator,
  43023. value: '...',
  43024. lineNumber: lineNumber,
  43025. lineStart: lineStart,
  43026. range: [start, index]
  43027. };
  43028. }
  43029. // Other 2-character punctuators: ++ -- << >> && ||
  43030. // Don't match these tokens if we're in a type, since they never can
  43031. // occur and can mess up types like Map<string, Array<string>>
  43032. if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
  43033. index += 2;
  43034. return {
  43035. type: Token.Punctuator,
  43036. value: ch1 + ch2,
  43037. lineNumber: lineNumber,
  43038. lineStart: lineStart,
  43039. range: [start, index]
  43040. };
  43041. }
  43042. if (ch1 === '=' && ch2 === '>') {
  43043. index += 2;
  43044. return {
  43045. type: Token.Punctuator,
  43046. value: '=>',
  43047. lineNumber: lineNumber,
  43048. lineStart: lineStart,
  43049. range: [start, index]
  43050. };
  43051. }
  43052. if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
  43053. ++index;
  43054. return {
  43055. type: Token.Punctuator,
  43056. value: ch1,
  43057. lineNumber: lineNumber,
  43058. lineStart: lineStart,
  43059. range: [start, index]
  43060. };
  43061. }
  43062. if (ch1 === '.') {
  43063. ++index;
  43064. return {
  43065. type: Token.Punctuator,
  43066. value: ch1,
  43067. lineNumber: lineNumber,
  43068. lineStart: lineStart,
  43069. range: [start, index]
  43070. };
  43071. }
  43072. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43073. }
  43074. // 7.8.3 Numeric Literals
  43075. function scanHexLiteral(start) {
  43076. var number = '';
  43077. while (index < length) {
  43078. if (!isHexDigit(source[index])) {
  43079. break;
  43080. }
  43081. number += source[index++];
  43082. }
  43083. if (number.length === 0) {
  43084. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43085. }
  43086. if (isIdentifierStart(source.charCodeAt(index))) {
  43087. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43088. }
  43089. return {
  43090. type: Token.NumericLiteral,
  43091. value: parseInt('0x' + number, 16),
  43092. lineNumber: lineNumber,
  43093. lineStart: lineStart,
  43094. range: [start, index]
  43095. };
  43096. }
  43097. function scanOctalLiteral(prefix, start) {
  43098. var number, octal;
  43099. if (isOctalDigit(prefix)) {
  43100. octal = true;
  43101. number = '0' + source[index++];
  43102. } else {
  43103. octal = false;
  43104. ++index;
  43105. number = '';
  43106. }
  43107. while (index < length) {
  43108. if (!isOctalDigit(source[index])) {
  43109. break;
  43110. }
  43111. number += source[index++];
  43112. }
  43113. if (!octal && number.length === 0) {
  43114. // only 0o or 0O
  43115. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43116. }
  43117. if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
  43118. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43119. }
  43120. return {
  43121. type: Token.NumericLiteral,
  43122. value: parseInt(number, 8),
  43123. octal: octal,
  43124. lineNumber: lineNumber,
  43125. lineStart: lineStart,
  43126. range: [start, index]
  43127. };
  43128. }
  43129. function scanNumericLiteral() {
  43130. var number, start, ch, octal;
  43131. ch = source[index];
  43132. assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
  43133. 'Numeric literal must start with a decimal digit or a decimal point');
  43134. start = index;
  43135. number = '';
  43136. if (ch !== '.') {
  43137. number = source[index++];
  43138. ch = source[index];
  43139. // Hex number starts with '0x'.
  43140. // Octal number starts with '0'.
  43141. // Octal number in ES6 starts with '0o'.
  43142. // Binary number in ES6 starts with '0b'.
  43143. if (number === '0') {
  43144. if (ch === 'x' || ch === 'X') {
  43145. ++index;
  43146. return scanHexLiteral(start);
  43147. }
  43148. if (ch === 'b' || ch === 'B') {
  43149. ++index;
  43150. number = '';
  43151. while (index < length) {
  43152. ch = source[index];
  43153. if (ch !== '0' && ch !== '1') {
  43154. break;
  43155. }
  43156. number += source[index++];
  43157. }
  43158. if (number.length === 0) {
  43159. // only 0b or 0B
  43160. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43161. }
  43162. if (index < length) {
  43163. ch = source.charCodeAt(index);
  43164. if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
  43165. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43166. }
  43167. }
  43168. return {
  43169. type: Token.NumericLiteral,
  43170. value: parseInt(number, 2),
  43171. lineNumber: lineNumber,
  43172. lineStart: lineStart,
  43173. range: [start, index]
  43174. };
  43175. }
  43176. if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
  43177. return scanOctalLiteral(ch, start);
  43178. }
  43179. // decimal number starts with '0' such as '09' is illegal.
  43180. if (ch && isDecimalDigit(ch.charCodeAt(0))) {
  43181. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43182. }
  43183. }
  43184. while (isDecimalDigit(source.charCodeAt(index))) {
  43185. number += source[index++];
  43186. }
  43187. ch = source[index];
  43188. }
  43189. if (ch === '.') {
  43190. number += source[index++];
  43191. while (isDecimalDigit(source.charCodeAt(index))) {
  43192. number += source[index++];
  43193. }
  43194. ch = source[index];
  43195. }
  43196. if (ch === 'e' || ch === 'E') {
  43197. number += source[index++];
  43198. ch = source[index];
  43199. if (ch === '+' || ch === '-') {
  43200. number += source[index++];
  43201. }
  43202. if (isDecimalDigit(source.charCodeAt(index))) {
  43203. while (isDecimalDigit(source.charCodeAt(index))) {
  43204. number += source[index++];
  43205. }
  43206. } else {
  43207. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43208. }
  43209. }
  43210. if (isIdentifierStart(source.charCodeAt(index))) {
  43211. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43212. }
  43213. return {
  43214. type: Token.NumericLiteral,
  43215. value: parseFloat(number),
  43216. lineNumber: lineNumber,
  43217. lineStart: lineStart,
  43218. range: [start, index]
  43219. };
  43220. }
  43221. // 7.8.4 String Literals
  43222. function scanStringLiteral() {
  43223. var str = '', quote, start, ch, code, unescaped, restore, octal = false;
  43224. quote = source[index];
  43225. assert((quote === '\'' || quote === '"'),
  43226. 'String literal must starts with a quote');
  43227. start = index;
  43228. ++index;
  43229. while (index < length) {
  43230. ch = source[index++];
  43231. if (ch === quote) {
  43232. quote = '';
  43233. break;
  43234. } else if (ch === '\\') {
  43235. ch = source[index++];
  43236. if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
  43237. switch (ch) {
  43238. case 'n':
  43239. str += '\n';
  43240. break;
  43241. case 'r':
  43242. str += '\r';
  43243. break;
  43244. case 't':
  43245. str += '\t';
  43246. break;
  43247. case 'u':
  43248. case 'x':
  43249. if (source[index] === '{') {
  43250. ++index;
  43251. str += scanUnicodeCodePointEscape();
  43252. } else {
  43253. restore = index;
  43254. unescaped = scanHexEscape(ch);
  43255. if (unescaped) {
  43256. str += unescaped;
  43257. } else {
  43258. index = restore;
  43259. str += ch;
  43260. }
  43261. }
  43262. break;
  43263. case 'b':
  43264. str += '\b';
  43265. break;
  43266. case 'f':
  43267. str += '\f';
  43268. break;
  43269. case 'v':
  43270. str += '\x0B';
  43271. break;
  43272. default:
  43273. if (isOctalDigit(ch)) {
  43274. code = '01234567'.indexOf(ch);
  43275. // \0 is not octal escape sequence
  43276. if (code !== 0) {
  43277. octal = true;
  43278. }
  43279. if (index < length && isOctalDigit(source[index])) {
  43280. octal = true;
  43281. code = code * 8 + '01234567'.indexOf(source[index++]);
  43282. // 3 digits are only allowed when string starts
  43283. // with 0, 1, 2, 3
  43284. if ('0123'.indexOf(ch) >= 0 &&
  43285. index < length &&
  43286. isOctalDigit(source[index])) {
  43287. code = code * 8 + '01234567'.indexOf(source[index++]);
  43288. }
  43289. }
  43290. str += String.fromCharCode(code);
  43291. } else {
  43292. str += ch;
  43293. }
  43294. break;
  43295. }
  43296. } else {
  43297. ++lineNumber;
  43298. if (ch === '\r' && source[index] === '\n') {
  43299. ++index;
  43300. }
  43301. lineStart = index;
  43302. }
  43303. } else if (isLineTerminator(ch.charCodeAt(0))) {
  43304. break;
  43305. } else {
  43306. str += ch;
  43307. }
  43308. }
  43309. if (quote !== '') {
  43310. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43311. }
  43312. return {
  43313. type: Token.StringLiteral,
  43314. value: str,
  43315. octal: octal,
  43316. lineNumber: lineNumber,
  43317. lineStart: lineStart,
  43318. range: [start, index]
  43319. };
  43320. }
  43321. function scanTemplate() {
  43322. var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal;
  43323. terminated = false;
  43324. tail = false;
  43325. start = index;
  43326. ++index;
  43327. while (index < length) {
  43328. ch = source[index++];
  43329. if (ch === '`') {
  43330. tail = true;
  43331. terminated = true;
  43332. break;
  43333. } else if (ch === '$') {
  43334. if (source[index] === '{') {
  43335. ++index;
  43336. terminated = true;
  43337. break;
  43338. }
  43339. cooked += ch;
  43340. } else if (ch === '\\') {
  43341. ch = source[index++];
  43342. if (!isLineTerminator(ch.charCodeAt(0))) {
  43343. switch (ch) {
  43344. case 'n':
  43345. cooked += '\n';
  43346. break;
  43347. case 'r':
  43348. cooked += '\r';
  43349. break;
  43350. case 't':
  43351. cooked += '\t';
  43352. break;
  43353. case 'u':
  43354. case 'x':
  43355. if (source[index] === '{') {
  43356. ++index;
  43357. cooked += scanUnicodeCodePointEscape();
  43358. } else {
  43359. restore = index;
  43360. unescaped = scanHexEscape(ch);
  43361. if (unescaped) {
  43362. cooked += unescaped;
  43363. } else {
  43364. index = restore;
  43365. cooked += ch;
  43366. }
  43367. }
  43368. break;
  43369. case 'b':
  43370. cooked += '\b';
  43371. break;
  43372. case 'f':
  43373. cooked += '\f';
  43374. break;
  43375. case 'v':
  43376. cooked += '\v';
  43377. break;
  43378. default:
  43379. if (isOctalDigit(ch)) {
  43380. code = '01234567'.indexOf(ch);
  43381. // \0 is not octal escape sequence
  43382. if (code !== 0) {
  43383. octal = true;
  43384. }
  43385. if (index < length && isOctalDigit(source[index])) {
  43386. octal = true;
  43387. code = code * 8 + '01234567'.indexOf(source[index++]);
  43388. // 3 digits are only allowed when string starts
  43389. // with 0, 1, 2, 3
  43390. if ('0123'.indexOf(ch) >= 0 &&
  43391. index < length &&
  43392. isOctalDigit(source[index])) {
  43393. code = code * 8 + '01234567'.indexOf(source[index++]);
  43394. }
  43395. }
  43396. cooked += String.fromCharCode(code);
  43397. } else {
  43398. cooked += ch;
  43399. }
  43400. break;
  43401. }
  43402. } else {
  43403. ++lineNumber;
  43404. if (ch === '\r' && source[index] === '\n') {
  43405. ++index;
  43406. }
  43407. lineStart = index;
  43408. }
  43409. } else if (isLineTerminator(ch.charCodeAt(0))) {
  43410. ++lineNumber;
  43411. if (ch === '\r' && source[index] === '\n') {
  43412. ++index;
  43413. }
  43414. lineStart = index;
  43415. cooked += '\n';
  43416. } else {
  43417. cooked += ch;
  43418. }
  43419. }
  43420. if (!terminated) {
  43421. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43422. }
  43423. return {
  43424. type: Token.Template,
  43425. value: {
  43426. cooked: cooked,
  43427. raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
  43428. },
  43429. tail: tail,
  43430. octal: octal,
  43431. lineNumber: lineNumber,
  43432. lineStart: lineStart,
  43433. range: [start, index]
  43434. };
  43435. }
  43436. function scanTemplateElement(option) {
  43437. var startsWith, template;
  43438. lookahead = null;
  43439. skipComment();
  43440. startsWith = (option.head) ? '`' : '}';
  43441. if (source[index] !== startsWith) {
  43442. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  43443. }
  43444. template = scanTemplate();
  43445. peek();
  43446. return template;
  43447. }
  43448. function scanRegExp() {
  43449. var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
  43450. lookahead = null;
  43451. skipComment();
  43452. start = index;
  43453. ch = source[index];
  43454. assert(ch === '/', 'Regular expression literal must start with a slash');
  43455. str = source[index++];
  43456. while (index < length) {
  43457. ch = source[index++];
  43458. str += ch;
  43459. if (classMarker) {
  43460. if (ch === ']') {
  43461. classMarker = false;
  43462. }
  43463. } else {
  43464. if (ch === '\\') {
  43465. ch = source[index++];
  43466. // ECMA-262 7.8.5
  43467. if (isLineTerminator(ch.charCodeAt(0))) {
  43468. throwError({}, Messages.UnterminatedRegExp);
  43469. }
  43470. str += ch;
  43471. } else if (ch === '/') {
  43472. terminated = true;
  43473. break;
  43474. } else if (ch === '[') {
  43475. classMarker = true;
  43476. } else if (isLineTerminator(ch.charCodeAt(0))) {
  43477. throwError({}, Messages.UnterminatedRegExp);
  43478. }
  43479. }
  43480. }
  43481. if (!terminated) {
  43482. throwError({}, Messages.UnterminatedRegExp);
  43483. }
  43484. // Exclude leading and trailing slash.
  43485. pattern = str.substr(1, str.length - 2);
  43486. flags = '';
  43487. while (index < length) {
  43488. ch = source[index];
  43489. if (!isIdentifierPart(ch.charCodeAt(0))) {
  43490. break;
  43491. }
  43492. ++index;
  43493. if (ch === '\\' && index < length) {
  43494. ch = source[index];
  43495. if (ch === 'u') {
  43496. ++index;
  43497. restore = index;
  43498. ch = scanHexEscape('u');
  43499. if (ch) {
  43500. flags += ch;
  43501. for (str += '\\u'; restore < index; ++restore) {
  43502. str += source[restore];
  43503. }
  43504. } else {
  43505. index = restore;
  43506. flags += 'u';
  43507. str += '\\u';
  43508. }
  43509. } else {
  43510. str += '\\';
  43511. }
  43512. } else {
  43513. flags += ch;
  43514. str += ch;
  43515. }
  43516. }
  43517. tmp = pattern;
  43518. if (flags.indexOf('u') >= 0) {
  43519. // Replace each astral symbol and every Unicode code point
  43520. // escape sequence that represents such a symbol with a single
  43521. // ASCII symbol to avoid throwing on regular expressions that
  43522. // are only valid in combination with the `/u` flag.
  43523. tmp = tmp
  43524. .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
  43525. .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
  43526. }
  43527. // First, detect invalid regular expressions.
  43528. try {
  43529. value = new RegExp(tmp);
  43530. } catch (e) {
  43531. throwError({}, Messages.InvalidRegExp);
  43532. }
  43533. // Return a regular expression object for this pattern-flag pair, or
  43534. // `null` in case the current environment doesn't support the flags it
  43535. // uses.
  43536. try {
  43537. value = new RegExp(pattern, flags);
  43538. } catch (exception) {
  43539. value = null;
  43540. }
  43541. peek();
  43542. if (extra.tokenize) {
  43543. return {
  43544. type: Token.RegularExpression,
  43545. value: value,
  43546. regex: {
  43547. pattern: pattern,
  43548. flags: flags
  43549. },
  43550. lineNumber: lineNumber,
  43551. lineStart: lineStart,
  43552. range: [start, index]
  43553. };
  43554. }
  43555. return {
  43556. literal: str,
  43557. value: value,
  43558. regex: {
  43559. pattern: pattern,
  43560. flags: flags
  43561. },
  43562. range: [start, index]
  43563. };
  43564. }
  43565. function isIdentifierName(token) {
  43566. return token.type === Token.Identifier ||
  43567. token.type === Token.Keyword ||
  43568. token.type === Token.BooleanLiteral ||
  43569. token.type === Token.NullLiteral;
  43570. }
  43571. function advanceSlash() {
  43572. var prevToken,
  43573. checkToken;
  43574. // Using the following algorithm:
  43575. // https://github.com/mozilla/sweet.js/wiki/design
  43576. prevToken = extra.tokens[extra.tokens.length - 1];
  43577. if (!prevToken) {
  43578. // Nothing before that: it cannot be a division.
  43579. return scanRegExp();
  43580. }
  43581. if (prevToken.type === 'Punctuator') {
  43582. if (prevToken.value === ')') {
  43583. checkToken = extra.tokens[extra.openParenToken - 1];
  43584. if (checkToken &&
  43585. checkToken.type === 'Keyword' &&
  43586. (checkToken.value === 'if' ||
  43587. checkToken.value === 'while' ||
  43588. checkToken.value === 'for' ||
  43589. checkToken.value === 'with')) {
  43590. return scanRegExp();
  43591. }
  43592. return scanPunctuator();
  43593. }
  43594. if (prevToken.value === '}') {
  43595. // Dividing a function by anything makes little sense,
  43596. // but we have to check for that.
  43597. if (extra.tokens[extra.openCurlyToken - 3] &&
  43598. extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
  43599. // Anonymous function.
  43600. checkToken = extra.tokens[extra.openCurlyToken - 4];
  43601. if (!checkToken) {
  43602. return scanPunctuator();
  43603. }
  43604. } else if (extra.tokens[extra.openCurlyToken - 4] &&
  43605. extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
  43606. // Named function.
  43607. checkToken = extra.tokens[extra.openCurlyToken - 5];
  43608. if (!checkToken) {
  43609. return scanRegExp();
  43610. }
  43611. } else {
  43612. return scanPunctuator();
  43613. }
  43614. // checkToken determines whether the function is
  43615. // a declaration or an expression.
  43616. if (FnExprTokens.indexOf(checkToken.value) >= 0) {
  43617. // It is an expression.
  43618. return scanPunctuator();
  43619. }
  43620. // It is a declaration.
  43621. return scanRegExp();
  43622. }
  43623. return scanRegExp();
  43624. }
  43625. if (prevToken.type === 'Keyword') {
  43626. return scanRegExp();
  43627. }
  43628. return scanPunctuator();
  43629. }
  43630. function advance() {
  43631. var ch;
  43632. if (!state.inXJSChild) {
  43633. skipComment();
  43634. }
  43635. if (index >= length) {
  43636. return {
  43637. type: Token.EOF,
  43638. lineNumber: lineNumber,
  43639. lineStart: lineStart,
  43640. range: [index, index]
  43641. };
  43642. }
  43643. if (state.inXJSChild) {
  43644. return advanceXJSChild();
  43645. }
  43646. ch = source.charCodeAt(index);
  43647. // Very common: ( and ) and ;
  43648. if (ch === 40 || ch === 41 || ch === 58) {
  43649. return scanPunctuator();
  43650. }
  43651. // String literal starts with single quote (#39) or double quote (#34).
  43652. if (ch === 39 || ch === 34) {
  43653. if (state.inXJSTag) {
  43654. return scanXJSStringLiteral();
  43655. }
  43656. return scanStringLiteral();
  43657. }
  43658. if (state.inXJSTag && isXJSIdentifierStart(ch)) {
  43659. return scanXJSIdentifier();
  43660. }
  43661. if (ch === 96) {
  43662. return scanTemplate();
  43663. }
  43664. if (isIdentifierStart(ch)) {
  43665. return scanIdentifier();
  43666. }
  43667. // Dot (.) char #46 can also start a floating-point number, hence the need
  43668. // to check the next character.
  43669. if (ch === 46) {
  43670. if (isDecimalDigit(source.charCodeAt(index + 1))) {
  43671. return scanNumericLiteral();
  43672. }
  43673. return scanPunctuator();
  43674. }
  43675. if (isDecimalDigit(ch)) {
  43676. return scanNumericLiteral();
  43677. }
  43678. // Slash (/) char #47 can also start a regex.
  43679. if (extra.tokenize && ch === 47) {
  43680. return advanceSlash();
  43681. }
  43682. return scanPunctuator();
  43683. }
  43684. function lex() {
  43685. var token;
  43686. token = lookahead;
  43687. index = token.range[1];
  43688. lineNumber = token.lineNumber;
  43689. lineStart = token.lineStart;
  43690. lookahead = advance();
  43691. index = token.range[1];
  43692. lineNumber = token.lineNumber;
  43693. lineStart = token.lineStart;
  43694. return token;
  43695. }
  43696. function peek() {
  43697. var pos, line, start;
  43698. pos = index;
  43699. line = lineNumber;
  43700. start = lineStart;
  43701. lookahead = advance();
  43702. index = pos;
  43703. lineNumber = line;
  43704. lineStart = start;
  43705. }
  43706. function lookahead2() {
  43707. var adv, pos, line, start, result;
  43708. // If we are collecting the tokens, don't grab the next one yet.
  43709. adv = (typeof extra.advance === 'function') ? extra.advance : advance;
  43710. pos = index;
  43711. line = lineNumber;
  43712. start = lineStart;
  43713. // Scan for the next immediate token.
  43714. if (lookahead === null) {
  43715. lookahead = adv();
  43716. }
  43717. index = lookahead.range[1];
  43718. lineNumber = lookahead.lineNumber;
  43719. lineStart = lookahead.lineStart;
  43720. // Grab the token right after.
  43721. result = adv();
  43722. index = pos;
  43723. lineNumber = line;
  43724. lineStart = start;
  43725. return result;
  43726. }
  43727. function rewind(token) {
  43728. index = token.range[0];
  43729. lineNumber = token.lineNumber;
  43730. lineStart = token.lineStart;
  43731. lookahead = token;
  43732. }
  43733. function markerCreate() {
  43734. if (!extra.loc && !extra.range) {
  43735. return undefined;
  43736. }
  43737. skipComment();
  43738. return {offset: index, line: lineNumber, col: index - lineStart};
  43739. }
  43740. function markerCreatePreserveWhitespace() {
  43741. if (!extra.loc && !extra.range) {
  43742. return undefined;
  43743. }
  43744. return {offset: index, line: lineNumber, col: index - lineStart};
  43745. }
  43746. function processComment(node) {
  43747. var lastChild,
  43748. trailingComments,
  43749. bottomRight = extra.bottomRightStack,
  43750. last = bottomRight[bottomRight.length - 1];
  43751. if (node.type === Syntax.Program) {
  43752. if (node.body.length > 0) {
  43753. return;
  43754. }
  43755. }
  43756. if (extra.trailingComments.length > 0) {
  43757. if (extra.trailingComments[0].range[0] >= node.range[1]) {
  43758. trailingComments = extra.trailingComments;
  43759. extra.trailingComments = [];
  43760. } else {
  43761. extra.trailingComments.length = 0;
  43762. }
  43763. } else {
  43764. if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
  43765. trailingComments = last.trailingComments;
  43766. delete last.trailingComments;
  43767. }
  43768. }
  43769. // Eating the stack.
  43770. if (last) {
  43771. while (last && last.range[0] >= node.range[0]) {
  43772. lastChild = last;
  43773. last = bottomRight.pop();
  43774. }
  43775. }
  43776. if (lastChild) {
  43777. if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
  43778. node.leadingComments = lastChild.leadingComments;
  43779. delete lastChild.leadingComments;
  43780. }
  43781. } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
  43782. node.leadingComments = extra.leadingComments;
  43783. extra.leadingComments = [];
  43784. }
  43785. if (trailingComments) {
  43786. node.trailingComments = trailingComments;
  43787. }
  43788. bottomRight.push(node);
  43789. }
  43790. function markerApply(marker, node) {
  43791. if (extra.range) {
  43792. node.range = [marker.offset, index];
  43793. }
  43794. if (extra.loc) {
  43795. node.loc = {
  43796. start: {
  43797. line: marker.line,
  43798. column: marker.col
  43799. },
  43800. end: {
  43801. line: lineNumber,
  43802. column: index - lineStart
  43803. }
  43804. };
  43805. node = delegate.postProcess(node);
  43806. }
  43807. if (extra.attachComment) {
  43808. processComment(node);
  43809. }
  43810. return node;
  43811. }
  43812. SyntaxTreeDelegate = {
  43813. name: 'SyntaxTree',
  43814. postProcess: function (node) {
  43815. return node;
  43816. },
  43817. createArrayExpression: function (elements) {
  43818. return {
  43819. type: Syntax.ArrayExpression,
  43820. elements: elements
  43821. };
  43822. },
  43823. createAssignmentExpression: function (operator, left, right) {
  43824. return {
  43825. type: Syntax.AssignmentExpression,
  43826. operator: operator,
  43827. left: left,
  43828. right: right
  43829. };
  43830. },
  43831. createBinaryExpression: function (operator, left, right) {
  43832. var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
  43833. Syntax.BinaryExpression;
  43834. return {
  43835. type: type,
  43836. operator: operator,
  43837. left: left,
  43838. right: right
  43839. };
  43840. },
  43841. createBlockStatement: function (body) {
  43842. return {
  43843. type: Syntax.BlockStatement,
  43844. body: body
  43845. };
  43846. },
  43847. createBreakStatement: function (label) {
  43848. return {
  43849. type: Syntax.BreakStatement,
  43850. label: label
  43851. };
  43852. },
  43853. createCallExpression: function (callee, args) {
  43854. return {
  43855. type: Syntax.CallExpression,
  43856. callee: callee,
  43857. 'arguments': args
  43858. };
  43859. },
  43860. createCatchClause: function (param, body) {
  43861. return {
  43862. type: Syntax.CatchClause,
  43863. param: param,
  43864. body: body
  43865. };
  43866. },
  43867. createConditionalExpression: function (test, consequent, alternate) {
  43868. return {
  43869. type: Syntax.ConditionalExpression,
  43870. test: test,
  43871. consequent: consequent,
  43872. alternate: alternate
  43873. };
  43874. },
  43875. createContinueStatement: function (label) {
  43876. return {
  43877. type: Syntax.ContinueStatement,
  43878. label: label
  43879. };
  43880. },
  43881. createDebuggerStatement: function () {
  43882. return {
  43883. type: Syntax.DebuggerStatement
  43884. };
  43885. },
  43886. createDoWhileStatement: function (body, test) {
  43887. return {
  43888. type: Syntax.DoWhileStatement,
  43889. body: body,
  43890. test: test
  43891. };
  43892. },
  43893. createEmptyStatement: function () {
  43894. return {
  43895. type: Syntax.EmptyStatement
  43896. };
  43897. },
  43898. createExpressionStatement: function (expression) {
  43899. return {
  43900. type: Syntax.ExpressionStatement,
  43901. expression: expression
  43902. };
  43903. },
  43904. createForStatement: function (init, test, update, body) {
  43905. return {
  43906. type: Syntax.ForStatement,
  43907. init: init,
  43908. test: test,
  43909. update: update,
  43910. body: body
  43911. };
  43912. },
  43913. createForInStatement: function (left, right, body) {
  43914. return {
  43915. type: Syntax.ForInStatement,
  43916. left: left,
  43917. right: right,
  43918. body: body,
  43919. each: false
  43920. };
  43921. },
  43922. createForOfStatement: function (left, right, body) {
  43923. return {
  43924. type: Syntax.ForOfStatement,
  43925. left: left,
  43926. right: right,
  43927. body: body
  43928. };
  43929. },
  43930. createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
  43931. isAsync, returnType, typeParameters) {
  43932. var funDecl = {
  43933. type: Syntax.FunctionDeclaration,
  43934. id: id,
  43935. params: params,
  43936. defaults: defaults,
  43937. body: body,
  43938. rest: rest,
  43939. generator: generator,
  43940. expression: expression,
  43941. returnType: returnType,
  43942. typeParameters: typeParameters
  43943. };
  43944. if (isAsync) {
  43945. funDecl.async = true;
  43946. }
  43947. return funDecl;
  43948. },
  43949. createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
  43950. isAsync, returnType, typeParameters) {
  43951. var funExpr = {
  43952. type: Syntax.FunctionExpression,
  43953. id: id,
  43954. params: params,
  43955. defaults: defaults,
  43956. body: body,
  43957. rest: rest,
  43958. generator: generator,
  43959. expression: expression,
  43960. returnType: returnType,
  43961. typeParameters: typeParameters
  43962. };
  43963. if (isAsync) {
  43964. funExpr.async = true;
  43965. }
  43966. return funExpr;
  43967. },
  43968. createIdentifier: function (name) {
  43969. return {
  43970. type: Syntax.Identifier,
  43971. name: name,
  43972. // Only here to initialize the shape of the object to ensure
  43973. // that the 'typeAnnotation' key is ordered before others that
  43974. // are added later (like 'loc' and 'range'). This just helps
  43975. // keep the shape of Identifier nodes consistent with everything
  43976. // else.
  43977. typeAnnotation: undefined,
  43978. optional: undefined
  43979. };
  43980. },
  43981. createTypeAnnotation: function (typeAnnotation) {
  43982. return {
  43983. type: Syntax.TypeAnnotation,
  43984. typeAnnotation: typeAnnotation
  43985. };
  43986. },
  43987. createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
  43988. return {
  43989. type: Syntax.FunctionTypeAnnotation,
  43990. params: params,
  43991. returnType: returnType,
  43992. rest: rest,
  43993. typeParameters: typeParameters
  43994. };
  43995. },
  43996. createFunctionTypeParam: function (name, typeAnnotation, optional) {
  43997. return {
  43998. type: Syntax.FunctionTypeParam,
  43999. name: name,
  44000. typeAnnotation: typeAnnotation,
  44001. optional: optional
  44002. };
  44003. },
  44004. createNullableTypeAnnotation: function (typeAnnotation) {
  44005. return {
  44006. type: Syntax.NullableTypeAnnotation,
  44007. typeAnnotation: typeAnnotation
  44008. };
  44009. },
  44010. createArrayTypeAnnotation: function (elementType) {
  44011. return {
  44012. type: Syntax.ArrayTypeAnnotation,
  44013. elementType: elementType
  44014. };
  44015. },
  44016. createGenericTypeAnnotation: function (id, typeParameters) {
  44017. return {
  44018. type: Syntax.GenericTypeAnnotation,
  44019. id: id,
  44020. typeParameters: typeParameters
  44021. };
  44022. },
  44023. createQualifiedTypeIdentifier: function (qualification, id) {
  44024. return {
  44025. type: Syntax.QualifiedTypeIdentifier,
  44026. qualification: qualification,
  44027. id: id
  44028. };
  44029. },
  44030. createTypeParameterDeclaration: function (params) {
  44031. return {
  44032. type: Syntax.TypeParameterDeclaration,
  44033. params: params
  44034. };
  44035. },
  44036. createTypeParameterInstantiation: function (params) {
  44037. return {
  44038. type: Syntax.TypeParameterInstantiation,
  44039. params: params
  44040. };
  44041. },
  44042. createAnyTypeAnnotation: function () {
  44043. return {
  44044. type: Syntax.AnyTypeAnnotation
  44045. };
  44046. },
  44047. createBooleanTypeAnnotation: function () {
  44048. return {
  44049. type: Syntax.BooleanTypeAnnotation
  44050. };
  44051. },
  44052. createNumberTypeAnnotation: function () {
  44053. return {
  44054. type: Syntax.NumberTypeAnnotation
  44055. };
  44056. },
  44057. createStringTypeAnnotation: function () {
  44058. return {
  44059. type: Syntax.StringTypeAnnotation
  44060. };
  44061. },
  44062. createStringLiteralTypeAnnotation: function (token) {
  44063. return {
  44064. type: Syntax.StringLiteralTypeAnnotation,
  44065. value: token.value,
  44066. raw: source.slice(token.range[0], token.range[1])
  44067. };
  44068. },
  44069. createVoidTypeAnnotation: function () {
  44070. return {
  44071. type: Syntax.VoidTypeAnnotation
  44072. };
  44073. },
  44074. createTypeofTypeAnnotation: function (argument) {
  44075. return {
  44076. type: Syntax.TypeofTypeAnnotation,
  44077. argument: argument
  44078. };
  44079. },
  44080. createTupleTypeAnnotation: function (types) {
  44081. return {
  44082. type: Syntax.TupleTypeAnnotation,
  44083. types: types
  44084. };
  44085. },
  44086. createObjectTypeAnnotation: function (properties, indexers, callProperties) {
  44087. return {
  44088. type: Syntax.ObjectTypeAnnotation,
  44089. properties: properties,
  44090. indexers: indexers,
  44091. callProperties: callProperties
  44092. };
  44093. },
  44094. createObjectTypeIndexer: function (id, key, value, isStatic) {
  44095. return {
  44096. type: Syntax.ObjectTypeIndexer,
  44097. id: id,
  44098. key: key,
  44099. value: value,
  44100. static: isStatic
  44101. };
  44102. },
  44103. createObjectTypeCallProperty: function (value, isStatic) {
  44104. return {
  44105. type: Syntax.ObjectTypeCallProperty,
  44106. value: value,
  44107. static: isStatic
  44108. };
  44109. },
  44110. createObjectTypeProperty: function (key, value, optional, isStatic) {
  44111. return {
  44112. type: Syntax.ObjectTypeProperty,
  44113. key: key,
  44114. value: value,
  44115. optional: optional,
  44116. static: isStatic
  44117. };
  44118. },
  44119. createUnionTypeAnnotation: function (types) {
  44120. return {
  44121. type: Syntax.UnionTypeAnnotation,
  44122. types: types
  44123. };
  44124. },
  44125. createIntersectionTypeAnnotation: function (types) {
  44126. return {
  44127. type: Syntax.IntersectionTypeAnnotation,
  44128. types: types
  44129. };
  44130. },
  44131. createTypeAlias: function (id, typeParameters, right) {
  44132. return {
  44133. type: Syntax.TypeAlias,
  44134. id: id,
  44135. typeParameters: typeParameters,
  44136. right: right
  44137. };
  44138. },
  44139. createInterface: function (id, typeParameters, body, extended) {
  44140. return {
  44141. type: Syntax.InterfaceDeclaration,
  44142. id: id,
  44143. typeParameters: typeParameters,
  44144. body: body,
  44145. extends: extended
  44146. };
  44147. },
  44148. createInterfaceExtends: function (id, typeParameters) {
  44149. return {
  44150. type: Syntax.InterfaceExtends,
  44151. id: id,
  44152. typeParameters: typeParameters
  44153. };
  44154. },
  44155. createDeclareFunction: function (id) {
  44156. return {
  44157. type: Syntax.DeclareFunction,
  44158. id: id
  44159. };
  44160. },
  44161. createDeclareVariable: function (id) {
  44162. return {
  44163. type: Syntax.DeclareVariable,
  44164. id: id
  44165. };
  44166. },
  44167. createDeclareModule: function (id, body) {
  44168. return {
  44169. type: Syntax.DeclareModule,
  44170. id: id,
  44171. body: body
  44172. };
  44173. },
  44174. createXJSAttribute: function (name, value) {
  44175. return {
  44176. type: Syntax.XJSAttribute,
  44177. name: name,
  44178. value: value || null
  44179. };
  44180. },
  44181. createXJSSpreadAttribute: function (argument) {
  44182. return {
  44183. type: Syntax.XJSSpreadAttribute,
  44184. argument: argument
  44185. };
  44186. },
  44187. createXJSIdentifier: function (name) {
  44188. return {
  44189. type: Syntax.XJSIdentifier,
  44190. name: name
  44191. };
  44192. },
  44193. createXJSNamespacedName: function (namespace, name) {
  44194. return {
  44195. type: Syntax.XJSNamespacedName,
  44196. namespace: namespace,
  44197. name: name
  44198. };
  44199. },
  44200. createXJSMemberExpression: function (object, property) {
  44201. return {
  44202. type: Syntax.XJSMemberExpression,
  44203. object: object,
  44204. property: property
  44205. };
  44206. },
  44207. createXJSElement: function (openingElement, closingElement, children) {
  44208. return {
  44209. type: Syntax.XJSElement,
  44210. openingElement: openingElement,
  44211. closingElement: closingElement,
  44212. children: children
  44213. };
  44214. },
  44215. createXJSEmptyExpression: function () {
  44216. return {
  44217. type: Syntax.XJSEmptyExpression
  44218. };
  44219. },
  44220. createXJSExpressionContainer: function (expression) {
  44221. return {
  44222. type: Syntax.XJSExpressionContainer,
  44223. expression: expression
  44224. };
  44225. },
  44226. createXJSOpeningElement: function (name, attributes, selfClosing) {
  44227. return {
  44228. type: Syntax.XJSOpeningElement,
  44229. name: name,
  44230. selfClosing: selfClosing,
  44231. attributes: attributes
  44232. };
  44233. },
  44234. createXJSClosingElement: function (name) {
  44235. return {
  44236. type: Syntax.XJSClosingElement,
  44237. name: name
  44238. };
  44239. },
  44240. createIfStatement: function (test, consequent, alternate) {
  44241. return {
  44242. type: Syntax.IfStatement,
  44243. test: test,
  44244. consequent: consequent,
  44245. alternate: alternate
  44246. };
  44247. },
  44248. createLabeledStatement: function (label, body) {
  44249. return {
  44250. type: Syntax.LabeledStatement,
  44251. label: label,
  44252. body: body
  44253. };
  44254. },
  44255. createLiteral: function (token) {
  44256. var object = {
  44257. type: Syntax.Literal,
  44258. value: token.value,
  44259. raw: source.slice(token.range[0], token.range[1])
  44260. };
  44261. if (token.regex) {
  44262. object.regex = token.regex;
  44263. }
  44264. return object;
  44265. },
  44266. createMemberExpression: function (accessor, object, property) {
  44267. return {
  44268. type: Syntax.MemberExpression,
  44269. computed: accessor === '[',
  44270. object: object,
  44271. property: property
  44272. };
  44273. },
  44274. createNewExpression: function (callee, args) {
  44275. return {
  44276. type: Syntax.NewExpression,
  44277. callee: callee,
  44278. 'arguments': args
  44279. };
  44280. },
  44281. createObjectExpression: function (properties) {
  44282. return {
  44283. type: Syntax.ObjectExpression,
  44284. properties: properties
  44285. };
  44286. },
  44287. createPostfixExpression: function (operator, argument) {
  44288. return {
  44289. type: Syntax.UpdateExpression,
  44290. operator: operator,
  44291. argument: argument,
  44292. prefix: false
  44293. };
  44294. },
  44295. createProgram: function (body) {
  44296. return {
  44297. type: Syntax.Program,
  44298. body: body
  44299. };
  44300. },
  44301. createProperty: function (kind, key, value, method, shorthand, computed) {
  44302. return {
  44303. type: Syntax.Property,
  44304. key: key,
  44305. value: value,
  44306. kind: kind,
  44307. method: method,
  44308. shorthand: shorthand,
  44309. computed: computed
  44310. };
  44311. },
  44312. createReturnStatement: function (argument) {
  44313. return {
  44314. type: Syntax.ReturnStatement,
  44315. argument: argument
  44316. };
  44317. },
  44318. createSequenceExpression: function (expressions) {
  44319. return {
  44320. type: Syntax.SequenceExpression,
  44321. expressions: expressions
  44322. };
  44323. },
  44324. createSwitchCase: function (test, consequent) {
  44325. return {
  44326. type: Syntax.SwitchCase,
  44327. test: test,
  44328. consequent: consequent
  44329. };
  44330. },
  44331. createSwitchStatement: function (discriminant, cases) {
  44332. return {
  44333. type: Syntax.SwitchStatement,
  44334. discriminant: discriminant,
  44335. cases: cases
  44336. };
  44337. },
  44338. createThisExpression: function () {
  44339. return {
  44340. type: Syntax.ThisExpression
  44341. };
  44342. },
  44343. createThrowStatement: function (argument) {
  44344. return {
  44345. type: Syntax.ThrowStatement,
  44346. argument: argument
  44347. };
  44348. },
  44349. createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
  44350. return {
  44351. type: Syntax.TryStatement,
  44352. block: block,
  44353. guardedHandlers: guardedHandlers,
  44354. handlers: handlers,
  44355. finalizer: finalizer
  44356. };
  44357. },
  44358. createUnaryExpression: function (operator, argument) {
  44359. if (operator === '++' || operator === '--') {
  44360. return {
  44361. type: Syntax.UpdateExpression,
  44362. operator: operator,
  44363. argument: argument,
  44364. prefix: true
  44365. };
  44366. }
  44367. return {
  44368. type: Syntax.UnaryExpression,
  44369. operator: operator,
  44370. argument: argument,
  44371. prefix: true
  44372. };
  44373. },
  44374. createVariableDeclaration: function (declarations, kind) {
  44375. return {
  44376. type: Syntax.VariableDeclaration,
  44377. declarations: declarations,
  44378. kind: kind
  44379. };
  44380. },
  44381. createVariableDeclarator: function (id, init) {
  44382. return {
  44383. type: Syntax.VariableDeclarator,
  44384. id: id,
  44385. init: init
  44386. };
  44387. },
  44388. createWhileStatement: function (test, body) {
  44389. return {
  44390. type: Syntax.WhileStatement,
  44391. test: test,
  44392. body: body
  44393. };
  44394. },
  44395. createWithStatement: function (object, body) {
  44396. return {
  44397. type: Syntax.WithStatement,
  44398. object: object,
  44399. body: body
  44400. };
  44401. },
  44402. createTemplateElement: function (value, tail) {
  44403. return {
  44404. type: Syntax.TemplateElement,
  44405. value: value,
  44406. tail: tail
  44407. };
  44408. },
  44409. createTemplateLiteral: function (quasis, expressions) {
  44410. return {
  44411. type: Syntax.TemplateLiteral,
  44412. quasis: quasis,
  44413. expressions: expressions
  44414. };
  44415. },
  44416. createSpreadElement: function (argument) {
  44417. return {
  44418. type: Syntax.SpreadElement,
  44419. argument: argument
  44420. };
  44421. },
  44422. createSpreadProperty: function (argument) {
  44423. return {
  44424. type: Syntax.SpreadProperty,
  44425. argument: argument
  44426. };
  44427. },
  44428. createTaggedTemplateExpression: function (tag, quasi) {
  44429. return {
  44430. type: Syntax.TaggedTemplateExpression,
  44431. tag: tag,
  44432. quasi: quasi
  44433. };
  44434. },
  44435. createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
  44436. var arrowExpr = {
  44437. type: Syntax.ArrowFunctionExpression,
  44438. id: null,
  44439. params: params,
  44440. defaults: defaults,
  44441. body: body,
  44442. rest: rest,
  44443. generator: false,
  44444. expression: expression
  44445. };
  44446. if (isAsync) {
  44447. arrowExpr.async = true;
  44448. }
  44449. return arrowExpr;
  44450. },
  44451. createMethodDefinition: function (propertyType, kind, key, value) {
  44452. return {
  44453. type: Syntax.MethodDefinition,
  44454. key: key,
  44455. value: value,
  44456. kind: kind,
  44457. 'static': propertyType === ClassPropertyType.static
  44458. };
  44459. },
  44460. createClassProperty: function (key, typeAnnotation, computed, isStatic) {
  44461. return {
  44462. type: Syntax.ClassProperty,
  44463. key: key,
  44464. typeAnnotation: typeAnnotation,
  44465. computed: computed,
  44466. static: isStatic
  44467. };
  44468. },
  44469. createClassBody: function (body) {
  44470. return {
  44471. type: Syntax.ClassBody,
  44472. body: body
  44473. };
  44474. },
  44475. createClassImplements: function (id, typeParameters) {
  44476. return {
  44477. type: Syntax.ClassImplements,
  44478. id: id,
  44479. typeParameters: typeParameters
  44480. };
  44481. },
  44482. createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  44483. return {
  44484. type: Syntax.ClassExpression,
  44485. id: id,
  44486. superClass: superClass,
  44487. body: body,
  44488. typeParameters: typeParameters,
  44489. superTypeParameters: superTypeParameters,
  44490. implements: implemented
  44491. };
  44492. },
  44493. createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  44494. return {
  44495. type: Syntax.ClassDeclaration,
  44496. id: id,
  44497. superClass: superClass,
  44498. body: body,
  44499. typeParameters: typeParameters,
  44500. superTypeParameters: superTypeParameters,
  44501. implements: implemented
  44502. };
  44503. },
  44504. createModuleSpecifier: function (token) {
  44505. return {
  44506. type: Syntax.ModuleSpecifier,
  44507. value: token.value,
  44508. raw: source.slice(token.range[0], token.range[1])
  44509. };
  44510. },
  44511. createExportSpecifier: function (id, name) {
  44512. return {
  44513. type: Syntax.ExportSpecifier,
  44514. id: id,
  44515. name: name
  44516. };
  44517. },
  44518. createExportBatchSpecifier: function () {
  44519. return {
  44520. type: Syntax.ExportBatchSpecifier
  44521. };
  44522. },
  44523. createImportDefaultSpecifier: function (id) {
  44524. return {
  44525. type: Syntax.ImportDefaultSpecifier,
  44526. id: id
  44527. };
  44528. },
  44529. createImportNamespaceSpecifier: function (id) {
  44530. return {
  44531. type: Syntax.ImportNamespaceSpecifier,
  44532. id: id
  44533. };
  44534. },
  44535. createExportDeclaration: function (isDefault, declaration, specifiers, source) {
  44536. return {
  44537. type: Syntax.ExportDeclaration,
  44538. 'default': !!isDefault,
  44539. declaration: declaration,
  44540. specifiers: specifiers,
  44541. source: source
  44542. };
  44543. },
  44544. createImportSpecifier: function (id, name) {
  44545. return {
  44546. type: Syntax.ImportSpecifier,
  44547. id: id,
  44548. name: name
  44549. };
  44550. },
  44551. createImportDeclaration: function (specifiers, source) {
  44552. return {
  44553. type: Syntax.ImportDeclaration,
  44554. specifiers: specifiers,
  44555. source: source
  44556. };
  44557. },
  44558. createYieldExpression: function (argument, delegate) {
  44559. return {
  44560. type: Syntax.YieldExpression,
  44561. argument: argument,
  44562. delegate: delegate
  44563. };
  44564. },
  44565. createAwaitExpression: function (argument) {
  44566. return {
  44567. type: Syntax.AwaitExpression,
  44568. argument: argument
  44569. };
  44570. },
  44571. createComprehensionExpression: function (filter, blocks, body) {
  44572. return {
  44573. type: Syntax.ComprehensionExpression,
  44574. filter: filter,
  44575. blocks: blocks,
  44576. body: body
  44577. };
  44578. }
  44579. };
  44580. // Return true if there is a line terminator before the next token.
  44581. function peekLineTerminator() {
  44582. var pos, line, start, found;
  44583. pos = index;
  44584. line = lineNumber;
  44585. start = lineStart;
  44586. skipComment();
  44587. found = lineNumber !== line;
  44588. index = pos;
  44589. lineNumber = line;
  44590. lineStart = start;
  44591. return found;
  44592. }
  44593. // Throw an exception
  44594. function throwError(token, messageFormat) {
  44595. var error,
  44596. args = Array.prototype.slice.call(arguments, 2),
  44597. msg = messageFormat.replace(
  44598. /%(\d)/g,
  44599. function (whole, index) {
  44600. assert(index < args.length, 'Message reference must be in range');
  44601. return args[index];
  44602. }
  44603. );
  44604. if (typeof token.lineNumber === 'number') {
  44605. error = new Error('Line ' + token.lineNumber + ': ' + msg);
  44606. error.index = token.range[0];
  44607. error.lineNumber = token.lineNumber;
  44608. error.column = token.range[0] - lineStart + 1;
  44609. } else {
  44610. error = new Error('Line ' + lineNumber + ': ' + msg);
  44611. error.index = index;
  44612. error.lineNumber = lineNumber;
  44613. error.column = index - lineStart + 1;
  44614. }
  44615. error.description = msg;
  44616. throw error;
  44617. }
  44618. function throwErrorTolerant() {
  44619. try {
  44620. throwError.apply(null, arguments);
  44621. } catch (e) {
  44622. if (extra.errors) {
  44623. extra.errors.push(e);
  44624. } else {
  44625. throw e;
  44626. }
  44627. }
  44628. }
  44629. // Throw an exception because of the token.
  44630. function throwUnexpected(token) {
  44631. if (token.type === Token.EOF) {
  44632. throwError(token, Messages.UnexpectedEOS);
  44633. }
  44634. if (token.type === Token.NumericLiteral) {
  44635. throwError(token, Messages.UnexpectedNumber);
  44636. }
  44637. if (token.type === Token.StringLiteral || token.type === Token.XJSText) {
  44638. throwError(token, Messages.UnexpectedString);
  44639. }
  44640. if (token.type === Token.Identifier) {
  44641. throwError(token, Messages.UnexpectedIdentifier);
  44642. }
  44643. if (token.type === Token.Keyword) {
  44644. if (isFutureReservedWord(token.value)) {
  44645. throwError(token, Messages.UnexpectedReserved);
  44646. } else if (strict && isStrictModeReservedWord(token.value)) {
  44647. throwErrorTolerant(token, Messages.StrictReservedWord);
  44648. return;
  44649. }
  44650. throwError(token, Messages.UnexpectedToken, token.value);
  44651. }
  44652. if (token.type === Token.Template) {
  44653. throwError(token, Messages.UnexpectedTemplate, token.value.raw);
  44654. }
  44655. // BooleanLiteral, NullLiteral, or Punctuator.
  44656. throwError(token, Messages.UnexpectedToken, token.value);
  44657. }
  44658. // Expect the next token to match the specified punctuator.
  44659. // If not, an exception will be thrown.
  44660. function expect(value) {
  44661. var token = lex();
  44662. if (token.type !== Token.Punctuator || token.value !== value) {
  44663. throwUnexpected(token);
  44664. }
  44665. }
  44666. // Expect the next token to match the specified keyword.
  44667. // If not, an exception will be thrown.
  44668. function expectKeyword(keyword, contextual) {
  44669. var token = lex();
  44670. if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
  44671. token.value !== keyword) {
  44672. throwUnexpected(token);
  44673. }
  44674. }
  44675. // Expect the next token to match the specified contextual keyword.
  44676. // If not, an exception will be thrown.
  44677. function expectContextualKeyword(keyword) {
  44678. return expectKeyword(keyword, true);
  44679. }
  44680. // Return true if the next token matches the specified punctuator.
  44681. function match(value) {
  44682. return lookahead.type === Token.Punctuator && lookahead.value === value;
  44683. }
  44684. // Return true if the next token matches the specified keyword
  44685. function matchKeyword(keyword, contextual) {
  44686. var expectedType = contextual ? Token.Identifier : Token.Keyword;
  44687. return lookahead.type === expectedType && lookahead.value === keyword;
  44688. }
  44689. // Return true if the next token matches the specified contextual keyword
  44690. function matchContextualKeyword(keyword) {
  44691. return matchKeyword(keyword, true);
  44692. }
  44693. // Return true if the next token is an assignment operator
  44694. function matchAssign() {
  44695. var op;
  44696. if (lookahead.type !== Token.Punctuator) {
  44697. return false;
  44698. }
  44699. op = lookahead.value;
  44700. return op === '=' ||
  44701. op === '*=' ||
  44702. op === '/=' ||
  44703. op === '%=' ||
  44704. op === '+=' ||
  44705. op === '-=' ||
  44706. op === '<<=' ||
  44707. op === '>>=' ||
  44708. op === '>>>=' ||
  44709. op === '&=' ||
  44710. op === '^=' ||
  44711. op === '|=';
  44712. }
  44713. // Note that 'yield' is treated as a keyword in strict mode, but a
  44714. // contextual keyword (identifier) in non-strict mode, so we need to
  44715. // use matchKeyword('yield', false) and matchKeyword('yield', true)
  44716. // (i.e. matchContextualKeyword) appropriately.
  44717. function matchYield() {
  44718. return state.yieldAllowed && matchKeyword('yield', !strict);
  44719. }
  44720. function matchAsync() {
  44721. var backtrackToken = lookahead, matches = false;
  44722. if (matchContextualKeyword('async')) {
  44723. lex(); // Make sure peekLineTerminator() starts after 'async'.
  44724. matches = !peekLineTerminator();
  44725. rewind(backtrackToken); // Revert the lex().
  44726. }
  44727. return matches;
  44728. }
  44729. function matchAwait() {
  44730. return state.awaitAllowed && matchContextualKeyword('await');
  44731. }
  44732. function consumeSemicolon() {
  44733. var line, oldIndex = index, oldLineNumber = lineNumber,
  44734. oldLineStart = lineStart, oldLookahead = lookahead;
  44735. // Catch the very common case first: immediately a semicolon (char #59).
  44736. if (source.charCodeAt(index) === 59) {
  44737. lex();
  44738. return;
  44739. }
  44740. line = lineNumber;
  44741. skipComment();
  44742. if (lineNumber !== line) {
  44743. index = oldIndex;
  44744. lineNumber = oldLineNumber;
  44745. lineStart = oldLineStart;
  44746. lookahead = oldLookahead;
  44747. return;
  44748. }
  44749. if (match(';')) {
  44750. lex();
  44751. return;
  44752. }
  44753. if (lookahead.type !== Token.EOF && !match('}')) {
  44754. throwUnexpected(lookahead);
  44755. }
  44756. }
  44757. // Return true if provided expression is LeftHandSideExpression
  44758. function isLeftHandSide(expr) {
  44759. return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
  44760. }
  44761. function isAssignableLeftHandSide(expr) {
  44762. return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
  44763. }
  44764. // 11.1.4 Array Initialiser
  44765. function parseArrayInitialiser() {
  44766. var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, body,
  44767. marker = markerCreate();
  44768. expect('[');
  44769. while (!match(']')) {
  44770. if (lookahead.value === 'for' &&
  44771. lookahead.type === Token.Keyword) {
  44772. if (!possiblecomprehension) {
  44773. throwError({}, Messages.ComprehensionError);
  44774. }
  44775. matchKeyword('for');
  44776. tmp = parseForStatement({ignoreBody: true});
  44777. tmp.of = tmp.type === Syntax.ForOfStatement;
  44778. tmp.type = Syntax.ComprehensionBlock;
  44779. if (tmp.left.kind) { // can't be let or const
  44780. throwError({}, Messages.ComprehensionError);
  44781. }
  44782. blocks.push(tmp);
  44783. } else if (lookahead.value === 'if' &&
  44784. lookahead.type === Token.Keyword) {
  44785. if (!possiblecomprehension) {
  44786. throwError({}, Messages.ComprehensionError);
  44787. }
  44788. expectKeyword('if');
  44789. expect('(');
  44790. filter = parseExpression();
  44791. expect(')');
  44792. } else if (lookahead.value === ',' &&
  44793. lookahead.type === Token.Punctuator) {
  44794. possiblecomprehension = false; // no longer allowed.
  44795. lex();
  44796. elements.push(null);
  44797. } else {
  44798. tmp = parseSpreadOrAssignmentExpression();
  44799. elements.push(tmp);
  44800. if (tmp && tmp.type === Syntax.SpreadElement) {
  44801. if (!match(']')) {
  44802. throwError({}, Messages.ElementAfterSpreadElement);
  44803. }
  44804. } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
  44805. expect(','); // this lexes.
  44806. possiblecomprehension = false;
  44807. }
  44808. }
  44809. }
  44810. expect(']');
  44811. if (filter && !blocks.length) {
  44812. throwError({}, Messages.ComprehensionRequiresBlock);
  44813. }
  44814. if (blocks.length) {
  44815. if (elements.length !== 1) {
  44816. throwError({}, Messages.ComprehensionError);
  44817. }
  44818. return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
  44819. }
  44820. return markerApply(marker, delegate.createArrayExpression(elements));
  44821. }
  44822. // 11.1.5 Object Initialiser
  44823. function parsePropertyFunction(options) {
  44824. var previousStrict, previousYieldAllowed, previousAwaitAllowed,
  44825. params, defaults, body, marker = markerCreate();
  44826. previousStrict = strict;
  44827. previousYieldAllowed = state.yieldAllowed;
  44828. state.yieldAllowed = options.generator;
  44829. previousAwaitAllowed = state.awaitAllowed;
  44830. state.awaitAllowed = options.async;
  44831. params = options.params || [];
  44832. defaults = options.defaults || [];
  44833. body = parseConciseBody();
  44834. if (options.name && strict && isRestrictedWord(params[0].name)) {
  44835. throwErrorTolerant(options.name, Messages.StrictParamName);
  44836. }
  44837. strict = previousStrict;
  44838. state.yieldAllowed = previousYieldAllowed;
  44839. state.awaitAllowed = previousAwaitAllowed;
  44840. return markerApply(marker, delegate.createFunctionExpression(
  44841. null,
  44842. params,
  44843. defaults,
  44844. body,
  44845. options.rest || null,
  44846. options.generator,
  44847. body.type !== Syntax.BlockStatement,
  44848. options.async,
  44849. options.returnType,
  44850. options.typeParameters
  44851. ));
  44852. }
  44853. function parsePropertyMethodFunction(options) {
  44854. var previousStrict, tmp, method;
  44855. previousStrict = strict;
  44856. strict = true;
  44857. tmp = parseParams();
  44858. if (tmp.stricted) {
  44859. throwErrorTolerant(tmp.stricted, tmp.message);
  44860. }
  44861. method = parsePropertyFunction({
  44862. params: tmp.params,
  44863. defaults: tmp.defaults,
  44864. rest: tmp.rest,
  44865. generator: options.generator,
  44866. async: options.async,
  44867. returnType: tmp.returnType,
  44868. typeParameters: options.typeParameters
  44869. });
  44870. strict = previousStrict;
  44871. return method;
  44872. }
  44873. function parseObjectPropertyKey() {
  44874. var marker = markerCreate(),
  44875. token = lex(),
  44876. propertyKey,
  44877. result;
  44878. // Note: This function is called only from parseObjectProperty(), where
  44879. // EOF and Punctuator tokens are already filtered out.
  44880. if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
  44881. if (strict && token.octal) {
  44882. throwErrorTolerant(token, Messages.StrictOctalLiteral);
  44883. }
  44884. return markerApply(marker, delegate.createLiteral(token));
  44885. }
  44886. if (token.type === Token.Punctuator && token.value === '[') {
  44887. // For computed properties we should skip the [ and ], and
  44888. // capture in marker only the assignment expression itself.
  44889. marker = markerCreate();
  44890. propertyKey = parseAssignmentExpression();
  44891. result = markerApply(marker, propertyKey);
  44892. expect(']');
  44893. return result;
  44894. }
  44895. return markerApply(marker, delegate.createIdentifier(token.value));
  44896. }
  44897. function parseObjectProperty() {
  44898. var token, key, id, value, param, expr, computed,
  44899. marker = markerCreate(), returnType;
  44900. token = lookahead;
  44901. computed = (token.value === '[');
  44902. if (token.type === Token.Identifier || computed || matchAsync()) {
  44903. id = parseObjectPropertyKey();
  44904. if (match(':')) {
  44905. lex();
  44906. return markerApply(
  44907. marker,
  44908. delegate.createProperty(
  44909. 'init',
  44910. id,
  44911. parseAssignmentExpression(),
  44912. false,
  44913. false,
  44914. computed
  44915. )
  44916. );
  44917. }
  44918. if (match('(')) {
  44919. return markerApply(
  44920. marker,
  44921. delegate.createProperty(
  44922. 'init',
  44923. id,
  44924. parsePropertyMethodFunction({
  44925. generator: false,
  44926. async: false
  44927. }),
  44928. true,
  44929. false,
  44930. computed
  44931. )
  44932. );
  44933. }
  44934. // Property Assignment: Getter and Setter.
  44935. if (token.value === 'get') {
  44936. computed = (lookahead.value === '[');
  44937. key = parseObjectPropertyKey();
  44938. expect('(');
  44939. expect(')');
  44940. if (match(':')) {
  44941. returnType = parseTypeAnnotation();
  44942. }
  44943. return markerApply(
  44944. marker,
  44945. delegate.createProperty(
  44946. 'get',
  44947. key,
  44948. parsePropertyFunction({
  44949. generator: false,
  44950. async: false,
  44951. returnType: returnType
  44952. }),
  44953. false,
  44954. false,
  44955. computed
  44956. )
  44957. );
  44958. }
  44959. if (token.value === 'set') {
  44960. computed = (lookahead.value === '[');
  44961. key = parseObjectPropertyKey();
  44962. expect('(');
  44963. token = lookahead;
  44964. param = [ parseTypeAnnotatableIdentifier() ];
  44965. expect(')');
  44966. if (match(':')) {
  44967. returnType = parseTypeAnnotation();
  44968. }
  44969. return markerApply(
  44970. marker,
  44971. delegate.createProperty(
  44972. 'set',
  44973. key,
  44974. parsePropertyFunction({
  44975. params: param,
  44976. generator: false,
  44977. async: false,
  44978. name: token,
  44979. returnType: returnType
  44980. }),
  44981. false,
  44982. false,
  44983. computed
  44984. )
  44985. );
  44986. }
  44987. if (token.value === 'async') {
  44988. computed = (lookahead.value === '[');
  44989. key = parseObjectPropertyKey();
  44990. return markerApply(
  44991. marker,
  44992. delegate.createProperty(
  44993. 'init',
  44994. key,
  44995. parsePropertyMethodFunction({
  44996. generator: false,
  44997. async: true
  44998. }),
  44999. true,
  45000. false,
  45001. computed
  45002. )
  45003. );
  45004. }
  45005. if (computed) {
  45006. // Computed properties can only be used with full notation.
  45007. throwUnexpected(lookahead);
  45008. }
  45009. return markerApply(
  45010. marker,
  45011. delegate.createProperty('init', id, id, false, true, false)
  45012. );
  45013. }
  45014. if (token.type === Token.EOF || token.type === Token.Punctuator) {
  45015. if (!match('*')) {
  45016. throwUnexpected(token);
  45017. }
  45018. lex();
  45019. computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
  45020. id = parseObjectPropertyKey();
  45021. if (!match('(')) {
  45022. throwUnexpected(lex());
  45023. }
  45024. return markerApply(marker, delegate.createProperty('init', id, parsePropertyMethodFunction({ generator: true }), true, false, computed));
  45025. }
  45026. key = parseObjectPropertyKey();
  45027. if (match(':')) {
  45028. lex();
  45029. return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
  45030. }
  45031. if (match('(')) {
  45032. return markerApply(marker, delegate.createProperty('init', key, parsePropertyMethodFunction({ generator: false }), true, false, false));
  45033. }
  45034. throwUnexpected(lex());
  45035. }
  45036. function parseObjectSpreadProperty() {
  45037. var marker = markerCreate();
  45038. expect('...');
  45039. return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
  45040. }
  45041. function parseObjectInitialiser() {
  45042. var properties = [], property, name, key, kind, map = {}, toString = String,
  45043. marker = markerCreate();
  45044. expect('{');
  45045. while (!match('}')) {
  45046. if (match('...')) {
  45047. property = parseObjectSpreadProperty();
  45048. } else {
  45049. property = parseObjectProperty();
  45050. if (property.key.type === Syntax.Identifier) {
  45051. name = property.key.name;
  45052. } else {
  45053. name = toString(property.key.value);
  45054. }
  45055. kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
  45056. key = '$' + name;
  45057. if (Object.prototype.hasOwnProperty.call(map, key)) {
  45058. if (map[key] === PropertyKind.Data) {
  45059. if (strict && kind === PropertyKind.Data) {
  45060. throwErrorTolerant({}, Messages.StrictDuplicateProperty);
  45061. } else if (kind !== PropertyKind.Data) {
  45062. throwErrorTolerant({}, Messages.AccessorDataProperty);
  45063. }
  45064. } else {
  45065. if (kind === PropertyKind.Data) {
  45066. throwErrorTolerant({}, Messages.AccessorDataProperty);
  45067. } else if (map[key] & kind) {
  45068. throwErrorTolerant({}, Messages.AccessorGetSet);
  45069. }
  45070. }
  45071. map[key] |= kind;
  45072. } else {
  45073. map[key] = kind;
  45074. }
  45075. }
  45076. properties.push(property);
  45077. if (!match('}')) {
  45078. expect(',');
  45079. }
  45080. }
  45081. expect('}');
  45082. return markerApply(marker, delegate.createObjectExpression(properties));
  45083. }
  45084. function parseTemplateElement(option) {
  45085. var marker = markerCreate(),
  45086. token = scanTemplateElement(option);
  45087. if (strict && token.octal) {
  45088. throwError(token, Messages.StrictOctalLiteral);
  45089. }
  45090. return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
  45091. }
  45092. function parseTemplateLiteral() {
  45093. var quasi, quasis, expressions, marker = markerCreate();
  45094. quasi = parseTemplateElement({ head: true });
  45095. quasis = [ quasi ];
  45096. expressions = [];
  45097. while (!quasi.tail) {
  45098. expressions.push(parseExpression());
  45099. quasi = parseTemplateElement({ head: false });
  45100. quasis.push(quasi);
  45101. }
  45102. return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
  45103. }
  45104. // 11.1.6 The Grouping Operator
  45105. function parseGroupExpression() {
  45106. var expr;
  45107. expect('(');
  45108. ++state.parenthesizedCount;
  45109. expr = parseExpression();
  45110. expect(')');
  45111. return expr;
  45112. }
  45113. function matchAsyncFuncExprOrDecl() {
  45114. var token;
  45115. if (matchAsync()) {
  45116. token = lookahead2();
  45117. if (token.type === Token.Keyword && token.value === 'function') {
  45118. return true;
  45119. }
  45120. }
  45121. return false;
  45122. }
  45123. // 11.1 Primary Expressions
  45124. function parsePrimaryExpression() {
  45125. var marker, type, token, expr;
  45126. type = lookahead.type;
  45127. if (type === Token.Identifier) {
  45128. marker = markerCreate();
  45129. return markerApply(marker, delegate.createIdentifier(lex().value));
  45130. }
  45131. if (type === Token.StringLiteral || type === Token.NumericLiteral) {
  45132. if (strict && lookahead.octal) {
  45133. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  45134. }
  45135. marker = markerCreate();
  45136. return markerApply(marker, delegate.createLiteral(lex()));
  45137. }
  45138. if (type === Token.Keyword) {
  45139. if (matchKeyword('this')) {
  45140. marker = markerCreate();
  45141. lex();
  45142. return markerApply(marker, delegate.createThisExpression());
  45143. }
  45144. if (matchKeyword('function')) {
  45145. return parseFunctionExpression();
  45146. }
  45147. if (matchKeyword('class')) {
  45148. return parseClassExpression();
  45149. }
  45150. if (matchKeyword('super')) {
  45151. marker = markerCreate();
  45152. lex();
  45153. return markerApply(marker, delegate.createIdentifier('super'));
  45154. }
  45155. }
  45156. if (type === Token.BooleanLiteral) {
  45157. marker = markerCreate();
  45158. token = lex();
  45159. token.value = (token.value === 'true');
  45160. return markerApply(marker, delegate.createLiteral(token));
  45161. }
  45162. if (type === Token.NullLiteral) {
  45163. marker = markerCreate();
  45164. token = lex();
  45165. token.value = null;
  45166. return markerApply(marker, delegate.createLiteral(token));
  45167. }
  45168. if (match('[')) {
  45169. return parseArrayInitialiser();
  45170. }
  45171. if (match('{')) {
  45172. return parseObjectInitialiser();
  45173. }
  45174. if (match('(')) {
  45175. return parseGroupExpression();
  45176. }
  45177. if (match('/') || match('/=')) {
  45178. marker = markerCreate();
  45179. return markerApply(marker, delegate.createLiteral(scanRegExp()));
  45180. }
  45181. if (type === Token.Template) {
  45182. return parseTemplateLiteral();
  45183. }
  45184. if (match('<')) {
  45185. return parseXJSElement();
  45186. }
  45187. throwUnexpected(lex());
  45188. }
  45189. // 11.2 Left-Hand-Side Expressions
  45190. function parseArguments() {
  45191. var args = [], arg;
  45192. expect('(');
  45193. if (!match(')')) {
  45194. while (index < length) {
  45195. arg = parseSpreadOrAssignmentExpression();
  45196. args.push(arg);
  45197. if (match(')')) {
  45198. break;
  45199. } else if (arg.type === Syntax.SpreadElement) {
  45200. throwError({}, Messages.ElementAfterSpreadElement);
  45201. }
  45202. expect(',');
  45203. }
  45204. }
  45205. expect(')');
  45206. return args;
  45207. }
  45208. function parseSpreadOrAssignmentExpression() {
  45209. if (match('...')) {
  45210. var marker = markerCreate();
  45211. lex();
  45212. return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
  45213. }
  45214. return parseAssignmentExpression();
  45215. }
  45216. function parseNonComputedProperty() {
  45217. var marker = markerCreate(),
  45218. token = lex();
  45219. if (!isIdentifierName(token)) {
  45220. throwUnexpected(token);
  45221. }
  45222. return markerApply(marker, delegate.createIdentifier(token.value));
  45223. }
  45224. function parseNonComputedMember() {
  45225. expect('.');
  45226. return parseNonComputedProperty();
  45227. }
  45228. function parseComputedMember() {
  45229. var expr;
  45230. expect('[');
  45231. expr = parseExpression();
  45232. expect(']');
  45233. return expr;
  45234. }
  45235. function parseNewExpression() {
  45236. var callee, args, marker = markerCreate();
  45237. expectKeyword('new');
  45238. callee = parseLeftHandSideExpression();
  45239. args = match('(') ? parseArguments() : [];
  45240. return markerApply(marker, delegate.createNewExpression(callee, args));
  45241. }
  45242. function parseLeftHandSideExpressionAllowCall() {
  45243. var expr, args, marker = markerCreate();
  45244. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  45245. while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) {
  45246. if (match('(')) {
  45247. args = parseArguments();
  45248. expr = markerApply(marker, delegate.createCallExpression(expr, args));
  45249. } else if (match('[')) {
  45250. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  45251. } else if (match('.')) {
  45252. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  45253. } else {
  45254. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  45255. }
  45256. }
  45257. return expr;
  45258. }
  45259. function parseLeftHandSideExpression() {
  45260. var expr, marker = markerCreate();
  45261. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  45262. while (match('.') || match('[') || lookahead.type === Token.Template) {
  45263. if (match('[')) {
  45264. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  45265. } else if (match('.')) {
  45266. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  45267. } else {
  45268. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  45269. }
  45270. }
  45271. return expr;
  45272. }
  45273. // 11.3 Postfix Expressions
  45274. function parsePostfixExpression() {
  45275. var marker = markerCreate(),
  45276. expr = parseLeftHandSideExpressionAllowCall(),
  45277. token;
  45278. if (lookahead.type !== Token.Punctuator) {
  45279. return expr;
  45280. }
  45281. if ((match('++') || match('--')) && !peekLineTerminator()) {
  45282. // 11.3.1, 11.3.2
  45283. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  45284. throwErrorTolerant({}, Messages.StrictLHSPostfix);
  45285. }
  45286. if (!isLeftHandSide(expr)) {
  45287. throwError({}, Messages.InvalidLHSInAssignment);
  45288. }
  45289. token = lex();
  45290. expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
  45291. }
  45292. return expr;
  45293. }
  45294. // 11.4 Unary Operators
  45295. function parseUnaryExpression() {
  45296. var marker, token, expr;
  45297. if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
  45298. return parsePostfixExpression();
  45299. }
  45300. if (match('++') || match('--')) {
  45301. marker = markerCreate();
  45302. token = lex();
  45303. expr = parseUnaryExpression();
  45304. // 11.4.4, 11.4.5
  45305. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  45306. throwErrorTolerant({}, Messages.StrictLHSPrefix);
  45307. }
  45308. if (!isLeftHandSide(expr)) {
  45309. throwError({}, Messages.InvalidLHSInAssignment);
  45310. }
  45311. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  45312. }
  45313. if (match('+') || match('-') || match('~') || match('!')) {
  45314. marker = markerCreate();
  45315. token = lex();
  45316. expr = parseUnaryExpression();
  45317. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  45318. }
  45319. if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
  45320. marker = markerCreate();
  45321. token = lex();
  45322. expr = parseUnaryExpression();
  45323. expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  45324. if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
  45325. throwErrorTolerant({}, Messages.StrictDelete);
  45326. }
  45327. return expr;
  45328. }
  45329. return parsePostfixExpression();
  45330. }
  45331. function binaryPrecedence(token, allowIn) {
  45332. var prec = 0;
  45333. if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
  45334. return 0;
  45335. }
  45336. switch (token.value) {
  45337. case '||':
  45338. prec = 1;
  45339. break;
  45340. case '&&':
  45341. prec = 2;
  45342. break;
  45343. case '|':
  45344. prec = 3;
  45345. break;
  45346. case '^':
  45347. prec = 4;
  45348. break;
  45349. case '&':
  45350. prec = 5;
  45351. break;
  45352. case '==':
  45353. case '!=':
  45354. case '===':
  45355. case '!==':
  45356. prec = 6;
  45357. break;
  45358. case '<':
  45359. case '>':
  45360. case '<=':
  45361. case '>=':
  45362. case 'instanceof':
  45363. prec = 7;
  45364. break;
  45365. case 'in':
  45366. prec = allowIn ? 7 : 0;
  45367. break;
  45368. case '<<':
  45369. case '>>':
  45370. case '>>>':
  45371. prec = 8;
  45372. break;
  45373. case '+':
  45374. case '-':
  45375. prec = 9;
  45376. break;
  45377. case '*':
  45378. case '/':
  45379. case '%':
  45380. prec = 11;
  45381. break;
  45382. default:
  45383. break;
  45384. }
  45385. return prec;
  45386. }
  45387. // 11.5 Multiplicative Operators
  45388. // 11.6 Additive Operators
  45389. // 11.7 Bitwise Shift Operators
  45390. // 11.8 Relational Operators
  45391. // 11.9 Equality Operators
  45392. // 11.10 Binary Bitwise Operators
  45393. // 11.11 Binary Logical Operators
  45394. function parseBinaryExpression() {
  45395. var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
  45396. marker, markers;
  45397. previousAllowIn = state.allowIn;
  45398. state.allowIn = true;
  45399. marker = markerCreate();
  45400. left = parseUnaryExpression();
  45401. token = lookahead;
  45402. prec = binaryPrecedence(token, previousAllowIn);
  45403. if (prec === 0) {
  45404. return left;
  45405. }
  45406. token.prec = prec;
  45407. lex();
  45408. markers = [marker, markerCreate()];
  45409. right = parseUnaryExpression();
  45410. stack = [left, token, right];
  45411. while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
  45412. // Reduce: make a binary expression from the three topmost entries.
  45413. while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
  45414. right = stack.pop();
  45415. operator = stack.pop().value;
  45416. left = stack.pop();
  45417. expr = delegate.createBinaryExpression(operator, left, right);
  45418. markers.pop();
  45419. marker = markers.pop();
  45420. markerApply(marker, expr);
  45421. stack.push(expr);
  45422. markers.push(marker);
  45423. }
  45424. // Shift.
  45425. token = lex();
  45426. token.prec = prec;
  45427. stack.push(token);
  45428. markers.push(markerCreate());
  45429. expr = parseUnaryExpression();
  45430. stack.push(expr);
  45431. }
  45432. state.allowIn = previousAllowIn;
  45433. // Final reduce to clean-up the stack.
  45434. i = stack.length - 1;
  45435. expr = stack[i];
  45436. markers.pop();
  45437. while (i > 1) {
  45438. expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
  45439. i -= 2;
  45440. marker = markers.pop();
  45441. markerApply(marker, expr);
  45442. }
  45443. return expr;
  45444. }
  45445. // 11.12 Conditional Operator
  45446. function parseConditionalExpression() {
  45447. var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
  45448. expr = parseBinaryExpression();
  45449. if (match('?')) {
  45450. lex();
  45451. previousAllowIn = state.allowIn;
  45452. state.allowIn = true;
  45453. consequent = parseAssignmentExpression();
  45454. state.allowIn = previousAllowIn;
  45455. expect(':');
  45456. alternate = parseAssignmentExpression();
  45457. expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
  45458. }
  45459. return expr;
  45460. }
  45461. // 11.13 Assignment Operators
  45462. function reinterpretAsAssignmentBindingPattern(expr) {
  45463. var i, len, property, element;
  45464. if (expr.type === Syntax.ObjectExpression) {
  45465. expr.type = Syntax.ObjectPattern;
  45466. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  45467. property = expr.properties[i];
  45468. if (property.type === Syntax.SpreadProperty) {
  45469. if (i < len - 1) {
  45470. throwError({}, Messages.PropertyAfterSpreadProperty);
  45471. }
  45472. reinterpretAsAssignmentBindingPattern(property.argument);
  45473. } else {
  45474. if (property.kind !== 'init') {
  45475. throwError({}, Messages.InvalidLHSInAssignment);
  45476. }
  45477. reinterpretAsAssignmentBindingPattern(property.value);
  45478. }
  45479. }
  45480. } else if (expr.type === Syntax.ArrayExpression) {
  45481. expr.type = Syntax.ArrayPattern;
  45482. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  45483. element = expr.elements[i];
  45484. if (element) {
  45485. reinterpretAsAssignmentBindingPattern(element);
  45486. }
  45487. }
  45488. } else if (expr.type === Syntax.Identifier) {
  45489. if (isRestrictedWord(expr.name)) {
  45490. throwError({}, Messages.InvalidLHSInAssignment);
  45491. }
  45492. } else if (expr.type === Syntax.SpreadElement) {
  45493. reinterpretAsAssignmentBindingPattern(expr.argument);
  45494. if (expr.argument.type === Syntax.ObjectPattern) {
  45495. throwError({}, Messages.ObjectPatternAsSpread);
  45496. }
  45497. } else {
  45498. if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
  45499. throwError({}, Messages.InvalidLHSInAssignment);
  45500. }
  45501. }
  45502. }
  45503. function reinterpretAsDestructuredParameter(options, expr) {
  45504. var i, len, property, element;
  45505. if (expr.type === Syntax.ObjectExpression) {
  45506. expr.type = Syntax.ObjectPattern;
  45507. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  45508. property = expr.properties[i];
  45509. if (property.type === Syntax.SpreadProperty) {
  45510. if (i < len - 1) {
  45511. throwError({}, Messages.PropertyAfterSpreadProperty);
  45512. }
  45513. reinterpretAsDestructuredParameter(options, property.argument);
  45514. } else {
  45515. if (property.kind !== 'init') {
  45516. throwError({}, Messages.InvalidLHSInFormalsList);
  45517. }
  45518. reinterpretAsDestructuredParameter(options, property.value);
  45519. }
  45520. }
  45521. } else if (expr.type === Syntax.ArrayExpression) {
  45522. expr.type = Syntax.ArrayPattern;
  45523. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  45524. element = expr.elements[i];
  45525. if (element) {
  45526. reinterpretAsDestructuredParameter(options, element);
  45527. }
  45528. }
  45529. } else if (expr.type === Syntax.Identifier) {
  45530. validateParam(options, expr, expr.name);
  45531. } else {
  45532. if (expr.type !== Syntax.MemberExpression) {
  45533. throwError({}, Messages.InvalidLHSInFormalsList);
  45534. }
  45535. }
  45536. }
  45537. function reinterpretAsCoverFormalsList(expressions) {
  45538. var i, len, param, params, defaults, defaultCount, options, rest;
  45539. params = [];
  45540. defaults = [];
  45541. defaultCount = 0;
  45542. rest = null;
  45543. options = {
  45544. paramSet: {}
  45545. };
  45546. for (i = 0, len = expressions.length; i < len; i += 1) {
  45547. param = expressions[i];
  45548. if (param.type === Syntax.Identifier) {
  45549. params.push(param);
  45550. defaults.push(null);
  45551. validateParam(options, param, param.name);
  45552. } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
  45553. reinterpretAsDestructuredParameter(options, param);
  45554. params.push(param);
  45555. defaults.push(null);
  45556. } else if (param.type === Syntax.SpreadElement) {
  45557. assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
  45558. reinterpretAsDestructuredParameter(options, param.argument);
  45559. rest = param.argument;
  45560. } else if (param.type === Syntax.AssignmentExpression) {
  45561. params.push(param.left);
  45562. defaults.push(param.right);
  45563. ++defaultCount;
  45564. validateParam(options, param.left, param.left.name);
  45565. } else {
  45566. return null;
  45567. }
  45568. }
  45569. if (options.message === Messages.StrictParamDupe) {
  45570. throwError(
  45571. strict ? options.stricted : options.firstRestricted,
  45572. options.message
  45573. );
  45574. }
  45575. if (defaultCount === 0) {
  45576. defaults = [];
  45577. }
  45578. return {
  45579. params: params,
  45580. defaults: defaults,
  45581. rest: rest,
  45582. stricted: options.stricted,
  45583. firstRestricted: options.firstRestricted,
  45584. message: options.message
  45585. };
  45586. }
  45587. function parseArrowFunctionExpression(options, marker) {
  45588. var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
  45589. expect('=>');
  45590. previousStrict = strict;
  45591. previousYieldAllowed = state.yieldAllowed;
  45592. state.yieldAllowed = false;
  45593. previousAwaitAllowed = state.awaitAllowed;
  45594. state.awaitAllowed = !!options.async;
  45595. body = parseConciseBody();
  45596. if (strict && options.firstRestricted) {
  45597. throwError(options.firstRestricted, options.message);
  45598. }
  45599. if (strict && options.stricted) {
  45600. throwErrorTolerant(options.stricted, options.message);
  45601. }
  45602. strict = previousStrict;
  45603. state.yieldAllowed = previousYieldAllowed;
  45604. state.awaitAllowed = previousAwaitAllowed;
  45605. return markerApply(marker, delegate.createArrowFunctionExpression(
  45606. options.params,
  45607. options.defaults,
  45608. body,
  45609. options.rest,
  45610. body.type !== Syntax.BlockStatement,
  45611. !!options.async
  45612. ));
  45613. }
  45614. function parseAssignmentExpression() {
  45615. var marker, expr, token, params, oldParenthesizedCount,
  45616. backtrackToken = lookahead, possiblyAsync = false;
  45617. if (matchYield()) {
  45618. return parseYieldExpression();
  45619. }
  45620. if (matchAwait()) {
  45621. return parseAwaitExpression();
  45622. }
  45623. oldParenthesizedCount = state.parenthesizedCount;
  45624. marker = markerCreate();
  45625. if (matchAsyncFuncExprOrDecl()) {
  45626. return parseFunctionExpression();
  45627. }
  45628. if (matchAsync()) {
  45629. // We can't be completely sure that this 'async' token is
  45630. // actually a contextual keyword modifying a function
  45631. // expression, so we might have to un-lex() it later by
  45632. // calling rewind(backtrackToken).
  45633. possiblyAsync = true;
  45634. lex();
  45635. }
  45636. if (match('(')) {
  45637. token = lookahead2();
  45638. if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
  45639. params = parseParams();
  45640. if (!match('=>')) {
  45641. throwUnexpected(lex());
  45642. }
  45643. params.async = possiblyAsync;
  45644. return parseArrowFunctionExpression(params, marker);
  45645. }
  45646. }
  45647. token = lookahead;
  45648. // If the 'async' keyword is not followed by a '(' character or an
  45649. // identifier, then it can't be an arrow function modifier, and we
  45650. // should interpret it as a normal identifer.
  45651. if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
  45652. possiblyAsync = false;
  45653. rewind(backtrackToken);
  45654. }
  45655. expr = parseConditionalExpression();
  45656. if (match('=>') &&
  45657. (state.parenthesizedCount === oldParenthesizedCount ||
  45658. state.parenthesizedCount === (oldParenthesizedCount + 1))) {
  45659. if (expr.type === Syntax.Identifier) {
  45660. params = reinterpretAsCoverFormalsList([ expr ]);
  45661. } else if (expr.type === Syntax.SequenceExpression) {
  45662. params = reinterpretAsCoverFormalsList(expr.expressions);
  45663. }
  45664. if (params) {
  45665. params.async = possiblyAsync;
  45666. return parseArrowFunctionExpression(params, marker);
  45667. }
  45668. }
  45669. // If we haven't returned by now, then the 'async' keyword was not
  45670. // a function modifier, and we should rewind and interpret it as a
  45671. // normal identifier.
  45672. if (possiblyAsync) {
  45673. possiblyAsync = false;
  45674. rewind(backtrackToken);
  45675. expr = parseConditionalExpression();
  45676. }
  45677. if (matchAssign()) {
  45678. // 11.13.1
  45679. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  45680. throwErrorTolerant(token, Messages.StrictLHSAssignment);
  45681. }
  45682. // ES.next draf 11.13 Runtime Semantics step 1
  45683. if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
  45684. reinterpretAsAssignmentBindingPattern(expr);
  45685. } else if (!isLeftHandSide(expr)) {
  45686. throwError({}, Messages.InvalidLHSInAssignment);
  45687. }
  45688. expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
  45689. }
  45690. return expr;
  45691. }
  45692. // 11.14 Comma Operator
  45693. function parseExpression() {
  45694. var marker, expr, expressions, sequence, coverFormalsList, spreadFound, oldParenthesizedCount;
  45695. oldParenthesizedCount = state.parenthesizedCount;
  45696. marker = markerCreate();
  45697. expr = parseAssignmentExpression();
  45698. expressions = [ expr ];
  45699. if (match(',')) {
  45700. while (index < length) {
  45701. if (!match(',')) {
  45702. break;
  45703. }
  45704. lex();
  45705. expr = parseSpreadOrAssignmentExpression();
  45706. expressions.push(expr);
  45707. if (expr.type === Syntax.SpreadElement) {
  45708. spreadFound = true;
  45709. if (!match(')')) {
  45710. throwError({}, Messages.ElementAfterSpreadElement);
  45711. }
  45712. break;
  45713. }
  45714. }
  45715. sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
  45716. }
  45717. if (match('=>')) {
  45718. // Do not allow nested parentheses on the LHS of the =>.
  45719. if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
  45720. expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
  45721. coverFormalsList = reinterpretAsCoverFormalsList(expr);
  45722. if (coverFormalsList) {
  45723. return parseArrowFunctionExpression(coverFormalsList, marker);
  45724. }
  45725. }
  45726. throwUnexpected(lex());
  45727. }
  45728. if (spreadFound && lookahead2().value !== '=>') {
  45729. throwError({}, Messages.IllegalSpread);
  45730. }
  45731. return sequence || expr;
  45732. }
  45733. // 12.1 Block
  45734. function parseStatementList() {
  45735. var list = [],
  45736. statement;
  45737. while (index < length) {
  45738. if (match('}')) {
  45739. break;
  45740. }
  45741. statement = parseSourceElement();
  45742. if (typeof statement === 'undefined') {
  45743. break;
  45744. }
  45745. list.push(statement);
  45746. }
  45747. return list;
  45748. }
  45749. function parseBlock() {
  45750. var block, marker = markerCreate();
  45751. expect('{');
  45752. block = parseStatementList();
  45753. expect('}');
  45754. return markerApply(marker, delegate.createBlockStatement(block));
  45755. }
  45756. // 12.2 Variable Statement
  45757. function parseTypeParameterDeclaration() {
  45758. var marker = markerCreate(), paramTypes = [];
  45759. expect('<');
  45760. while (!match('>')) {
  45761. paramTypes.push(parseVariableIdentifier());
  45762. if (!match('>')) {
  45763. expect(',');
  45764. }
  45765. }
  45766. expect('>');
  45767. return markerApply(marker, delegate.createTypeParameterDeclaration(
  45768. paramTypes
  45769. ));
  45770. }
  45771. function parseTypeParameterInstantiation() {
  45772. var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
  45773. state.inType = true;
  45774. expect('<');
  45775. while (!match('>')) {
  45776. paramTypes.push(parseType());
  45777. if (!match('>')) {
  45778. expect(',');
  45779. }
  45780. }
  45781. expect('>');
  45782. state.inType = oldInType;
  45783. return markerApply(marker, delegate.createTypeParameterInstantiation(
  45784. paramTypes
  45785. ));
  45786. }
  45787. function parseObjectTypeIndexer(marker, isStatic) {
  45788. var id, key, value;
  45789. expect('[');
  45790. id = parseObjectPropertyKey();
  45791. expect(':');
  45792. key = parseType();
  45793. expect(']');
  45794. expect(':');
  45795. value = parseType();
  45796. return markerApply(marker, delegate.createObjectTypeIndexer(
  45797. id,
  45798. key,
  45799. value,
  45800. isStatic
  45801. ));
  45802. }
  45803. function parseObjectTypeMethodish(marker) {
  45804. var params = [], rest = null, returnType, typeParameters = null;
  45805. if (match('<')) {
  45806. typeParameters = parseTypeParameterDeclaration();
  45807. }
  45808. expect('(');
  45809. while (lookahead.type === Token.Identifier) {
  45810. params.push(parseFunctionTypeParam());
  45811. if (!match(')')) {
  45812. expect(',');
  45813. }
  45814. }
  45815. if (match('...')) {
  45816. lex();
  45817. rest = parseFunctionTypeParam();
  45818. }
  45819. expect(')');
  45820. expect(':');
  45821. returnType = parseType();
  45822. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  45823. params,
  45824. returnType,
  45825. rest,
  45826. typeParameters
  45827. ));
  45828. }
  45829. function parseObjectTypeMethod(marker, isStatic, key) {
  45830. var optional = false, value;
  45831. value = parseObjectTypeMethodish(marker);
  45832. return markerApply(marker, delegate.createObjectTypeProperty(
  45833. key,
  45834. value,
  45835. optional,
  45836. isStatic
  45837. ));
  45838. }
  45839. function parseObjectTypeCallProperty(marker, isStatic) {
  45840. var valueMarker = markerCreate();
  45841. return markerApply(marker, delegate.createObjectTypeCallProperty(
  45842. parseObjectTypeMethodish(valueMarker),
  45843. isStatic
  45844. ));
  45845. }
  45846. function parseObjectType(allowStatic) {
  45847. var callProperties = [], indexers = [], marker, optional = false,
  45848. properties = [], property, propertyKey, propertyTypeAnnotation,
  45849. token, isStatic;
  45850. expect('{');
  45851. while (!match('}')) {
  45852. marker = markerCreate();
  45853. if (allowStatic && matchContextualKeyword('static')) {
  45854. token = lex();
  45855. isStatic = true;
  45856. }
  45857. if (match('[')) {
  45858. indexers.push(parseObjectTypeIndexer(marker, isStatic));
  45859. } else if (match('(') || match('<')) {
  45860. callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
  45861. } else {
  45862. if (isStatic && match(':')) {
  45863. propertyKey = markerApply(marker, delegate.createIdentifier(token));
  45864. throwErrorTolerant(token, Messages.StrictReservedWord);
  45865. } else {
  45866. propertyKey = parseObjectPropertyKey();
  45867. }
  45868. if (match('<') || match('(')) {
  45869. // This is a method property
  45870. properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
  45871. } else {
  45872. if (match('?')) {
  45873. lex();
  45874. optional = true;
  45875. }
  45876. expect(':');
  45877. propertyTypeAnnotation = parseType();
  45878. properties.push(markerApply(marker, delegate.createObjectTypeProperty(
  45879. propertyKey,
  45880. propertyTypeAnnotation,
  45881. optional,
  45882. isStatic
  45883. )));
  45884. }
  45885. }
  45886. if (match(';')) {
  45887. lex();
  45888. } else if (!match('}')) {
  45889. throwUnexpected(lookahead);
  45890. }
  45891. }
  45892. expect('}');
  45893. return delegate.createObjectTypeAnnotation(
  45894. properties,
  45895. indexers,
  45896. callProperties
  45897. );
  45898. }
  45899. function parseGenericType() {
  45900. var marker = markerCreate(), returnType = null,
  45901. typeParameters = null, typeIdentifier,
  45902. typeIdentifierMarker = markerCreate;
  45903. typeIdentifier = parseVariableIdentifier();
  45904. while (match('.')) {
  45905. expect('.');
  45906. typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
  45907. typeIdentifier,
  45908. parseVariableIdentifier()
  45909. ));
  45910. }
  45911. if (match('<')) {
  45912. typeParameters = parseTypeParameterInstantiation();
  45913. }
  45914. return markerApply(marker, delegate.createGenericTypeAnnotation(
  45915. typeIdentifier,
  45916. typeParameters
  45917. ));
  45918. }
  45919. function parseVoidType() {
  45920. var marker = markerCreate();
  45921. expectKeyword('void');
  45922. return markerApply(marker, delegate.createVoidTypeAnnotation());
  45923. }
  45924. function parseTypeofType() {
  45925. var argument, marker = markerCreate();
  45926. expectKeyword('typeof');
  45927. argument = parsePrimaryType();
  45928. return markerApply(marker, delegate.createTypeofTypeAnnotation(
  45929. argument
  45930. ));
  45931. }
  45932. function parseTupleType() {
  45933. var marker = markerCreate(), types = [];
  45934. expect('[');
  45935. // We allow trailing commas
  45936. while (index < length && !match(']')) {
  45937. types.push(parseType());
  45938. if (match(']')) {
  45939. break;
  45940. }
  45941. expect(',');
  45942. }
  45943. expect(']');
  45944. return markerApply(marker, delegate.createTupleTypeAnnotation(
  45945. types
  45946. ));
  45947. }
  45948. function parseFunctionTypeParam() {
  45949. var marker = markerCreate(), name, optional = false, typeAnnotation;
  45950. name = parseVariableIdentifier();
  45951. if (match('?')) {
  45952. lex();
  45953. optional = true;
  45954. }
  45955. expect(':');
  45956. typeAnnotation = parseType();
  45957. return markerApply(marker, delegate.createFunctionTypeParam(
  45958. name,
  45959. typeAnnotation,
  45960. optional
  45961. ));
  45962. }
  45963. function parseFunctionTypeParams() {
  45964. var ret = { params: [], rest: null };
  45965. while (lookahead.type === Token.Identifier) {
  45966. ret.params.push(parseFunctionTypeParam());
  45967. if (!match(')')) {
  45968. expect(',');
  45969. }
  45970. }
  45971. if (match('...')) {
  45972. lex();
  45973. ret.rest = parseFunctionTypeParam();
  45974. }
  45975. return ret;
  45976. }
  45977. // The parsing of types roughly parallels the parsing of expressions, and
  45978. // primary types are kind of like primary expressions...they're the
  45979. // primitives with which other types are constructed.
  45980. function parsePrimaryType() {
  45981. var typeIdentifier = null, params = null, returnType = null,
  45982. marker = markerCreate(), rest = null, tmp,
  45983. typeParameters, token, type, isGroupedType = false;
  45984. switch (lookahead.type) {
  45985. case Token.Identifier:
  45986. switch (lookahead.value) {
  45987. case 'any':
  45988. lex();
  45989. return markerApply(marker, delegate.createAnyTypeAnnotation());
  45990. case 'bool': // fallthrough
  45991. case 'boolean':
  45992. lex();
  45993. return markerApply(marker, delegate.createBooleanTypeAnnotation());
  45994. case 'number':
  45995. lex();
  45996. return markerApply(marker, delegate.createNumberTypeAnnotation());
  45997. case 'string':
  45998. lex();
  45999. return markerApply(marker, delegate.createStringTypeAnnotation());
  46000. }
  46001. return markerApply(marker, parseGenericType());
  46002. case Token.Punctuator:
  46003. switch (lookahead.value) {
  46004. case '{':
  46005. return markerApply(marker, parseObjectType());
  46006. case '[':
  46007. return parseTupleType();
  46008. case '<':
  46009. typeParameters = parseTypeParameterDeclaration();
  46010. expect('(');
  46011. tmp = parseFunctionTypeParams();
  46012. params = tmp.params;
  46013. rest = tmp.rest;
  46014. expect(')');
  46015. expect('=>');
  46016. returnType = parseType();
  46017. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  46018. params,
  46019. returnType,
  46020. rest,
  46021. typeParameters
  46022. ));
  46023. case '(':
  46024. lex();
  46025. // Check to see if this is actually a grouped type
  46026. if (!match(')') && !match('...')) {
  46027. if (lookahead.type === Token.Identifier) {
  46028. token = lookahead2();
  46029. isGroupedType = token.value !== '?' && token.value !== ':';
  46030. } else {
  46031. isGroupedType = true;
  46032. }
  46033. }
  46034. if (isGroupedType) {
  46035. type = parseType();
  46036. expect(')');
  46037. // If we see a => next then someone was probably confused about
  46038. // function types, so we can provide a better error message
  46039. if (match('=>')) {
  46040. throwError({}, Messages.ConfusedAboutFunctionType);
  46041. }
  46042. return type;
  46043. }
  46044. tmp = parseFunctionTypeParams();
  46045. params = tmp.params;
  46046. rest = tmp.rest;
  46047. expect(')');
  46048. expect('=>');
  46049. returnType = parseType();
  46050. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  46051. params,
  46052. returnType,
  46053. rest,
  46054. null /* typeParameters */
  46055. ));
  46056. }
  46057. break;
  46058. case Token.Keyword:
  46059. switch (lookahead.value) {
  46060. case 'void':
  46061. return markerApply(marker, parseVoidType());
  46062. case 'typeof':
  46063. return markerApply(marker, parseTypeofType());
  46064. }
  46065. break;
  46066. case Token.StringLiteral:
  46067. token = lex();
  46068. if (token.octal) {
  46069. throwError(token, Messages.StrictOctalLiteral);
  46070. }
  46071. return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
  46072. token
  46073. ));
  46074. }
  46075. throwUnexpected(lookahead);
  46076. }
  46077. function parsePostfixType() {
  46078. var marker = markerCreate(), t = parsePrimaryType();
  46079. if (match('[')) {
  46080. expect('[');
  46081. expect(']');
  46082. return markerApply(marker, delegate.createArrayTypeAnnotation(t));
  46083. }
  46084. return t;
  46085. }
  46086. function parsePrefixType() {
  46087. var marker = markerCreate();
  46088. if (match('?')) {
  46089. lex();
  46090. return markerApply(marker, delegate.createNullableTypeAnnotation(
  46091. parsePrefixType()
  46092. ));
  46093. }
  46094. return parsePostfixType();
  46095. }
  46096. function parseIntersectionType() {
  46097. var marker = markerCreate(), type, types;
  46098. type = parsePrefixType();
  46099. types = [type];
  46100. while (match('&')) {
  46101. lex();
  46102. types.push(parsePrefixType());
  46103. }
  46104. return types.length === 1 ?
  46105. type :
  46106. markerApply(marker, delegate.createIntersectionTypeAnnotation(
  46107. types
  46108. ));
  46109. }
  46110. function parseUnionType() {
  46111. var marker = markerCreate(), type, types;
  46112. type = parseIntersectionType();
  46113. types = [type];
  46114. while (match('|')) {
  46115. lex();
  46116. types.push(parseIntersectionType());
  46117. }
  46118. return types.length === 1 ?
  46119. type :
  46120. markerApply(marker, delegate.createUnionTypeAnnotation(
  46121. types
  46122. ));
  46123. }
  46124. function parseType() {
  46125. var oldInType = state.inType, type;
  46126. state.inType = true;
  46127. type = parseUnionType();
  46128. state.inType = oldInType;
  46129. return type;
  46130. }
  46131. function parseTypeAnnotation() {
  46132. var marker = markerCreate(), type;
  46133. expect(':');
  46134. type = parseType();
  46135. return markerApply(marker, delegate.createTypeAnnotation(type));
  46136. }
  46137. function parseVariableIdentifier() {
  46138. var marker = markerCreate(),
  46139. token = lex();
  46140. if (token.type !== Token.Identifier) {
  46141. throwUnexpected(token);
  46142. }
  46143. return markerApply(marker, delegate.createIdentifier(token.value));
  46144. }
  46145. function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
  46146. var marker = markerCreate(),
  46147. ident = parseVariableIdentifier(),
  46148. isOptionalParam = false;
  46149. if (canBeOptionalParam && match('?')) {
  46150. expect('?');
  46151. isOptionalParam = true;
  46152. }
  46153. if (requireTypeAnnotation || match(':')) {
  46154. ident.typeAnnotation = parseTypeAnnotation();
  46155. ident = markerApply(marker, ident);
  46156. }
  46157. if (isOptionalParam) {
  46158. ident.optional = true;
  46159. ident = markerApply(marker, ident);
  46160. }
  46161. return ident;
  46162. }
  46163. function parseVariableDeclaration(kind) {
  46164. var id,
  46165. marker = markerCreate(),
  46166. init = null,
  46167. typeAnnotationMarker = markerCreate();
  46168. if (match('{')) {
  46169. id = parseObjectInitialiser();
  46170. reinterpretAsAssignmentBindingPattern(id);
  46171. if (match(':')) {
  46172. id.typeAnnotation = parseTypeAnnotation();
  46173. markerApply(typeAnnotationMarker, id);
  46174. }
  46175. } else if (match('[')) {
  46176. id = parseArrayInitialiser();
  46177. reinterpretAsAssignmentBindingPattern(id);
  46178. if (match(':')) {
  46179. id.typeAnnotation = parseTypeAnnotation();
  46180. markerApply(typeAnnotationMarker, id);
  46181. }
  46182. } else {
  46183. id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
  46184. // 12.2.1
  46185. if (strict && isRestrictedWord(id.name)) {
  46186. throwErrorTolerant({}, Messages.StrictVarName);
  46187. }
  46188. }
  46189. if (kind === 'const') {
  46190. if (!match('=')) {
  46191. throwError({}, Messages.NoUnintializedConst);
  46192. }
  46193. expect('=');
  46194. init = parseAssignmentExpression();
  46195. } else if (match('=')) {
  46196. lex();
  46197. init = parseAssignmentExpression();
  46198. }
  46199. return markerApply(marker, delegate.createVariableDeclarator(id, init));
  46200. }
  46201. function parseVariableDeclarationList(kind) {
  46202. var list = [];
  46203. do {
  46204. list.push(parseVariableDeclaration(kind));
  46205. if (!match(',')) {
  46206. break;
  46207. }
  46208. lex();
  46209. } while (index < length);
  46210. return list;
  46211. }
  46212. function parseVariableStatement() {
  46213. var declarations, marker = markerCreate();
  46214. expectKeyword('var');
  46215. declarations = parseVariableDeclarationList();
  46216. consumeSemicolon();
  46217. return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
  46218. }
  46219. // kind may be `const` or `let`
  46220. // Both are experimental and not in the specification yet.
  46221. // see http://wiki.ecmascript.org/doku.php?id=harmony:const
  46222. // and http://wiki.ecmascript.org/doku.php?id=harmony:let
  46223. function parseConstLetDeclaration(kind) {
  46224. var declarations, marker = markerCreate();
  46225. expectKeyword(kind);
  46226. declarations = parseVariableDeclarationList(kind);
  46227. consumeSemicolon();
  46228. return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
  46229. }
  46230. // people.mozilla.org/~jorendorff/es6-draft.html
  46231. function parseModuleSpecifier() {
  46232. var marker = markerCreate(),
  46233. specifier;
  46234. if (lookahead.type !== Token.StringLiteral) {
  46235. throwError({}, Messages.InvalidModuleSpecifier);
  46236. }
  46237. specifier = delegate.createModuleSpecifier(lookahead);
  46238. lex();
  46239. return markerApply(marker, specifier);
  46240. }
  46241. function parseExportBatchSpecifier() {
  46242. var marker = markerCreate();
  46243. expect('*');
  46244. return markerApply(marker, delegate.createExportBatchSpecifier());
  46245. }
  46246. function parseExportSpecifier() {
  46247. var id, name = null, marker = markerCreate(), from;
  46248. if (matchKeyword('default')) {
  46249. lex();
  46250. id = markerApply(marker, delegate.createIdentifier('default'));
  46251. // export {default} from "something";
  46252. } else {
  46253. id = parseVariableIdentifier();
  46254. }
  46255. if (matchContextualKeyword('as')) {
  46256. lex();
  46257. name = parseNonComputedProperty();
  46258. }
  46259. return markerApply(marker, delegate.createExportSpecifier(id, name));
  46260. }
  46261. function parseExportDeclaration() {
  46262. var backtrackToken, id, previousAllowKeyword, declaration = null,
  46263. isExportFromIdentifier,
  46264. src = null, specifiers = [],
  46265. marker = markerCreate();
  46266. expectKeyword('export');
  46267. if (matchKeyword('default')) {
  46268. // covers:
  46269. // export default ...
  46270. lex();
  46271. if (matchKeyword('function') || matchKeyword('class')) {
  46272. backtrackToken = lookahead;
  46273. lex();
  46274. if (isIdentifierName(lookahead)) {
  46275. // covers:
  46276. // export default function foo () {}
  46277. // export default class foo {}
  46278. id = parseNonComputedProperty();
  46279. rewind(backtrackToken);
  46280. return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
  46281. }
  46282. // covers:
  46283. // export default function () {}
  46284. // export default class {}
  46285. rewind(backtrackToken);
  46286. switch (lookahead.value) {
  46287. case 'class':
  46288. return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
  46289. case 'function':
  46290. return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
  46291. }
  46292. }
  46293. if (matchContextualKeyword('from')) {
  46294. throwError({}, Messages.UnexpectedToken, lookahead.value);
  46295. }
  46296. // covers:
  46297. // export default {};
  46298. // export default [];
  46299. if (match('{')) {
  46300. declaration = parseObjectInitialiser();
  46301. } else if (match('[')) {
  46302. declaration = parseArrayInitialiser();
  46303. } else {
  46304. declaration = parseAssignmentExpression();
  46305. }
  46306. consumeSemicolon();
  46307. return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
  46308. }
  46309. // non-default export
  46310. if (lookahead.type === Token.Keyword) {
  46311. // covers:
  46312. // export var f = 1;
  46313. switch (lookahead.value) {
  46314. case 'let':
  46315. case 'const':
  46316. case 'var':
  46317. case 'class':
  46318. case 'function':
  46319. return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
  46320. }
  46321. }
  46322. if (match('*')) {
  46323. // covers:
  46324. // export * from "foo";
  46325. specifiers.push(parseExportBatchSpecifier());
  46326. if (!matchContextualKeyword('from')) {
  46327. throwError({}, lookahead.value ?
  46328. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  46329. }
  46330. lex();
  46331. src = parseModuleSpecifier();
  46332. consumeSemicolon();
  46333. return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
  46334. }
  46335. expect('{');
  46336. do {
  46337. isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
  46338. specifiers.push(parseExportSpecifier());
  46339. } while (match(',') && lex());
  46340. expect('}');
  46341. if (matchContextualKeyword('from')) {
  46342. // covering:
  46343. // export {default} from "foo";
  46344. // export {foo} from "foo";
  46345. lex();
  46346. src = parseModuleSpecifier();
  46347. consumeSemicolon();
  46348. } else if (isExportFromIdentifier) {
  46349. // covering:
  46350. // export {default}; // missing fromClause
  46351. throwError({}, lookahead.value ?
  46352. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  46353. } else {
  46354. // cover
  46355. // export {foo};
  46356. consumeSemicolon();
  46357. }
  46358. return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
  46359. }
  46360. function parseImportSpecifier() {
  46361. // import {<foo as bar>} ...;
  46362. var id, name = null, marker = markerCreate();
  46363. id = parseNonComputedProperty();
  46364. if (matchContextualKeyword('as')) {
  46365. lex();
  46366. name = parseVariableIdentifier();
  46367. }
  46368. return markerApply(marker, delegate.createImportSpecifier(id, name));
  46369. }
  46370. function parseNamedImports() {
  46371. var specifiers = [];
  46372. // {foo, bar as bas}
  46373. expect('{');
  46374. do {
  46375. specifiers.push(parseImportSpecifier());
  46376. } while (match(',') && lex());
  46377. expect('}');
  46378. return specifiers;
  46379. }
  46380. function parseImportDefaultSpecifier() {
  46381. // import <foo> ...;
  46382. var id, marker = markerCreate();
  46383. id = parseNonComputedProperty();
  46384. return markerApply(marker, delegate.createImportDefaultSpecifier(id));
  46385. }
  46386. function parseImportNamespaceSpecifier() {
  46387. // import <* as foo> ...;
  46388. var id, marker = markerCreate();
  46389. expect('*');
  46390. if (!matchContextualKeyword('as')) {
  46391. throwError({}, Messages.NoAsAfterImportNamespace);
  46392. }
  46393. lex();
  46394. id = parseNonComputedProperty();
  46395. return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
  46396. }
  46397. function parseImportDeclaration() {
  46398. var specifiers, src, marker = markerCreate();
  46399. expectKeyword('import');
  46400. specifiers = [];
  46401. if (lookahead.type === Token.StringLiteral) {
  46402. // covers:
  46403. // import "foo";
  46404. src = parseModuleSpecifier();
  46405. consumeSemicolon();
  46406. return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
  46407. }
  46408. if (!matchKeyword('default') && isIdentifierName(lookahead)) {
  46409. // covers:
  46410. // import foo
  46411. // import foo, ...
  46412. specifiers.push(parseImportDefaultSpecifier());
  46413. if (match(',')) {
  46414. lex();
  46415. }
  46416. }
  46417. if (match('*')) {
  46418. // covers:
  46419. // import foo, * as foo
  46420. // import * as foo
  46421. specifiers.push(parseImportNamespaceSpecifier());
  46422. } else if (match('{')) {
  46423. // covers:
  46424. // import foo, {bar}
  46425. // import {bar}
  46426. specifiers = specifiers.concat(parseNamedImports());
  46427. }
  46428. if (!matchContextualKeyword('from')) {
  46429. throwError({}, lookahead.value ?
  46430. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  46431. }
  46432. lex();
  46433. src = parseModuleSpecifier();
  46434. consumeSemicolon();
  46435. return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
  46436. }
  46437. // 12.3 Empty Statement
  46438. function parseEmptyStatement() {
  46439. var marker = markerCreate();
  46440. expect(';');
  46441. return markerApply(marker, delegate.createEmptyStatement());
  46442. }
  46443. // 12.4 Expression Statement
  46444. function parseExpressionStatement() {
  46445. var marker = markerCreate(), expr = parseExpression();
  46446. consumeSemicolon();
  46447. return markerApply(marker, delegate.createExpressionStatement(expr));
  46448. }
  46449. // 12.5 If statement
  46450. function parseIfStatement() {
  46451. var test, consequent, alternate, marker = markerCreate();
  46452. expectKeyword('if');
  46453. expect('(');
  46454. test = parseExpression();
  46455. expect(')');
  46456. consequent = parseStatement();
  46457. if (matchKeyword('else')) {
  46458. lex();
  46459. alternate = parseStatement();
  46460. } else {
  46461. alternate = null;
  46462. }
  46463. return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
  46464. }
  46465. // 12.6 Iteration Statements
  46466. function parseDoWhileStatement() {
  46467. var body, test, oldInIteration, marker = markerCreate();
  46468. expectKeyword('do');
  46469. oldInIteration = state.inIteration;
  46470. state.inIteration = true;
  46471. body = parseStatement();
  46472. state.inIteration = oldInIteration;
  46473. expectKeyword('while');
  46474. expect('(');
  46475. test = parseExpression();
  46476. expect(')');
  46477. if (match(';')) {
  46478. lex();
  46479. }
  46480. return markerApply(marker, delegate.createDoWhileStatement(body, test));
  46481. }
  46482. function parseWhileStatement() {
  46483. var test, body, oldInIteration, marker = markerCreate();
  46484. expectKeyword('while');
  46485. expect('(');
  46486. test = parseExpression();
  46487. expect(')');
  46488. oldInIteration = state.inIteration;
  46489. state.inIteration = true;
  46490. body = parseStatement();
  46491. state.inIteration = oldInIteration;
  46492. return markerApply(marker, delegate.createWhileStatement(test, body));
  46493. }
  46494. function parseForVariableDeclaration() {
  46495. var marker = markerCreate(),
  46496. token = lex(),
  46497. declarations = parseVariableDeclarationList();
  46498. return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
  46499. }
  46500. function parseForStatement(opts) {
  46501. var init, test, update, left, right, body, operator, oldInIteration,
  46502. marker = markerCreate();
  46503. init = test = update = null;
  46504. expectKeyword('for');
  46505. // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
  46506. if (matchContextualKeyword('each')) {
  46507. throwError({}, Messages.EachNotAllowed);
  46508. }
  46509. expect('(');
  46510. if (match(';')) {
  46511. lex();
  46512. } else {
  46513. if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
  46514. state.allowIn = false;
  46515. init = parseForVariableDeclaration();
  46516. state.allowIn = true;
  46517. if (init.declarations.length === 1) {
  46518. if (matchKeyword('in') || matchContextualKeyword('of')) {
  46519. operator = lookahead;
  46520. if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
  46521. lex();
  46522. left = init;
  46523. right = parseExpression();
  46524. init = null;
  46525. }
  46526. }
  46527. }
  46528. } else {
  46529. state.allowIn = false;
  46530. init = parseExpression();
  46531. state.allowIn = true;
  46532. if (matchContextualKeyword('of')) {
  46533. operator = lex();
  46534. left = init;
  46535. right = parseExpression();
  46536. init = null;
  46537. } else if (matchKeyword('in')) {
  46538. // LeftHandSideExpression
  46539. if (!isAssignableLeftHandSide(init)) {
  46540. throwError({}, Messages.InvalidLHSInForIn);
  46541. }
  46542. operator = lex();
  46543. left = init;
  46544. right = parseExpression();
  46545. init = null;
  46546. }
  46547. }
  46548. if (typeof left === 'undefined') {
  46549. expect(';');
  46550. }
  46551. }
  46552. if (typeof left === 'undefined') {
  46553. if (!match(';')) {
  46554. test = parseExpression();
  46555. }
  46556. expect(';');
  46557. if (!match(')')) {
  46558. update = parseExpression();
  46559. }
  46560. }
  46561. expect(')');
  46562. oldInIteration = state.inIteration;
  46563. state.inIteration = true;
  46564. if (!(opts !== undefined && opts.ignoreBody)) {
  46565. body = parseStatement();
  46566. }
  46567. state.inIteration = oldInIteration;
  46568. if (typeof left === 'undefined') {
  46569. return markerApply(marker, delegate.createForStatement(init, test, update, body));
  46570. }
  46571. if (operator.value === 'in') {
  46572. return markerApply(marker, delegate.createForInStatement(left, right, body));
  46573. }
  46574. return markerApply(marker, delegate.createForOfStatement(left, right, body));
  46575. }
  46576. // 12.7 The continue statement
  46577. function parseContinueStatement() {
  46578. var label = null, key, marker = markerCreate();
  46579. expectKeyword('continue');
  46580. // Optimize the most common form: 'continue;'.
  46581. if (source.charCodeAt(index) === 59) {
  46582. lex();
  46583. if (!state.inIteration) {
  46584. throwError({}, Messages.IllegalContinue);
  46585. }
  46586. return markerApply(marker, delegate.createContinueStatement(null));
  46587. }
  46588. if (peekLineTerminator()) {
  46589. if (!state.inIteration) {
  46590. throwError({}, Messages.IllegalContinue);
  46591. }
  46592. return markerApply(marker, delegate.createContinueStatement(null));
  46593. }
  46594. if (lookahead.type === Token.Identifier) {
  46595. label = parseVariableIdentifier();
  46596. key = '$' + label.name;
  46597. if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
  46598. throwError({}, Messages.UnknownLabel, label.name);
  46599. }
  46600. }
  46601. consumeSemicolon();
  46602. if (label === null && !state.inIteration) {
  46603. throwError({}, Messages.IllegalContinue);
  46604. }
  46605. return markerApply(marker, delegate.createContinueStatement(label));
  46606. }
  46607. // 12.8 The break statement
  46608. function parseBreakStatement() {
  46609. var label = null, key, marker = markerCreate();
  46610. expectKeyword('break');
  46611. // Catch the very common case first: immediately a semicolon (char #59).
  46612. if (source.charCodeAt(index) === 59) {
  46613. lex();
  46614. if (!(state.inIteration || state.inSwitch)) {
  46615. throwError({}, Messages.IllegalBreak);
  46616. }
  46617. return markerApply(marker, delegate.createBreakStatement(null));
  46618. }
  46619. if (peekLineTerminator()) {
  46620. if (!(state.inIteration || state.inSwitch)) {
  46621. throwError({}, Messages.IllegalBreak);
  46622. }
  46623. return markerApply(marker, delegate.createBreakStatement(null));
  46624. }
  46625. if (lookahead.type === Token.Identifier) {
  46626. label = parseVariableIdentifier();
  46627. key = '$' + label.name;
  46628. if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
  46629. throwError({}, Messages.UnknownLabel, label.name);
  46630. }
  46631. }
  46632. consumeSemicolon();
  46633. if (label === null && !(state.inIteration || state.inSwitch)) {
  46634. throwError({}, Messages.IllegalBreak);
  46635. }
  46636. return markerApply(marker, delegate.createBreakStatement(label));
  46637. }
  46638. // 12.9 The return statement
  46639. function parseReturnStatement() {
  46640. var argument = null, marker = markerCreate();
  46641. expectKeyword('return');
  46642. if (!state.inFunctionBody) {
  46643. throwErrorTolerant({}, Messages.IllegalReturn);
  46644. }
  46645. // 'return' followed by a space and an identifier is very common.
  46646. if (source.charCodeAt(index) === 32) {
  46647. if (isIdentifierStart(source.charCodeAt(index + 1))) {
  46648. argument = parseExpression();
  46649. consumeSemicolon();
  46650. return markerApply(marker, delegate.createReturnStatement(argument));
  46651. }
  46652. }
  46653. if (peekLineTerminator()) {
  46654. return markerApply(marker, delegate.createReturnStatement(null));
  46655. }
  46656. if (!match(';')) {
  46657. if (!match('}') && lookahead.type !== Token.EOF) {
  46658. argument = parseExpression();
  46659. }
  46660. }
  46661. consumeSemicolon();
  46662. return markerApply(marker, delegate.createReturnStatement(argument));
  46663. }
  46664. // 12.10 The with statement
  46665. function parseWithStatement() {
  46666. var object, body, marker = markerCreate();
  46667. if (strict) {
  46668. throwErrorTolerant({}, Messages.StrictModeWith);
  46669. }
  46670. expectKeyword('with');
  46671. expect('(');
  46672. object = parseExpression();
  46673. expect(')');
  46674. body = parseStatement();
  46675. return markerApply(marker, delegate.createWithStatement(object, body));
  46676. }
  46677. // 12.10 The swith statement
  46678. function parseSwitchCase() {
  46679. var test,
  46680. consequent = [],
  46681. sourceElement,
  46682. marker = markerCreate();
  46683. if (matchKeyword('default')) {
  46684. lex();
  46685. test = null;
  46686. } else {
  46687. expectKeyword('case');
  46688. test = parseExpression();
  46689. }
  46690. expect(':');
  46691. while (index < length) {
  46692. if (match('}') || matchKeyword('default') || matchKeyword('case')) {
  46693. break;
  46694. }
  46695. sourceElement = parseSourceElement();
  46696. if (typeof sourceElement === 'undefined') {
  46697. break;
  46698. }
  46699. consequent.push(sourceElement);
  46700. }
  46701. return markerApply(marker, delegate.createSwitchCase(test, consequent));
  46702. }
  46703. function parseSwitchStatement() {
  46704. var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
  46705. expectKeyword('switch');
  46706. expect('(');
  46707. discriminant = parseExpression();
  46708. expect(')');
  46709. expect('{');
  46710. cases = [];
  46711. if (match('}')) {
  46712. lex();
  46713. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  46714. }
  46715. oldInSwitch = state.inSwitch;
  46716. state.inSwitch = true;
  46717. defaultFound = false;
  46718. while (index < length) {
  46719. if (match('}')) {
  46720. break;
  46721. }
  46722. clause = parseSwitchCase();
  46723. if (clause.test === null) {
  46724. if (defaultFound) {
  46725. throwError({}, Messages.MultipleDefaultsInSwitch);
  46726. }
  46727. defaultFound = true;
  46728. }
  46729. cases.push(clause);
  46730. }
  46731. state.inSwitch = oldInSwitch;
  46732. expect('}');
  46733. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  46734. }
  46735. // 12.13 The throw statement
  46736. function parseThrowStatement() {
  46737. var argument, marker = markerCreate();
  46738. expectKeyword('throw');
  46739. if (peekLineTerminator()) {
  46740. throwError({}, Messages.NewlineAfterThrow);
  46741. }
  46742. argument = parseExpression();
  46743. consumeSemicolon();
  46744. return markerApply(marker, delegate.createThrowStatement(argument));
  46745. }
  46746. // 12.14 The try statement
  46747. function parseCatchClause() {
  46748. var param, body, marker = markerCreate();
  46749. expectKeyword('catch');
  46750. expect('(');
  46751. if (match(')')) {
  46752. throwUnexpected(lookahead);
  46753. }
  46754. param = parseExpression();
  46755. // 12.14.1
  46756. if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
  46757. throwErrorTolerant({}, Messages.StrictCatchVariable);
  46758. }
  46759. expect(')');
  46760. body = parseBlock();
  46761. return markerApply(marker, delegate.createCatchClause(param, body));
  46762. }
  46763. function parseTryStatement() {
  46764. var block, handlers = [], finalizer = null, marker = markerCreate();
  46765. expectKeyword('try');
  46766. block = parseBlock();
  46767. if (matchKeyword('catch')) {
  46768. handlers.push(parseCatchClause());
  46769. }
  46770. if (matchKeyword('finally')) {
  46771. lex();
  46772. finalizer = parseBlock();
  46773. }
  46774. if (handlers.length === 0 && !finalizer) {
  46775. throwError({}, Messages.NoCatchOrFinally);
  46776. }
  46777. return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
  46778. }
  46779. // 12.15 The debugger statement
  46780. function parseDebuggerStatement() {
  46781. var marker = markerCreate();
  46782. expectKeyword('debugger');
  46783. consumeSemicolon();
  46784. return markerApply(marker, delegate.createDebuggerStatement());
  46785. }
  46786. // 12 Statements
  46787. function parseStatement() {
  46788. var type = lookahead.type,
  46789. marker,
  46790. expr,
  46791. labeledBody,
  46792. key;
  46793. if (type === Token.EOF) {
  46794. throwUnexpected(lookahead);
  46795. }
  46796. if (type === Token.Punctuator) {
  46797. switch (lookahead.value) {
  46798. case ';':
  46799. return parseEmptyStatement();
  46800. case '{':
  46801. return parseBlock();
  46802. case '(':
  46803. return parseExpressionStatement();
  46804. default:
  46805. break;
  46806. }
  46807. }
  46808. if (type === Token.Keyword) {
  46809. switch (lookahead.value) {
  46810. case 'break':
  46811. return parseBreakStatement();
  46812. case 'continue':
  46813. return parseContinueStatement();
  46814. case 'debugger':
  46815. return parseDebuggerStatement();
  46816. case 'do':
  46817. return parseDoWhileStatement();
  46818. case 'for':
  46819. return parseForStatement();
  46820. case 'function':
  46821. return parseFunctionDeclaration();
  46822. case 'class':
  46823. return parseClassDeclaration();
  46824. case 'if':
  46825. return parseIfStatement();
  46826. case 'return':
  46827. return parseReturnStatement();
  46828. case 'switch':
  46829. return parseSwitchStatement();
  46830. case 'throw':
  46831. return parseThrowStatement();
  46832. case 'try':
  46833. return parseTryStatement();
  46834. case 'var':
  46835. return parseVariableStatement();
  46836. case 'while':
  46837. return parseWhileStatement();
  46838. case 'with':
  46839. return parseWithStatement();
  46840. default:
  46841. break;
  46842. }
  46843. }
  46844. if (matchAsyncFuncExprOrDecl()) {
  46845. return parseFunctionDeclaration();
  46846. }
  46847. marker = markerCreate();
  46848. expr = parseExpression();
  46849. // 12.12 Labelled Statements
  46850. if ((expr.type === Syntax.Identifier) && match(':')) {
  46851. lex();
  46852. key = '$' + expr.name;
  46853. if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
  46854. throwError({}, Messages.Redeclaration, 'Label', expr.name);
  46855. }
  46856. state.labelSet[key] = true;
  46857. labeledBody = parseStatement();
  46858. delete state.labelSet[key];
  46859. return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
  46860. }
  46861. consumeSemicolon();
  46862. return markerApply(marker, delegate.createExpressionStatement(expr));
  46863. }
  46864. // 13 Function Definition
  46865. function parseConciseBody() {
  46866. if (match('{')) {
  46867. return parseFunctionSourceElements();
  46868. }
  46869. return parseAssignmentExpression();
  46870. }
  46871. function parseFunctionSourceElements() {
  46872. var sourceElement, sourceElements = [], token, directive, firstRestricted,
  46873. oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
  46874. marker = markerCreate();
  46875. expect('{');
  46876. while (index < length) {
  46877. if (lookahead.type !== Token.StringLiteral) {
  46878. break;
  46879. }
  46880. token = lookahead;
  46881. sourceElement = parseSourceElement();
  46882. sourceElements.push(sourceElement);
  46883. if (sourceElement.expression.type !== Syntax.Literal) {
  46884. // this is not directive
  46885. break;
  46886. }
  46887. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  46888. if (directive === 'use strict') {
  46889. strict = true;
  46890. if (firstRestricted) {
  46891. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  46892. }
  46893. } else {
  46894. if (!firstRestricted && token.octal) {
  46895. firstRestricted = token;
  46896. }
  46897. }
  46898. }
  46899. oldLabelSet = state.labelSet;
  46900. oldInIteration = state.inIteration;
  46901. oldInSwitch = state.inSwitch;
  46902. oldInFunctionBody = state.inFunctionBody;
  46903. oldParenthesizedCount = state.parenthesizedCount;
  46904. state.labelSet = {};
  46905. state.inIteration = false;
  46906. state.inSwitch = false;
  46907. state.inFunctionBody = true;
  46908. state.parenthesizedCount = 0;
  46909. while (index < length) {
  46910. if (match('}')) {
  46911. break;
  46912. }
  46913. sourceElement = parseSourceElement();
  46914. if (typeof sourceElement === 'undefined') {
  46915. break;
  46916. }
  46917. sourceElements.push(sourceElement);
  46918. }
  46919. expect('}');
  46920. state.labelSet = oldLabelSet;
  46921. state.inIteration = oldInIteration;
  46922. state.inSwitch = oldInSwitch;
  46923. state.inFunctionBody = oldInFunctionBody;
  46924. state.parenthesizedCount = oldParenthesizedCount;
  46925. return markerApply(marker, delegate.createBlockStatement(sourceElements));
  46926. }
  46927. function validateParam(options, param, name) {
  46928. var key = '$' + name;
  46929. if (strict) {
  46930. if (isRestrictedWord(name)) {
  46931. options.stricted = param;
  46932. options.message = Messages.StrictParamName;
  46933. }
  46934. if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
  46935. options.stricted = param;
  46936. options.message = Messages.StrictParamDupe;
  46937. }
  46938. } else if (!options.firstRestricted) {
  46939. if (isRestrictedWord(name)) {
  46940. options.firstRestricted = param;
  46941. options.message = Messages.StrictParamName;
  46942. } else if (isStrictModeReservedWord(name)) {
  46943. options.firstRestricted = param;
  46944. options.message = Messages.StrictReservedWord;
  46945. } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
  46946. options.firstRestricted = param;
  46947. options.message = Messages.StrictParamDupe;
  46948. }
  46949. }
  46950. options.paramSet[key] = true;
  46951. }
  46952. function parseParam(options) {
  46953. var marker, token, rest, param, def;
  46954. token = lookahead;
  46955. if (token.value === '...') {
  46956. token = lex();
  46957. rest = true;
  46958. }
  46959. if (match('[')) {
  46960. marker = markerCreate();
  46961. param = parseArrayInitialiser();
  46962. reinterpretAsDestructuredParameter(options, param);
  46963. if (match(':')) {
  46964. param.typeAnnotation = parseTypeAnnotation();
  46965. markerApply(marker, param);
  46966. }
  46967. } else if (match('{')) {
  46968. marker = markerCreate();
  46969. if (rest) {
  46970. throwError({}, Messages.ObjectPatternAsRestParameter);
  46971. }
  46972. param = parseObjectInitialiser();
  46973. reinterpretAsDestructuredParameter(options, param);
  46974. if (match(':')) {
  46975. param.typeAnnotation = parseTypeAnnotation();
  46976. markerApply(marker, param);
  46977. }
  46978. } else {
  46979. param =
  46980. rest
  46981. ? parseTypeAnnotatableIdentifier(
  46982. false, /* requireTypeAnnotation */
  46983. false /* canBeOptionalParam */
  46984. )
  46985. : parseTypeAnnotatableIdentifier(
  46986. false, /* requireTypeAnnotation */
  46987. true /* canBeOptionalParam */
  46988. );
  46989. validateParam(options, token, token.value);
  46990. }
  46991. if (match('=')) {
  46992. if (rest) {
  46993. throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
  46994. }
  46995. lex();
  46996. def = parseAssignmentExpression();
  46997. ++options.defaultCount;
  46998. }
  46999. if (rest) {
  47000. if (!match(')')) {
  47001. throwError({}, Messages.ParameterAfterRestParameter);
  47002. }
  47003. options.rest = param;
  47004. return false;
  47005. }
  47006. options.params.push(param);
  47007. options.defaults.push(def);
  47008. return !match(')');
  47009. }
  47010. function parseParams(firstRestricted) {
  47011. var options, marker = markerCreate();
  47012. options = {
  47013. params: [],
  47014. defaultCount: 0,
  47015. defaults: [],
  47016. rest: null,
  47017. firstRestricted: firstRestricted
  47018. };
  47019. expect('(');
  47020. if (!match(')')) {
  47021. options.paramSet = {};
  47022. while (index < length) {
  47023. if (!parseParam(options)) {
  47024. break;
  47025. }
  47026. expect(',');
  47027. }
  47028. }
  47029. expect(')');
  47030. if (options.defaultCount === 0) {
  47031. options.defaults = [];
  47032. }
  47033. if (match(':')) {
  47034. options.returnType = parseTypeAnnotation();
  47035. }
  47036. return markerApply(marker, options);
  47037. }
  47038. function parseFunctionDeclaration() {
  47039. var id, body, token, tmp, firstRestricted, message, generator, isAsync,
  47040. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  47041. marker = markerCreate(), typeParameters;
  47042. isAsync = false;
  47043. if (matchAsync()) {
  47044. lex();
  47045. isAsync = true;
  47046. }
  47047. expectKeyword('function');
  47048. generator = false;
  47049. if (match('*')) {
  47050. lex();
  47051. generator = true;
  47052. }
  47053. token = lookahead;
  47054. id = parseVariableIdentifier();
  47055. if (match('<')) {
  47056. typeParameters = parseTypeParameterDeclaration();
  47057. }
  47058. if (strict) {
  47059. if (isRestrictedWord(token.value)) {
  47060. throwErrorTolerant(token, Messages.StrictFunctionName);
  47061. }
  47062. } else {
  47063. if (isRestrictedWord(token.value)) {
  47064. firstRestricted = token;
  47065. message = Messages.StrictFunctionName;
  47066. } else if (isStrictModeReservedWord(token.value)) {
  47067. firstRestricted = token;
  47068. message = Messages.StrictReservedWord;
  47069. }
  47070. }
  47071. tmp = parseParams(firstRestricted);
  47072. firstRestricted = tmp.firstRestricted;
  47073. if (tmp.message) {
  47074. message = tmp.message;
  47075. }
  47076. previousStrict = strict;
  47077. previousYieldAllowed = state.yieldAllowed;
  47078. state.yieldAllowed = generator;
  47079. previousAwaitAllowed = state.awaitAllowed;
  47080. state.awaitAllowed = isAsync;
  47081. body = parseFunctionSourceElements();
  47082. if (strict && firstRestricted) {
  47083. throwError(firstRestricted, message);
  47084. }
  47085. if (strict && tmp.stricted) {
  47086. throwErrorTolerant(tmp.stricted, message);
  47087. }
  47088. strict = previousStrict;
  47089. state.yieldAllowed = previousYieldAllowed;
  47090. state.awaitAllowed = previousAwaitAllowed;
  47091. return markerApply(
  47092. marker,
  47093. delegate.createFunctionDeclaration(
  47094. id,
  47095. tmp.params,
  47096. tmp.defaults,
  47097. body,
  47098. tmp.rest,
  47099. generator,
  47100. false,
  47101. isAsync,
  47102. tmp.returnType,
  47103. typeParameters
  47104. )
  47105. );
  47106. }
  47107. function parseFunctionExpression() {
  47108. var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
  47109. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  47110. marker = markerCreate(), typeParameters;
  47111. isAsync = false;
  47112. if (matchAsync()) {
  47113. lex();
  47114. isAsync = true;
  47115. }
  47116. expectKeyword('function');
  47117. generator = false;
  47118. if (match('*')) {
  47119. lex();
  47120. generator = true;
  47121. }
  47122. if (!match('(')) {
  47123. if (!match('<')) {
  47124. token = lookahead;
  47125. id = parseVariableIdentifier();
  47126. if (strict) {
  47127. if (isRestrictedWord(token.value)) {
  47128. throwErrorTolerant(token, Messages.StrictFunctionName);
  47129. }
  47130. } else {
  47131. if (isRestrictedWord(token.value)) {
  47132. firstRestricted = token;
  47133. message = Messages.StrictFunctionName;
  47134. } else if (isStrictModeReservedWord(token.value)) {
  47135. firstRestricted = token;
  47136. message = Messages.StrictReservedWord;
  47137. }
  47138. }
  47139. }
  47140. if (match('<')) {
  47141. typeParameters = parseTypeParameterDeclaration();
  47142. }
  47143. }
  47144. tmp = parseParams(firstRestricted);
  47145. firstRestricted = tmp.firstRestricted;
  47146. if (tmp.message) {
  47147. message = tmp.message;
  47148. }
  47149. previousStrict = strict;
  47150. previousYieldAllowed = state.yieldAllowed;
  47151. state.yieldAllowed = generator;
  47152. previousAwaitAllowed = state.awaitAllowed;
  47153. state.awaitAllowed = isAsync;
  47154. body = parseFunctionSourceElements();
  47155. if (strict && firstRestricted) {
  47156. throwError(firstRestricted, message);
  47157. }
  47158. if (strict && tmp.stricted) {
  47159. throwErrorTolerant(tmp.stricted, message);
  47160. }
  47161. strict = previousStrict;
  47162. state.yieldAllowed = previousYieldAllowed;
  47163. state.awaitAllowed = previousAwaitAllowed;
  47164. return markerApply(
  47165. marker,
  47166. delegate.createFunctionExpression(
  47167. id,
  47168. tmp.params,
  47169. tmp.defaults,
  47170. body,
  47171. tmp.rest,
  47172. generator,
  47173. false,
  47174. isAsync,
  47175. tmp.returnType,
  47176. typeParameters
  47177. )
  47178. );
  47179. }
  47180. function parseYieldExpression() {
  47181. var delegateFlag, expr, marker = markerCreate();
  47182. expectKeyword('yield', !strict);
  47183. delegateFlag = false;
  47184. if (match('*')) {
  47185. lex();
  47186. delegateFlag = true;
  47187. }
  47188. expr = parseAssignmentExpression();
  47189. return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
  47190. }
  47191. function parseAwaitExpression() {
  47192. var expr, marker = markerCreate();
  47193. expectContextualKeyword('await');
  47194. expr = parseAssignmentExpression();
  47195. return markerApply(marker, delegate.createAwaitExpression(expr));
  47196. }
  47197. // 14 Classes
  47198. function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
  47199. var token, param, propType, isValidDuplicateProp = false,
  47200. isAsync, typeParameters, tokenValue, returnType,
  47201. annotationMarker;
  47202. propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
  47203. if (generator) {
  47204. return delegate.createMethodDefinition(
  47205. propType,
  47206. '',
  47207. key,
  47208. parsePropertyMethodFunction({ generator: true })
  47209. );
  47210. }
  47211. tokenValue = key.type === 'Identifier' && key.name;
  47212. if (tokenValue === 'get' && !match('(')) {
  47213. key = parseObjectPropertyKey();
  47214. // It is a syntax error if any other properties have a name
  47215. // duplicating this one unless they are a setter
  47216. if (existingPropNames[propType].hasOwnProperty(key.name)) {
  47217. isValidDuplicateProp =
  47218. // There isn't already a getter for this prop
  47219. existingPropNames[propType][key.name].get === undefined
  47220. // There isn't already a data prop by this name
  47221. && existingPropNames[propType][key.name].data === undefined
  47222. // The only existing prop by this name is a setter
  47223. && existingPropNames[propType][key.name].set !== undefined;
  47224. if (!isValidDuplicateProp) {
  47225. throwError(key, Messages.IllegalDuplicateClassProperty);
  47226. }
  47227. } else {
  47228. existingPropNames[propType][key.name] = {};
  47229. }
  47230. existingPropNames[propType][key.name].get = true;
  47231. expect('(');
  47232. expect(')');
  47233. if (match(':')) {
  47234. returnType = parseTypeAnnotation();
  47235. }
  47236. return delegate.createMethodDefinition(
  47237. propType,
  47238. 'get',
  47239. key,
  47240. parsePropertyFunction({ generator: false, returnType: returnType })
  47241. );
  47242. }
  47243. if (tokenValue === 'set' && !match('(')) {
  47244. key = parseObjectPropertyKey();
  47245. // It is a syntax error if any other properties have a name
  47246. // duplicating this one unless they are a getter
  47247. if (existingPropNames[propType].hasOwnProperty(key.name)) {
  47248. isValidDuplicateProp =
  47249. // There isn't already a setter for this prop
  47250. existingPropNames[propType][key.name].set === undefined
  47251. // There isn't already a data prop by this name
  47252. && existingPropNames[propType][key.name].data === undefined
  47253. // The only existing prop by this name is a getter
  47254. && existingPropNames[propType][key.name].get !== undefined;
  47255. if (!isValidDuplicateProp) {
  47256. throwError(key, Messages.IllegalDuplicateClassProperty);
  47257. }
  47258. } else {
  47259. existingPropNames[propType][key.name] = {};
  47260. }
  47261. existingPropNames[propType][key.name].set = true;
  47262. expect('(');
  47263. token = lookahead;
  47264. param = [ parseTypeAnnotatableIdentifier() ];
  47265. expect(')');
  47266. if (match(':')) {
  47267. returnType = parseTypeAnnotation();
  47268. }
  47269. return delegate.createMethodDefinition(
  47270. propType,
  47271. 'set',
  47272. key,
  47273. parsePropertyFunction({
  47274. params: param,
  47275. generator: false,
  47276. name: token,
  47277. returnType: returnType
  47278. })
  47279. );
  47280. }
  47281. if (match('<')) {
  47282. typeParameters = parseTypeParameterDeclaration();
  47283. }
  47284. isAsync = tokenValue === 'async' && !match('(');
  47285. if (isAsync) {
  47286. key = parseObjectPropertyKey();
  47287. }
  47288. // It is a syntax error if any other properties have the same name as a
  47289. // non-getter, non-setter method
  47290. if (existingPropNames[propType].hasOwnProperty(key.name)) {
  47291. throwError(key, Messages.IllegalDuplicateClassProperty);
  47292. } else {
  47293. existingPropNames[propType][key.name] = {};
  47294. }
  47295. existingPropNames[propType][key.name].data = true;
  47296. return delegate.createMethodDefinition(
  47297. propType,
  47298. '',
  47299. key,
  47300. parsePropertyMethodFunction({
  47301. generator: false,
  47302. async: isAsync,
  47303. typeParameters: typeParameters
  47304. })
  47305. );
  47306. }
  47307. function parseClassProperty(existingPropNames, key, computed, isStatic) {
  47308. var typeAnnotation;
  47309. typeAnnotation = parseTypeAnnotation();
  47310. expect(';');
  47311. return delegate.createClassProperty(
  47312. key,
  47313. typeAnnotation,
  47314. computed,
  47315. isStatic
  47316. );
  47317. }
  47318. function parseClassElement(existingProps) {
  47319. var computed, generator = false, key, marker = markerCreate(),
  47320. isStatic = false;
  47321. if (match(';')) {
  47322. lex();
  47323. return;
  47324. }
  47325. if (lookahead.value === 'static') {
  47326. lex();
  47327. isStatic = true;
  47328. }
  47329. if (match('*')) {
  47330. lex();
  47331. generator = true;
  47332. }
  47333. computed = (lookahead.value === '[');
  47334. key = parseObjectPropertyKey();
  47335. if (!generator && lookahead.value === ':') {
  47336. return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
  47337. }
  47338. return markerApply(marker, parseMethodDefinition(
  47339. existingProps,
  47340. key,
  47341. isStatic,
  47342. generator,
  47343. computed
  47344. ));
  47345. }
  47346. function parseClassBody() {
  47347. var classElement, classElements = [], existingProps = {}, marker = markerCreate();
  47348. existingProps[ClassPropertyType.static] = {};
  47349. existingProps[ClassPropertyType.prototype] = {};
  47350. expect('{');
  47351. while (index < length) {
  47352. if (match('}')) {
  47353. break;
  47354. }
  47355. classElement = parseClassElement(existingProps);
  47356. if (typeof classElement !== 'undefined') {
  47357. classElements.push(classElement);
  47358. }
  47359. }
  47360. expect('}');
  47361. return markerApply(marker, delegate.createClassBody(classElements));
  47362. }
  47363. function parseClassImplements() {
  47364. var id, implemented = [], marker, typeParameters;
  47365. expectContextualKeyword('implements');
  47366. while (index < length) {
  47367. marker = markerCreate();
  47368. id = parseVariableIdentifier();
  47369. if (match('<')) {
  47370. typeParameters = parseTypeParameterInstantiation();
  47371. } else {
  47372. typeParameters = null;
  47373. }
  47374. implemented.push(markerApply(marker, delegate.createClassImplements(
  47375. id,
  47376. typeParameters
  47377. )));
  47378. if (!match(',')) {
  47379. break;
  47380. }
  47381. expect(',');
  47382. }
  47383. return implemented;
  47384. }
  47385. function parseClassExpression() {
  47386. var id, implemented, previousYieldAllowed, superClass = null,
  47387. superTypeParameters, marker = markerCreate(), typeParameters;
  47388. expectKeyword('class');
  47389. if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
  47390. id = parseVariableIdentifier();
  47391. }
  47392. if (match('<')) {
  47393. typeParameters = parseTypeParameterDeclaration();
  47394. }
  47395. if (matchKeyword('extends')) {
  47396. expectKeyword('extends');
  47397. previousYieldAllowed = state.yieldAllowed;
  47398. state.yieldAllowed = false;
  47399. superClass = parseLeftHandSideExpressionAllowCall();
  47400. if (match('<')) {
  47401. superTypeParameters = parseTypeParameterInstantiation();
  47402. }
  47403. state.yieldAllowed = previousYieldAllowed;
  47404. }
  47405. if (matchContextualKeyword('implements')) {
  47406. implemented = parseClassImplements();
  47407. }
  47408. return markerApply(marker, delegate.createClassExpression(
  47409. id,
  47410. superClass,
  47411. parseClassBody(),
  47412. typeParameters,
  47413. superTypeParameters,
  47414. implemented
  47415. ));
  47416. }
  47417. function parseClassDeclaration() {
  47418. var id, implemented, previousYieldAllowed, superClass = null,
  47419. superTypeParameters, marker = markerCreate(), typeParameters;
  47420. expectKeyword('class');
  47421. id = parseVariableIdentifier();
  47422. if (match('<')) {
  47423. typeParameters = parseTypeParameterDeclaration();
  47424. }
  47425. if (matchKeyword('extends')) {
  47426. expectKeyword('extends');
  47427. previousYieldAllowed = state.yieldAllowed;
  47428. state.yieldAllowed = false;
  47429. superClass = parseLeftHandSideExpressionAllowCall();
  47430. if (match('<')) {
  47431. superTypeParameters = parseTypeParameterInstantiation();
  47432. }
  47433. state.yieldAllowed = previousYieldAllowed;
  47434. }
  47435. if (matchContextualKeyword('implements')) {
  47436. implemented = parseClassImplements();
  47437. }
  47438. return markerApply(marker, delegate.createClassDeclaration(
  47439. id,
  47440. superClass,
  47441. parseClassBody(),
  47442. typeParameters,
  47443. superTypeParameters,
  47444. implemented
  47445. ));
  47446. }
  47447. // 15 Program
  47448. function parseSourceElement() {
  47449. var token;
  47450. if (lookahead.type === Token.Keyword) {
  47451. switch (lookahead.value) {
  47452. case 'const':
  47453. case 'let':
  47454. return parseConstLetDeclaration(lookahead.value);
  47455. case 'function':
  47456. return parseFunctionDeclaration();
  47457. default:
  47458. return parseStatement();
  47459. }
  47460. }
  47461. if (matchContextualKeyword('type')
  47462. && lookahead2().type === Token.Identifier) {
  47463. return parseTypeAlias();
  47464. }
  47465. if (matchContextualKeyword('interface')
  47466. && lookahead2().type === Token.Identifier) {
  47467. return parseInterface();
  47468. }
  47469. if (matchContextualKeyword('declare')) {
  47470. token = lookahead2();
  47471. if (token.type === Token.Keyword) {
  47472. switch (token.value) {
  47473. case 'class':
  47474. return parseDeclareClass();
  47475. case 'function':
  47476. return parseDeclareFunction();
  47477. case 'var':
  47478. return parseDeclareVariable();
  47479. }
  47480. } else if (token.type === Token.Identifier
  47481. && token.value === 'module') {
  47482. return parseDeclareModule();
  47483. }
  47484. }
  47485. if (lookahead.type !== Token.EOF) {
  47486. return parseStatement();
  47487. }
  47488. }
  47489. function parseProgramElement() {
  47490. if (lookahead.type === Token.Keyword) {
  47491. switch (lookahead.value) {
  47492. case 'export':
  47493. return parseExportDeclaration();
  47494. case 'import':
  47495. return parseImportDeclaration();
  47496. }
  47497. }
  47498. return parseSourceElement();
  47499. }
  47500. function parseProgramElements() {
  47501. var sourceElement, sourceElements = [], token, directive, firstRestricted;
  47502. while (index < length) {
  47503. token = lookahead;
  47504. if (token.type !== Token.StringLiteral) {
  47505. break;
  47506. }
  47507. sourceElement = parseProgramElement();
  47508. sourceElements.push(sourceElement);
  47509. if (sourceElement.expression.type !== Syntax.Literal) {
  47510. // this is not directive
  47511. break;
  47512. }
  47513. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  47514. if (directive === 'use strict') {
  47515. strict = true;
  47516. if (firstRestricted) {
  47517. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  47518. }
  47519. } else {
  47520. if (!firstRestricted && token.octal) {
  47521. firstRestricted = token;
  47522. }
  47523. }
  47524. }
  47525. while (index < length) {
  47526. sourceElement = parseProgramElement();
  47527. if (typeof sourceElement === 'undefined') {
  47528. break;
  47529. }
  47530. sourceElements.push(sourceElement);
  47531. }
  47532. return sourceElements;
  47533. }
  47534. function parseProgram() {
  47535. var body, marker = markerCreate();
  47536. strict = false;
  47537. peek();
  47538. body = parseProgramElements();
  47539. return markerApply(marker, delegate.createProgram(body));
  47540. }
  47541. // The following functions are needed only when the option to preserve
  47542. // the comments is active.
  47543. function addComment(type, value, start, end, loc) {
  47544. var comment;
  47545. assert(typeof start === 'number', 'Comment must have valid position');
  47546. // Because the way the actual token is scanned, often the comments
  47547. // (if any) are skipped twice during the lexical analysis.
  47548. // Thus, we need to skip adding a comment if the comment array already
  47549. // handled it.
  47550. if (state.lastCommentStart >= start) {
  47551. return;
  47552. }
  47553. state.lastCommentStart = start;
  47554. comment = {
  47555. type: type,
  47556. value: value
  47557. };
  47558. if (extra.range) {
  47559. comment.range = [start, end];
  47560. }
  47561. if (extra.loc) {
  47562. comment.loc = loc;
  47563. }
  47564. extra.comments.push(comment);
  47565. if (extra.attachComment) {
  47566. extra.leadingComments.push(comment);
  47567. extra.trailingComments.push(comment);
  47568. }
  47569. }
  47570. function scanComment() {
  47571. var comment, ch, loc, start, blockComment, lineComment;
  47572. comment = '';
  47573. blockComment = false;
  47574. lineComment = false;
  47575. while (index < length) {
  47576. ch = source[index];
  47577. if (lineComment) {
  47578. ch = source[index++];
  47579. if (isLineTerminator(ch.charCodeAt(0))) {
  47580. loc.end = {
  47581. line: lineNumber,
  47582. column: index - lineStart - 1
  47583. };
  47584. lineComment = false;
  47585. addComment('Line', comment, start, index - 1, loc);
  47586. if (ch === '\r' && source[index] === '\n') {
  47587. ++index;
  47588. }
  47589. ++lineNumber;
  47590. lineStart = index;
  47591. comment = '';
  47592. } else if (index >= length) {
  47593. lineComment = false;
  47594. comment += ch;
  47595. loc.end = {
  47596. line: lineNumber,
  47597. column: length - lineStart
  47598. };
  47599. addComment('Line', comment, start, length, loc);
  47600. } else {
  47601. comment += ch;
  47602. }
  47603. } else if (blockComment) {
  47604. if (isLineTerminator(ch.charCodeAt(0))) {
  47605. if (ch === '\r') {
  47606. ++index;
  47607. comment += '\r';
  47608. }
  47609. if (ch !== '\r' || source[index] === '\n') {
  47610. comment += source[index];
  47611. ++lineNumber;
  47612. ++index;
  47613. lineStart = index;
  47614. if (index >= length) {
  47615. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  47616. }
  47617. }
  47618. } else {
  47619. ch = source[index++];
  47620. if (index >= length) {
  47621. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  47622. }
  47623. comment += ch;
  47624. if (ch === '*') {
  47625. ch = source[index];
  47626. if (ch === '/') {
  47627. comment = comment.substr(0, comment.length - 1);
  47628. blockComment = false;
  47629. ++index;
  47630. loc.end = {
  47631. line: lineNumber,
  47632. column: index - lineStart
  47633. };
  47634. addComment('Block', comment, start, index, loc);
  47635. comment = '';
  47636. }
  47637. }
  47638. }
  47639. } else if (ch === '/') {
  47640. ch = source[index + 1];
  47641. if (ch === '/') {
  47642. loc = {
  47643. start: {
  47644. line: lineNumber,
  47645. column: index - lineStart
  47646. }
  47647. };
  47648. start = index;
  47649. index += 2;
  47650. lineComment = true;
  47651. if (index >= length) {
  47652. loc.end = {
  47653. line: lineNumber,
  47654. column: index - lineStart
  47655. };
  47656. lineComment = false;
  47657. addComment('Line', comment, start, index, loc);
  47658. }
  47659. } else if (ch === '*') {
  47660. start = index;
  47661. index += 2;
  47662. blockComment = true;
  47663. loc = {
  47664. start: {
  47665. line: lineNumber,
  47666. column: index - lineStart - 2
  47667. }
  47668. };
  47669. if (index >= length) {
  47670. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  47671. }
  47672. } else {
  47673. break;
  47674. }
  47675. } else if (isWhiteSpace(ch.charCodeAt(0))) {
  47676. ++index;
  47677. } else if (isLineTerminator(ch.charCodeAt(0))) {
  47678. ++index;
  47679. if (ch === '\r' && source[index] === '\n') {
  47680. ++index;
  47681. }
  47682. ++lineNumber;
  47683. lineStart = index;
  47684. } else {
  47685. break;
  47686. }
  47687. }
  47688. }
  47689. // 16 XJS
  47690. XHTMLEntities = {
  47691. quot: '\u0022',
  47692. amp: '&',
  47693. apos: '\u0027',
  47694. lt: '<',
  47695. gt: '>',
  47696. nbsp: '\u00A0',
  47697. iexcl: '\u00A1',
  47698. cent: '\u00A2',
  47699. pound: '\u00A3',
  47700. curren: '\u00A4',
  47701. yen: '\u00A5',
  47702. brvbar: '\u00A6',
  47703. sect: '\u00A7',
  47704. uml: '\u00A8',
  47705. copy: '\u00A9',
  47706. ordf: '\u00AA',
  47707. laquo: '\u00AB',
  47708. not: '\u00AC',
  47709. shy: '\u00AD',
  47710. reg: '\u00AE',
  47711. macr: '\u00AF',
  47712. deg: '\u00B0',
  47713. plusmn: '\u00B1',
  47714. sup2: '\u00B2',
  47715. sup3: '\u00B3',
  47716. acute: '\u00B4',
  47717. micro: '\u00B5',
  47718. para: '\u00B6',
  47719. middot: '\u00B7',
  47720. cedil: '\u00B8',
  47721. sup1: '\u00B9',
  47722. ordm: '\u00BA',
  47723. raquo: '\u00BB',
  47724. frac14: '\u00BC',
  47725. frac12: '\u00BD',
  47726. frac34: '\u00BE',
  47727. iquest: '\u00BF',
  47728. Agrave: '\u00C0',
  47729. Aacute: '\u00C1',
  47730. Acirc: '\u00C2',
  47731. Atilde: '\u00C3',
  47732. Auml: '\u00C4',
  47733. Aring: '\u00C5',
  47734. AElig: '\u00C6',
  47735. Ccedil: '\u00C7',
  47736. Egrave: '\u00C8',
  47737. Eacute: '\u00C9',
  47738. Ecirc: '\u00CA',
  47739. Euml: '\u00CB',
  47740. Igrave: '\u00CC',
  47741. Iacute: '\u00CD',
  47742. Icirc: '\u00CE',
  47743. Iuml: '\u00CF',
  47744. ETH: '\u00D0',
  47745. Ntilde: '\u00D1',
  47746. Ograve: '\u00D2',
  47747. Oacute: '\u00D3',
  47748. Ocirc: '\u00D4',
  47749. Otilde: '\u00D5',
  47750. Ouml: '\u00D6',
  47751. times: '\u00D7',
  47752. Oslash: '\u00D8',
  47753. Ugrave: '\u00D9',
  47754. Uacute: '\u00DA',
  47755. Ucirc: '\u00DB',
  47756. Uuml: '\u00DC',
  47757. Yacute: '\u00DD',
  47758. THORN: '\u00DE',
  47759. szlig: '\u00DF',
  47760. agrave: '\u00E0',
  47761. aacute: '\u00E1',
  47762. acirc: '\u00E2',
  47763. atilde: '\u00E3',
  47764. auml: '\u00E4',
  47765. aring: '\u00E5',
  47766. aelig: '\u00E6',
  47767. ccedil: '\u00E7',
  47768. egrave: '\u00E8',
  47769. eacute: '\u00E9',
  47770. ecirc: '\u00EA',
  47771. euml: '\u00EB',
  47772. igrave: '\u00EC',
  47773. iacute: '\u00ED',
  47774. icirc: '\u00EE',
  47775. iuml: '\u00EF',
  47776. eth: '\u00F0',
  47777. ntilde: '\u00F1',
  47778. ograve: '\u00F2',
  47779. oacute: '\u00F3',
  47780. ocirc: '\u00F4',
  47781. otilde: '\u00F5',
  47782. ouml: '\u00F6',
  47783. divide: '\u00F7',
  47784. oslash: '\u00F8',
  47785. ugrave: '\u00F9',
  47786. uacute: '\u00FA',
  47787. ucirc: '\u00FB',
  47788. uuml: '\u00FC',
  47789. yacute: '\u00FD',
  47790. thorn: '\u00FE',
  47791. yuml: '\u00FF',
  47792. OElig: '\u0152',
  47793. oelig: '\u0153',
  47794. Scaron: '\u0160',
  47795. scaron: '\u0161',
  47796. Yuml: '\u0178',
  47797. fnof: '\u0192',
  47798. circ: '\u02C6',
  47799. tilde: '\u02DC',
  47800. Alpha: '\u0391',
  47801. Beta: '\u0392',
  47802. Gamma: '\u0393',
  47803. Delta: '\u0394',
  47804. Epsilon: '\u0395',
  47805. Zeta: '\u0396',
  47806. Eta: '\u0397',
  47807. Theta: '\u0398',
  47808. Iota: '\u0399',
  47809. Kappa: '\u039A',
  47810. Lambda: '\u039B',
  47811. Mu: '\u039C',
  47812. Nu: '\u039D',
  47813. Xi: '\u039E',
  47814. Omicron: '\u039F',
  47815. Pi: '\u03A0',
  47816. Rho: '\u03A1',
  47817. Sigma: '\u03A3',
  47818. Tau: '\u03A4',
  47819. Upsilon: '\u03A5',
  47820. Phi: '\u03A6',
  47821. Chi: '\u03A7',
  47822. Psi: '\u03A8',
  47823. Omega: '\u03A9',
  47824. alpha: '\u03B1',
  47825. beta: '\u03B2',
  47826. gamma: '\u03B3',
  47827. delta: '\u03B4',
  47828. epsilon: '\u03B5',
  47829. zeta: '\u03B6',
  47830. eta: '\u03B7',
  47831. theta: '\u03B8',
  47832. iota: '\u03B9',
  47833. kappa: '\u03BA',
  47834. lambda: '\u03BB',
  47835. mu: '\u03BC',
  47836. nu: '\u03BD',
  47837. xi: '\u03BE',
  47838. omicron: '\u03BF',
  47839. pi: '\u03C0',
  47840. rho: '\u03C1',
  47841. sigmaf: '\u03C2',
  47842. sigma: '\u03C3',
  47843. tau: '\u03C4',
  47844. upsilon: '\u03C5',
  47845. phi: '\u03C6',
  47846. chi: '\u03C7',
  47847. psi: '\u03C8',
  47848. omega: '\u03C9',
  47849. thetasym: '\u03D1',
  47850. upsih: '\u03D2',
  47851. piv: '\u03D6',
  47852. ensp: '\u2002',
  47853. emsp: '\u2003',
  47854. thinsp: '\u2009',
  47855. zwnj: '\u200C',
  47856. zwj: '\u200D',
  47857. lrm: '\u200E',
  47858. rlm: '\u200F',
  47859. ndash: '\u2013',
  47860. mdash: '\u2014',
  47861. lsquo: '\u2018',
  47862. rsquo: '\u2019',
  47863. sbquo: '\u201A',
  47864. ldquo: '\u201C',
  47865. rdquo: '\u201D',
  47866. bdquo: '\u201E',
  47867. dagger: '\u2020',
  47868. Dagger: '\u2021',
  47869. bull: '\u2022',
  47870. hellip: '\u2026',
  47871. permil: '\u2030',
  47872. prime: '\u2032',
  47873. Prime: '\u2033',
  47874. lsaquo: '\u2039',
  47875. rsaquo: '\u203A',
  47876. oline: '\u203E',
  47877. frasl: '\u2044',
  47878. euro: '\u20AC',
  47879. image: '\u2111',
  47880. weierp: '\u2118',
  47881. real: '\u211C',
  47882. trade: '\u2122',
  47883. alefsym: '\u2135',
  47884. larr: '\u2190',
  47885. uarr: '\u2191',
  47886. rarr: '\u2192',
  47887. darr: '\u2193',
  47888. harr: '\u2194',
  47889. crarr: '\u21B5',
  47890. lArr: '\u21D0',
  47891. uArr: '\u21D1',
  47892. rArr: '\u21D2',
  47893. dArr: '\u21D3',
  47894. hArr: '\u21D4',
  47895. forall: '\u2200',
  47896. part: '\u2202',
  47897. exist: '\u2203',
  47898. empty: '\u2205',
  47899. nabla: '\u2207',
  47900. isin: '\u2208',
  47901. notin: '\u2209',
  47902. ni: '\u220B',
  47903. prod: '\u220F',
  47904. sum: '\u2211',
  47905. minus: '\u2212',
  47906. lowast: '\u2217',
  47907. radic: '\u221A',
  47908. prop: '\u221D',
  47909. infin: '\u221E',
  47910. ang: '\u2220',
  47911. and: '\u2227',
  47912. or: '\u2228',
  47913. cap: '\u2229',
  47914. cup: '\u222A',
  47915. 'int': '\u222B',
  47916. there4: '\u2234',
  47917. sim: '\u223C',
  47918. cong: '\u2245',
  47919. asymp: '\u2248',
  47920. ne: '\u2260',
  47921. equiv: '\u2261',
  47922. le: '\u2264',
  47923. ge: '\u2265',
  47924. sub: '\u2282',
  47925. sup: '\u2283',
  47926. nsub: '\u2284',
  47927. sube: '\u2286',
  47928. supe: '\u2287',
  47929. oplus: '\u2295',
  47930. otimes: '\u2297',
  47931. perp: '\u22A5',
  47932. sdot: '\u22C5',
  47933. lceil: '\u2308',
  47934. rceil: '\u2309',
  47935. lfloor: '\u230A',
  47936. rfloor: '\u230B',
  47937. lang: '\u2329',
  47938. rang: '\u232A',
  47939. loz: '\u25CA',
  47940. spades: '\u2660',
  47941. clubs: '\u2663',
  47942. hearts: '\u2665',
  47943. diams: '\u2666'
  47944. };
  47945. function getQualifiedXJSName(object) {
  47946. if (object.type === Syntax.XJSIdentifier) {
  47947. return object.name;
  47948. }
  47949. if (object.type === Syntax.XJSNamespacedName) {
  47950. return object.namespace.name + ':' + object.name.name;
  47951. }
  47952. if (object.type === Syntax.XJSMemberExpression) {
  47953. return (
  47954. getQualifiedXJSName(object.object) + '.' +
  47955. getQualifiedXJSName(object.property)
  47956. );
  47957. }
  47958. }
  47959. function isXJSIdentifierStart(ch) {
  47960. // exclude backslash (\)
  47961. return (ch !== 92) && isIdentifierStart(ch);
  47962. }
  47963. function isXJSIdentifierPart(ch) {
  47964. // exclude backslash (\) and add hyphen (-)
  47965. return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
  47966. }
  47967. function scanXJSIdentifier() {
  47968. var ch, start, value = '';
  47969. start = index;
  47970. while (index < length) {
  47971. ch = source.charCodeAt(index);
  47972. if (!isXJSIdentifierPart(ch)) {
  47973. break;
  47974. }
  47975. value += source[index++];
  47976. }
  47977. return {
  47978. type: Token.XJSIdentifier,
  47979. value: value,
  47980. lineNumber: lineNumber,
  47981. lineStart: lineStart,
  47982. range: [start, index]
  47983. };
  47984. }
  47985. function scanXJSEntity() {
  47986. var ch, str = '', start = index, count = 0, code;
  47987. ch = source[index];
  47988. assert(ch === '&', 'Entity must start with an ampersand');
  47989. index++;
  47990. while (index < length && count++ < 10) {
  47991. ch = source[index++];
  47992. if (ch === ';') {
  47993. break;
  47994. }
  47995. str += ch;
  47996. }
  47997. // Well-formed entity (ending was found).
  47998. if (ch === ';') {
  47999. // Numeric entity.
  48000. if (str[0] === '#') {
  48001. if (str[1] === 'x') {
  48002. code = +('0' + str.substr(1));
  48003. } else {
  48004. // Removing leading zeros in order to avoid treating as octal in old browsers.
  48005. code = +str.substr(1).replace(Regex.LeadingZeros, '');
  48006. }
  48007. if (!isNaN(code)) {
  48008. return String.fromCharCode(code);
  48009. }
  48010. } else if (XHTMLEntities[str]) {
  48011. return XHTMLEntities[str];
  48012. }
  48013. }
  48014. // Treat non-entity sequences as regular text.
  48015. index = start + 1;
  48016. return '&';
  48017. }
  48018. function scanXJSText(stopChars) {
  48019. var ch, str = '', start;
  48020. start = index;
  48021. while (index < length) {
  48022. ch = source[index];
  48023. if (stopChars.indexOf(ch) !== -1) {
  48024. break;
  48025. }
  48026. if (ch === '&') {
  48027. str += scanXJSEntity();
  48028. } else {
  48029. index++;
  48030. if (ch === '\r' && source[index] === '\n') {
  48031. str += ch;
  48032. ch = source[index];
  48033. index++;
  48034. }
  48035. if (isLineTerminator(ch.charCodeAt(0))) {
  48036. ++lineNumber;
  48037. lineStart = index;
  48038. }
  48039. str += ch;
  48040. }
  48041. }
  48042. return {
  48043. type: Token.XJSText,
  48044. value: str,
  48045. lineNumber: lineNumber,
  48046. lineStart: lineStart,
  48047. range: [start, index]
  48048. };
  48049. }
  48050. function scanXJSStringLiteral() {
  48051. var innerToken, quote, start;
  48052. quote = source[index];
  48053. assert((quote === '\'' || quote === '"'),
  48054. 'String literal must starts with a quote');
  48055. start = index;
  48056. ++index;
  48057. innerToken = scanXJSText([quote]);
  48058. if (quote !== source[index]) {
  48059. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  48060. }
  48061. ++index;
  48062. innerToken.range = [start, index];
  48063. return innerToken;
  48064. }
  48065. /**
  48066. * Between XJS opening and closing tags (e.g. <foo>HERE</foo>), anything that
  48067. * is not another XJS tag and is not an expression wrapped by {} is text.
  48068. */
  48069. function advanceXJSChild() {
  48070. var ch = source.charCodeAt(index);
  48071. // { (123) and < (60)
  48072. if (ch !== 123 && ch !== 60) {
  48073. return scanXJSText(['<', '{']);
  48074. }
  48075. return scanPunctuator();
  48076. }
  48077. function parseXJSIdentifier() {
  48078. var token, marker = markerCreate();
  48079. if (lookahead.type !== Token.XJSIdentifier) {
  48080. throwUnexpected(lookahead);
  48081. }
  48082. token = lex();
  48083. return markerApply(marker, delegate.createXJSIdentifier(token.value));
  48084. }
  48085. function parseXJSNamespacedName() {
  48086. var namespace, name, marker = markerCreate();
  48087. namespace = parseXJSIdentifier();
  48088. expect(':');
  48089. name = parseXJSIdentifier();
  48090. return markerApply(marker, delegate.createXJSNamespacedName(namespace, name));
  48091. }
  48092. function parseXJSMemberExpression() {
  48093. var marker = markerCreate(),
  48094. expr = parseXJSIdentifier();
  48095. while (match('.')) {
  48096. lex();
  48097. expr = markerApply(marker, delegate.createXJSMemberExpression(expr, parseXJSIdentifier()));
  48098. }
  48099. return expr;
  48100. }
  48101. function parseXJSElementName() {
  48102. if (lookahead2().value === ':') {
  48103. return parseXJSNamespacedName();
  48104. }
  48105. if (lookahead2().value === '.') {
  48106. return parseXJSMemberExpression();
  48107. }
  48108. return parseXJSIdentifier();
  48109. }
  48110. function parseXJSAttributeName() {
  48111. if (lookahead2().value === ':') {
  48112. return parseXJSNamespacedName();
  48113. }
  48114. return parseXJSIdentifier();
  48115. }
  48116. function parseXJSAttributeValue() {
  48117. var value, marker;
  48118. if (match('{')) {
  48119. value = parseXJSExpressionContainer();
  48120. if (value.expression.type === Syntax.XJSEmptyExpression) {
  48121. throwError(
  48122. value,
  48123. 'XJS attributes must only be assigned a non-empty ' +
  48124. 'expression'
  48125. );
  48126. }
  48127. } else if (match('<')) {
  48128. value = parseXJSElement();
  48129. } else if (lookahead.type === Token.XJSText) {
  48130. marker = markerCreate();
  48131. value = markerApply(marker, delegate.createLiteral(lex()));
  48132. } else {
  48133. throwError({}, Messages.InvalidXJSAttributeValue);
  48134. }
  48135. return value;
  48136. }
  48137. function parseXJSEmptyExpression() {
  48138. var marker = markerCreatePreserveWhitespace();
  48139. while (source.charAt(index) !== '}') {
  48140. index++;
  48141. }
  48142. return markerApply(marker, delegate.createXJSEmptyExpression());
  48143. }
  48144. function parseXJSExpressionContainer() {
  48145. var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
  48146. origInXJSChild = state.inXJSChild;
  48147. origInXJSTag = state.inXJSTag;
  48148. state.inXJSChild = false;
  48149. state.inXJSTag = false;
  48150. expect('{');
  48151. if (match('}')) {
  48152. expression = parseXJSEmptyExpression();
  48153. } else {
  48154. expression = parseExpression();
  48155. }
  48156. state.inXJSChild = origInXJSChild;
  48157. state.inXJSTag = origInXJSTag;
  48158. expect('}');
  48159. return markerApply(marker, delegate.createXJSExpressionContainer(expression));
  48160. }
  48161. function parseXJSSpreadAttribute() {
  48162. var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
  48163. origInXJSChild = state.inXJSChild;
  48164. origInXJSTag = state.inXJSTag;
  48165. state.inXJSChild = false;
  48166. state.inXJSTag = false;
  48167. expect('{');
  48168. expect('...');
  48169. expression = parseAssignmentExpression();
  48170. state.inXJSChild = origInXJSChild;
  48171. state.inXJSTag = origInXJSTag;
  48172. expect('}');
  48173. return markerApply(marker, delegate.createXJSSpreadAttribute(expression));
  48174. }
  48175. function parseXJSAttribute() {
  48176. var name, marker;
  48177. if (match('{')) {
  48178. return parseXJSSpreadAttribute();
  48179. }
  48180. marker = markerCreate();
  48181. name = parseXJSAttributeName();
  48182. // HTML empty attribute
  48183. if (match('=')) {
  48184. lex();
  48185. return markerApply(marker, delegate.createXJSAttribute(name, parseXJSAttributeValue()));
  48186. }
  48187. return markerApply(marker, delegate.createXJSAttribute(name));
  48188. }
  48189. function parseXJSChild() {
  48190. var token, marker;
  48191. if (match('{')) {
  48192. token = parseXJSExpressionContainer();
  48193. } else if (lookahead.type === Token.XJSText) {
  48194. marker = markerCreatePreserveWhitespace();
  48195. token = markerApply(marker, delegate.createLiteral(lex()));
  48196. } else {
  48197. token = parseXJSElement();
  48198. }
  48199. return token;
  48200. }
  48201. function parseXJSClosingElement() {
  48202. var name, origInXJSChild, origInXJSTag, marker = markerCreate();
  48203. origInXJSChild = state.inXJSChild;
  48204. origInXJSTag = state.inXJSTag;
  48205. state.inXJSChild = false;
  48206. state.inXJSTag = true;
  48207. expect('<');
  48208. expect('/');
  48209. name = parseXJSElementName();
  48210. // Because advance() (called by lex() called by expect()) expects there
  48211. // to be a valid token after >, it needs to know whether to look for a
  48212. // standard JS token or an XJS text node
  48213. state.inXJSChild = origInXJSChild;
  48214. state.inXJSTag = origInXJSTag;
  48215. expect('>');
  48216. return markerApply(marker, delegate.createXJSClosingElement(name));
  48217. }
  48218. function parseXJSOpeningElement() {
  48219. var name, attribute, attributes = [], selfClosing = false, origInXJSChild, origInXJSTag, marker = markerCreate();
  48220. origInXJSChild = state.inXJSChild;
  48221. origInXJSTag = state.inXJSTag;
  48222. state.inXJSChild = false;
  48223. state.inXJSTag = true;
  48224. expect('<');
  48225. name = parseXJSElementName();
  48226. while (index < length &&
  48227. lookahead.value !== '/' &&
  48228. lookahead.value !== '>') {
  48229. attributes.push(parseXJSAttribute());
  48230. }
  48231. state.inXJSTag = origInXJSTag;
  48232. if (lookahead.value === '/') {
  48233. expect('/');
  48234. // Because advance() (called by lex() called by expect()) expects
  48235. // there to be a valid token after >, it needs to know whether to
  48236. // look for a standard JS token or an XJS text node
  48237. state.inXJSChild = origInXJSChild;
  48238. expect('>');
  48239. selfClosing = true;
  48240. } else {
  48241. state.inXJSChild = true;
  48242. expect('>');
  48243. }
  48244. return markerApply(marker, delegate.createXJSOpeningElement(name, attributes, selfClosing));
  48245. }
  48246. function parseXJSElement() {
  48247. var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
  48248. origInXJSChild = state.inXJSChild;
  48249. origInXJSTag = state.inXJSTag;
  48250. openingElement = parseXJSOpeningElement();
  48251. if (!openingElement.selfClosing) {
  48252. while (index < length) {
  48253. state.inXJSChild = false; // Call lookahead2() with inXJSChild = false because </ should not be considered in the child
  48254. if (lookahead.value === '<' && lookahead2().value === '/') {
  48255. break;
  48256. }
  48257. state.inXJSChild = true;
  48258. children.push(parseXJSChild());
  48259. }
  48260. state.inXJSChild = origInXJSChild;
  48261. state.inXJSTag = origInXJSTag;
  48262. closingElement = parseXJSClosingElement();
  48263. if (getQualifiedXJSName(closingElement.name) !== getQualifiedXJSName(openingElement.name)) {
  48264. throwError({}, Messages.ExpectedXJSClosingTag, getQualifiedXJSName(openingElement.name));
  48265. }
  48266. }
  48267. // When (erroneously) writing two adjacent tags like
  48268. //
  48269. // var x = <div>one</div><div>two</div>;
  48270. //
  48271. // the default error message is a bit incomprehensible. Since it's
  48272. // rarely (never?) useful to write a less-than sign after an XJS
  48273. // element, we disallow it here in the parser in order to provide a
  48274. // better error message. (In the rare case that the less-than operator
  48275. // was intended, the left tag can be wrapped in parentheses.)
  48276. if (!origInXJSChild && match('<')) {
  48277. throwError(lookahead, Messages.AdjacentXJSElements);
  48278. }
  48279. return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
  48280. }
  48281. function parseTypeAlias() {
  48282. var id, marker = markerCreate(), typeParameters = null, right;
  48283. expectContextualKeyword('type');
  48284. id = parseVariableIdentifier();
  48285. if (match('<')) {
  48286. typeParameters = parseTypeParameterDeclaration();
  48287. }
  48288. expect('=');
  48289. right = parseType();
  48290. consumeSemicolon();
  48291. return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
  48292. }
  48293. function parseInterfaceExtends() {
  48294. var marker = markerCreate(), id, typeParameters = null;
  48295. id = parseVariableIdentifier();
  48296. if (match('<')) {
  48297. typeParameters = parseTypeParameterInstantiation();
  48298. }
  48299. return markerApply(marker, delegate.createInterfaceExtends(
  48300. id,
  48301. typeParameters
  48302. ));
  48303. }
  48304. function parseInterfaceish(marker, allowStatic) {
  48305. var body, bodyMarker, extended = [], id,
  48306. typeParameters = null;
  48307. id = parseVariableIdentifier();
  48308. if (match('<')) {
  48309. typeParameters = parseTypeParameterDeclaration();
  48310. }
  48311. if (matchKeyword('extends')) {
  48312. expectKeyword('extends');
  48313. while (index < length) {
  48314. extended.push(parseInterfaceExtends());
  48315. if (!match(',')) {
  48316. break;
  48317. }
  48318. expect(',');
  48319. }
  48320. }
  48321. bodyMarker = markerCreate();
  48322. body = markerApply(bodyMarker, parseObjectType(allowStatic));
  48323. return markerApply(marker, delegate.createInterface(
  48324. id,
  48325. typeParameters,
  48326. body,
  48327. extended
  48328. ));
  48329. }
  48330. function parseInterface() {
  48331. var body, bodyMarker, extended = [], id, marker = markerCreate(),
  48332. typeParameters = null;
  48333. expectContextualKeyword('interface');
  48334. return parseInterfaceish(marker, /* allowStatic */false);
  48335. }
  48336. function parseDeclareClass() {
  48337. var marker = markerCreate(), ret;
  48338. expectContextualKeyword('declare');
  48339. expectKeyword('class');
  48340. ret = parseInterfaceish(marker, /* allowStatic */true);
  48341. ret.type = Syntax.DeclareClass;
  48342. return ret;
  48343. }
  48344. function parseDeclareFunction() {
  48345. var id, idMarker,
  48346. marker = markerCreate(), params, returnType, rest, tmp,
  48347. typeParameters = null, value, valueMarker;
  48348. expectContextualKeyword('declare');
  48349. expectKeyword('function');
  48350. idMarker = markerCreate();
  48351. id = parseVariableIdentifier();
  48352. valueMarker = markerCreate();
  48353. if (match('<')) {
  48354. typeParameters = parseTypeParameterDeclaration();
  48355. }
  48356. expect('(');
  48357. tmp = parseFunctionTypeParams();
  48358. params = tmp.params;
  48359. rest = tmp.rest;
  48360. expect(')');
  48361. expect(':');
  48362. returnType = parseType();
  48363. value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
  48364. params,
  48365. returnType,
  48366. rest,
  48367. typeParameters
  48368. ));
  48369. id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
  48370. value
  48371. ));
  48372. markerApply(idMarker, id);
  48373. consumeSemicolon();
  48374. return markerApply(marker, delegate.createDeclareFunction(
  48375. id
  48376. ));
  48377. }
  48378. function parseDeclareVariable() {
  48379. var id, marker = markerCreate();
  48380. expectContextualKeyword('declare');
  48381. expectKeyword('var');
  48382. id = parseTypeAnnotatableIdentifier();
  48383. consumeSemicolon();
  48384. return markerApply(marker, delegate.createDeclareVariable(
  48385. id
  48386. ));
  48387. }
  48388. function parseDeclareModule() {
  48389. var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
  48390. expectContextualKeyword('declare');
  48391. expectContextualKeyword('module');
  48392. if (lookahead.type === Token.StringLiteral) {
  48393. if (strict && lookahead.octal) {
  48394. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  48395. }
  48396. idMarker = markerCreate();
  48397. id = markerApply(idMarker, delegate.createLiteral(lex()));
  48398. } else {
  48399. id = parseVariableIdentifier();
  48400. }
  48401. bodyMarker = markerCreate();
  48402. expect('{');
  48403. while (index < length && !match('}')) {
  48404. token = lookahead2();
  48405. switch (token.value) {
  48406. case 'class':
  48407. body.push(parseDeclareClass());
  48408. break;
  48409. case 'function':
  48410. body.push(parseDeclareFunction());
  48411. break;
  48412. case 'var':
  48413. body.push(parseDeclareVariable());
  48414. break;
  48415. default:
  48416. throwUnexpected(lookahead);
  48417. }
  48418. }
  48419. expect('}');
  48420. return markerApply(marker, delegate.createDeclareModule(
  48421. id,
  48422. markerApply(bodyMarker, delegate.createBlockStatement(body))
  48423. ));
  48424. }
  48425. function collectToken() {
  48426. var start, loc, token, range, value, entry;
  48427. if (!state.inXJSChild) {
  48428. skipComment();
  48429. }
  48430. start = index;
  48431. loc = {
  48432. start: {
  48433. line: lineNumber,
  48434. column: index - lineStart
  48435. }
  48436. };
  48437. token = extra.advance();
  48438. loc.end = {
  48439. line: lineNumber,
  48440. column: index - lineStart
  48441. };
  48442. if (token.type !== Token.EOF) {
  48443. range = [token.range[0], token.range[1]];
  48444. value = source.slice(token.range[0], token.range[1]);
  48445. entry = {
  48446. type: TokenName[token.type],
  48447. value: value,
  48448. range: range,
  48449. loc: loc
  48450. };
  48451. if (token.regex) {
  48452. entry.regex = {
  48453. pattern: token.regex.pattern,
  48454. flags: token.regex.flags
  48455. };
  48456. }
  48457. extra.tokens.push(entry);
  48458. }
  48459. return token;
  48460. }
  48461. function collectRegex() {
  48462. var pos, loc, regex, token;
  48463. skipComment();
  48464. pos = index;
  48465. loc = {
  48466. start: {
  48467. line: lineNumber,
  48468. column: index - lineStart
  48469. }
  48470. };
  48471. regex = extra.scanRegExp();
  48472. loc.end = {
  48473. line: lineNumber,
  48474. column: index - lineStart
  48475. };
  48476. if (!extra.tokenize) {
  48477. // Pop the previous token, which is likely '/' or '/='
  48478. if (extra.tokens.length > 0) {
  48479. token = extra.tokens[extra.tokens.length - 1];
  48480. if (token.range[0] === pos && token.type === 'Punctuator') {
  48481. if (token.value === '/' || token.value === '/=') {
  48482. extra.tokens.pop();
  48483. }
  48484. }
  48485. }
  48486. extra.tokens.push({
  48487. type: 'RegularExpression',
  48488. value: regex.literal,
  48489. regex: regex.regex,
  48490. range: [pos, index],
  48491. loc: loc
  48492. });
  48493. }
  48494. return regex;
  48495. }
  48496. function filterTokenLocation() {
  48497. var i, entry, token, tokens = [];
  48498. for (i = 0; i < extra.tokens.length; ++i) {
  48499. entry = extra.tokens[i];
  48500. token = {
  48501. type: entry.type,
  48502. value: entry.value
  48503. };
  48504. if (entry.regex) {
  48505. token.regex = {
  48506. pattern: entry.regex.pattern,
  48507. flags: entry.regex.flags
  48508. };
  48509. }
  48510. if (extra.range) {
  48511. token.range = entry.range;
  48512. }
  48513. if (extra.loc) {
  48514. token.loc = entry.loc;
  48515. }
  48516. tokens.push(token);
  48517. }
  48518. extra.tokens = tokens;
  48519. }
  48520. function patch() {
  48521. if (extra.comments) {
  48522. extra.skipComment = skipComment;
  48523. skipComment = scanComment;
  48524. }
  48525. if (typeof extra.tokens !== 'undefined') {
  48526. extra.advance = advance;
  48527. extra.scanRegExp = scanRegExp;
  48528. advance = collectToken;
  48529. scanRegExp = collectRegex;
  48530. }
  48531. }
  48532. function unpatch() {
  48533. if (typeof extra.skipComment === 'function') {
  48534. skipComment = extra.skipComment;
  48535. }
  48536. if (typeof extra.scanRegExp === 'function') {
  48537. advance = extra.advance;
  48538. scanRegExp = extra.scanRegExp;
  48539. }
  48540. }
  48541. // This is used to modify the delegate.
  48542. function extend(object, properties) {
  48543. var entry, result = {};
  48544. for (entry in object) {
  48545. if (object.hasOwnProperty(entry)) {
  48546. result[entry] = object[entry];
  48547. }
  48548. }
  48549. for (entry in properties) {
  48550. if (properties.hasOwnProperty(entry)) {
  48551. result[entry] = properties[entry];
  48552. }
  48553. }
  48554. return result;
  48555. }
  48556. function tokenize(code, options) {
  48557. var toString,
  48558. token,
  48559. tokens;
  48560. toString = String;
  48561. if (typeof code !== 'string' && !(code instanceof String)) {
  48562. code = toString(code);
  48563. }
  48564. delegate = SyntaxTreeDelegate;
  48565. source = code;
  48566. index = 0;
  48567. lineNumber = (source.length > 0) ? 1 : 0;
  48568. lineStart = 0;
  48569. length = source.length;
  48570. lookahead = null;
  48571. state = {
  48572. allowKeyword: true,
  48573. allowIn: true,
  48574. labelSet: {},
  48575. inFunctionBody: false,
  48576. inIteration: false,
  48577. inSwitch: false,
  48578. lastCommentStart: -1
  48579. };
  48580. extra = {};
  48581. // Options matching.
  48582. options = options || {};
  48583. // Of course we collect tokens here.
  48584. options.tokens = true;
  48585. extra.tokens = [];
  48586. extra.tokenize = true;
  48587. // The following two fields are necessary to compute the Regex tokens.
  48588. extra.openParenToken = -1;
  48589. extra.openCurlyToken = -1;
  48590. extra.range = (typeof options.range === 'boolean') && options.range;
  48591. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  48592. if (typeof options.comment === 'boolean' && options.comment) {
  48593. extra.comments = [];
  48594. }
  48595. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  48596. extra.errors = [];
  48597. }
  48598. if (length > 0) {
  48599. if (typeof source[0] === 'undefined') {
  48600. // Try first to convert to a string. This is good as fast path
  48601. // for old IE which understands string indexing for string
  48602. // literals only and not for string object.
  48603. if (code instanceof String) {
  48604. source = code.valueOf();
  48605. }
  48606. }
  48607. }
  48608. patch();
  48609. try {
  48610. peek();
  48611. if (lookahead.type === Token.EOF) {
  48612. return extra.tokens;
  48613. }
  48614. token = lex();
  48615. while (lookahead.type !== Token.EOF) {
  48616. try {
  48617. token = lex();
  48618. } catch (lexError) {
  48619. token = lookahead;
  48620. if (extra.errors) {
  48621. extra.errors.push(lexError);
  48622. // We have to break on the first error
  48623. // to avoid infinite loops.
  48624. break;
  48625. } else {
  48626. throw lexError;
  48627. }
  48628. }
  48629. }
  48630. filterTokenLocation();
  48631. tokens = extra.tokens;
  48632. if (typeof extra.comments !== 'undefined') {
  48633. tokens.comments = extra.comments;
  48634. }
  48635. if (typeof extra.errors !== 'undefined') {
  48636. tokens.errors = extra.errors;
  48637. }
  48638. } catch (e) {
  48639. throw e;
  48640. } finally {
  48641. unpatch();
  48642. extra = {};
  48643. }
  48644. return tokens;
  48645. }
  48646. function parse(code, options) {
  48647. var program, toString;
  48648. toString = String;
  48649. if (typeof code !== 'string' && !(code instanceof String)) {
  48650. code = toString(code);
  48651. }
  48652. delegate = SyntaxTreeDelegate;
  48653. source = code;
  48654. index = 0;
  48655. lineNumber = (source.length > 0) ? 1 : 0;
  48656. lineStart = 0;
  48657. length = source.length;
  48658. lookahead = null;
  48659. state = {
  48660. allowKeyword: false,
  48661. allowIn: true,
  48662. labelSet: {},
  48663. parenthesizedCount: 0,
  48664. inFunctionBody: false,
  48665. inIteration: false,
  48666. inSwitch: false,
  48667. inXJSChild: false,
  48668. inXJSTag: false,
  48669. inType: false,
  48670. lastCommentStart: -1,
  48671. yieldAllowed: false,
  48672. awaitAllowed: false
  48673. };
  48674. extra = {};
  48675. if (typeof options !== 'undefined') {
  48676. extra.range = (typeof options.range === 'boolean') && options.range;
  48677. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  48678. extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
  48679. if (extra.loc && options.source !== null && options.source !== undefined) {
  48680. delegate = extend(delegate, {
  48681. 'postProcess': function (node) {
  48682. node.loc.source = toString(options.source);
  48683. return node;
  48684. }
  48685. });
  48686. }
  48687. if (typeof options.tokens === 'boolean' && options.tokens) {
  48688. extra.tokens = [];
  48689. }
  48690. if (typeof options.comment === 'boolean' && options.comment) {
  48691. extra.comments = [];
  48692. }
  48693. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  48694. extra.errors = [];
  48695. }
  48696. if (extra.attachComment) {
  48697. extra.range = true;
  48698. extra.comments = [];
  48699. extra.bottomRightStack = [];
  48700. extra.trailingComments = [];
  48701. extra.leadingComments = [];
  48702. }
  48703. }
  48704. if (length > 0) {
  48705. if (typeof source[0] === 'undefined') {
  48706. // Try first to convert to a string. This is good as fast path
  48707. // for old IE which understands string indexing for string
  48708. // literals only and not for string object.
  48709. if (code instanceof String) {
  48710. source = code.valueOf();
  48711. }
  48712. }
  48713. }
  48714. patch();
  48715. try {
  48716. program = parseProgram();
  48717. if (typeof extra.comments !== 'undefined') {
  48718. program.comments = extra.comments;
  48719. }
  48720. if (typeof extra.tokens !== 'undefined') {
  48721. filterTokenLocation();
  48722. program.tokens = extra.tokens;
  48723. }
  48724. if (typeof extra.errors !== 'undefined') {
  48725. program.errors = extra.errors;
  48726. }
  48727. } catch (e) {
  48728. throw e;
  48729. } finally {
  48730. unpatch();
  48731. extra = {};
  48732. }
  48733. return program;
  48734. }
  48735. // Sync with *.json manifests.
  48736. exports.version = '8001.1001.0-dev-harmony-fb';
  48737. exports.tokenize = tokenize;
  48738. exports.parse = parse;
  48739. // Deep copy.
  48740. exports.Syntax = (function () {
  48741. var name, types = {};
  48742. if (typeof Object.create === 'function') {
  48743. types = Object.create(null);
  48744. }
  48745. for (name in Syntax) {
  48746. if (Syntax.hasOwnProperty(name)) {
  48747. types[name] = Syntax[name];
  48748. }
  48749. }
  48750. if (typeof Object.freeze === 'function') {
  48751. Object.freeze(types);
  48752. }
  48753. return types;
  48754. }());
  48755. }));
  48756. /* vim: set sw=4 ts=4 et tw=80 : */
  48757. },{}],454:[function(require,module,exports){
  48758. // simple-fmt.js
  48759. // MIT licensed, see LICENSE file
  48760. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  48761. var fmt = (function() {
  48762. "use strict";
  48763. function fmt(str, var_args) {
  48764. var args = Array.prototype.slice.call(arguments, 1);
  48765. return str.replace(/\{(\d+)\}/g, function(s, match) {
  48766. return (match in args ? args[match] : s);
  48767. });
  48768. }
  48769. function obj(str, obj) {
  48770. return str.replace(/\{([_$a-zA-Z0-9][_$a-zA-Z0-9]*)\}/g, function(s, match) {
  48771. return (match in obj ? obj[match] : s);
  48772. });
  48773. }
  48774. function repeat(str, n) {
  48775. return (new Array(n + 1)).join(str);
  48776. }
  48777. fmt.fmt = fmt;
  48778. fmt.obj = obj;
  48779. fmt.repeat = repeat;
  48780. return fmt;
  48781. })();
  48782. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  48783. module.exports = fmt;
  48784. }
  48785. },{}],455:[function(require,module,exports){
  48786. // simple-is.js
  48787. // MIT licensed, see LICENSE file
  48788. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  48789. var is = (function() {
  48790. "use strict";
  48791. var hasOwnProperty = Object.prototype.hasOwnProperty;
  48792. var toString = Object.prototype.toString;
  48793. var _undefined = void 0;
  48794. return {
  48795. nan: function(v) {
  48796. return v !== v;
  48797. },
  48798. boolean: function(v) {
  48799. return typeof v === "boolean";
  48800. },
  48801. number: function(v) {
  48802. return typeof v === "number";
  48803. },
  48804. string: function(v) {
  48805. return typeof v === "string";
  48806. },
  48807. fn: function(v) {
  48808. return typeof v === "function";
  48809. },
  48810. object: function(v) {
  48811. return v !== null && typeof v === "object";
  48812. },
  48813. primitive: function(v) {
  48814. var t = typeof v;
  48815. return v === null || v === _undefined ||
  48816. t === "boolean" || t === "number" || t === "string";
  48817. },
  48818. array: Array.isArray || function(v) {
  48819. return toString.call(v) === "[object Array]";
  48820. },
  48821. finitenumber: function(v) {
  48822. return typeof v === "number" && isFinite(v);
  48823. },
  48824. someof: function(v, values) {
  48825. return values.indexOf(v) >= 0;
  48826. },
  48827. noneof: function(v, values) {
  48828. return values.indexOf(v) === -1;
  48829. },
  48830. own: function(obj, prop) {
  48831. return hasOwnProperty.call(obj, prop);
  48832. },
  48833. };
  48834. })();
  48835. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  48836. module.exports = is;
  48837. }
  48838. },{}],456:[function(require,module,exports){
  48839. // stringmap.js
  48840. // MIT licensed, see LICENSE file
  48841. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  48842. var StringMap = (function() {
  48843. "use strict";
  48844. // to save us a few characters
  48845. var hasOwnProperty = Object.prototype.hasOwnProperty;
  48846. var create = (function() {
  48847. function hasOwnEnumerableProps(obj) {
  48848. for (var prop in obj) {
  48849. if (hasOwnProperty.call(obj, prop)) {
  48850. return true;
  48851. }
  48852. }
  48853. return false;
  48854. }
  48855. // FF <= 3.6:
  48856. // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true
  48857. // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false
  48858. function hasOwnPollutedProps(obj) {
  48859. return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__");
  48860. }
  48861. var useObjectCreate = false;
  48862. if (typeof Object.create === "function") {
  48863. if (!hasOwnEnumerableProps(Object.create(null))) {
  48864. useObjectCreate = true;
  48865. }
  48866. }
  48867. if (useObjectCreate === false) {
  48868. if (hasOwnEnumerableProps({})) {
  48869. throw new Error("StringMap environment error 0, please file a bug at https://github.com/olov/stringmap/issues");
  48870. }
  48871. }
  48872. // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims)
  48873. var o = (useObjectCreate ? Object.create(null) : {});
  48874. var useProtoClear = false;
  48875. if (hasOwnPollutedProps(o)) {
  48876. o.__proto__ = null;
  48877. if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) {
  48878. throw new Error("StringMap environment error 1, please file a bug at https://github.com/olov/stringmap/issues");
  48879. }
  48880. useProtoClear = true;
  48881. }
  48882. // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims)
  48883. return function() {
  48884. var o = (useObjectCreate ? Object.create(null) : {});
  48885. if (useProtoClear) {
  48886. o.__proto__ = null;
  48887. }
  48888. return o;
  48889. };
  48890. })();
  48891. // stringmap ctor
  48892. function stringmap(optional_object) {
  48893. // use with or without new
  48894. if (!(this instanceof stringmap)) {
  48895. return new stringmap(optional_object);
  48896. }
  48897. this.obj = create();
  48898. this.hasProto = false; // false (no __proto__ key) or true (has __proto__ key)
  48899. this.proto = undefined; // value for __proto__ key when hasProto is true, undefined otherwise
  48900. if (optional_object) {
  48901. this.setMany(optional_object);
  48902. }
  48903. };
  48904. // primitive methods that deals with data representation
  48905. stringmap.prototype.has = function(key) {
  48906. // The type-check of key in has, get, set and delete is important because otherwise an object
  48907. // {toString: function() { return "__proto__"; }} can avoid the key === "__proto__" test.
  48908. // The alternative to type-checking would be to force string conversion, i.e. key = String(key);
  48909. if (typeof key !== "string") {
  48910. throw new Error("StringMap expected string key");
  48911. }
  48912. return (key === "__proto__" ?
  48913. this.hasProto :
  48914. hasOwnProperty.call(this.obj, key));
  48915. };
  48916. stringmap.prototype.get = function(key) {
  48917. if (typeof key !== "string") {
  48918. throw new Error("StringMap expected string key");
  48919. }
  48920. return (key === "__proto__" ?
  48921. this.proto :
  48922. (hasOwnProperty.call(this.obj, key) ? this.obj[key] : undefined));
  48923. };
  48924. stringmap.prototype.set = function(key, value) {
  48925. if (typeof key !== "string") {
  48926. throw new Error("StringMap expected string key");
  48927. }
  48928. if (key === "__proto__") {
  48929. this.hasProto = true;
  48930. this.proto = value;
  48931. } else {
  48932. this.obj[key] = value;
  48933. }
  48934. };
  48935. stringmap.prototype.remove = function(key) {
  48936. if (typeof key !== "string") {
  48937. throw new Error("StringMap expected string key");
  48938. }
  48939. var didExist = this.has(key);
  48940. if (key === "__proto__") {
  48941. this.hasProto = false;
  48942. this.proto = undefined;
  48943. } else {
  48944. delete this.obj[key];
  48945. }
  48946. return didExist;
  48947. };
  48948. // alias remove to delete but beware:
  48949. // sm.delete("key"); // OK in ES5 and later
  48950. // sm['delete']("key"); // OK in all ES versions
  48951. // sm.remove("key"); // OK in all ES versions
  48952. stringmap.prototype['delete'] = stringmap.prototype.remove;
  48953. stringmap.prototype.isEmpty = function() {
  48954. for (var key in this.obj) {
  48955. if (hasOwnProperty.call(this.obj, key)) {
  48956. return false;
  48957. }
  48958. }
  48959. return !this.hasProto;
  48960. };
  48961. stringmap.prototype.size = function() {
  48962. var len = 0;
  48963. for (var key in this.obj) {
  48964. if (hasOwnProperty.call(this.obj, key)) {
  48965. ++len;
  48966. }
  48967. }
  48968. return (this.hasProto ? len + 1 : len);
  48969. };
  48970. stringmap.prototype.keys = function() {
  48971. var keys = [];
  48972. for (var key in this.obj) {
  48973. if (hasOwnProperty.call(this.obj, key)) {
  48974. keys.push(key);
  48975. }
  48976. }
  48977. if (this.hasProto) {
  48978. keys.push("__proto__");
  48979. }
  48980. return keys;
  48981. };
  48982. stringmap.prototype.values = function() {
  48983. var values = [];
  48984. for (var key in this.obj) {
  48985. if (hasOwnProperty.call(this.obj, key)) {
  48986. values.push(this.obj[key]);
  48987. }
  48988. }
  48989. if (this.hasProto) {
  48990. values.push(this.proto);
  48991. }
  48992. return values;
  48993. };
  48994. stringmap.prototype.items = function() {
  48995. var items = [];
  48996. for (var key in this.obj) {
  48997. if (hasOwnProperty.call(this.obj, key)) {
  48998. items.push([key, this.obj[key]]);
  48999. }
  49000. }
  49001. if (this.hasProto) {
  49002. items.push(["__proto__", this.proto]);
  49003. }
  49004. return items;
  49005. };
  49006. // methods that rely on the above primitives
  49007. stringmap.prototype.setMany = function(object) {
  49008. if (object === null || (typeof object !== "object" && typeof object !== "function")) {
  49009. throw new Error("StringMap expected Object");
  49010. }
  49011. for (var key in object) {
  49012. if (hasOwnProperty.call(object, key)) {
  49013. this.set(key, object[key]);
  49014. }
  49015. }
  49016. return this;
  49017. };
  49018. stringmap.prototype.merge = function(other) {
  49019. var keys = other.keys();
  49020. for (var i = 0; i < keys.length; i++) {
  49021. var key = keys[i];
  49022. this.set(key, other.get(key));
  49023. }
  49024. return this;
  49025. };
  49026. stringmap.prototype.map = function(fn) {
  49027. var keys = this.keys();
  49028. for (var i = 0; i < keys.length; i++) {
  49029. var key = keys[i];
  49030. keys[i] = fn(this.get(key), key); // re-use keys array for results
  49031. }
  49032. return keys;
  49033. };
  49034. stringmap.prototype.forEach = function(fn) {
  49035. var keys = this.keys();
  49036. for (var i = 0; i < keys.length; i++) {
  49037. var key = keys[i];
  49038. fn(this.get(key), key);
  49039. }
  49040. };
  49041. stringmap.prototype.clone = function() {
  49042. var other = stringmap();
  49043. return other.merge(this);
  49044. };
  49045. stringmap.prototype.toString = function() {
  49046. var self = this;
  49047. return "{" + this.keys().map(function(key) {
  49048. return JSON.stringify(key) + ":" + JSON.stringify(self.get(key));
  49049. }).join(",") + "}";
  49050. };
  49051. return stringmap;
  49052. })();
  49053. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  49054. module.exports = StringMap;
  49055. }
  49056. },{}],457:[function(require,module,exports){
  49057. // stringset.js
  49058. // MIT licensed, see LICENSE file
  49059. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  49060. var StringSet = (function() {
  49061. "use strict";
  49062. // to save us a few characters
  49063. var hasOwnProperty = Object.prototype.hasOwnProperty;
  49064. var create = (function() {
  49065. function hasOwnEnumerableProps(obj) {
  49066. for (var prop in obj) {
  49067. if (hasOwnProperty.call(obj, prop)) {
  49068. return true;
  49069. }
  49070. }
  49071. return false;
  49072. }
  49073. // FF <= 3.6:
  49074. // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true
  49075. // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false
  49076. function hasOwnPollutedProps(obj) {
  49077. return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__");
  49078. }
  49079. var useObjectCreate = false;
  49080. if (typeof Object.create === "function") {
  49081. if (!hasOwnEnumerableProps(Object.create(null))) {
  49082. useObjectCreate = true;
  49083. }
  49084. }
  49085. if (useObjectCreate === false) {
  49086. if (hasOwnEnumerableProps({})) {
  49087. throw new Error("StringSet environment error 0, please file a bug at https://github.com/olov/stringset/issues");
  49088. }
  49089. }
  49090. // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims)
  49091. var o = (useObjectCreate ? Object.create(null) : {});
  49092. var useProtoClear = false;
  49093. if (hasOwnPollutedProps(o)) {
  49094. o.__proto__ = null;
  49095. if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) {
  49096. throw new Error("StringSet environment error 1, please file a bug at https://github.com/olov/stringset/issues");
  49097. }
  49098. useProtoClear = true;
  49099. }
  49100. // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims)
  49101. return function() {
  49102. var o = (useObjectCreate ? Object.create(null) : {});
  49103. if (useProtoClear) {
  49104. o.__proto__ = null;
  49105. }
  49106. return o;
  49107. };
  49108. })();
  49109. // stringset ctor
  49110. function stringset(optional_array) {
  49111. // use with or without new
  49112. if (!(this instanceof stringset)) {
  49113. return new stringset(optional_array);
  49114. }
  49115. this.obj = create();
  49116. this.hasProto = false; // false (no __proto__ item) or true (has __proto__ item)
  49117. if (optional_array) {
  49118. this.addMany(optional_array);
  49119. }
  49120. };
  49121. // primitive methods that deals with data representation
  49122. stringset.prototype.has = function(item) {
  49123. // The type-check of item in has, get, set and delete is important because otherwise an object
  49124. // {toString: function() { return "__proto__"; }} can avoid the item === "__proto__" test.
  49125. // The alternative to type-checking would be to force string conversion, i.e. item = String(item);
  49126. if (typeof item !== "string") {
  49127. throw new Error("StringSet expected string item");
  49128. }
  49129. return (item === "__proto__" ?
  49130. this.hasProto :
  49131. hasOwnProperty.call(this.obj, item));
  49132. };
  49133. stringset.prototype.add = function(item) {
  49134. if (typeof item !== "string") {
  49135. throw new Error("StringSet expected string item");
  49136. }
  49137. if (item === "__proto__") {
  49138. this.hasProto = true;
  49139. } else {
  49140. this.obj[item] = true;
  49141. }
  49142. };
  49143. stringset.prototype.remove = function(item) {
  49144. if (typeof item !== "string") {
  49145. throw new Error("StringSet expected string item");
  49146. }
  49147. var didExist = this.has(item);
  49148. if (item === "__proto__") {
  49149. this.hasProto = false;
  49150. } else {
  49151. delete this.obj[item];
  49152. }
  49153. return didExist;
  49154. };
  49155. // alias remove to delete but beware:
  49156. // ss.delete("key"); // OK in ES5 and later
  49157. // ss['delete']("key"); // OK in all ES versions
  49158. // ss.remove("key"); // OK in all ES versions
  49159. stringset.prototype['delete'] = stringset.prototype.remove;
  49160. stringset.prototype.isEmpty = function() {
  49161. for (var item in this.obj) {
  49162. if (hasOwnProperty.call(this.obj, item)) {
  49163. return false;
  49164. }
  49165. }
  49166. return !this.hasProto;
  49167. };
  49168. stringset.prototype.size = function() {
  49169. var len = 0;
  49170. for (var item in this.obj) {
  49171. if (hasOwnProperty.call(this.obj, item)) {
  49172. ++len;
  49173. }
  49174. }
  49175. return (this.hasProto ? len + 1 : len);
  49176. };
  49177. stringset.prototype.items = function() {
  49178. var items = [];
  49179. for (var item in this.obj) {
  49180. if (hasOwnProperty.call(this.obj, item)) {
  49181. items.push(item);
  49182. }
  49183. }
  49184. if (this.hasProto) {
  49185. items.push("__proto__");
  49186. }
  49187. return items;
  49188. };
  49189. // methods that rely on the above primitives
  49190. stringset.prototype.addMany = function(items) {
  49191. if (!Array.isArray(items)) {
  49192. throw new Error("StringSet expected array");
  49193. }
  49194. for (var i = 0; i < items.length; i++) {
  49195. this.add(items[i]);
  49196. }
  49197. return this;
  49198. };
  49199. stringset.prototype.merge = function(other) {
  49200. this.addMany(other.items());
  49201. return this;
  49202. };
  49203. stringset.prototype.clone = function() {
  49204. var other = stringset();
  49205. return other.merge(this);
  49206. };
  49207. stringset.prototype.toString = function() {
  49208. return "{" + this.items().map(JSON.stringify).join(",") + "}";
  49209. };
  49210. return stringset;
  49211. })();
  49212. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  49213. module.exports = StringSet;
  49214. }
  49215. },{}],458:[function(require,module,exports){
  49216. /*
  49217. Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
  49218. Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
  49219. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  49220. Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
  49221. Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
  49222. Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
  49223. Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
  49224. Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
  49225. Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
  49226. Redistribution and use in source and binary forms, with or without
  49227. modification, are permitted provided that the following conditions are met:
  49228. * Redistributions of source code must retain the above copyright
  49229. notice, this list of conditions and the following disclaimer.
  49230. * Redistributions in binary form must reproduce the above copyright
  49231. notice, this list of conditions and the following disclaimer in the
  49232. documentation and/or other materials provided with the distribution.
  49233. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  49234. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49235. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  49236. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  49237. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  49238. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  49239. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  49240. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  49241. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  49242. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49243. */
  49244. (function (root, factory) {
  49245. 'use strict';
  49246. // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
  49247. // Rhino, and plain browser loading.
  49248. /* istanbul ignore next */
  49249. if (typeof define === 'function' && define.amd) {
  49250. define(['exports'], factory);
  49251. } else if (typeof exports !== 'undefined') {
  49252. factory(exports);
  49253. } else {
  49254. factory((root.esprima = {}));
  49255. }
  49256. }(this, function (exports) {
  49257. 'use strict';
  49258. var Token,
  49259. TokenName,
  49260. FnExprTokens,
  49261. Syntax,
  49262. PropertyKind,
  49263. Messages,
  49264. Regex,
  49265. SyntaxTreeDelegate,
  49266. XHTMLEntities,
  49267. ClassPropertyType,
  49268. source,
  49269. strict,
  49270. index,
  49271. lineNumber,
  49272. lineStart,
  49273. length,
  49274. delegate,
  49275. lookahead,
  49276. state,
  49277. extra;
  49278. Token = {
  49279. BooleanLiteral: 1,
  49280. EOF: 2,
  49281. Identifier: 3,
  49282. Keyword: 4,
  49283. NullLiteral: 5,
  49284. NumericLiteral: 6,
  49285. Punctuator: 7,
  49286. StringLiteral: 8,
  49287. RegularExpression: 9,
  49288. Template: 10,
  49289. JSXIdentifier: 11,
  49290. JSXText: 12
  49291. };
  49292. TokenName = {};
  49293. TokenName[Token.BooleanLiteral] = 'Boolean';
  49294. TokenName[Token.EOF] = '<end>';
  49295. TokenName[Token.Identifier] = 'Identifier';
  49296. TokenName[Token.Keyword] = 'Keyword';
  49297. TokenName[Token.NullLiteral] = 'Null';
  49298. TokenName[Token.NumericLiteral] = 'Numeric';
  49299. TokenName[Token.Punctuator] = 'Punctuator';
  49300. TokenName[Token.StringLiteral] = 'String';
  49301. TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
  49302. TokenName[Token.JSXText] = 'JSXText';
  49303. TokenName[Token.RegularExpression] = 'RegularExpression';
  49304. // A function following one of those tokens is an expression.
  49305. FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
  49306. 'return', 'case', 'delete', 'throw', 'void',
  49307. // assignment operators
  49308. '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
  49309. '&=', '|=', '^=', ',',
  49310. // binary/unary operators
  49311. '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
  49312. '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
  49313. '<=', '<', '>', '!=', '!=='];
  49314. Syntax = {
  49315. AnyTypeAnnotation: 'AnyTypeAnnotation',
  49316. ArrayExpression: 'ArrayExpression',
  49317. ArrayPattern: 'ArrayPattern',
  49318. ArrayTypeAnnotation: 'ArrayTypeAnnotation',
  49319. ArrowFunctionExpression: 'ArrowFunctionExpression',
  49320. AssignmentExpression: 'AssignmentExpression',
  49321. BinaryExpression: 'BinaryExpression',
  49322. BlockStatement: 'BlockStatement',
  49323. BooleanTypeAnnotation: 'BooleanTypeAnnotation',
  49324. BreakStatement: 'BreakStatement',
  49325. CallExpression: 'CallExpression',
  49326. CatchClause: 'CatchClause',
  49327. ClassBody: 'ClassBody',
  49328. ClassDeclaration: 'ClassDeclaration',
  49329. ClassExpression: 'ClassExpression',
  49330. ClassImplements: 'ClassImplements',
  49331. ClassProperty: 'ClassProperty',
  49332. ComprehensionBlock: 'ComprehensionBlock',
  49333. ComprehensionExpression: 'ComprehensionExpression',
  49334. ConditionalExpression: 'ConditionalExpression',
  49335. ContinueStatement: 'ContinueStatement',
  49336. DebuggerStatement: 'DebuggerStatement',
  49337. DeclareClass: 'DeclareClass',
  49338. DeclareFunction: 'DeclareFunction',
  49339. DeclareModule: 'DeclareModule',
  49340. DeclareVariable: 'DeclareVariable',
  49341. DoWhileStatement: 'DoWhileStatement',
  49342. EmptyStatement: 'EmptyStatement',
  49343. ExportDeclaration: 'ExportDeclaration',
  49344. ExportBatchSpecifier: 'ExportBatchSpecifier',
  49345. ExportSpecifier: 'ExportSpecifier',
  49346. ExpressionStatement: 'ExpressionStatement',
  49347. ForInStatement: 'ForInStatement',
  49348. ForOfStatement: 'ForOfStatement',
  49349. ForStatement: 'ForStatement',
  49350. FunctionDeclaration: 'FunctionDeclaration',
  49351. FunctionExpression: 'FunctionExpression',
  49352. FunctionTypeAnnotation: 'FunctionTypeAnnotation',
  49353. FunctionTypeParam: 'FunctionTypeParam',
  49354. GenericTypeAnnotation: 'GenericTypeAnnotation',
  49355. Identifier: 'Identifier',
  49356. IfStatement: 'IfStatement',
  49357. ImportDeclaration: 'ImportDeclaration',
  49358. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  49359. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  49360. ImportSpecifier: 'ImportSpecifier',
  49361. InterfaceDeclaration: 'InterfaceDeclaration',
  49362. InterfaceExtends: 'InterfaceExtends',
  49363. IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
  49364. LabeledStatement: 'LabeledStatement',
  49365. Literal: 'Literal',
  49366. LogicalExpression: 'LogicalExpression',
  49367. MemberExpression: 'MemberExpression',
  49368. MethodDefinition: 'MethodDefinition',
  49369. ModuleSpecifier: 'ModuleSpecifier',
  49370. NewExpression: 'NewExpression',
  49371. NullableTypeAnnotation: 'NullableTypeAnnotation',
  49372. NumberTypeAnnotation: 'NumberTypeAnnotation',
  49373. ObjectExpression: 'ObjectExpression',
  49374. ObjectPattern: 'ObjectPattern',
  49375. ObjectTypeAnnotation: 'ObjectTypeAnnotation',
  49376. ObjectTypeCallProperty: 'ObjectTypeCallProperty',
  49377. ObjectTypeIndexer: 'ObjectTypeIndexer',
  49378. ObjectTypeProperty: 'ObjectTypeProperty',
  49379. Program: 'Program',
  49380. Property: 'Property',
  49381. QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
  49382. ReturnStatement: 'ReturnStatement',
  49383. SequenceExpression: 'SequenceExpression',
  49384. SpreadElement: 'SpreadElement',
  49385. SpreadProperty: 'SpreadProperty',
  49386. StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
  49387. StringTypeAnnotation: 'StringTypeAnnotation',
  49388. SwitchCase: 'SwitchCase',
  49389. SwitchStatement: 'SwitchStatement',
  49390. TaggedTemplateExpression: 'TaggedTemplateExpression',
  49391. TemplateElement: 'TemplateElement',
  49392. TemplateLiteral: 'TemplateLiteral',
  49393. ThisExpression: 'ThisExpression',
  49394. ThrowStatement: 'ThrowStatement',
  49395. TupleTypeAnnotation: 'TupleTypeAnnotation',
  49396. TryStatement: 'TryStatement',
  49397. TypeAlias: 'TypeAlias',
  49398. TypeAnnotation: 'TypeAnnotation',
  49399. TypeCastExpression: 'TypeCastExpression',
  49400. TypeofTypeAnnotation: 'TypeofTypeAnnotation',
  49401. TypeParameterDeclaration: 'TypeParameterDeclaration',
  49402. TypeParameterInstantiation: 'TypeParameterInstantiation',
  49403. UnaryExpression: 'UnaryExpression',
  49404. UnionTypeAnnotation: 'UnionTypeAnnotation',
  49405. UpdateExpression: 'UpdateExpression',
  49406. VariableDeclaration: 'VariableDeclaration',
  49407. VariableDeclarator: 'VariableDeclarator',
  49408. VoidTypeAnnotation: 'VoidTypeAnnotation',
  49409. WhileStatement: 'WhileStatement',
  49410. WithStatement: 'WithStatement',
  49411. JSXIdentifier: 'JSXIdentifier',
  49412. JSXNamespacedName: 'JSXNamespacedName',
  49413. JSXMemberExpression: 'JSXMemberExpression',
  49414. JSXEmptyExpression: 'JSXEmptyExpression',
  49415. JSXExpressionContainer: 'JSXExpressionContainer',
  49416. JSXElement: 'JSXElement',
  49417. JSXClosingElement: 'JSXClosingElement',
  49418. JSXOpeningElement: 'JSXOpeningElement',
  49419. JSXAttribute: 'JSXAttribute',
  49420. JSXSpreadAttribute: 'JSXSpreadAttribute',
  49421. JSXText: 'JSXText',
  49422. YieldExpression: 'YieldExpression',
  49423. AwaitExpression: 'AwaitExpression'
  49424. };
  49425. PropertyKind = {
  49426. Data: 1,
  49427. Get: 2,
  49428. Set: 4
  49429. };
  49430. ClassPropertyType = {
  49431. 'static': 'static',
  49432. prototype: 'prototype'
  49433. };
  49434. // Error messages should be identical to V8.
  49435. Messages = {
  49436. UnexpectedToken: 'Unexpected token %0',
  49437. UnexpectedNumber: 'Unexpected number',
  49438. UnexpectedString: 'Unexpected string',
  49439. UnexpectedIdentifier: 'Unexpected identifier',
  49440. UnexpectedReserved: 'Unexpected reserved word',
  49441. UnexpectedTemplate: 'Unexpected quasi %0',
  49442. UnexpectedEOS: 'Unexpected end of input',
  49443. NewlineAfterThrow: 'Illegal newline after throw',
  49444. InvalidRegExp: 'Invalid regular expression',
  49445. UnterminatedRegExp: 'Invalid regular expression: missing /',
  49446. InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
  49447. InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
  49448. InvalidLHSInForIn: 'Invalid left-hand side in for-in',
  49449. MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
  49450. NoCatchOrFinally: 'Missing catch or finally after try',
  49451. UnknownLabel: 'Undefined label \'%0\'',
  49452. Redeclaration: '%0 \'%1\' has already been declared',
  49453. IllegalContinue: 'Illegal continue statement',
  49454. IllegalBreak: 'Illegal break statement',
  49455. IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
  49456. IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
  49457. IllegalReturn: 'Illegal return statement',
  49458. IllegalSpread: 'Illegal spread element',
  49459. StrictModeWith: 'Strict mode code may not include a with statement',
  49460. StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
  49461. StrictVarName: 'Variable name may not be eval or arguments in strict mode',
  49462. StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
  49463. StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
  49464. ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
  49465. DefaultRestParameter: 'Rest parameter can not have a default value',
  49466. ElementAfterSpreadElement: 'Spread must be the final element of an element list',
  49467. PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
  49468. ObjectPatternAsRestParameter: 'Invalid rest parameter',
  49469. ObjectPatternAsSpread: 'Invalid spread argument',
  49470. StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
  49471. StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
  49472. StrictDelete: 'Delete of an unqualified identifier in strict mode.',
  49473. StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
  49474. AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
  49475. AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
  49476. StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
  49477. StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
  49478. StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
  49479. StrictReservedWord: 'Use of future reserved word in strict mode',
  49480. MissingFromClause: 'Missing from clause',
  49481. NoAsAfterImportNamespace: 'Missing as after import *',
  49482. InvalidModuleSpecifier: 'Invalid module specifier',
  49483. IllegalImportDeclaration: 'Illegal import declaration',
  49484. IllegalExportDeclaration: 'Illegal export declaration',
  49485. NoUninitializedConst: 'Const must be initialized',
  49486. ComprehensionRequiresBlock: 'Comprehension must have at least one block',
  49487. ComprehensionError: 'Comprehension Error',
  49488. EachNotAllowed: 'Each is not supported',
  49489. InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
  49490. ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
  49491. AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
  49492. ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
  49493. 'you are trying to write a function type, but you ended up ' +
  49494. 'writing a grouped type followed by an =>, which is a syntax ' +
  49495. 'error. Remember, function type parameters are named so function ' +
  49496. 'types look like (name1: type1, name2: type2) => returnType. You ' +
  49497. 'probably wrote (type1) => returnType'
  49498. };
  49499. // See also tools/generate-unicode-regex.py.
  49500. Regex = {
  49501. NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\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\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\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\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-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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]'),
  49502. NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\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\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\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\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\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\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\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\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-\u191c\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\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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-\ufe26\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]'),
  49503. LeadingZeros: new RegExp('^0+(?!$)')
  49504. };
  49505. // Ensure the condition is true, otherwise throw an error.
  49506. // This is only to have a better contract semantic, i.e. another safety net
  49507. // to catch a logic error. The condition shall be fulfilled in normal case.
  49508. // Do NOT use this to enforce a certain condition on any user input.
  49509. function assert(condition, message) {
  49510. /* istanbul ignore if */
  49511. if (!condition) {
  49512. throw new Error('ASSERT: ' + message);
  49513. }
  49514. }
  49515. function StringMap() {
  49516. this.$data = {};
  49517. }
  49518. StringMap.prototype.get = function (key) {
  49519. key = '$' + key;
  49520. return this.$data[key];
  49521. };
  49522. StringMap.prototype.set = function (key, value) {
  49523. key = '$' + key;
  49524. this.$data[key] = value;
  49525. return this;
  49526. };
  49527. StringMap.prototype.has = function (key) {
  49528. key = '$' + key;
  49529. return Object.prototype.hasOwnProperty.call(this.$data, key);
  49530. };
  49531. StringMap.prototype.delete = function (key) {
  49532. key = '$' + key;
  49533. return delete this.$data[key];
  49534. };
  49535. function isDecimalDigit(ch) {
  49536. return (ch >= 48 && ch <= 57); // 0..9
  49537. }
  49538. function isHexDigit(ch) {
  49539. return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
  49540. }
  49541. function isOctalDigit(ch) {
  49542. return '01234567'.indexOf(ch) >= 0;
  49543. }
  49544. // 7.2 White Space
  49545. function isWhiteSpace(ch) {
  49546. return (ch === 32) || // space
  49547. (ch === 9) || // tab
  49548. (ch === 0xB) ||
  49549. (ch === 0xC) ||
  49550. (ch === 0xA0) ||
  49551. (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
  49552. }
  49553. // 7.3 Line Terminators
  49554. function isLineTerminator(ch) {
  49555. return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
  49556. }
  49557. // 7.6 Identifier Names and Identifiers
  49558. function isIdentifierStart(ch) {
  49559. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  49560. (ch >= 65 && ch <= 90) || // A..Z
  49561. (ch >= 97 && ch <= 122) || // a..z
  49562. (ch === 92) || // \ (backslash)
  49563. ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
  49564. }
  49565. function isIdentifierPart(ch) {
  49566. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  49567. (ch >= 65 && ch <= 90) || // A..Z
  49568. (ch >= 97 && ch <= 122) || // a..z
  49569. (ch >= 48 && ch <= 57) || // 0..9
  49570. (ch === 92) || // \ (backslash)
  49571. ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
  49572. }
  49573. // 7.6.1.2 Future Reserved Words
  49574. function isFutureReservedWord(id) {
  49575. switch (id) {
  49576. case 'class':
  49577. case 'enum':
  49578. case 'export':
  49579. case 'extends':
  49580. case 'import':
  49581. case 'super':
  49582. return true;
  49583. default:
  49584. return false;
  49585. }
  49586. }
  49587. function isStrictModeReservedWord(id) {
  49588. switch (id) {
  49589. case 'implements':
  49590. case 'interface':
  49591. case 'package':
  49592. case 'private':
  49593. case 'protected':
  49594. case 'public':
  49595. case 'static':
  49596. case 'yield':
  49597. case 'let':
  49598. return true;
  49599. default:
  49600. return false;
  49601. }
  49602. }
  49603. function isRestrictedWord(id) {
  49604. return id === 'eval' || id === 'arguments';
  49605. }
  49606. // 7.6.1.1 Keywords
  49607. function isKeyword(id) {
  49608. if (strict && isStrictModeReservedWord(id)) {
  49609. return true;
  49610. }
  49611. // 'const' is specialized as Keyword in V8.
  49612. // 'yield' is only treated as a keyword in strict mode.
  49613. // 'let' is for compatiblity with SpiderMonkey and ES.next.
  49614. // Some others are from future reserved words.
  49615. switch (id.length) {
  49616. case 2:
  49617. return (id === 'if') || (id === 'in') || (id === 'do');
  49618. case 3:
  49619. return (id === 'var') || (id === 'for') || (id === 'new') ||
  49620. (id === 'try') || (id === 'let');
  49621. case 4:
  49622. return (id === 'this') || (id === 'else') || (id === 'case') ||
  49623. (id === 'void') || (id === 'with') || (id === 'enum');
  49624. case 5:
  49625. return (id === 'while') || (id === 'break') || (id === 'catch') ||
  49626. (id === 'throw') || (id === 'const') ||
  49627. (id === 'class') || (id === 'super');
  49628. case 6:
  49629. return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
  49630. (id === 'switch') || (id === 'export') || (id === 'import');
  49631. case 7:
  49632. return (id === 'default') || (id === 'finally') || (id === 'extends');
  49633. case 8:
  49634. return (id === 'function') || (id === 'continue') || (id === 'debugger');
  49635. case 10:
  49636. return (id === 'instanceof');
  49637. default:
  49638. return false;
  49639. }
  49640. }
  49641. // 7.4 Comments
  49642. function addComment(type, value, start, end, loc) {
  49643. var comment;
  49644. assert(typeof start === 'number', 'Comment must have valid position');
  49645. // Because the way the actual token is scanned, often the comments
  49646. // (if any) are skipped twice during the lexical analysis.
  49647. // Thus, we need to skip adding a comment if the comment array already
  49648. // handled it.
  49649. if (state.lastCommentStart >= start) {
  49650. return;
  49651. }
  49652. state.lastCommentStart = start;
  49653. comment = {
  49654. type: type,
  49655. value: value
  49656. };
  49657. if (extra.range) {
  49658. comment.range = [start, end];
  49659. }
  49660. if (extra.loc) {
  49661. comment.loc = loc;
  49662. }
  49663. extra.comments.push(comment);
  49664. if (extra.attachComment) {
  49665. extra.leadingComments.push(comment);
  49666. extra.trailingComments.push(comment);
  49667. }
  49668. }
  49669. function skipSingleLineComment() {
  49670. var start, loc, ch, comment;
  49671. start = index - 2;
  49672. loc = {
  49673. start: {
  49674. line: lineNumber,
  49675. column: index - lineStart - 2
  49676. }
  49677. };
  49678. while (index < length) {
  49679. ch = source.charCodeAt(index);
  49680. ++index;
  49681. if (isLineTerminator(ch)) {
  49682. if (extra.comments) {
  49683. comment = source.slice(start + 2, index - 1);
  49684. loc.end = {
  49685. line: lineNumber,
  49686. column: index - lineStart - 1
  49687. };
  49688. addComment('Line', comment, start, index - 1, loc);
  49689. }
  49690. if (ch === 13 && source.charCodeAt(index) === 10) {
  49691. ++index;
  49692. }
  49693. ++lineNumber;
  49694. lineStart = index;
  49695. return;
  49696. }
  49697. }
  49698. if (extra.comments) {
  49699. comment = source.slice(start + 2, index);
  49700. loc.end = {
  49701. line: lineNumber,
  49702. column: index - lineStart
  49703. };
  49704. addComment('Line', comment, start, index, loc);
  49705. }
  49706. }
  49707. function skipMultiLineComment() {
  49708. var start, loc, ch, comment;
  49709. if (extra.comments) {
  49710. start = index - 2;
  49711. loc = {
  49712. start: {
  49713. line: lineNumber,
  49714. column: index - lineStart - 2
  49715. }
  49716. };
  49717. }
  49718. while (index < length) {
  49719. ch = source.charCodeAt(index);
  49720. if (isLineTerminator(ch)) {
  49721. if (ch === 13 && source.charCodeAt(index + 1) === 10) {
  49722. ++index;
  49723. }
  49724. ++lineNumber;
  49725. ++index;
  49726. lineStart = index;
  49727. if (index >= length) {
  49728. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49729. }
  49730. } else if (ch === 42) {
  49731. // Block comment ends with '*/' (char #42, char #47).
  49732. if (source.charCodeAt(index + 1) === 47) {
  49733. ++index;
  49734. ++index;
  49735. if (extra.comments) {
  49736. comment = source.slice(start + 2, index - 2);
  49737. loc.end = {
  49738. line: lineNumber,
  49739. column: index - lineStart
  49740. };
  49741. addComment('Block', comment, start, index, loc);
  49742. }
  49743. return;
  49744. }
  49745. ++index;
  49746. } else {
  49747. ++index;
  49748. }
  49749. }
  49750. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49751. }
  49752. function skipComment() {
  49753. var ch;
  49754. while (index < length) {
  49755. ch = source.charCodeAt(index);
  49756. if (isWhiteSpace(ch)) {
  49757. ++index;
  49758. } else if (isLineTerminator(ch)) {
  49759. ++index;
  49760. if (ch === 13 && source.charCodeAt(index) === 10) {
  49761. ++index;
  49762. }
  49763. ++lineNumber;
  49764. lineStart = index;
  49765. } else if (ch === 47) { // 47 is '/'
  49766. ch = source.charCodeAt(index + 1);
  49767. if (ch === 47) {
  49768. ++index;
  49769. ++index;
  49770. skipSingleLineComment();
  49771. } else if (ch === 42) { // 42 is '*'
  49772. ++index;
  49773. ++index;
  49774. skipMultiLineComment();
  49775. } else {
  49776. break;
  49777. }
  49778. } else {
  49779. break;
  49780. }
  49781. }
  49782. }
  49783. function scanHexEscape(prefix) {
  49784. var i, len, ch, code = 0;
  49785. len = (prefix === 'u') ? 4 : 2;
  49786. for (i = 0; i < len; ++i) {
  49787. if (index < length && isHexDigit(source[index])) {
  49788. ch = source[index++];
  49789. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  49790. } else {
  49791. return '';
  49792. }
  49793. }
  49794. return String.fromCharCode(code);
  49795. }
  49796. function scanUnicodeCodePointEscape() {
  49797. var ch, code, cu1, cu2;
  49798. ch = source[index];
  49799. code = 0;
  49800. // At least, one hex digit is required.
  49801. if (ch === '}') {
  49802. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49803. }
  49804. while (index < length) {
  49805. ch = source[index++];
  49806. if (!isHexDigit(ch)) {
  49807. break;
  49808. }
  49809. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  49810. }
  49811. if (code > 0x10FFFF || ch !== '}') {
  49812. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49813. }
  49814. // UTF-16 Encoding
  49815. if (code <= 0xFFFF) {
  49816. return String.fromCharCode(code);
  49817. }
  49818. cu1 = ((code - 0x10000) >> 10) + 0xD800;
  49819. cu2 = ((code - 0x10000) & 1023) + 0xDC00;
  49820. return String.fromCharCode(cu1, cu2);
  49821. }
  49822. function getEscapedIdentifier() {
  49823. var ch, id;
  49824. ch = source.charCodeAt(index++);
  49825. id = String.fromCharCode(ch);
  49826. // '\u' (char #92, char #117) denotes an escaped character.
  49827. if (ch === 92) {
  49828. if (source.charCodeAt(index) !== 117) {
  49829. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49830. }
  49831. ++index;
  49832. ch = scanHexEscape('u');
  49833. if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
  49834. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49835. }
  49836. id = ch;
  49837. }
  49838. while (index < length) {
  49839. ch = source.charCodeAt(index);
  49840. if (!isIdentifierPart(ch)) {
  49841. break;
  49842. }
  49843. ++index;
  49844. id += String.fromCharCode(ch);
  49845. // '\u' (char #92, char #117) denotes an escaped character.
  49846. if (ch === 92) {
  49847. id = id.substr(0, id.length - 1);
  49848. if (source.charCodeAt(index) !== 117) {
  49849. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49850. }
  49851. ++index;
  49852. ch = scanHexEscape('u');
  49853. if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
  49854. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  49855. }
  49856. id += ch;
  49857. }
  49858. }
  49859. return id;
  49860. }
  49861. function getIdentifier() {
  49862. var start, ch;
  49863. start = index++;
  49864. while (index < length) {
  49865. ch = source.charCodeAt(index);
  49866. if (ch === 92) {
  49867. // Blackslash (char #92) marks Unicode escape sequence.
  49868. index = start;
  49869. return getEscapedIdentifier();
  49870. }
  49871. if (isIdentifierPart(ch)) {
  49872. ++index;
  49873. } else {
  49874. break;
  49875. }
  49876. }
  49877. return source.slice(start, index);
  49878. }
  49879. function scanIdentifier() {
  49880. var start, id, type;
  49881. start = index;
  49882. // Backslash (char #92) starts an escaped character.
  49883. id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
  49884. // There is no keyword or literal with only one character.
  49885. // Thus, it must be an identifier.
  49886. if (id.length === 1) {
  49887. type = Token.Identifier;
  49888. } else if (isKeyword(id)) {
  49889. type = Token.Keyword;
  49890. } else if (id === 'null') {
  49891. type = Token.NullLiteral;
  49892. } else if (id === 'true' || id === 'false') {
  49893. type = Token.BooleanLiteral;
  49894. } else {
  49895. type = Token.Identifier;
  49896. }
  49897. return {
  49898. type: type,
  49899. value: id,
  49900. lineNumber: lineNumber,
  49901. lineStart: lineStart,
  49902. range: [start, index]
  49903. };
  49904. }
  49905. // 7.7 Punctuators
  49906. function scanPunctuator() {
  49907. var start = index,
  49908. code = source.charCodeAt(index),
  49909. code2,
  49910. ch1 = source[index],
  49911. ch2,
  49912. ch3,
  49913. ch4;
  49914. if (state.inJSXTag || state.inJSXChild) {
  49915. // Don't need to check for '{' and '}' as it's already handled
  49916. // correctly by default.
  49917. switch (code) {
  49918. case 60: // <
  49919. case 62: // >
  49920. ++index;
  49921. return {
  49922. type: Token.Punctuator,
  49923. value: String.fromCharCode(code),
  49924. lineNumber: lineNumber,
  49925. lineStart: lineStart,
  49926. range: [start, index]
  49927. };
  49928. }
  49929. }
  49930. switch (code) {
  49931. // Check for most common single-character punctuators.
  49932. case 40: // ( open bracket
  49933. case 41: // ) close bracket
  49934. case 59: // ; semicolon
  49935. case 44: // , comma
  49936. case 123: // { open curly brace
  49937. case 125: // } close curly brace
  49938. case 91: // [
  49939. case 93: // ]
  49940. case 58: // :
  49941. case 63: // ?
  49942. case 126: // ~
  49943. ++index;
  49944. if (extra.tokenize) {
  49945. if (code === 40) {
  49946. extra.openParenToken = extra.tokens.length;
  49947. } else if (code === 123) {
  49948. extra.openCurlyToken = extra.tokens.length;
  49949. }
  49950. }
  49951. return {
  49952. type: Token.Punctuator,
  49953. value: String.fromCharCode(code),
  49954. lineNumber: lineNumber,
  49955. lineStart: lineStart,
  49956. range: [start, index]
  49957. };
  49958. default:
  49959. code2 = source.charCodeAt(index + 1);
  49960. // '=' (char #61) marks an assignment or comparison operator.
  49961. if (code2 === 61) {
  49962. switch (code) {
  49963. case 37: // %
  49964. case 38: // &
  49965. case 42: // *:
  49966. case 43: // +
  49967. case 45: // -
  49968. case 47: // /
  49969. case 60: // <
  49970. case 62: // >
  49971. case 94: // ^
  49972. case 124: // |
  49973. index += 2;
  49974. return {
  49975. type: Token.Punctuator,
  49976. value: String.fromCharCode(code) + String.fromCharCode(code2),
  49977. lineNumber: lineNumber,
  49978. lineStart: lineStart,
  49979. range: [start, index]
  49980. };
  49981. case 33: // !
  49982. case 61: // =
  49983. index += 2;
  49984. // !== and ===
  49985. if (source.charCodeAt(index) === 61) {
  49986. ++index;
  49987. }
  49988. return {
  49989. type: Token.Punctuator,
  49990. value: source.slice(start, index),
  49991. lineNumber: lineNumber,
  49992. lineStart: lineStart,
  49993. range: [start, index]
  49994. };
  49995. default:
  49996. break;
  49997. }
  49998. }
  49999. break;
  50000. }
  50001. // Peek more characters.
  50002. ch2 = source[index + 1];
  50003. ch3 = source[index + 2];
  50004. ch4 = source[index + 3];
  50005. // 4-character punctuator: >>>=
  50006. if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
  50007. if (ch4 === '=') {
  50008. index += 4;
  50009. return {
  50010. type: Token.Punctuator,
  50011. value: '>>>=',
  50012. lineNumber: lineNumber,
  50013. lineStart: lineStart,
  50014. range: [start, index]
  50015. };
  50016. }
  50017. }
  50018. // 3-character punctuators: === !== >>> <<= >>=
  50019. if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
  50020. index += 3;
  50021. return {
  50022. type: Token.Punctuator,
  50023. value: '>>>',
  50024. lineNumber: lineNumber,
  50025. lineStart: lineStart,
  50026. range: [start, index]
  50027. };
  50028. }
  50029. if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
  50030. index += 3;
  50031. return {
  50032. type: Token.Punctuator,
  50033. value: '<<=',
  50034. lineNumber: lineNumber,
  50035. lineStart: lineStart,
  50036. range: [start, index]
  50037. };
  50038. }
  50039. if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
  50040. index += 3;
  50041. return {
  50042. type: Token.Punctuator,
  50043. value: '>>=',
  50044. lineNumber: lineNumber,
  50045. lineStart: lineStart,
  50046. range: [start, index]
  50047. };
  50048. }
  50049. if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
  50050. index += 3;
  50051. return {
  50052. type: Token.Punctuator,
  50053. value: '...',
  50054. lineNumber: lineNumber,
  50055. lineStart: lineStart,
  50056. range: [start, index]
  50057. };
  50058. }
  50059. // Other 2-character punctuators: ++ -- << >> && ||
  50060. // Don't match these tokens if we're in a type, since they never can
  50061. // occur and can mess up types like Map<string, Array<string>>
  50062. if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
  50063. index += 2;
  50064. return {
  50065. type: Token.Punctuator,
  50066. value: ch1 + ch2,
  50067. lineNumber: lineNumber,
  50068. lineStart: lineStart,
  50069. range: [start, index]
  50070. };
  50071. }
  50072. if (ch1 === '=' && ch2 === '>') {
  50073. index += 2;
  50074. return {
  50075. type: Token.Punctuator,
  50076. value: '=>',
  50077. lineNumber: lineNumber,
  50078. lineStart: lineStart,
  50079. range: [start, index]
  50080. };
  50081. }
  50082. if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
  50083. ++index;
  50084. return {
  50085. type: Token.Punctuator,
  50086. value: ch1,
  50087. lineNumber: lineNumber,
  50088. lineStart: lineStart,
  50089. range: [start, index]
  50090. };
  50091. }
  50092. if (ch1 === '.') {
  50093. ++index;
  50094. return {
  50095. type: Token.Punctuator,
  50096. value: ch1,
  50097. lineNumber: lineNumber,
  50098. lineStart: lineStart,
  50099. range: [start, index]
  50100. };
  50101. }
  50102. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50103. }
  50104. // 7.8.3 Numeric Literals
  50105. function scanHexLiteral(start) {
  50106. var number = '';
  50107. while (index < length) {
  50108. if (!isHexDigit(source[index])) {
  50109. break;
  50110. }
  50111. number += source[index++];
  50112. }
  50113. if (number.length === 0) {
  50114. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50115. }
  50116. if (isIdentifierStart(source.charCodeAt(index))) {
  50117. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50118. }
  50119. return {
  50120. type: Token.NumericLiteral,
  50121. value: parseInt('0x' + number, 16),
  50122. lineNumber: lineNumber,
  50123. lineStart: lineStart,
  50124. range: [start, index]
  50125. };
  50126. }
  50127. function scanBinaryLiteral(start) {
  50128. var ch, number;
  50129. number = '';
  50130. while (index < length) {
  50131. ch = source[index];
  50132. if (ch !== '0' && ch !== '1') {
  50133. break;
  50134. }
  50135. number += source[index++];
  50136. }
  50137. if (number.length === 0) {
  50138. // only 0b or 0B
  50139. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50140. }
  50141. if (index < length) {
  50142. ch = source.charCodeAt(index);
  50143. /* istanbul ignore else */
  50144. if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
  50145. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50146. }
  50147. }
  50148. return {
  50149. type: Token.NumericLiteral,
  50150. value: parseInt(number, 2),
  50151. lineNumber: lineNumber,
  50152. lineStart: lineStart,
  50153. range: [start, index]
  50154. };
  50155. }
  50156. function scanOctalLiteral(prefix, start) {
  50157. var number, octal;
  50158. if (isOctalDigit(prefix)) {
  50159. octal = true;
  50160. number = '0' + source[index++];
  50161. } else {
  50162. octal = false;
  50163. ++index;
  50164. number = '';
  50165. }
  50166. while (index < length) {
  50167. if (!isOctalDigit(source[index])) {
  50168. break;
  50169. }
  50170. number += source[index++];
  50171. }
  50172. if (!octal && number.length === 0) {
  50173. // only 0o or 0O
  50174. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50175. }
  50176. if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
  50177. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50178. }
  50179. return {
  50180. type: Token.NumericLiteral,
  50181. value: parseInt(number, 8),
  50182. octal: octal,
  50183. lineNumber: lineNumber,
  50184. lineStart: lineStart,
  50185. range: [start, index]
  50186. };
  50187. }
  50188. function scanNumericLiteral() {
  50189. var number, start, ch;
  50190. ch = source[index];
  50191. assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
  50192. 'Numeric literal must start with a decimal digit or a decimal point');
  50193. start = index;
  50194. number = '';
  50195. if (ch !== '.') {
  50196. number = source[index++];
  50197. ch = source[index];
  50198. // Hex number starts with '0x'.
  50199. // Octal number starts with '0'.
  50200. // Octal number in ES6 starts with '0o'.
  50201. // Binary number in ES6 starts with '0b'.
  50202. if (number === '0') {
  50203. if (ch === 'x' || ch === 'X') {
  50204. ++index;
  50205. return scanHexLiteral(start);
  50206. }
  50207. if (ch === 'b' || ch === 'B') {
  50208. ++index;
  50209. return scanBinaryLiteral(start);
  50210. }
  50211. if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
  50212. return scanOctalLiteral(ch, start);
  50213. }
  50214. // decimal number starts with '0' such as '09' is illegal.
  50215. if (ch && isDecimalDigit(ch.charCodeAt(0))) {
  50216. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50217. }
  50218. }
  50219. while (isDecimalDigit(source.charCodeAt(index))) {
  50220. number += source[index++];
  50221. }
  50222. ch = source[index];
  50223. }
  50224. if (ch === '.') {
  50225. number += source[index++];
  50226. while (isDecimalDigit(source.charCodeAt(index))) {
  50227. number += source[index++];
  50228. }
  50229. ch = source[index];
  50230. }
  50231. if (ch === 'e' || ch === 'E') {
  50232. number += source[index++];
  50233. ch = source[index];
  50234. if (ch === '+' || ch === '-') {
  50235. number += source[index++];
  50236. }
  50237. if (isDecimalDigit(source.charCodeAt(index))) {
  50238. while (isDecimalDigit(source.charCodeAt(index))) {
  50239. number += source[index++];
  50240. }
  50241. } else {
  50242. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50243. }
  50244. }
  50245. if (isIdentifierStart(source.charCodeAt(index))) {
  50246. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50247. }
  50248. return {
  50249. type: Token.NumericLiteral,
  50250. value: parseFloat(number),
  50251. lineNumber: lineNumber,
  50252. lineStart: lineStart,
  50253. range: [start, index]
  50254. };
  50255. }
  50256. // 7.8.4 String Literals
  50257. function scanStringLiteral() {
  50258. var str = '', quote, start, ch, code, unescaped, restore, octal = false;
  50259. quote = source[index];
  50260. assert((quote === '\'' || quote === '"'),
  50261. 'String literal must starts with a quote');
  50262. start = index;
  50263. ++index;
  50264. while (index < length) {
  50265. ch = source[index++];
  50266. if (ch === quote) {
  50267. quote = '';
  50268. break;
  50269. } else if (ch === '\\') {
  50270. ch = source[index++];
  50271. if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
  50272. switch (ch) {
  50273. case 'n':
  50274. str += '\n';
  50275. break;
  50276. case 'r':
  50277. str += '\r';
  50278. break;
  50279. case 't':
  50280. str += '\t';
  50281. break;
  50282. case 'u':
  50283. case 'x':
  50284. if (source[index] === '{') {
  50285. ++index;
  50286. str += scanUnicodeCodePointEscape();
  50287. } else {
  50288. restore = index;
  50289. unescaped = scanHexEscape(ch);
  50290. if (unescaped) {
  50291. str += unescaped;
  50292. } else {
  50293. index = restore;
  50294. str += ch;
  50295. }
  50296. }
  50297. break;
  50298. case 'b':
  50299. str += '\b';
  50300. break;
  50301. case 'f':
  50302. str += '\f';
  50303. break;
  50304. case 'v':
  50305. str += '\x0B';
  50306. break;
  50307. default:
  50308. if (isOctalDigit(ch)) {
  50309. code = '01234567'.indexOf(ch);
  50310. // \0 is not octal escape sequence
  50311. if (code !== 0) {
  50312. octal = true;
  50313. }
  50314. /* istanbul ignore else */
  50315. if (index < length && isOctalDigit(source[index])) {
  50316. octal = true;
  50317. code = code * 8 + '01234567'.indexOf(source[index++]);
  50318. // 3 digits are only allowed when string starts
  50319. // with 0, 1, 2, 3
  50320. if ('0123'.indexOf(ch) >= 0 &&
  50321. index < length &&
  50322. isOctalDigit(source[index])) {
  50323. code = code * 8 + '01234567'.indexOf(source[index++]);
  50324. }
  50325. }
  50326. str += String.fromCharCode(code);
  50327. } else {
  50328. str += ch;
  50329. }
  50330. break;
  50331. }
  50332. } else {
  50333. ++lineNumber;
  50334. if (ch === '\r' && source[index] === '\n') {
  50335. ++index;
  50336. }
  50337. lineStart = index;
  50338. }
  50339. } else if (isLineTerminator(ch.charCodeAt(0))) {
  50340. break;
  50341. } else {
  50342. str += ch;
  50343. }
  50344. }
  50345. if (quote !== '') {
  50346. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50347. }
  50348. return {
  50349. type: Token.StringLiteral,
  50350. value: str,
  50351. octal: octal,
  50352. lineNumber: lineNumber,
  50353. lineStart: lineStart,
  50354. range: [start, index]
  50355. };
  50356. }
  50357. function scanTemplate() {
  50358. var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal;
  50359. terminated = false;
  50360. tail = false;
  50361. start = index;
  50362. ++index;
  50363. while (index < length) {
  50364. ch = source[index++];
  50365. if (ch === '`') {
  50366. tail = true;
  50367. terminated = true;
  50368. break;
  50369. } else if (ch === '$') {
  50370. if (source[index] === '{') {
  50371. ++index;
  50372. terminated = true;
  50373. break;
  50374. }
  50375. cooked += ch;
  50376. } else if (ch === '\\') {
  50377. ch = source[index++];
  50378. if (!isLineTerminator(ch.charCodeAt(0))) {
  50379. switch (ch) {
  50380. case 'n':
  50381. cooked += '\n';
  50382. break;
  50383. case 'r':
  50384. cooked += '\r';
  50385. break;
  50386. case 't':
  50387. cooked += '\t';
  50388. break;
  50389. case 'u':
  50390. case 'x':
  50391. if (source[index] === '{') {
  50392. ++index;
  50393. cooked += scanUnicodeCodePointEscape();
  50394. } else {
  50395. restore = index;
  50396. unescaped = scanHexEscape(ch);
  50397. if (unescaped) {
  50398. cooked += unescaped;
  50399. } else {
  50400. index = restore;
  50401. cooked += ch;
  50402. }
  50403. }
  50404. break;
  50405. case 'b':
  50406. cooked += '\b';
  50407. break;
  50408. case 'f':
  50409. cooked += '\f';
  50410. break;
  50411. case 'v':
  50412. cooked += '\v';
  50413. break;
  50414. default:
  50415. if (isOctalDigit(ch)) {
  50416. code = '01234567'.indexOf(ch);
  50417. // \0 is not octal escape sequence
  50418. if (code !== 0) {
  50419. octal = true;
  50420. }
  50421. /* istanbul ignore else */
  50422. if (index < length && isOctalDigit(source[index])) {
  50423. octal = true;
  50424. code = code * 8 + '01234567'.indexOf(source[index++]);
  50425. // 3 digits are only allowed when string starts
  50426. // with 0, 1, 2, 3
  50427. if ('0123'.indexOf(ch) >= 0 &&
  50428. index < length &&
  50429. isOctalDigit(source[index])) {
  50430. code = code * 8 + '01234567'.indexOf(source[index++]);
  50431. }
  50432. }
  50433. cooked += String.fromCharCode(code);
  50434. } else {
  50435. cooked += ch;
  50436. }
  50437. break;
  50438. }
  50439. } else {
  50440. ++lineNumber;
  50441. if (ch === '\r' && source[index] === '\n') {
  50442. ++index;
  50443. }
  50444. lineStart = index;
  50445. }
  50446. } else if (isLineTerminator(ch.charCodeAt(0))) {
  50447. ++lineNumber;
  50448. if (ch === '\r' && source[index] === '\n') {
  50449. ++index;
  50450. }
  50451. lineStart = index;
  50452. cooked += '\n';
  50453. } else {
  50454. cooked += ch;
  50455. }
  50456. }
  50457. if (!terminated) {
  50458. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50459. }
  50460. return {
  50461. type: Token.Template,
  50462. value: {
  50463. cooked: cooked,
  50464. raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
  50465. },
  50466. tail: tail,
  50467. octal: octal,
  50468. lineNumber: lineNumber,
  50469. lineStart: lineStart,
  50470. range: [start, index]
  50471. };
  50472. }
  50473. function scanTemplateElement(option) {
  50474. var startsWith, template;
  50475. lookahead = null;
  50476. skipComment();
  50477. startsWith = (option.head) ? '`' : '}';
  50478. if (source[index] !== startsWith) {
  50479. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  50480. }
  50481. template = scanTemplate();
  50482. peek();
  50483. return template;
  50484. }
  50485. function testRegExp(pattern, flags) {
  50486. var tmp = pattern,
  50487. value;
  50488. if (flags.indexOf('u') >= 0) {
  50489. // Replace each astral symbol and every Unicode code point
  50490. // escape sequence with a single ASCII symbol to avoid throwing on
  50491. // regular expressions that are only valid in combination with the
  50492. // `/u` flag.
  50493. // Note: replacing with the ASCII symbol `x` might cause false
  50494. // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
  50495. // perfectly valid pattern that is equivalent to `[a-b]`, but it
  50496. // would be replaced by `[x-b]` which throws an error.
  50497. tmp = tmp
  50498. .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
  50499. if (parseInt($1, 16) <= 0x10FFFF) {
  50500. return 'x';
  50501. }
  50502. throwError({}, Messages.InvalidRegExp);
  50503. })
  50504. .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
  50505. }
  50506. // First, detect invalid regular expressions.
  50507. try {
  50508. value = new RegExp(tmp);
  50509. } catch (e) {
  50510. throwError({}, Messages.InvalidRegExp);
  50511. }
  50512. // Return a regular expression object for this pattern-flag pair, or
  50513. // `null` in case the current environment doesn't support the flags it
  50514. // uses.
  50515. try {
  50516. return new RegExp(pattern, flags);
  50517. } catch (exception) {
  50518. return null;
  50519. }
  50520. }
  50521. function scanRegExpBody() {
  50522. var ch, str, classMarker, terminated, body;
  50523. ch = source[index];
  50524. assert(ch === '/', 'Regular expression literal must start with a slash');
  50525. str = source[index++];
  50526. classMarker = false;
  50527. terminated = false;
  50528. while (index < length) {
  50529. ch = source[index++];
  50530. str += ch;
  50531. if (ch === '\\') {
  50532. ch = source[index++];
  50533. // ECMA-262 7.8.5
  50534. if (isLineTerminator(ch.charCodeAt(0))) {
  50535. throwError({}, Messages.UnterminatedRegExp);
  50536. }
  50537. str += ch;
  50538. } else if (isLineTerminator(ch.charCodeAt(0))) {
  50539. throwError({}, Messages.UnterminatedRegExp);
  50540. } else if (classMarker) {
  50541. if (ch === ']') {
  50542. classMarker = false;
  50543. }
  50544. } else {
  50545. if (ch === '/') {
  50546. terminated = true;
  50547. break;
  50548. } else if (ch === '[') {
  50549. classMarker = true;
  50550. }
  50551. }
  50552. }
  50553. if (!terminated) {
  50554. throwError({}, Messages.UnterminatedRegExp);
  50555. }
  50556. // Exclude leading and trailing slash.
  50557. body = str.substr(1, str.length - 2);
  50558. return {
  50559. value: body,
  50560. literal: str
  50561. };
  50562. }
  50563. function scanRegExpFlags() {
  50564. var ch, str, flags, restore;
  50565. str = '';
  50566. flags = '';
  50567. while (index < length) {
  50568. ch = source[index];
  50569. if (!isIdentifierPart(ch.charCodeAt(0))) {
  50570. break;
  50571. }
  50572. ++index;
  50573. if (ch === '\\' && index < length) {
  50574. ch = source[index];
  50575. if (ch === 'u') {
  50576. ++index;
  50577. restore = index;
  50578. ch = scanHexEscape('u');
  50579. if (ch) {
  50580. flags += ch;
  50581. for (str += '\\u'; restore < index; ++restore) {
  50582. str += source[restore];
  50583. }
  50584. } else {
  50585. index = restore;
  50586. flags += 'u';
  50587. str += '\\u';
  50588. }
  50589. throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
  50590. } else {
  50591. str += '\\';
  50592. throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
  50593. }
  50594. } else {
  50595. flags += ch;
  50596. str += ch;
  50597. }
  50598. }
  50599. return {
  50600. value: flags,
  50601. literal: str
  50602. };
  50603. }
  50604. function scanRegExp() {
  50605. var start, body, flags, value;
  50606. lookahead = null;
  50607. skipComment();
  50608. start = index;
  50609. body = scanRegExpBody();
  50610. flags = scanRegExpFlags();
  50611. value = testRegExp(body.value, flags.value);
  50612. if (extra.tokenize) {
  50613. return {
  50614. type: Token.RegularExpression,
  50615. value: value,
  50616. regex: {
  50617. pattern: body.value,
  50618. flags: flags.value
  50619. },
  50620. lineNumber: lineNumber,
  50621. lineStart: lineStart,
  50622. range: [start, index]
  50623. };
  50624. }
  50625. return {
  50626. literal: body.literal + flags.literal,
  50627. value: value,
  50628. regex: {
  50629. pattern: body.value,
  50630. flags: flags.value
  50631. },
  50632. range: [start, index]
  50633. };
  50634. }
  50635. function isIdentifierName(token) {
  50636. return token.type === Token.Identifier ||
  50637. token.type === Token.Keyword ||
  50638. token.type === Token.BooleanLiteral ||
  50639. token.type === Token.NullLiteral;
  50640. }
  50641. function advanceSlash() {
  50642. var prevToken,
  50643. checkToken;
  50644. // Using the following algorithm:
  50645. // https://github.com/mozilla/sweet.js/wiki/design
  50646. prevToken = extra.tokens[extra.tokens.length - 1];
  50647. if (!prevToken) {
  50648. // Nothing before that: it cannot be a division.
  50649. return scanRegExp();
  50650. }
  50651. if (prevToken.type === 'Punctuator') {
  50652. if (prevToken.value === ')') {
  50653. checkToken = extra.tokens[extra.openParenToken - 1];
  50654. if (checkToken &&
  50655. checkToken.type === 'Keyword' &&
  50656. (checkToken.value === 'if' ||
  50657. checkToken.value === 'while' ||
  50658. checkToken.value === 'for' ||
  50659. checkToken.value === 'with')) {
  50660. return scanRegExp();
  50661. }
  50662. return scanPunctuator();
  50663. }
  50664. if (prevToken.value === '}') {
  50665. // Dividing a function by anything makes little sense,
  50666. // but we have to check for that.
  50667. if (extra.tokens[extra.openCurlyToken - 3] &&
  50668. extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
  50669. // Anonymous function.
  50670. checkToken = extra.tokens[extra.openCurlyToken - 4];
  50671. if (!checkToken) {
  50672. return scanPunctuator();
  50673. }
  50674. } else if (extra.tokens[extra.openCurlyToken - 4] &&
  50675. extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
  50676. // Named function.
  50677. checkToken = extra.tokens[extra.openCurlyToken - 5];
  50678. if (!checkToken) {
  50679. return scanRegExp();
  50680. }
  50681. } else {
  50682. return scanPunctuator();
  50683. }
  50684. // checkToken determines whether the function is
  50685. // a declaration or an expression.
  50686. if (FnExprTokens.indexOf(checkToken.value) >= 0) {
  50687. // It is an expression.
  50688. return scanPunctuator();
  50689. }
  50690. // It is a declaration.
  50691. return scanRegExp();
  50692. }
  50693. return scanRegExp();
  50694. }
  50695. if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
  50696. return scanRegExp();
  50697. }
  50698. return scanPunctuator();
  50699. }
  50700. function advance() {
  50701. var ch;
  50702. if (!state.inJSXChild) {
  50703. skipComment();
  50704. }
  50705. if (index >= length) {
  50706. return {
  50707. type: Token.EOF,
  50708. lineNumber: lineNumber,
  50709. lineStart: lineStart,
  50710. range: [index, index]
  50711. };
  50712. }
  50713. if (state.inJSXChild) {
  50714. return advanceJSXChild();
  50715. }
  50716. ch = source.charCodeAt(index);
  50717. // Very common: ( and ) and ;
  50718. if (ch === 40 || ch === 41 || ch === 58) {
  50719. return scanPunctuator();
  50720. }
  50721. // String literal starts with single quote (#39) or double quote (#34).
  50722. if (ch === 39 || ch === 34) {
  50723. if (state.inJSXTag) {
  50724. return scanJSXStringLiteral();
  50725. }
  50726. return scanStringLiteral();
  50727. }
  50728. if (state.inJSXTag && isJSXIdentifierStart(ch)) {
  50729. return scanJSXIdentifier();
  50730. }
  50731. if (ch === 96) {
  50732. return scanTemplate();
  50733. }
  50734. if (isIdentifierStart(ch)) {
  50735. return scanIdentifier();
  50736. }
  50737. // Dot (.) char #46 can also start a floating-point number, hence the need
  50738. // to check the next character.
  50739. if (ch === 46) {
  50740. if (isDecimalDigit(source.charCodeAt(index + 1))) {
  50741. return scanNumericLiteral();
  50742. }
  50743. return scanPunctuator();
  50744. }
  50745. if (isDecimalDigit(ch)) {
  50746. return scanNumericLiteral();
  50747. }
  50748. // Slash (/) char #47 can also start a regex.
  50749. if (extra.tokenize && ch === 47) {
  50750. return advanceSlash();
  50751. }
  50752. return scanPunctuator();
  50753. }
  50754. function lex() {
  50755. var token;
  50756. token = lookahead;
  50757. index = token.range[1];
  50758. lineNumber = token.lineNumber;
  50759. lineStart = token.lineStart;
  50760. lookahead = advance();
  50761. index = token.range[1];
  50762. lineNumber = token.lineNumber;
  50763. lineStart = token.lineStart;
  50764. return token;
  50765. }
  50766. function peek() {
  50767. var pos, line, start;
  50768. pos = index;
  50769. line = lineNumber;
  50770. start = lineStart;
  50771. lookahead = advance();
  50772. index = pos;
  50773. lineNumber = line;
  50774. lineStart = start;
  50775. }
  50776. function lookahead2() {
  50777. var adv, pos, line, start, result;
  50778. // If we are collecting the tokens, don't grab the next one yet.
  50779. /* istanbul ignore next */
  50780. adv = (typeof extra.advance === 'function') ? extra.advance : advance;
  50781. pos = index;
  50782. line = lineNumber;
  50783. start = lineStart;
  50784. // Scan for the next immediate token.
  50785. /* istanbul ignore if */
  50786. if (lookahead === null) {
  50787. lookahead = adv();
  50788. }
  50789. index = lookahead.range[1];
  50790. lineNumber = lookahead.lineNumber;
  50791. lineStart = lookahead.lineStart;
  50792. // Grab the token right after.
  50793. result = adv();
  50794. index = pos;
  50795. lineNumber = line;
  50796. lineStart = start;
  50797. return result;
  50798. }
  50799. function rewind(token) {
  50800. index = token.range[0];
  50801. lineNumber = token.lineNumber;
  50802. lineStart = token.lineStart;
  50803. lookahead = token;
  50804. }
  50805. function markerCreate() {
  50806. if (!extra.loc && !extra.range) {
  50807. return undefined;
  50808. }
  50809. skipComment();
  50810. return {offset: index, line: lineNumber, col: index - lineStart};
  50811. }
  50812. function markerCreatePreserveWhitespace() {
  50813. if (!extra.loc && !extra.range) {
  50814. return undefined;
  50815. }
  50816. return {offset: index, line: lineNumber, col: index - lineStart};
  50817. }
  50818. function processComment(node) {
  50819. var lastChild,
  50820. trailingComments,
  50821. bottomRight = extra.bottomRightStack,
  50822. last = bottomRight[bottomRight.length - 1];
  50823. if (node.type === Syntax.Program) {
  50824. /* istanbul ignore else */
  50825. if (node.body.length > 0) {
  50826. return;
  50827. }
  50828. }
  50829. if (extra.trailingComments.length > 0) {
  50830. if (extra.trailingComments[0].range[0] >= node.range[1]) {
  50831. trailingComments = extra.trailingComments;
  50832. extra.trailingComments = [];
  50833. } else {
  50834. extra.trailingComments.length = 0;
  50835. }
  50836. } else {
  50837. if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
  50838. trailingComments = last.trailingComments;
  50839. delete last.trailingComments;
  50840. }
  50841. }
  50842. // Eating the stack.
  50843. if (last) {
  50844. while (last && last.range[0] >= node.range[0]) {
  50845. lastChild = last;
  50846. last = bottomRight.pop();
  50847. }
  50848. }
  50849. if (lastChild) {
  50850. if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
  50851. node.leadingComments = lastChild.leadingComments;
  50852. delete lastChild.leadingComments;
  50853. }
  50854. } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
  50855. node.leadingComments = extra.leadingComments;
  50856. extra.leadingComments = [];
  50857. }
  50858. if (trailingComments) {
  50859. node.trailingComments = trailingComments;
  50860. }
  50861. bottomRight.push(node);
  50862. }
  50863. function markerApply(marker, node) {
  50864. if (extra.range) {
  50865. node.range = [marker.offset, index];
  50866. }
  50867. if (extra.loc) {
  50868. node.loc = {
  50869. start: {
  50870. line: marker.line,
  50871. column: marker.col
  50872. },
  50873. end: {
  50874. line: lineNumber,
  50875. column: index - lineStart
  50876. }
  50877. };
  50878. node = delegate.postProcess(node);
  50879. }
  50880. if (extra.attachComment) {
  50881. processComment(node);
  50882. }
  50883. return node;
  50884. }
  50885. SyntaxTreeDelegate = {
  50886. name: 'SyntaxTree',
  50887. postProcess: function (node) {
  50888. return node;
  50889. },
  50890. createArrayExpression: function (elements) {
  50891. return {
  50892. type: Syntax.ArrayExpression,
  50893. elements: elements
  50894. };
  50895. },
  50896. createAssignmentExpression: function (operator, left, right) {
  50897. return {
  50898. type: Syntax.AssignmentExpression,
  50899. operator: operator,
  50900. left: left,
  50901. right: right
  50902. };
  50903. },
  50904. createBinaryExpression: function (operator, left, right) {
  50905. var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
  50906. Syntax.BinaryExpression;
  50907. return {
  50908. type: type,
  50909. operator: operator,
  50910. left: left,
  50911. right: right
  50912. };
  50913. },
  50914. createBlockStatement: function (body) {
  50915. return {
  50916. type: Syntax.BlockStatement,
  50917. body: body
  50918. };
  50919. },
  50920. createBreakStatement: function (label) {
  50921. return {
  50922. type: Syntax.BreakStatement,
  50923. label: label
  50924. };
  50925. },
  50926. createCallExpression: function (callee, args) {
  50927. return {
  50928. type: Syntax.CallExpression,
  50929. callee: callee,
  50930. 'arguments': args
  50931. };
  50932. },
  50933. createCatchClause: function (param, body) {
  50934. return {
  50935. type: Syntax.CatchClause,
  50936. param: param,
  50937. body: body
  50938. };
  50939. },
  50940. createConditionalExpression: function (test, consequent, alternate) {
  50941. return {
  50942. type: Syntax.ConditionalExpression,
  50943. test: test,
  50944. consequent: consequent,
  50945. alternate: alternate
  50946. };
  50947. },
  50948. createContinueStatement: function (label) {
  50949. return {
  50950. type: Syntax.ContinueStatement,
  50951. label: label
  50952. };
  50953. },
  50954. createDebuggerStatement: function () {
  50955. return {
  50956. type: Syntax.DebuggerStatement
  50957. };
  50958. },
  50959. createDoWhileStatement: function (body, test) {
  50960. return {
  50961. type: Syntax.DoWhileStatement,
  50962. body: body,
  50963. test: test
  50964. };
  50965. },
  50966. createEmptyStatement: function () {
  50967. return {
  50968. type: Syntax.EmptyStatement
  50969. };
  50970. },
  50971. createExpressionStatement: function (expression) {
  50972. return {
  50973. type: Syntax.ExpressionStatement,
  50974. expression: expression
  50975. };
  50976. },
  50977. createForStatement: function (init, test, update, body) {
  50978. return {
  50979. type: Syntax.ForStatement,
  50980. init: init,
  50981. test: test,
  50982. update: update,
  50983. body: body
  50984. };
  50985. },
  50986. createForInStatement: function (left, right, body) {
  50987. return {
  50988. type: Syntax.ForInStatement,
  50989. left: left,
  50990. right: right,
  50991. body: body,
  50992. each: false
  50993. };
  50994. },
  50995. createForOfStatement: function (left, right, body) {
  50996. return {
  50997. type: Syntax.ForOfStatement,
  50998. left: left,
  50999. right: right,
  51000. body: body
  51001. };
  51002. },
  51003. createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
  51004. isAsync, returnType, typeParameters) {
  51005. var funDecl = {
  51006. type: Syntax.FunctionDeclaration,
  51007. id: id,
  51008. params: params,
  51009. defaults: defaults,
  51010. body: body,
  51011. rest: rest,
  51012. generator: generator,
  51013. expression: expression,
  51014. returnType: returnType,
  51015. typeParameters: typeParameters
  51016. };
  51017. if (isAsync) {
  51018. funDecl.async = true;
  51019. }
  51020. return funDecl;
  51021. },
  51022. createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
  51023. isAsync, returnType, typeParameters) {
  51024. var funExpr = {
  51025. type: Syntax.FunctionExpression,
  51026. id: id,
  51027. params: params,
  51028. defaults: defaults,
  51029. body: body,
  51030. rest: rest,
  51031. generator: generator,
  51032. expression: expression,
  51033. returnType: returnType,
  51034. typeParameters: typeParameters
  51035. };
  51036. if (isAsync) {
  51037. funExpr.async = true;
  51038. }
  51039. return funExpr;
  51040. },
  51041. createIdentifier: function (name) {
  51042. return {
  51043. type: Syntax.Identifier,
  51044. name: name,
  51045. // Only here to initialize the shape of the object to ensure
  51046. // that the 'typeAnnotation' key is ordered before others that
  51047. // are added later (like 'loc' and 'range'). This just helps
  51048. // keep the shape of Identifier nodes consistent with everything
  51049. // else.
  51050. typeAnnotation: undefined,
  51051. optional: undefined
  51052. };
  51053. },
  51054. createTypeAnnotation: function (typeAnnotation) {
  51055. return {
  51056. type: Syntax.TypeAnnotation,
  51057. typeAnnotation: typeAnnotation
  51058. };
  51059. },
  51060. createTypeCast: function (expression, typeAnnotation) {
  51061. return {
  51062. type: Syntax.TypeCastExpression,
  51063. expression: expression,
  51064. typeAnnotation: typeAnnotation
  51065. };
  51066. },
  51067. createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
  51068. return {
  51069. type: Syntax.FunctionTypeAnnotation,
  51070. params: params,
  51071. returnType: returnType,
  51072. rest: rest,
  51073. typeParameters: typeParameters
  51074. };
  51075. },
  51076. createFunctionTypeParam: function (name, typeAnnotation, optional) {
  51077. return {
  51078. type: Syntax.FunctionTypeParam,
  51079. name: name,
  51080. typeAnnotation: typeAnnotation,
  51081. optional: optional
  51082. };
  51083. },
  51084. createNullableTypeAnnotation: function (typeAnnotation) {
  51085. return {
  51086. type: Syntax.NullableTypeAnnotation,
  51087. typeAnnotation: typeAnnotation
  51088. };
  51089. },
  51090. createArrayTypeAnnotation: function (elementType) {
  51091. return {
  51092. type: Syntax.ArrayTypeAnnotation,
  51093. elementType: elementType
  51094. };
  51095. },
  51096. createGenericTypeAnnotation: function (id, typeParameters) {
  51097. return {
  51098. type: Syntax.GenericTypeAnnotation,
  51099. id: id,
  51100. typeParameters: typeParameters
  51101. };
  51102. },
  51103. createQualifiedTypeIdentifier: function (qualification, id) {
  51104. return {
  51105. type: Syntax.QualifiedTypeIdentifier,
  51106. qualification: qualification,
  51107. id: id
  51108. };
  51109. },
  51110. createTypeParameterDeclaration: function (params) {
  51111. return {
  51112. type: Syntax.TypeParameterDeclaration,
  51113. params: params
  51114. };
  51115. },
  51116. createTypeParameterInstantiation: function (params) {
  51117. return {
  51118. type: Syntax.TypeParameterInstantiation,
  51119. params: params
  51120. };
  51121. },
  51122. createAnyTypeAnnotation: function () {
  51123. return {
  51124. type: Syntax.AnyTypeAnnotation
  51125. };
  51126. },
  51127. createBooleanTypeAnnotation: function () {
  51128. return {
  51129. type: Syntax.BooleanTypeAnnotation
  51130. };
  51131. },
  51132. createNumberTypeAnnotation: function () {
  51133. return {
  51134. type: Syntax.NumberTypeAnnotation
  51135. };
  51136. },
  51137. createStringTypeAnnotation: function () {
  51138. return {
  51139. type: Syntax.StringTypeAnnotation
  51140. };
  51141. },
  51142. createStringLiteralTypeAnnotation: function (token) {
  51143. return {
  51144. type: Syntax.StringLiteralTypeAnnotation,
  51145. value: token.value,
  51146. raw: source.slice(token.range[0], token.range[1])
  51147. };
  51148. },
  51149. createVoidTypeAnnotation: function () {
  51150. return {
  51151. type: Syntax.VoidTypeAnnotation
  51152. };
  51153. },
  51154. createTypeofTypeAnnotation: function (argument) {
  51155. return {
  51156. type: Syntax.TypeofTypeAnnotation,
  51157. argument: argument
  51158. };
  51159. },
  51160. createTupleTypeAnnotation: function (types) {
  51161. return {
  51162. type: Syntax.TupleTypeAnnotation,
  51163. types: types
  51164. };
  51165. },
  51166. createObjectTypeAnnotation: function (properties, indexers, callProperties) {
  51167. return {
  51168. type: Syntax.ObjectTypeAnnotation,
  51169. properties: properties,
  51170. indexers: indexers,
  51171. callProperties: callProperties
  51172. };
  51173. },
  51174. createObjectTypeIndexer: function (id, key, value, isStatic) {
  51175. return {
  51176. type: Syntax.ObjectTypeIndexer,
  51177. id: id,
  51178. key: key,
  51179. value: value,
  51180. static: isStatic
  51181. };
  51182. },
  51183. createObjectTypeCallProperty: function (value, isStatic) {
  51184. return {
  51185. type: Syntax.ObjectTypeCallProperty,
  51186. value: value,
  51187. static: isStatic
  51188. };
  51189. },
  51190. createObjectTypeProperty: function (key, value, optional, isStatic) {
  51191. return {
  51192. type: Syntax.ObjectTypeProperty,
  51193. key: key,
  51194. value: value,
  51195. optional: optional,
  51196. static: isStatic
  51197. };
  51198. },
  51199. createUnionTypeAnnotation: function (types) {
  51200. return {
  51201. type: Syntax.UnionTypeAnnotation,
  51202. types: types
  51203. };
  51204. },
  51205. createIntersectionTypeAnnotation: function (types) {
  51206. return {
  51207. type: Syntax.IntersectionTypeAnnotation,
  51208. types: types
  51209. };
  51210. },
  51211. createTypeAlias: function (id, typeParameters, right) {
  51212. return {
  51213. type: Syntax.TypeAlias,
  51214. id: id,
  51215. typeParameters: typeParameters,
  51216. right: right
  51217. };
  51218. },
  51219. createInterface: function (id, typeParameters, body, extended) {
  51220. return {
  51221. type: Syntax.InterfaceDeclaration,
  51222. id: id,
  51223. typeParameters: typeParameters,
  51224. body: body,
  51225. extends: extended
  51226. };
  51227. },
  51228. createInterfaceExtends: function (id, typeParameters) {
  51229. return {
  51230. type: Syntax.InterfaceExtends,
  51231. id: id,
  51232. typeParameters: typeParameters
  51233. };
  51234. },
  51235. createDeclareFunction: function (id) {
  51236. return {
  51237. type: Syntax.DeclareFunction,
  51238. id: id
  51239. };
  51240. },
  51241. createDeclareVariable: function (id) {
  51242. return {
  51243. type: Syntax.DeclareVariable,
  51244. id: id
  51245. };
  51246. },
  51247. createDeclareModule: function (id, body) {
  51248. return {
  51249. type: Syntax.DeclareModule,
  51250. id: id,
  51251. body: body
  51252. };
  51253. },
  51254. createJSXAttribute: function (name, value) {
  51255. return {
  51256. type: Syntax.JSXAttribute,
  51257. name: name,
  51258. value: value || null
  51259. };
  51260. },
  51261. createJSXSpreadAttribute: function (argument) {
  51262. return {
  51263. type: Syntax.JSXSpreadAttribute,
  51264. argument: argument
  51265. };
  51266. },
  51267. createJSXIdentifier: function (name) {
  51268. return {
  51269. type: Syntax.JSXIdentifier,
  51270. name: name
  51271. };
  51272. },
  51273. createJSXNamespacedName: function (namespace, name) {
  51274. return {
  51275. type: Syntax.JSXNamespacedName,
  51276. namespace: namespace,
  51277. name: name
  51278. };
  51279. },
  51280. createJSXMemberExpression: function (object, property) {
  51281. return {
  51282. type: Syntax.JSXMemberExpression,
  51283. object: object,
  51284. property: property
  51285. };
  51286. },
  51287. createJSXElement: function (openingElement, closingElement, children) {
  51288. return {
  51289. type: Syntax.JSXElement,
  51290. openingElement: openingElement,
  51291. closingElement: closingElement,
  51292. children: children
  51293. };
  51294. },
  51295. createJSXEmptyExpression: function () {
  51296. return {
  51297. type: Syntax.JSXEmptyExpression
  51298. };
  51299. },
  51300. createJSXExpressionContainer: function (expression) {
  51301. return {
  51302. type: Syntax.JSXExpressionContainer,
  51303. expression: expression
  51304. };
  51305. },
  51306. createJSXOpeningElement: function (name, attributes, selfClosing) {
  51307. return {
  51308. type: Syntax.JSXOpeningElement,
  51309. name: name,
  51310. selfClosing: selfClosing,
  51311. attributes: attributes
  51312. };
  51313. },
  51314. createJSXClosingElement: function (name) {
  51315. return {
  51316. type: Syntax.JSXClosingElement,
  51317. name: name
  51318. };
  51319. },
  51320. createIfStatement: function (test, consequent, alternate) {
  51321. return {
  51322. type: Syntax.IfStatement,
  51323. test: test,
  51324. consequent: consequent,
  51325. alternate: alternate
  51326. };
  51327. },
  51328. createLabeledStatement: function (label, body) {
  51329. return {
  51330. type: Syntax.LabeledStatement,
  51331. label: label,
  51332. body: body
  51333. };
  51334. },
  51335. createLiteral: function (token) {
  51336. var object = {
  51337. type: Syntax.Literal,
  51338. value: token.value,
  51339. raw: source.slice(token.range[0], token.range[1])
  51340. };
  51341. if (token.regex) {
  51342. object.regex = token.regex;
  51343. }
  51344. return object;
  51345. },
  51346. createMemberExpression: function (accessor, object, property) {
  51347. return {
  51348. type: Syntax.MemberExpression,
  51349. computed: accessor === '[',
  51350. object: object,
  51351. property: property
  51352. };
  51353. },
  51354. createNewExpression: function (callee, args) {
  51355. return {
  51356. type: Syntax.NewExpression,
  51357. callee: callee,
  51358. 'arguments': args
  51359. };
  51360. },
  51361. createObjectExpression: function (properties) {
  51362. return {
  51363. type: Syntax.ObjectExpression,
  51364. properties: properties
  51365. };
  51366. },
  51367. createPostfixExpression: function (operator, argument) {
  51368. return {
  51369. type: Syntax.UpdateExpression,
  51370. operator: operator,
  51371. argument: argument,
  51372. prefix: false
  51373. };
  51374. },
  51375. createProgram: function (body) {
  51376. return {
  51377. type: Syntax.Program,
  51378. body: body
  51379. };
  51380. },
  51381. createProperty: function (kind, key, value, method, shorthand, computed) {
  51382. return {
  51383. type: Syntax.Property,
  51384. key: key,
  51385. value: value,
  51386. kind: kind,
  51387. method: method,
  51388. shorthand: shorthand,
  51389. computed: computed
  51390. };
  51391. },
  51392. createReturnStatement: function (argument) {
  51393. return {
  51394. type: Syntax.ReturnStatement,
  51395. argument: argument
  51396. };
  51397. },
  51398. createSequenceExpression: function (expressions) {
  51399. return {
  51400. type: Syntax.SequenceExpression,
  51401. expressions: expressions
  51402. };
  51403. },
  51404. createSwitchCase: function (test, consequent) {
  51405. return {
  51406. type: Syntax.SwitchCase,
  51407. test: test,
  51408. consequent: consequent
  51409. };
  51410. },
  51411. createSwitchStatement: function (discriminant, cases) {
  51412. return {
  51413. type: Syntax.SwitchStatement,
  51414. discriminant: discriminant,
  51415. cases: cases
  51416. };
  51417. },
  51418. createThisExpression: function () {
  51419. return {
  51420. type: Syntax.ThisExpression
  51421. };
  51422. },
  51423. createThrowStatement: function (argument) {
  51424. return {
  51425. type: Syntax.ThrowStatement,
  51426. argument: argument
  51427. };
  51428. },
  51429. createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
  51430. return {
  51431. type: Syntax.TryStatement,
  51432. block: block,
  51433. guardedHandlers: guardedHandlers,
  51434. handlers: handlers,
  51435. finalizer: finalizer
  51436. };
  51437. },
  51438. createUnaryExpression: function (operator, argument) {
  51439. if (operator === '++' || operator === '--') {
  51440. return {
  51441. type: Syntax.UpdateExpression,
  51442. operator: operator,
  51443. argument: argument,
  51444. prefix: true
  51445. };
  51446. }
  51447. return {
  51448. type: Syntax.UnaryExpression,
  51449. operator: operator,
  51450. argument: argument,
  51451. prefix: true
  51452. };
  51453. },
  51454. createVariableDeclaration: function (declarations, kind) {
  51455. return {
  51456. type: Syntax.VariableDeclaration,
  51457. declarations: declarations,
  51458. kind: kind
  51459. };
  51460. },
  51461. createVariableDeclarator: function (id, init) {
  51462. return {
  51463. type: Syntax.VariableDeclarator,
  51464. id: id,
  51465. init: init
  51466. };
  51467. },
  51468. createWhileStatement: function (test, body) {
  51469. return {
  51470. type: Syntax.WhileStatement,
  51471. test: test,
  51472. body: body
  51473. };
  51474. },
  51475. createWithStatement: function (object, body) {
  51476. return {
  51477. type: Syntax.WithStatement,
  51478. object: object,
  51479. body: body
  51480. };
  51481. },
  51482. createTemplateElement: function (value, tail) {
  51483. return {
  51484. type: Syntax.TemplateElement,
  51485. value: value,
  51486. tail: tail
  51487. };
  51488. },
  51489. createTemplateLiteral: function (quasis, expressions) {
  51490. return {
  51491. type: Syntax.TemplateLiteral,
  51492. quasis: quasis,
  51493. expressions: expressions
  51494. };
  51495. },
  51496. createSpreadElement: function (argument) {
  51497. return {
  51498. type: Syntax.SpreadElement,
  51499. argument: argument
  51500. };
  51501. },
  51502. createSpreadProperty: function (argument) {
  51503. return {
  51504. type: Syntax.SpreadProperty,
  51505. argument: argument
  51506. };
  51507. },
  51508. createTaggedTemplateExpression: function (tag, quasi) {
  51509. return {
  51510. type: Syntax.TaggedTemplateExpression,
  51511. tag: tag,
  51512. quasi: quasi
  51513. };
  51514. },
  51515. createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
  51516. var arrowExpr = {
  51517. type: Syntax.ArrowFunctionExpression,
  51518. id: null,
  51519. params: params,
  51520. defaults: defaults,
  51521. body: body,
  51522. rest: rest,
  51523. generator: false,
  51524. expression: expression
  51525. };
  51526. if (isAsync) {
  51527. arrowExpr.async = true;
  51528. }
  51529. return arrowExpr;
  51530. },
  51531. createMethodDefinition: function (propertyType, kind, key, value, computed) {
  51532. return {
  51533. type: Syntax.MethodDefinition,
  51534. key: key,
  51535. value: value,
  51536. kind: kind,
  51537. 'static': propertyType === ClassPropertyType.static,
  51538. computed: computed
  51539. };
  51540. },
  51541. createClassProperty: function (key, typeAnnotation, computed, isStatic) {
  51542. return {
  51543. type: Syntax.ClassProperty,
  51544. key: key,
  51545. typeAnnotation: typeAnnotation,
  51546. computed: computed,
  51547. static: isStatic
  51548. };
  51549. },
  51550. createClassBody: function (body) {
  51551. return {
  51552. type: Syntax.ClassBody,
  51553. body: body
  51554. };
  51555. },
  51556. createClassImplements: function (id, typeParameters) {
  51557. return {
  51558. type: Syntax.ClassImplements,
  51559. id: id,
  51560. typeParameters: typeParameters
  51561. };
  51562. },
  51563. createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  51564. return {
  51565. type: Syntax.ClassExpression,
  51566. id: id,
  51567. superClass: superClass,
  51568. body: body,
  51569. typeParameters: typeParameters,
  51570. superTypeParameters: superTypeParameters,
  51571. implements: implemented
  51572. };
  51573. },
  51574. createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  51575. return {
  51576. type: Syntax.ClassDeclaration,
  51577. id: id,
  51578. superClass: superClass,
  51579. body: body,
  51580. typeParameters: typeParameters,
  51581. superTypeParameters: superTypeParameters,
  51582. implements: implemented
  51583. };
  51584. },
  51585. createModuleSpecifier: function (token) {
  51586. return {
  51587. type: Syntax.ModuleSpecifier,
  51588. value: token.value,
  51589. raw: source.slice(token.range[0], token.range[1])
  51590. };
  51591. },
  51592. createExportSpecifier: function (id, name) {
  51593. return {
  51594. type: Syntax.ExportSpecifier,
  51595. id: id,
  51596. name: name
  51597. };
  51598. },
  51599. createExportBatchSpecifier: function () {
  51600. return {
  51601. type: Syntax.ExportBatchSpecifier
  51602. };
  51603. },
  51604. createImportDefaultSpecifier: function (id) {
  51605. return {
  51606. type: Syntax.ImportDefaultSpecifier,
  51607. id: id
  51608. };
  51609. },
  51610. createImportNamespaceSpecifier: function (id) {
  51611. return {
  51612. type: Syntax.ImportNamespaceSpecifier,
  51613. id: id
  51614. };
  51615. },
  51616. createExportDeclaration: function (isDefault, declaration, specifiers, src) {
  51617. return {
  51618. type: Syntax.ExportDeclaration,
  51619. 'default': !!isDefault,
  51620. declaration: declaration,
  51621. specifiers: specifiers,
  51622. source: src
  51623. };
  51624. },
  51625. createImportSpecifier: function (id, name) {
  51626. return {
  51627. type: Syntax.ImportSpecifier,
  51628. id: id,
  51629. name: name
  51630. };
  51631. },
  51632. createImportDeclaration: function (specifiers, src, isType) {
  51633. return {
  51634. type: Syntax.ImportDeclaration,
  51635. specifiers: specifiers,
  51636. source: src,
  51637. isType: isType
  51638. };
  51639. },
  51640. createYieldExpression: function (argument, dlg) {
  51641. return {
  51642. type: Syntax.YieldExpression,
  51643. argument: argument,
  51644. delegate: dlg
  51645. };
  51646. },
  51647. createAwaitExpression: function (argument) {
  51648. return {
  51649. type: Syntax.AwaitExpression,
  51650. argument: argument
  51651. };
  51652. },
  51653. createComprehensionExpression: function (filter, blocks, body) {
  51654. return {
  51655. type: Syntax.ComprehensionExpression,
  51656. filter: filter,
  51657. blocks: blocks,
  51658. body: body
  51659. };
  51660. }
  51661. };
  51662. // Return true if there is a line terminator before the next token.
  51663. function peekLineTerminator() {
  51664. var pos, line, start, found;
  51665. pos = index;
  51666. line = lineNumber;
  51667. start = lineStart;
  51668. skipComment();
  51669. found = lineNumber !== line;
  51670. index = pos;
  51671. lineNumber = line;
  51672. lineStart = start;
  51673. return found;
  51674. }
  51675. // Throw an exception
  51676. function throwError(token, messageFormat) {
  51677. var error,
  51678. args = Array.prototype.slice.call(arguments, 2),
  51679. msg = messageFormat.replace(
  51680. /%(\d)/g,
  51681. function (whole, idx) {
  51682. assert(idx < args.length, 'Message reference must be in range');
  51683. return args[idx];
  51684. }
  51685. );
  51686. if (typeof token.lineNumber === 'number') {
  51687. error = new Error('Line ' + token.lineNumber + ': ' + msg);
  51688. error.index = token.range[0];
  51689. error.lineNumber = token.lineNumber;
  51690. error.column = token.range[0] - lineStart + 1;
  51691. } else {
  51692. error = new Error('Line ' + lineNumber + ': ' + msg);
  51693. error.index = index;
  51694. error.lineNumber = lineNumber;
  51695. error.column = index - lineStart + 1;
  51696. }
  51697. error.description = msg;
  51698. throw error;
  51699. }
  51700. function throwErrorTolerant() {
  51701. try {
  51702. throwError.apply(null, arguments);
  51703. } catch (e) {
  51704. if (extra.errors) {
  51705. extra.errors.push(e);
  51706. } else {
  51707. throw e;
  51708. }
  51709. }
  51710. }
  51711. // Throw an exception because of the token.
  51712. function throwUnexpected(token) {
  51713. if (token.type === Token.EOF) {
  51714. throwError(token, Messages.UnexpectedEOS);
  51715. }
  51716. if (token.type === Token.NumericLiteral) {
  51717. throwError(token, Messages.UnexpectedNumber);
  51718. }
  51719. if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
  51720. throwError(token, Messages.UnexpectedString);
  51721. }
  51722. if (token.type === Token.Identifier) {
  51723. throwError(token, Messages.UnexpectedIdentifier);
  51724. }
  51725. if (token.type === Token.Keyword) {
  51726. if (isFutureReservedWord(token.value)) {
  51727. throwError(token, Messages.UnexpectedReserved);
  51728. } else if (strict && isStrictModeReservedWord(token.value)) {
  51729. throwErrorTolerant(token, Messages.StrictReservedWord);
  51730. return;
  51731. }
  51732. throwError(token, Messages.UnexpectedToken, token.value);
  51733. }
  51734. if (token.type === Token.Template) {
  51735. throwError(token, Messages.UnexpectedTemplate, token.value.raw);
  51736. }
  51737. // BooleanLiteral, NullLiteral, or Punctuator.
  51738. throwError(token, Messages.UnexpectedToken, token.value);
  51739. }
  51740. // Expect the next token to match the specified punctuator.
  51741. // If not, an exception will be thrown.
  51742. function expect(value) {
  51743. var token = lex();
  51744. if (token.type !== Token.Punctuator || token.value !== value) {
  51745. throwUnexpected(token);
  51746. }
  51747. }
  51748. // Expect the next token to match the specified keyword.
  51749. // If not, an exception will be thrown.
  51750. function expectKeyword(keyword, contextual) {
  51751. var token = lex();
  51752. if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
  51753. token.value !== keyword) {
  51754. throwUnexpected(token);
  51755. }
  51756. }
  51757. // Expect the next token to match the specified contextual keyword.
  51758. // If not, an exception will be thrown.
  51759. function expectContextualKeyword(keyword) {
  51760. return expectKeyword(keyword, true);
  51761. }
  51762. // Return true if the next token matches the specified punctuator.
  51763. function match(value) {
  51764. return lookahead.type === Token.Punctuator && lookahead.value === value;
  51765. }
  51766. // Return true if the next token matches the specified keyword
  51767. function matchKeyword(keyword, contextual) {
  51768. var expectedType = contextual ? Token.Identifier : Token.Keyword;
  51769. return lookahead.type === expectedType && lookahead.value === keyword;
  51770. }
  51771. // Return true if the next token matches the specified contextual keyword
  51772. function matchContextualKeyword(keyword) {
  51773. return matchKeyword(keyword, true);
  51774. }
  51775. // Return true if the next token is an assignment operator
  51776. function matchAssign() {
  51777. var op;
  51778. if (lookahead.type !== Token.Punctuator) {
  51779. return false;
  51780. }
  51781. op = lookahead.value;
  51782. return op === '=' ||
  51783. op === '*=' ||
  51784. op === '/=' ||
  51785. op === '%=' ||
  51786. op === '+=' ||
  51787. op === '-=' ||
  51788. op === '<<=' ||
  51789. op === '>>=' ||
  51790. op === '>>>=' ||
  51791. op === '&=' ||
  51792. op === '^=' ||
  51793. op === '|=';
  51794. }
  51795. // Note that 'yield' is treated as a keyword in strict mode, but a
  51796. // contextual keyword (identifier) in non-strict mode, so we need to
  51797. // use matchKeyword('yield', false) and matchKeyword('yield', true)
  51798. // (i.e. matchContextualKeyword) appropriately.
  51799. function matchYield() {
  51800. return state.yieldAllowed && matchKeyword('yield', !strict);
  51801. }
  51802. function matchAsync() {
  51803. var backtrackToken = lookahead, matches = false;
  51804. if (matchContextualKeyword('async')) {
  51805. lex(); // Make sure peekLineTerminator() starts after 'async'.
  51806. matches = !peekLineTerminator();
  51807. rewind(backtrackToken); // Revert the lex().
  51808. }
  51809. return matches;
  51810. }
  51811. function matchAwait() {
  51812. return state.awaitAllowed && matchContextualKeyword('await');
  51813. }
  51814. function consumeSemicolon() {
  51815. var line, oldIndex = index, oldLineNumber = lineNumber,
  51816. oldLineStart = lineStart, oldLookahead = lookahead;
  51817. // Catch the very common case first: immediately a semicolon (char #59).
  51818. if (source.charCodeAt(index) === 59) {
  51819. lex();
  51820. return;
  51821. }
  51822. line = lineNumber;
  51823. skipComment();
  51824. if (lineNumber !== line) {
  51825. index = oldIndex;
  51826. lineNumber = oldLineNumber;
  51827. lineStart = oldLineStart;
  51828. lookahead = oldLookahead;
  51829. return;
  51830. }
  51831. if (match(';')) {
  51832. lex();
  51833. return;
  51834. }
  51835. if (lookahead.type !== Token.EOF && !match('}')) {
  51836. throwUnexpected(lookahead);
  51837. }
  51838. }
  51839. // Return true if provided expression is LeftHandSideExpression
  51840. function isLeftHandSide(expr) {
  51841. return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
  51842. }
  51843. function isAssignableLeftHandSide(expr) {
  51844. return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
  51845. }
  51846. // 11.1.4 Array Initialiser
  51847. function parseArrayInitialiser() {
  51848. var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
  51849. marker = markerCreate();
  51850. expect('[');
  51851. while (!match(']')) {
  51852. if (lookahead.value === 'for' &&
  51853. lookahead.type === Token.Keyword) {
  51854. if (!possiblecomprehension) {
  51855. throwError({}, Messages.ComprehensionError);
  51856. }
  51857. matchKeyword('for');
  51858. tmp = parseForStatement({ignoreBody: true});
  51859. tmp.of = tmp.type === Syntax.ForOfStatement;
  51860. tmp.type = Syntax.ComprehensionBlock;
  51861. if (tmp.left.kind) { // can't be let or const
  51862. throwError({}, Messages.ComprehensionError);
  51863. }
  51864. blocks.push(tmp);
  51865. } else if (lookahead.value === 'if' &&
  51866. lookahead.type === Token.Keyword) {
  51867. if (!possiblecomprehension) {
  51868. throwError({}, Messages.ComprehensionError);
  51869. }
  51870. expectKeyword('if');
  51871. expect('(');
  51872. filter = parseExpression();
  51873. expect(')');
  51874. } else if (lookahead.value === ',' &&
  51875. lookahead.type === Token.Punctuator) {
  51876. possiblecomprehension = false; // no longer allowed.
  51877. lex();
  51878. elements.push(null);
  51879. } else {
  51880. tmp = parseSpreadOrAssignmentExpression();
  51881. elements.push(tmp);
  51882. if (tmp && tmp.type === Syntax.SpreadElement) {
  51883. if (!match(']')) {
  51884. throwError({}, Messages.ElementAfterSpreadElement);
  51885. }
  51886. } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
  51887. expect(','); // this lexes.
  51888. possiblecomprehension = false;
  51889. }
  51890. }
  51891. }
  51892. expect(']');
  51893. if (filter && !blocks.length) {
  51894. throwError({}, Messages.ComprehensionRequiresBlock);
  51895. }
  51896. if (blocks.length) {
  51897. if (elements.length !== 1) {
  51898. throwError({}, Messages.ComprehensionError);
  51899. }
  51900. return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
  51901. }
  51902. return markerApply(marker, delegate.createArrayExpression(elements));
  51903. }
  51904. // 11.1.5 Object Initialiser
  51905. function parsePropertyFunction(options) {
  51906. var previousStrict, previousYieldAllowed, previousAwaitAllowed,
  51907. params, defaults, body, marker = markerCreate();
  51908. previousStrict = strict;
  51909. previousYieldAllowed = state.yieldAllowed;
  51910. state.yieldAllowed = options.generator;
  51911. previousAwaitAllowed = state.awaitAllowed;
  51912. state.awaitAllowed = options.async;
  51913. params = options.params || [];
  51914. defaults = options.defaults || [];
  51915. body = parseConciseBody();
  51916. if (options.name && strict && isRestrictedWord(params[0].name)) {
  51917. throwErrorTolerant(options.name, Messages.StrictParamName);
  51918. }
  51919. strict = previousStrict;
  51920. state.yieldAllowed = previousYieldAllowed;
  51921. state.awaitAllowed = previousAwaitAllowed;
  51922. return markerApply(marker, delegate.createFunctionExpression(
  51923. null,
  51924. params,
  51925. defaults,
  51926. body,
  51927. options.rest || null,
  51928. options.generator,
  51929. body.type !== Syntax.BlockStatement,
  51930. options.async,
  51931. options.returnType,
  51932. options.typeParameters
  51933. ));
  51934. }
  51935. function parsePropertyMethodFunction(options) {
  51936. var previousStrict, tmp, method;
  51937. previousStrict = strict;
  51938. strict = true;
  51939. tmp = parseParams();
  51940. if (tmp.stricted) {
  51941. throwErrorTolerant(tmp.stricted, tmp.message);
  51942. }
  51943. method = parsePropertyFunction({
  51944. params: tmp.params,
  51945. defaults: tmp.defaults,
  51946. rest: tmp.rest,
  51947. generator: options.generator,
  51948. async: options.async,
  51949. returnType: tmp.returnType,
  51950. typeParameters: options.typeParameters
  51951. });
  51952. strict = previousStrict;
  51953. return method;
  51954. }
  51955. function parseObjectPropertyKey() {
  51956. var marker = markerCreate(),
  51957. token = lex(),
  51958. propertyKey,
  51959. result;
  51960. // Note: This function is called only from parseObjectProperty(), where
  51961. // EOF and Punctuator tokens are already filtered out.
  51962. if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
  51963. if (strict && token.octal) {
  51964. throwErrorTolerant(token, Messages.StrictOctalLiteral);
  51965. }
  51966. return markerApply(marker, delegate.createLiteral(token));
  51967. }
  51968. if (token.type === Token.Punctuator && token.value === '[') {
  51969. // For computed properties we should skip the [ and ], and
  51970. // capture in marker only the assignment expression itself.
  51971. marker = markerCreate();
  51972. propertyKey = parseAssignmentExpression();
  51973. result = markerApply(marker, propertyKey);
  51974. expect(']');
  51975. return result;
  51976. }
  51977. return markerApply(marker, delegate.createIdentifier(token.value));
  51978. }
  51979. function parseObjectProperty() {
  51980. var token, key, id, param, computed,
  51981. marker = markerCreate(), returnType, typeParameters;
  51982. token = lookahead;
  51983. computed = (token.value === '[' && token.type === Token.Punctuator);
  51984. if (token.type === Token.Identifier || computed || matchAsync()) {
  51985. id = parseObjectPropertyKey();
  51986. if (match(':')) {
  51987. lex();
  51988. return markerApply(
  51989. marker,
  51990. delegate.createProperty(
  51991. 'init',
  51992. id,
  51993. parseAssignmentExpression(),
  51994. false,
  51995. false,
  51996. computed
  51997. )
  51998. );
  51999. }
  52000. if (match('(') || match('<')) {
  52001. if (match('<')) {
  52002. typeParameters = parseTypeParameterDeclaration();
  52003. }
  52004. return markerApply(
  52005. marker,
  52006. delegate.createProperty(
  52007. 'init',
  52008. id,
  52009. parsePropertyMethodFunction({
  52010. generator: false,
  52011. async: false,
  52012. typeParameters: typeParameters
  52013. }),
  52014. true,
  52015. false,
  52016. computed
  52017. )
  52018. );
  52019. }
  52020. // Property Assignment: Getter and Setter.
  52021. if (token.value === 'get') {
  52022. computed = (lookahead.value === '[');
  52023. key = parseObjectPropertyKey();
  52024. expect('(');
  52025. expect(')');
  52026. if (match(':')) {
  52027. returnType = parseTypeAnnotation();
  52028. }
  52029. return markerApply(
  52030. marker,
  52031. delegate.createProperty(
  52032. 'get',
  52033. key,
  52034. parsePropertyFunction({
  52035. generator: false,
  52036. async: false,
  52037. returnType: returnType
  52038. }),
  52039. false,
  52040. false,
  52041. computed
  52042. )
  52043. );
  52044. }
  52045. if (token.value === 'set') {
  52046. computed = (lookahead.value === '[');
  52047. key = parseObjectPropertyKey();
  52048. expect('(');
  52049. token = lookahead;
  52050. param = [ parseTypeAnnotatableIdentifier() ];
  52051. expect(')');
  52052. if (match(':')) {
  52053. returnType = parseTypeAnnotation();
  52054. }
  52055. return markerApply(
  52056. marker,
  52057. delegate.createProperty(
  52058. 'set',
  52059. key,
  52060. parsePropertyFunction({
  52061. params: param,
  52062. generator: false,
  52063. async: false,
  52064. name: token,
  52065. returnType: returnType
  52066. }),
  52067. false,
  52068. false,
  52069. computed
  52070. )
  52071. );
  52072. }
  52073. if (token.value === 'async') {
  52074. computed = (lookahead.value === '[');
  52075. key = parseObjectPropertyKey();
  52076. if (match('<')) {
  52077. typeParameters = parseTypeParameterDeclaration();
  52078. }
  52079. return markerApply(
  52080. marker,
  52081. delegate.createProperty(
  52082. 'init',
  52083. key,
  52084. parsePropertyMethodFunction({
  52085. generator: false,
  52086. async: true,
  52087. typeParameters: typeParameters
  52088. }),
  52089. true,
  52090. false,
  52091. computed
  52092. )
  52093. );
  52094. }
  52095. if (computed) {
  52096. // Computed properties can only be used with full notation.
  52097. throwUnexpected(lookahead);
  52098. }
  52099. return markerApply(
  52100. marker,
  52101. delegate.createProperty('init', id, id, false, true, false)
  52102. );
  52103. }
  52104. if (token.type === Token.EOF || token.type === Token.Punctuator) {
  52105. if (!match('*')) {
  52106. throwUnexpected(token);
  52107. }
  52108. lex();
  52109. computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
  52110. id = parseObjectPropertyKey();
  52111. if (match('<')) {
  52112. typeParameters = parseTypeParameterDeclaration();
  52113. }
  52114. if (!match('(')) {
  52115. throwUnexpected(lex());
  52116. }
  52117. return markerApply(marker, delegate.createProperty(
  52118. 'init',
  52119. id,
  52120. parsePropertyMethodFunction({
  52121. generator: true,
  52122. typeParameters: typeParameters
  52123. }),
  52124. true,
  52125. false,
  52126. computed
  52127. ));
  52128. }
  52129. key = parseObjectPropertyKey();
  52130. if (match(':')) {
  52131. lex();
  52132. return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
  52133. }
  52134. if (match('(') || match('<')) {
  52135. if (match('<')) {
  52136. typeParameters = parseTypeParameterDeclaration();
  52137. }
  52138. return markerApply(marker, delegate.createProperty(
  52139. 'init',
  52140. key,
  52141. parsePropertyMethodFunction({
  52142. generator: false,
  52143. typeParameters: typeParameters
  52144. }),
  52145. true,
  52146. false,
  52147. false
  52148. ));
  52149. }
  52150. throwUnexpected(lex());
  52151. }
  52152. function parseObjectSpreadProperty() {
  52153. var marker = markerCreate();
  52154. expect('...');
  52155. return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
  52156. }
  52157. function getFieldName(key) {
  52158. var toString = String;
  52159. if (key.type === Syntax.Identifier) {
  52160. return key.name;
  52161. }
  52162. return toString(key.value);
  52163. }
  52164. function parseObjectInitialiser() {
  52165. var properties = [], property, name, kind, storedKind, map = new StringMap(),
  52166. marker = markerCreate(), toString = String;
  52167. expect('{');
  52168. while (!match('}')) {
  52169. if (match('...')) {
  52170. property = parseObjectSpreadProperty();
  52171. } else {
  52172. property = parseObjectProperty();
  52173. if (property.key.type === Syntax.Identifier) {
  52174. name = property.key.name;
  52175. } else {
  52176. name = toString(property.key.value);
  52177. }
  52178. kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
  52179. if (map.has(name)) {
  52180. storedKind = map.get(name);
  52181. if (storedKind === PropertyKind.Data) {
  52182. if (strict && kind === PropertyKind.Data) {
  52183. throwErrorTolerant({}, Messages.StrictDuplicateProperty);
  52184. } else if (kind !== PropertyKind.Data) {
  52185. throwErrorTolerant({}, Messages.AccessorDataProperty);
  52186. }
  52187. } else {
  52188. if (kind === PropertyKind.Data) {
  52189. throwErrorTolerant({}, Messages.AccessorDataProperty);
  52190. } else if (storedKind & kind) {
  52191. throwErrorTolerant({}, Messages.AccessorGetSet);
  52192. }
  52193. }
  52194. map.set(name, storedKind | kind);
  52195. } else {
  52196. map.set(name, kind);
  52197. }
  52198. }
  52199. properties.push(property);
  52200. if (!match('}')) {
  52201. expect(',');
  52202. }
  52203. }
  52204. expect('}');
  52205. return markerApply(marker, delegate.createObjectExpression(properties));
  52206. }
  52207. function parseTemplateElement(option) {
  52208. var marker = markerCreate(),
  52209. token = scanTemplateElement(option);
  52210. if (strict && token.octal) {
  52211. throwError(token, Messages.StrictOctalLiteral);
  52212. }
  52213. return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
  52214. }
  52215. function parseTemplateLiteral() {
  52216. var quasi, quasis, expressions, marker = markerCreate();
  52217. quasi = parseTemplateElement({ head: true });
  52218. quasis = [ quasi ];
  52219. expressions = [];
  52220. while (!quasi.tail) {
  52221. expressions.push(parseExpression());
  52222. quasi = parseTemplateElement({ head: false });
  52223. quasis.push(quasi);
  52224. }
  52225. return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
  52226. }
  52227. // 11.1.6 The Grouping Operator
  52228. function parseGroupExpression() {
  52229. var expr, marker, typeAnnotation;
  52230. expect('(');
  52231. ++state.parenthesizedCount;
  52232. marker = markerCreate();
  52233. expr = parseExpression();
  52234. if (match(':')) {
  52235. typeAnnotation = parseTypeAnnotation();
  52236. expr = markerApply(marker, delegate.createTypeCast(
  52237. expr,
  52238. typeAnnotation
  52239. ));
  52240. }
  52241. expect(')');
  52242. return expr;
  52243. }
  52244. function matchAsyncFuncExprOrDecl() {
  52245. var token;
  52246. if (matchAsync()) {
  52247. token = lookahead2();
  52248. if (token.type === Token.Keyword && token.value === 'function') {
  52249. return true;
  52250. }
  52251. }
  52252. return false;
  52253. }
  52254. // 11.1 Primary Expressions
  52255. function parsePrimaryExpression() {
  52256. var marker, type, token, expr;
  52257. type = lookahead.type;
  52258. if (type === Token.Identifier) {
  52259. marker = markerCreate();
  52260. return markerApply(marker, delegate.createIdentifier(lex().value));
  52261. }
  52262. if (type === Token.StringLiteral || type === Token.NumericLiteral) {
  52263. if (strict && lookahead.octal) {
  52264. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  52265. }
  52266. marker = markerCreate();
  52267. return markerApply(marker, delegate.createLiteral(lex()));
  52268. }
  52269. if (type === Token.Keyword) {
  52270. if (matchKeyword('this')) {
  52271. marker = markerCreate();
  52272. lex();
  52273. return markerApply(marker, delegate.createThisExpression());
  52274. }
  52275. if (matchKeyword('function')) {
  52276. return parseFunctionExpression();
  52277. }
  52278. if (matchKeyword('class')) {
  52279. return parseClassExpression();
  52280. }
  52281. if (matchKeyword('super')) {
  52282. marker = markerCreate();
  52283. lex();
  52284. return markerApply(marker, delegate.createIdentifier('super'));
  52285. }
  52286. }
  52287. if (type === Token.BooleanLiteral) {
  52288. marker = markerCreate();
  52289. token = lex();
  52290. token.value = (token.value === 'true');
  52291. return markerApply(marker, delegate.createLiteral(token));
  52292. }
  52293. if (type === Token.NullLiteral) {
  52294. marker = markerCreate();
  52295. token = lex();
  52296. token.value = null;
  52297. return markerApply(marker, delegate.createLiteral(token));
  52298. }
  52299. if (match('[')) {
  52300. return parseArrayInitialiser();
  52301. }
  52302. if (match('{')) {
  52303. return parseObjectInitialiser();
  52304. }
  52305. if (match('(')) {
  52306. return parseGroupExpression();
  52307. }
  52308. if (match('/') || match('/=')) {
  52309. marker = markerCreate();
  52310. expr = delegate.createLiteral(scanRegExp());
  52311. peek();
  52312. return markerApply(marker, expr);
  52313. }
  52314. if (type === Token.Template) {
  52315. return parseTemplateLiteral();
  52316. }
  52317. if (match('<')) {
  52318. return parseJSXElement();
  52319. }
  52320. throwUnexpected(lex());
  52321. }
  52322. // 11.2 Left-Hand-Side Expressions
  52323. function parseArguments() {
  52324. var args = [], arg;
  52325. expect('(');
  52326. if (!match(')')) {
  52327. while (index < length) {
  52328. arg = parseSpreadOrAssignmentExpression();
  52329. args.push(arg);
  52330. if (match(')')) {
  52331. break;
  52332. } else if (arg.type === Syntax.SpreadElement) {
  52333. throwError({}, Messages.ElementAfterSpreadElement);
  52334. }
  52335. expect(',');
  52336. }
  52337. }
  52338. expect(')');
  52339. return args;
  52340. }
  52341. function parseSpreadOrAssignmentExpression() {
  52342. if (match('...')) {
  52343. var marker = markerCreate();
  52344. lex();
  52345. return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
  52346. }
  52347. return parseAssignmentExpression();
  52348. }
  52349. function parseNonComputedProperty() {
  52350. var marker = markerCreate(),
  52351. token = lex();
  52352. if (!isIdentifierName(token)) {
  52353. throwUnexpected(token);
  52354. }
  52355. return markerApply(marker, delegate.createIdentifier(token.value));
  52356. }
  52357. function parseNonComputedMember() {
  52358. expect('.');
  52359. return parseNonComputedProperty();
  52360. }
  52361. function parseComputedMember() {
  52362. var expr;
  52363. expect('[');
  52364. expr = parseExpression();
  52365. expect(']');
  52366. return expr;
  52367. }
  52368. function parseNewExpression() {
  52369. var callee, args, marker = markerCreate();
  52370. expectKeyword('new');
  52371. callee = parseLeftHandSideExpression();
  52372. args = match('(') ? parseArguments() : [];
  52373. return markerApply(marker, delegate.createNewExpression(callee, args));
  52374. }
  52375. function parseLeftHandSideExpressionAllowCall() {
  52376. var expr, args, marker = markerCreate();
  52377. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  52378. while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) {
  52379. if (match('(')) {
  52380. args = parseArguments();
  52381. expr = markerApply(marker, delegate.createCallExpression(expr, args));
  52382. } else if (match('[')) {
  52383. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  52384. } else if (match('.')) {
  52385. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  52386. } else {
  52387. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  52388. }
  52389. }
  52390. return expr;
  52391. }
  52392. function parseLeftHandSideExpression() {
  52393. var expr, marker = markerCreate();
  52394. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  52395. while (match('.') || match('[') || lookahead.type === Token.Template) {
  52396. if (match('[')) {
  52397. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  52398. } else if (match('.')) {
  52399. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  52400. } else {
  52401. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  52402. }
  52403. }
  52404. return expr;
  52405. }
  52406. // 11.3 Postfix Expressions
  52407. function parsePostfixExpression() {
  52408. var marker = markerCreate(),
  52409. expr = parseLeftHandSideExpressionAllowCall(),
  52410. token;
  52411. if (lookahead.type !== Token.Punctuator) {
  52412. return expr;
  52413. }
  52414. if ((match('++') || match('--')) && !peekLineTerminator()) {
  52415. // 11.3.1, 11.3.2
  52416. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  52417. throwErrorTolerant({}, Messages.StrictLHSPostfix);
  52418. }
  52419. if (!isLeftHandSide(expr)) {
  52420. throwError({}, Messages.InvalidLHSInAssignment);
  52421. }
  52422. token = lex();
  52423. expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
  52424. }
  52425. return expr;
  52426. }
  52427. // 11.4 Unary Operators
  52428. function parseUnaryExpression() {
  52429. var marker, token, expr;
  52430. if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
  52431. return parsePostfixExpression();
  52432. }
  52433. if (match('++') || match('--')) {
  52434. marker = markerCreate();
  52435. token = lex();
  52436. expr = parseUnaryExpression();
  52437. // 11.4.4, 11.4.5
  52438. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  52439. throwErrorTolerant({}, Messages.StrictLHSPrefix);
  52440. }
  52441. if (!isLeftHandSide(expr)) {
  52442. throwError({}, Messages.InvalidLHSInAssignment);
  52443. }
  52444. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  52445. }
  52446. if (match('+') || match('-') || match('~') || match('!')) {
  52447. marker = markerCreate();
  52448. token = lex();
  52449. expr = parseUnaryExpression();
  52450. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  52451. }
  52452. if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
  52453. marker = markerCreate();
  52454. token = lex();
  52455. expr = parseUnaryExpression();
  52456. expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  52457. if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
  52458. throwErrorTolerant({}, Messages.StrictDelete);
  52459. }
  52460. return expr;
  52461. }
  52462. return parsePostfixExpression();
  52463. }
  52464. function binaryPrecedence(token, allowIn) {
  52465. var prec = 0;
  52466. if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
  52467. return 0;
  52468. }
  52469. switch (token.value) {
  52470. case '||':
  52471. prec = 1;
  52472. break;
  52473. case '&&':
  52474. prec = 2;
  52475. break;
  52476. case '|':
  52477. prec = 3;
  52478. break;
  52479. case '^':
  52480. prec = 4;
  52481. break;
  52482. case '&':
  52483. prec = 5;
  52484. break;
  52485. case '==':
  52486. case '!=':
  52487. case '===':
  52488. case '!==':
  52489. prec = 6;
  52490. break;
  52491. case '<':
  52492. case '>':
  52493. case '<=':
  52494. case '>=':
  52495. case 'instanceof':
  52496. prec = 7;
  52497. break;
  52498. case 'in':
  52499. prec = allowIn ? 7 : 0;
  52500. break;
  52501. case '<<':
  52502. case '>>':
  52503. case '>>>':
  52504. prec = 8;
  52505. break;
  52506. case '+':
  52507. case '-':
  52508. prec = 9;
  52509. break;
  52510. case '*':
  52511. case '/':
  52512. case '%':
  52513. prec = 11;
  52514. break;
  52515. default:
  52516. break;
  52517. }
  52518. return prec;
  52519. }
  52520. // 11.5 Multiplicative Operators
  52521. // 11.6 Additive Operators
  52522. // 11.7 Bitwise Shift Operators
  52523. // 11.8 Relational Operators
  52524. // 11.9 Equality Operators
  52525. // 11.10 Binary Bitwise Operators
  52526. // 11.11 Binary Logical Operators
  52527. function parseBinaryExpression() {
  52528. var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
  52529. marker, markers;
  52530. previousAllowIn = state.allowIn;
  52531. state.allowIn = true;
  52532. marker = markerCreate();
  52533. left = parseUnaryExpression();
  52534. token = lookahead;
  52535. prec = binaryPrecedence(token, previousAllowIn);
  52536. if (prec === 0) {
  52537. return left;
  52538. }
  52539. token.prec = prec;
  52540. lex();
  52541. markers = [marker, markerCreate()];
  52542. right = parseUnaryExpression();
  52543. stack = [left, token, right];
  52544. while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
  52545. // Reduce: make a binary expression from the three topmost entries.
  52546. while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
  52547. right = stack.pop();
  52548. operator = stack.pop().value;
  52549. left = stack.pop();
  52550. expr = delegate.createBinaryExpression(operator, left, right);
  52551. markers.pop();
  52552. marker = markers.pop();
  52553. markerApply(marker, expr);
  52554. stack.push(expr);
  52555. markers.push(marker);
  52556. }
  52557. // Shift.
  52558. token = lex();
  52559. token.prec = prec;
  52560. stack.push(token);
  52561. markers.push(markerCreate());
  52562. expr = parseUnaryExpression();
  52563. stack.push(expr);
  52564. }
  52565. state.allowIn = previousAllowIn;
  52566. // Final reduce to clean-up the stack.
  52567. i = stack.length - 1;
  52568. expr = stack[i];
  52569. markers.pop();
  52570. while (i > 1) {
  52571. expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
  52572. i -= 2;
  52573. marker = markers.pop();
  52574. markerApply(marker, expr);
  52575. }
  52576. return expr;
  52577. }
  52578. // 11.12 Conditional Operator
  52579. function parseConditionalExpression() {
  52580. var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
  52581. expr = parseBinaryExpression();
  52582. if (match('?')) {
  52583. lex();
  52584. previousAllowIn = state.allowIn;
  52585. state.allowIn = true;
  52586. consequent = parseAssignmentExpression();
  52587. state.allowIn = previousAllowIn;
  52588. expect(':');
  52589. alternate = parseAssignmentExpression();
  52590. expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
  52591. }
  52592. return expr;
  52593. }
  52594. // 11.13 Assignment Operators
  52595. // 12.14.5 AssignmentPattern
  52596. function reinterpretAsAssignmentBindingPattern(expr) {
  52597. var i, len, property, element;
  52598. if (expr.type === Syntax.ObjectExpression) {
  52599. expr.type = Syntax.ObjectPattern;
  52600. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  52601. property = expr.properties[i];
  52602. if (property.type === Syntax.SpreadProperty) {
  52603. if (i < len - 1) {
  52604. throwError({}, Messages.PropertyAfterSpreadProperty);
  52605. }
  52606. reinterpretAsAssignmentBindingPattern(property.argument);
  52607. } else {
  52608. if (property.kind !== 'init') {
  52609. throwError({}, Messages.InvalidLHSInAssignment);
  52610. }
  52611. reinterpretAsAssignmentBindingPattern(property.value);
  52612. }
  52613. }
  52614. } else if (expr.type === Syntax.ArrayExpression) {
  52615. expr.type = Syntax.ArrayPattern;
  52616. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  52617. element = expr.elements[i];
  52618. /* istanbul ignore else */
  52619. if (element) {
  52620. reinterpretAsAssignmentBindingPattern(element);
  52621. }
  52622. }
  52623. } else if (expr.type === Syntax.Identifier) {
  52624. if (isRestrictedWord(expr.name)) {
  52625. throwError({}, Messages.InvalidLHSInAssignment);
  52626. }
  52627. } else if (expr.type === Syntax.SpreadElement) {
  52628. reinterpretAsAssignmentBindingPattern(expr.argument);
  52629. if (expr.argument.type === Syntax.ObjectPattern) {
  52630. throwError({}, Messages.ObjectPatternAsSpread);
  52631. }
  52632. } else {
  52633. /* istanbul ignore else */
  52634. if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
  52635. throwError({}, Messages.InvalidLHSInAssignment);
  52636. }
  52637. }
  52638. }
  52639. // 13.2.3 BindingPattern
  52640. function reinterpretAsDestructuredParameter(options, expr) {
  52641. var i, len, property, element;
  52642. if (expr.type === Syntax.ObjectExpression) {
  52643. expr.type = Syntax.ObjectPattern;
  52644. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  52645. property = expr.properties[i];
  52646. if (property.type === Syntax.SpreadProperty) {
  52647. if (i < len - 1) {
  52648. throwError({}, Messages.PropertyAfterSpreadProperty);
  52649. }
  52650. reinterpretAsDestructuredParameter(options, property.argument);
  52651. } else {
  52652. if (property.kind !== 'init') {
  52653. throwError({}, Messages.InvalidLHSInFormalsList);
  52654. }
  52655. reinterpretAsDestructuredParameter(options, property.value);
  52656. }
  52657. }
  52658. } else if (expr.type === Syntax.ArrayExpression) {
  52659. expr.type = Syntax.ArrayPattern;
  52660. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  52661. element = expr.elements[i];
  52662. if (element) {
  52663. reinterpretAsDestructuredParameter(options, element);
  52664. }
  52665. }
  52666. } else if (expr.type === Syntax.Identifier) {
  52667. validateParam(options, expr, expr.name);
  52668. } else if (expr.type === Syntax.SpreadElement) {
  52669. // BindingRestElement only allows BindingIdentifier
  52670. if (expr.argument.type !== Syntax.Identifier) {
  52671. throwError({}, Messages.InvalidLHSInFormalsList);
  52672. }
  52673. validateParam(options, expr.argument, expr.argument.name);
  52674. } else {
  52675. throwError({}, Messages.InvalidLHSInFormalsList);
  52676. }
  52677. }
  52678. function reinterpretAsCoverFormalsList(expressions) {
  52679. var i, len, param, params, defaults, defaultCount, options, rest;
  52680. params = [];
  52681. defaults = [];
  52682. defaultCount = 0;
  52683. rest = null;
  52684. options = {
  52685. paramSet: new StringMap()
  52686. };
  52687. for (i = 0, len = expressions.length; i < len; i += 1) {
  52688. param = expressions[i];
  52689. if (param.type === Syntax.Identifier) {
  52690. params.push(param);
  52691. defaults.push(null);
  52692. validateParam(options, param, param.name);
  52693. } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
  52694. reinterpretAsDestructuredParameter(options, param);
  52695. params.push(param);
  52696. defaults.push(null);
  52697. } else if (param.type === Syntax.SpreadElement) {
  52698. assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
  52699. if (param.argument.type !== Syntax.Identifier) {
  52700. throwError({}, Messages.InvalidLHSInFormalsList);
  52701. }
  52702. reinterpretAsDestructuredParameter(options, param.argument);
  52703. rest = param.argument;
  52704. } else if (param.type === Syntax.AssignmentExpression) {
  52705. params.push(param.left);
  52706. defaults.push(param.right);
  52707. ++defaultCount;
  52708. validateParam(options, param.left, param.left.name);
  52709. } else {
  52710. return null;
  52711. }
  52712. }
  52713. if (options.message === Messages.StrictParamDupe) {
  52714. throwError(
  52715. strict ? options.stricted : options.firstRestricted,
  52716. options.message
  52717. );
  52718. }
  52719. if (defaultCount === 0) {
  52720. defaults = [];
  52721. }
  52722. return {
  52723. params: params,
  52724. defaults: defaults,
  52725. rest: rest,
  52726. stricted: options.stricted,
  52727. firstRestricted: options.firstRestricted,
  52728. message: options.message
  52729. };
  52730. }
  52731. function parseArrowFunctionExpression(options, marker) {
  52732. var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
  52733. expect('=>');
  52734. previousStrict = strict;
  52735. previousYieldAllowed = state.yieldAllowed;
  52736. state.yieldAllowed = false;
  52737. previousAwaitAllowed = state.awaitAllowed;
  52738. state.awaitAllowed = !!options.async;
  52739. body = parseConciseBody();
  52740. if (strict && options.firstRestricted) {
  52741. throwError(options.firstRestricted, options.message);
  52742. }
  52743. if (strict && options.stricted) {
  52744. throwErrorTolerant(options.stricted, options.message);
  52745. }
  52746. strict = previousStrict;
  52747. state.yieldAllowed = previousYieldAllowed;
  52748. state.awaitAllowed = previousAwaitAllowed;
  52749. return markerApply(marker, delegate.createArrowFunctionExpression(
  52750. options.params,
  52751. options.defaults,
  52752. body,
  52753. options.rest,
  52754. body.type !== Syntax.BlockStatement,
  52755. !!options.async
  52756. ));
  52757. }
  52758. function parseAssignmentExpression() {
  52759. var marker, expr, token, params, oldParenthesizedCount,
  52760. startsWithParen = false, backtrackToken = lookahead,
  52761. possiblyAsync = false;
  52762. if (matchYield()) {
  52763. return parseYieldExpression();
  52764. }
  52765. if (matchAwait()) {
  52766. return parseAwaitExpression();
  52767. }
  52768. oldParenthesizedCount = state.parenthesizedCount;
  52769. marker = markerCreate();
  52770. if (matchAsyncFuncExprOrDecl()) {
  52771. return parseFunctionExpression();
  52772. }
  52773. if (matchAsync()) {
  52774. // We can't be completely sure that this 'async' token is
  52775. // actually a contextual keyword modifying a function
  52776. // expression, so we might have to un-lex() it later by
  52777. // calling rewind(backtrackToken).
  52778. possiblyAsync = true;
  52779. lex();
  52780. }
  52781. if (match('(')) {
  52782. token = lookahead2();
  52783. if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
  52784. params = parseParams();
  52785. if (!match('=>')) {
  52786. throwUnexpected(lex());
  52787. }
  52788. params.async = possiblyAsync;
  52789. return parseArrowFunctionExpression(params, marker);
  52790. }
  52791. startsWithParen = true;
  52792. }
  52793. token = lookahead;
  52794. // If the 'async' keyword is not followed by a '(' character or an
  52795. // identifier, then it can't be an arrow function modifier, and we
  52796. // should interpret it as a normal identifer.
  52797. if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
  52798. possiblyAsync = false;
  52799. rewind(backtrackToken);
  52800. }
  52801. expr = parseConditionalExpression();
  52802. if (match('=>') &&
  52803. (state.parenthesizedCount === oldParenthesizedCount ||
  52804. state.parenthesizedCount === (oldParenthesizedCount + 1))) {
  52805. if (expr.type === Syntax.Identifier) {
  52806. params = reinterpretAsCoverFormalsList([ expr ]);
  52807. } else if (expr.type === Syntax.AssignmentExpression ||
  52808. expr.type === Syntax.ArrayExpression ||
  52809. expr.type === Syntax.ObjectExpression) {
  52810. if (!startsWithParen) {
  52811. throwUnexpected(lex());
  52812. }
  52813. params = reinterpretAsCoverFormalsList([ expr ]);
  52814. } else if (expr.type === Syntax.SequenceExpression) {
  52815. params = reinterpretAsCoverFormalsList(expr.expressions);
  52816. }
  52817. if (params) {
  52818. params.async = possiblyAsync;
  52819. return parseArrowFunctionExpression(params, marker);
  52820. }
  52821. }
  52822. // If we haven't returned by now, then the 'async' keyword was not
  52823. // a function modifier, and we should rewind and interpret it as a
  52824. // normal identifier.
  52825. if (possiblyAsync) {
  52826. possiblyAsync = false;
  52827. rewind(backtrackToken);
  52828. expr = parseConditionalExpression();
  52829. }
  52830. if (matchAssign()) {
  52831. // 11.13.1
  52832. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  52833. throwErrorTolerant(token, Messages.StrictLHSAssignment);
  52834. }
  52835. // ES.next draf 11.13 Runtime Semantics step 1
  52836. if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
  52837. reinterpretAsAssignmentBindingPattern(expr);
  52838. } else if (!isLeftHandSide(expr)) {
  52839. throwError({}, Messages.InvalidLHSInAssignment);
  52840. }
  52841. expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
  52842. }
  52843. return expr;
  52844. }
  52845. // 11.14 Comma Operator
  52846. function parseExpression() {
  52847. var marker, expr, expressions, sequence, spreadFound;
  52848. marker = markerCreate();
  52849. expr = parseAssignmentExpression();
  52850. expressions = [ expr ];
  52851. if (match(',')) {
  52852. while (index < length) {
  52853. if (!match(',')) {
  52854. break;
  52855. }
  52856. lex();
  52857. expr = parseSpreadOrAssignmentExpression();
  52858. expressions.push(expr);
  52859. if (expr.type === Syntax.SpreadElement) {
  52860. spreadFound = true;
  52861. if (!match(')')) {
  52862. throwError({}, Messages.ElementAfterSpreadElement);
  52863. }
  52864. break;
  52865. }
  52866. }
  52867. sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
  52868. }
  52869. if (spreadFound && lookahead2().value !== '=>') {
  52870. throwError({}, Messages.IllegalSpread);
  52871. }
  52872. return sequence || expr;
  52873. }
  52874. // 12.1 Block
  52875. function parseStatementList() {
  52876. var list = [],
  52877. statement;
  52878. while (index < length) {
  52879. if (match('}')) {
  52880. break;
  52881. }
  52882. statement = parseSourceElement();
  52883. if (typeof statement === 'undefined') {
  52884. break;
  52885. }
  52886. list.push(statement);
  52887. }
  52888. return list;
  52889. }
  52890. function parseBlock() {
  52891. var block, marker = markerCreate();
  52892. expect('{');
  52893. block = parseStatementList();
  52894. expect('}');
  52895. return markerApply(marker, delegate.createBlockStatement(block));
  52896. }
  52897. // 12.2 Variable Statement
  52898. function parseTypeParameterDeclaration() {
  52899. var marker = markerCreate(), paramTypes = [];
  52900. expect('<');
  52901. while (!match('>')) {
  52902. paramTypes.push(parseVariableIdentifier());
  52903. if (!match('>')) {
  52904. expect(',');
  52905. }
  52906. }
  52907. expect('>');
  52908. return markerApply(marker, delegate.createTypeParameterDeclaration(
  52909. paramTypes
  52910. ));
  52911. }
  52912. function parseTypeParameterInstantiation() {
  52913. var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
  52914. state.inType = true;
  52915. expect('<');
  52916. while (!match('>')) {
  52917. paramTypes.push(parseType());
  52918. if (!match('>')) {
  52919. expect(',');
  52920. }
  52921. }
  52922. expect('>');
  52923. state.inType = oldInType;
  52924. return markerApply(marker, delegate.createTypeParameterInstantiation(
  52925. paramTypes
  52926. ));
  52927. }
  52928. function parseObjectTypeIndexer(marker, isStatic) {
  52929. var id, key, value;
  52930. expect('[');
  52931. id = parseObjectPropertyKey();
  52932. expect(':');
  52933. key = parseType();
  52934. expect(']');
  52935. expect(':');
  52936. value = parseType();
  52937. return markerApply(marker, delegate.createObjectTypeIndexer(
  52938. id,
  52939. key,
  52940. value,
  52941. isStatic
  52942. ));
  52943. }
  52944. function parseObjectTypeMethodish(marker) {
  52945. var params = [], rest = null, returnType, typeParameters = null;
  52946. if (match('<')) {
  52947. typeParameters = parseTypeParameterDeclaration();
  52948. }
  52949. expect('(');
  52950. while (lookahead.type === Token.Identifier) {
  52951. params.push(parseFunctionTypeParam());
  52952. if (!match(')')) {
  52953. expect(',');
  52954. }
  52955. }
  52956. if (match('...')) {
  52957. lex();
  52958. rest = parseFunctionTypeParam();
  52959. }
  52960. expect(')');
  52961. expect(':');
  52962. returnType = parseType();
  52963. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  52964. params,
  52965. returnType,
  52966. rest,
  52967. typeParameters
  52968. ));
  52969. }
  52970. function parseObjectTypeMethod(marker, isStatic, key) {
  52971. var optional = false, value;
  52972. value = parseObjectTypeMethodish(marker);
  52973. return markerApply(marker, delegate.createObjectTypeProperty(
  52974. key,
  52975. value,
  52976. optional,
  52977. isStatic
  52978. ));
  52979. }
  52980. function parseObjectTypeCallProperty(marker, isStatic) {
  52981. var valueMarker = markerCreate();
  52982. return markerApply(marker, delegate.createObjectTypeCallProperty(
  52983. parseObjectTypeMethodish(valueMarker),
  52984. isStatic
  52985. ));
  52986. }
  52987. function parseObjectType(allowStatic) {
  52988. var callProperties = [], indexers = [], marker, optional = false,
  52989. properties = [], propertyKey, propertyTypeAnnotation,
  52990. token, isStatic, matchStatic;
  52991. expect('{');
  52992. while (!match('}')) {
  52993. marker = markerCreate();
  52994. matchStatic =
  52995. strict
  52996. ? matchKeyword('static')
  52997. : matchContextualKeyword('static');
  52998. if (allowStatic && matchStatic) {
  52999. token = lex();
  53000. isStatic = true;
  53001. }
  53002. if (match('[')) {
  53003. indexers.push(parseObjectTypeIndexer(marker, isStatic));
  53004. } else if (match('(') || match('<')) {
  53005. callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
  53006. } else {
  53007. if (isStatic && match(':')) {
  53008. propertyKey = markerApply(marker, delegate.createIdentifier(token));
  53009. throwErrorTolerant(token, Messages.StrictReservedWord);
  53010. } else {
  53011. propertyKey = parseObjectPropertyKey();
  53012. }
  53013. if (match('<') || match('(')) {
  53014. // This is a method property
  53015. properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
  53016. } else {
  53017. if (match('?')) {
  53018. lex();
  53019. optional = true;
  53020. }
  53021. expect(':');
  53022. propertyTypeAnnotation = parseType();
  53023. properties.push(markerApply(marker, delegate.createObjectTypeProperty(
  53024. propertyKey,
  53025. propertyTypeAnnotation,
  53026. optional,
  53027. isStatic
  53028. )));
  53029. }
  53030. }
  53031. if (match(';')) {
  53032. lex();
  53033. } else if (!match('}')) {
  53034. throwUnexpected(lookahead);
  53035. }
  53036. }
  53037. expect('}');
  53038. return delegate.createObjectTypeAnnotation(
  53039. properties,
  53040. indexers,
  53041. callProperties
  53042. );
  53043. }
  53044. function parseGenericType() {
  53045. var marker = markerCreate(),
  53046. typeParameters = null, typeIdentifier;
  53047. typeIdentifier = parseVariableIdentifier();
  53048. while (match('.')) {
  53049. expect('.');
  53050. typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
  53051. typeIdentifier,
  53052. parseVariableIdentifier()
  53053. ));
  53054. }
  53055. if (match('<')) {
  53056. typeParameters = parseTypeParameterInstantiation();
  53057. }
  53058. return markerApply(marker, delegate.createGenericTypeAnnotation(
  53059. typeIdentifier,
  53060. typeParameters
  53061. ));
  53062. }
  53063. function parseVoidType() {
  53064. var marker = markerCreate();
  53065. expectKeyword('void');
  53066. return markerApply(marker, delegate.createVoidTypeAnnotation());
  53067. }
  53068. function parseTypeofType() {
  53069. var argument, marker = markerCreate();
  53070. expectKeyword('typeof');
  53071. argument = parsePrimaryType();
  53072. return markerApply(marker, delegate.createTypeofTypeAnnotation(
  53073. argument
  53074. ));
  53075. }
  53076. function parseTupleType() {
  53077. var marker = markerCreate(), types = [];
  53078. expect('[');
  53079. // We allow trailing commas
  53080. while (index < length && !match(']')) {
  53081. types.push(parseType());
  53082. if (match(']')) {
  53083. break;
  53084. }
  53085. expect(',');
  53086. }
  53087. expect(']');
  53088. return markerApply(marker, delegate.createTupleTypeAnnotation(
  53089. types
  53090. ));
  53091. }
  53092. function parseFunctionTypeParam() {
  53093. var marker = markerCreate(), name, optional = false, typeAnnotation;
  53094. name = parseVariableIdentifier();
  53095. if (match('?')) {
  53096. lex();
  53097. optional = true;
  53098. }
  53099. expect(':');
  53100. typeAnnotation = parseType();
  53101. return markerApply(marker, delegate.createFunctionTypeParam(
  53102. name,
  53103. typeAnnotation,
  53104. optional
  53105. ));
  53106. }
  53107. function parseFunctionTypeParams() {
  53108. var ret = { params: [], rest: null };
  53109. while (lookahead.type === Token.Identifier) {
  53110. ret.params.push(parseFunctionTypeParam());
  53111. if (!match(')')) {
  53112. expect(',');
  53113. }
  53114. }
  53115. if (match('...')) {
  53116. lex();
  53117. ret.rest = parseFunctionTypeParam();
  53118. }
  53119. return ret;
  53120. }
  53121. // The parsing of types roughly parallels the parsing of expressions, and
  53122. // primary types are kind of like primary expressions...they're the
  53123. // primitives with which other types are constructed.
  53124. function parsePrimaryType() {
  53125. var params = null, returnType = null,
  53126. marker = markerCreate(), rest = null, tmp,
  53127. typeParameters, token, type, isGroupedType = false;
  53128. switch (lookahead.type) {
  53129. case Token.Identifier:
  53130. switch (lookahead.value) {
  53131. case 'any':
  53132. lex();
  53133. return markerApply(marker, delegate.createAnyTypeAnnotation());
  53134. case 'bool': // fallthrough
  53135. case 'boolean':
  53136. lex();
  53137. return markerApply(marker, delegate.createBooleanTypeAnnotation());
  53138. case 'number':
  53139. lex();
  53140. return markerApply(marker, delegate.createNumberTypeAnnotation());
  53141. case 'string':
  53142. lex();
  53143. return markerApply(marker, delegate.createStringTypeAnnotation());
  53144. }
  53145. return markerApply(marker, parseGenericType());
  53146. case Token.Punctuator:
  53147. switch (lookahead.value) {
  53148. case '{':
  53149. return markerApply(marker, parseObjectType());
  53150. case '[':
  53151. return parseTupleType();
  53152. case '<':
  53153. typeParameters = parseTypeParameterDeclaration();
  53154. expect('(');
  53155. tmp = parseFunctionTypeParams();
  53156. params = tmp.params;
  53157. rest = tmp.rest;
  53158. expect(')');
  53159. expect('=>');
  53160. returnType = parseType();
  53161. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  53162. params,
  53163. returnType,
  53164. rest,
  53165. typeParameters
  53166. ));
  53167. case '(':
  53168. lex();
  53169. // Check to see if this is actually a grouped type
  53170. if (!match(')') && !match('...')) {
  53171. if (lookahead.type === Token.Identifier) {
  53172. token = lookahead2();
  53173. isGroupedType = token.value !== '?' && token.value !== ':';
  53174. } else {
  53175. isGroupedType = true;
  53176. }
  53177. }
  53178. if (isGroupedType) {
  53179. type = parseType();
  53180. expect(')');
  53181. // If we see a => next then someone was probably confused about
  53182. // function types, so we can provide a better error message
  53183. if (match('=>')) {
  53184. throwError({}, Messages.ConfusedAboutFunctionType);
  53185. }
  53186. return type;
  53187. }
  53188. tmp = parseFunctionTypeParams();
  53189. params = tmp.params;
  53190. rest = tmp.rest;
  53191. expect(')');
  53192. expect('=>');
  53193. returnType = parseType();
  53194. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  53195. params,
  53196. returnType,
  53197. rest,
  53198. null /* typeParameters */
  53199. ));
  53200. }
  53201. break;
  53202. case Token.Keyword:
  53203. switch (lookahead.value) {
  53204. case 'void':
  53205. return markerApply(marker, parseVoidType());
  53206. case 'typeof':
  53207. return markerApply(marker, parseTypeofType());
  53208. }
  53209. break;
  53210. case Token.StringLiteral:
  53211. token = lex();
  53212. if (token.octal) {
  53213. throwError(token, Messages.StrictOctalLiteral);
  53214. }
  53215. return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
  53216. token
  53217. ));
  53218. }
  53219. throwUnexpected(lookahead);
  53220. }
  53221. function parsePostfixType() {
  53222. var marker = markerCreate(), t = parsePrimaryType();
  53223. if (match('[')) {
  53224. expect('[');
  53225. expect(']');
  53226. return markerApply(marker, delegate.createArrayTypeAnnotation(t));
  53227. }
  53228. return t;
  53229. }
  53230. function parsePrefixType() {
  53231. var marker = markerCreate();
  53232. if (match('?')) {
  53233. lex();
  53234. return markerApply(marker, delegate.createNullableTypeAnnotation(
  53235. parsePrefixType()
  53236. ));
  53237. }
  53238. return parsePostfixType();
  53239. }
  53240. function parseIntersectionType() {
  53241. var marker = markerCreate(), type, types;
  53242. type = parsePrefixType();
  53243. types = [type];
  53244. while (match('&')) {
  53245. lex();
  53246. types.push(parsePrefixType());
  53247. }
  53248. return types.length === 1 ?
  53249. type :
  53250. markerApply(marker, delegate.createIntersectionTypeAnnotation(
  53251. types
  53252. ));
  53253. }
  53254. function parseUnionType() {
  53255. var marker = markerCreate(), type, types;
  53256. type = parseIntersectionType();
  53257. types = [type];
  53258. while (match('|')) {
  53259. lex();
  53260. types.push(parseIntersectionType());
  53261. }
  53262. return types.length === 1 ?
  53263. type :
  53264. markerApply(marker, delegate.createUnionTypeAnnotation(
  53265. types
  53266. ));
  53267. }
  53268. function parseType() {
  53269. var oldInType = state.inType, type;
  53270. state.inType = true;
  53271. type = parseUnionType();
  53272. state.inType = oldInType;
  53273. return type;
  53274. }
  53275. function parseTypeAnnotation() {
  53276. var marker = markerCreate(), type;
  53277. expect(':');
  53278. type = parseType();
  53279. return markerApply(marker, delegate.createTypeAnnotation(type));
  53280. }
  53281. function parseVariableIdentifier() {
  53282. var marker = markerCreate(),
  53283. token = lex();
  53284. if (token.type !== Token.Identifier) {
  53285. throwUnexpected(token);
  53286. }
  53287. return markerApply(marker, delegate.createIdentifier(token.value));
  53288. }
  53289. function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
  53290. var marker = markerCreate(),
  53291. ident = parseVariableIdentifier(),
  53292. isOptionalParam = false;
  53293. if (canBeOptionalParam && match('?')) {
  53294. expect('?');
  53295. isOptionalParam = true;
  53296. }
  53297. if (requireTypeAnnotation || match(':')) {
  53298. ident.typeAnnotation = parseTypeAnnotation();
  53299. ident = markerApply(marker, ident);
  53300. }
  53301. if (isOptionalParam) {
  53302. ident.optional = true;
  53303. ident = markerApply(marker, ident);
  53304. }
  53305. return ident;
  53306. }
  53307. function parseVariableDeclaration(kind) {
  53308. var id,
  53309. marker = markerCreate(),
  53310. init = null,
  53311. typeAnnotationMarker = markerCreate();
  53312. if (match('{')) {
  53313. id = parseObjectInitialiser();
  53314. reinterpretAsAssignmentBindingPattern(id);
  53315. if (match(':')) {
  53316. id.typeAnnotation = parseTypeAnnotation();
  53317. markerApply(typeAnnotationMarker, id);
  53318. }
  53319. } else if (match('[')) {
  53320. id = parseArrayInitialiser();
  53321. reinterpretAsAssignmentBindingPattern(id);
  53322. if (match(':')) {
  53323. id.typeAnnotation = parseTypeAnnotation();
  53324. markerApply(typeAnnotationMarker, id);
  53325. }
  53326. } else {
  53327. /* istanbul ignore next */
  53328. id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
  53329. // 12.2.1
  53330. if (strict && isRestrictedWord(id.name)) {
  53331. throwErrorTolerant({}, Messages.StrictVarName);
  53332. }
  53333. }
  53334. if (kind === 'const') {
  53335. if (!match('=')) {
  53336. throwError({}, Messages.NoUninitializedConst);
  53337. }
  53338. expect('=');
  53339. init = parseAssignmentExpression();
  53340. } else if (match('=')) {
  53341. lex();
  53342. init = parseAssignmentExpression();
  53343. }
  53344. return markerApply(marker, delegate.createVariableDeclarator(id, init));
  53345. }
  53346. function parseVariableDeclarationList(kind) {
  53347. var list = [];
  53348. do {
  53349. list.push(parseVariableDeclaration(kind));
  53350. if (!match(',')) {
  53351. break;
  53352. }
  53353. lex();
  53354. } while (index < length);
  53355. return list;
  53356. }
  53357. function parseVariableStatement() {
  53358. var declarations, marker = markerCreate();
  53359. expectKeyword('var');
  53360. declarations = parseVariableDeclarationList();
  53361. consumeSemicolon();
  53362. return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
  53363. }
  53364. // kind may be `const` or `let`
  53365. // Both are experimental and not in the specification yet.
  53366. // see http://wiki.ecmascript.org/doku.php?id=harmony:const
  53367. // and http://wiki.ecmascript.org/doku.php?id=harmony:let
  53368. function parseConstLetDeclaration(kind) {
  53369. var declarations, marker = markerCreate();
  53370. expectKeyword(kind);
  53371. declarations = parseVariableDeclarationList(kind);
  53372. consumeSemicolon();
  53373. return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
  53374. }
  53375. // people.mozilla.org/~jorendorff/es6-draft.html
  53376. function parseModuleSpecifier() {
  53377. var marker = markerCreate(),
  53378. specifier;
  53379. if (lookahead.type !== Token.StringLiteral) {
  53380. throwError({}, Messages.InvalidModuleSpecifier);
  53381. }
  53382. specifier = delegate.createModuleSpecifier(lookahead);
  53383. lex();
  53384. return markerApply(marker, specifier);
  53385. }
  53386. function parseExportBatchSpecifier() {
  53387. var marker = markerCreate();
  53388. expect('*');
  53389. return markerApply(marker, delegate.createExportBatchSpecifier());
  53390. }
  53391. function parseExportSpecifier() {
  53392. var id, name = null, marker = markerCreate(), from;
  53393. if (matchKeyword('default')) {
  53394. lex();
  53395. id = markerApply(marker, delegate.createIdentifier('default'));
  53396. // export {default} from "something";
  53397. } else {
  53398. id = parseVariableIdentifier();
  53399. }
  53400. if (matchContextualKeyword('as')) {
  53401. lex();
  53402. name = parseNonComputedProperty();
  53403. }
  53404. return markerApply(marker, delegate.createExportSpecifier(id, name));
  53405. }
  53406. function parseExportDeclaration() {
  53407. var declaration = null,
  53408. possibleIdentifierToken, sourceElement,
  53409. isExportFromIdentifier,
  53410. src = null, specifiers = [],
  53411. marker = markerCreate();
  53412. expectKeyword('export');
  53413. if (matchKeyword('default')) {
  53414. // covers:
  53415. // export default ...
  53416. lex();
  53417. if (matchKeyword('function') || matchKeyword('class')) {
  53418. possibleIdentifierToken = lookahead2();
  53419. if (isIdentifierName(possibleIdentifierToken)) {
  53420. // covers:
  53421. // export default function foo () {}
  53422. // export default class foo {}
  53423. sourceElement = parseSourceElement();
  53424. return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
  53425. }
  53426. // covers:
  53427. // export default function () {}
  53428. // export default class {}
  53429. switch (lookahead.value) {
  53430. case 'class':
  53431. return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
  53432. case 'function':
  53433. return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
  53434. }
  53435. }
  53436. if (matchContextualKeyword('from')) {
  53437. throwError({}, Messages.UnexpectedToken, lookahead.value);
  53438. }
  53439. // covers:
  53440. // export default {};
  53441. // export default [];
  53442. if (match('{')) {
  53443. declaration = parseObjectInitialiser();
  53444. } else if (match('[')) {
  53445. declaration = parseArrayInitialiser();
  53446. } else {
  53447. declaration = parseAssignmentExpression();
  53448. }
  53449. consumeSemicolon();
  53450. return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
  53451. }
  53452. // non-default export
  53453. if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
  53454. // covers:
  53455. // export var f = 1;
  53456. switch (lookahead.value) {
  53457. case 'type':
  53458. case 'let':
  53459. case 'const':
  53460. case 'var':
  53461. case 'class':
  53462. case 'function':
  53463. return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
  53464. }
  53465. }
  53466. if (match('*')) {
  53467. // covers:
  53468. // export * from "foo";
  53469. specifiers.push(parseExportBatchSpecifier());
  53470. if (!matchContextualKeyword('from')) {
  53471. throwError({}, lookahead.value ?
  53472. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  53473. }
  53474. lex();
  53475. src = parseModuleSpecifier();
  53476. consumeSemicolon();
  53477. return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
  53478. }
  53479. expect('{');
  53480. if (!match('}')) {
  53481. do {
  53482. isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
  53483. specifiers.push(parseExportSpecifier());
  53484. } while (match(',') && lex());
  53485. }
  53486. expect('}');
  53487. if (matchContextualKeyword('from')) {
  53488. // covering:
  53489. // export {default} from "foo";
  53490. // export {foo} from "foo";
  53491. lex();
  53492. src = parseModuleSpecifier();
  53493. consumeSemicolon();
  53494. } else if (isExportFromIdentifier) {
  53495. // covering:
  53496. // export {default}; // missing fromClause
  53497. throwError({}, lookahead.value ?
  53498. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  53499. } else {
  53500. // cover
  53501. // export {foo};
  53502. consumeSemicolon();
  53503. }
  53504. return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
  53505. }
  53506. function parseImportSpecifier() {
  53507. // import {<foo as bar>} ...;
  53508. var id, name = null, marker = markerCreate();
  53509. id = parseNonComputedProperty();
  53510. if (matchContextualKeyword('as')) {
  53511. lex();
  53512. name = parseVariableIdentifier();
  53513. }
  53514. return markerApply(marker, delegate.createImportSpecifier(id, name));
  53515. }
  53516. function parseNamedImports() {
  53517. var specifiers = [];
  53518. // {foo, bar as bas}
  53519. expect('{');
  53520. if (!match('}')) {
  53521. do {
  53522. specifiers.push(parseImportSpecifier());
  53523. } while (match(',') && lex());
  53524. }
  53525. expect('}');
  53526. return specifiers;
  53527. }
  53528. function parseImportDefaultSpecifier() {
  53529. // import <foo> ...;
  53530. var id, marker = markerCreate();
  53531. id = parseNonComputedProperty();
  53532. return markerApply(marker, delegate.createImportDefaultSpecifier(id));
  53533. }
  53534. function parseImportNamespaceSpecifier() {
  53535. // import <* as foo> ...;
  53536. var id, marker = markerCreate();
  53537. expect('*');
  53538. if (!matchContextualKeyword('as')) {
  53539. throwError({}, Messages.NoAsAfterImportNamespace);
  53540. }
  53541. lex();
  53542. id = parseNonComputedProperty();
  53543. return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
  53544. }
  53545. function parseImportDeclaration() {
  53546. var specifiers, src, marker = markerCreate(), isType = false, token2;
  53547. expectKeyword('import');
  53548. if (matchContextualKeyword('type')) {
  53549. token2 = lookahead2();
  53550. if ((token2.type === Token.Identifier && token2.value !== 'from') ||
  53551. (token2.type === Token.Punctuator &&
  53552. (token2.value === '{' || token2.value === '*'))) {
  53553. isType = true;
  53554. lex();
  53555. }
  53556. }
  53557. specifiers = [];
  53558. if (lookahead.type === Token.StringLiteral) {
  53559. // covers:
  53560. // import "foo";
  53561. src = parseModuleSpecifier();
  53562. consumeSemicolon();
  53563. return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
  53564. }
  53565. if (!matchKeyword('default') && isIdentifierName(lookahead)) {
  53566. // covers:
  53567. // import foo
  53568. // import foo, ...
  53569. specifiers.push(parseImportDefaultSpecifier());
  53570. if (match(',')) {
  53571. lex();
  53572. }
  53573. }
  53574. if (match('*')) {
  53575. // covers:
  53576. // import foo, * as foo
  53577. // import * as foo
  53578. specifiers.push(parseImportNamespaceSpecifier());
  53579. } else if (match('{')) {
  53580. // covers:
  53581. // import foo, {bar}
  53582. // import {bar}
  53583. specifiers = specifiers.concat(parseNamedImports());
  53584. }
  53585. if (!matchContextualKeyword('from')) {
  53586. throwError({}, lookahead.value ?
  53587. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  53588. }
  53589. lex();
  53590. src = parseModuleSpecifier();
  53591. consumeSemicolon();
  53592. return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
  53593. }
  53594. // 12.3 Empty Statement
  53595. function parseEmptyStatement() {
  53596. var marker = markerCreate();
  53597. expect(';');
  53598. return markerApply(marker, delegate.createEmptyStatement());
  53599. }
  53600. // 12.4 Expression Statement
  53601. function parseExpressionStatement() {
  53602. var marker = markerCreate(), expr = parseExpression();
  53603. consumeSemicolon();
  53604. return markerApply(marker, delegate.createExpressionStatement(expr));
  53605. }
  53606. // 12.5 If statement
  53607. function parseIfStatement() {
  53608. var test, consequent, alternate, marker = markerCreate();
  53609. expectKeyword('if');
  53610. expect('(');
  53611. test = parseExpression();
  53612. expect(')');
  53613. consequent = parseStatement();
  53614. if (matchKeyword('else')) {
  53615. lex();
  53616. alternate = parseStatement();
  53617. } else {
  53618. alternate = null;
  53619. }
  53620. return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
  53621. }
  53622. // 12.6 Iteration Statements
  53623. function parseDoWhileStatement() {
  53624. var body, test, oldInIteration, marker = markerCreate();
  53625. expectKeyword('do');
  53626. oldInIteration = state.inIteration;
  53627. state.inIteration = true;
  53628. body = parseStatement();
  53629. state.inIteration = oldInIteration;
  53630. expectKeyword('while');
  53631. expect('(');
  53632. test = parseExpression();
  53633. expect(')');
  53634. if (match(';')) {
  53635. lex();
  53636. }
  53637. return markerApply(marker, delegate.createDoWhileStatement(body, test));
  53638. }
  53639. function parseWhileStatement() {
  53640. var test, body, oldInIteration, marker = markerCreate();
  53641. expectKeyword('while');
  53642. expect('(');
  53643. test = parseExpression();
  53644. expect(')');
  53645. oldInIteration = state.inIteration;
  53646. state.inIteration = true;
  53647. body = parseStatement();
  53648. state.inIteration = oldInIteration;
  53649. return markerApply(marker, delegate.createWhileStatement(test, body));
  53650. }
  53651. function parseForVariableDeclaration() {
  53652. var marker = markerCreate(),
  53653. token = lex(),
  53654. declarations = parseVariableDeclarationList();
  53655. return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
  53656. }
  53657. function parseForStatement(opts) {
  53658. var init, test, update, left, right, body, operator, oldInIteration,
  53659. marker = markerCreate();
  53660. init = test = update = null;
  53661. expectKeyword('for');
  53662. // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
  53663. if (matchContextualKeyword('each')) {
  53664. throwError({}, Messages.EachNotAllowed);
  53665. }
  53666. expect('(');
  53667. if (match(';')) {
  53668. lex();
  53669. } else {
  53670. if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
  53671. state.allowIn = false;
  53672. init = parseForVariableDeclaration();
  53673. state.allowIn = true;
  53674. if (init.declarations.length === 1) {
  53675. if (matchKeyword('in') || matchContextualKeyword('of')) {
  53676. operator = lookahead;
  53677. if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
  53678. lex();
  53679. left = init;
  53680. right = parseExpression();
  53681. init = null;
  53682. }
  53683. }
  53684. }
  53685. } else {
  53686. state.allowIn = false;
  53687. init = parseExpression();
  53688. state.allowIn = true;
  53689. if (matchContextualKeyword('of')) {
  53690. operator = lex();
  53691. left = init;
  53692. right = parseExpression();
  53693. init = null;
  53694. } else if (matchKeyword('in')) {
  53695. // LeftHandSideExpression
  53696. if (!isAssignableLeftHandSide(init)) {
  53697. throwError({}, Messages.InvalidLHSInForIn);
  53698. }
  53699. operator = lex();
  53700. left = init;
  53701. right = parseExpression();
  53702. init = null;
  53703. }
  53704. }
  53705. if (typeof left === 'undefined') {
  53706. expect(';');
  53707. }
  53708. }
  53709. if (typeof left === 'undefined') {
  53710. if (!match(';')) {
  53711. test = parseExpression();
  53712. }
  53713. expect(';');
  53714. if (!match(')')) {
  53715. update = parseExpression();
  53716. }
  53717. }
  53718. expect(')');
  53719. oldInIteration = state.inIteration;
  53720. state.inIteration = true;
  53721. if (!(opts !== undefined && opts.ignoreBody)) {
  53722. body = parseStatement();
  53723. }
  53724. state.inIteration = oldInIteration;
  53725. if (typeof left === 'undefined') {
  53726. return markerApply(marker, delegate.createForStatement(init, test, update, body));
  53727. }
  53728. if (operator.value === 'in') {
  53729. return markerApply(marker, delegate.createForInStatement(left, right, body));
  53730. }
  53731. return markerApply(marker, delegate.createForOfStatement(left, right, body));
  53732. }
  53733. // 12.7 The continue statement
  53734. function parseContinueStatement() {
  53735. var label = null, marker = markerCreate();
  53736. expectKeyword('continue');
  53737. // Optimize the most common form: 'continue;'.
  53738. if (source.charCodeAt(index) === 59) {
  53739. lex();
  53740. if (!state.inIteration) {
  53741. throwError({}, Messages.IllegalContinue);
  53742. }
  53743. return markerApply(marker, delegate.createContinueStatement(null));
  53744. }
  53745. if (peekLineTerminator()) {
  53746. if (!state.inIteration) {
  53747. throwError({}, Messages.IllegalContinue);
  53748. }
  53749. return markerApply(marker, delegate.createContinueStatement(null));
  53750. }
  53751. if (lookahead.type === Token.Identifier) {
  53752. label = parseVariableIdentifier();
  53753. if (!state.labelSet.has(label.name)) {
  53754. throwError({}, Messages.UnknownLabel, label.name);
  53755. }
  53756. }
  53757. consumeSemicolon();
  53758. if (label === null && !state.inIteration) {
  53759. throwError({}, Messages.IllegalContinue);
  53760. }
  53761. return markerApply(marker, delegate.createContinueStatement(label));
  53762. }
  53763. // 12.8 The break statement
  53764. function parseBreakStatement() {
  53765. var label = null, marker = markerCreate();
  53766. expectKeyword('break');
  53767. // Catch the very common case first: immediately a semicolon (char #59).
  53768. if (source.charCodeAt(index) === 59) {
  53769. lex();
  53770. if (!(state.inIteration || state.inSwitch)) {
  53771. throwError({}, Messages.IllegalBreak);
  53772. }
  53773. return markerApply(marker, delegate.createBreakStatement(null));
  53774. }
  53775. if (peekLineTerminator()) {
  53776. if (!(state.inIteration || state.inSwitch)) {
  53777. throwError({}, Messages.IllegalBreak);
  53778. }
  53779. return markerApply(marker, delegate.createBreakStatement(null));
  53780. }
  53781. if (lookahead.type === Token.Identifier) {
  53782. label = parseVariableIdentifier();
  53783. if (!state.labelSet.has(label.name)) {
  53784. throwError({}, Messages.UnknownLabel, label.name);
  53785. }
  53786. }
  53787. consumeSemicolon();
  53788. if (label === null && !(state.inIteration || state.inSwitch)) {
  53789. throwError({}, Messages.IllegalBreak);
  53790. }
  53791. return markerApply(marker, delegate.createBreakStatement(label));
  53792. }
  53793. // 12.9 The return statement
  53794. function parseReturnStatement() {
  53795. var argument = null, marker = markerCreate();
  53796. expectKeyword('return');
  53797. if (!state.inFunctionBody) {
  53798. throwErrorTolerant({}, Messages.IllegalReturn);
  53799. }
  53800. // 'return' followed by a space and an identifier is very common.
  53801. if (source.charCodeAt(index) === 32) {
  53802. if (isIdentifierStart(source.charCodeAt(index + 1))) {
  53803. argument = parseExpression();
  53804. consumeSemicolon();
  53805. return markerApply(marker, delegate.createReturnStatement(argument));
  53806. }
  53807. }
  53808. if (peekLineTerminator()) {
  53809. return markerApply(marker, delegate.createReturnStatement(null));
  53810. }
  53811. if (!match(';')) {
  53812. if (!match('}') && lookahead.type !== Token.EOF) {
  53813. argument = parseExpression();
  53814. }
  53815. }
  53816. consumeSemicolon();
  53817. return markerApply(marker, delegate.createReturnStatement(argument));
  53818. }
  53819. // 12.10 The with statement
  53820. function parseWithStatement() {
  53821. var object, body, marker = markerCreate();
  53822. if (strict) {
  53823. throwErrorTolerant({}, Messages.StrictModeWith);
  53824. }
  53825. expectKeyword('with');
  53826. expect('(');
  53827. object = parseExpression();
  53828. expect(')');
  53829. body = parseStatement();
  53830. return markerApply(marker, delegate.createWithStatement(object, body));
  53831. }
  53832. // 12.10 The swith statement
  53833. function parseSwitchCase() {
  53834. var test,
  53835. consequent = [],
  53836. sourceElement,
  53837. marker = markerCreate();
  53838. if (matchKeyword('default')) {
  53839. lex();
  53840. test = null;
  53841. } else {
  53842. expectKeyword('case');
  53843. test = parseExpression();
  53844. }
  53845. expect(':');
  53846. while (index < length) {
  53847. if (match('}') || matchKeyword('default') || matchKeyword('case')) {
  53848. break;
  53849. }
  53850. sourceElement = parseSourceElement();
  53851. if (typeof sourceElement === 'undefined') {
  53852. break;
  53853. }
  53854. consequent.push(sourceElement);
  53855. }
  53856. return markerApply(marker, delegate.createSwitchCase(test, consequent));
  53857. }
  53858. function parseSwitchStatement() {
  53859. var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
  53860. expectKeyword('switch');
  53861. expect('(');
  53862. discriminant = parseExpression();
  53863. expect(')');
  53864. expect('{');
  53865. cases = [];
  53866. if (match('}')) {
  53867. lex();
  53868. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  53869. }
  53870. oldInSwitch = state.inSwitch;
  53871. state.inSwitch = true;
  53872. defaultFound = false;
  53873. while (index < length) {
  53874. if (match('}')) {
  53875. break;
  53876. }
  53877. clause = parseSwitchCase();
  53878. if (clause.test === null) {
  53879. if (defaultFound) {
  53880. throwError({}, Messages.MultipleDefaultsInSwitch);
  53881. }
  53882. defaultFound = true;
  53883. }
  53884. cases.push(clause);
  53885. }
  53886. state.inSwitch = oldInSwitch;
  53887. expect('}');
  53888. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  53889. }
  53890. // 12.13 The throw statement
  53891. function parseThrowStatement() {
  53892. var argument, marker = markerCreate();
  53893. expectKeyword('throw');
  53894. if (peekLineTerminator()) {
  53895. throwError({}, Messages.NewlineAfterThrow);
  53896. }
  53897. argument = parseExpression();
  53898. consumeSemicolon();
  53899. return markerApply(marker, delegate.createThrowStatement(argument));
  53900. }
  53901. // 12.14 The try statement
  53902. function parseCatchClause() {
  53903. var param, body, marker = markerCreate();
  53904. expectKeyword('catch');
  53905. expect('(');
  53906. if (match(')')) {
  53907. throwUnexpected(lookahead);
  53908. }
  53909. param = parseExpression();
  53910. // 12.14.1
  53911. if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
  53912. throwErrorTolerant({}, Messages.StrictCatchVariable);
  53913. }
  53914. expect(')');
  53915. body = parseBlock();
  53916. return markerApply(marker, delegate.createCatchClause(param, body));
  53917. }
  53918. function parseTryStatement() {
  53919. var block, handlers = [], finalizer = null, marker = markerCreate();
  53920. expectKeyword('try');
  53921. block = parseBlock();
  53922. if (matchKeyword('catch')) {
  53923. handlers.push(parseCatchClause());
  53924. }
  53925. if (matchKeyword('finally')) {
  53926. lex();
  53927. finalizer = parseBlock();
  53928. }
  53929. if (handlers.length === 0 && !finalizer) {
  53930. throwError({}, Messages.NoCatchOrFinally);
  53931. }
  53932. return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
  53933. }
  53934. // 12.15 The debugger statement
  53935. function parseDebuggerStatement() {
  53936. var marker = markerCreate();
  53937. expectKeyword('debugger');
  53938. consumeSemicolon();
  53939. return markerApply(marker, delegate.createDebuggerStatement());
  53940. }
  53941. // 12 Statements
  53942. function parseStatement() {
  53943. var type = lookahead.type,
  53944. marker,
  53945. expr,
  53946. labeledBody;
  53947. if (type === Token.EOF) {
  53948. throwUnexpected(lookahead);
  53949. }
  53950. if (type === Token.Punctuator) {
  53951. switch (lookahead.value) {
  53952. case ';':
  53953. return parseEmptyStatement();
  53954. case '{':
  53955. return parseBlock();
  53956. case '(':
  53957. return parseExpressionStatement();
  53958. default:
  53959. break;
  53960. }
  53961. }
  53962. if (type === Token.Keyword) {
  53963. switch (lookahead.value) {
  53964. case 'break':
  53965. return parseBreakStatement();
  53966. case 'continue':
  53967. return parseContinueStatement();
  53968. case 'debugger':
  53969. return parseDebuggerStatement();
  53970. case 'do':
  53971. return parseDoWhileStatement();
  53972. case 'for':
  53973. return parseForStatement();
  53974. case 'function':
  53975. return parseFunctionDeclaration();
  53976. case 'class':
  53977. return parseClassDeclaration();
  53978. case 'if':
  53979. return parseIfStatement();
  53980. case 'return':
  53981. return parseReturnStatement();
  53982. case 'switch':
  53983. return parseSwitchStatement();
  53984. case 'throw':
  53985. return parseThrowStatement();
  53986. case 'try':
  53987. return parseTryStatement();
  53988. case 'var':
  53989. return parseVariableStatement();
  53990. case 'while':
  53991. return parseWhileStatement();
  53992. case 'with':
  53993. return parseWithStatement();
  53994. default:
  53995. break;
  53996. }
  53997. }
  53998. if (matchAsyncFuncExprOrDecl()) {
  53999. return parseFunctionDeclaration();
  54000. }
  54001. marker = markerCreate();
  54002. expr = parseExpression();
  54003. // 12.12 Labelled Statements
  54004. if ((expr.type === Syntax.Identifier) && match(':')) {
  54005. lex();
  54006. if (state.labelSet.has(expr.name)) {
  54007. throwError({}, Messages.Redeclaration, 'Label', expr.name);
  54008. }
  54009. state.labelSet.set(expr.name, true);
  54010. labeledBody = parseStatement();
  54011. state.labelSet.delete(expr.name);
  54012. return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
  54013. }
  54014. consumeSemicolon();
  54015. return markerApply(marker, delegate.createExpressionStatement(expr));
  54016. }
  54017. // 13 Function Definition
  54018. function parseConciseBody() {
  54019. if (match('{')) {
  54020. return parseFunctionSourceElements();
  54021. }
  54022. return parseAssignmentExpression();
  54023. }
  54024. function parseFunctionSourceElements() {
  54025. var sourceElement, sourceElements = [], token, directive, firstRestricted,
  54026. oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
  54027. marker = markerCreate();
  54028. expect('{');
  54029. while (index < length) {
  54030. if (lookahead.type !== Token.StringLiteral) {
  54031. break;
  54032. }
  54033. token = lookahead;
  54034. sourceElement = parseSourceElement();
  54035. sourceElements.push(sourceElement);
  54036. if (sourceElement.expression.type !== Syntax.Literal) {
  54037. // this is not directive
  54038. break;
  54039. }
  54040. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  54041. if (directive === 'use strict') {
  54042. strict = true;
  54043. if (firstRestricted) {
  54044. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  54045. }
  54046. } else {
  54047. if (!firstRestricted && token.octal) {
  54048. firstRestricted = token;
  54049. }
  54050. }
  54051. }
  54052. oldLabelSet = state.labelSet;
  54053. oldInIteration = state.inIteration;
  54054. oldInSwitch = state.inSwitch;
  54055. oldInFunctionBody = state.inFunctionBody;
  54056. oldParenthesizedCount = state.parenthesizedCount;
  54057. state.labelSet = new StringMap();
  54058. state.inIteration = false;
  54059. state.inSwitch = false;
  54060. state.inFunctionBody = true;
  54061. state.parenthesizedCount = 0;
  54062. while (index < length) {
  54063. if (match('}')) {
  54064. break;
  54065. }
  54066. sourceElement = parseSourceElement();
  54067. if (typeof sourceElement === 'undefined') {
  54068. break;
  54069. }
  54070. sourceElements.push(sourceElement);
  54071. }
  54072. expect('}');
  54073. state.labelSet = oldLabelSet;
  54074. state.inIteration = oldInIteration;
  54075. state.inSwitch = oldInSwitch;
  54076. state.inFunctionBody = oldInFunctionBody;
  54077. state.parenthesizedCount = oldParenthesizedCount;
  54078. return markerApply(marker, delegate.createBlockStatement(sourceElements));
  54079. }
  54080. function validateParam(options, param, name) {
  54081. if (strict) {
  54082. if (isRestrictedWord(name)) {
  54083. options.stricted = param;
  54084. options.message = Messages.StrictParamName;
  54085. }
  54086. if (options.paramSet.has(name)) {
  54087. options.stricted = param;
  54088. options.message = Messages.StrictParamDupe;
  54089. }
  54090. } else if (!options.firstRestricted) {
  54091. if (isRestrictedWord(name)) {
  54092. options.firstRestricted = param;
  54093. options.message = Messages.StrictParamName;
  54094. } else if (isStrictModeReservedWord(name)) {
  54095. options.firstRestricted = param;
  54096. options.message = Messages.StrictReservedWord;
  54097. } else if (options.paramSet.has(name)) {
  54098. options.firstRestricted = param;
  54099. options.message = Messages.StrictParamDupe;
  54100. }
  54101. }
  54102. options.paramSet.set(name, true);
  54103. }
  54104. function parseParam(options) {
  54105. var marker, token, rest, param, def;
  54106. token = lookahead;
  54107. if (token.value === '...') {
  54108. token = lex();
  54109. rest = true;
  54110. }
  54111. if (match('[')) {
  54112. marker = markerCreate();
  54113. param = parseArrayInitialiser();
  54114. reinterpretAsDestructuredParameter(options, param);
  54115. if (match(':')) {
  54116. param.typeAnnotation = parseTypeAnnotation();
  54117. markerApply(marker, param);
  54118. }
  54119. } else if (match('{')) {
  54120. marker = markerCreate();
  54121. if (rest) {
  54122. throwError({}, Messages.ObjectPatternAsRestParameter);
  54123. }
  54124. param = parseObjectInitialiser();
  54125. reinterpretAsDestructuredParameter(options, param);
  54126. if (match(':')) {
  54127. param.typeAnnotation = parseTypeAnnotation();
  54128. markerApply(marker, param);
  54129. }
  54130. } else {
  54131. param =
  54132. rest
  54133. ? parseTypeAnnotatableIdentifier(
  54134. false, /* requireTypeAnnotation */
  54135. false /* canBeOptionalParam */
  54136. )
  54137. : parseTypeAnnotatableIdentifier(
  54138. false, /* requireTypeAnnotation */
  54139. true /* canBeOptionalParam */
  54140. );
  54141. validateParam(options, token, token.value);
  54142. }
  54143. if (match('=')) {
  54144. if (rest) {
  54145. throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
  54146. }
  54147. lex();
  54148. def = parseAssignmentExpression();
  54149. ++options.defaultCount;
  54150. }
  54151. if (rest) {
  54152. if (!match(')')) {
  54153. throwError({}, Messages.ParameterAfterRestParameter);
  54154. }
  54155. options.rest = param;
  54156. return false;
  54157. }
  54158. options.params.push(param);
  54159. options.defaults.push(def);
  54160. return !match(')');
  54161. }
  54162. function parseParams(firstRestricted) {
  54163. var options, marker = markerCreate();
  54164. options = {
  54165. params: [],
  54166. defaultCount: 0,
  54167. defaults: [],
  54168. rest: null,
  54169. firstRestricted: firstRestricted
  54170. };
  54171. expect('(');
  54172. if (!match(')')) {
  54173. options.paramSet = new StringMap();
  54174. while (index < length) {
  54175. if (!parseParam(options)) {
  54176. break;
  54177. }
  54178. expect(',');
  54179. }
  54180. }
  54181. expect(')');
  54182. if (options.defaultCount === 0) {
  54183. options.defaults = [];
  54184. }
  54185. if (match(':')) {
  54186. options.returnType = parseTypeAnnotation();
  54187. }
  54188. return markerApply(marker, options);
  54189. }
  54190. function parseFunctionDeclaration() {
  54191. var id, body, token, tmp, firstRestricted, message, generator, isAsync,
  54192. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  54193. marker = markerCreate(), typeParameters;
  54194. isAsync = false;
  54195. if (matchAsync()) {
  54196. lex();
  54197. isAsync = true;
  54198. }
  54199. expectKeyword('function');
  54200. generator = false;
  54201. if (match('*')) {
  54202. lex();
  54203. generator = true;
  54204. }
  54205. token = lookahead;
  54206. id = parseVariableIdentifier();
  54207. if (match('<')) {
  54208. typeParameters = parseTypeParameterDeclaration();
  54209. }
  54210. if (strict) {
  54211. if (isRestrictedWord(token.value)) {
  54212. throwErrorTolerant(token, Messages.StrictFunctionName);
  54213. }
  54214. } else {
  54215. if (isRestrictedWord(token.value)) {
  54216. firstRestricted = token;
  54217. message = Messages.StrictFunctionName;
  54218. } else if (isStrictModeReservedWord(token.value)) {
  54219. firstRestricted = token;
  54220. message = Messages.StrictReservedWord;
  54221. }
  54222. }
  54223. tmp = parseParams(firstRestricted);
  54224. firstRestricted = tmp.firstRestricted;
  54225. if (tmp.message) {
  54226. message = tmp.message;
  54227. }
  54228. previousStrict = strict;
  54229. previousYieldAllowed = state.yieldAllowed;
  54230. state.yieldAllowed = generator;
  54231. previousAwaitAllowed = state.awaitAllowed;
  54232. state.awaitAllowed = isAsync;
  54233. body = parseFunctionSourceElements();
  54234. if (strict && firstRestricted) {
  54235. throwError(firstRestricted, message);
  54236. }
  54237. if (strict && tmp.stricted) {
  54238. throwErrorTolerant(tmp.stricted, message);
  54239. }
  54240. strict = previousStrict;
  54241. state.yieldAllowed = previousYieldAllowed;
  54242. state.awaitAllowed = previousAwaitAllowed;
  54243. return markerApply(
  54244. marker,
  54245. delegate.createFunctionDeclaration(
  54246. id,
  54247. tmp.params,
  54248. tmp.defaults,
  54249. body,
  54250. tmp.rest,
  54251. generator,
  54252. false,
  54253. isAsync,
  54254. tmp.returnType,
  54255. typeParameters
  54256. )
  54257. );
  54258. }
  54259. function parseFunctionExpression() {
  54260. var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
  54261. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  54262. marker = markerCreate(), typeParameters;
  54263. isAsync = false;
  54264. if (matchAsync()) {
  54265. lex();
  54266. isAsync = true;
  54267. }
  54268. expectKeyword('function');
  54269. generator = false;
  54270. if (match('*')) {
  54271. lex();
  54272. generator = true;
  54273. }
  54274. if (!match('(')) {
  54275. if (!match('<')) {
  54276. token = lookahead;
  54277. id = parseVariableIdentifier();
  54278. if (strict) {
  54279. if (isRestrictedWord(token.value)) {
  54280. throwErrorTolerant(token, Messages.StrictFunctionName);
  54281. }
  54282. } else {
  54283. if (isRestrictedWord(token.value)) {
  54284. firstRestricted = token;
  54285. message = Messages.StrictFunctionName;
  54286. } else if (isStrictModeReservedWord(token.value)) {
  54287. firstRestricted = token;
  54288. message = Messages.StrictReservedWord;
  54289. }
  54290. }
  54291. }
  54292. if (match('<')) {
  54293. typeParameters = parseTypeParameterDeclaration();
  54294. }
  54295. }
  54296. tmp = parseParams(firstRestricted);
  54297. firstRestricted = tmp.firstRestricted;
  54298. if (tmp.message) {
  54299. message = tmp.message;
  54300. }
  54301. previousStrict = strict;
  54302. previousYieldAllowed = state.yieldAllowed;
  54303. state.yieldAllowed = generator;
  54304. previousAwaitAllowed = state.awaitAllowed;
  54305. state.awaitAllowed = isAsync;
  54306. body = parseFunctionSourceElements();
  54307. if (strict && firstRestricted) {
  54308. throwError(firstRestricted, message);
  54309. }
  54310. if (strict && tmp.stricted) {
  54311. throwErrorTolerant(tmp.stricted, message);
  54312. }
  54313. strict = previousStrict;
  54314. state.yieldAllowed = previousYieldAllowed;
  54315. state.awaitAllowed = previousAwaitAllowed;
  54316. return markerApply(
  54317. marker,
  54318. delegate.createFunctionExpression(
  54319. id,
  54320. tmp.params,
  54321. tmp.defaults,
  54322. body,
  54323. tmp.rest,
  54324. generator,
  54325. false,
  54326. isAsync,
  54327. tmp.returnType,
  54328. typeParameters
  54329. )
  54330. );
  54331. }
  54332. function parseYieldExpression() {
  54333. var delegateFlag, expr, marker = markerCreate();
  54334. expectKeyword('yield', !strict);
  54335. delegateFlag = false;
  54336. if (match('*')) {
  54337. lex();
  54338. delegateFlag = true;
  54339. }
  54340. expr = parseAssignmentExpression();
  54341. return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
  54342. }
  54343. function parseAwaitExpression() {
  54344. var expr, marker = markerCreate();
  54345. expectContextualKeyword('await');
  54346. expr = parseAssignmentExpression();
  54347. return markerApply(marker, delegate.createAwaitExpression(expr));
  54348. }
  54349. // 14 Functions and classes
  54350. // 14.1 Functions is defined above (13 in ES5)
  54351. // 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
  54352. // 14.3 Method Definitions
  54353. // 14.3.7
  54354. function specialMethod(methodDefinition) {
  54355. return methodDefinition.kind === 'get' ||
  54356. methodDefinition.kind === 'set' ||
  54357. methodDefinition.value.generator;
  54358. }
  54359. function parseMethodDefinition(key, isStatic, generator, computed) {
  54360. var token, param, propType,
  54361. isAsync, typeParameters, tokenValue, returnType;
  54362. propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
  54363. if (generator) {
  54364. return delegate.createMethodDefinition(
  54365. propType,
  54366. '',
  54367. key,
  54368. parsePropertyMethodFunction({ generator: true }),
  54369. computed
  54370. );
  54371. }
  54372. tokenValue = key.type === 'Identifier' && key.name;
  54373. if (tokenValue === 'get' && !match('(')) {
  54374. key = parseObjectPropertyKey();
  54375. expect('(');
  54376. expect(')');
  54377. if (match(':')) {
  54378. returnType = parseTypeAnnotation();
  54379. }
  54380. return delegate.createMethodDefinition(
  54381. propType,
  54382. 'get',
  54383. key,
  54384. parsePropertyFunction({ generator: false, returnType: returnType }),
  54385. computed
  54386. );
  54387. }
  54388. if (tokenValue === 'set' && !match('(')) {
  54389. key = parseObjectPropertyKey();
  54390. expect('(');
  54391. token = lookahead;
  54392. param = [ parseTypeAnnotatableIdentifier() ];
  54393. expect(')');
  54394. if (match(':')) {
  54395. returnType = parseTypeAnnotation();
  54396. }
  54397. return delegate.createMethodDefinition(
  54398. propType,
  54399. 'set',
  54400. key,
  54401. parsePropertyFunction({
  54402. params: param,
  54403. generator: false,
  54404. name: token,
  54405. returnType: returnType
  54406. }),
  54407. computed
  54408. );
  54409. }
  54410. if (match('<')) {
  54411. typeParameters = parseTypeParameterDeclaration();
  54412. }
  54413. isAsync = tokenValue === 'async' && !match('(');
  54414. if (isAsync) {
  54415. key = parseObjectPropertyKey();
  54416. }
  54417. return delegate.createMethodDefinition(
  54418. propType,
  54419. '',
  54420. key,
  54421. parsePropertyMethodFunction({
  54422. generator: false,
  54423. async: isAsync,
  54424. typeParameters: typeParameters
  54425. }),
  54426. computed
  54427. );
  54428. }
  54429. function parseClassProperty(key, computed, isStatic) {
  54430. var typeAnnotation;
  54431. typeAnnotation = parseTypeAnnotation();
  54432. expect(';');
  54433. return delegate.createClassProperty(
  54434. key,
  54435. typeAnnotation,
  54436. computed,
  54437. isStatic
  54438. );
  54439. }
  54440. function parseClassElement() {
  54441. var computed = false, generator = false, key, marker = markerCreate(),
  54442. isStatic = false, possiblyOpenBracketToken;
  54443. if (match(';')) {
  54444. lex();
  54445. return undefined;
  54446. }
  54447. if (lookahead.value === 'static') {
  54448. lex();
  54449. isStatic = true;
  54450. }
  54451. if (match('*')) {
  54452. lex();
  54453. generator = true;
  54454. }
  54455. possiblyOpenBracketToken = lookahead;
  54456. if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
  54457. possiblyOpenBracketToken = lookahead2();
  54458. }
  54459. if (possiblyOpenBracketToken.type === Token.Punctuator
  54460. && possiblyOpenBracketToken.value === '[') {
  54461. computed = true;
  54462. }
  54463. key = parseObjectPropertyKey();
  54464. if (!generator && lookahead.value === ':') {
  54465. return markerApply(marker, parseClassProperty(key, computed, isStatic));
  54466. }
  54467. return markerApply(marker, parseMethodDefinition(
  54468. key,
  54469. isStatic,
  54470. generator,
  54471. computed
  54472. ));
  54473. }
  54474. function parseClassBody() {
  54475. var classElement, classElements = [], existingProps = {},
  54476. marker = markerCreate(), propName, propType;
  54477. existingProps[ClassPropertyType.static] = new StringMap();
  54478. existingProps[ClassPropertyType.prototype] = new StringMap();
  54479. expect('{');
  54480. while (index < length) {
  54481. if (match('}')) {
  54482. break;
  54483. }
  54484. classElement = parseClassElement(existingProps);
  54485. if (typeof classElement !== 'undefined') {
  54486. classElements.push(classElement);
  54487. propName = !classElement.computed && getFieldName(classElement.key);
  54488. if (propName !== false) {
  54489. propType = classElement.static ?
  54490. ClassPropertyType.static :
  54491. ClassPropertyType.prototype;
  54492. if (classElement.type === Syntax.MethodDefinition) {
  54493. if (propName === 'constructor' && !classElement.static) {
  54494. if (specialMethod(classElement)) {
  54495. throwError(classElement, Messages.IllegalClassConstructorProperty);
  54496. }
  54497. if (existingProps[ClassPropertyType.prototype].has('constructor')) {
  54498. throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
  54499. }
  54500. }
  54501. existingProps[propType].set(propName, true);
  54502. }
  54503. }
  54504. }
  54505. }
  54506. expect('}');
  54507. return markerApply(marker, delegate.createClassBody(classElements));
  54508. }
  54509. function parseClassImplements() {
  54510. var id, implemented = [], marker, typeParameters;
  54511. if (strict) {
  54512. expectKeyword('implements');
  54513. } else {
  54514. expectContextualKeyword('implements');
  54515. }
  54516. while (index < length) {
  54517. marker = markerCreate();
  54518. id = parseVariableIdentifier();
  54519. if (match('<')) {
  54520. typeParameters = parseTypeParameterInstantiation();
  54521. } else {
  54522. typeParameters = null;
  54523. }
  54524. implemented.push(markerApply(marker, delegate.createClassImplements(
  54525. id,
  54526. typeParameters
  54527. )));
  54528. if (!match(',')) {
  54529. break;
  54530. }
  54531. expect(',');
  54532. }
  54533. return implemented;
  54534. }
  54535. function parseClassExpression() {
  54536. var id, implemented, previousYieldAllowed, superClass = null,
  54537. superTypeParameters, marker = markerCreate(), typeParameters,
  54538. matchImplements;
  54539. expectKeyword('class');
  54540. matchImplements =
  54541. strict
  54542. ? matchKeyword('implements')
  54543. : matchContextualKeyword('implements');
  54544. if (!matchKeyword('extends') && !matchImplements && !match('{')) {
  54545. id = parseVariableIdentifier();
  54546. }
  54547. if (match('<')) {
  54548. typeParameters = parseTypeParameterDeclaration();
  54549. }
  54550. if (matchKeyword('extends')) {
  54551. expectKeyword('extends');
  54552. previousYieldAllowed = state.yieldAllowed;
  54553. state.yieldAllowed = false;
  54554. superClass = parseLeftHandSideExpressionAllowCall();
  54555. if (match('<')) {
  54556. superTypeParameters = parseTypeParameterInstantiation();
  54557. }
  54558. state.yieldAllowed = previousYieldAllowed;
  54559. }
  54560. if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
  54561. implemented = parseClassImplements();
  54562. }
  54563. return markerApply(marker, delegate.createClassExpression(
  54564. id,
  54565. superClass,
  54566. parseClassBody(),
  54567. typeParameters,
  54568. superTypeParameters,
  54569. implemented
  54570. ));
  54571. }
  54572. function parseClassDeclaration() {
  54573. var id, implemented, previousYieldAllowed, superClass = null,
  54574. superTypeParameters, marker = markerCreate(), typeParameters;
  54575. expectKeyword('class');
  54576. id = parseVariableIdentifier();
  54577. if (match('<')) {
  54578. typeParameters = parseTypeParameterDeclaration();
  54579. }
  54580. if (matchKeyword('extends')) {
  54581. expectKeyword('extends');
  54582. previousYieldAllowed = state.yieldAllowed;
  54583. state.yieldAllowed = false;
  54584. superClass = parseLeftHandSideExpressionAllowCall();
  54585. if (match('<')) {
  54586. superTypeParameters = parseTypeParameterInstantiation();
  54587. }
  54588. state.yieldAllowed = previousYieldAllowed;
  54589. }
  54590. if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
  54591. implemented = parseClassImplements();
  54592. }
  54593. return markerApply(marker, delegate.createClassDeclaration(
  54594. id,
  54595. superClass,
  54596. parseClassBody(),
  54597. typeParameters,
  54598. superTypeParameters,
  54599. implemented
  54600. ));
  54601. }
  54602. // 15 Program
  54603. function parseSourceElement() {
  54604. var token;
  54605. if (lookahead.type === Token.Keyword) {
  54606. switch (lookahead.value) {
  54607. case 'const':
  54608. case 'let':
  54609. return parseConstLetDeclaration(lookahead.value);
  54610. case 'function':
  54611. return parseFunctionDeclaration();
  54612. case 'export':
  54613. throwErrorTolerant({}, Messages.IllegalExportDeclaration);
  54614. return parseExportDeclaration();
  54615. case 'import':
  54616. throwErrorTolerant({}, Messages.IllegalImportDeclaration);
  54617. return parseImportDeclaration();
  54618. case 'interface':
  54619. if (lookahead2().type === Token.Identifier) {
  54620. return parseInterface();
  54621. }
  54622. return parseStatement();
  54623. default:
  54624. return parseStatement();
  54625. }
  54626. }
  54627. if (matchContextualKeyword('type')
  54628. && lookahead2().type === Token.Identifier) {
  54629. return parseTypeAlias();
  54630. }
  54631. if (matchContextualKeyword('interface')
  54632. && lookahead2().type === Token.Identifier) {
  54633. return parseInterface();
  54634. }
  54635. if (matchContextualKeyword('declare')) {
  54636. token = lookahead2();
  54637. if (token.type === Token.Keyword) {
  54638. switch (token.value) {
  54639. case 'class':
  54640. return parseDeclareClass();
  54641. case 'function':
  54642. return parseDeclareFunction();
  54643. case 'var':
  54644. return parseDeclareVariable();
  54645. }
  54646. } else if (token.type === Token.Identifier
  54647. && token.value === 'module') {
  54648. return parseDeclareModule();
  54649. }
  54650. }
  54651. if (lookahead.type !== Token.EOF) {
  54652. return parseStatement();
  54653. }
  54654. }
  54655. function parseProgramElement() {
  54656. var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
  54657. if (isModule && lookahead.type === Token.Keyword) {
  54658. switch (lookahead.value) {
  54659. case 'export':
  54660. return parseExportDeclaration();
  54661. case 'import':
  54662. return parseImportDeclaration();
  54663. }
  54664. }
  54665. return parseSourceElement();
  54666. }
  54667. function parseProgramElements() {
  54668. var sourceElement, sourceElements = [], token, directive, firstRestricted;
  54669. while (index < length) {
  54670. token = lookahead;
  54671. if (token.type !== Token.StringLiteral) {
  54672. break;
  54673. }
  54674. sourceElement = parseProgramElement();
  54675. sourceElements.push(sourceElement);
  54676. if (sourceElement.expression.type !== Syntax.Literal) {
  54677. // this is not directive
  54678. break;
  54679. }
  54680. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  54681. if (directive === 'use strict') {
  54682. strict = true;
  54683. if (firstRestricted) {
  54684. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  54685. }
  54686. } else {
  54687. if (!firstRestricted && token.octal) {
  54688. firstRestricted = token;
  54689. }
  54690. }
  54691. }
  54692. while (index < length) {
  54693. sourceElement = parseProgramElement();
  54694. if (typeof sourceElement === 'undefined') {
  54695. break;
  54696. }
  54697. sourceElements.push(sourceElement);
  54698. }
  54699. return sourceElements;
  54700. }
  54701. function parseProgram() {
  54702. var body, marker = markerCreate();
  54703. strict = extra.sourceType === 'module';
  54704. peek();
  54705. body = parseProgramElements();
  54706. return markerApply(marker, delegate.createProgram(body));
  54707. }
  54708. // 16 JSX
  54709. XHTMLEntities = {
  54710. quot: '\u0022',
  54711. amp: '&',
  54712. apos: '\u0027',
  54713. lt: '<',
  54714. gt: '>',
  54715. nbsp: '\u00A0',
  54716. iexcl: '\u00A1',
  54717. cent: '\u00A2',
  54718. pound: '\u00A3',
  54719. curren: '\u00A4',
  54720. yen: '\u00A5',
  54721. brvbar: '\u00A6',
  54722. sect: '\u00A7',
  54723. uml: '\u00A8',
  54724. copy: '\u00A9',
  54725. ordf: '\u00AA',
  54726. laquo: '\u00AB',
  54727. not: '\u00AC',
  54728. shy: '\u00AD',
  54729. reg: '\u00AE',
  54730. macr: '\u00AF',
  54731. deg: '\u00B0',
  54732. plusmn: '\u00B1',
  54733. sup2: '\u00B2',
  54734. sup3: '\u00B3',
  54735. acute: '\u00B4',
  54736. micro: '\u00B5',
  54737. para: '\u00B6',
  54738. middot: '\u00B7',
  54739. cedil: '\u00B8',
  54740. sup1: '\u00B9',
  54741. ordm: '\u00BA',
  54742. raquo: '\u00BB',
  54743. frac14: '\u00BC',
  54744. frac12: '\u00BD',
  54745. frac34: '\u00BE',
  54746. iquest: '\u00BF',
  54747. Agrave: '\u00C0',
  54748. Aacute: '\u00C1',
  54749. Acirc: '\u00C2',
  54750. Atilde: '\u00C3',
  54751. Auml: '\u00C4',
  54752. Aring: '\u00C5',
  54753. AElig: '\u00C6',
  54754. Ccedil: '\u00C7',
  54755. Egrave: '\u00C8',
  54756. Eacute: '\u00C9',
  54757. Ecirc: '\u00CA',
  54758. Euml: '\u00CB',
  54759. Igrave: '\u00CC',
  54760. Iacute: '\u00CD',
  54761. Icirc: '\u00CE',
  54762. Iuml: '\u00CF',
  54763. ETH: '\u00D0',
  54764. Ntilde: '\u00D1',
  54765. Ograve: '\u00D2',
  54766. Oacute: '\u00D3',
  54767. Ocirc: '\u00D4',
  54768. Otilde: '\u00D5',
  54769. Ouml: '\u00D6',
  54770. times: '\u00D7',
  54771. Oslash: '\u00D8',
  54772. Ugrave: '\u00D9',
  54773. Uacute: '\u00DA',
  54774. Ucirc: '\u00DB',
  54775. Uuml: '\u00DC',
  54776. Yacute: '\u00DD',
  54777. THORN: '\u00DE',
  54778. szlig: '\u00DF',
  54779. agrave: '\u00E0',
  54780. aacute: '\u00E1',
  54781. acirc: '\u00E2',
  54782. atilde: '\u00E3',
  54783. auml: '\u00E4',
  54784. aring: '\u00E5',
  54785. aelig: '\u00E6',
  54786. ccedil: '\u00E7',
  54787. egrave: '\u00E8',
  54788. eacute: '\u00E9',
  54789. ecirc: '\u00EA',
  54790. euml: '\u00EB',
  54791. igrave: '\u00EC',
  54792. iacute: '\u00ED',
  54793. icirc: '\u00EE',
  54794. iuml: '\u00EF',
  54795. eth: '\u00F0',
  54796. ntilde: '\u00F1',
  54797. ograve: '\u00F2',
  54798. oacute: '\u00F3',
  54799. ocirc: '\u00F4',
  54800. otilde: '\u00F5',
  54801. ouml: '\u00F6',
  54802. divide: '\u00F7',
  54803. oslash: '\u00F8',
  54804. ugrave: '\u00F9',
  54805. uacute: '\u00FA',
  54806. ucirc: '\u00FB',
  54807. uuml: '\u00FC',
  54808. yacute: '\u00FD',
  54809. thorn: '\u00FE',
  54810. yuml: '\u00FF',
  54811. OElig: '\u0152',
  54812. oelig: '\u0153',
  54813. Scaron: '\u0160',
  54814. scaron: '\u0161',
  54815. Yuml: '\u0178',
  54816. fnof: '\u0192',
  54817. circ: '\u02C6',
  54818. tilde: '\u02DC',
  54819. Alpha: '\u0391',
  54820. Beta: '\u0392',
  54821. Gamma: '\u0393',
  54822. Delta: '\u0394',
  54823. Epsilon: '\u0395',
  54824. Zeta: '\u0396',
  54825. Eta: '\u0397',
  54826. Theta: '\u0398',
  54827. Iota: '\u0399',
  54828. Kappa: '\u039A',
  54829. Lambda: '\u039B',
  54830. Mu: '\u039C',
  54831. Nu: '\u039D',
  54832. Xi: '\u039E',
  54833. Omicron: '\u039F',
  54834. Pi: '\u03A0',
  54835. Rho: '\u03A1',
  54836. Sigma: '\u03A3',
  54837. Tau: '\u03A4',
  54838. Upsilon: '\u03A5',
  54839. Phi: '\u03A6',
  54840. Chi: '\u03A7',
  54841. Psi: '\u03A8',
  54842. Omega: '\u03A9',
  54843. alpha: '\u03B1',
  54844. beta: '\u03B2',
  54845. gamma: '\u03B3',
  54846. delta: '\u03B4',
  54847. epsilon: '\u03B5',
  54848. zeta: '\u03B6',
  54849. eta: '\u03B7',
  54850. theta: '\u03B8',
  54851. iota: '\u03B9',
  54852. kappa: '\u03BA',
  54853. lambda: '\u03BB',
  54854. mu: '\u03BC',
  54855. nu: '\u03BD',
  54856. xi: '\u03BE',
  54857. omicron: '\u03BF',
  54858. pi: '\u03C0',
  54859. rho: '\u03C1',
  54860. sigmaf: '\u03C2',
  54861. sigma: '\u03C3',
  54862. tau: '\u03C4',
  54863. upsilon: '\u03C5',
  54864. phi: '\u03C6',
  54865. chi: '\u03C7',
  54866. psi: '\u03C8',
  54867. omega: '\u03C9',
  54868. thetasym: '\u03D1',
  54869. upsih: '\u03D2',
  54870. piv: '\u03D6',
  54871. ensp: '\u2002',
  54872. emsp: '\u2003',
  54873. thinsp: '\u2009',
  54874. zwnj: '\u200C',
  54875. zwj: '\u200D',
  54876. lrm: '\u200E',
  54877. rlm: '\u200F',
  54878. ndash: '\u2013',
  54879. mdash: '\u2014',
  54880. lsquo: '\u2018',
  54881. rsquo: '\u2019',
  54882. sbquo: '\u201A',
  54883. ldquo: '\u201C',
  54884. rdquo: '\u201D',
  54885. bdquo: '\u201E',
  54886. dagger: '\u2020',
  54887. Dagger: '\u2021',
  54888. bull: '\u2022',
  54889. hellip: '\u2026',
  54890. permil: '\u2030',
  54891. prime: '\u2032',
  54892. Prime: '\u2033',
  54893. lsaquo: '\u2039',
  54894. rsaquo: '\u203A',
  54895. oline: '\u203E',
  54896. frasl: '\u2044',
  54897. euro: '\u20AC',
  54898. image: '\u2111',
  54899. weierp: '\u2118',
  54900. real: '\u211C',
  54901. trade: '\u2122',
  54902. alefsym: '\u2135',
  54903. larr: '\u2190',
  54904. uarr: '\u2191',
  54905. rarr: '\u2192',
  54906. darr: '\u2193',
  54907. harr: '\u2194',
  54908. crarr: '\u21B5',
  54909. lArr: '\u21D0',
  54910. uArr: '\u21D1',
  54911. rArr: '\u21D2',
  54912. dArr: '\u21D3',
  54913. hArr: '\u21D4',
  54914. forall: '\u2200',
  54915. part: '\u2202',
  54916. exist: '\u2203',
  54917. empty: '\u2205',
  54918. nabla: '\u2207',
  54919. isin: '\u2208',
  54920. notin: '\u2209',
  54921. ni: '\u220B',
  54922. prod: '\u220F',
  54923. sum: '\u2211',
  54924. minus: '\u2212',
  54925. lowast: '\u2217',
  54926. radic: '\u221A',
  54927. prop: '\u221D',
  54928. infin: '\u221E',
  54929. ang: '\u2220',
  54930. and: '\u2227',
  54931. or: '\u2228',
  54932. cap: '\u2229',
  54933. cup: '\u222A',
  54934. 'int': '\u222B',
  54935. there4: '\u2234',
  54936. sim: '\u223C',
  54937. cong: '\u2245',
  54938. asymp: '\u2248',
  54939. ne: '\u2260',
  54940. equiv: '\u2261',
  54941. le: '\u2264',
  54942. ge: '\u2265',
  54943. sub: '\u2282',
  54944. sup: '\u2283',
  54945. nsub: '\u2284',
  54946. sube: '\u2286',
  54947. supe: '\u2287',
  54948. oplus: '\u2295',
  54949. otimes: '\u2297',
  54950. perp: '\u22A5',
  54951. sdot: '\u22C5',
  54952. lceil: '\u2308',
  54953. rceil: '\u2309',
  54954. lfloor: '\u230A',
  54955. rfloor: '\u230B',
  54956. lang: '\u2329',
  54957. rang: '\u232A',
  54958. loz: '\u25CA',
  54959. spades: '\u2660',
  54960. clubs: '\u2663',
  54961. hearts: '\u2665',
  54962. diams: '\u2666'
  54963. };
  54964. function getQualifiedJSXName(object) {
  54965. if (object.type === Syntax.JSXIdentifier) {
  54966. return object.name;
  54967. }
  54968. if (object.type === Syntax.JSXNamespacedName) {
  54969. return object.namespace.name + ':' + object.name.name;
  54970. }
  54971. /* istanbul ignore else */
  54972. if (object.type === Syntax.JSXMemberExpression) {
  54973. return (
  54974. getQualifiedJSXName(object.object) + '.' +
  54975. getQualifiedJSXName(object.property)
  54976. );
  54977. }
  54978. /* istanbul ignore next */
  54979. throwUnexpected(object);
  54980. }
  54981. function isJSXIdentifierStart(ch) {
  54982. // exclude backslash (\)
  54983. return (ch !== 92) && isIdentifierStart(ch);
  54984. }
  54985. function isJSXIdentifierPart(ch) {
  54986. // exclude backslash (\) and add hyphen (-)
  54987. return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
  54988. }
  54989. function scanJSXIdentifier() {
  54990. var ch, start, value = '';
  54991. start = index;
  54992. while (index < length) {
  54993. ch = source.charCodeAt(index);
  54994. if (!isJSXIdentifierPart(ch)) {
  54995. break;
  54996. }
  54997. value += source[index++];
  54998. }
  54999. return {
  55000. type: Token.JSXIdentifier,
  55001. value: value,
  55002. lineNumber: lineNumber,
  55003. lineStart: lineStart,
  55004. range: [start, index]
  55005. };
  55006. }
  55007. function scanJSXEntity() {
  55008. var ch, str = '', start = index, count = 0, code;
  55009. ch = source[index];
  55010. assert(ch === '&', 'Entity must start with an ampersand');
  55011. index++;
  55012. while (index < length && count++ < 10) {
  55013. ch = source[index++];
  55014. if (ch === ';') {
  55015. break;
  55016. }
  55017. str += ch;
  55018. }
  55019. // Well-formed entity (ending was found).
  55020. if (ch === ';') {
  55021. // Numeric entity.
  55022. if (str[0] === '#') {
  55023. if (str[1] === 'x') {
  55024. code = +('0' + str.substr(1));
  55025. } else {
  55026. // Removing leading zeros in order to avoid treating as octal in old browsers.
  55027. code = +str.substr(1).replace(Regex.LeadingZeros, '');
  55028. }
  55029. if (!isNaN(code)) {
  55030. return String.fromCharCode(code);
  55031. }
  55032. /* istanbul ignore else */
  55033. } else if (XHTMLEntities[str]) {
  55034. return XHTMLEntities[str];
  55035. }
  55036. }
  55037. // Treat non-entity sequences as regular text.
  55038. index = start + 1;
  55039. return '&';
  55040. }
  55041. function scanJSXText(stopChars) {
  55042. var ch, str = '', start;
  55043. start = index;
  55044. while (index < length) {
  55045. ch = source[index];
  55046. if (stopChars.indexOf(ch) !== -1) {
  55047. break;
  55048. }
  55049. if (ch === '&') {
  55050. str += scanJSXEntity();
  55051. } else {
  55052. index++;
  55053. if (ch === '\r' && source[index] === '\n') {
  55054. str += ch;
  55055. ch = source[index];
  55056. index++;
  55057. }
  55058. if (isLineTerminator(ch.charCodeAt(0))) {
  55059. ++lineNumber;
  55060. lineStart = index;
  55061. }
  55062. str += ch;
  55063. }
  55064. }
  55065. return {
  55066. type: Token.JSXText,
  55067. value: str,
  55068. lineNumber: lineNumber,
  55069. lineStart: lineStart,
  55070. range: [start, index]
  55071. };
  55072. }
  55073. function scanJSXStringLiteral() {
  55074. var innerToken, quote, start;
  55075. quote = source[index];
  55076. assert((quote === '\'' || quote === '"'),
  55077. 'String literal must starts with a quote');
  55078. start = index;
  55079. ++index;
  55080. innerToken = scanJSXText([quote]);
  55081. if (quote !== source[index]) {
  55082. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  55083. }
  55084. ++index;
  55085. innerToken.range = [start, index];
  55086. return innerToken;
  55087. }
  55088. /**
  55089. * Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
  55090. * is not another JSX tag and is not an expression wrapped by {} is text.
  55091. */
  55092. function advanceJSXChild() {
  55093. var ch = source.charCodeAt(index);
  55094. // '<' 60, '>' 62, '{' 123, '}' 125
  55095. if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
  55096. return scanJSXText(['<', '>', '{', '}']);
  55097. }
  55098. return scanPunctuator();
  55099. }
  55100. function parseJSXIdentifier() {
  55101. var token, marker = markerCreate();
  55102. if (lookahead.type !== Token.JSXIdentifier) {
  55103. throwUnexpected(lookahead);
  55104. }
  55105. token = lex();
  55106. return markerApply(marker, delegate.createJSXIdentifier(token.value));
  55107. }
  55108. function parseJSXNamespacedName() {
  55109. var namespace, name, marker = markerCreate();
  55110. namespace = parseJSXIdentifier();
  55111. expect(':');
  55112. name = parseJSXIdentifier();
  55113. return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
  55114. }
  55115. function parseJSXMemberExpression() {
  55116. var marker = markerCreate(),
  55117. expr = parseJSXIdentifier();
  55118. while (match('.')) {
  55119. lex();
  55120. expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
  55121. }
  55122. return expr;
  55123. }
  55124. function parseJSXElementName() {
  55125. if (lookahead2().value === ':') {
  55126. return parseJSXNamespacedName();
  55127. }
  55128. if (lookahead2().value === '.') {
  55129. return parseJSXMemberExpression();
  55130. }
  55131. return parseJSXIdentifier();
  55132. }
  55133. function parseJSXAttributeName() {
  55134. if (lookahead2().value === ':') {
  55135. return parseJSXNamespacedName();
  55136. }
  55137. return parseJSXIdentifier();
  55138. }
  55139. function parseJSXAttributeValue() {
  55140. var value, marker;
  55141. if (match('{')) {
  55142. value = parseJSXExpressionContainer();
  55143. if (value.expression.type === Syntax.JSXEmptyExpression) {
  55144. throwError(
  55145. value,
  55146. 'JSX attributes must only be assigned a non-empty ' +
  55147. 'expression'
  55148. );
  55149. }
  55150. } else if (match('<')) {
  55151. value = parseJSXElement();
  55152. } else if (lookahead.type === Token.JSXText) {
  55153. marker = markerCreate();
  55154. value = markerApply(marker, delegate.createLiteral(lex()));
  55155. } else {
  55156. throwError({}, Messages.InvalidJSXAttributeValue);
  55157. }
  55158. return value;
  55159. }
  55160. function parseJSXEmptyExpression() {
  55161. var marker = markerCreatePreserveWhitespace();
  55162. while (source.charAt(index) !== '}') {
  55163. index++;
  55164. }
  55165. return markerApply(marker, delegate.createJSXEmptyExpression());
  55166. }
  55167. function parseJSXExpressionContainer() {
  55168. var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
  55169. origInJSXChild = state.inJSXChild;
  55170. origInJSXTag = state.inJSXTag;
  55171. state.inJSXChild = false;
  55172. state.inJSXTag = false;
  55173. expect('{');
  55174. if (match('}')) {
  55175. expression = parseJSXEmptyExpression();
  55176. } else {
  55177. expression = parseExpression();
  55178. }
  55179. state.inJSXChild = origInJSXChild;
  55180. state.inJSXTag = origInJSXTag;
  55181. expect('}');
  55182. return markerApply(marker, delegate.createJSXExpressionContainer(expression));
  55183. }
  55184. function parseJSXSpreadAttribute() {
  55185. var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
  55186. origInJSXChild = state.inJSXChild;
  55187. origInJSXTag = state.inJSXTag;
  55188. state.inJSXChild = false;
  55189. state.inJSXTag = false;
  55190. expect('{');
  55191. expect('...');
  55192. expression = parseAssignmentExpression();
  55193. state.inJSXChild = origInJSXChild;
  55194. state.inJSXTag = origInJSXTag;
  55195. expect('}');
  55196. return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
  55197. }
  55198. function parseJSXAttribute() {
  55199. var name, marker;
  55200. if (match('{')) {
  55201. return parseJSXSpreadAttribute();
  55202. }
  55203. marker = markerCreate();
  55204. name = parseJSXAttributeName();
  55205. // HTML empty attribute
  55206. if (match('=')) {
  55207. lex();
  55208. return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
  55209. }
  55210. return markerApply(marker, delegate.createJSXAttribute(name));
  55211. }
  55212. function parseJSXChild() {
  55213. var token, marker;
  55214. if (match('{')) {
  55215. token = parseJSXExpressionContainer();
  55216. } else if (lookahead.type === Token.JSXText) {
  55217. marker = markerCreatePreserveWhitespace();
  55218. token = markerApply(marker, delegate.createLiteral(lex()));
  55219. } else if (match('<')) {
  55220. token = parseJSXElement();
  55221. } else {
  55222. throwUnexpected(lookahead);
  55223. }
  55224. return token;
  55225. }
  55226. function parseJSXClosingElement() {
  55227. var name, origInJSXChild, origInJSXTag, marker = markerCreate();
  55228. origInJSXChild = state.inJSXChild;
  55229. origInJSXTag = state.inJSXTag;
  55230. state.inJSXChild = false;
  55231. state.inJSXTag = true;
  55232. expect('<');
  55233. expect('/');
  55234. name = parseJSXElementName();
  55235. // Because advance() (called by lex() called by expect()) expects there
  55236. // to be a valid token after >, it needs to know whether to look for a
  55237. // standard JS token or an JSX text node
  55238. state.inJSXChild = origInJSXChild;
  55239. state.inJSXTag = origInJSXTag;
  55240. expect('>');
  55241. return markerApply(marker, delegate.createJSXClosingElement(name));
  55242. }
  55243. function parseJSXOpeningElement() {
  55244. var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
  55245. origInJSXChild = state.inJSXChild;
  55246. origInJSXTag = state.inJSXTag;
  55247. state.inJSXChild = false;
  55248. state.inJSXTag = true;
  55249. expect('<');
  55250. name = parseJSXElementName();
  55251. while (index < length &&
  55252. lookahead.value !== '/' &&
  55253. lookahead.value !== '>') {
  55254. attributes.push(parseJSXAttribute());
  55255. }
  55256. state.inJSXTag = origInJSXTag;
  55257. if (lookahead.value === '/') {
  55258. expect('/');
  55259. // Because advance() (called by lex() called by expect()) expects
  55260. // there to be a valid token after >, it needs to know whether to
  55261. // look for a standard JS token or an JSX text node
  55262. state.inJSXChild = origInJSXChild;
  55263. expect('>');
  55264. selfClosing = true;
  55265. } else {
  55266. state.inJSXChild = true;
  55267. expect('>');
  55268. }
  55269. return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
  55270. }
  55271. function parseJSXElement() {
  55272. var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
  55273. origInJSXChild = state.inJSXChild;
  55274. origInJSXTag = state.inJSXTag;
  55275. openingElement = parseJSXOpeningElement();
  55276. if (!openingElement.selfClosing) {
  55277. while (index < length) {
  55278. state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
  55279. if (lookahead.value === '<' && lookahead2().value === '/') {
  55280. break;
  55281. }
  55282. state.inJSXChild = true;
  55283. children.push(parseJSXChild());
  55284. }
  55285. state.inJSXChild = origInJSXChild;
  55286. state.inJSXTag = origInJSXTag;
  55287. closingElement = parseJSXClosingElement();
  55288. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  55289. throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
  55290. }
  55291. }
  55292. // When (erroneously) writing two adjacent tags like
  55293. //
  55294. // var x = <div>one</div><div>two</div>;
  55295. //
  55296. // the default error message is a bit incomprehensible. Since it's
  55297. // rarely (never?) useful to write a less-than sign after an JSX
  55298. // element, we disallow it here in the parser in order to provide a
  55299. // better error message. (In the rare case that the less-than operator
  55300. // was intended, the left tag can be wrapped in parentheses.)
  55301. if (!origInJSXChild && match('<')) {
  55302. throwError(lookahead, Messages.AdjacentJSXElements);
  55303. }
  55304. return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
  55305. }
  55306. function parseTypeAlias() {
  55307. var id, marker = markerCreate(), typeParameters = null, right;
  55308. expectContextualKeyword('type');
  55309. id = parseVariableIdentifier();
  55310. if (match('<')) {
  55311. typeParameters = parseTypeParameterDeclaration();
  55312. }
  55313. expect('=');
  55314. right = parseType();
  55315. consumeSemicolon();
  55316. return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
  55317. }
  55318. function parseInterfaceExtends() {
  55319. var marker = markerCreate(), id, typeParameters = null;
  55320. id = parseVariableIdentifier();
  55321. if (match('<')) {
  55322. typeParameters = parseTypeParameterInstantiation();
  55323. }
  55324. return markerApply(marker, delegate.createInterfaceExtends(
  55325. id,
  55326. typeParameters
  55327. ));
  55328. }
  55329. function parseInterfaceish(marker, allowStatic) {
  55330. var body, bodyMarker, extended = [], id,
  55331. typeParameters = null;
  55332. id = parseVariableIdentifier();
  55333. if (match('<')) {
  55334. typeParameters = parseTypeParameterDeclaration();
  55335. }
  55336. if (matchKeyword('extends')) {
  55337. expectKeyword('extends');
  55338. while (index < length) {
  55339. extended.push(parseInterfaceExtends());
  55340. if (!match(',')) {
  55341. break;
  55342. }
  55343. expect(',');
  55344. }
  55345. }
  55346. bodyMarker = markerCreate();
  55347. body = markerApply(bodyMarker, parseObjectType(allowStatic));
  55348. return markerApply(marker, delegate.createInterface(
  55349. id,
  55350. typeParameters,
  55351. body,
  55352. extended
  55353. ));
  55354. }
  55355. function parseInterface() {
  55356. var marker = markerCreate();
  55357. if (strict) {
  55358. expectKeyword('interface');
  55359. } else {
  55360. expectContextualKeyword('interface');
  55361. }
  55362. return parseInterfaceish(marker, /* allowStatic */false);
  55363. }
  55364. function parseDeclareClass() {
  55365. var marker = markerCreate(), ret;
  55366. expectContextualKeyword('declare');
  55367. expectKeyword('class');
  55368. ret = parseInterfaceish(marker, /* allowStatic */true);
  55369. ret.type = Syntax.DeclareClass;
  55370. return ret;
  55371. }
  55372. function parseDeclareFunction() {
  55373. var id, idMarker,
  55374. marker = markerCreate(), params, returnType, rest, tmp,
  55375. typeParameters = null, value, valueMarker;
  55376. expectContextualKeyword('declare');
  55377. expectKeyword('function');
  55378. idMarker = markerCreate();
  55379. id = parseVariableIdentifier();
  55380. valueMarker = markerCreate();
  55381. if (match('<')) {
  55382. typeParameters = parseTypeParameterDeclaration();
  55383. }
  55384. expect('(');
  55385. tmp = parseFunctionTypeParams();
  55386. params = tmp.params;
  55387. rest = tmp.rest;
  55388. expect(')');
  55389. expect(':');
  55390. returnType = parseType();
  55391. value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
  55392. params,
  55393. returnType,
  55394. rest,
  55395. typeParameters
  55396. ));
  55397. id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
  55398. value
  55399. ));
  55400. markerApply(idMarker, id);
  55401. consumeSemicolon();
  55402. return markerApply(marker, delegate.createDeclareFunction(
  55403. id
  55404. ));
  55405. }
  55406. function parseDeclareVariable() {
  55407. var id, marker = markerCreate();
  55408. expectContextualKeyword('declare');
  55409. expectKeyword('var');
  55410. id = parseTypeAnnotatableIdentifier();
  55411. consumeSemicolon();
  55412. return markerApply(marker, delegate.createDeclareVariable(
  55413. id
  55414. ));
  55415. }
  55416. function parseDeclareModule() {
  55417. var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
  55418. expectContextualKeyword('declare');
  55419. expectContextualKeyword('module');
  55420. if (lookahead.type === Token.StringLiteral) {
  55421. if (strict && lookahead.octal) {
  55422. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  55423. }
  55424. idMarker = markerCreate();
  55425. id = markerApply(idMarker, delegate.createLiteral(lex()));
  55426. } else {
  55427. id = parseVariableIdentifier();
  55428. }
  55429. bodyMarker = markerCreate();
  55430. expect('{');
  55431. while (index < length && !match('}')) {
  55432. token = lookahead2();
  55433. switch (token.value) {
  55434. case 'class':
  55435. body.push(parseDeclareClass());
  55436. break;
  55437. case 'function':
  55438. body.push(parseDeclareFunction());
  55439. break;
  55440. case 'var':
  55441. body.push(parseDeclareVariable());
  55442. break;
  55443. default:
  55444. throwUnexpected(lookahead);
  55445. }
  55446. }
  55447. expect('}');
  55448. return markerApply(marker, delegate.createDeclareModule(
  55449. id,
  55450. markerApply(bodyMarker, delegate.createBlockStatement(body))
  55451. ));
  55452. }
  55453. function collectToken() {
  55454. var loc, token, range, value, entry;
  55455. /* istanbul ignore else */
  55456. if (!state.inJSXChild) {
  55457. skipComment();
  55458. }
  55459. loc = {
  55460. start: {
  55461. line: lineNumber,
  55462. column: index - lineStart
  55463. }
  55464. };
  55465. token = extra.advance();
  55466. loc.end = {
  55467. line: lineNumber,
  55468. column: index - lineStart
  55469. };
  55470. if (token.type !== Token.EOF) {
  55471. range = [token.range[0], token.range[1]];
  55472. value = source.slice(token.range[0], token.range[1]);
  55473. entry = {
  55474. type: TokenName[token.type],
  55475. value: value,
  55476. range: range,
  55477. loc: loc
  55478. };
  55479. if (token.regex) {
  55480. entry.regex = {
  55481. pattern: token.regex.pattern,
  55482. flags: token.regex.flags
  55483. };
  55484. }
  55485. extra.tokens.push(entry);
  55486. }
  55487. return token;
  55488. }
  55489. function collectRegex() {
  55490. var pos, loc, regex, token;
  55491. skipComment();
  55492. pos = index;
  55493. loc = {
  55494. start: {
  55495. line: lineNumber,
  55496. column: index - lineStart
  55497. }
  55498. };
  55499. regex = extra.scanRegExp();
  55500. loc.end = {
  55501. line: lineNumber,
  55502. column: index - lineStart
  55503. };
  55504. if (!extra.tokenize) {
  55505. /* istanbul ignore next */
  55506. // Pop the previous token, which is likely '/' or '/='
  55507. if (extra.tokens.length > 0) {
  55508. token = extra.tokens[extra.tokens.length - 1];
  55509. if (token.range[0] === pos && token.type === 'Punctuator') {
  55510. if (token.value === '/' || token.value === '/=') {
  55511. extra.tokens.pop();
  55512. }
  55513. }
  55514. }
  55515. extra.tokens.push({
  55516. type: 'RegularExpression',
  55517. value: regex.literal,
  55518. regex: regex.regex,
  55519. range: [pos, index],
  55520. loc: loc
  55521. });
  55522. }
  55523. return regex;
  55524. }
  55525. function filterTokenLocation() {
  55526. var i, entry, token, tokens = [];
  55527. for (i = 0; i < extra.tokens.length; ++i) {
  55528. entry = extra.tokens[i];
  55529. token = {
  55530. type: entry.type,
  55531. value: entry.value
  55532. };
  55533. if (entry.regex) {
  55534. token.regex = {
  55535. pattern: entry.regex.pattern,
  55536. flags: entry.regex.flags
  55537. };
  55538. }
  55539. if (extra.range) {
  55540. token.range = entry.range;
  55541. }
  55542. if (extra.loc) {
  55543. token.loc = entry.loc;
  55544. }
  55545. tokens.push(token);
  55546. }
  55547. extra.tokens = tokens;
  55548. }
  55549. function patch() {
  55550. if (typeof extra.tokens !== 'undefined') {
  55551. extra.advance = advance;
  55552. extra.scanRegExp = scanRegExp;
  55553. advance = collectToken;
  55554. scanRegExp = collectRegex;
  55555. }
  55556. }
  55557. function unpatch() {
  55558. if (typeof extra.scanRegExp === 'function') {
  55559. advance = extra.advance;
  55560. scanRegExp = extra.scanRegExp;
  55561. }
  55562. }
  55563. // This is used to modify the delegate.
  55564. function extend(object, properties) {
  55565. var entry, result = {};
  55566. for (entry in object) {
  55567. /* istanbul ignore else */
  55568. if (object.hasOwnProperty(entry)) {
  55569. result[entry] = object[entry];
  55570. }
  55571. }
  55572. for (entry in properties) {
  55573. /* istanbul ignore else */
  55574. if (properties.hasOwnProperty(entry)) {
  55575. result[entry] = properties[entry];
  55576. }
  55577. }
  55578. return result;
  55579. }
  55580. function tokenize(code, options) {
  55581. var toString,
  55582. token,
  55583. tokens;
  55584. toString = String;
  55585. if (typeof code !== 'string' && !(code instanceof String)) {
  55586. code = toString(code);
  55587. }
  55588. delegate = SyntaxTreeDelegate;
  55589. source = code;
  55590. index = 0;
  55591. lineNumber = (source.length > 0) ? 1 : 0;
  55592. lineStart = 0;
  55593. length = source.length;
  55594. lookahead = null;
  55595. state = {
  55596. allowKeyword: true,
  55597. allowIn: true,
  55598. labelSet: new StringMap(),
  55599. inFunctionBody: false,
  55600. inIteration: false,
  55601. inSwitch: false,
  55602. lastCommentStart: -1
  55603. };
  55604. extra = {};
  55605. // Options matching.
  55606. options = options || {};
  55607. // Of course we collect tokens here.
  55608. options.tokens = true;
  55609. extra.tokens = [];
  55610. extra.tokenize = true;
  55611. // The following two fields are necessary to compute the Regex tokens.
  55612. extra.openParenToken = -1;
  55613. extra.openCurlyToken = -1;
  55614. extra.range = (typeof options.range === 'boolean') && options.range;
  55615. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  55616. if (typeof options.comment === 'boolean' && options.comment) {
  55617. extra.comments = [];
  55618. }
  55619. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  55620. extra.errors = [];
  55621. }
  55622. patch();
  55623. try {
  55624. peek();
  55625. if (lookahead.type === Token.EOF) {
  55626. return extra.tokens;
  55627. }
  55628. token = lex();
  55629. while (lookahead.type !== Token.EOF) {
  55630. try {
  55631. token = lex();
  55632. } catch (lexError) {
  55633. token = lookahead;
  55634. if (extra.errors) {
  55635. extra.errors.push(lexError);
  55636. // We have to break on the first error
  55637. // to avoid infinite loops.
  55638. break;
  55639. } else {
  55640. throw lexError;
  55641. }
  55642. }
  55643. }
  55644. filterTokenLocation();
  55645. tokens = extra.tokens;
  55646. if (typeof extra.comments !== 'undefined') {
  55647. tokens.comments = extra.comments;
  55648. }
  55649. if (typeof extra.errors !== 'undefined') {
  55650. tokens.errors = extra.errors;
  55651. }
  55652. } catch (e) {
  55653. throw e;
  55654. } finally {
  55655. unpatch();
  55656. extra = {};
  55657. }
  55658. return tokens;
  55659. }
  55660. function parse(code, options) {
  55661. var program, toString;
  55662. toString = String;
  55663. if (typeof code !== 'string' && !(code instanceof String)) {
  55664. code = toString(code);
  55665. }
  55666. delegate = SyntaxTreeDelegate;
  55667. source = code;
  55668. index = 0;
  55669. lineNumber = (source.length > 0) ? 1 : 0;
  55670. lineStart = 0;
  55671. length = source.length;
  55672. lookahead = null;
  55673. state = {
  55674. allowKeyword: false,
  55675. allowIn: true,
  55676. labelSet: new StringMap(),
  55677. parenthesizedCount: 0,
  55678. inFunctionBody: false,
  55679. inIteration: false,
  55680. inSwitch: false,
  55681. inJSXChild: false,
  55682. inJSXTag: false,
  55683. inType: false,
  55684. lastCommentStart: -1,
  55685. yieldAllowed: false,
  55686. awaitAllowed: false
  55687. };
  55688. extra = {};
  55689. if (typeof options !== 'undefined') {
  55690. extra.range = (typeof options.range === 'boolean') && options.range;
  55691. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  55692. extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
  55693. if (extra.loc && options.source !== null && options.source !== undefined) {
  55694. delegate = extend(delegate, {
  55695. 'postProcess': function (node) {
  55696. node.loc.source = toString(options.source);
  55697. return node;
  55698. }
  55699. });
  55700. }
  55701. extra.sourceType = options.sourceType;
  55702. if (typeof options.tokens === 'boolean' && options.tokens) {
  55703. extra.tokens = [];
  55704. }
  55705. if (typeof options.comment === 'boolean' && options.comment) {
  55706. extra.comments = [];
  55707. }
  55708. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  55709. extra.errors = [];
  55710. }
  55711. if (extra.attachComment) {
  55712. extra.range = true;
  55713. extra.comments = [];
  55714. extra.bottomRightStack = [];
  55715. extra.trailingComments = [];
  55716. extra.leadingComments = [];
  55717. }
  55718. }
  55719. patch();
  55720. try {
  55721. program = parseProgram();
  55722. if (typeof extra.comments !== 'undefined') {
  55723. program.comments = extra.comments;
  55724. }
  55725. if (typeof extra.tokens !== 'undefined') {
  55726. filterTokenLocation();
  55727. program.tokens = extra.tokens;
  55728. }
  55729. if (typeof extra.errors !== 'undefined') {
  55730. program.errors = extra.errors;
  55731. }
  55732. } catch (e) {
  55733. throw e;
  55734. } finally {
  55735. unpatch();
  55736. extra = {};
  55737. }
  55738. return program;
  55739. }
  55740. // Sync with *.json manifests.
  55741. exports.version = '13001.1.0-dev-harmony-fb';
  55742. exports.tokenize = tokenize;
  55743. exports.parse = parse;
  55744. // Deep copy.
  55745. /* istanbul ignore next */
  55746. exports.Syntax = (function () {
  55747. var name, types = {};
  55748. if (typeof Object.create === 'function') {
  55749. types = Object.create(null);
  55750. }
  55751. for (name in Syntax) {
  55752. if (Syntax.hasOwnProperty(name)) {
  55753. types[name] = Syntax[name];
  55754. }
  55755. }
  55756. if (typeof Object.freeze === 'function') {
  55757. Object.freeze(types);
  55758. }
  55759. return types;
  55760. }());
  55761. }));
  55762. /* vim: set sw=4 ts=4 et tw=80 : */
  55763. },{}],459:[function(require,module,exports){
  55764. var assert = require("assert");
  55765. var types = require("./types");
  55766. var n = types.namedTypes;
  55767. var isArray = types.builtInTypes.array;
  55768. var isObject = types.builtInTypes.object;
  55769. var linesModule = require("./lines");
  55770. var fromString = linesModule.fromString;
  55771. var Lines = linesModule.Lines;
  55772. var concat = linesModule.concat;
  55773. var util = require("./util");
  55774. var comparePos = util.comparePos;
  55775. var childNodesCacheKey = require("private").makeUniqueKey();
  55776. // TODO Move a non-caching implementation of this function into ast-types,
  55777. // and implement a caching wrapper function here.
  55778. function getSortedChildNodes(node, resultArray) {
  55779. if (!node) {
  55780. return;
  55781. }
  55782. // The .loc checks below are sensitive to some of the problems that
  55783. // are fixed by this utility function. Specifically, if it decides to
  55784. // set node.loc to null, indicating that the node's .loc information
  55785. // is unreliable, then we don't want to add node to the resultArray.
  55786. util.fixFaultyLocations(node);
  55787. if (resultArray) {
  55788. if (n.Node.check(node) &&
  55789. n.SourceLocation.check(node.loc)) {
  55790. // This reverse insertion sort almost always takes constant
  55791. // time because we almost always (maybe always?) append the
  55792. // nodes in order anyway.
  55793. for (var i = resultArray.length - 1; i >= 0; --i) {
  55794. if (comparePos(resultArray[i].loc.end,
  55795. node.loc.start) <= 0) {
  55796. break;
  55797. }
  55798. }
  55799. resultArray.splice(i + 1, 0, node);
  55800. return;
  55801. }
  55802. } else if (node[childNodesCacheKey]) {
  55803. return node[childNodesCacheKey];
  55804. }
  55805. var names;
  55806. if (isArray.check(node)) {
  55807. names = Object.keys(node);
  55808. } else if (isObject.check(node)) {
  55809. names = types.getFieldNames(node);
  55810. } else {
  55811. return;
  55812. }
  55813. if (!resultArray) {
  55814. Object.defineProperty(node, childNodesCacheKey, {
  55815. value: resultArray = [],
  55816. enumerable: false
  55817. });
  55818. }
  55819. for (var i = 0, nameCount = names.length; i < nameCount; ++i) {
  55820. getSortedChildNodes(node[names[i]], resultArray);
  55821. }
  55822. return resultArray;
  55823. }
  55824. // As efficiently as possible, decorate the comment object with
  55825. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  55826. // least one of which is guaranteed to be defined.
  55827. function decorateComment(node, comment) {
  55828. var childNodes = getSortedChildNodes(node);
  55829. // Time to dust off the old binary search robes and wizard hat.
  55830. var left = 0, right = childNodes.length;
  55831. while (left < right) {
  55832. var middle = (left + right) >> 1;
  55833. var child = childNodes[middle];
  55834. if (comparePos(child.loc.start, comment.loc.start) <= 0 &&
  55835. comparePos(comment.loc.end, child.loc.end) <= 0) {
  55836. // The comment is completely contained by this child node.
  55837. decorateComment(comment.enclosingNode = child, comment);
  55838. return; // Abandon the binary search at this level.
  55839. }
  55840. if (comparePos(child.loc.end, comment.loc.start) <= 0) {
  55841. // This child node falls completely before the comment.
  55842. // Because we will never consider this node or any nodes
  55843. // before it again, this node must be the closest preceding
  55844. // node we have encountered so far.
  55845. var precedingNode = child;
  55846. left = middle + 1;
  55847. continue;
  55848. }
  55849. if (comparePos(comment.loc.end, child.loc.start) <= 0) {
  55850. // This child node falls completely after the comment.
  55851. // Because we will never consider this node or any nodes after
  55852. // it again, this node must be the closest following node we
  55853. // have encountered so far.
  55854. var followingNode = child;
  55855. right = middle;
  55856. continue;
  55857. }
  55858. throw new Error("Comment location overlaps with node location");
  55859. }
  55860. if (precedingNode) {
  55861. comment.precedingNode = precedingNode;
  55862. }
  55863. if (followingNode) {
  55864. comment.followingNode = followingNode;
  55865. }
  55866. }
  55867. exports.attach = function(comments, ast, lines) {
  55868. if (!isArray.check(comments)) {
  55869. return;
  55870. }
  55871. var tiesToBreak = [];
  55872. comments.forEach(function(comment) {
  55873. comment.loc.lines = lines;
  55874. decorateComment(ast, comment);
  55875. var pn = comment.precedingNode;
  55876. var en = comment.enclosingNode;
  55877. var fn = comment.followingNode;
  55878. if (pn && fn) {
  55879. var tieCount = tiesToBreak.length;
  55880. if (tieCount > 0) {
  55881. var lastTie = tiesToBreak[tieCount - 1];
  55882. assert.strictEqual(
  55883. lastTie.precedingNode === comment.precedingNode,
  55884. lastTie.followingNode === comment.followingNode
  55885. );
  55886. if (lastTie.followingNode !== comment.followingNode) {
  55887. breakTies(tiesToBreak, lines);
  55888. }
  55889. }
  55890. tiesToBreak.push(comment);
  55891. } else if (pn) {
  55892. // No contest: we have a trailing comment.
  55893. breakTies(tiesToBreak, lines);
  55894. addTrailingComment(pn, comment);
  55895. } else if (fn) {
  55896. // No contest: we have a leading comment.
  55897. breakTies(tiesToBreak, lines);
  55898. addLeadingComment(fn, comment);
  55899. } else if (en) {
  55900. // The enclosing node has no child nodes at all, so what we
  55901. // have here is a dangling comment, e.g. [/* crickets */].
  55902. breakTies(tiesToBreak, lines);
  55903. addDanglingComment(en, comment);
  55904. } else {
  55905. throw new Error("AST contains no nodes at all?");
  55906. }
  55907. });
  55908. breakTies(tiesToBreak, lines);
  55909. comments.forEach(function(comment) {
  55910. // These node references were useful for breaking ties, but we
  55911. // don't need them anymore, and they create cycles in the AST that
  55912. // may lead to infinite recursion if we don't delete them here.
  55913. delete comment.precedingNode;
  55914. delete comment.enclosingNode;
  55915. delete comment.followingNode;
  55916. });
  55917. };
  55918. function breakTies(tiesToBreak, lines) {
  55919. var tieCount = tiesToBreak.length;
  55920. if (tieCount === 0) {
  55921. return;
  55922. }
  55923. var pn = tiesToBreak[0].precedingNode;
  55924. var fn = tiesToBreak[0].followingNode;
  55925. var gapEndPos = fn.loc.start;
  55926. // Iterate backwards through tiesToBreak, examining the gaps
  55927. // between the tied comments. In order to qualify as leading, a
  55928. // comment must be separated from fn by an unbroken series of
  55929. // whitespace-only gaps (or other comments).
  55930. for (var indexOfFirstLeadingComment = tieCount;
  55931. indexOfFirstLeadingComment > 0;
  55932. --indexOfFirstLeadingComment) {
  55933. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  55934. assert.strictEqual(comment.precedingNode, pn);
  55935. assert.strictEqual(comment.followingNode, fn);
  55936. var gap = lines.sliceString(comment.loc.end, gapEndPos);
  55937. if (/\S/.test(gap)) {
  55938. // The gap string contained something other than whitespace.
  55939. break;
  55940. }
  55941. gapEndPos = comment.loc.start;
  55942. }
  55943. while (indexOfFirstLeadingComment <= tieCount &&
  55944. (comment = tiesToBreak[indexOfFirstLeadingComment]) &&
  55945. // If the comment is a //-style comment and indented more
  55946. // deeply than the node itself, reconsider it as trailing.
  55947. comment.type === "Line" &&
  55948. comment.loc.start.column > fn.loc.start.column) {
  55949. ++indexOfFirstLeadingComment;
  55950. }
  55951. tiesToBreak.forEach(function(comment, i) {
  55952. if (i < indexOfFirstLeadingComment) {
  55953. addTrailingComment(pn, comment);
  55954. } else {
  55955. addLeadingComment(fn, comment);
  55956. }
  55957. });
  55958. tiesToBreak.length = 0;
  55959. }
  55960. function addCommentHelper(node, comment) {
  55961. var comments = node.comments || (node.comments = []);
  55962. comments.push(comment);
  55963. }
  55964. function addLeadingComment(node, comment) {
  55965. comment.leading = true;
  55966. comment.trailing = false;
  55967. addCommentHelper(node, comment);
  55968. }
  55969. function addDanglingComment(node, comment) {
  55970. comment.leading = false;
  55971. comment.trailing = false;
  55972. addCommentHelper(node, comment);
  55973. }
  55974. function addTrailingComment(node, comment) {
  55975. comment.leading = false;
  55976. comment.trailing = true;
  55977. addCommentHelper(node, comment);
  55978. }
  55979. function printLeadingComment(commentPath, print) {
  55980. var comment = commentPath.getValue();
  55981. n.Comment.assert(comment);
  55982. var loc = comment.loc;
  55983. var lines = loc && loc.lines;
  55984. var parts = [print(commentPath)];
  55985. if (comment.trailing) {
  55986. // When we print trailing comments as leading comments, we don't
  55987. // want to bring any trailing spaces along.
  55988. parts.push("\n");
  55989. } else if (lines instanceof Lines) {
  55990. var trailingSpace = lines.slice(
  55991. loc.end,
  55992. lines.skipSpaces(loc.end)
  55993. );
  55994. if (trailingSpace.length === 1) {
  55995. // If the trailing space contains no newlines, then we want to
  55996. // preserve it exactly as we found it.
  55997. parts.push(trailingSpace);
  55998. } else {
  55999. // If the trailing space contains newlines, then replace it
  56000. // with just that many newlines, with all other spaces removed.
  56001. parts.push(new Array(trailingSpace.length).join("\n"));
  56002. }
  56003. } else {
  56004. parts.push("\n");
  56005. }
  56006. return concat(parts);
  56007. }
  56008. function printTrailingComment(commentPath, print) {
  56009. var comment = commentPath.getValue(commentPath);
  56010. n.Comment.assert(comment);
  56011. var loc = comment.loc;
  56012. var lines = loc && loc.lines;
  56013. var parts = [];
  56014. if (lines instanceof Lines) {
  56015. var fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos();
  56016. var leadingSpace = lines.slice(fromPos, loc.start);
  56017. if (leadingSpace.length === 1) {
  56018. // If the leading space contains no newlines, then we want to
  56019. // preserve it exactly as we found it.
  56020. parts.push(leadingSpace);
  56021. } else {
  56022. // If the leading space contains newlines, then replace it
  56023. // with just that many newlines, sans all other spaces.
  56024. parts.push(new Array(leadingSpace.length).join("\n"));
  56025. }
  56026. }
  56027. parts.push(print(commentPath));
  56028. return concat(parts);
  56029. }
  56030. exports.printComments = function(path, print) {
  56031. var value = path.getValue();
  56032. var innerLines = print(path);
  56033. var comments = n.Node.check(value) &&
  56034. types.getFieldValue(value, "comments");
  56035. if (!comments || comments.length === 0) {
  56036. return innerLines;
  56037. }
  56038. var leadingParts = [];
  56039. var trailingParts = [innerLines];
  56040. path.each(function(commentPath) {
  56041. var comment = commentPath.getValue();
  56042. var leading = types.getFieldValue(comment, "leading");
  56043. var trailing = types.getFieldValue(comment, "trailing");
  56044. if (leading || (trailing && comment.type !== "Block")) {
  56045. leadingParts.push(printLeadingComment(commentPath, print));
  56046. } else if (trailing) {
  56047. assert.strictEqual(comment.type, "Block");
  56048. trailingParts.push(printTrailingComment(commentPath, print));
  56049. }
  56050. }, "comments");
  56051. leadingParts.push.apply(leadingParts, trailingParts);
  56052. return concat(leadingParts);
  56053. };
  56054. },{"./lines":461,"./types":467,"./util":468,"assert":190,"private":435}],460:[function(require,module,exports){
  56055. var assert = require("assert");
  56056. var types = require("./types");
  56057. var n = types.namedTypes;
  56058. var Node = n.Node;
  56059. var isArray = types.builtInTypes.array;
  56060. var isNumber = types.builtInTypes.number;
  56061. function FastPath(value) {
  56062. assert.ok(this instanceof FastPath);
  56063. this.stack = [value];
  56064. }
  56065. var FPp = FastPath.prototype;
  56066. module.exports = FastPath;
  56067. // Static convenience function for coercing a value to a FastPath.
  56068. FastPath.from = function(obj) {
  56069. if (obj instanceof FastPath) {
  56070. // Return a defensive copy of any existing FastPath instances.
  56071. return obj.copy();
  56072. }
  56073. if (obj instanceof types.NodePath) {
  56074. // For backwards compatibility, unroll NodePath instances into
  56075. // lightweight FastPath [..., name, value] stacks.
  56076. var copy = Object.create(FastPath.prototype);
  56077. var stack = [obj.value];
  56078. for (var pp; (pp = obj.parentPath); obj = pp)
  56079. stack.push(obj.name, pp.value);
  56080. copy.stack = stack.reverse();
  56081. return copy;
  56082. }
  56083. // Otherwise use obj as the value of the new FastPath instance.
  56084. return new FastPath(obj);
  56085. };
  56086. FPp.copy = function copy() {
  56087. var copy = Object.create(FastPath.prototype);
  56088. copy.stack = this.stack.slice(0);
  56089. return copy;
  56090. };
  56091. // The name of the current property is always the penultimate element of
  56092. // this.stack, and always a String.
  56093. FPp.getName = function getName() {
  56094. var s = this.stack;
  56095. var len = s.length;
  56096. if (len > 1) {
  56097. return s[len - 2];
  56098. }
  56099. // Since the name is always a string, null is a safe sentinel value to
  56100. // return if we do not know the name of the (root) value.
  56101. return null;
  56102. };
  56103. // The value of the current property is always the final element of
  56104. // this.stack.
  56105. FPp.getValue = function getValue() {
  56106. var s = this.stack;
  56107. return s[s.length - 1];
  56108. };
  56109. function getNodeHelper(path, count) {
  56110. var s = path.stack;
  56111. for (var i = s.length - 1; i >= 0; i -= 2) {
  56112. var value = s[i];
  56113. if (n.Node.check(value) && --count < 0) {
  56114. return value;
  56115. }
  56116. }
  56117. return null;
  56118. }
  56119. FPp.getNode = function getNode(count) {
  56120. return getNodeHelper(this, ~~count);
  56121. };
  56122. FPp.getParentNode = function getParentNode(count) {
  56123. return getNodeHelper(this, ~~count + 1);
  56124. };
  56125. // The length of the stack can be either even or odd, depending on whether
  56126. // or not we have a name for the root value. The difference between the
  56127. // index of the root value and the index of the final value is always
  56128. // even, though, which allows us to return the root value in constant time
  56129. // (i.e. without iterating backwards through the stack).
  56130. FPp.getRootValue = function getRootValue() {
  56131. var s = this.stack;
  56132. if (s.length % 2 === 0) {
  56133. return s[1];
  56134. }
  56135. return s[0];
  56136. };
  56137. // Temporarily push properties named by string arguments given after the
  56138. // callback function onto this.stack, then call the callback with a
  56139. // reference to this (modified) FastPath object. Note that the stack will
  56140. // be restored to its original state after the callback is finished, so it
  56141. // is probably a mistake to retain a reference to the path.
  56142. FPp.call = function call(callback/*, name1, name2, ... */) {
  56143. var s = this.stack;
  56144. var origLen = s.length;
  56145. var value = s[origLen - 1];
  56146. var argc = arguments.length;
  56147. for (var i = 1; i < argc; ++i) {
  56148. var name = arguments[i];
  56149. value = value[name];
  56150. s.push(name, value);
  56151. }
  56152. var result = callback(this);
  56153. s.length = origLen;
  56154. return result;
  56155. };
  56156. // Similar to FastPath.prototype.call, except that the value obtained by
  56157. // accessing this.getValue()[name1][name2]... should be array-like. The
  56158. // callback will be called with a reference to this path object for each
  56159. // element of the array.
  56160. FPp.each = function each(callback/*, name1, name2, ... */) {
  56161. var s = this.stack;
  56162. var origLen = s.length;
  56163. var value = s[origLen - 1];
  56164. var argc = arguments.length;
  56165. for (var i = 1; i < argc; ++i) {
  56166. var name = arguments[i];
  56167. value = value[name];
  56168. s.push(name, value);
  56169. }
  56170. for (var i = 0; i < value.length; ++i) {
  56171. if (i in value) {
  56172. s.push(i, value[i]);
  56173. // If the callback needs to know the value of i, call
  56174. // path.getName(), assuming path is the parameter name.
  56175. callback(this);
  56176. s.length -= 2;
  56177. }
  56178. }
  56179. s.length = origLen;
  56180. };
  56181. // Similar to FastPath.prototype.each, except that the results of the
  56182. // callback function invocations are stored in an array and returned at
  56183. // the end of the iteration.
  56184. FPp.map = function map(callback/*, name1, name2, ... */) {
  56185. var s = this.stack;
  56186. var origLen = s.length;
  56187. var value = s[origLen - 1];
  56188. var argc = arguments.length;
  56189. for (var i = 1; i < argc; ++i) {
  56190. var name = arguments[i];
  56191. value = value[name];
  56192. s.push(name, value);
  56193. }
  56194. var result = new Array(value.length);
  56195. for (var i = 0; i < value.length; ++i) {
  56196. if (i in value) {
  56197. s.push(i, value[i]);
  56198. result[i] = callback(this, i);
  56199. s.length -= 2;
  56200. }
  56201. }
  56202. s.length = origLen;
  56203. return result;
  56204. };
  56205. // Inspired by require("ast-types").NodePath.prototype.needsParens, but
  56206. // more efficient because we're iterating backwards through a stack.
  56207. FPp.needsParens = function(assumeExpressionContext) {
  56208. var parent = this.getParentNode();
  56209. if (!parent) {
  56210. return false;
  56211. }
  56212. var name = this.getName();
  56213. var node = this.getNode();
  56214. // If the value of this path is some child of a Node and not a Node
  56215. // itself, then it doesn't need parentheses. Only Node objects (in
  56216. // fact, only Expression nodes) need parentheses.
  56217. if (this.getValue() !== node) {
  56218. return false;
  56219. }
  56220. // Only expressions need parentheses.
  56221. if (!n.Expression.check(node)) {
  56222. return false;
  56223. }
  56224. // Identifiers never need parentheses.
  56225. if (node.type === "Identifier") {
  56226. return false;
  56227. }
  56228. switch (node.type) {
  56229. case "UnaryExpression":
  56230. case "SpreadElement":
  56231. case "SpreadProperty":
  56232. return parent.type === "MemberExpression"
  56233. && name === "object"
  56234. && parent.object === node;
  56235. case "BinaryExpression":
  56236. case "LogicalExpression":
  56237. switch (parent.type) {
  56238. case "CallExpression":
  56239. return name === "callee"
  56240. && parent.callee === node;
  56241. case "UnaryExpression":
  56242. case "SpreadElement":
  56243. case "SpreadProperty":
  56244. return true;
  56245. case "MemberExpression":
  56246. return name === "object"
  56247. && parent.object === node;
  56248. case "BinaryExpression":
  56249. case "LogicalExpression":
  56250. var po = parent.operator;
  56251. var pp = PRECEDENCE[po];
  56252. var no = node.operator;
  56253. var np = PRECEDENCE[no];
  56254. if (pp > np) {
  56255. return true;
  56256. }
  56257. if (pp === np && name === "right") {
  56258. assert.strictEqual(parent.right, node);
  56259. return true;
  56260. }
  56261. default:
  56262. return false;
  56263. }
  56264. case "SequenceExpression":
  56265. switch (parent.type) {
  56266. case "ForStatement":
  56267. // Although parentheses wouldn't hurt around sequence
  56268. // expressions in the head of for loops, traditional style
  56269. // dictates that e.g. i++, j++ should not be wrapped with
  56270. // parentheses.
  56271. return false;
  56272. case "ExpressionStatement":
  56273. return name !== "expression";
  56274. default:
  56275. // Otherwise err on the side of overparenthesization, adding
  56276. // explicit exceptions above if this proves overzealous.
  56277. return true;
  56278. }
  56279. case "YieldExpression":
  56280. switch (parent.type) {
  56281. case "BinaryExpression":
  56282. case "LogicalExpression":
  56283. case "UnaryExpression":
  56284. case "SpreadElement":
  56285. case "SpreadProperty":
  56286. case "CallExpression":
  56287. case "MemberExpression":
  56288. case "NewExpression":
  56289. case "ConditionalExpression":
  56290. case "YieldExpression":
  56291. return true;
  56292. default:
  56293. return false;
  56294. }
  56295. case "Literal":
  56296. return parent.type === "MemberExpression"
  56297. && isNumber.check(node.value)
  56298. && name === "object"
  56299. && parent.object === node;
  56300. case "AssignmentExpression":
  56301. case "ConditionalExpression":
  56302. switch (parent.type) {
  56303. case "UnaryExpression":
  56304. case "SpreadElement":
  56305. case "SpreadProperty":
  56306. case "BinaryExpression":
  56307. case "LogicalExpression":
  56308. return true;
  56309. case "CallExpression":
  56310. return name === "callee"
  56311. && parent.callee === node;
  56312. case "ConditionalExpression":
  56313. return name === "test"
  56314. && parent.test === node;
  56315. case "MemberExpression":
  56316. return name === "object"
  56317. && parent.object === node;
  56318. default:
  56319. return false;
  56320. }
  56321. case "ArrowFunctionExpression":
  56322. return isBinary(parent);
  56323. case "ObjectExpression":
  56324. if (parent.type === "ArrowFunctionExpression" &&
  56325. name === "body") {
  56326. return true;
  56327. }
  56328. default:
  56329. if (parent.type === "NewExpression" &&
  56330. name === "callee" &&
  56331. parent.callee === node) {
  56332. return containsCallExpression(node);
  56333. }
  56334. }
  56335. if (assumeExpressionContext !== true &&
  56336. !this.canBeFirstInStatement() &&
  56337. this.firstInStatement())
  56338. return true;
  56339. return false;
  56340. };
  56341. function isBinary(node) {
  56342. return n.BinaryExpression.check(node)
  56343. || n.LogicalExpression.check(node);
  56344. }
  56345. function isUnaryLike(node) {
  56346. return n.UnaryExpression.check(node)
  56347. // I considered making SpreadElement and SpreadProperty subtypes
  56348. // of UnaryExpression, but they're not really Expression nodes.
  56349. || (n.SpreadElement && n.SpreadElement.check(node))
  56350. || (n.SpreadProperty && n.SpreadProperty.check(node));
  56351. }
  56352. var PRECEDENCE = {};
  56353. [["||"],
  56354. ["&&"],
  56355. ["|"],
  56356. ["^"],
  56357. ["&"],
  56358. ["==", "===", "!=", "!=="],
  56359. ["<", ">", "<=", ">=", "in", "instanceof"],
  56360. [">>", "<<", ">>>"],
  56361. ["+", "-"],
  56362. ["*", "/", "%"]
  56363. ].forEach(function(tier, i) {
  56364. tier.forEach(function(op) {
  56365. PRECEDENCE[op] = i;
  56366. });
  56367. });
  56368. function containsCallExpression(node) {
  56369. if (n.CallExpression.check(node)) {
  56370. return true;
  56371. }
  56372. if (isArray.check(node)) {
  56373. return node.some(containsCallExpression);
  56374. }
  56375. if (n.Node.check(node)) {
  56376. return types.someField(node, function(name, child) {
  56377. return containsCallExpression(child);
  56378. });
  56379. }
  56380. return false;
  56381. }
  56382. FPp.canBeFirstInStatement = function() {
  56383. var node = this.getNode();
  56384. return !n.FunctionExpression.check(node)
  56385. && !n.ObjectExpression.check(node);
  56386. };
  56387. FPp.firstInStatement = function() {
  56388. var s = this.stack;
  56389. var parentName, parent;
  56390. var childName, child;
  56391. for (var i = s.length - 1; i >= 0; i -= 2) {
  56392. if (n.Node.check(s[i])) {
  56393. childName = parentName;
  56394. child = parent;
  56395. parentName = s[i - 1];
  56396. parent = s[i];
  56397. }
  56398. if (!parent || !child) {
  56399. continue;
  56400. }
  56401. if (n.BlockStatement.check(parent) &&
  56402. parentName === "body" &&
  56403. childName === 0) {
  56404. assert.strictEqual(parent.body[0], child);
  56405. return true;
  56406. }
  56407. if (n.ExpressionStatement.check(parent) &&
  56408. childName === "expression") {
  56409. assert.strictEqual(parent.expression, child);
  56410. return true;
  56411. }
  56412. if (n.SequenceExpression.check(parent) &&
  56413. parentName === "expressions" &&
  56414. childName === 0) {
  56415. assert.strictEqual(parent.expressions[0], child);
  56416. continue;
  56417. }
  56418. if (n.CallExpression.check(parent) &&
  56419. childName === "callee") {
  56420. assert.strictEqual(parent.callee, child);
  56421. continue;
  56422. }
  56423. if (n.MemberExpression.check(parent) &&
  56424. childName === "object") {
  56425. assert.strictEqual(parent.object, child);
  56426. continue;
  56427. }
  56428. if (n.ConditionalExpression.check(parent) &&
  56429. childName === "test") {
  56430. assert.strictEqual(parent.test, child);
  56431. continue;
  56432. }
  56433. if (isBinary(parent) &&
  56434. childName === "left") {
  56435. assert.strictEqual(parent.left, child);
  56436. continue;
  56437. }
  56438. if (n.UnaryExpression.check(parent) &&
  56439. !parent.prefix &&
  56440. childName === "argument") {
  56441. assert.strictEqual(parent.argument, child);
  56442. continue;
  56443. }
  56444. return false;
  56445. }
  56446. return true;
  56447. };
  56448. },{"./types":467,"assert":190}],461:[function(require,module,exports){
  56449. var assert = require("assert");
  56450. var sourceMap = require("source-map");
  56451. var normalizeOptions = require("./options").normalize;
  56452. var secretKey = require("private").makeUniqueKey();
  56453. var types = require("./types");
  56454. var isString = types.builtInTypes.string;
  56455. var comparePos = require("./util").comparePos;
  56456. var Mapping = require("./mapping");
  56457. // Goals:
  56458. // 1. Minimize new string creation.
  56459. // 2. Keep (de)identation O(lines) time.
  56460. // 3. Permit negative indentations.
  56461. // 4. Enforce immutability.
  56462. // 5. No newline characters.
  56463. function getSecret(lines) {
  56464. return lines[secretKey];
  56465. }
  56466. function Lines(infos, sourceFileName) {
  56467. assert.ok(this instanceof Lines);
  56468. assert.ok(infos.length > 0);
  56469. if (sourceFileName) {
  56470. isString.assert(sourceFileName);
  56471. } else {
  56472. sourceFileName = null;
  56473. }
  56474. Object.defineProperty(this, secretKey, {
  56475. value: {
  56476. infos: infos,
  56477. mappings: [],
  56478. name: sourceFileName,
  56479. cachedSourceMap: null
  56480. }
  56481. });
  56482. if (sourceFileName) {
  56483. getSecret(this).mappings.push(new Mapping(this, {
  56484. start: this.firstPos(),
  56485. end: this.lastPos()
  56486. }));
  56487. }
  56488. }
  56489. // Exposed for instanceof checks. The fromString function should be used
  56490. // to create new Lines objects.
  56491. exports.Lines = Lines;
  56492. var Lp = Lines.prototype;
  56493. // These properties used to be assigned to each new object in the Lines
  56494. // constructor, but we can more efficiently stuff them into the secret and
  56495. // let these lazy accessors compute their values on-the-fly.
  56496. Object.defineProperties(Lp, {
  56497. length: {
  56498. get: function() {
  56499. return getSecret(this).infos.length;
  56500. }
  56501. },
  56502. name: {
  56503. get: function() {
  56504. return getSecret(this).name;
  56505. }
  56506. }
  56507. });
  56508. function copyLineInfo(info) {
  56509. return {
  56510. line: info.line,
  56511. indent: info.indent,
  56512. sliceStart: info.sliceStart,
  56513. sliceEnd: info.sliceEnd
  56514. };
  56515. }
  56516. var fromStringCache = {};
  56517. var hasOwn = fromStringCache.hasOwnProperty;
  56518. var maxCacheKeyLen = 10;
  56519. function countSpaces(spaces, tabWidth) {
  56520. var count = 0;
  56521. var len = spaces.length;
  56522. for (var i = 0; i < len; ++i) {
  56523. switch (spaces.charCodeAt(i)) {
  56524. case 9: // '\t'
  56525. assert.strictEqual(typeof tabWidth, "number");
  56526. assert.ok(tabWidth > 0);
  56527. var next = Math.ceil(count / tabWidth) * tabWidth;
  56528. if (next === count) {
  56529. count += tabWidth;
  56530. } else {
  56531. count = next;
  56532. }
  56533. break;
  56534. case 11: // '\v'
  56535. case 12: // '\f'
  56536. case 13: // '\r'
  56537. case 0xfeff: // zero-width non-breaking space
  56538. // These characters contribute nothing to indentation.
  56539. break;
  56540. case 32: // ' '
  56541. default: // Treat all other whitespace like ' '.
  56542. count += 1;
  56543. break;
  56544. }
  56545. }
  56546. return count;
  56547. }
  56548. exports.countSpaces = countSpaces;
  56549. var leadingSpaceExp = /^\s*/;
  56550. /**
  56551. * @param {Object} options - Options object that configures printing.
  56552. */
  56553. function fromString(string, options) {
  56554. if (string instanceof Lines)
  56555. return string;
  56556. string += "";
  56557. var tabWidth = options && options.tabWidth;
  56558. var tabless = string.indexOf("\t") < 0;
  56559. var cacheable = !options && tabless && (string.length <= maxCacheKeyLen);
  56560. assert.ok(tabWidth || tabless, "No tab width specified but encountered tabs in string\n" + string);
  56561. if (cacheable && hasOwn.call(fromStringCache, string))
  56562. return fromStringCache[string];
  56563. var lines = new Lines(string.split("\n").map(function(line) {
  56564. var spaces = leadingSpaceExp.exec(line)[0];
  56565. return {
  56566. line: line,
  56567. indent: countSpaces(spaces, tabWidth),
  56568. sliceStart: spaces.length,
  56569. sliceEnd: line.length
  56570. };
  56571. }), normalizeOptions(options).sourceFileName);
  56572. if (cacheable)
  56573. fromStringCache[string] = lines;
  56574. return lines;
  56575. }
  56576. exports.fromString = fromString;
  56577. function isOnlyWhitespace(string) {
  56578. return !/\S/.test(string);
  56579. }
  56580. Lp.toString = function(options) {
  56581. return this.sliceString(this.firstPos(), this.lastPos(), options);
  56582. };
  56583. Lp.getSourceMap = function(sourceMapName, sourceRoot) {
  56584. if (!sourceMapName) {
  56585. // Although we could make up a name or generate an anonymous
  56586. // source map, instead we assume that any consumer who does not
  56587. // provide a name does not actually want a source map.
  56588. return null;
  56589. }
  56590. var targetLines = this;
  56591. function updateJSON(json) {
  56592. json = json || {};
  56593. isString.assert(sourceMapName);
  56594. json.file = sourceMapName;
  56595. if (sourceRoot) {
  56596. isString.assert(sourceRoot);
  56597. json.sourceRoot = sourceRoot;
  56598. }
  56599. return json;
  56600. }
  56601. var secret = getSecret(targetLines);
  56602. if (secret.cachedSourceMap) {
  56603. // Since Lines objects are immutable, we can reuse any source map
  56604. // that was previously generated. Nevertheless, we return a new
  56605. // JSON object here to protect the cached source map from outside
  56606. // modification.
  56607. return updateJSON(secret.cachedSourceMap.toJSON());
  56608. }
  56609. var smg = new sourceMap.SourceMapGenerator(updateJSON());
  56610. var sourcesToContents = {};
  56611. secret.mappings.forEach(function(mapping) {
  56612. var sourceCursor = mapping.sourceLines.skipSpaces(
  56613. mapping.sourceLoc.start
  56614. ) || mapping.sourceLines.lastPos();
  56615. var targetCursor = targetLines.skipSpaces(
  56616. mapping.targetLoc.start
  56617. ) || targetLines.lastPos();
  56618. while (comparePos(sourceCursor, mapping.sourceLoc.end) < 0 &&
  56619. comparePos(targetCursor, mapping.targetLoc.end) < 0) {
  56620. var sourceChar = mapping.sourceLines.charAt(sourceCursor);
  56621. var targetChar = targetLines.charAt(targetCursor);
  56622. assert.strictEqual(sourceChar, targetChar);
  56623. var sourceName = mapping.sourceLines.name;
  56624. // Add mappings one character at a time for maximum resolution.
  56625. smg.addMapping({
  56626. source: sourceName,
  56627. original: { line: sourceCursor.line,
  56628. column: sourceCursor.column },
  56629. generated: { line: targetCursor.line,
  56630. column: targetCursor.column }
  56631. });
  56632. if (!hasOwn.call(sourcesToContents, sourceName)) {
  56633. var sourceContent = mapping.sourceLines.toString();
  56634. smg.setSourceContent(sourceName, sourceContent);
  56635. sourcesToContents[sourceName] = sourceContent;
  56636. }
  56637. targetLines.nextPos(targetCursor, true);
  56638. mapping.sourceLines.nextPos(sourceCursor, true);
  56639. }
  56640. });
  56641. secret.cachedSourceMap = smg;
  56642. return smg.toJSON();
  56643. };
  56644. Lp.bootstrapCharAt = function(pos) {
  56645. assert.strictEqual(typeof pos, "object");
  56646. assert.strictEqual(typeof pos.line, "number");
  56647. assert.strictEqual(typeof pos.column, "number");
  56648. var line = pos.line,
  56649. column = pos.column,
  56650. strings = this.toString().split("\n"),
  56651. string = strings[line - 1];
  56652. if (typeof string === "undefined")
  56653. return "";
  56654. if (column === string.length &&
  56655. line < strings.length)
  56656. return "\n";
  56657. if (column >= string.length)
  56658. return "";
  56659. return string.charAt(column);
  56660. };
  56661. Lp.charAt = function(pos) {
  56662. assert.strictEqual(typeof pos, "object");
  56663. assert.strictEqual(typeof pos.line, "number");
  56664. assert.strictEqual(typeof pos.column, "number");
  56665. var line = pos.line,
  56666. column = pos.column,
  56667. secret = getSecret(this),
  56668. infos = secret.infos,
  56669. info = infos[line - 1],
  56670. c = column;
  56671. if (typeof info === "undefined" || c < 0)
  56672. return "";
  56673. var indent = this.getIndentAt(line);
  56674. if (c < indent)
  56675. return " ";
  56676. c += info.sliceStart - indent;
  56677. if (c === info.sliceEnd &&
  56678. line < this.length)
  56679. return "\n";
  56680. if (c >= info.sliceEnd)
  56681. return "";
  56682. return info.line.charAt(c);
  56683. };
  56684. Lp.stripMargin = function(width, skipFirstLine) {
  56685. if (width === 0)
  56686. return this;
  56687. assert.ok(width > 0, "negative margin: " + width);
  56688. if (skipFirstLine && this.length === 1)
  56689. return this;
  56690. var secret = getSecret(this);
  56691. var lines = new Lines(secret.infos.map(function(info, i) {
  56692. if (info.line && (i > 0 || !skipFirstLine)) {
  56693. info = copyLineInfo(info);
  56694. info.indent = Math.max(0, info.indent - width);
  56695. }
  56696. return info;
  56697. }));
  56698. if (secret.mappings.length > 0) {
  56699. var newMappings = getSecret(lines).mappings;
  56700. assert.strictEqual(newMappings.length, 0);
  56701. secret.mappings.forEach(function(mapping) {
  56702. newMappings.push(mapping.indent(width, skipFirstLine, true));
  56703. });
  56704. }
  56705. return lines;
  56706. };
  56707. Lp.indent = function(by) {
  56708. if (by === 0)
  56709. return this;
  56710. var secret = getSecret(this);
  56711. var lines = new Lines(secret.infos.map(function(info) {
  56712. if (info.line) {
  56713. info = copyLineInfo(info);
  56714. info.indent += by;
  56715. }
  56716. return info
  56717. }));
  56718. if (secret.mappings.length > 0) {
  56719. var newMappings = getSecret(lines).mappings;
  56720. assert.strictEqual(newMappings.length, 0);
  56721. secret.mappings.forEach(function(mapping) {
  56722. newMappings.push(mapping.indent(by));
  56723. });
  56724. }
  56725. return lines;
  56726. };
  56727. Lp.indentTail = function(by) {
  56728. if (by === 0)
  56729. return this;
  56730. if (this.length < 2)
  56731. return this;
  56732. var secret = getSecret(this);
  56733. var lines = new Lines(secret.infos.map(function(info, i) {
  56734. if (i > 0 && info.line) {
  56735. info = copyLineInfo(info);
  56736. info.indent += by;
  56737. }
  56738. return info;
  56739. }));
  56740. if (secret.mappings.length > 0) {
  56741. var newMappings = getSecret(lines).mappings;
  56742. assert.strictEqual(newMappings.length, 0);
  56743. secret.mappings.forEach(function(mapping) {
  56744. newMappings.push(mapping.indent(by, true));
  56745. });
  56746. }
  56747. return lines;
  56748. };
  56749. Lp.getIndentAt = function(line) {
  56750. assert.ok(line >= 1, "no line " + line + " (line numbers start from 1)");
  56751. var secret = getSecret(this),
  56752. info = secret.infos[line - 1];
  56753. return Math.max(info.indent, 0);
  56754. };
  56755. Lp.guessTabWidth = function() {
  56756. var secret = getSecret(this);
  56757. if (hasOwn.call(secret, "cachedTabWidth")) {
  56758. return secret.cachedTabWidth;
  56759. }
  56760. var counts = []; // Sparse array.
  56761. var lastIndent = 0;
  56762. for (var line = 1, last = this.length; line <= last; ++line) {
  56763. var info = secret.infos[line - 1];
  56764. var sliced = info.line.slice(info.sliceStart, info.sliceEnd);
  56765. // Whitespace-only lines don't tell us much about the likely tab
  56766. // width of this code.
  56767. if (isOnlyWhitespace(sliced)) {
  56768. continue;
  56769. }
  56770. var diff = Math.abs(info.indent - lastIndent);
  56771. counts[diff] = ~~counts[diff] + 1;
  56772. lastIndent = info.indent;
  56773. }
  56774. var maxCount = -1;
  56775. var result = 2;
  56776. for (var tabWidth = 1;
  56777. tabWidth < counts.length;
  56778. tabWidth += 1) {
  56779. if (hasOwn.call(counts, tabWidth) &&
  56780. counts[tabWidth] > maxCount) {
  56781. maxCount = counts[tabWidth];
  56782. result = tabWidth;
  56783. }
  56784. }
  56785. return secret.cachedTabWidth = result;
  56786. };
  56787. Lp.isOnlyWhitespace = function() {
  56788. return isOnlyWhitespace(this.toString());
  56789. };
  56790. Lp.isPrecededOnlyByWhitespace = function(pos) {
  56791. var secret = getSecret(this);
  56792. var info = secret.infos[pos.line - 1];
  56793. var indent = Math.max(info.indent, 0);
  56794. var diff = pos.column - indent;
  56795. if (diff <= 0) {
  56796. // If pos.column does not exceed the indentation amount, then
  56797. // there must be only whitespace before it.
  56798. return true;
  56799. }
  56800. var start = info.sliceStart;
  56801. var end = Math.min(start + diff, info.sliceEnd);
  56802. var prefix = info.line.slice(start, end);
  56803. return isOnlyWhitespace(prefix);
  56804. };
  56805. Lp.getLineLength = function(line) {
  56806. var secret = getSecret(this),
  56807. info = secret.infos[line - 1];
  56808. return this.getIndentAt(line) + info.sliceEnd - info.sliceStart;
  56809. };
  56810. Lp.nextPos = function(pos, skipSpaces) {
  56811. var l = Math.max(pos.line, 0),
  56812. c = Math.max(pos.column, 0);
  56813. if (c < this.getLineLength(l)) {
  56814. pos.column += 1;
  56815. return skipSpaces
  56816. ? !!this.skipSpaces(pos, false, true)
  56817. : true;
  56818. }
  56819. if (l < this.length) {
  56820. pos.line += 1;
  56821. pos.column = 0;
  56822. return skipSpaces
  56823. ? !!this.skipSpaces(pos, false, true)
  56824. : true;
  56825. }
  56826. return false;
  56827. };
  56828. Lp.prevPos = function(pos, skipSpaces) {
  56829. var l = pos.line,
  56830. c = pos.column;
  56831. if (c < 1) {
  56832. l -= 1;
  56833. if (l < 1)
  56834. return false;
  56835. c = this.getLineLength(l);
  56836. } else {
  56837. c = Math.min(c - 1, this.getLineLength(l));
  56838. }
  56839. pos.line = l;
  56840. pos.column = c;
  56841. return skipSpaces
  56842. ? !!this.skipSpaces(pos, true, true)
  56843. : true;
  56844. };
  56845. Lp.firstPos = function() {
  56846. // Trivial, but provided for completeness.
  56847. return { line: 1, column: 0 };
  56848. };
  56849. Lp.lastPos = function() {
  56850. return {
  56851. line: this.length,
  56852. column: this.getLineLength(this.length)
  56853. };
  56854. };
  56855. Lp.skipSpaces = function(pos, backward, modifyInPlace) {
  56856. if (pos) {
  56857. pos = modifyInPlace ? pos : {
  56858. line: pos.line,
  56859. column: pos.column
  56860. };
  56861. } else if (backward) {
  56862. pos = this.lastPos();
  56863. } else {
  56864. pos = this.firstPos();
  56865. }
  56866. if (backward) {
  56867. while (this.prevPos(pos)) {
  56868. if (!isOnlyWhitespace(this.charAt(pos)) &&
  56869. this.nextPos(pos)) {
  56870. return pos;
  56871. }
  56872. }
  56873. return null;
  56874. } else {
  56875. while (isOnlyWhitespace(this.charAt(pos))) {
  56876. if (!this.nextPos(pos)) {
  56877. return null;
  56878. }
  56879. }
  56880. return pos;
  56881. }
  56882. };
  56883. Lp.trimLeft = function() {
  56884. var pos = this.skipSpaces(this.firstPos(), false, true);
  56885. return pos ? this.slice(pos) : emptyLines;
  56886. };
  56887. Lp.trimRight = function() {
  56888. var pos = this.skipSpaces(this.lastPos(), true, true);
  56889. return pos ? this.slice(this.firstPos(), pos) : emptyLines;
  56890. };
  56891. Lp.trim = function() {
  56892. var start = this.skipSpaces(this.firstPos(), false, true);
  56893. if (start === null)
  56894. return emptyLines;
  56895. var end = this.skipSpaces(this.lastPos(), true, true);
  56896. assert.notStrictEqual(end, null);
  56897. return this.slice(start, end);
  56898. };
  56899. Lp.eachPos = function(callback, startPos, skipSpaces) {
  56900. var pos = this.firstPos();
  56901. if (startPos) {
  56902. pos.line = startPos.line,
  56903. pos.column = startPos.column
  56904. }
  56905. if (skipSpaces && !this.skipSpaces(pos, false, true)) {
  56906. return; // Encountered nothing but spaces.
  56907. }
  56908. do callback.call(this, pos);
  56909. while (this.nextPos(pos, skipSpaces));
  56910. };
  56911. Lp.bootstrapSlice = function(start, end) {
  56912. var strings = this.toString().split("\n").slice(
  56913. start.line - 1, end.line);
  56914. strings.push(strings.pop().slice(0, end.column));
  56915. strings[0] = strings[0].slice(start.column);
  56916. return fromString(strings.join("\n"));
  56917. };
  56918. Lp.slice = function(start, end) {
  56919. if (!end) {
  56920. if (!start) {
  56921. // The client seems to want a copy of this Lines object, but
  56922. // Lines objects are immutable, so it's perfectly adequate to
  56923. // return the same object.
  56924. return this;
  56925. }
  56926. // Slice to the end if no end position was provided.
  56927. end = this.lastPos();
  56928. }
  56929. var secret = getSecret(this);
  56930. var sliced = secret.infos.slice(start.line - 1, end.line);
  56931. if (start.line === end.line) {
  56932. sliced[0] = sliceInfo(sliced[0], start.column, end.column);
  56933. } else {
  56934. assert.ok(start.line < end.line);
  56935. sliced[0] = sliceInfo(sliced[0], start.column);
  56936. sliced.push(sliceInfo(sliced.pop(), 0, end.column));
  56937. }
  56938. var lines = new Lines(sliced);
  56939. if (secret.mappings.length > 0) {
  56940. var newMappings = getSecret(lines).mappings;
  56941. assert.strictEqual(newMappings.length, 0);
  56942. secret.mappings.forEach(function(mapping) {
  56943. var sliced = mapping.slice(this, start, end);
  56944. if (sliced) {
  56945. newMappings.push(sliced);
  56946. }
  56947. }, this);
  56948. }
  56949. return lines;
  56950. };
  56951. function sliceInfo(info, startCol, endCol) {
  56952. var sliceStart = info.sliceStart;
  56953. var sliceEnd = info.sliceEnd;
  56954. var indent = Math.max(info.indent, 0);
  56955. var lineLength = indent + sliceEnd - sliceStart;
  56956. if (typeof endCol === "undefined") {
  56957. endCol = lineLength;
  56958. }
  56959. startCol = Math.max(startCol, 0);
  56960. endCol = Math.min(endCol, lineLength);
  56961. endCol = Math.max(endCol, startCol);
  56962. if (endCol < indent) {
  56963. indent = endCol;
  56964. sliceEnd = sliceStart;
  56965. } else {
  56966. sliceEnd -= lineLength - endCol;
  56967. }
  56968. lineLength = endCol;
  56969. lineLength -= startCol;
  56970. if (startCol < indent) {
  56971. indent -= startCol;
  56972. } else {
  56973. startCol -= indent;
  56974. indent = 0;
  56975. sliceStart += startCol;
  56976. }
  56977. assert.ok(indent >= 0);
  56978. assert.ok(sliceStart <= sliceEnd);
  56979. assert.strictEqual(lineLength, indent + sliceEnd - sliceStart);
  56980. if (info.indent === indent &&
  56981. info.sliceStart === sliceStart &&
  56982. info.sliceEnd === sliceEnd) {
  56983. return info;
  56984. }
  56985. return {
  56986. line: info.line,
  56987. indent: indent,
  56988. sliceStart: sliceStart,
  56989. sliceEnd: sliceEnd
  56990. };
  56991. }
  56992. Lp.bootstrapSliceString = function(start, end, options) {
  56993. return this.slice(start, end).toString(options);
  56994. };
  56995. Lp.sliceString = function(start, end, options) {
  56996. if (!end) {
  56997. if (!start) {
  56998. // The client seems to want a copy of this Lines object, but
  56999. // Lines objects are immutable, so it's perfectly adequate to
  57000. // return the same object.
  57001. return this;
  57002. }
  57003. // Slice to the end if no end position was provided.
  57004. end = this.lastPos();
  57005. }
  57006. options = normalizeOptions(options);
  57007. var infos = getSecret(this).infos;
  57008. var parts = [];
  57009. var tabWidth = options.tabWidth;
  57010. for (var line = start.line; line <= end.line; ++line) {
  57011. var info = infos[line - 1];
  57012. if (line === start.line) {
  57013. if (line === end.line) {
  57014. info = sliceInfo(info, start.column, end.column);
  57015. } else {
  57016. info = sliceInfo(info, start.column);
  57017. }
  57018. } else if (line === end.line) {
  57019. info = sliceInfo(info, 0, end.column);
  57020. }
  57021. var indent = Math.max(info.indent, 0);
  57022. var before = info.line.slice(0, info.sliceStart);
  57023. if (options.reuseWhitespace &&
  57024. isOnlyWhitespace(before) &&
  57025. countSpaces(before, options.tabWidth) === indent) {
  57026. // Reuse original spaces if the indentation is correct.
  57027. parts.push(info.line.slice(0, info.sliceEnd));
  57028. continue;
  57029. }
  57030. var tabs = 0;
  57031. var spaces = indent;
  57032. if (options.useTabs) {
  57033. tabs = Math.floor(indent / tabWidth);
  57034. spaces -= tabs * tabWidth;
  57035. }
  57036. var result = "";
  57037. if (tabs > 0) {
  57038. result += new Array(tabs + 1).join("\t");
  57039. }
  57040. if (spaces > 0) {
  57041. result += new Array(spaces + 1).join(" ");
  57042. }
  57043. result += info.line.slice(info.sliceStart, info.sliceEnd);
  57044. parts.push(result);
  57045. }
  57046. return parts.join("\n");
  57047. };
  57048. Lp.isEmpty = function() {
  57049. return this.length < 2 && this.getLineLength(1) < 1;
  57050. };
  57051. Lp.join = function(elements) {
  57052. var separator = this;
  57053. var separatorSecret = getSecret(separator);
  57054. var infos = [];
  57055. var mappings = [];
  57056. var prevInfo;
  57057. function appendSecret(secret) {
  57058. if (secret === null)
  57059. return;
  57060. if (prevInfo) {
  57061. var info = secret.infos[0];
  57062. var indent = new Array(info.indent + 1).join(" ");
  57063. var prevLine = infos.length;
  57064. var prevColumn = Math.max(prevInfo.indent, 0) +
  57065. prevInfo.sliceEnd - prevInfo.sliceStart;
  57066. prevInfo.line = prevInfo.line.slice(
  57067. 0, prevInfo.sliceEnd) + indent + info.line.slice(
  57068. info.sliceStart, info.sliceEnd);
  57069. prevInfo.sliceEnd = prevInfo.line.length;
  57070. if (secret.mappings.length > 0) {
  57071. secret.mappings.forEach(function(mapping) {
  57072. mappings.push(mapping.add(prevLine, prevColumn));
  57073. });
  57074. }
  57075. } else if (secret.mappings.length > 0) {
  57076. mappings.push.apply(mappings, secret.mappings);
  57077. }
  57078. secret.infos.forEach(function(info, i) {
  57079. if (!prevInfo || i > 0) {
  57080. prevInfo = copyLineInfo(info);
  57081. infos.push(prevInfo);
  57082. }
  57083. });
  57084. }
  57085. function appendWithSeparator(secret, i) {
  57086. if (i > 0)
  57087. appendSecret(separatorSecret);
  57088. appendSecret(secret);
  57089. }
  57090. elements.map(function(elem) {
  57091. var lines = fromString(elem);
  57092. if (lines.isEmpty())
  57093. return null;
  57094. return getSecret(lines);
  57095. }).forEach(separator.isEmpty()
  57096. ? appendSecret
  57097. : appendWithSeparator);
  57098. if (infos.length < 1)
  57099. return emptyLines;
  57100. var lines = new Lines(infos);
  57101. getSecret(lines).mappings = mappings;
  57102. return lines;
  57103. };
  57104. exports.concat = function(elements) {
  57105. return emptyLines.join(elements);
  57106. };
  57107. Lp.concat = function(other) {
  57108. var args = arguments,
  57109. list = [this];
  57110. list.push.apply(list, args);
  57111. assert.strictEqual(list.length, args.length + 1);
  57112. return emptyLines.join(list);
  57113. };
  57114. // The emptyLines object needs to be created all the way down here so that
  57115. // Lines.prototype will be fully populated.
  57116. var emptyLines = fromString("");
  57117. },{"./mapping":462,"./options":463,"./types":467,"./util":468,"assert":190,"private":435,"source-map":483}],462:[function(require,module,exports){
  57118. var assert = require("assert");
  57119. var types = require("./types");
  57120. var isString = types.builtInTypes.string;
  57121. var isNumber = types.builtInTypes.number;
  57122. var SourceLocation = types.namedTypes.SourceLocation;
  57123. var Position = types.namedTypes.Position;
  57124. var linesModule = require("./lines");
  57125. var comparePos = require("./util").comparePos;
  57126. function Mapping(sourceLines, sourceLoc, targetLoc) {
  57127. assert.ok(this instanceof Mapping);
  57128. assert.ok(sourceLines instanceof linesModule.Lines);
  57129. SourceLocation.assert(sourceLoc);
  57130. if (targetLoc) {
  57131. // In certain cases it's possible for targetLoc.{start,end}.column
  57132. // values to be negative, which technically makes them no longer
  57133. // valid SourceLocation nodes, so we need to be more forgiving.
  57134. assert.ok(
  57135. isNumber.check(targetLoc.start.line) &&
  57136. isNumber.check(targetLoc.start.column) &&
  57137. isNumber.check(targetLoc.end.line) &&
  57138. isNumber.check(targetLoc.end.column)
  57139. );
  57140. } else {
  57141. // Assume identity mapping if no targetLoc specified.
  57142. targetLoc = sourceLoc;
  57143. }
  57144. Object.defineProperties(this, {
  57145. sourceLines: { value: sourceLines },
  57146. sourceLoc: { value: sourceLoc },
  57147. targetLoc: { value: targetLoc }
  57148. });
  57149. }
  57150. var Mp = Mapping.prototype;
  57151. module.exports = Mapping;
  57152. Mp.slice = function(lines, start, end) {
  57153. assert.ok(lines instanceof linesModule.Lines);
  57154. Position.assert(start);
  57155. if (end) {
  57156. Position.assert(end);
  57157. } else {
  57158. end = lines.lastPos();
  57159. }
  57160. var sourceLines = this.sourceLines;
  57161. var sourceLoc = this.sourceLoc;
  57162. var targetLoc = this.targetLoc;
  57163. function skip(name) {
  57164. var sourceFromPos = sourceLoc[name];
  57165. var targetFromPos = targetLoc[name];
  57166. var targetToPos = start;
  57167. if (name === "end") {
  57168. targetToPos = end;
  57169. } else {
  57170. assert.strictEqual(name, "start");
  57171. }
  57172. return skipChars(
  57173. sourceLines, sourceFromPos,
  57174. lines, targetFromPos, targetToPos
  57175. );
  57176. }
  57177. if (comparePos(start, targetLoc.start) <= 0) {
  57178. if (comparePos(targetLoc.end, end) <= 0) {
  57179. targetLoc = {
  57180. start: subtractPos(targetLoc.start, start.line, start.column),
  57181. end: subtractPos(targetLoc.end, start.line, start.column)
  57182. };
  57183. // The sourceLoc can stay the same because the contents of the
  57184. // targetLoc have not changed.
  57185. } else if (comparePos(end, targetLoc.start) <= 0) {
  57186. return null;
  57187. } else {
  57188. sourceLoc = {
  57189. start: sourceLoc.start,
  57190. end: skip("end")
  57191. };
  57192. targetLoc = {
  57193. start: subtractPos(targetLoc.start, start.line, start.column),
  57194. end: subtractPos(end, start.line, start.column)
  57195. };
  57196. }
  57197. } else {
  57198. if (comparePos(targetLoc.end, start) <= 0) {
  57199. return null;
  57200. }
  57201. if (comparePos(targetLoc.end, end) <= 0) {
  57202. sourceLoc = {
  57203. start: skip("start"),
  57204. end: sourceLoc.end
  57205. };
  57206. targetLoc = {
  57207. // Same as subtractPos(start, start.line, start.column):
  57208. start: { line: 1, column: 0 },
  57209. end: subtractPos(targetLoc.end, start.line, start.column)
  57210. };
  57211. } else {
  57212. sourceLoc = {
  57213. start: skip("start"),
  57214. end: skip("end")
  57215. };
  57216. targetLoc = {
  57217. // Same as subtractPos(start, start.line, start.column):
  57218. start: { line: 1, column: 0 },
  57219. end: subtractPos(end, start.line, start.column)
  57220. };
  57221. }
  57222. }
  57223. return new Mapping(this.sourceLines, sourceLoc, targetLoc);
  57224. };
  57225. Mp.add = function(line, column) {
  57226. return new Mapping(this.sourceLines, this.sourceLoc, {
  57227. start: addPos(this.targetLoc.start, line, column),
  57228. end: addPos(this.targetLoc.end, line, column)
  57229. });
  57230. };
  57231. function addPos(toPos, line, column) {
  57232. return {
  57233. line: toPos.line + line - 1,
  57234. column: (toPos.line === 1)
  57235. ? toPos.column + column
  57236. : toPos.column
  57237. };
  57238. }
  57239. Mp.subtract = function(line, column) {
  57240. return new Mapping(this.sourceLines, this.sourceLoc, {
  57241. start: subtractPos(this.targetLoc.start, line, column),
  57242. end: subtractPos(this.targetLoc.end, line, column)
  57243. });
  57244. };
  57245. function subtractPos(fromPos, line, column) {
  57246. return {
  57247. line: fromPos.line - line + 1,
  57248. column: (fromPos.line === line)
  57249. ? fromPos.column - column
  57250. : fromPos.column
  57251. };
  57252. }
  57253. Mp.indent = function(by, skipFirstLine, noNegativeColumns) {
  57254. if (by === 0) {
  57255. return this;
  57256. }
  57257. var targetLoc = this.targetLoc;
  57258. var startLine = targetLoc.start.line;
  57259. var endLine = targetLoc.end.line;
  57260. if (skipFirstLine && startLine === 1 && endLine === 1) {
  57261. return this;
  57262. }
  57263. targetLoc = {
  57264. start: targetLoc.start,
  57265. end: targetLoc.end
  57266. };
  57267. if (!skipFirstLine || startLine > 1) {
  57268. var startColumn = targetLoc.start.column + by;
  57269. targetLoc.start = {
  57270. line: startLine,
  57271. column: noNegativeColumns
  57272. ? Math.max(0, startColumn)
  57273. : startColumn
  57274. };
  57275. }
  57276. if (!skipFirstLine || endLine > 1) {
  57277. var endColumn = targetLoc.end.column + by;
  57278. targetLoc.end = {
  57279. line: endLine,
  57280. column: noNegativeColumns
  57281. ? Math.max(0, endColumn)
  57282. : endColumn
  57283. };
  57284. }
  57285. return new Mapping(this.sourceLines, this.sourceLoc, targetLoc);
  57286. };
  57287. function skipChars(
  57288. sourceLines, sourceFromPos,
  57289. targetLines, targetFromPos, targetToPos
  57290. ) {
  57291. assert.ok(sourceLines instanceof linesModule.Lines);
  57292. assert.ok(targetLines instanceof linesModule.Lines);
  57293. Position.assert(sourceFromPos);
  57294. Position.assert(targetFromPos);
  57295. Position.assert(targetToPos);
  57296. var targetComparison = comparePos(targetFromPos, targetToPos);
  57297. if (targetComparison === 0) {
  57298. // Trivial case: no characters to skip.
  57299. return sourceFromPos;
  57300. }
  57301. if (targetComparison < 0) {
  57302. // Skipping forward.
  57303. var sourceCursor = sourceLines.skipSpaces(sourceFromPos);
  57304. var targetCursor = targetLines.skipSpaces(targetFromPos);
  57305. var lineDiff = targetToPos.line - targetCursor.line;
  57306. sourceCursor.line += lineDiff;
  57307. targetCursor.line += lineDiff;
  57308. if (lineDiff > 0) {
  57309. // If jumping to later lines, reset columns to the beginnings
  57310. // of those lines.
  57311. sourceCursor.column = 0;
  57312. targetCursor.column = 0;
  57313. } else {
  57314. assert.strictEqual(lineDiff, 0);
  57315. }
  57316. while (comparePos(targetCursor, targetToPos) < 0 &&
  57317. targetLines.nextPos(targetCursor, true)) {
  57318. assert.ok(sourceLines.nextPos(sourceCursor, true));
  57319. assert.strictEqual(
  57320. sourceLines.charAt(sourceCursor),
  57321. targetLines.charAt(targetCursor)
  57322. );
  57323. }
  57324. } else {
  57325. // Skipping backward.
  57326. var sourceCursor = sourceLines.skipSpaces(sourceFromPos, true);
  57327. var targetCursor = targetLines.skipSpaces(targetFromPos, true);
  57328. var lineDiff = targetToPos.line - targetCursor.line;
  57329. sourceCursor.line += lineDiff;
  57330. targetCursor.line += lineDiff;
  57331. if (lineDiff < 0) {
  57332. // If jumping to earlier lines, reset columns to the ends of
  57333. // those lines.
  57334. sourceCursor.column = sourceLines.getLineLength(sourceCursor.line);
  57335. targetCursor.column = targetLines.getLineLength(targetCursor.line);
  57336. } else {
  57337. assert.strictEqual(lineDiff, 0);
  57338. }
  57339. while (comparePos(targetToPos, targetCursor) < 0 &&
  57340. targetLines.prevPos(targetCursor, true)) {
  57341. assert.ok(sourceLines.prevPos(sourceCursor, true));
  57342. assert.strictEqual(
  57343. sourceLines.charAt(sourceCursor),
  57344. targetLines.charAt(targetCursor)
  57345. );
  57346. }
  57347. }
  57348. return sourceCursor;
  57349. }
  57350. },{"./lines":461,"./types":467,"./util":468,"assert":190}],463:[function(require,module,exports){
  57351. var defaults = {
  57352. // If you want to use a different branch of esprima, or any other
  57353. // module that supports a .parse function, pass that module object to
  57354. // recast.parse as options.esprima.
  57355. esprima: require("esprima-fb"),
  57356. // Number of spaces the pretty-printer should use per tab for
  57357. // indentation. If you do not pass this option explicitly, it will be
  57358. // (quite reliably!) inferred from the original code.
  57359. tabWidth: 4,
  57360. // If you really want the pretty-printer to use tabs instead of
  57361. // spaces, make this option true.
  57362. useTabs: false,
  57363. // The reprinting code leaves leading whitespace untouched unless it
  57364. // has to reindent a line, or you pass false for this option.
  57365. reuseWhitespace: true,
  57366. // Some of the pretty-printer code (such as that for printing function
  57367. // parameter lists) makes a valiant attempt to prevent really long
  57368. // lines. You can adjust the limit by changing this option; however,
  57369. // there is no guarantee that line length will fit inside this limit.
  57370. wrapColumn: 74, // Aspirational for now.
  57371. // Pass a string as options.sourceFileName to recast.parse to tell the
  57372. // reprinter to keep track of reused code so that it can construct a
  57373. // source map automatically.
  57374. sourceFileName: null,
  57375. // Pass a string as options.sourceMapName to recast.print, and
  57376. // (provided you passed options.sourceFileName earlier) the
  57377. // PrintResult of recast.print will have a .map property for the
  57378. // generated source map.
  57379. sourceMapName: null,
  57380. // If provided, this option will be passed along to the source map
  57381. // generator as a root directory for relative source file paths.
  57382. sourceRoot: null,
  57383. // If you provide a source map that was generated from a previous call
  57384. // to recast.print as options.inputSourceMap, the old source map will
  57385. // be composed with the new source map.
  57386. inputSourceMap: null,
  57387. // If you want esprima to generate .range information (recast only
  57388. // uses .loc internally), pass true for this option.
  57389. range: false,
  57390. // If you want esprima not to throw exceptions when it encounters
  57391. // non-fatal errors, keep this option true.
  57392. tolerant: true,
  57393. // If you want to override the quotes used in string literals, specify
  57394. // either "single", "double", or "auto" here ("auto" will select the one
  57395. // which results in the shorter literal)
  57396. // Otherwise, the input marks will be preserved
  57397. quote: null,
  57398. }, hasOwn = defaults.hasOwnProperty;
  57399. // Copy options and fill in default values.
  57400. exports.normalize = function(options) {
  57401. options = options || defaults;
  57402. function get(key) {
  57403. return hasOwn.call(options, key)
  57404. ? options[key]
  57405. : defaults[key];
  57406. }
  57407. return {
  57408. tabWidth: +get("tabWidth"),
  57409. useTabs: !!get("useTabs"),
  57410. reuseWhitespace: !!get("reuseWhitespace"),
  57411. wrapColumn: Math.max(get("wrapColumn"), 0),
  57412. sourceFileName: get("sourceFileName"),
  57413. sourceMapName: get("sourceMapName"),
  57414. sourceRoot: get("sourceRoot"),
  57415. inputSourceMap: get("inputSourceMap"),
  57416. esprima: get("esprima"),
  57417. range: get("range"),
  57418. tolerant: get("tolerant"),
  57419. quote: get("quote"),
  57420. };
  57421. };
  57422. },{"esprima-fb":470}],464:[function(require,module,exports){
  57423. var assert = require("assert");
  57424. var types = require("./types");
  57425. var n = types.namedTypes;
  57426. var b = types.builders;
  57427. var isObject = types.builtInTypes.object;
  57428. var isArray = types.builtInTypes.array;
  57429. var isFunction = types.builtInTypes.function;
  57430. var Patcher = require("./patcher").Patcher;
  57431. var normalizeOptions = require("./options").normalize;
  57432. var fromString = require("./lines").fromString;
  57433. var attachComments = require("./comments").attach;
  57434. var util = require("./util");
  57435. exports.parse = function parse(source, options) {
  57436. options = normalizeOptions(options);
  57437. var lines = fromString(source, options);
  57438. var sourceWithoutTabs = lines.toString({
  57439. tabWidth: options.tabWidth,
  57440. reuseWhitespace: false,
  57441. useTabs: false
  57442. });
  57443. var program = options.esprima.parse(sourceWithoutTabs, {
  57444. loc: true,
  57445. range: options.range,
  57446. comment: true,
  57447. tolerant: options.tolerant,
  57448. sourceType: 'module'
  57449. });
  57450. // Expand the Program node's .loc to include all comments, since
  57451. // typically its .loc.start and .loc.end will coincide with those of
  57452. // the first and last statements, respectively, excluding any comments
  57453. // that fall outside that region.
  57454. program.loc = util.getTrueLoc(program);
  57455. var comments = program.comments;
  57456. delete program.comments;
  57457. // In order to ensure we reprint leading and trailing program
  57458. // comments, wrap the original Program node with a File node.
  57459. var file = b.file(program);
  57460. file.loc = {
  57461. lines: lines,
  57462. indent: 0,
  57463. start: lines.firstPos(),
  57464. end: lines.lastPos()
  57465. };
  57466. // Passing file.program here instead of just file means that initial
  57467. // comments will be attached to program.body[0] instead of program.
  57468. attachComments(
  57469. comments,
  57470. program.body.length ? file.program : file,
  57471. lines
  57472. );
  57473. // Return a copy of the original AST so that any changes made may be
  57474. // compared to the original.
  57475. return new TreeCopier(lines).copy(file);
  57476. };
  57477. function TreeCopier(lines) {
  57478. assert.ok(this instanceof TreeCopier);
  57479. this.lines = lines;
  57480. this.indent = 0;
  57481. }
  57482. var TCp = TreeCopier.prototype;
  57483. TCp.copy = function(node) {
  57484. if (isArray.check(node)) {
  57485. return node.map(this.copy, this);
  57486. }
  57487. if (!isObject.check(node)) {
  57488. return node;
  57489. }
  57490. util.fixFaultyLocations(node);
  57491. var copy = Object.create(Object.getPrototypeOf(node), {
  57492. original: { // Provide a link from the copy to the original.
  57493. value: node,
  57494. configurable: false,
  57495. enumerable: false,
  57496. writable: true
  57497. }
  57498. });
  57499. var loc = node.loc;
  57500. var oldIndent = this.indent;
  57501. var newIndent = oldIndent;
  57502. if (loc) {
  57503. // When node is a comment, we set node.loc.indent to
  57504. // node.loc.start.column so that, when/if we print the comment by
  57505. // itself, we can strip that much whitespace from the left margin
  57506. // of the comment. This only really matters for multiline Block
  57507. // comments, but it doesn't hurt for Line comments.
  57508. if (node.type === "Block" || node.type === "Line" ||
  57509. this.lines.isPrecededOnlyByWhitespace(loc.start)) {
  57510. newIndent = this.indent = loc.start.column;
  57511. }
  57512. loc.lines = this.lines;
  57513. loc.indent = newIndent;
  57514. }
  57515. var keys = Object.keys(node);
  57516. var keyCount = keys.length;
  57517. for (var i = 0; i < keyCount; ++i) {
  57518. var key = keys[i];
  57519. if (key === "loc") {
  57520. copy[key] = node[key];
  57521. } else {
  57522. copy[key] = this.copy(node[key]);
  57523. }
  57524. }
  57525. this.indent = oldIndent;
  57526. return copy;
  57527. };
  57528. },{"./comments":459,"./lines":461,"./options":463,"./patcher":465,"./types":467,"./util":468,"assert":190}],465:[function(require,module,exports){
  57529. var assert = require("assert");
  57530. var linesModule = require("./lines");
  57531. var types = require("./types");
  57532. var getFieldValue = types.getFieldValue;
  57533. var Printable = types.namedTypes.Printable;
  57534. var Expression = types.namedTypes.Expression;
  57535. var SourceLocation = types.namedTypes.SourceLocation;
  57536. var util = require("./util");
  57537. var comparePos = util.comparePos;
  57538. var FastPath = require("./fast-path");
  57539. var isObject = types.builtInTypes.object;
  57540. var isArray = types.builtInTypes.array;
  57541. var isString = types.builtInTypes.string;
  57542. var riskyAdjoiningCharExp = /[0-9a-z_$]/i;
  57543. function Patcher(lines) {
  57544. assert.ok(this instanceof Patcher);
  57545. assert.ok(lines instanceof linesModule.Lines);
  57546. var self = this,
  57547. replacements = [];
  57548. self.replace = function(loc, lines) {
  57549. if (isString.check(lines))
  57550. lines = linesModule.fromString(lines);
  57551. replacements.push({
  57552. lines: lines,
  57553. start: loc.start,
  57554. end: loc.end
  57555. });
  57556. };
  57557. self.get = function(loc) {
  57558. // If no location is provided, return the complete Lines object.
  57559. loc = loc || {
  57560. start: { line: 1, column: 0 },
  57561. end: { line: lines.length,
  57562. column: lines.getLineLength(lines.length) }
  57563. };
  57564. var sliceFrom = loc.start,
  57565. toConcat = [];
  57566. function pushSlice(from, to) {
  57567. assert.ok(comparePos(from, to) <= 0);
  57568. toConcat.push(lines.slice(from, to));
  57569. }
  57570. replacements.sort(function(a, b) {
  57571. return comparePos(a.start, b.start);
  57572. }).forEach(function(rep) {
  57573. if (comparePos(sliceFrom, rep.start) > 0) {
  57574. // Ignore nested replacement ranges.
  57575. } else {
  57576. pushSlice(sliceFrom, rep.start);
  57577. toConcat.push(rep.lines);
  57578. sliceFrom = rep.end;
  57579. }
  57580. });
  57581. pushSlice(sliceFrom, loc.end);
  57582. return linesModule.concat(toConcat);
  57583. };
  57584. }
  57585. exports.Patcher = Patcher;
  57586. var Pp = Patcher.prototype;
  57587. Pp.tryToReprintComments = function(newNode, oldNode, print) {
  57588. var patcher = this;
  57589. if (!newNode.comments &&
  57590. !oldNode.comments) {
  57591. // We were (vacuously) able to reprint all the comments!
  57592. return true;
  57593. }
  57594. var newPath = FastPath.from(newNode);
  57595. var oldPath = FastPath.from(oldNode);
  57596. newPath.stack.push("comments", getSurroundingComments(newNode));
  57597. oldPath.stack.push("comments", getSurroundingComments(oldNode));
  57598. var reprints = [];
  57599. var ableToReprintComments =
  57600. findArrayReprints(newPath, oldPath, reprints);
  57601. // No need to pop anything from newPath.stack or oldPath.stack, since
  57602. // newPath and oldPath are fresh local variables.
  57603. if (ableToReprintComments && reprints.length > 0) {
  57604. reprints.forEach(function(reprint) {
  57605. var oldComment = reprint.oldPath.getValue();
  57606. assert.ok(oldComment.leading || oldComment.trailing);
  57607. patcher.replace(
  57608. oldComment.loc,
  57609. // Comments can't have .comments, so it doesn't matter
  57610. // whether we print with comments or without.
  57611. print(reprint.newPath).indentTail(oldComment.loc.indent)
  57612. );
  57613. });
  57614. }
  57615. return ableToReprintComments;
  57616. };
  57617. // Get all comments that are either leading or trailing, ignoring any
  57618. // comments that occur inside node.loc. Returns an empty array for nodes
  57619. // with no leading or trailing comments.
  57620. function getSurroundingComments(node) {
  57621. var result = [];
  57622. if (node.comments &&
  57623. node.comments.length > 0) {
  57624. node.comments.forEach(function(comment) {
  57625. if (comment.leading || comment.trailing) {
  57626. result.push(comment);
  57627. }
  57628. });
  57629. }
  57630. return result;
  57631. }
  57632. Pp.deleteComments = function(node) {
  57633. if (!node.comments) {
  57634. return;
  57635. }
  57636. var patcher = this;
  57637. node.comments.forEach(function(comment) {
  57638. if (comment.leading) {
  57639. // Delete leading comments along with any trailing whitespace
  57640. // they might have.
  57641. patcher.replace({
  57642. start: comment.loc.start,
  57643. end: node.loc.lines.skipSpaces(
  57644. comment.loc.end, false, false)
  57645. }, "");
  57646. } else if (comment.trailing) {
  57647. // Delete trailing comments along with any leading whitespace
  57648. // they might have.
  57649. patcher.replace({
  57650. start: node.loc.lines.skipSpaces(
  57651. comment.loc.start, true, false),
  57652. end: comment.loc.end
  57653. }, "");
  57654. }
  57655. });
  57656. };
  57657. exports.getReprinter = function(path) {
  57658. assert.ok(path instanceof FastPath);
  57659. // Make sure that this path refers specifically to a Node, rather than
  57660. // some non-Node subproperty of a Node.
  57661. var node = path.getValue();
  57662. if (!Printable.check(node))
  57663. return;
  57664. var orig = node.original;
  57665. var origLoc = orig && orig.loc;
  57666. var lines = origLoc && origLoc.lines;
  57667. var reprints = [];
  57668. if (!lines || !findReprints(path, reprints))
  57669. return;
  57670. return function(print) {
  57671. var patcher = new Patcher(lines);
  57672. reprints.forEach(function(reprint) {
  57673. var newNode = reprint.newPath.getValue();
  57674. var oldNode = reprint.oldPath.getValue();
  57675. SourceLocation.assert(oldNode.loc, true);
  57676. var needToPrintNewPathWithComments =
  57677. !patcher.tryToReprintComments(newNode, oldNode, print)
  57678. if (needToPrintNewPathWithComments) {
  57679. // Since we were not able to preserve all leading/trailing
  57680. // comments, we delete oldNode's comments, print newPath
  57681. // with comments, and then patch the resulting lines where
  57682. // oldNode used to be.
  57683. patcher.deleteComments(oldNode);
  57684. }
  57685. var pos = util.copyPos(oldNode.loc.start);
  57686. var needsLeadingSpace = lines.prevPos(pos) &&
  57687. riskyAdjoiningCharExp.test(lines.charAt(pos));
  57688. var newLines = print(
  57689. reprint.newPath,
  57690. needToPrintNewPathWithComments
  57691. ).indentTail(oldNode.loc.indent);
  57692. var needsTrailingSpace =
  57693. riskyAdjoiningCharExp.test(lines.charAt(oldNode.loc.end));
  57694. // If we try to replace the argument of a ReturnStatement like
  57695. // return"asdf" with e.g. a literal null expression, we run
  57696. // the risk of ending up with returnnull, so we need to add an
  57697. // extra leading space in situations where that might
  57698. // happen. Likewise for "asdf"in obj. See #170.
  57699. if (needsLeadingSpace || needsTrailingSpace) {
  57700. var newParts = [];
  57701. needsLeadingSpace && newParts.push(" ");
  57702. newParts.push(newLines);
  57703. needsTrailingSpace && newParts.push(" ");
  57704. newLines = linesModule.concat(newParts);
  57705. }
  57706. patcher.replace(oldNode.loc, newLines);
  57707. });
  57708. // Recall that origLoc is the .loc of an ancestor node that is
  57709. // guaranteed to contain all the reprinted nodes and comments.
  57710. return patcher.get(origLoc).indentTail(-orig.loc.indent);
  57711. };
  57712. };
  57713. function findReprints(newPath, reprints) {
  57714. var newNode = newPath.getValue();
  57715. Printable.assert(newNode);
  57716. var oldNode = newNode.original;
  57717. Printable.assert(oldNode);
  57718. assert.deepEqual(reprints, []);
  57719. if (newNode.type !== oldNode.type) {
  57720. return false;
  57721. }
  57722. var oldPath = new FastPath(oldNode);
  57723. var canReprint = findChildReprints(newPath, oldPath, reprints);
  57724. if (!canReprint) {
  57725. // Make absolutely sure the calling code does not attempt to reprint
  57726. // any nodes.
  57727. reprints.length = 0;
  57728. }
  57729. return canReprint;
  57730. }
  57731. function findAnyReprints(newPath, oldPath, reprints) {
  57732. var newNode = newPath.getValue();
  57733. var oldNode = oldPath.getValue();
  57734. if (newNode === oldNode)
  57735. return true;
  57736. if (isArray.check(newNode))
  57737. return findArrayReprints(newPath, oldPath, reprints);
  57738. if (isObject.check(newNode))
  57739. return findObjectReprints(newPath, oldPath, reprints);
  57740. return false;
  57741. }
  57742. function findArrayReprints(newPath, oldPath, reprints) {
  57743. var newNode = newPath.getValue();
  57744. var oldNode = oldPath.getValue();
  57745. isArray.assert(newNode);
  57746. var len = newNode.length;
  57747. if (!(isArray.check(oldNode) &&
  57748. oldNode.length === len))
  57749. return false;
  57750. for (var i = 0; i < len; ++i) {
  57751. newPath.stack.push(i, newNode[i]);
  57752. oldPath.stack.push(i, oldNode[i]);
  57753. var canReprint = findAnyReprints(newPath, oldPath, reprints);
  57754. newPath.stack.length -= 2;
  57755. oldPath.stack.length -= 2;
  57756. if (!canReprint) {
  57757. return false;
  57758. }
  57759. }
  57760. return true;
  57761. }
  57762. function findObjectReprints(newPath, oldPath, reprints) {
  57763. var newNode = newPath.getValue();
  57764. isObject.assert(newNode);
  57765. if (newNode.original === null) {
  57766. // If newNode.original node was set to null, reprint the node.
  57767. return false;
  57768. }
  57769. var oldNode = oldPath.getValue();
  57770. if (!isObject.check(oldNode))
  57771. return false;
  57772. if (Printable.check(newNode)) {
  57773. if (!Printable.check(oldNode)) {
  57774. return false;
  57775. }
  57776. // Here we need to decide whether the reprinted code for newNode
  57777. // is appropriate for patching into the location of oldNode.
  57778. if (newNode.type === oldNode.type) {
  57779. var childReprints = [];
  57780. if (findChildReprints(newPath, oldPath, childReprints)) {
  57781. reprints.push.apply(reprints, childReprints);
  57782. } else if (oldNode.loc) {
  57783. // If we have no .loc information for oldNode, then we
  57784. // won't be able to reprint it.
  57785. reprints.push({
  57786. oldPath: oldPath.copy(),
  57787. newPath: newPath.copy()
  57788. });
  57789. } else {
  57790. return false;
  57791. }
  57792. return true;
  57793. }
  57794. if (Expression.check(newNode) &&
  57795. Expression.check(oldNode) &&
  57796. // If we have no .loc information for oldNode, then we won't
  57797. // be able to reprint it.
  57798. oldNode.loc) {
  57799. // If both nodes are subtypes of Expression, then we should be
  57800. // able to fill the location occupied by the old node with
  57801. // code printed for the new node with no ill consequences.
  57802. reprints.push({
  57803. oldPath: oldPath.copy(),
  57804. newPath: newPath.copy()
  57805. });
  57806. return true;
  57807. }
  57808. // The nodes have different types, and at least one of the types
  57809. // is not a subtype of the Expression type, so we cannot safely
  57810. // assume the nodes are syntactically interchangeable.
  57811. return false;
  57812. }
  57813. return findChildReprints(newPath, oldPath, reprints);
  57814. }
  57815. // This object is reused in hasOpeningParen and hasClosingParen to avoid
  57816. // having to allocate a temporary object.
  57817. var reusablePos = { line: 1, column: 0 };
  57818. var nonSpaceExp = /\S/;
  57819. function hasOpeningParen(oldPath) {
  57820. var oldNode = oldPath.getValue();
  57821. var loc = oldNode.loc;
  57822. var lines = loc && loc.lines;
  57823. if (lines) {
  57824. var pos = reusablePos;
  57825. pos.line = loc.start.line;
  57826. pos.column = loc.start.column;
  57827. while (lines.prevPos(pos)) {
  57828. var ch = lines.charAt(pos);
  57829. if (ch === "(") {
  57830. // If we found an opening parenthesis but it occurred before
  57831. // the start of the original subtree for this reprinting, then
  57832. // we must not return true for hasOpeningParen(oldPath).
  57833. return comparePos(oldPath.getRootValue().loc.start, pos) <= 0;
  57834. }
  57835. if (nonSpaceExp.test(ch)) {
  57836. return false;
  57837. }
  57838. }
  57839. }
  57840. return false;
  57841. }
  57842. function hasClosingParen(oldPath) {
  57843. var oldNode = oldPath.getValue();
  57844. var loc = oldNode.loc;
  57845. var lines = loc && loc.lines;
  57846. if (lines) {
  57847. var pos = reusablePos;
  57848. pos.line = loc.end.line;
  57849. pos.column = loc.end.column;
  57850. do {
  57851. var ch = lines.charAt(pos);
  57852. if (ch === ")") {
  57853. // If we found a closing parenthesis but it occurred after the
  57854. // end of the original subtree for this reprinting, then we
  57855. // must not return true for hasClosingParen(oldPath).
  57856. return comparePos(pos, oldPath.getRootValue().loc.end) <= 0;
  57857. }
  57858. if (nonSpaceExp.test(ch)) {
  57859. return false;
  57860. }
  57861. } while (lines.nextPos(pos));
  57862. }
  57863. return false;
  57864. }
  57865. function hasParens(oldPath) {
  57866. // This logic can technically be fooled if the node has parentheses
  57867. // but there are comments intervening between the parentheses and the
  57868. // node. In such cases the node will be harmlessly wrapped in an
  57869. // additional layer of parentheses.
  57870. return hasOpeningParen(oldPath) && hasClosingParen(oldPath);
  57871. }
  57872. function findChildReprints(newPath, oldPath, reprints) {
  57873. var newNode = newPath.getValue();
  57874. var oldNode = oldPath.getValue();
  57875. isObject.assert(newNode);
  57876. isObject.assert(oldNode);
  57877. if (newNode.original === null) {
  57878. // If newNode.original node was set to null, reprint the node.
  57879. return false;
  57880. }
  57881. // If this type of node cannot come lexically first in its enclosing
  57882. // statement (e.g. a function expression or object literal), and it
  57883. // seems to be doing so, then the only way we can ignore this problem
  57884. // and save ourselves from falling back to the pretty printer is if an
  57885. // opening parenthesis happens to precede the node. For example,
  57886. // (function(){ ... }()); does not need to be reprinted, even though
  57887. // the FunctionExpression comes lexically first in the enclosing
  57888. // ExpressionStatement and fails the hasParens test, because the
  57889. // parent CallExpression passes the hasParens test. If we relied on
  57890. // the path.needsParens() && !hasParens(oldNode) check below, the
  57891. // absence of a closing parenthesis after the FunctionExpression would
  57892. // trigger pretty-printing unnecessarily.
  57893. if (!newPath.canBeFirstInStatement() &&
  57894. newPath.firstInStatement() &&
  57895. !hasOpeningParen(oldPath))
  57896. return false;
  57897. // If this node needs parentheses and will not be wrapped with
  57898. // parentheses when reprinted, then return false to skip reprinting
  57899. // and let it be printed generically.
  57900. if (newPath.needsParens(true) && !hasParens(oldPath)) {
  57901. return false;
  57902. }
  57903. for (var k in util.getUnionOfKeys(newNode, oldNode)) {
  57904. if (k === "loc")
  57905. continue;
  57906. newPath.stack.push(k, types.getFieldValue(newNode, k));
  57907. oldPath.stack.push(k, types.getFieldValue(oldNode, k));
  57908. var canReprint = findAnyReprints(newPath, oldPath, reprints);
  57909. newPath.stack.length -= 2;
  57910. oldPath.stack.length -= 2;
  57911. if (!canReprint) {
  57912. return false;
  57913. }
  57914. }
  57915. return true;
  57916. }
  57917. },{"./fast-path":460,"./lines":461,"./types":467,"./util":468,"assert":190}],466:[function(require,module,exports){
  57918. var assert = require("assert");
  57919. var sourceMap = require("source-map");
  57920. var printComments = require("./comments").printComments;
  57921. var linesModule = require("./lines");
  57922. var fromString = linesModule.fromString;
  57923. var concat = linesModule.concat;
  57924. var normalizeOptions = require("./options").normalize;
  57925. var getReprinter = require("./patcher").getReprinter;
  57926. var types = require("./types");
  57927. var namedTypes = types.namedTypes;
  57928. var isString = types.builtInTypes.string;
  57929. var isObject = types.builtInTypes.object;
  57930. var FastPath = require("./fast-path");
  57931. var util = require("./util");
  57932. function PrintResult(code, sourceMap) {
  57933. assert.ok(this instanceof PrintResult);
  57934. isString.assert(code);
  57935. this.code = code;
  57936. if (sourceMap) {
  57937. isObject.assert(sourceMap);
  57938. this.map = sourceMap;
  57939. }
  57940. }
  57941. var PRp = PrintResult.prototype;
  57942. var warnedAboutToString = false;
  57943. PRp.toString = function() {
  57944. if (!warnedAboutToString) {
  57945. console.warn(
  57946. "Deprecation warning: recast.print now returns an object with " +
  57947. "a .code property. You appear to be treating the object as a " +
  57948. "string, which might still work but is strongly discouraged."
  57949. );
  57950. warnedAboutToString = true;
  57951. }
  57952. return this.code;
  57953. };
  57954. var emptyPrintResult = new PrintResult("");
  57955. function Printer(originalOptions) {
  57956. assert.ok(this instanceof Printer);
  57957. var explicitTabWidth = originalOptions && originalOptions.tabWidth;
  57958. var options = normalizeOptions(originalOptions);
  57959. assert.notStrictEqual(options, originalOptions);
  57960. // It's common for client code to pass the same options into both
  57961. // recast.parse and recast.print, but the Printer doesn't need (and
  57962. // can be confused by) options.sourceFileName, so we null it out.
  57963. options.sourceFileName = null;
  57964. function printWithComments(path) {
  57965. assert.ok(path instanceof FastPath);
  57966. return printComments(path, print);
  57967. }
  57968. function print(path, includeComments) {
  57969. if (includeComments)
  57970. return printWithComments(path);
  57971. assert.ok(path instanceof FastPath);
  57972. if (!explicitTabWidth) {
  57973. var oldTabWidth = options.tabWidth;
  57974. var loc = path.getNode().loc;
  57975. if (loc && loc.lines && loc.lines.guessTabWidth) {
  57976. options.tabWidth = loc.lines.guessTabWidth();
  57977. var lines = maybeReprint(path);
  57978. options.tabWidth = oldTabWidth;
  57979. return lines;
  57980. }
  57981. }
  57982. return maybeReprint(path);
  57983. }
  57984. function maybeReprint(path) {
  57985. var reprinter = getReprinter(path);
  57986. if (reprinter)
  57987. return maybeAddParens(path, reprinter(print));
  57988. return printRootGenerically(path);
  57989. }
  57990. // Print the root node generically, but then resume reprinting its
  57991. // children non-generically.
  57992. function printRootGenerically(path) {
  57993. return genericPrint(path, options, printWithComments);
  57994. }
  57995. // Print the entire AST generically.
  57996. function printGenerically(path) {
  57997. return genericPrint(path, options, printGenerically);
  57998. }
  57999. this.print = function(ast) {
  58000. if (!ast) {
  58001. return emptyPrintResult;
  58002. }
  58003. var lines = print(FastPath.from(ast), true);
  58004. return new PrintResult(
  58005. lines.toString(options),
  58006. util.composeSourceMaps(
  58007. options.inputSourceMap,
  58008. lines.getSourceMap(
  58009. options.sourceMapName,
  58010. options.sourceRoot
  58011. )
  58012. )
  58013. );
  58014. };
  58015. this.printGenerically = function(ast) {
  58016. if (!ast) {
  58017. return emptyPrintResult;
  58018. }
  58019. var path = FastPath.from(ast);
  58020. var oldReuseWhitespace = options.reuseWhitespace;
  58021. // Do not reuse whitespace (or anything else, for that matter)
  58022. // when printing generically.
  58023. options.reuseWhitespace = false;
  58024. // TODO Allow printing of comments?
  58025. var pr = new PrintResult(printGenerically(path).toString(options));
  58026. options.reuseWhitespace = oldReuseWhitespace;
  58027. return pr;
  58028. };
  58029. }
  58030. exports.Printer = Printer;
  58031. function maybeAddParens(path, lines) {
  58032. return path.needsParens() ? concat(["(", lines, ")"]) : lines;
  58033. }
  58034. function genericPrint(path, options, printPath) {
  58035. assert.ok(path instanceof FastPath);
  58036. return maybeAddParens(path, genericPrintNoParens(path, options, printPath));
  58037. }
  58038. function genericPrintNoParens(path, options, print) {
  58039. var n = path.getValue();
  58040. if (!n) {
  58041. return fromString("");
  58042. }
  58043. if (typeof n === "string") {
  58044. return fromString(n, options);
  58045. }
  58046. namedTypes.Printable.assert(n);
  58047. switch (n.type) {
  58048. case "File":
  58049. return path.call(print, "program");
  58050. case "Program":
  58051. return maybeAddSemicolon(path.call(function(bodyPath) {
  58052. return printStatementSequence(bodyPath, options, print);
  58053. }, "body"));
  58054. case "EmptyStatement":
  58055. return fromString("");
  58056. case "ExpressionStatement":
  58057. return concat([path.call(print, "expression"), ";"]);
  58058. case "BinaryExpression":
  58059. case "LogicalExpression":
  58060. case "AssignmentExpression":
  58061. return fromString(" ").join([
  58062. path.call(print, "left"),
  58063. n.operator,
  58064. path.call(print, "right")
  58065. ]);
  58066. case "AssignmentPattern":
  58067. return concat([
  58068. path.call(print, "left"),
  58069. "=",
  58070. path.call(print, "right")
  58071. ]);
  58072. case "MemberExpression":
  58073. var parts = [path.call(print, "object")];
  58074. var property = path.call(print, "property");
  58075. if (n.computed) {
  58076. parts.push("[", property, "]");
  58077. } else {
  58078. parts.push(".", property);
  58079. }
  58080. return concat(parts);
  58081. case "Path":
  58082. return fromString(".").join(n.body);
  58083. case "Identifier":
  58084. return concat([
  58085. fromString(n.name, options),
  58086. path.call(print, "typeAnnotation")
  58087. ]);
  58088. case "SpreadElement":
  58089. case "SpreadElementPattern":
  58090. case "SpreadProperty":
  58091. case "SpreadPropertyPattern":
  58092. case "RestElement":
  58093. return concat(["...", path.call(print, "argument")]);
  58094. case "FunctionDeclaration":
  58095. case "FunctionExpression":
  58096. var parts = [];
  58097. if (n.async)
  58098. parts.push("async ");
  58099. parts.push("function");
  58100. if (n.generator)
  58101. parts.push("*");
  58102. if (n.id) {
  58103. parts.push(
  58104. " ",
  58105. path.call(print, "id"),
  58106. path.call(print, "typeParameters")
  58107. );
  58108. }
  58109. parts.push(
  58110. "(",
  58111. printFunctionParams(path, options, print),
  58112. ")",
  58113. path.call(print, "returnType"),
  58114. " ",
  58115. path.call(print, "body")
  58116. );
  58117. return concat(parts);
  58118. case "ArrowFunctionExpression":
  58119. var parts = [];
  58120. if (n.async)
  58121. parts.push("async ");
  58122. if (n.params.length === 1 && !n.rest) {
  58123. parts.push(path.call(print, "params", 0));
  58124. } else {
  58125. parts.push(
  58126. "(",
  58127. printFunctionParams(path, options, print),
  58128. ")"
  58129. );
  58130. }
  58131. parts.push(" => ", path.call(print, "body"));
  58132. return concat(parts);
  58133. case "MethodDefinition":
  58134. var parts = [];
  58135. if (n.static) {
  58136. parts.push("static ");
  58137. }
  58138. parts.push(printMethod(path, options, print));
  58139. return concat(parts);
  58140. case "YieldExpression":
  58141. var parts = ["yield"];
  58142. if (n.delegate)
  58143. parts.push("*");
  58144. if (n.argument)
  58145. parts.push(" ", path.call(print, "argument"));
  58146. return concat(parts);
  58147. case "AwaitExpression":
  58148. var parts = ["await"];
  58149. if (n.all)
  58150. parts.push("*");
  58151. if (n.argument)
  58152. parts.push(" ", path.call(print, "argument"));
  58153. return concat(parts);
  58154. case "ModuleDeclaration":
  58155. var parts = ["module", path.call(print, "id")];
  58156. if (n.source) {
  58157. assert.ok(!n.body);
  58158. parts.push("from", path.call(print, "source"));
  58159. } else {
  58160. parts.push(path.call(print, "body"));
  58161. }
  58162. return fromString(" ").join(parts);
  58163. case "ImportSpecifier":
  58164. case "ExportSpecifier":
  58165. var parts = [path.call(print, "id")];
  58166. if (n.name)
  58167. parts.push(" as ", path.call(print, "name"));
  58168. return concat(parts);
  58169. case "ExportBatchSpecifier":
  58170. return fromString("*");
  58171. case "ImportNamespaceSpecifier":
  58172. return concat(["* as ", path.call(print, "id")]);
  58173. case "ImportDefaultSpecifier":
  58174. return path.call(print, "id");
  58175. case "ExportDeclaration":
  58176. var parts = ["export"];
  58177. if (n["default"]) {
  58178. parts.push(" default");
  58179. } else if (n.specifiers &&
  58180. n.specifiers.length > 0) {
  58181. if (n.specifiers.length === 1 &&
  58182. n.specifiers[0].type === "ExportBatchSpecifier") {
  58183. parts.push(" *");
  58184. } else {
  58185. parts.push(
  58186. " { ",
  58187. fromString(", ").join(path.map(print, "specifiers")),
  58188. " }"
  58189. );
  58190. }
  58191. if (n.source)
  58192. parts.push(" from ", path.call(print, "source"));
  58193. parts.push(";");
  58194. return concat(parts);
  58195. }
  58196. if (n.declaration) {
  58197. if (!namedTypes.Node.check(n.declaration)) {
  58198. console.log(JSON.stringify(n, null, 2));
  58199. }
  58200. var decLines = path.call(print, "declaration");
  58201. parts.push(" ", decLines);
  58202. if (lastNonSpaceCharacter(decLines) !== ";") {
  58203. parts.push(";");
  58204. }
  58205. }
  58206. return concat(parts);
  58207. case "ImportDeclaration":
  58208. var parts = ["import "];
  58209. if (n.specifiers &&
  58210. n.specifiers.length > 0) {
  58211. var foundImportSpecifier = false;
  58212. path.each(function(specifierPath) {
  58213. var i = specifierPath.getName();
  58214. if (i > 0) {
  58215. parts.push(", ");
  58216. }
  58217. var value = specifierPath.getValue();
  58218. if (namedTypes.ImportDefaultSpecifier.check(value) ||
  58219. namedTypes.ImportNamespaceSpecifier.check(value)) {
  58220. assert.strictEqual(foundImportSpecifier, false);
  58221. } else {
  58222. namedTypes.ImportSpecifier.assert(value);
  58223. if (!foundImportSpecifier) {
  58224. foundImportSpecifier = true;
  58225. parts.push("{");
  58226. }
  58227. }
  58228. parts.push(print(specifierPath));
  58229. }, "specifiers");
  58230. if (foundImportSpecifier) {
  58231. parts.push("}");
  58232. }
  58233. parts.push(" from ");
  58234. }
  58235. parts.push(path.call(print, "source"), ";");
  58236. return concat(parts);
  58237. case "BlockStatement":
  58238. var naked = path.call(function(bodyPath) {
  58239. return printStatementSequence(bodyPath, options, print);
  58240. }, "body");
  58241. if (naked.isEmpty()) {
  58242. return fromString("{}");
  58243. }
  58244. return concat([
  58245. "{\n",
  58246. naked.indent(options.tabWidth),
  58247. "\n}"
  58248. ]);
  58249. case "ReturnStatement":
  58250. var parts = ["return"];
  58251. if (n.argument) {
  58252. var argLines = path.call(print, "argument");
  58253. if (argLines.length > 1 &&
  58254. (namedTypes.XJSElement &&
  58255. namedTypes.XJSElement.check(n.argument) ||
  58256. namedTypes.JSXElement &&
  58257. namedTypes.JSXElement.check(n.argument))) {
  58258. parts.push(
  58259. " (\n",
  58260. argLines.indent(options.tabWidth),
  58261. "\n)"
  58262. );
  58263. } else {
  58264. parts.push(" ", argLines);
  58265. }
  58266. }
  58267. parts.push(";");
  58268. return concat(parts);
  58269. case "CallExpression":
  58270. return concat([
  58271. path.call(print, "callee"),
  58272. printArgumentsList(path, options, print)
  58273. ]);
  58274. case "ObjectExpression":
  58275. case "ObjectPattern":
  58276. case "ObjectTypeAnnotation":
  58277. var allowBreak = false;
  58278. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  58279. var separator = isTypeAnnotation ? ';' : ',';
  58280. var fields = [];
  58281. if (isTypeAnnotation) {
  58282. fields.push("indexers", "callProperties");
  58283. }
  58284. fields.push("properties");
  58285. var len = 0;
  58286. fields.forEach(function(field) {
  58287. len += n[field].length;
  58288. });
  58289. var oneLine = (isTypeAnnotation && len === 1) || len === 0;
  58290. var parts = [oneLine ? "{" : "{\n"];
  58291. fields.forEach(function(field) {
  58292. path.map(function(childPath) {
  58293. var i = childPath.getName();
  58294. var prop = childPath.getValue();
  58295. var lines = print(childPath);
  58296. if (!oneLine) {
  58297. lines = lines.indent(options.tabWidth);
  58298. }
  58299. var multiLine = !isTypeAnnotation && lines.length > 1;
  58300. if (multiLine && allowBreak) {
  58301. // Similar to the logic for BlockStatement.
  58302. parts.push("\n");
  58303. }
  58304. parts.push(lines);
  58305. if (i < len - 1) {
  58306. // Add an extra line break if the previous object property
  58307. // had a multi-line value.
  58308. parts.push(separator + (multiLine ? "\n\n" : "\n"));
  58309. allowBreak = !multiLine;
  58310. } else if (len !== 1 && isTypeAnnotation) {
  58311. parts.push(separator);
  58312. }
  58313. }, field);
  58314. });
  58315. parts.push(oneLine ? "}" : "\n}");
  58316. return concat(parts);
  58317. case "PropertyPattern":
  58318. return concat([
  58319. path.call(print, "key"),
  58320. ": ",
  58321. path.call(print, "pattern")
  58322. ]);
  58323. case "Property": // Non-standard AST node type.
  58324. if (n.method || n.kind === "get" || n.kind === "set") {
  58325. return printMethod(path, options, print);
  58326. }
  58327. var key = path.call(print, "key");
  58328. if (n.computed) {
  58329. key = concat(["[", key, "]"]);
  58330. }
  58331. if (n.shorthand) {
  58332. return key;
  58333. }
  58334. return concat([key, ": ", path.call(print, "value")]);
  58335. case "ArrayExpression":
  58336. case "ArrayPattern":
  58337. var elems = n.elements,
  58338. len = elems.length,
  58339. parts = ["["];
  58340. path.each(function(elemPath) {
  58341. var i = elemPath.getName();
  58342. var elem = elemPath.getValue();
  58343. if (!elem) {
  58344. // If the array expression ends with a hole, that hole
  58345. // will be ignored by the interpreter, but if it ends with
  58346. // two (or more) holes, we need to write out two (or more)
  58347. // commas so that the resulting code is interpreted with
  58348. // both (all) of the holes.
  58349. parts.push(",");
  58350. } else {
  58351. if (i > 0)
  58352. parts.push(" ");
  58353. parts.push(print(elemPath));
  58354. if (i < len - 1)
  58355. parts.push(",");
  58356. }
  58357. }, "elements");
  58358. parts.push("]");
  58359. return concat(parts);
  58360. case "SequenceExpression":
  58361. return fromString(", ").join(path.map(print, "expressions"));
  58362. case "ThisExpression":
  58363. return fromString("this");
  58364. case "Literal":
  58365. if (typeof n.value !== "string")
  58366. return fromString(n.value, options);
  58367. // intentionally fall through...
  58368. case "ModuleSpecifier":
  58369. return fromString(nodeStr(n.value, options), options);
  58370. case "UnaryExpression":
  58371. var parts = [n.operator];
  58372. if (/[a-z]$/.test(n.operator))
  58373. parts.push(" ");
  58374. parts.push(path.call(print, "argument"));
  58375. return concat(parts);
  58376. case "UpdateExpression":
  58377. var parts = [path.call(print, "argument"), n.operator];
  58378. if (n.prefix)
  58379. parts.reverse();
  58380. return concat(parts);
  58381. case "ConditionalExpression":
  58382. return concat([
  58383. "(", path.call(print, "test"),
  58384. " ? ", path.call(print, "consequent"),
  58385. " : ", path.call(print, "alternate"), ")"
  58386. ]);
  58387. case "NewExpression":
  58388. var parts = ["new ", path.call(print, "callee")];
  58389. var args = n.arguments;
  58390. if (args) {
  58391. parts.push(printArgumentsList(path, options, print));
  58392. }
  58393. return concat(parts);
  58394. case "VariableDeclaration":
  58395. var parts = [n.kind, " "];
  58396. var maxLen = 0;
  58397. var printed = path.map(function(childPath) {
  58398. var lines = print(childPath);
  58399. maxLen = Math.max(lines.length, maxLen);
  58400. return lines;
  58401. }, "declarations");
  58402. if (maxLen === 1) {
  58403. parts.push(fromString(", ").join(printed));
  58404. } else if (printed.length > 1 ) {
  58405. parts.push(
  58406. fromString(",\n").join(printed)
  58407. .indentTail(n.kind.length + 1)
  58408. );
  58409. } else {
  58410. parts.push(printed[0]);
  58411. }
  58412. // We generally want to terminate all variable declarations with a
  58413. // semicolon, except when they are children of for loops.
  58414. var parentNode = path.getParentNode();
  58415. if (!namedTypes.ForStatement.check(parentNode) &&
  58416. !namedTypes.ForInStatement.check(parentNode) &&
  58417. !(namedTypes.ForOfStatement &&
  58418. namedTypes.ForOfStatement.check(parentNode))) {
  58419. parts.push(";");
  58420. }
  58421. return concat(parts);
  58422. case "VariableDeclarator":
  58423. return n.init ? fromString(" = ").join([
  58424. path.call(print, "id"),
  58425. path.call(print, "init")
  58426. ]) : path.call(print, "id");
  58427. case "WithStatement":
  58428. return concat([
  58429. "with (",
  58430. path.call(print, "object"),
  58431. ") ",
  58432. path.call(print, "body")
  58433. ]);
  58434. case "IfStatement":
  58435. var con = adjustClause(path.call(print, "consequent"), options),
  58436. parts = ["if (", path.call(print, "test"), ")", con];
  58437. if (n.alternate)
  58438. parts.push(
  58439. endsWithBrace(con) ? " else" : "\nelse",
  58440. adjustClause(path.call(print, "alternate"), options));
  58441. return concat(parts);
  58442. case "ForStatement":
  58443. // TODO Get the for (;;) case right.
  58444. var init = path.call(print, "init"),
  58445. sep = init.length > 1 ? ";\n" : "; ",
  58446. forParen = "for (",
  58447. indented = fromString(sep).join([
  58448. init,
  58449. path.call(print, "test"),
  58450. path.call(print, "update")
  58451. ]).indentTail(forParen.length),
  58452. head = concat([forParen, indented, ")"]),
  58453. clause = adjustClause(path.call(print, "body"), options),
  58454. parts = [head];
  58455. if (head.length > 1) {
  58456. parts.push("\n");
  58457. clause = clause.trimLeft();
  58458. }
  58459. parts.push(clause);
  58460. return concat(parts);
  58461. case "WhileStatement":
  58462. return concat([
  58463. "while (",
  58464. path.call(print, "test"),
  58465. ")",
  58466. adjustClause(path.call(print, "body"), options)
  58467. ]);
  58468. case "ForInStatement":
  58469. // Note: esprima can't actually parse "for each (".
  58470. return concat([
  58471. n.each ? "for each (" : "for (",
  58472. path.call(print, "left"),
  58473. " in ",
  58474. path.call(print, "right"),
  58475. ")",
  58476. adjustClause(path.call(print, "body"), options)
  58477. ]);
  58478. case "ForOfStatement":
  58479. return concat([
  58480. "for (",
  58481. path.call(print, "left"),
  58482. " of ",
  58483. path.call(print, "right"),
  58484. ")",
  58485. adjustClause(path.call(print, "body"), options)
  58486. ]);
  58487. case "DoWhileStatement":
  58488. var doBody = concat([
  58489. "do",
  58490. adjustClause(path.call(print, "body"), options)
  58491. ]), parts = [doBody];
  58492. if (endsWithBrace(doBody))
  58493. parts.push(" while");
  58494. else
  58495. parts.push("\nwhile");
  58496. parts.push(" (", path.call(print, "test"), ");");
  58497. return concat(parts);
  58498. case "BreakStatement":
  58499. var parts = ["break"];
  58500. if (n.label)
  58501. parts.push(" ", path.call(print, "label"));
  58502. parts.push(";");
  58503. return concat(parts);
  58504. case "ContinueStatement":
  58505. var parts = ["continue"];
  58506. if (n.label)
  58507. parts.push(" ", path.call(print, "label"));
  58508. parts.push(";");
  58509. return concat(parts);
  58510. case "LabeledStatement":
  58511. return concat([
  58512. path.call(print, "label"),
  58513. ":\n",
  58514. path.call(print, "body")
  58515. ]);
  58516. case "TryStatement":
  58517. var parts = [
  58518. "try ",
  58519. path.call(print, "block")
  58520. ];
  58521. if (n.handler) {
  58522. parts.push(" ", path.call(print, "handler"));
  58523. } else if (n.handlers) {
  58524. path.each(function(handlerPath) {
  58525. parts.push(" ", print(handlerPath));
  58526. }, "handlers");
  58527. }
  58528. if (n.finalizer) {
  58529. parts.push(" finally ", path.call(print, "finalizer"));
  58530. }
  58531. return concat(parts);
  58532. case "CatchClause":
  58533. var parts = ["catch (", path.call(print, "param")];
  58534. if (n.guard)
  58535. // Note: esprima does not recognize conditional catch clauses.
  58536. parts.push(" if ", path.call(print, "guard"));
  58537. parts.push(") ", path.call(print, "body"));
  58538. return concat(parts);
  58539. case "ThrowStatement":
  58540. return concat(["throw ", path.call(print, "argument"), ";"]);
  58541. case "SwitchStatement":
  58542. return concat([
  58543. "switch (",
  58544. path.call(print, "discriminant"),
  58545. ") {\n",
  58546. fromString("\n").join(path.map(print, "cases")),
  58547. "\n}"
  58548. ]);
  58549. // Note: ignoring n.lexical because it has no printing consequences.
  58550. case "SwitchCase":
  58551. var parts = [];
  58552. if (n.test)
  58553. parts.push("case ", path.call(print, "test"), ":");
  58554. else
  58555. parts.push("default:");
  58556. if (n.consequent.length > 0) {
  58557. parts.push("\n", path.call(function(consequentPath) {
  58558. return printStatementSequence(consequentPath, options, print);
  58559. }, "consequent").indent(options.tabWidth));
  58560. }
  58561. return concat(parts);
  58562. case "DebuggerStatement":
  58563. return fromString("debugger;");
  58564. // JSX extensions below.
  58565. case "XJSAttribute":
  58566. case "JSXAttribute":
  58567. var parts = [path.call(print, "name")];
  58568. if (n.value)
  58569. parts.push("=", path.call(print, "value"));
  58570. return concat(parts);
  58571. case "XJSIdentifier":
  58572. case "JSXIdentifier":
  58573. return fromString(n.name, options);
  58574. case "XJSNamespacedName":
  58575. case "JSXNamespacedName":
  58576. return fromString(":").join([
  58577. path.call(print, "namespace"),
  58578. path.call(print, "name")
  58579. ]);
  58580. case "XJSMemberExpression":
  58581. case "JSXMemberExpression":
  58582. return fromString(".").join([
  58583. path.call(print, "object"),
  58584. path.call(print, "property")
  58585. ]);
  58586. case "XJSSpreadAttribute":
  58587. case "JSXSpreadAttribute":
  58588. return concat(["{...", path.call(print, "argument"), "}"]);
  58589. case "XJSExpressionContainer":
  58590. case "JSXExpressionContainer":
  58591. return concat(["{", path.call(print, "expression"), "}"]);
  58592. case "XJSElement":
  58593. case "JSXElement":
  58594. var openingLines = path.call(print, "openingElement");
  58595. if (n.openingElement.selfClosing) {
  58596. assert.ok(!n.closingElement);
  58597. return openingLines;
  58598. }
  58599. var childLines = concat(
  58600. path.map(function(childPath) {
  58601. var child = childPath.getValue();
  58602. if (namedTypes.Literal.check(child) &&
  58603. typeof child.value === "string") {
  58604. if (/\S/.test(child.value)) {
  58605. return child.value.replace(/^\s+|\s+$/g, "");
  58606. } else if (/\n/.test(child.value)) {
  58607. return "\n";
  58608. }
  58609. }
  58610. return print(childPath);
  58611. }, "children")
  58612. ).indentTail(options.tabWidth);
  58613. var closingLines = path.call(print, "closingElement");
  58614. return concat([
  58615. openingLines,
  58616. childLines,
  58617. closingLines
  58618. ]);
  58619. case "XJSOpeningElement":
  58620. case "JSXOpeningElement":
  58621. var parts = ["<", path.call(print, "name")];
  58622. var attrParts = [];
  58623. path.each(function(attrPath) {
  58624. attrParts.push(" ", print(attrPath));
  58625. }, "attributes");
  58626. var attrLines = concat(attrParts);
  58627. var needLineWrap = (
  58628. attrLines.length > 1 ||
  58629. attrLines.getLineLength(1) > options.wrapColumn
  58630. );
  58631. if (needLineWrap) {
  58632. attrParts.forEach(function(part, i) {
  58633. if (part === " ") {
  58634. assert.strictEqual(i % 2, 0);
  58635. attrParts[i] = "\n";
  58636. }
  58637. });
  58638. attrLines = concat(attrParts).indentTail(options.tabWidth);
  58639. }
  58640. parts.push(attrLines, n.selfClosing ? " />" : ">");
  58641. return concat(parts);
  58642. case "XJSClosingElement":
  58643. case "JSXClosingElement":
  58644. return concat(["</", path.call(print, "name"), ">"]);
  58645. case "XJSText":
  58646. case "JSXText":
  58647. return fromString(n.value, options);
  58648. case "XJSEmptyExpression":
  58649. case "JSXEmptyExpression":
  58650. return fromString("");
  58651. case "TypeAnnotatedIdentifier":
  58652. return concat([
  58653. path.call(print, "annotation"),
  58654. " ",
  58655. path.call(print, "identifier")
  58656. ]);
  58657. case "ClassBody":
  58658. if (n.body.length === 0) {
  58659. return fromString("{}");
  58660. }
  58661. return concat([
  58662. "{\n",
  58663. path.call(function(bodyPath) {
  58664. return printStatementSequence(bodyPath, options, print);
  58665. }, "body").indent(options.tabWidth),
  58666. "\n}"
  58667. ]);
  58668. case "ClassPropertyDefinition":
  58669. var parts = ["static ", path.call(print, "definition")];
  58670. if (!namedTypes.MethodDefinition.check(n.definition))
  58671. parts.push(";");
  58672. return concat(parts);
  58673. case "ClassProperty":
  58674. return concat([
  58675. path.call(print, "key"),
  58676. path.call(print, "typeAnnotation"),
  58677. ";"
  58678. ]);
  58679. case "ClassDeclaration":
  58680. case "ClassExpression":
  58681. var parts = ["class"];
  58682. if (n.id) {
  58683. parts.push(
  58684. " ",
  58685. path.call(print, "id"),
  58686. path.call(print, "typeParameters")
  58687. );
  58688. }
  58689. if (n.superClass) {
  58690. parts.push(
  58691. " extends ",
  58692. path.call(print, "superClass"),
  58693. path.call(print, "superTypeParameters")
  58694. );
  58695. }
  58696. if (n["implements"]) {
  58697. parts.push(
  58698. " implements ",
  58699. fromString(", ").join(path.map(print, "implements"))
  58700. );
  58701. }
  58702. parts.push(" ", path.call(print, "body"));
  58703. return concat(parts);
  58704. // These types are unprintable because they serve as abstract
  58705. // supertypes for other (printable) types.
  58706. case "Node":
  58707. case "Printable":
  58708. case "SourceLocation":
  58709. case "Position":
  58710. case "Statement":
  58711. case "Function":
  58712. case "Pattern":
  58713. case "Expression":
  58714. case "Declaration":
  58715. case "Specifier":
  58716. case "NamedSpecifier":
  58717. case "Comment": // Supertype of Block and Line.
  58718. case "MemberTypeAnnotation": // Flow
  58719. case "TupleTypeAnnotation": // Flow
  58720. case "Type": // Flow
  58721. throw new Error("unprintable type: " + JSON.stringify(n.type));
  58722. case "Block": // Block comment.
  58723. return concat(["/*", fromString(n.value, options), "*/"]);
  58724. case "Line": // Line comment.
  58725. return concat(["//", fromString(n.value, options)]);
  58726. // Type Annotations for Facebook Flow, typically stripped out or
  58727. // transformed away before printing.
  58728. case "TypeAnnotation":
  58729. var parts = [];
  58730. if (n.typeAnnotation) {
  58731. if (n.typeAnnotation.type !== "FunctionTypeAnnotation") {
  58732. parts.push(": ");
  58733. }
  58734. parts.push(path.call(print, "typeAnnotation"));
  58735. return concat(parts);
  58736. }
  58737. return fromString("");
  58738. case "AnyTypeAnnotation":
  58739. return fromString("any", options);
  58740. case "ArrayTypeAnnotation":
  58741. return concat([
  58742. path.call(print, "elementType"),
  58743. "[]"
  58744. ]);
  58745. case "BooleanTypeAnnotation":
  58746. return fromString("boolean", options);
  58747. case "DeclareClass":
  58748. return concat([
  58749. fromString("declare class ", options),
  58750. path.call(print, "id"),
  58751. " ",
  58752. path.call(print, "body"),
  58753. ]);
  58754. case "DeclareFunction":
  58755. return concat([
  58756. fromString("declare function ", options),
  58757. path.call(print, "id")
  58758. ]);
  58759. case "DeclareModule":
  58760. return concat([
  58761. fromString("declare module ", options),
  58762. path.call(print, "id"),
  58763. " ",
  58764. path.call(print, "body"),
  58765. ]);
  58766. case "DeclareVariable":
  58767. return concat([
  58768. fromString("declare var ", options),
  58769. path.call(print, "id")
  58770. ]);
  58771. case "FunctionTypeAnnotation":
  58772. // FunctionTypeAnnotation is ambiguous:
  58773. // declare function(a: B): void; OR
  58774. // var A: (a: B) => void;
  58775. var parts = [];
  58776. var parent = path.getParentNode(0);
  58777. var isArrowFunctionTypeAnnotation = !(
  58778. namedTypes.ObjectTypeCallProperty.check(parent) ||
  58779. namedTypes.DeclareFunction.check(path.getParentNode(2))
  58780. );
  58781. var needsColon =
  58782. isArrowFunctionTypeAnnotation &&
  58783. !namedTypes.FunctionTypeParam.check(parent);
  58784. if (needsColon) {
  58785. parts.push(": ");
  58786. }
  58787. parts.push(
  58788. "(",
  58789. fromString(", ").join(path.map(print, "params")),
  58790. ")"
  58791. );
  58792. // The returnType is not wrapped in a TypeAnnotation, so the colon
  58793. // needs to be added separately.
  58794. if (n.returnType) {
  58795. parts.push(
  58796. isArrowFunctionTypeAnnotation ? " => " : ": ",
  58797. path.call(print, "returnType")
  58798. );
  58799. }
  58800. return concat(parts);
  58801. case "FunctionTypeParam":
  58802. return concat([
  58803. path.call(print, "name"),
  58804. ": ",
  58805. path.call(print, "typeAnnotation"),
  58806. ]);
  58807. case "GenericTypeAnnotation":
  58808. return concat([
  58809. path.call(print, "id"),
  58810. path.call(print, "typeParameters")
  58811. ]);
  58812. case "InterfaceDeclaration":
  58813. var parts = [
  58814. fromString("interface ", options),
  58815. path.call(print, "id"),
  58816. path.call(print, "typeParameters"),
  58817. " "
  58818. ];
  58819. if (n["extends"]) {
  58820. parts.push(
  58821. "extends ",
  58822. fromString(", ").join(path.map(print, "extends"))
  58823. );
  58824. }
  58825. parts.push(path.call(print, "body"));
  58826. return concat(parts);
  58827. case "ClassImplements":
  58828. case "InterfaceExtends":
  58829. return concat([
  58830. path.call(print, "id"),
  58831. path.call(print, "typeParameters")
  58832. ]);
  58833. case "IntersectionTypeAnnotation":
  58834. return fromString(" & ").join(path.map(print, "types"));
  58835. case "NullableTypeAnnotation":
  58836. return concat([
  58837. "?",
  58838. path.call(print, "typeAnnotation")
  58839. ]);
  58840. case "NumberTypeAnnotation":
  58841. return fromString("number", options);
  58842. case "ObjectTypeCallProperty":
  58843. return path.call(print, "value");
  58844. case "ObjectTypeIndexer":
  58845. return concat([
  58846. "[",
  58847. path.call(print, "id"),
  58848. ": ",
  58849. path.call(print, "key"),
  58850. "]: ",
  58851. path.call(print, "value")
  58852. ]);
  58853. case "ObjectTypeProperty":
  58854. return concat([
  58855. path.call(print, "key"),
  58856. ": ",
  58857. path.call(print, "value")
  58858. ]);
  58859. case "QualifiedTypeIdentifier":
  58860. return concat([
  58861. path.call(print, "qualification"),
  58862. ".",
  58863. path.call(print, "id")
  58864. ]);
  58865. case "StringLiteralTypeAnnotation":
  58866. return fromString(nodeStr(n.value, options), options);
  58867. case "StringTypeAnnotation":
  58868. return fromString("string", options);
  58869. case "TypeAlias":
  58870. return concat([
  58871. "type ",
  58872. path.call(print, "id"),
  58873. " = ",
  58874. path.call(print, "right")
  58875. ]);
  58876. case "TypeCastExpression":
  58877. return concat([
  58878. "(",
  58879. path.call(print, "expression"),
  58880. path.call(print, "typeAnnotation"),
  58881. ")"
  58882. ]);
  58883. case "TypeParameterDeclaration":
  58884. case "TypeParameterInstantiation":
  58885. return concat([
  58886. "<",
  58887. fromString(", ").join(path.map(print, "params")),
  58888. ">"
  58889. ]);
  58890. case "TypeofTypeAnnotation":
  58891. return concat([
  58892. fromString("typeof ", options),
  58893. path.call(print, "argument")
  58894. ]);
  58895. case "UnionTypeAnnotation":
  58896. return fromString(" | ").join(path.map(print, "types"));
  58897. case "VoidTypeAnnotation":
  58898. return fromString("void", options);
  58899. // Unhandled types below. If encountered, nodes of these types should
  58900. // be either left alone or desugared into AST types that are fully
  58901. // supported by the pretty-printer.
  58902. case "ClassHeritage": // TODO
  58903. case "ComprehensionBlock": // TODO
  58904. case "ComprehensionExpression": // TODO
  58905. case "Glob": // TODO
  58906. case "TaggedTemplateExpression": // TODO
  58907. case "TemplateElement": // TODO
  58908. case "TemplateLiteral": // TODO
  58909. case "GeneratorExpression": // TODO
  58910. case "LetStatement": // TODO
  58911. case "LetExpression": // TODO
  58912. case "GraphExpression": // TODO
  58913. case "GraphIndexExpression": // TODO
  58914. // XML types that nobody cares about or needs to print.
  58915. case "XMLDefaultDeclaration":
  58916. case "XMLAnyName":
  58917. case "XMLQualifiedIdentifier":
  58918. case "XMLFunctionQualifiedIdentifier":
  58919. case "XMLAttributeSelector":
  58920. case "XMLFilterExpression":
  58921. case "XML":
  58922. case "XMLElement":
  58923. case "XMLList":
  58924. case "XMLEscape":
  58925. case "XMLText":
  58926. case "XMLStartTag":
  58927. case "XMLEndTag":
  58928. case "XMLPointTag":
  58929. case "XMLName":
  58930. case "XMLAttribute":
  58931. case "XMLCdata":
  58932. case "XMLComment":
  58933. case "XMLProcessingInstruction":
  58934. default:
  58935. debugger;
  58936. throw new Error("unknown type: " + JSON.stringify(n.type));
  58937. }
  58938. return p;
  58939. }
  58940. function printStatementSequence(path, options, print) {
  58941. var inClassBody =
  58942. namedTypes.ClassBody &&
  58943. namedTypes.ClassBody.check(path.getParentNode());
  58944. var filtered = [];
  58945. path.each(function(stmtPath) {
  58946. var i = stmtPath.getName();
  58947. var stmt = stmtPath.getValue();
  58948. // Just in case the AST has been modified to contain falsy
  58949. // "statements," it's safer simply to skip them.
  58950. if (!stmt) {
  58951. return;
  58952. }
  58953. // Skip printing EmptyStatement nodes to avoid leaving stray
  58954. // semicolons lying around.
  58955. if (stmt.type === "EmptyStatement") {
  58956. return;
  58957. }
  58958. if (!inClassBody) {
  58959. namedTypes.Statement.assert(stmt);
  58960. }
  58961. // We can't hang onto stmtPath outside of this function, because
  58962. // it's just a reference to a mutable FastPath object, so we have
  58963. // to go ahead and print it here.
  58964. filtered.push({
  58965. node: stmt,
  58966. printed: print(stmtPath)
  58967. });
  58968. });
  58969. var prevTrailingSpace = null;
  58970. var len = filtered.length;
  58971. var parts = [];
  58972. filtered.forEach(function(info, i) {
  58973. var printed = info.printed;
  58974. var stmt = info.node;
  58975. var needSemicolon = true;
  58976. var multiLine = printed.length > 1;
  58977. var notFirst = i > 0;
  58978. var notLast = i < len - 1;
  58979. var leadingSpace;
  58980. var trailingSpace;
  58981. if (inClassBody) {
  58982. if (namedTypes.MethodDefinition.check(stmt) ||
  58983. (namedTypes.ClassPropertyDefinition.check(stmt) &&
  58984. namedTypes.MethodDefinition.check(stmt.definition))) {
  58985. needSemicolon = false;
  58986. }
  58987. }
  58988. if (needSemicolon) {
  58989. // Try to add a semicolon to anything that isn't a method in a
  58990. // class body.
  58991. printed = maybeAddSemicolon(printed);
  58992. }
  58993. var trueLoc = options.reuseWhitespace && util.getTrueLoc(stmt);
  58994. var lines = trueLoc && trueLoc.lines;
  58995. if (notFirst) {
  58996. if (lines) {
  58997. var beforeStart = lines.skipSpaces(trueLoc.start, true);
  58998. var beforeStartLine = beforeStart ? beforeStart.line : 1;
  58999. var leadingGap = trueLoc.start.line - beforeStartLine;
  59000. leadingSpace = Array(leadingGap + 1).join("\n");
  59001. } else {
  59002. leadingSpace = multiLine ? "\n\n" : "\n";
  59003. }
  59004. } else {
  59005. leadingSpace = "";
  59006. }
  59007. if (notLast) {
  59008. if (lines) {
  59009. var afterEnd = lines.skipSpaces(trueLoc.end);
  59010. var afterEndLine = afterEnd ? afterEnd.line : lines.length;
  59011. var trailingGap = afterEndLine - trueLoc.end.line;
  59012. trailingSpace = Array(trailingGap + 1).join("\n");
  59013. } else {
  59014. trailingSpace = multiLine ? "\n\n" : "\n";
  59015. }
  59016. } else {
  59017. trailingSpace = "";
  59018. }
  59019. parts.push(
  59020. maxSpace(prevTrailingSpace, leadingSpace),
  59021. printed
  59022. );
  59023. if (notLast) {
  59024. prevTrailingSpace = trailingSpace;
  59025. } else if (trailingSpace) {
  59026. parts.push(trailingSpace);
  59027. }
  59028. });
  59029. return concat(parts);
  59030. }
  59031. function maxSpace(s1, s2) {
  59032. if (!s1 && !s2) {
  59033. return fromString("");
  59034. }
  59035. if (!s1) {
  59036. return fromString(s2);
  59037. }
  59038. if (!s2) {
  59039. return fromString(s1);
  59040. }
  59041. var spaceLines1 = fromString(s1);
  59042. var spaceLines2 = fromString(s2);
  59043. if (spaceLines2.length > spaceLines1.length) {
  59044. return spaceLines2;
  59045. }
  59046. return spaceLines1;
  59047. }
  59048. function printMethod(path, options, print) {
  59049. var node = path.getNode();
  59050. var kind = node.kind;
  59051. var parts = [];
  59052. namedTypes.FunctionExpression.assert(node.value);
  59053. if (node.value.async) {
  59054. parts.push("async ");
  59055. }
  59056. if (!kind || kind === "init") {
  59057. if (node.value.generator) {
  59058. parts.push("*");
  59059. }
  59060. } else {
  59061. assert.ok(kind === "get" || kind === "set");
  59062. parts.push(kind, " ");
  59063. }
  59064. var key = path.call(print, "key");
  59065. if (node.computed) {
  59066. key = concat(["[", key, "]"]);
  59067. }
  59068. parts.push(
  59069. key,
  59070. path.call(print, "value", "typeParameters"),
  59071. "(",
  59072. path.call(function(valuePath) {
  59073. return printFunctionParams(valuePath, options, print);
  59074. }, "value"),
  59075. ")",
  59076. path.call(print, "value", "returnType"),
  59077. " ",
  59078. path.call(print, "value", "body")
  59079. );
  59080. return concat(parts);
  59081. }
  59082. function printArgumentsList(path, options, print) {
  59083. var printed = path.map(print, "arguments");
  59084. var joined = fromString(", ").join(printed);
  59085. if (joined.getLineLength(1) > options.wrapColumn) {
  59086. joined = fromString(",\n").join(printed);
  59087. return concat(["(\n", joined.indent(options.tabWidth), "\n)"]);
  59088. }
  59089. return concat(["(", joined, ")"]);
  59090. }
  59091. function printFunctionParams(path, options, print) {
  59092. var fun = path.getValue();
  59093. namedTypes.Function.assert(fun);
  59094. var printed = path.map(print, "params");
  59095. if (fun.defaults) {
  59096. path.each(function(defExprPath) {
  59097. var i = defExprPath.getName();
  59098. var p = printed[i];
  59099. if (p && defExprPath.getValue()) {
  59100. printed[i] = concat([p, "=", print(defExprPath)]);
  59101. }
  59102. }, "defaults");
  59103. }
  59104. if (fun.rest) {
  59105. printed.push(concat(["...", path.call(print, "rest")]));
  59106. }
  59107. var joined = fromString(", ").join(printed);
  59108. if (joined.length > 1 ||
  59109. joined.getLineLength(1) > options.wrapColumn) {
  59110. joined = fromString(",\n").join(printed);
  59111. return concat(["\n", joined.indent(options.tabWidth)]);
  59112. }
  59113. return joined;
  59114. }
  59115. function adjustClause(clause, options) {
  59116. if (clause.length > 1)
  59117. return concat([" ", clause]);
  59118. return concat([
  59119. "\n",
  59120. maybeAddSemicolon(clause).indent(options.tabWidth)
  59121. ]);
  59122. }
  59123. function lastNonSpaceCharacter(lines) {
  59124. var pos = lines.lastPos();
  59125. do {
  59126. var ch = lines.charAt(pos);
  59127. if (/\S/.test(ch))
  59128. return ch;
  59129. } while (lines.prevPos(pos));
  59130. }
  59131. function endsWithBrace(lines) {
  59132. return lastNonSpaceCharacter(lines) === "}";
  59133. }
  59134. function swapQuotes(str) {
  59135. return str.replace(/['"]/g, function(m) {
  59136. return m === '"' ? '\'' : '"';
  59137. });
  59138. }
  59139. function nodeStr(str, options) {
  59140. isString.assert(str);
  59141. switch (options.quote) {
  59142. case "auto":
  59143. var double = JSON.stringify(str);
  59144. var single = swapQuotes(JSON.stringify(swapQuotes(str)));
  59145. return double.length > single.length ? single : double;
  59146. case "single":
  59147. return swapQuotes(JSON.stringify(swapQuotes(str)));
  59148. case "double":
  59149. default:
  59150. return JSON.stringify(str);
  59151. }
  59152. }
  59153. function maybeAddSemicolon(lines) {
  59154. var eoc = lastNonSpaceCharacter(lines);
  59155. if (!eoc || "\n};".indexOf(eoc) < 0)
  59156. return concat([lines, ";"]);
  59157. return lines;
  59158. }
  59159. },{"./comments":459,"./fast-path":460,"./lines":461,"./options":463,"./patcher":465,"./types":467,"./util":468,"assert":190,"source-map":483}],467:[function(require,module,exports){
  59160. var types = require("ast-types");
  59161. var def = types.Type.def;
  59162. def("File")
  59163. .bases("Node")
  59164. .build("program")
  59165. .field("program", def("Program"));
  59166. types.finalize();
  59167. module.exports = types;
  59168. },{"ast-types":188}],468:[function(require,module,exports){
  59169. var assert = require("assert");
  59170. var types = require("./types");
  59171. var getFieldValue = types.getFieldValue;
  59172. var n = types.namedTypes;
  59173. var sourceMap = require("source-map");
  59174. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  59175. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  59176. var hasOwn = Object.prototype.hasOwnProperty;
  59177. function getUnionOfKeys() {
  59178. var result = {};
  59179. var argc = arguments.length;
  59180. for (var i = 0; i < argc; ++i) {
  59181. var keys = Object.keys(arguments[i]);
  59182. var keyCount = keys.length;
  59183. for (var j = 0; j < keyCount; ++j) {
  59184. result[keys[j]] = true;
  59185. }
  59186. }
  59187. return result;
  59188. }
  59189. exports.getUnionOfKeys = getUnionOfKeys;
  59190. function comparePos(pos1, pos2) {
  59191. return (pos1.line - pos2.line) || (pos1.column - pos2.column);
  59192. }
  59193. exports.comparePos = comparePos;
  59194. function copyPos(pos) {
  59195. return {
  59196. line: pos.line,
  59197. column: pos.column
  59198. };
  59199. }
  59200. exports.copyPos = copyPos;
  59201. exports.composeSourceMaps = function(formerMap, latterMap) {
  59202. if (formerMap) {
  59203. if (!latterMap) {
  59204. return formerMap;
  59205. }
  59206. } else {
  59207. return latterMap || null;
  59208. }
  59209. var smcFormer = new SourceMapConsumer(formerMap);
  59210. var smcLatter = new SourceMapConsumer(latterMap);
  59211. var smg = new SourceMapGenerator({
  59212. file: latterMap.file,
  59213. sourceRoot: latterMap.sourceRoot
  59214. });
  59215. var sourcesToContents = {};
  59216. smcLatter.eachMapping(function(mapping) {
  59217. var origPos = smcFormer.originalPositionFor({
  59218. line: mapping.originalLine,
  59219. column: mapping.originalColumn
  59220. });
  59221. var sourceName = origPos.source;
  59222. if (sourceName === null) {
  59223. return;
  59224. }
  59225. smg.addMapping({
  59226. source: sourceName,
  59227. original: copyPos(origPos),
  59228. generated: {
  59229. line: mapping.generatedLine,
  59230. column: mapping.generatedColumn
  59231. },
  59232. name: mapping.name
  59233. });
  59234. var sourceContent = smcFormer.sourceContentFor(sourceName);
  59235. if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) {
  59236. sourcesToContents[sourceName] = sourceContent;
  59237. smg.setSourceContent(sourceName, sourceContent);
  59238. }
  59239. });
  59240. return smg.toJSON();
  59241. };
  59242. exports.getTrueLoc = function(node) {
  59243. // It's possible that node is newly-created (not parsed by Esprima),
  59244. // in which case it probably won't have a .loc property (or an
  59245. // .original property for that matter). That's fine; we'll just
  59246. // pretty-print it as usual.
  59247. if (!node.loc) {
  59248. return null;
  59249. }
  59250. if (!node.comments) {
  59251. // If the node has no comments, regard node.loc as true.
  59252. return node.loc;
  59253. }
  59254. var start = node.loc.start;
  59255. var end = node.loc.end;
  59256. // If the node has any comments, their locations might contribute to
  59257. // the true start/end positions of the node.
  59258. node.comments.forEach(function(comment) {
  59259. if (comment.loc) {
  59260. if (comparePos(comment.loc.start, start) < 0) {
  59261. start = comment.loc.start;
  59262. }
  59263. if (comparePos(end, comment.loc.end) < 0) {
  59264. end = comment.loc.end;
  59265. }
  59266. }
  59267. });
  59268. return {
  59269. lines: node.loc.lines,
  59270. start: start,
  59271. end: end
  59272. };
  59273. };
  59274. exports.fixFaultyLocations = function(node) {
  59275. if ((n.MethodDefinition && n.MethodDefinition.check(node)) ||
  59276. (n.Property.check(node) && (node.method || node.shorthand))) {
  59277. // If the node is a MethodDefinition or a .method or .shorthand
  59278. // Property, then the location information stored in
  59279. // node.value.loc is very likely untrustworthy (just the {body}
  59280. // part of a method, or nothing in the case of shorthand
  59281. // properties), so we null out that information to prevent
  59282. // accidental reuse of bogus source code during reprinting.
  59283. node.value.loc = null;
  59284. if (n.FunctionExpression.check(node.value)) {
  59285. // FunctionExpression method values should be anonymous,
  59286. // because their .id fields are ignored anyway.
  59287. node.value.id = null;
  59288. }
  59289. }
  59290. var loc = node.loc;
  59291. if (loc) {
  59292. if (loc.start.line < 1) {
  59293. loc.start.line = 1;
  59294. }
  59295. if (loc.end.line < 1) {
  59296. loc.end.line = 1;
  59297. }
  59298. }
  59299. };
  59300. },{"./types":467,"assert":190,"source-map":483}],469:[function(require,module,exports){
  59301. (function (process){
  59302. var types = require("./lib/types");
  59303. var parse = require("./lib/parser").parse;
  59304. var Printer = require("./lib/printer").Printer;
  59305. function print(node, options) {
  59306. return new Printer(options).print(node);
  59307. }
  59308. function prettyPrint(node, options) {
  59309. return new Printer(options).printGenerically(node);
  59310. }
  59311. function run(transformer, options) {
  59312. return runFile(process.argv[2], transformer, options);
  59313. }
  59314. function runFile(path, transformer, options) {
  59315. require("fs").readFile(path, "utf-8", function(err, code) {
  59316. if (err) {
  59317. console.error(err);
  59318. return;
  59319. }
  59320. runString(code, transformer, options);
  59321. });
  59322. }
  59323. function defaultWriteback(output) {
  59324. process.stdout.write(output);
  59325. }
  59326. function runString(code, transformer, options) {
  59327. var writeback = options && options.writeback || defaultWriteback;
  59328. transformer(parse(code, options), function(node) {
  59329. writeback(print(node, options).code);
  59330. });
  59331. }
  59332. Object.defineProperties(exports, {
  59333. /**
  59334. * Parse a string of code into an augmented syntax tree suitable for
  59335. * arbitrary modification and reprinting.
  59336. */
  59337. parse: {
  59338. enumerable: true,
  59339. value: parse
  59340. },
  59341. /**
  59342. * Traverse and potentially modify an abstract syntax tree using a
  59343. * convenient visitor syntax:
  59344. *
  59345. * recast.visit(ast, {
  59346. * names: [],
  59347. * visitIdentifier: function(path) {
  59348. * var node = path.value;
  59349. * this.visitor.names.push(node.name);
  59350. * this.traverse(path);
  59351. * }
  59352. * });
  59353. */
  59354. visit: {
  59355. enumerable: true,
  59356. value: types.visit
  59357. },
  59358. /**
  59359. * Reprint a modified syntax tree using as much of the original source
  59360. * code as possible.
  59361. */
  59362. print: {
  59363. enumerable: true,
  59364. value: print
  59365. },
  59366. /**
  59367. * Print without attempting to reuse any original source code.
  59368. */
  59369. prettyPrint: {
  59370. enumerable: false,
  59371. value: prettyPrint
  59372. },
  59373. /**
  59374. * Customized version of require("ast-types").
  59375. */
  59376. types: {
  59377. enumerable: false,
  59378. value: types
  59379. },
  59380. /**
  59381. * Convenient command-line interface (see e.g. example/add-braces).
  59382. */
  59383. run: {
  59384. enumerable: false,
  59385. value: run
  59386. }
  59387. });
  59388. }).call(this,require('_process'))
  59389. },{"./lib/parser":464,"./lib/printer":466,"./lib/types":467,"_process":200,"fs":189}],470:[function(require,module,exports){
  59390. /*
  59391. Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
  59392. Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
  59393. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  59394. Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
  59395. Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
  59396. Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
  59397. Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
  59398. Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
  59399. Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
  59400. Redistribution and use in source and binary forms, with or without
  59401. modification, are permitted provided that the following conditions are met:
  59402. * Redistributions of source code must retain the above copyright
  59403. notice, this list of conditions and the following disclaimer.
  59404. * Redistributions in binary form must reproduce the above copyright
  59405. notice, this list of conditions and the following disclaimer in the
  59406. documentation and/or other materials provided with the distribution.
  59407. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  59408. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  59409. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  59410. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  59411. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  59412. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  59413. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  59414. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59415. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  59416. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59417. */
  59418. (function (root, factory) {
  59419. 'use strict';
  59420. // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
  59421. // Rhino, and plain browser loading.
  59422. /* istanbul ignore next */
  59423. if (typeof define === 'function' && define.amd) {
  59424. define(['exports'], factory);
  59425. } else if (typeof exports !== 'undefined') {
  59426. factory(exports);
  59427. } else {
  59428. factory((root.esprima = {}));
  59429. }
  59430. }(this, function (exports) {
  59431. 'use strict';
  59432. var Token,
  59433. TokenName,
  59434. FnExprTokens,
  59435. Syntax,
  59436. PropertyKind,
  59437. Messages,
  59438. Regex,
  59439. SyntaxTreeDelegate,
  59440. XHTMLEntities,
  59441. ClassPropertyType,
  59442. source,
  59443. strict,
  59444. index,
  59445. lineNumber,
  59446. lineStart,
  59447. length,
  59448. delegate,
  59449. lookahead,
  59450. state,
  59451. extra;
  59452. Token = {
  59453. BooleanLiteral: 1,
  59454. EOF: 2,
  59455. Identifier: 3,
  59456. Keyword: 4,
  59457. NullLiteral: 5,
  59458. NumericLiteral: 6,
  59459. Punctuator: 7,
  59460. StringLiteral: 8,
  59461. RegularExpression: 9,
  59462. Template: 10,
  59463. JSXIdentifier: 11,
  59464. JSXText: 12
  59465. };
  59466. TokenName = {};
  59467. TokenName[Token.BooleanLiteral] = 'Boolean';
  59468. TokenName[Token.EOF] = '<end>';
  59469. TokenName[Token.Identifier] = 'Identifier';
  59470. TokenName[Token.Keyword] = 'Keyword';
  59471. TokenName[Token.NullLiteral] = 'Null';
  59472. TokenName[Token.NumericLiteral] = 'Numeric';
  59473. TokenName[Token.Punctuator] = 'Punctuator';
  59474. TokenName[Token.StringLiteral] = 'String';
  59475. TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
  59476. TokenName[Token.JSXText] = 'JSXText';
  59477. TokenName[Token.RegularExpression] = 'RegularExpression';
  59478. TokenName[Token.Template] = 'Template';
  59479. // A function following one of those tokens is an expression.
  59480. FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
  59481. 'return', 'case', 'delete', 'throw', 'void',
  59482. // assignment operators
  59483. '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
  59484. '&=', '|=', '^=', ',',
  59485. // binary/unary operators
  59486. '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
  59487. '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
  59488. '<=', '<', '>', '!=', '!=='];
  59489. Syntax = {
  59490. AnyTypeAnnotation: 'AnyTypeAnnotation',
  59491. ArrayExpression: 'ArrayExpression',
  59492. ArrayPattern: 'ArrayPattern',
  59493. ArrayTypeAnnotation: 'ArrayTypeAnnotation',
  59494. ArrowFunctionExpression: 'ArrowFunctionExpression',
  59495. AssignmentExpression: 'AssignmentExpression',
  59496. BinaryExpression: 'BinaryExpression',
  59497. BlockStatement: 'BlockStatement',
  59498. BooleanTypeAnnotation: 'BooleanTypeAnnotation',
  59499. BreakStatement: 'BreakStatement',
  59500. CallExpression: 'CallExpression',
  59501. CatchClause: 'CatchClause',
  59502. ClassBody: 'ClassBody',
  59503. ClassDeclaration: 'ClassDeclaration',
  59504. ClassExpression: 'ClassExpression',
  59505. ClassImplements: 'ClassImplements',
  59506. ClassProperty: 'ClassProperty',
  59507. ComprehensionBlock: 'ComprehensionBlock',
  59508. ComprehensionExpression: 'ComprehensionExpression',
  59509. ConditionalExpression: 'ConditionalExpression',
  59510. ContinueStatement: 'ContinueStatement',
  59511. DebuggerStatement: 'DebuggerStatement',
  59512. DeclareClass: 'DeclareClass',
  59513. DeclareFunction: 'DeclareFunction',
  59514. DeclareModule: 'DeclareModule',
  59515. DeclareVariable: 'DeclareVariable',
  59516. DoWhileStatement: 'DoWhileStatement',
  59517. EmptyStatement: 'EmptyStatement',
  59518. ExportDeclaration: 'ExportDeclaration',
  59519. ExportBatchSpecifier: 'ExportBatchSpecifier',
  59520. ExportSpecifier: 'ExportSpecifier',
  59521. ExpressionStatement: 'ExpressionStatement',
  59522. ForInStatement: 'ForInStatement',
  59523. ForOfStatement: 'ForOfStatement',
  59524. ForStatement: 'ForStatement',
  59525. FunctionDeclaration: 'FunctionDeclaration',
  59526. FunctionExpression: 'FunctionExpression',
  59527. FunctionTypeAnnotation: 'FunctionTypeAnnotation',
  59528. FunctionTypeParam: 'FunctionTypeParam',
  59529. GenericTypeAnnotation: 'GenericTypeAnnotation',
  59530. Identifier: 'Identifier',
  59531. IfStatement: 'IfStatement',
  59532. ImportDeclaration: 'ImportDeclaration',
  59533. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  59534. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  59535. ImportSpecifier: 'ImportSpecifier',
  59536. InterfaceDeclaration: 'InterfaceDeclaration',
  59537. InterfaceExtends: 'InterfaceExtends',
  59538. IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
  59539. LabeledStatement: 'LabeledStatement',
  59540. Literal: 'Literal',
  59541. LogicalExpression: 'LogicalExpression',
  59542. MemberExpression: 'MemberExpression',
  59543. MethodDefinition: 'MethodDefinition',
  59544. NewExpression: 'NewExpression',
  59545. NullableTypeAnnotation: 'NullableTypeAnnotation',
  59546. NumberTypeAnnotation: 'NumberTypeAnnotation',
  59547. ObjectExpression: 'ObjectExpression',
  59548. ObjectPattern: 'ObjectPattern',
  59549. ObjectTypeAnnotation: 'ObjectTypeAnnotation',
  59550. ObjectTypeCallProperty: 'ObjectTypeCallProperty',
  59551. ObjectTypeIndexer: 'ObjectTypeIndexer',
  59552. ObjectTypeProperty: 'ObjectTypeProperty',
  59553. Program: 'Program',
  59554. Property: 'Property',
  59555. QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
  59556. ReturnStatement: 'ReturnStatement',
  59557. SequenceExpression: 'SequenceExpression',
  59558. SpreadElement: 'SpreadElement',
  59559. SpreadProperty: 'SpreadProperty',
  59560. StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
  59561. StringTypeAnnotation: 'StringTypeAnnotation',
  59562. SwitchCase: 'SwitchCase',
  59563. SwitchStatement: 'SwitchStatement',
  59564. TaggedTemplateExpression: 'TaggedTemplateExpression',
  59565. TemplateElement: 'TemplateElement',
  59566. TemplateLiteral: 'TemplateLiteral',
  59567. ThisExpression: 'ThisExpression',
  59568. ThrowStatement: 'ThrowStatement',
  59569. TupleTypeAnnotation: 'TupleTypeAnnotation',
  59570. TryStatement: 'TryStatement',
  59571. TypeAlias: 'TypeAlias',
  59572. TypeAnnotation: 'TypeAnnotation',
  59573. TypeCastExpression: 'TypeCastExpression',
  59574. TypeofTypeAnnotation: 'TypeofTypeAnnotation',
  59575. TypeParameterDeclaration: 'TypeParameterDeclaration',
  59576. TypeParameterInstantiation: 'TypeParameterInstantiation',
  59577. UnaryExpression: 'UnaryExpression',
  59578. UnionTypeAnnotation: 'UnionTypeAnnotation',
  59579. UpdateExpression: 'UpdateExpression',
  59580. VariableDeclaration: 'VariableDeclaration',
  59581. VariableDeclarator: 'VariableDeclarator',
  59582. VoidTypeAnnotation: 'VoidTypeAnnotation',
  59583. WhileStatement: 'WhileStatement',
  59584. WithStatement: 'WithStatement',
  59585. JSXIdentifier: 'JSXIdentifier',
  59586. JSXNamespacedName: 'JSXNamespacedName',
  59587. JSXMemberExpression: 'JSXMemberExpression',
  59588. JSXEmptyExpression: 'JSXEmptyExpression',
  59589. JSXExpressionContainer: 'JSXExpressionContainer',
  59590. JSXElement: 'JSXElement',
  59591. JSXClosingElement: 'JSXClosingElement',
  59592. JSXOpeningElement: 'JSXOpeningElement',
  59593. JSXAttribute: 'JSXAttribute',
  59594. JSXSpreadAttribute: 'JSXSpreadAttribute',
  59595. JSXText: 'JSXText',
  59596. YieldExpression: 'YieldExpression',
  59597. AwaitExpression: 'AwaitExpression'
  59598. };
  59599. PropertyKind = {
  59600. Data: 1,
  59601. Get: 2,
  59602. Set: 4
  59603. };
  59604. ClassPropertyType = {
  59605. 'static': 'static',
  59606. prototype: 'prototype'
  59607. };
  59608. // Error messages should be identical to V8.
  59609. Messages = {
  59610. UnexpectedToken: 'Unexpected token %0',
  59611. UnexpectedNumber: 'Unexpected number',
  59612. UnexpectedString: 'Unexpected string',
  59613. UnexpectedIdentifier: 'Unexpected identifier',
  59614. UnexpectedReserved: 'Unexpected reserved word',
  59615. UnexpectedTemplate: 'Unexpected quasi %0',
  59616. UnexpectedEOS: 'Unexpected end of input',
  59617. NewlineAfterThrow: 'Illegal newline after throw',
  59618. InvalidRegExp: 'Invalid regular expression',
  59619. UnterminatedRegExp: 'Invalid regular expression: missing /',
  59620. InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
  59621. InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
  59622. InvalidLHSInForIn: 'Invalid left-hand side in for-in',
  59623. MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
  59624. NoCatchOrFinally: 'Missing catch or finally after try',
  59625. UnknownLabel: 'Undefined label \'%0\'',
  59626. Redeclaration: '%0 \'%1\' has already been declared',
  59627. IllegalContinue: 'Illegal continue statement',
  59628. IllegalBreak: 'Illegal break statement',
  59629. IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
  59630. IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
  59631. IllegalReturn: 'Illegal return statement',
  59632. IllegalSpread: 'Illegal spread element',
  59633. StrictModeWith: 'Strict mode code may not include a with statement',
  59634. StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
  59635. StrictVarName: 'Variable name may not be eval or arguments in strict mode',
  59636. StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
  59637. StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
  59638. ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
  59639. DefaultRestParameter: 'Rest parameter can not have a default value',
  59640. ElementAfterSpreadElement: 'Spread must be the final element of an element list',
  59641. PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
  59642. ObjectPatternAsRestParameter: 'Invalid rest parameter',
  59643. ObjectPatternAsSpread: 'Invalid spread argument',
  59644. StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
  59645. StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
  59646. StrictDelete: 'Delete of an unqualified identifier in strict mode.',
  59647. StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
  59648. AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
  59649. AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
  59650. StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
  59651. StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
  59652. StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
  59653. StrictReservedWord: 'Use of future reserved word in strict mode',
  59654. MissingFromClause: 'Missing from clause',
  59655. NoAsAfterImportNamespace: 'Missing as after import *',
  59656. InvalidModuleSpecifier: 'Invalid module specifier',
  59657. IllegalImportDeclaration: 'Illegal import declaration',
  59658. IllegalExportDeclaration: 'Illegal export declaration',
  59659. NoUninitializedConst: 'Const must be initialized',
  59660. ComprehensionRequiresBlock: 'Comprehension must have at least one block',
  59661. ComprehensionError: 'Comprehension Error',
  59662. EachNotAllowed: 'Each is not supported',
  59663. InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
  59664. ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
  59665. AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
  59666. ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
  59667. 'you are trying to write a function type, but you ended up ' +
  59668. 'writing a grouped type followed by an =>, which is a syntax ' +
  59669. 'error. Remember, function type parameters are named so function ' +
  59670. 'types look like (name1: type1, name2: type2) => returnType. You ' +
  59671. 'probably wrote (type1) => returnType'
  59672. };
  59673. // See also tools/generate-unicode-regex.py.
  59674. Regex = {
  59675. NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\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\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\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\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-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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]'),
  59676. NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\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\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\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\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\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\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\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\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-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\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-\u191c\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\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\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-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\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-\ufe26\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]'),
  59677. LeadingZeros: new RegExp('^0+(?!$)')
  59678. };
  59679. // Ensure the condition is true, otherwise throw an error.
  59680. // This is only to have a better contract semantic, i.e. another safety net
  59681. // to catch a logic error. The condition shall be fulfilled in normal case.
  59682. // Do NOT use this to enforce a certain condition on any user input.
  59683. function assert(condition, message) {
  59684. /* istanbul ignore if */
  59685. if (!condition) {
  59686. throw new Error('ASSERT: ' + message);
  59687. }
  59688. }
  59689. function StringMap() {
  59690. this.$data = {};
  59691. }
  59692. StringMap.prototype.get = function (key) {
  59693. key = '$' + key;
  59694. return this.$data[key];
  59695. };
  59696. StringMap.prototype.set = function (key, value) {
  59697. key = '$' + key;
  59698. this.$data[key] = value;
  59699. return this;
  59700. };
  59701. StringMap.prototype.has = function (key) {
  59702. key = '$' + key;
  59703. return Object.prototype.hasOwnProperty.call(this.$data, key);
  59704. };
  59705. StringMap.prototype.delete = function (key) {
  59706. key = '$' + key;
  59707. return delete this.$data[key];
  59708. };
  59709. function isDecimalDigit(ch) {
  59710. return (ch >= 48 && ch <= 57); // 0..9
  59711. }
  59712. function isHexDigit(ch) {
  59713. return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
  59714. }
  59715. function isOctalDigit(ch) {
  59716. return '01234567'.indexOf(ch) >= 0;
  59717. }
  59718. // 7.2 White Space
  59719. function isWhiteSpace(ch) {
  59720. return (ch === 32) || // space
  59721. (ch === 9) || // tab
  59722. (ch === 0xB) ||
  59723. (ch === 0xC) ||
  59724. (ch === 0xA0) ||
  59725. (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
  59726. }
  59727. // 7.3 Line Terminators
  59728. function isLineTerminator(ch) {
  59729. return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
  59730. }
  59731. // 7.6 Identifier Names and Identifiers
  59732. function isIdentifierStart(ch) {
  59733. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  59734. (ch >= 65 && ch <= 90) || // A..Z
  59735. (ch >= 97 && ch <= 122) || // a..z
  59736. (ch === 92) || // \ (backslash)
  59737. ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
  59738. }
  59739. function isIdentifierPart(ch) {
  59740. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  59741. (ch >= 65 && ch <= 90) || // A..Z
  59742. (ch >= 97 && ch <= 122) || // a..z
  59743. (ch >= 48 && ch <= 57) || // 0..9
  59744. (ch === 92) || // \ (backslash)
  59745. ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
  59746. }
  59747. // 7.6.1.2 Future Reserved Words
  59748. function isFutureReservedWord(id) {
  59749. switch (id) {
  59750. case 'class':
  59751. case 'enum':
  59752. case 'export':
  59753. case 'extends':
  59754. case 'import':
  59755. case 'super':
  59756. return true;
  59757. default:
  59758. return false;
  59759. }
  59760. }
  59761. function isStrictModeReservedWord(id) {
  59762. switch (id) {
  59763. case 'implements':
  59764. case 'interface':
  59765. case 'package':
  59766. case 'private':
  59767. case 'protected':
  59768. case 'public':
  59769. case 'static':
  59770. case 'yield':
  59771. case 'let':
  59772. return true;
  59773. default:
  59774. return false;
  59775. }
  59776. }
  59777. function isRestrictedWord(id) {
  59778. return id === 'eval' || id === 'arguments';
  59779. }
  59780. // 7.6.1.1 Keywords
  59781. function isKeyword(id) {
  59782. if (strict && isStrictModeReservedWord(id)) {
  59783. return true;
  59784. }
  59785. // 'const' is specialized as Keyword in V8.
  59786. // 'yield' is only treated as a keyword in strict mode.
  59787. // 'let' is for compatiblity with SpiderMonkey and ES.next.
  59788. // Some others are from future reserved words.
  59789. switch (id.length) {
  59790. case 2:
  59791. return (id === 'if') || (id === 'in') || (id === 'do');
  59792. case 3:
  59793. return (id === 'var') || (id === 'for') || (id === 'new') ||
  59794. (id === 'try') || (id === 'let');
  59795. case 4:
  59796. return (id === 'this') || (id === 'else') || (id === 'case') ||
  59797. (id === 'void') || (id === 'with') || (id === 'enum');
  59798. case 5:
  59799. return (id === 'while') || (id === 'break') || (id === 'catch') ||
  59800. (id === 'throw') || (id === 'const') ||
  59801. (id === 'class') || (id === 'super');
  59802. case 6:
  59803. return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
  59804. (id === 'switch') || (id === 'export') || (id === 'import');
  59805. case 7:
  59806. return (id === 'default') || (id === 'finally') || (id === 'extends');
  59807. case 8:
  59808. return (id === 'function') || (id === 'continue') || (id === 'debugger');
  59809. case 10:
  59810. return (id === 'instanceof');
  59811. default:
  59812. return false;
  59813. }
  59814. }
  59815. // 7.4 Comments
  59816. function addComment(type, value, start, end, loc) {
  59817. var comment;
  59818. assert(typeof start === 'number', 'Comment must have valid position');
  59819. // Because the way the actual token is scanned, often the comments
  59820. // (if any) are skipped twice during the lexical analysis.
  59821. // Thus, we need to skip adding a comment if the comment array already
  59822. // handled it.
  59823. if (state.lastCommentStart >= start) {
  59824. return;
  59825. }
  59826. state.lastCommentStart = start;
  59827. comment = {
  59828. type: type,
  59829. value: value
  59830. };
  59831. if (extra.range) {
  59832. comment.range = [start, end];
  59833. }
  59834. if (extra.loc) {
  59835. comment.loc = loc;
  59836. }
  59837. extra.comments.push(comment);
  59838. if (extra.attachComment) {
  59839. extra.leadingComments.push(comment);
  59840. extra.trailingComments.push(comment);
  59841. }
  59842. }
  59843. function skipSingleLineComment() {
  59844. var start, loc, ch, comment;
  59845. start = index - 2;
  59846. loc = {
  59847. start: {
  59848. line: lineNumber,
  59849. column: index - lineStart - 2
  59850. }
  59851. };
  59852. while (index < length) {
  59853. ch = source.charCodeAt(index);
  59854. ++index;
  59855. if (isLineTerminator(ch)) {
  59856. if (extra.comments) {
  59857. comment = source.slice(start + 2, index - 1);
  59858. loc.end = {
  59859. line: lineNumber,
  59860. column: index - lineStart - 1
  59861. };
  59862. addComment('Line', comment, start, index - 1, loc);
  59863. }
  59864. if (ch === 13 && source.charCodeAt(index) === 10) {
  59865. ++index;
  59866. }
  59867. ++lineNumber;
  59868. lineStart = index;
  59869. return;
  59870. }
  59871. }
  59872. if (extra.comments) {
  59873. comment = source.slice(start + 2, index);
  59874. loc.end = {
  59875. line: lineNumber,
  59876. column: index - lineStart
  59877. };
  59878. addComment('Line', comment, start, index, loc);
  59879. }
  59880. }
  59881. function skipMultiLineComment() {
  59882. var start, loc, ch, comment;
  59883. if (extra.comments) {
  59884. start = index - 2;
  59885. loc = {
  59886. start: {
  59887. line: lineNumber,
  59888. column: index - lineStart - 2
  59889. }
  59890. };
  59891. }
  59892. while (index < length) {
  59893. ch = source.charCodeAt(index);
  59894. if (isLineTerminator(ch)) {
  59895. if (ch === 13 && source.charCodeAt(index + 1) === 10) {
  59896. ++index;
  59897. }
  59898. ++lineNumber;
  59899. ++index;
  59900. lineStart = index;
  59901. if (index >= length) {
  59902. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  59903. }
  59904. } else if (ch === 42) {
  59905. // Block comment ends with '*/' (char #42, char #47).
  59906. if (source.charCodeAt(index + 1) === 47) {
  59907. ++index;
  59908. ++index;
  59909. if (extra.comments) {
  59910. comment = source.slice(start + 2, index - 2);
  59911. loc.end = {
  59912. line: lineNumber,
  59913. column: index - lineStart
  59914. };
  59915. addComment('Block', comment, start, index, loc);
  59916. }
  59917. return;
  59918. }
  59919. ++index;
  59920. } else {
  59921. ++index;
  59922. }
  59923. }
  59924. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  59925. }
  59926. function skipComment() {
  59927. var ch;
  59928. while (index < length) {
  59929. ch = source.charCodeAt(index);
  59930. if (isWhiteSpace(ch)) {
  59931. ++index;
  59932. } else if (isLineTerminator(ch)) {
  59933. ++index;
  59934. if (ch === 13 && source.charCodeAt(index) === 10) {
  59935. ++index;
  59936. }
  59937. ++lineNumber;
  59938. lineStart = index;
  59939. } else if (ch === 47) { // 47 is '/'
  59940. ch = source.charCodeAt(index + 1);
  59941. if (ch === 47) {
  59942. ++index;
  59943. ++index;
  59944. skipSingleLineComment();
  59945. } else if (ch === 42) { // 42 is '*'
  59946. ++index;
  59947. ++index;
  59948. skipMultiLineComment();
  59949. } else {
  59950. break;
  59951. }
  59952. } else {
  59953. break;
  59954. }
  59955. }
  59956. }
  59957. function scanHexEscape(prefix) {
  59958. var i, len, ch, code = 0;
  59959. len = (prefix === 'u') ? 4 : 2;
  59960. for (i = 0; i < len; ++i) {
  59961. if (index < length && isHexDigit(source[index])) {
  59962. ch = source[index++];
  59963. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  59964. } else {
  59965. return '';
  59966. }
  59967. }
  59968. return String.fromCharCode(code);
  59969. }
  59970. function scanUnicodeCodePointEscape() {
  59971. var ch, code, cu1, cu2;
  59972. ch = source[index];
  59973. code = 0;
  59974. // At least, one hex digit is required.
  59975. if (ch === '}') {
  59976. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  59977. }
  59978. while (index < length) {
  59979. ch = source[index++];
  59980. if (!isHexDigit(ch)) {
  59981. break;
  59982. }
  59983. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  59984. }
  59985. if (code > 0x10FFFF || ch !== '}') {
  59986. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  59987. }
  59988. // UTF-16 Encoding
  59989. if (code <= 0xFFFF) {
  59990. return String.fromCharCode(code);
  59991. }
  59992. cu1 = ((code - 0x10000) >> 10) + 0xD800;
  59993. cu2 = ((code - 0x10000) & 1023) + 0xDC00;
  59994. return String.fromCharCode(cu1, cu2);
  59995. }
  59996. function getEscapedIdentifier() {
  59997. var ch, id;
  59998. ch = source.charCodeAt(index++);
  59999. id = String.fromCharCode(ch);
  60000. // '\u' (char #92, char #117) denotes an escaped character.
  60001. if (ch === 92) {
  60002. if (source.charCodeAt(index) !== 117) {
  60003. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60004. }
  60005. ++index;
  60006. ch = scanHexEscape('u');
  60007. if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
  60008. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60009. }
  60010. id = ch;
  60011. }
  60012. while (index < length) {
  60013. ch = source.charCodeAt(index);
  60014. if (!isIdentifierPart(ch)) {
  60015. break;
  60016. }
  60017. ++index;
  60018. id += String.fromCharCode(ch);
  60019. // '\u' (char #92, char #117) denotes an escaped character.
  60020. if (ch === 92) {
  60021. id = id.substr(0, id.length - 1);
  60022. if (source.charCodeAt(index) !== 117) {
  60023. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60024. }
  60025. ++index;
  60026. ch = scanHexEscape('u');
  60027. if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
  60028. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60029. }
  60030. id += ch;
  60031. }
  60032. }
  60033. return id;
  60034. }
  60035. function getIdentifier() {
  60036. var start, ch;
  60037. start = index++;
  60038. while (index < length) {
  60039. ch = source.charCodeAt(index);
  60040. if (ch === 92) {
  60041. // Blackslash (char #92) marks Unicode escape sequence.
  60042. index = start;
  60043. return getEscapedIdentifier();
  60044. }
  60045. if (isIdentifierPart(ch)) {
  60046. ++index;
  60047. } else {
  60048. break;
  60049. }
  60050. }
  60051. return source.slice(start, index);
  60052. }
  60053. function scanIdentifier() {
  60054. var start, id, type;
  60055. start = index;
  60056. // Backslash (char #92) starts an escaped character.
  60057. id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
  60058. // There is no keyword or literal with only one character.
  60059. // Thus, it must be an identifier.
  60060. if (id.length === 1) {
  60061. type = Token.Identifier;
  60062. } else if (isKeyword(id)) {
  60063. type = Token.Keyword;
  60064. } else if (id === 'null') {
  60065. type = Token.NullLiteral;
  60066. } else if (id === 'true' || id === 'false') {
  60067. type = Token.BooleanLiteral;
  60068. } else {
  60069. type = Token.Identifier;
  60070. }
  60071. return {
  60072. type: type,
  60073. value: id,
  60074. lineNumber: lineNumber,
  60075. lineStart: lineStart,
  60076. range: [start, index]
  60077. };
  60078. }
  60079. // 7.7 Punctuators
  60080. function scanPunctuator() {
  60081. var start = index,
  60082. code = source.charCodeAt(index),
  60083. code2,
  60084. ch1 = source[index],
  60085. ch2,
  60086. ch3,
  60087. ch4;
  60088. if (state.inJSXTag || state.inJSXChild) {
  60089. // Don't need to check for '{' and '}' as it's already handled
  60090. // correctly by default.
  60091. switch (code) {
  60092. case 60: // <
  60093. case 62: // >
  60094. ++index;
  60095. return {
  60096. type: Token.Punctuator,
  60097. value: String.fromCharCode(code),
  60098. lineNumber: lineNumber,
  60099. lineStart: lineStart,
  60100. range: [start, index]
  60101. };
  60102. }
  60103. }
  60104. switch (code) {
  60105. // Check for most common single-character punctuators.
  60106. case 40: // ( open bracket
  60107. case 41: // ) close bracket
  60108. case 59: // ; semicolon
  60109. case 44: // , comma
  60110. case 91: // [
  60111. case 93: // ]
  60112. case 58: // :
  60113. case 63: // ?
  60114. case 126: // ~
  60115. ++index;
  60116. if (extra.tokenize && code === 40) {
  60117. extra.openParenToken = extra.tokens.length;
  60118. }
  60119. return {
  60120. type: Token.Punctuator,
  60121. value: String.fromCharCode(code),
  60122. lineNumber: lineNumber,
  60123. lineStart: lineStart,
  60124. range: [start, index]
  60125. };
  60126. case 123: // { open curly brace
  60127. case 125: // } close curly brace
  60128. ++index;
  60129. if (extra.tokenize && code === 123) {
  60130. extra.openCurlyToken = extra.tokens.length;
  60131. }
  60132. // lookahead2 function can cause tokens to be scanned twice and in doing so
  60133. // would wreck the curly stack by pushing the same token onto the stack twice.
  60134. // curlyLastIndex ensures each token is pushed or popped exactly once
  60135. if (index > state.curlyLastIndex) {
  60136. state.curlyLastIndex = index;
  60137. if (code === 123) {
  60138. state.curlyStack.push('{');
  60139. } else {
  60140. state.curlyStack.pop();
  60141. }
  60142. }
  60143. return {
  60144. type: Token.Punctuator,
  60145. value: String.fromCharCode(code),
  60146. lineNumber: lineNumber,
  60147. lineStart: lineStart,
  60148. range: [start, index]
  60149. };
  60150. default:
  60151. code2 = source.charCodeAt(index + 1);
  60152. // '=' (char #61) marks an assignment or comparison operator.
  60153. if (code2 === 61) {
  60154. switch (code) {
  60155. case 37: // %
  60156. case 38: // &
  60157. case 42: // *:
  60158. case 43: // +
  60159. case 45: // -
  60160. case 47: // /
  60161. case 60: // <
  60162. case 62: // >
  60163. case 94: // ^
  60164. case 124: // |
  60165. index += 2;
  60166. return {
  60167. type: Token.Punctuator,
  60168. value: String.fromCharCode(code) + String.fromCharCode(code2),
  60169. lineNumber: lineNumber,
  60170. lineStart: lineStart,
  60171. range: [start, index]
  60172. };
  60173. case 33: // !
  60174. case 61: // =
  60175. index += 2;
  60176. // !== and ===
  60177. if (source.charCodeAt(index) === 61) {
  60178. ++index;
  60179. }
  60180. return {
  60181. type: Token.Punctuator,
  60182. value: source.slice(start, index),
  60183. lineNumber: lineNumber,
  60184. lineStart: lineStart,
  60185. range: [start, index]
  60186. };
  60187. default:
  60188. break;
  60189. }
  60190. }
  60191. break;
  60192. }
  60193. // Peek more characters.
  60194. ch2 = source[index + 1];
  60195. ch3 = source[index + 2];
  60196. ch4 = source[index + 3];
  60197. // 4-character punctuator: >>>=
  60198. if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
  60199. if (ch4 === '=') {
  60200. index += 4;
  60201. return {
  60202. type: Token.Punctuator,
  60203. value: '>>>=',
  60204. lineNumber: lineNumber,
  60205. lineStart: lineStart,
  60206. range: [start, index]
  60207. };
  60208. }
  60209. }
  60210. // 3-character punctuators: === !== >>> <<= >>=
  60211. if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) {
  60212. index += 3;
  60213. return {
  60214. type: Token.Punctuator,
  60215. value: '>>>',
  60216. lineNumber: lineNumber,
  60217. lineStart: lineStart,
  60218. range: [start, index]
  60219. };
  60220. }
  60221. if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
  60222. index += 3;
  60223. return {
  60224. type: Token.Punctuator,
  60225. value: '<<=',
  60226. lineNumber: lineNumber,
  60227. lineStart: lineStart,
  60228. range: [start, index]
  60229. };
  60230. }
  60231. if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
  60232. index += 3;
  60233. return {
  60234. type: Token.Punctuator,
  60235. value: '>>=',
  60236. lineNumber: lineNumber,
  60237. lineStart: lineStart,
  60238. range: [start, index]
  60239. };
  60240. }
  60241. if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
  60242. index += 3;
  60243. return {
  60244. type: Token.Punctuator,
  60245. value: '...',
  60246. lineNumber: lineNumber,
  60247. lineStart: lineStart,
  60248. range: [start, index]
  60249. };
  60250. }
  60251. // Other 2-character punctuators: ++ -- << >> && ||
  60252. // Don't match these tokens if we're in a type, since they never can
  60253. // occur and can mess up types like Map<string, Array<string>>
  60254. if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
  60255. index += 2;
  60256. return {
  60257. type: Token.Punctuator,
  60258. value: ch1 + ch2,
  60259. lineNumber: lineNumber,
  60260. lineStart: lineStart,
  60261. range: [start, index]
  60262. };
  60263. }
  60264. if (ch1 === '=' && ch2 === '>') {
  60265. index += 2;
  60266. return {
  60267. type: Token.Punctuator,
  60268. value: '=>',
  60269. lineNumber: lineNumber,
  60270. lineStart: lineStart,
  60271. range: [start, index]
  60272. };
  60273. }
  60274. if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
  60275. ++index;
  60276. return {
  60277. type: Token.Punctuator,
  60278. value: ch1,
  60279. lineNumber: lineNumber,
  60280. lineStart: lineStart,
  60281. range: [start, index]
  60282. };
  60283. }
  60284. if (ch1 === '.') {
  60285. ++index;
  60286. return {
  60287. type: Token.Punctuator,
  60288. value: ch1,
  60289. lineNumber: lineNumber,
  60290. lineStart: lineStart,
  60291. range: [start, index]
  60292. };
  60293. }
  60294. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60295. }
  60296. // 7.8.3 Numeric Literals
  60297. function scanHexLiteral(start) {
  60298. var number = '';
  60299. while (index < length) {
  60300. if (!isHexDigit(source[index])) {
  60301. break;
  60302. }
  60303. number += source[index++];
  60304. }
  60305. if (number.length === 0) {
  60306. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60307. }
  60308. if (isIdentifierStart(source.charCodeAt(index))) {
  60309. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60310. }
  60311. return {
  60312. type: Token.NumericLiteral,
  60313. value: parseInt('0x' + number, 16),
  60314. lineNumber: lineNumber,
  60315. lineStart: lineStart,
  60316. range: [start, index]
  60317. };
  60318. }
  60319. function scanBinaryLiteral(start) {
  60320. var ch, number;
  60321. number = '';
  60322. while (index < length) {
  60323. ch = source[index];
  60324. if (ch !== '0' && ch !== '1') {
  60325. break;
  60326. }
  60327. number += source[index++];
  60328. }
  60329. if (number.length === 0) {
  60330. // only 0b or 0B
  60331. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60332. }
  60333. if (index < length) {
  60334. ch = source.charCodeAt(index);
  60335. /* istanbul ignore else */
  60336. if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
  60337. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60338. }
  60339. }
  60340. return {
  60341. type: Token.NumericLiteral,
  60342. value: parseInt(number, 2),
  60343. lineNumber: lineNumber,
  60344. lineStart: lineStart,
  60345. range: [start, index]
  60346. };
  60347. }
  60348. function scanOctalLiteral(prefix, start) {
  60349. var number, octal;
  60350. if (isOctalDigit(prefix)) {
  60351. octal = true;
  60352. number = '0' + source[index++];
  60353. } else {
  60354. octal = false;
  60355. ++index;
  60356. number = '';
  60357. }
  60358. while (index < length) {
  60359. if (!isOctalDigit(source[index])) {
  60360. break;
  60361. }
  60362. number += source[index++];
  60363. }
  60364. if (!octal && number.length === 0) {
  60365. // only 0o or 0O
  60366. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60367. }
  60368. if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
  60369. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60370. }
  60371. return {
  60372. type: Token.NumericLiteral,
  60373. value: parseInt(number, 8),
  60374. octal: octal,
  60375. lineNumber: lineNumber,
  60376. lineStart: lineStart,
  60377. range: [start, index]
  60378. };
  60379. }
  60380. function scanNumericLiteral() {
  60381. var number, start, ch;
  60382. ch = source[index];
  60383. assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
  60384. 'Numeric literal must start with a decimal digit or a decimal point');
  60385. start = index;
  60386. number = '';
  60387. if (ch !== '.') {
  60388. number = source[index++];
  60389. ch = source[index];
  60390. // Hex number starts with '0x'.
  60391. // Octal number starts with '0'.
  60392. // Octal number in ES6 starts with '0o'.
  60393. // Binary number in ES6 starts with '0b'.
  60394. if (number === '0') {
  60395. if (ch === 'x' || ch === 'X') {
  60396. ++index;
  60397. return scanHexLiteral(start);
  60398. }
  60399. if (ch === 'b' || ch === 'B') {
  60400. ++index;
  60401. return scanBinaryLiteral(start);
  60402. }
  60403. if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
  60404. return scanOctalLiteral(ch, start);
  60405. }
  60406. // decimal number starts with '0' such as '09' is illegal.
  60407. if (ch && isDecimalDigit(ch.charCodeAt(0))) {
  60408. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60409. }
  60410. }
  60411. while (isDecimalDigit(source.charCodeAt(index))) {
  60412. number += source[index++];
  60413. }
  60414. ch = source[index];
  60415. }
  60416. if (ch === '.') {
  60417. number += source[index++];
  60418. while (isDecimalDigit(source.charCodeAt(index))) {
  60419. number += source[index++];
  60420. }
  60421. ch = source[index];
  60422. }
  60423. if (ch === 'e' || ch === 'E') {
  60424. number += source[index++];
  60425. ch = source[index];
  60426. if (ch === '+' || ch === '-') {
  60427. number += source[index++];
  60428. }
  60429. if (isDecimalDigit(source.charCodeAt(index))) {
  60430. while (isDecimalDigit(source.charCodeAt(index))) {
  60431. number += source[index++];
  60432. }
  60433. } else {
  60434. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60435. }
  60436. }
  60437. if (isIdentifierStart(source.charCodeAt(index))) {
  60438. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60439. }
  60440. return {
  60441. type: Token.NumericLiteral,
  60442. value: parseFloat(number),
  60443. lineNumber: lineNumber,
  60444. lineStart: lineStart,
  60445. range: [start, index]
  60446. };
  60447. }
  60448. // 7.8.4 String Literals
  60449. function scanStringLiteral() {
  60450. var str = '', quote, start, ch, code, unescaped, restore, octal = false;
  60451. quote = source[index];
  60452. assert((quote === '\'' || quote === '"'),
  60453. 'String literal must starts with a quote');
  60454. start = index;
  60455. ++index;
  60456. while (index < length) {
  60457. ch = source[index++];
  60458. if (ch === quote) {
  60459. quote = '';
  60460. break;
  60461. } else if (ch === '\\') {
  60462. ch = source[index++];
  60463. if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
  60464. switch (ch) {
  60465. case 'n':
  60466. str += '\n';
  60467. break;
  60468. case 'r':
  60469. str += '\r';
  60470. break;
  60471. case 't':
  60472. str += '\t';
  60473. break;
  60474. case 'u':
  60475. case 'x':
  60476. if (source[index] === '{') {
  60477. ++index;
  60478. str += scanUnicodeCodePointEscape();
  60479. } else {
  60480. restore = index;
  60481. unescaped = scanHexEscape(ch);
  60482. if (unescaped) {
  60483. str += unescaped;
  60484. } else {
  60485. index = restore;
  60486. str += ch;
  60487. }
  60488. }
  60489. break;
  60490. case 'b':
  60491. str += '\b';
  60492. break;
  60493. case 'f':
  60494. str += '\f';
  60495. break;
  60496. case 'v':
  60497. str += '\x0B';
  60498. break;
  60499. default:
  60500. if (isOctalDigit(ch)) {
  60501. code = '01234567'.indexOf(ch);
  60502. // \0 is not octal escape sequence
  60503. if (code !== 0) {
  60504. octal = true;
  60505. }
  60506. /* istanbul ignore else */
  60507. if (index < length && isOctalDigit(source[index])) {
  60508. octal = true;
  60509. code = code * 8 + '01234567'.indexOf(source[index++]);
  60510. // 3 digits are only allowed when string starts
  60511. // with 0, 1, 2, 3
  60512. if ('0123'.indexOf(ch) >= 0 &&
  60513. index < length &&
  60514. isOctalDigit(source[index])) {
  60515. code = code * 8 + '01234567'.indexOf(source[index++]);
  60516. }
  60517. }
  60518. str += String.fromCharCode(code);
  60519. } else {
  60520. str += ch;
  60521. }
  60522. break;
  60523. }
  60524. } else {
  60525. ++lineNumber;
  60526. if (ch === '\r' && source[index] === '\n') {
  60527. ++index;
  60528. }
  60529. lineStart = index;
  60530. }
  60531. } else if (isLineTerminator(ch.charCodeAt(0))) {
  60532. break;
  60533. } else {
  60534. str += ch;
  60535. }
  60536. }
  60537. if (quote !== '') {
  60538. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60539. }
  60540. return {
  60541. type: Token.StringLiteral,
  60542. value: str,
  60543. octal: octal,
  60544. lineNumber: lineNumber,
  60545. lineStart: lineStart,
  60546. range: [start, index]
  60547. };
  60548. }
  60549. function scanTemplate() {
  60550. var cooked = '', ch, start, terminated, head, tail, restore, unescaped, code, octal;
  60551. terminated = false;
  60552. tail = false;
  60553. start = index;
  60554. head = (source[index] === '`');
  60555. ++index;
  60556. while (index < length) {
  60557. ch = source[index++];
  60558. if (ch === '`') {
  60559. tail = true;
  60560. terminated = true;
  60561. break;
  60562. } else if (ch === '$') {
  60563. if (source[index] === '{') {
  60564. ++index;
  60565. terminated = true;
  60566. break;
  60567. }
  60568. cooked += ch;
  60569. } else if (ch === '\\') {
  60570. ch = source[index++];
  60571. if (!isLineTerminator(ch.charCodeAt(0))) {
  60572. switch (ch) {
  60573. case 'n':
  60574. cooked += '\n';
  60575. break;
  60576. case 'r':
  60577. cooked += '\r';
  60578. break;
  60579. case 't':
  60580. cooked += '\t';
  60581. break;
  60582. case 'u':
  60583. case 'x':
  60584. if (source[index] === '{') {
  60585. ++index;
  60586. cooked += scanUnicodeCodePointEscape();
  60587. } else {
  60588. restore = index;
  60589. unescaped = scanHexEscape(ch);
  60590. if (unescaped) {
  60591. cooked += unescaped;
  60592. } else {
  60593. index = restore;
  60594. cooked += ch;
  60595. }
  60596. }
  60597. break;
  60598. case 'b':
  60599. cooked += '\b';
  60600. break;
  60601. case 'f':
  60602. cooked += '\f';
  60603. break;
  60604. case 'v':
  60605. cooked += '\v';
  60606. break;
  60607. default:
  60608. if (isOctalDigit(ch)) {
  60609. code = '01234567'.indexOf(ch);
  60610. // \0 is not octal escape sequence
  60611. if (code !== 0) {
  60612. octal = true;
  60613. }
  60614. /* istanbul ignore else */
  60615. if (index < length && isOctalDigit(source[index])) {
  60616. octal = true;
  60617. code = code * 8 + '01234567'.indexOf(source[index++]);
  60618. // 3 digits are only allowed when string starts
  60619. // with 0, 1, 2, 3
  60620. if ('0123'.indexOf(ch) >= 0 &&
  60621. index < length &&
  60622. isOctalDigit(source[index])) {
  60623. code = code * 8 + '01234567'.indexOf(source[index++]);
  60624. }
  60625. }
  60626. cooked += String.fromCharCode(code);
  60627. } else {
  60628. cooked += ch;
  60629. }
  60630. break;
  60631. }
  60632. } else {
  60633. ++lineNumber;
  60634. if (ch === '\r' && source[index] === '\n') {
  60635. ++index;
  60636. }
  60637. lineStart = index;
  60638. }
  60639. } else if (isLineTerminator(ch.charCodeAt(0))) {
  60640. ++lineNumber;
  60641. if (ch === '\r' && source[index] === '\n') {
  60642. ++index;
  60643. }
  60644. lineStart = index;
  60645. cooked += '\n';
  60646. } else {
  60647. cooked += ch;
  60648. }
  60649. }
  60650. if (!terminated) {
  60651. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  60652. }
  60653. if (index > state.curlyLastIndex) {
  60654. state.curlyLastIndex = index;
  60655. if (!tail) {
  60656. state.curlyStack.push('template');
  60657. }
  60658. if (!head) {
  60659. state.curlyStack.pop();
  60660. }
  60661. }
  60662. return {
  60663. type: Token.Template,
  60664. value: {
  60665. cooked: cooked,
  60666. raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
  60667. },
  60668. head: head,
  60669. tail: tail,
  60670. octal: octal,
  60671. lineNumber: lineNumber,
  60672. lineStart: lineStart,
  60673. range: [start, index]
  60674. };
  60675. }
  60676. function testRegExp(pattern, flags) {
  60677. var tmp = pattern,
  60678. value;
  60679. if (flags.indexOf('u') >= 0) {
  60680. // Replace each astral symbol and every Unicode code point
  60681. // escape sequence with a single ASCII symbol to avoid throwing on
  60682. // regular expressions that are only valid in combination with the
  60683. // `/u` flag.
  60684. // Note: replacing with the ASCII symbol `x` might cause false
  60685. // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
  60686. // perfectly valid pattern that is equivalent to `[a-b]`, but it
  60687. // would be replaced by `[x-b]` which throws an error.
  60688. tmp = tmp
  60689. .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
  60690. if (parseInt($1, 16) <= 0x10FFFF) {
  60691. return 'x';
  60692. }
  60693. throwError({}, Messages.InvalidRegExp);
  60694. })
  60695. .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
  60696. }
  60697. // First, detect invalid regular expressions.
  60698. try {
  60699. value = new RegExp(tmp);
  60700. } catch (e) {
  60701. throwError({}, Messages.InvalidRegExp);
  60702. }
  60703. // Return a regular expression object for this pattern-flag pair, or
  60704. // `null` in case the current environment doesn't support the flags it
  60705. // uses.
  60706. try {
  60707. return new RegExp(pattern, flags);
  60708. } catch (exception) {
  60709. return null;
  60710. }
  60711. }
  60712. function scanRegExpBody() {
  60713. var ch, str, classMarker, terminated, body;
  60714. ch = source[index];
  60715. assert(ch === '/', 'Regular expression literal must start with a slash');
  60716. str = source[index++];
  60717. classMarker = false;
  60718. terminated = false;
  60719. while (index < length) {
  60720. ch = source[index++];
  60721. str += ch;
  60722. if (ch === '\\') {
  60723. ch = source[index++];
  60724. // ECMA-262 7.8.5
  60725. if (isLineTerminator(ch.charCodeAt(0))) {
  60726. throwError({}, Messages.UnterminatedRegExp);
  60727. }
  60728. str += ch;
  60729. } else if (isLineTerminator(ch.charCodeAt(0))) {
  60730. throwError({}, Messages.UnterminatedRegExp);
  60731. } else if (classMarker) {
  60732. if (ch === ']') {
  60733. classMarker = false;
  60734. }
  60735. } else {
  60736. if (ch === '/') {
  60737. terminated = true;
  60738. break;
  60739. } else if (ch === '[') {
  60740. classMarker = true;
  60741. }
  60742. }
  60743. }
  60744. if (!terminated) {
  60745. throwError({}, Messages.UnterminatedRegExp);
  60746. }
  60747. // Exclude leading and trailing slash.
  60748. body = str.substr(1, str.length - 2);
  60749. return {
  60750. value: body,
  60751. literal: str
  60752. };
  60753. }
  60754. function scanRegExpFlags() {
  60755. var ch, str, flags, restore;
  60756. str = '';
  60757. flags = '';
  60758. while (index < length) {
  60759. ch = source[index];
  60760. if (!isIdentifierPart(ch.charCodeAt(0))) {
  60761. break;
  60762. }
  60763. ++index;
  60764. if (ch === '\\' && index < length) {
  60765. ch = source[index];
  60766. if (ch === 'u') {
  60767. ++index;
  60768. restore = index;
  60769. ch = scanHexEscape('u');
  60770. if (ch) {
  60771. flags += ch;
  60772. for (str += '\\u'; restore < index; ++restore) {
  60773. str += source[restore];
  60774. }
  60775. } else {
  60776. index = restore;
  60777. flags += 'u';
  60778. str += '\\u';
  60779. }
  60780. throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
  60781. } else {
  60782. str += '\\';
  60783. throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
  60784. }
  60785. } else {
  60786. flags += ch;
  60787. str += ch;
  60788. }
  60789. }
  60790. return {
  60791. value: flags,
  60792. literal: str
  60793. };
  60794. }
  60795. function scanRegExp() {
  60796. var start, body, flags, value;
  60797. lookahead = null;
  60798. skipComment();
  60799. start = index;
  60800. body = scanRegExpBody();
  60801. flags = scanRegExpFlags();
  60802. value = testRegExp(body.value, flags.value);
  60803. if (extra.tokenize) {
  60804. return {
  60805. type: Token.RegularExpression,
  60806. value: value,
  60807. regex: {
  60808. pattern: body.value,
  60809. flags: flags.value
  60810. },
  60811. lineNumber: lineNumber,
  60812. lineStart: lineStart,
  60813. range: [start, index]
  60814. };
  60815. }
  60816. return {
  60817. literal: body.literal + flags.literal,
  60818. value: value,
  60819. regex: {
  60820. pattern: body.value,
  60821. flags: flags.value
  60822. },
  60823. range: [start, index]
  60824. };
  60825. }
  60826. function isIdentifierName(token) {
  60827. return token.type === Token.Identifier ||
  60828. token.type === Token.Keyword ||
  60829. token.type === Token.BooleanLiteral ||
  60830. token.type === Token.NullLiteral;
  60831. }
  60832. function advanceSlash() {
  60833. var prevToken,
  60834. checkToken;
  60835. // Using the following algorithm:
  60836. // https://github.com/mozilla/sweet.js/wiki/design
  60837. prevToken = extra.tokens[extra.tokens.length - 1];
  60838. if (!prevToken) {
  60839. // Nothing before that: it cannot be a division.
  60840. return scanRegExp();
  60841. }
  60842. if (prevToken.type === 'Punctuator') {
  60843. if (prevToken.value === ')') {
  60844. checkToken = extra.tokens[extra.openParenToken - 1];
  60845. if (checkToken &&
  60846. checkToken.type === 'Keyword' &&
  60847. (checkToken.value === 'if' ||
  60848. checkToken.value === 'while' ||
  60849. checkToken.value === 'for' ||
  60850. checkToken.value === 'with')) {
  60851. return scanRegExp();
  60852. }
  60853. return scanPunctuator();
  60854. }
  60855. if (prevToken.value === '}') {
  60856. // Dividing a function by anything makes little sense,
  60857. // but we have to check for that.
  60858. if (extra.tokens[extra.openCurlyToken - 3] &&
  60859. extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
  60860. // Anonymous function.
  60861. checkToken = extra.tokens[extra.openCurlyToken - 4];
  60862. if (!checkToken) {
  60863. return scanPunctuator();
  60864. }
  60865. } else if (extra.tokens[extra.openCurlyToken - 4] &&
  60866. extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
  60867. // Named function.
  60868. checkToken = extra.tokens[extra.openCurlyToken - 5];
  60869. if (!checkToken) {
  60870. return scanRegExp();
  60871. }
  60872. } else {
  60873. return scanPunctuator();
  60874. }
  60875. // checkToken determines whether the function is
  60876. // a declaration or an expression.
  60877. if (FnExprTokens.indexOf(checkToken.value) >= 0) {
  60878. // It is an expression.
  60879. return scanPunctuator();
  60880. }
  60881. // It is a declaration.
  60882. return scanRegExp();
  60883. }
  60884. return scanRegExp();
  60885. }
  60886. if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
  60887. return scanRegExp();
  60888. }
  60889. return scanPunctuator();
  60890. }
  60891. function advance() {
  60892. var ch;
  60893. if (!state.inJSXChild) {
  60894. skipComment();
  60895. }
  60896. if (index >= length) {
  60897. return {
  60898. type: Token.EOF,
  60899. lineNumber: lineNumber,
  60900. lineStart: lineStart,
  60901. range: [index, index]
  60902. };
  60903. }
  60904. if (state.inJSXChild) {
  60905. return advanceJSXChild();
  60906. }
  60907. ch = source.charCodeAt(index);
  60908. // Very common: ( and ) and ;
  60909. if (ch === 40 || ch === 41 || ch === 58) {
  60910. return scanPunctuator();
  60911. }
  60912. // String literal starts with single quote (#39) or double quote (#34).
  60913. if (ch === 39 || ch === 34) {
  60914. if (state.inJSXTag) {
  60915. return scanJSXStringLiteral();
  60916. }
  60917. return scanStringLiteral();
  60918. }
  60919. if (state.inJSXTag && isJSXIdentifierStart(ch)) {
  60920. return scanJSXIdentifier();
  60921. }
  60922. // Template literals start with backtick (#96) for template head
  60923. // or close curly (#125) for template middle or template tail.
  60924. if (ch === 96 || (ch === 125 && state.curlyStack[state.curlyStack.length - 1] === 'template')) {
  60925. return scanTemplate();
  60926. }
  60927. if (isIdentifierStart(ch)) {
  60928. return scanIdentifier();
  60929. }
  60930. // Dot (.) char #46 can also start a floating-point number, hence the need
  60931. // to check the next character.
  60932. if (ch === 46) {
  60933. if (isDecimalDigit(source.charCodeAt(index + 1))) {
  60934. return scanNumericLiteral();
  60935. }
  60936. return scanPunctuator();
  60937. }
  60938. if (isDecimalDigit(ch)) {
  60939. return scanNumericLiteral();
  60940. }
  60941. // Slash (/) char #47 can also start a regex.
  60942. if (extra.tokenize && ch === 47) {
  60943. return advanceSlash();
  60944. }
  60945. return scanPunctuator();
  60946. }
  60947. function lex() {
  60948. var token;
  60949. token = lookahead;
  60950. index = token.range[1];
  60951. lineNumber = token.lineNumber;
  60952. lineStart = token.lineStart;
  60953. lookahead = advance();
  60954. index = token.range[1];
  60955. lineNumber = token.lineNumber;
  60956. lineStart = token.lineStart;
  60957. return token;
  60958. }
  60959. function peek() {
  60960. var pos, line, start;
  60961. pos = index;
  60962. line = lineNumber;
  60963. start = lineStart;
  60964. lookahead = advance();
  60965. index = pos;
  60966. lineNumber = line;
  60967. lineStart = start;
  60968. }
  60969. function lookahead2() {
  60970. var adv, pos, line, start, result;
  60971. // If we are collecting the tokens, don't grab the next one yet.
  60972. /* istanbul ignore next */
  60973. adv = (typeof extra.advance === 'function') ? extra.advance : advance;
  60974. pos = index;
  60975. line = lineNumber;
  60976. start = lineStart;
  60977. // Scan for the next immediate token.
  60978. /* istanbul ignore if */
  60979. if (lookahead === null) {
  60980. lookahead = adv();
  60981. }
  60982. index = lookahead.range[1];
  60983. lineNumber = lookahead.lineNumber;
  60984. lineStart = lookahead.lineStart;
  60985. // Grab the token right after.
  60986. result = adv();
  60987. index = pos;
  60988. lineNumber = line;
  60989. lineStart = start;
  60990. return result;
  60991. }
  60992. function rewind(token) {
  60993. index = token.range[0];
  60994. lineNumber = token.lineNumber;
  60995. lineStart = token.lineStart;
  60996. lookahead = token;
  60997. }
  60998. function markerCreate() {
  60999. if (!extra.loc && !extra.range) {
  61000. return undefined;
  61001. }
  61002. skipComment();
  61003. return {offset: index, line: lineNumber, col: index - lineStart};
  61004. }
  61005. function markerCreatePreserveWhitespace() {
  61006. if (!extra.loc && !extra.range) {
  61007. return undefined;
  61008. }
  61009. return {offset: index, line: lineNumber, col: index - lineStart};
  61010. }
  61011. function processComment(node) {
  61012. var lastChild,
  61013. trailingComments,
  61014. bottomRight = extra.bottomRightStack,
  61015. last = bottomRight[bottomRight.length - 1];
  61016. if (node.type === Syntax.Program) {
  61017. /* istanbul ignore else */
  61018. if (node.body.length > 0) {
  61019. return;
  61020. }
  61021. }
  61022. if (extra.trailingComments.length > 0) {
  61023. if (extra.trailingComments[0].range[0] >= node.range[1]) {
  61024. trailingComments = extra.trailingComments;
  61025. extra.trailingComments = [];
  61026. } else {
  61027. extra.trailingComments.length = 0;
  61028. }
  61029. } else {
  61030. if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
  61031. trailingComments = last.trailingComments;
  61032. delete last.trailingComments;
  61033. }
  61034. }
  61035. // Eating the stack.
  61036. if (last) {
  61037. while (last && last.range[0] >= node.range[0]) {
  61038. lastChild = last;
  61039. last = bottomRight.pop();
  61040. }
  61041. }
  61042. if (lastChild) {
  61043. if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
  61044. node.leadingComments = lastChild.leadingComments;
  61045. delete lastChild.leadingComments;
  61046. }
  61047. } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
  61048. node.leadingComments = extra.leadingComments;
  61049. extra.leadingComments = [];
  61050. }
  61051. if (trailingComments) {
  61052. node.trailingComments = trailingComments;
  61053. }
  61054. bottomRight.push(node);
  61055. }
  61056. function markerApply(marker, node) {
  61057. if (extra.range) {
  61058. node.range = [marker.offset, index];
  61059. }
  61060. if (extra.loc) {
  61061. node.loc = {
  61062. start: {
  61063. line: marker.line,
  61064. column: marker.col
  61065. },
  61066. end: {
  61067. line: lineNumber,
  61068. column: index - lineStart
  61069. }
  61070. };
  61071. node = delegate.postProcess(node);
  61072. }
  61073. if (extra.attachComment) {
  61074. processComment(node);
  61075. }
  61076. return node;
  61077. }
  61078. SyntaxTreeDelegate = {
  61079. name: 'SyntaxTree',
  61080. postProcess: function (node) {
  61081. return node;
  61082. },
  61083. createArrayExpression: function (elements) {
  61084. return {
  61085. type: Syntax.ArrayExpression,
  61086. elements: elements
  61087. };
  61088. },
  61089. createAssignmentExpression: function (operator, left, right) {
  61090. return {
  61091. type: Syntax.AssignmentExpression,
  61092. operator: operator,
  61093. left: left,
  61094. right: right
  61095. };
  61096. },
  61097. createBinaryExpression: function (operator, left, right) {
  61098. var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
  61099. Syntax.BinaryExpression;
  61100. return {
  61101. type: type,
  61102. operator: operator,
  61103. left: left,
  61104. right: right
  61105. };
  61106. },
  61107. createBlockStatement: function (body) {
  61108. return {
  61109. type: Syntax.BlockStatement,
  61110. body: body
  61111. };
  61112. },
  61113. createBreakStatement: function (label) {
  61114. return {
  61115. type: Syntax.BreakStatement,
  61116. label: label
  61117. };
  61118. },
  61119. createCallExpression: function (callee, args) {
  61120. return {
  61121. type: Syntax.CallExpression,
  61122. callee: callee,
  61123. 'arguments': args
  61124. };
  61125. },
  61126. createCatchClause: function (param, body) {
  61127. return {
  61128. type: Syntax.CatchClause,
  61129. param: param,
  61130. body: body
  61131. };
  61132. },
  61133. createConditionalExpression: function (test, consequent, alternate) {
  61134. return {
  61135. type: Syntax.ConditionalExpression,
  61136. test: test,
  61137. consequent: consequent,
  61138. alternate: alternate
  61139. };
  61140. },
  61141. createContinueStatement: function (label) {
  61142. return {
  61143. type: Syntax.ContinueStatement,
  61144. label: label
  61145. };
  61146. },
  61147. createDebuggerStatement: function () {
  61148. return {
  61149. type: Syntax.DebuggerStatement
  61150. };
  61151. },
  61152. createDoWhileStatement: function (body, test) {
  61153. return {
  61154. type: Syntax.DoWhileStatement,
  61155. body: body,
  61156. test: test
  61157. };
  61158. },
  61159. createEmptyStatement: function () {
  61160. return {
  61161. type: Syntax.EmptyStatement
  61162. };
  61163. },
  61164. createExpressionStatement: function (expression) {
  61165. return {
  61166. type: Syntax.ExpressionStatement,
  61167. expression: expression
  61168. };
  61169. },
  61170. createForStatement: function (init, test, update, body) {
  61171. return {
  61172. type: Syntax.ForStatement,
  61173. init: init,
  61174. test: test,
  61175. update: update,
  61176. body: body
  61177. };
  61178. },
  61179. createForInStatement: function (left, right, body) {
  61180. return {
  61181. type: Syntax.ForInStatement,
  61182. left: left,
  61183. right: right,
  61184. body: body,
  61185. each: false
  61186. };
  61187. },
  61188. createForOfStatement: function (left, right, body) {
  61189. return {
  61190. type: Syntax.ForOfStatement,
  61191. left: left,
  61192. right: right,
  61193. body: body
  61194. };
  61195. },
  61196. createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
  61197. isAsync, returnType, typeParameters) {
  61198. var funDecl = {
  61199. type: Syntax.FunctionDeclaration,
  61200. id: id,
  61201. params: params,
  61202. defaults: defaults,
  61203. body: body,
  61204. rest: rest,
  61205. generator: generator,
  61206. expression: expression,
  61207. returnType: returnType,
  61208. typeParameters: typeParameters
  61209. };
  61210. if (isAsync) {
  61211. funDecl.async = true;
  61212. }
  61213. return funDecl;
  61214. },
  61215. createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
  61216. isAsync, returnType, typeParameters) {
  61217. var funExpr = {
  61218. type: Syntax.FunctionExpression,
  61219. id: id,
  61220. params: params,
  61221. defaults: defaults,
  61222. body: body,
  61223. rest: rest,
  61224. generator: generator,
  61225. expression: expression,
  61226. returnType: returnType,
  61227. typeParameters: typeParameters
  61228. };
  61229. if (isAsync) {
  61230. funExpr.async = true;
  61231. }
  61232. return funExpr;
  61233. },
  61234. createIdentifier: function (name) {
  61235. return {
  61236. type: Syntax.Identifier,
  61237. name: name,
  61238. // Only here to initialize the shape of the object to ensure
  61239. // that the 'typeAnnotation' key is ordered before others that
  61240. // are added later (like 'loc' and 'range'). This just helps
  61241. // keep the shape of Identifier nodes consistent with everything
  61242. // else.
  61243. typeAnnotation: undefined,
  61244. optional: undefined
  61245. };
  61246. },
  61247. createTypeAnnotation: function (typeAnnotation) {
  61248. return {
  61249. type: Syntax.TypeAnnotation,
  61250. typeAnnotation: typeAnnotation
  61251. };
  61252. },
  61253. createTypeCast: function (expression, typeAnnotation) {
  61254. return {
  61255. type: Syntax.TypeCastExpression,
  61256. expression: expression,
  61257. typeAnnotation: typeAnnotation
  61258. };
  61259. },
  61260. createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
  61261. return {
  61262. type: Syntax.FunctionTypeAnnotation,
  61263. params: params,
  61264. returnType: returnType,
  61265. rest: rest,
  61266. typeParameters: typeParameters
  61267. };
  61268. },
  61269. createFunctionTypeParam: function (name, typeAnnotation, optional) {
  61270. return {
  61271. type: Syntax.FunctionTypeParam,
  61272. name: name,
  61273. typeAnnotation: typeAnnotation,
  61274. optional: optional
  61275. };
  61276. },
  61277. createNullableTypeAnnotation: function (typeAnnotation) {
  61278. return {
  61279. type: Syntax.NullableTypeAnnotation,
  61280. typeAnnotation: typeAnnotation
  61281. };
  61282. },
  61283. createArrayTypeAnnotation: function (elementType) {
  61284. return {
  61285. type: Syntax.ArrayTypeAnnotation,
  61286. elementType: elementType
  61287. };
  61288. },
  61289. createGenericTypeAnnotation: function (id, typeParameters) {
  61290. return {
  61291. type: Syntax.GenericTypeAnnotation,
  61292. id: id,
  61293. typeParameters: typeParameters
  61294. };
  61295. },
  61296. createQualifiedTypeIdentifier: function (qualification, id) {
  61297. return {
  61298. type: Syntax.QualifiedTypeIdentifier,
  61299. qualification: qualification,
  61300. id: id
  61301. };
  61302. },
  61303. createTypeParameterDeclaration: function (params) {
  61304. return {
  61305. type: Syntax.TypeParameterDeclaration,
  61306. params: params
  61307. };
  61308. },
  61309. createTypeParameterInstantiation: function (params) {
  61310. return {
  61311. type: Syntax.TypeParameterInstantiation,
  61312. params: params
  61313. };
  61314. },
  61315. createAnyTypeAnnotation: function () {
  61316. return {
  61317. type: Syntax.AnyTypeAnnotation
  61318. };
  61319. },
  61320. createBooleanTypeAnnotation: function () {
  61321. return {
  61322. type: Syntax.BooleanTypeAnnotation
  61323. };
  61324. },
  61325. createNumberTypeAnnotation: function () {
  61326. return {
  61327. type: Syntax.NumberTypeAnnotation
  61328. };
  61329. },
  61330. createStringTypeAnnotation: function () {
  61331. return {
  61332. type: Syntax.StringTypeAnnotation
  61333. };
  61334. },
  61335. createStringLiteralTypeAnnotation: function (token) {
  61336. return {
  61337. type: Syntax.StringLiteralTypeAnnotation,
  61338. value: token.value,
  61339. raw: source.slice(token.range[0], token.range[1])
  61340. };
  61341. },
  61342. createVoidTypeAnnotation: function () {
  61343. return {
  61344. type: Syntax.VoidTypeAnnotation
  61345. };
  61346. },
  61347. createTypeofTypeAnnotation: function (argument) {
  61348. return {
  61349. type: Syntax.TypeofTypeAnnotation,
  61350. argument: argument
  61351. };
  61352. },
  61353. createTupleTypeAnnotation: function (types) {
  61354. return {
  61355. type: Syntax.TupleTypeAnnotation,
  61356. types: types
  61357. };
  61358. },
  61359. createObjectTypeAnnotation: function (properties, indexers, callProperties) {
  61360. return {
  61361. type: Syntax.ObjectTypeAnnotation,
  61362. properties: properties,
  61363. indexers: indexers,
  61364. callProperties: callProperties
  61365. };
  61366. },
  61367. createObjectTypeIndexer: function (id, key, value, isStatic) {
  61368. return {
  61369. type: Syntax.ObjectTypeIndexer,
  61370. id: id,
  61371. key: key,
  61372. value: value,
  61373. static: isStatic
  61374. };
  61375. },
  61376. createObjectTypeCallProperty: function (value, isStatic) {
  61377. return {
  61378. type: Syntax.ObjectTypeCallProperty,
  61379. value: value,
  61380. static: isStatic
  61381. };
  61382. },
  61383. createObjectTypeProperty: function (key, value, optional, isStatic) {
  61384. return {
  61385. type: Syntax.ObjectTypeProperty,
  61386. key: key,
  61387. value: value,
  61388. optional: optional,
  61389. static: isStatic
  61390. };
  61391. },
  61392. createUnionTypeAnnotation: function (types) {
  61393. return {
  61394. type: Syntax.UnionTypeAnnotation,
  61395. types: types
  61396. };
  61397. },
  61398. createIntersectionTypeAnnotation: function (types) {
  61399. return {
  61400. type: Syntax.IntersectionTypeAnnotation,
  61401. types: types
  61402. };
  61403. },
  61404. createTypeAlias: function (id, typeParameters, right) {
  61405. return {
  61406. type: Syntax.TypeAlias,
  61407. id: id,
  61408. typeParameters: typeParameters,
  61409. right: right
  61410. };
  61411. },
  61412. createInterface: function (id, typeParameters, body, extended) {
  61413. return {
  61414. type: Syntax.InterfaceDeclaration,
  61415. id: id,
  61416. typeParameters: typeParameters,
  61417. body: body,
  61418. extends: extended
  61419. };
  61420. },
  61421. createInterfaceExtends: function (id, typeParameters) {
  61422. return {
  61423. type: Syntax.InterfaceExtends,
  61424. id: id,
  61425. typeParameters: typeParameters
  61426. };
  61427. },
  61428. createDeclareFunction: function (id) {
  61429. return {
  61430. type: Syntax.DeclareFunction,
  61431. id: id
  61432. };
  61433. },
  61434. createDeclareVariable: function (id) {
  61435. return {
  61436. type: Syntax.DeclareVariable,
  61437. id: id
  61438. };
  61439. },
  61440. createDeclareModule: function (id, body) {
  61441. return {
  61442. type: Syntax.DeclareModule,
  61443. id: id,
  61444. body: body
  61445. };
  61446. },
  61447. createJSXAttribute: function (name, value) {
  61448. return {
  61449. type: Syntax.JSXAttribute,
  61450. name: name,
  61451. value: value || null
  61452. };
  61453. },
  61454. createJSXSpreadAttribute: function (argument) {
  61455. return {
  61456. type: Syntax.JSXSpreadAttribute,
  61457. argument: argument
  61458. };
  61459. },
  61460. createJSXIdentifier: function (name) {
  61461. return {
  61462. type: Syntax.JSXIdentifier,
  61463. name: name
  61464. };
  61465. },
  61466. createJSXNamespacedName: function (namespace, name) {
  61467. return {
  61468. type: Syntax.JSXNamespacedName,
  61469. namespace: namespace,
  61470. name: name
  61471. };
  61472. },
  61473. createJSXMemberExpression: function (object, property) {
  61474. return {
  61475. type: Syntax.JSXMemberExpression,
  61476. object: object,
  61477. property: property
  61478. };
  61479. },
  61480. createJSXElement: function (openingElement, closingElement, children) {
  61481. return {
  61482. type: Syntax.JSXElement,
  61483. openingElement: openingElement,
  61484. closingElement: closingElement,
  61485. children: children
  61486. };
  61487. },
  61488. createJSXEmptyExpression: function () {
  61489. return {
  61490. type: Syntax.JSXEmptyExpression
  61491. };
  61492. },
  61493. createJSXExpressionContainer: function (expression) {
  61494. return {
  61495. type: Syntax.JSXExpressionContainer,
  61496. expression: expression
  61497. };
  61498. },
  61499. createJSXOpeningElement: function (name, attributes, selfClosing) {
  61500. return {
  61501. type: Syntax.JSXOpeningElement,
  61502. name: name,
  61503. selfClosing: selfClosing,
  61504. attributes: attributes
  61505. };
  61506. },
  61507. createJSXClosingElement: function (name) {
  61508. return {
  61509. type: Syntax.JSXClosingElement,
  61510. name: name
  61511. };
  61512. },
  61513. createIfStatement: function (test, consequent, alternate) {
  61514. return {
  61515. type: Syntax.IfStatement,
  61516. test: test,
  61517. consequent: consequent,
  61518. alternate: alternate
  61519. };
  61520. },
  61521. createLabeledStatement: function (label, body) {
  61522. return {
  61523. type: Syntax.LabeledStatement,
  61524. label: label,
  61525. body: body
  61526. };
  61527. },
  61528. createLiteral: function (token) {
  61529. var object = {
  61530. type: Syntax.Literal,
  61531. value: token.value,
  61532. raw: source.slice(token.range[0], token.range[1])
  61533. };
  61534. if (token.regex) {
  61535. object.regex = token.regex;
  61536. }
  61537. return object;
  61538. },
  61539. createMemberExpression: function (accessor, object, property) {
  61540. return {
  61541. type: Syntax.MemberExpression,
  61542. computed: accessor === '[',
  61543. object: object,
  61544. property: property
  61545. };
  61546. },
  61547. createNewExpression: function (callee, args) {
  61548. return {
  61549. type: Syntax.NewExpression,
  61550. callee: callee,
  61551. 'arguments': args
  61552. };
  61553. },
  61554. createObjectExpression: function (properties) {
  61555. return {
  61556. type: Syntax.ObjectExpression,
  61557. properties: properties
  61558. };
  61559. },
  61560. createPostfixExpression: function (operator, argument) {
  61561. return {
  61562. type: Syntax.UpdateExpression,
  61563. operator: operator,
  61564. argument: argument,
  61565. prefix: false
  61566. };
  61567. },
  61568. createProgram: function (body) {
  61569. return {
  61570. type: Syntax.Program,
  61571. body: body
  61572. };
  61573. },
  61574. createProperty: function (kind, key, value, method, shorthand, computed) {
  61575. return {
  61576. type: Syntax.Property,
  61577. key: key,
  61578. value: value,
  61579. kind: kind,
  61580. method: method,
  61581. shorthand: shorthand,
  61582. computed: computed
  61583. };
  61584. },
  61585. createReturnStatement: function (argument) {
  61586. return {
  61587. type: Syntax.ReturnStatement,
  61588. argument: argument
  61589. };
  61590. },
  61591. createSequenceExpression: function (expressions) {
  61592. return {
  61593. type: Syntax.SequenceExpression,
  61594. expressions: expressions
  61595. };
  61596. },
  61597. createSwitchCase: function (test, consequent) {
  61598. return {
  61599. type: Syntax.SwitchCase,
  61600. test: test,
  61601. consequent: consequent
  61602. };
  61603. },
  61604. createSwitchStatement: function (discriminant, cases) {
  61605. return {
  61606. type: Syntax.SwitchStatement,
  61607. discriminant: discriminant,
  61608. cases: cases
  61609. };
  61610. },
  61611. createThisExpression: function () {
  61612. return {
  61613. type: Syntax.ThisExpression
  61614. };
  61615. },
  61616. createThrowStatement: function (argument) {
  61617. return {
  61618. type: Syntax.ThrowStatement,
  61619. argument: argument
  61620. };
  61621. },
  61622. createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
  61623. return {
  61624. type: Syntax.TryStatement,
  61625. block: block,
  61626. guardedHandlers: guardedHandlers,
  61627. handlers: handlers,
  61628. finalizer: finalizer
  61629. };
  61630. },
  61631. createUnaryExpression: function (operator, argument) {
  61632. if (operator === '++' || operator === '--') {
  61633. return {
  61634. type: Syntax.UpdateExpression,
  61635. operator: operator,
  61636. argument: argument,
  61637. prefix: true
  61638. };
  61639. }
  61640. return {
  61641. type: Syntax.UnaryExpression,
  61642. operator: operator,
  61643. argument: argument,
  61644. prefix: true
  61645. };
  61646. },
  61647. createVariableDeclaration: function (declarations, kind) {
  61648. return {
  61649. type: Syntax.VariableDeclaration,
  61650. declarations: declarations,
  61651. kind: kind
  61652. };
  61653. },
  61654. createVariableDeclarator: function (id, init) {
  61655. return {
  61656. type: Syntax.VariableDeclarator,
  61657. id: id,
  61658. init: init
  61659. };
  61660. },
  61661. createWhileStatement: function (test, body) {
  61662. return {
  61663. type: Syntax.WhileStatement,
  61664. test: test,
  61665. body: body
  61666. };
  61667. },
  61668. createWithStatement: function (object, body) {
  61669. return {
  61670. type: Syntax.WithStatement,
  61671. object: object,
  61672. body: body
  61673. };
  61674. },
  61675. createTemplateElement: function (value, tail) {
  61676. return {
  61677. type: Syntax.TemplateElement,
  61678. value: value,
  61679. tail: tail
  61680. };
  61681. },
  61682. createTemplateLiteral: function (quasis, expressions) {
  61683. return {
  61684. type: Syntax.TemplateLiteral,
  61685. quasis: quasis,
  61686. expressions: expressions
  61687. };
  61688. },
  61689. createSpreadElement: function (argument) {
  61690. return {
  61691. type: Syntax.SpreadElement,
  61692. argument: argument
  61693. };
  61694. },
  61695. createSpreadProperty: function (argument) {
  61696. return {
  61697. type: Syntax.SpreadProperty,
  61698. argument: argument
  61699. };
  61700. },
  61701. createTaggedTemplateExpression: function (tag, quasi) {
  61702. return {
  61703. type: Syntax.TaggedTemplateExpression,
  61704. tag: tag,
  61705. quasi: quasi
  61706. };
  61707. },
  61708. createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
  61709. var arrowExpr = {
  61710. type: Syntax.ArrowFunctionExpression,
  61711. id: null,
  61712. params: params,
  61713. defaults: defaults,
  61714. body: body,
  61715. rest: rest,
  61716. generator: false,
  61717. expression: expression
  61718. };
  61719. if (isAsync) {
  61720. arrowExpr.async = true;
  61721. }
  61722. return arrowExpr;
  61723. },
  61724. createMethodDefinition: function (propertyType, kind, key, value, computed) {
  61725. return {
  61726. type: Syntax.MethodDefinition,
  61727. key: key,
  61728. value: value,
  61729. kind: kind,
  61730. 'static': propertyType === ClassPropertyType.static,
  61731. computed: computed
  61732. };
  61733. },
  61734. createClassProperty: function (key, typeAnnotation, computed, isStatic) {
  61735. return {
  61736. type: Syntax.ClassProperty,
  61737. key: key,
  61738. typeAnnotation: typeAnnotation,
  61739. computed: computed,
  61740. static: isStatic
  61741. };
  61742. },
  61743. createClassBody: function (body) {
  61744. return {
  61745. type: Syntax.ClassBody,
  61746. body: body
  61747. };
  61748. },
  61749. createClassImplements: function (id, typeParameters) {
  61750. return {
  61751. type: Syntax.ClassImplements,
  61752. id: id,
  61753. typeParameters: typeParameters
  61754. };
  61755. },
  61756. createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  61757. return {
  61758. type: Syntax.ClassExpression,
  61759. id: id,
  61760. superClass: superClass,
  61761. body: body,
  61762. typeParameters: typeParameters,
  61763. superTypeParameters: superTypeParameters,
  61764. implements: implemented
  61765. };
  61766. },
  61767. createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
  61768. return {
  61769. type: Syntax.ClassDeclaration,
  61770. id: id,
  61771. superClass: superClass,
  61772. body: body,
  61773. typeParameters: typeParameters,
  61774. superTypeParameters: superTypeParameters,
  61775. implements: implemented
  61776. };
  61777. },
  61778. createExportSpecifier: function (id, name) {
  61779. return {
  61780. type: Syntax.ExportSpecifier,
  61781. id: id,
  61782. name: name
  61783. };
  61784. },
  61785. createExportBatchSpecifier: function () {
  61786. return {
  61787. type: Syntax.ExportBatchSpecifier
  61788. };
  61789. },
  61790. createImportDefaultSpecifier: function (id) {
  61791. return {
  61792. type: Syntax.ImportDefaultSpecifier,
  61793. id: id
  61794. };
  61795. },
  61796. createImportNamespaceSpecifier: function (id) {
  61797. return {
  61798. type: Syntax.ImportNamespaceSpecifier,
  61799. id: id
  61800. };
  61801. },
  61802. createExportDeclaration: function (isDefault, declaration, specifiers, src) {
  61803. return {
  61804. type: Syntax.ExportDeclaration,
  61805. 'default': !!isDefault,
  61806. declaration: declaration,
  61807. specifiers: specifiers,
  61808. source: src
  61809. };
  61810. },
  61811. createImportSpecifier: function (id, name) {
  61812. return {
  61813. type: Syntax.ImportSpecifier,
  61814. id: id,
  61815. name: name
  61816. };
  61817. },
  61818. createImportDeclaration: function (specifiers, src, isType) {
  61819. return {
  61820. type: Syntax.ImportDeclaration,
  61821. specifiers: specifiers,
  61822. source: src,
  61823. isType: isType
  61824. };
  61825. },
  61826. createYieldExpression: function (argument, dlg) {
  61827. return {
  61828. type: Syntax.YieldExpression,
  61829. argument: argument,
  61830. delegate: dlg
  61831. };
  61832. },
  61833. createAwaitExpression: function (argument) {
  61834. return {
  61835. type: Syntax.AwaitExpression,
  61836. argument: argument
  61837. };
  61838. },
  61839. createComprehensionExpression: function (filter, blocks, body) {
  61840. return {
  61841. type: Syntax.ComprehensionExpression,
  61842. filter: filter,
  61843. blocks: blocks,
  61844. body: body
  61845. };
  61846. }
  61847. };
  61848. // Return true if there is a line terminator before the next token.
  61849. function peekLineTerminator() {
  61850. var pos, line, start, found;
  61851. pos = index;
  61852. line = lineNumber;
  61853. start = lineStart;
  61854. skipComment();
  61855. found = lineNumber !== line;
  61856. index = pos;
  61857. lineNumber = line;
  61858. lineStart = start;
  61859. return found;
  61860. }
  61861. // Throw an exception
  61862. function throwError(token, messageFormat) {
  61863. var error,
  61864. args = Array.prototype.slice.call(arguments, 2),
  61865. msg = messageFormat.replace(
  61866. /%(\d)/g,
  61867. function (whole, idx) {
  61868. assert(idx < args.length, 'Message reference must be in range');
  61869. return args[idx];
  61870. }
  61871. );
  61872. if (typeof token.lineNumber === 'number') {
  61873. error = new Error('Line ' + token.lineNumber + ': ' + msg);
  61874. error.index = token.range[0];
  61875. error.lineNumber = token.lineNumber;
  61876. error.column = token.range[0] - lineStart + 1;
  61877. } else {
  61878. error = new Error('Line ' + lineNumber + ': ' + msg);
  61879. error.index = index;
  61880. error.lineNumber = lineNumber;
  61881. error.column = index - lineStart + 1;
  61882. }
  61883. error.description = msg;
  61884. throw error;
  61885. }
  61886. function throwErrorTolerant() {
  61887. try {
  61888. throwError.apply(null, arguments);
  61889. } catch (e) {
  61890. if (extra.errors) {
  61891. extra.errors.push(e);
  61892. } else {
  61893. throw e;
  61894. }
  61895. }
  61896. }
  61897. // Throw an exception because of the token.
  61898. function throwUnexpected(token) {
  61899. if (token.type === Token.EOF) {
  61900. throwError(token, Messages.UnexpectedEOS);
  61901. }
  61902. if (token.type === Token.NumericLiteral) {
  61903. throwError(token, Messages.UnexpectedNumber);
  61904. }
  61905. if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
  61906. throwError(token, Messages.UnexpectedString);
  61907. }
  61908. if (token.type === Token.Identifier) {
  61909. throwError(token, Messages.UnexpectedIdentifier);
  61910. }
  61911. if (token.type === Token.Keyword) {
  61912. if (isFutureReservedWord(token.value)) {
  61913. throwError(token, Messages.UnexpectedReserved);
  61914. } else if (strict && isStrictModeReservedWord(token.value)) {
  61915. throwErrorTolerant(token, Messages.StrictReservedWord);
  61916. return;
  61917. }
  61918. throwError(token, Messages.UnexpectedToken, token.value);
  61919. }
  61920. if (token.type === Token.Template) {
  61921. throwError(token, Messages.UnexpectedTemplate, token.value.raw);
  61922. }
  61923. // BooleanLiteral, NullLiteral, or Punctuator.
  61924. throwError(token, Messages.UnexpectedToken, token.value);
  61925. }
  61926. // Expect the next token to match the specified punctuator.
  61927. // If not, an exception will be thrown.
  61928. function expect(value) {
  61929. var token = lex();
  61930. if (token.type !== Token.Punctuator || token.value !== value) {
  61931. throwUnexpected(token);
  61932. }
  61933. }
  61934. // Expect the next token to match the specified keyword.
  61935. // If not, an exception will be thrown.
  61936. function expectKeyword(keyword, contextual) {
  61937. var token = lex();
  61938. if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
  61939. token.value !== keyword) {
  61940. throwUnexpected(token);
  61941. }
  61942. }
  61943. // Expect the next token to match the specified contextual keyword.
  61944. // If not, an exception will be thrown.
  61945. function expectContextualKeyword(keyword) {
  61946. return expectKeyword(keyword, true);
  61947. }
  61948. // Return true if the next token matches the specified punctuator.
  61949. function match(value) {
  61950. return lookahead.type === Token.Punctuator && lookahead.value === value;
  61951. }
  61952. // Return true if the next token matches the specified keyword
  61953. function matchKeyword(keyword, contextual) {
  61954. var expectedType = contextual ? Token.Identifier : Token.Keyword;
  61955. return lookahead.type === expectedType && lookahead.value === keyword;
  61956. }
  61957. // Return true if the next token matches the specified contextual keyword
  61958. function matchContextualKeyword(keyword) {
  61959. return matchKeyword(keyword, true);
  61960. }
  61961. // Return true if the next token is an assignment operator
  61962. function matchAssign() {
  61963. var op;
  61964. if (lookahead.type !== Token.Punctuator) {
  61965. return false;
  61966. }
  61967. op = lookahead.value;
  61968. return op === '=' ||
  61969. op === '*=' ||
  61970. op === '/=' ||
  61971. op === '%=' ||
  61972. op === '+=' ||
  61973. op === '-=' ||
  61974. op === '<<=' ||
  61975. op === '>>=' ||
  61976. op === '>>>=' ||
  61977. op === '&=' ||
  61978. op === '^=' ||
  61979. op === '|=';
  61980. }
  61981. // Note that 'yield' is treated as a keyword in strict mode, but a
  61982. // contextual keyword (identifier) in non-strict mode, so we need to
  61983. // use matchKeyword('yield', false) and matchKeyword('yield', true)
  61984. // (i.e. matchContextualKeyword) appropriately.
  61985. function matchYield() {
  61986. return state.yieldAllowed && matchKeyword('yield', !strict);
  61987. }
  61988. function matchAsync() {
  61989. var backtrackToken = lookahead, matches = false;
  61990. if (matchContextualKeyword('async')) {
  61991. lex(); // Make sure peekLineTerminator() starts after 'async'.
  61992. matches = !peekLineTerminator();
  61993. rewind(backtrackToken); // Revert the lex().
  61994. }
  61995. return matches;
  61996. }
  61997. function matchAwait() {
  61998. return state.awaitAllowed && matchContextualKeyword('await');
  61999. }
  62000. function consumeSemicolon() {
  62001. var line, oldIndex = index, oldLineNumber = lineNumber,
  62002. oldLineStart = lineStart, oldLookahead = lookahead;
  62003. // Catch the very common case first: immediately a semicolon (char #59).
  62004. if (source.charCodeAt(index) === 59) {
  62005. lex();
  62006. return;
  62007. }
  62008. line = lineNumber;
  62009. skipComment();
  62010. if (lineNumber !== line) {
  62011. index = oldIndex;
  62012. lineNumber = oldLineNumber;
  62013. lineStart = oldLineStart;
  62014. lookahead = oldLookahead;
  62015. return;
  62016. }
  62017. if (match(';')) {
  62018. lex();
  62019. return;
  62020. }
  62021. if (lookahead.type !== Token.EOF && !match('}')) {
  62022. throwUnexpected(lookahead);
  62023. }
  62024. }
  62025. // Return true if provided expression is LeftHandSideExpression
  62026. function isLeftHandSide(expr) {
  62027. return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
  62028. }
  62029. function isAssignableLeftHandSide(expr) {
  62030. return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
  62031. }
  62032. // 11.1.4 Array Initialiser
  62033. function parseArrayInitialiser() {
  62034. var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
  62035. marker = markerCreate();
  62036. expect('[');
  62037. while (!match(']')) {
  62038. if (lookahead.value === 'for' &&
  62039. lookahead.type === Token.Keyword) {
  62040. if (!possiblecomprehension) {
  62041. throwError({}, Messages.ComprehensionError);
  62042. }
  62043. matchKeyword('for');
  62044. tmp = parseForStatement({ignoreBody: true});
  62045. tmp.of = tmp.type === Syntax.ForOfStatement;
  62046. tmp.type = Syntax.ComprehensionBlock;
  62047. if (tmp.left.kind) { // can't be let or const
  62048. throwError({}, Messages.ComprehensionError);
  62049. }
  62050. blocks.push(tmp);
  62051. } else if (lookahead.value === 'if' &&
  62052. lookahead.type === Token.Keyword) {
  62053. if (!possiblecomprehension) {
  62054. throwError({}, Messages.ComprehensionError);
  62055. }
  62056. expectKeyword('if');
  62057. expect('(');
  62058. filter = parseExpression();
  62059. expect(')');
  62060. } else if (lookahead.value === ',' &&
  62061. lookahead.type === Token.Punctuator) {
  62062. possiblecomprehension = false; // no longer allowed.
  62063. lex();
  62064. elements.push(null);
  62065. } else {
  62066. tmp = parseSpreadOrAssignmentExpression();
  62067. elements.push(tmp);
  62068. if (tmp && tmp.type === Syntax.SpreadElement) {
  62069. if (!match(']')) {
  62070. throwError({}, Messages.ElementAfterSpreadElement);
  62071. }
  62072. } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
  62073. expect(','); // this lexes.
  62074. possiblecomprehension = false;
  62075. }
  62076. }
  62077. }
  62078. expect(']');
  62079. if (filter && !blocks.length) {
  62080. throwError({}, Messages.ComprehensionRequiresBlock);
  62081. }
  62082. if (blocks.length) {
  62083. if (elements.length !== 1) {
  62084. throwError({}, Messages.ComprehensionError);
  62085. }
  62086. return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
  62087. }
  62088. return markerApply(marker, delegate.createArrayExpression(elements));
  62089. }
  62090. // 11.1.5 Object Initialiser
  62091. function parsePropertyFunction(options) {
  62092. var previousStrict, previousYieldAllowed, previousAwaitAllowed,
  62093. params, defaults, body, marker = markerCreate();
  62094. previousStrict = strict;
  62095. previousYieldAllowed = state.yieldAllowed;
  62096. state.yieldAllowed = options.generator;
  62097. previousAwaitAllowed = state.awaitAllowed;
  62098. state.awaitAllowed = options.async;
  62099. params = options.params || [];
  62100. defaults = options.defaults || [];
  62101. body = parseConciseBody();
  62102. if (options.name && strict && isRestrictedWord(params[0].name)) {
  62103. throwErrorTolerant(options.name, Messages.StrictParamName);
  62104. }
  62105. strict = previousStrict;
  62106. state.yieldAllowed = previousYieldAllowed;
  62107. state.awaitAllowed = previousAwaitAllowed;
  62108. return markerApply(marker, delegate.createFunctionExpression(
  62109. null,
  62110. params,
  62111. defaults,
  62112. body,
  62113. options.rest || null,
  62114. options.generator,
  62115. body.type !== Syntax.BlockStatement,
  62116. options.async,
  62117. options.returnType,
  62118. options.typeParameters
  62119. ));
  62120. }
  62121. function parsePropertyMethodFunction(options) {
  62122. var previousStrict, tmp, method;
  62123. previousStrict = strict;
  62124. strict = true;
  62125. tmp = parseParams();
  62126. if (tmp.stricted) {
  62127. throwErrorTolerant(tmp.stricted, tmp.message);
  62128. }
  62129. method = parsePropertyFunction({
  62130. params: tmp.params,
  62131. defaults: tmp.defaults,
  62132. rest: tmp.rest,
  62133. generator: options.generator,
  62134. async: options.async,
  62135. returnType: tmp.returnType,
  62136. typeParameters: options.typeParameters
  62137. });
  62138. strict = previousStrict;
  62139. return method;
  62140. }
  62141. function parseObjectPropertyKey() {
  62142. var marker = markerCreate(),
  62143. token = lex(),
  62144. propertyKey,
  62145. result;
  62146. // Note: This function is called only from parseObjectProperty(), where
  62147. // EOF and Punctuator tokens are already filtered out.
  62148. if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
  62149. if (strict && token.octal) {
  62150. throwErrorTolerant(token, Messages.StrictOctalLiteral);
  62151. }
  62152. return markerApply(marker, delegate.createLiteral(token));
  62153. }
  62154. if (token.type === Token.Punctuator && token.value === '[') {
  62155. // For computed properties we should skip the [ and ], and
  62156. // capture in marker only the assignment expression itself.
  62157. marker = markerCreate();
  62158. propertyKey = parseAssignmentExpression();
  62159. result = markerApply(marker, propertyKey);
  62160. expect(']');
  62161. return result;
  62162. }
  62163. return markerApply(marker, delegate.createIdentifier(token.value));
  62164. }
  62165. function parseObjectProperty() {
  62166. var token, key, id, param, computed,
  62167. marker = markerCreate(), returnType, typeParameters;
  62168. token = lookahead;
  62169. computed = (token.value === '[' && token.type === Token.Punctuator);
  62170. if (token.type === Token.Identifier || computed || matchAsync()) {
  62171. id = parseObjectPropertyKey();
  62172. if (match(':')) {
  62173. lex();
  62174. return markerApply(
  62175. marker,
  62176. delegate.createProperty(
  62177. 'init',
  62178. id,
  62179. parseAssignmentExpression(),
  62180. false,
  62181. false,
  62182. computed
  62183. )
  62184. );
  62185. }
  62186. if (match('(') || match('<')) {
  62187. if (match('<')) {
  62188. typeParameters = parseTypeParameterDeclaration();
  62189. }
  62190. return markerApply(
  62191. marker,
  62192. delegate.createProperty(
  62193. 'init',
  62194. id,
  62195. parsePropertyMethodFunction({
  62196. generator: false,
  62197. async: false,
  62198. typeParameters: typeParameters
  62199. }),
  62200. true,
  62201. false,
  62202. computed
  62203. )
  62204. );
  62205. }
  62206. // Property Assignment: Getter and Setter.
  62207. if (token.value === 'get') {
  62208. computed = (lookahead.value === '[');
  62209. key = parseObjectPropertyKey();
  62210. expect('(');
  62211. expect(')');
  62212. if (match(':')) {
  62213. returnType = parseTypeAnnotation();
  62214. }
  62215. return markerApply(
  62216. marker,
  62217. delegate.createProperty(
  62218. 'get',
  62219. key,
  62220. parsePropertyFunction({
  62221. generator: false,
  62222. async: false,
  62223. returnType: returnType
  62224. }),
  62225. false,
  62226. false,
  62227. computed
  62228. )
  62229. );
  62230. }
  62231. if (token.value === 'set') {
  62232. computed = (lookahead.value === '[');
  62233. key = parseObjectPropertyKey();
  62234. expect('(');
  62235. token = lookahead;
  62236. param = [ parseTypeAnnotatableIdentifier() ];
  62237. expect(')');
  62238. if (match(':')) {
  62239. returnType = parseTypeAnnotation();
  62240. }
  62241. return markerApply(
  62242. marker,
  62243. delegate.createProperty(
  62244. 'set',
  62245. key,
  62246. parsePropertyFunction({
  62247. params: param,
  62248. generator: false,
  62249. async: false,
  62250. name: token,
  62251. returnType: returnType
  62252. }),
  62253. false,
  62254. false,
  62255. computed
  62256. )
  62257. );
  62258. }
  62259. if (token.value === 'async') {
  62260. computed = (lookahead.value === '[');
  62261. key = parseObjectPropertyKey();
  62262. if (match('<')) {
  62263. typeParameters = parseTypeParameterDeclaration();
  62264. }
  62265. return markerApply(
  62266. marker,
  62267. delegate.createProperty(
  62268. 'init',
  62269. key,
  62270. parsePropertyMethodFunction({
  62271. generator: false,
  62272. async: true,
  62273. typeParameters: typeParameters
  62274. }),
  62275. true,
  62276. false,
  62277. computed
  62278. )
  62279. );
  62280. }
  62281. if (computed) {
  62282. // Computed properties can only be used with full notation.
  62283. throwUnexpected(lookahead);
  62284. }
  62285. return markerApply(
  62286. marker,
  62287. delegate.createProperty('init', id, id, false, true, false)
  62288. );
  62289. }
  62290. if (token.type === Token.EOF || token.type === Token.Punctuator) {
  62291. if (!match('*')) {
  62292. throwUnexpected(token);
  62293. }
  62294. lex();
  62295. computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
  62296. id = parseObjectPropertyKey();
  62297. if (match('<')) {
  62298. typeParameters = parseTypeParameterDeclaration();
  62299. }
  62300. if (!match('(')) {
  62301. throwUnexpected(lex());
  62302. }
  62303. return markerApply(marker, delegate.createProperty(
  62304. 'init',
  62305. id,
  62306. parsePropertyMethodFunction({
  62307. generator: true,
  62308. typeParameters: typeParameters
  62309. }),
  62310. true,
  62311. false,
  62312. computed
  62313. ));
  62314. }
  62315. key = parseObjectPropertyKey();
  62316. if (match(':')) {
  62317. lex();
  62318. return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
  62319. }
  62320. if (match('(') || match('<')) {
  62321. if (match('<')) {
  62322. typeParameters = parseTypeParameterDeclaration();
  62323. }
  62324. return markerApply(marker, delegate.createProperty(
  62325. 'init',
  62326. key,
  62327. parsePropertyMethodFunction({
  62328. generator: false,
  62329. typeParameters: typeParameters
  62330. }),
  62331. true,
  62332. false,
  62333. false
  62334. ));
  62335. }
  62336. throwUnexpected(lex());
  62337. }
  62338. function parseObjectSpreadProperty() {
  62339. var marker = markerCreate();
  62340. expect('...');
  62341. return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
  62342. }
  62343. function getFieldName(key) {
  62344. var toString = String;
  62345. if (key.type === Syntax.Identifier) {
  62346. return key.name;
  62347. }
  62348. return toString(key.value);
  62349. }
  62350. function parseObjectInitialiser() {
  62351. var properties = [], property, name, kind, storedKind, map = new StringMap(),
  62352. marker = markerCreate(), toString = String;
  62353. expect('{');
  62354. while (!match('}')) {
  62355. if (match('...')) {
  62356. property = parseObjectSpreadProperty();
  62357. } else {
  62358. property = parseObjectProperty();
  62359. if (property.key.type === Syntax.Identifier) {
  62360. name = property.key.name;
  62361. } else {
  62362. name = toString(property.key.value);
  62363. }
  62364. kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
  62365. if (map.has(name)) {
  62366. storedKind = map.get(name);
  62367. if (storedKind === PropertyKind.Data) {
  62368. if (strict && kind === PropertyKind.Data) {
  62369. throwErrorTolerant({}, Messages.StrictDuplicateProperty);
  62370. } else if (kind !== PropertyKind.Data) {
  62371. throwErrorTolerant({}, Messages.AccessorDataProperty);
  62372. }
  62373. } else {
  62374. if (kind === PropertyKind.Data) {
  62375. throwErrorTolerant({}, Messages.AccessorDataProperty);
  62376. } else if (storedKind & kind) {
  62377. throwErrorTolerant({}, Messages.AccessorGetSet);
  62378. }
  62379. }
  62380. map.set(name, storedKind | kind);
  62381. } else {
  62382. map.set(name, kind);
  62383. }
  62384. }
  62385. properties.push(property);
  62386. if (!match('}')) {
  62387. expect(',');
  62388. }
  62389. }
  62390. expect('}');
  62391. return markerApply(marker, delegate.createObjectExpression(properties));
  62392. }
  62393. function parseTemplateElement(option) {
  62394. var marker, token;
  62395. if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) {
  62396. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  62397. }
  62398. marker = markerCreate();
  62399. token = lex();
  62400. if (strict && token.octal) {
  62401. throwError(token, Messages.StrictOctalLiteral);
  62402. }
  62403. return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
  62404. }
  62405. function parseTemplateLiteral() {
  62406. var quasi, quasis, expressions, marker = markerCreate();
  62407. quasi = parseTemplateElement({ head: true });
  62408. quasis = [ quasi ];
  62409. expressions = [];
  62410. while (!quasi.tail) {
  62411. expressions.push(parseExpression());
  62412. quasi = parseTemplateElement({ head: false });
  62413. quasis.push(quasi);
  62414. }
  62415. return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
  62416. }
  62417. // 11.1.6 The Grouping Operator
  62418. function parseGroupExpression() {
  62419. var expr, marker, typeAnnotation;
  62420. expect('(');
  62421. ++state.parenthesizedCount;
  62422. marker = markerCreate();
  62423. expr = parseExpression();
  62424. if (match(':')) {
  62425. typeAnnotation = parseTypeAnnotation();
  62426. expr = markerApply(marker, delegate.createTypeCast(
  62427. expr,
  62428. typeAnnotation
  62429. ));
  62430. }
  62431. expect(')');
  62432. return expr;
  62433. }
  62434. function matchAsyncFuncExprOrDecl() {
  62435. var token;
  62436. if (matchAsync()) {
  62437. token = lookahead2();
  62438. if (token.type === Token.Keyword && token.value === 'function') {
  62439. return true;
  62440. }
  62441. }
  62442. return false;
  62443. }
  62444. // 11.1 Primary Expressions
  62445. function parsePrimaryExpression() {
  62446. var marker, type, token, expr;
  62447. type = lookahead.type;
  62448. if (type === Token.Identifier) {
  62449. marker = markerCreate();
  62450. return markerApply(marker, delegate.createIdentifier(lex().value));
  62451. }
  62452. if (type === Token.StringLiteral || type === Token.NumericLiteral) {
  62453. if (strict && lookahead.octal) {
  62454. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  62455. }
  62456. marker = markerCreate();
  62457. return markerApply(marker, delegate.createLiteral(lex()));
  62458. }
  62459. if (type === Token.Keyword) {
  62460. if (matchKeyword('this')) {
  62461. marker = markerCreate();
  62462. lex();
  62463. return markerApply(marker, delegate.createThisExpression());
  62464. }
  62465. if (matchKeyword('function')) {
  62466. return parseFunctionExpression();
  62467. }
  62468. if (matchKeyword('class')) {
  62469. return parseClassExpression();
  62470. }
  62471. if (matchKeyword('super')) {
  62472. marker = markerCreate();
  62473. lex();
  62474. return markerApply(marker, delegate.createIdentifier('super'));
  62475. }
  62476. }
  62477. if (type === Token.BooleanLiteral) {
  62478. marker = markerCreate();
  62479. token = lex();
  62480. token.value = (token.value === 'true');
  62481. return markerApply(marker, delegate.createLiteral(token));
  62482. }
  62483. if (type === Token.NullLiteral) {
  62484. marker = markerCreate();
  62485. token = lex();
  62486. token.value = null;
  62487. return markerApply(marker, delegate.createLiteral(token));
  62488. }
  62489. if (match('[')) {
  62490. return parseArrayInitialiser();
  62491. }
  62492. if (match('{')) {
  62493. return parseObjectInitialiser();
  62494. }
  62495. if (match('(')) {
  62496. return parseGroupExpression();
  62497. }
  62498. if (match('/') || match('/=')) {
  62499. marker = markerCreate();
  62500. expr = delegate.createLiteral(scanRegExp());
  62501. peek();
  62502. return markerApply(marker, expr);
  62503. }
  62504. if (type === Token.Template) {
  62505. return parseTemplateLiteral();
  62506. }
  62507. if (match('<')) {
  62508. return parseJSXElement();
  62509. }
  62510. throwUnexpected(lex());
  62511. }
  62512. // 11.2 Left-Hand-Side Expressions
  62513. function parseArguments() {
  62514. var args = [], arg;
  62515. expect('(');
  62516. if (!match(')')) {
  62517. while (index < length) {
  62518. arg = parseSpreadOrAssignmentExpression();
  62519. args.push(arg);
  62520. if (arg.type === Syntax.SpreadElement) {
  62521. if (match(')')) {
  62522. break;
  62523. } else {
  62524. throwError({}, Messages.ElementAfterSpreadElement);
  62525. }
  62526. }
  62527. if (match(')')) {
  62528. break;
  62529. } else {
  62530. expect(',');
  62531. if (match(')')) {
  62532. break;
  62533. }
  62534. }
  62535. }
  62536. }
  62537. expect(')');
  62538. return args;
  62539. }
  62540. function parseSpreadOrAssignmentExpression() {
  62541. if (match('...')) {
  62542. var marker = markerCreate();
  62543. lex();
  62544. return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
  62545. }
  62546. return parseAssignmentExpression();
  62547. }
  62548. function parseNonComputedProperty() {
  62549. var marker = markerCreate(),
  62550. token = lex();
  62551. if (!isIdentifierName(token)) {
  62552. throwUnexpected(token);
  62553. }
  62554. return markerApply(marker, delegate.createIdentifier(token.value));
  62555. }
  62556. function parseNonComputedMember() {
  62557. expect('.');
  62558. return parseNonComputedProperty();
  62559. }
  62560. function parseComputedMember() {
  62561. var expr;
  62562. expect('[');
  62563. expr = parseExpression();
  62564. expect(']');
  62565. return expr;
  62566. }
  62567. function parseNewExpression() {
  62568. var callee, args, marker = markerCreate();
  62569. expectKeyword('new');
  62570. callee = parseLeftHandSideExpression();
  62571. args = match('(') ? parseArguments() : [];
  62572. return markerApply(marker, delegate.createNewExpression(callee, args));
  62573. }
  62574. function parseLeftHandSideExpressionAllowCall() {
  62575. var expr, args, marker = markerCreate();
  62576. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  62577. while (match('.') || match('[') || match('(') || (lookahead.type === Token.Template && lookahead.head)) {
  62578. if (match('(')) {
  62579. args = parseArguments();
  62580. expr = markerApply(marker, delegate.createCallExpression(expr, args));
  62581. } else if (match('[')) {
  62582. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  62583. } else if (match('.')) {
  62584. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  62585. } else {
  62586. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  62587. }
  62588. }
  62589. return expr;
  62590. }
  62591. function parseLeftHandSideExpression() {
  62592. var expr, marker = markerCreate();
  62593. expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
  62594. while (match('.') || match('[') || (lookahead.type === Token.Template && lookahead.head)) {
  62595. if (match('[')) {
  62596. expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
  62597. } else if (match('.')) {
  62598. expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
  62599. } else {
  62600. expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
  62601. }
  62602. }
  62603. return expr;
  62604. }
  62605. // 11.3 Postfix Expressions
  62606. function parsePostfixExpression() {
  62607. var marker = markerCreate(),
  62608. expr = parseLeftHandSideExpressionAllowCall(),
  62609. token;
  62610. if (lookahead.type !== Token.Punctuator) {
  62611. return expr;
  62612. }
  62613. if ((match('++') || match('--')) && !peekLineTerminator()) {
  62614. // 11.3.1, 11.3.2
  62615. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  62616. throwErrorTolerant({}, Messages.StrictLHSPostfix);
  62617. }
  62618. if (!isLeftHandSide(expr)) {
  62619. throwError({}, Messages.InvalidLHSInAssignment);
  62620. }
  62621. token = lex();
  62622. expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
  62623. }
  62624. return expr;
  62625. }
  62626. // 11.4 Unary Operators
  62627. function parseUnaryExpression() {
  62628. var marker, token, expr;
  62629. if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
  62630. return parsePostfixExpression();
  62631. }
  62632. if (match('++') || match('--')) {
  62633. marker = markerCreate();
  62634. token = lex();
  62635. expr = parseUnaryExpression();
  62636. // 11.4.4, 11.4.5
  62637. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  62638. throwErrorTolerant({}, Messages.StrictLHSPrefix);
  62639. }
  62640. if (!isLeftHandSide(expr)) {
  62641. throwError({}, Messages.InvalidLHSInAssignment);
  62642. }
  62643. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  62644. }
  62645. if (match('+') || match('-') || match('~') || match('!')) {
  62646. marker = markerCreate();
  62647. token = lex();
  62648. expr = parseUnaryExpression();
  62649. return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  62650. }
  62651. if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
  62652. marker = markerCreate();
  62653. token = lex();
  62654. expr = parseUnaryExpression();
  62655. expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
  62656. if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
  62657. throwErrorTolerant({}, Messages.StrictDelete);
  62658. }
  62659. return expr;
  62660. }
  62661. return parsePostfixExpression();
  62662. }
  62663. function binaryPrecedence(token, allowIn) {
  62664. var prec = 0;
  62665. if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
  62666. return 0;
  62667. }
  62668. switch (token.value) {
  62669. case '||':
  62670. prec = 1;
  62671. break;
  62672. case '&&':
  62673. prec = 2;
  62674. break;
  62675. case '|':
  62676. prec = 3;
  62677. break;
  62678. case '^':
  62679. prec = 4;
  62680. break;
  62681. case '&':
  62682. prec = 5;
  62683. break;
  62684. case '==':
  62685. case '!=':
  62686. case '===':
  62687. case '!==':
  62688. prec = 6;
  62689. break;
  62690. case '<':
  62691. case '>':
  62692. case '<=':
  62693. case '>=':
  62694. case 'instanceof':
  62695. prec = 7;
  62696. break;
  62697. case 'in':
  62698. prec = allowIn ? 7 : 0;
  62699. break;
  62700. case '<<':
  62701. case '>>':
  62702. case '>>>':
  62703. prec = 8;
  62704. break;
  62705. case '+':
  62706. case '-':
  62707. prec = 9;
  62708. break;
  62709. case '*':
  62710. case '/':
  62711. case '%':
  62712. prec = 11;
  62713. break;
  62714. default:
  62715. break;
  62716. }
  62717. return prec;
  62718. }
  62719. // 11.5 Multiplicative Operators
  62720. // 11.6 Additive Operators
  62721. // 11.7 Bitwise Shift Operators
  62722. // 11.8 Relational Operators
  62723. // 11.9 Equality Operators
  62724. // 11.10 Binary Bitwise Operators
  62725. // 11.11 Binary Logical Operators
  62726. function parseBinaryExpression() {
  62727. var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
  62728. marker, markers;
  62729. previousAllowIn = state.allowIn;
  62730. state.allowIn = true;
  62731. marker = markerCreate();
  62732. left = parseUnaryExpression();
  62733. token = lookahead;
  62734. prec = binaryPrecedence(token, previousAllowIn);
  62735. if (prec === 0) {
  62736. return left;
  62737. }
  62738. token.prec = prec;
  62739. lex();
  62740. markers = [marker, markerCreate()];
  62741. right = parseUnaryExpression();
  62742. stack = [left, token, right];
  62743. while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
  62744. // Reduce: make a binary expression from the three topmost entries.
  62745. while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
  62746. right = stack.pop();
  62747. operator = stack.pop().value;
  62748. left = stack.pop();
  62749. expr = delegate.createBinaryExpression(operator, left, right);
  62750. markers.pop();
  62751. marker = markers.pop();
  62752. markerApply(marker, expr);
  62753. stack.push(expr);
  62754. markers.push(marker);
  62755. }
  62756. // Shift.
  62757. token = lex();
  62758. token.prec = prec;
  62759. stack.push(token);
  62760. markers.push(markerCreate());
  62761. expr = parseUnaryExpression();
  62762. stack.push(expr);
  62763. }
  62764. state.allowIn = previousAllowIn;
  62765. // Final reduce to clean-up the stack.
  62766. i = stack.length - 1;
  62767. expr = stack[i];
  62768. markers.pop();
  62769. while (i > 1) {
  62770. expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
  62771. i -= 2;
  62772. marker = markers.pop();
  62773. markerApply(marker, expr);
  62774. }
  62775. return expr;
  62776. }
  62777. // 11.12 Conditional Operator
  62778. function parseConditionalExpression() {
  62779. var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
  62780. expr = parseBinaryExpression();
  62781. if (match('?')) {
  62782. lex();
  62783. previousAllowIn = state.allowIn;
  62784. state.allowIn = true;
  62785. consequent = parseAssignmentExpression();
  62786. state.allowIn = previousAllowIn;
  62787. expect(':');
  62788. alternate = parseAssignmentExpression();
  62789. expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
  62790. }
  62791. return expr;
  62792. }
  62793. // 11.13 Assignment Operators
  62794. // 12.14.5 AssignmentPattern
  62795. function reinterpretAsAssignmentBindingPattern(expr) {
  62796. var i, len, property, element;
  62797. if (expr.type === Syntax.ObjectExpression) {
  62798. expr.type = Syntax.ObjectPattern;
  62799. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  62800. property = expr.properties[i];
  62801. if (property.type === Syntax.SpreadProperty) {
  62802. if (i < len - 1) {
  62803. throwError({}, Messages.PropertyAfterSpreadProperty);
  62804. }
  62805. reinterpretAsAssignmentBindingPattern(property.argument);
  62806. } else {
  62807. if (property.kind !== 'init') {
  62808. throwError({}, Messages.InvalidLHSInAssignment);
  62809. }
  62810. reinterpretAsAssignmentBindingPattern(property.value);
  62811. }
  62812. }
  62813. } else if (expr.type === Syntax.ArrayExpression) {
  62814. expr.type = Syntax.ArrayPattern;
  62815. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  62816. element = expr.elements[i];
  62817. /* istanbul ignore else */
  62818. if (element) {
  62819. reinterpretAsAssignmentBindingPattern(element);
  62820. }
  62821. }
  62822. } else if (expr.type === Syntax.Identifier) {
  62823. if (isRestrictedWord(expr.name)) {
  62824. throwError({}, Messages.InvalidLHSInAssignment);
  62825. }
  62826. } else if (expr.type === Syntax.SpreadElement) {
  62827. reinterpretAsAssignmentBindingPattern(expr.argument);
  62828. if (expr.argument.type === Syntax.ObjectPattern) {
  62829. throwError({}, Messages.ObjectPatternAsSpread);
  62830. }
  62831. } else {
  62832. /* istanbul ignore else */
  62833. if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
  62834. throwError({}, Messages.InvalidLHSInAssignment);
  62835. }
  62836. }
  62837. }
  62838. // 13.2.3 BindingPattern
  62839. function reinterpretAsDestructuredParameter(options, expr) {
  62840. var i, len, property, element;
  62841. if (expr.type === Syntax.ObjectExpression) {
  62842. expr.type = Syntax.ObjectPattern;
  62843. for (i = 0, len = expr.properties.length; i < len; i += 1) {
  62844. property = expr.properties[i];
  62845. if (property.type === Syntax.SpreadProperty) {
  62846. if (i < len - 1) {
  62847. throwError({}, Messages.PropertyAfterSpreadProperty);
  62848. }
  62849. reinterpretAsDestructuredParameter(options, property.argument);
  62850. } else {
  62851. if (property.kind !== 'init') {
  62852. throwError({}, Messages.InvalidLHSInFormalsList);
  62853. }
  62854. reinterpretAsDestructuredParameter(options, property.value);
  62855. }
  62856. }
  62857. } else if (expr.type === Syntax.ArrayExpression) {
  62858. expr.type = Syntax.ArrayPattern;
  62859. for (i = 0, len = expr.elements.length; i < len; i += 1) {
  62860. element = expr.elements[i];
  62861. if (element) {
  62862. reinterpretAsDestructuredParameter(options, element);
  62863. }
  62864. }
  62865. } else if (expr.type === Syntax.Identifier) {
  62866. validateParam(options, expr, expr.name);
  62867. } else if (expr.type === Syntax.SpreadElement) {
  62868. // BindingRestElement only allows BindingIdentifier
  62869. if (expr.argument.type !== Syntax.Identifier) {
  62870. throwError({}, Messages.InvalidLHSInFormalsList);
  62871. }
  62872. validateParam(options, expr.argument, expr.argument.name);
  62873. } else {
  62874. throwError({}, Messages.InvalidLHSInFormalsList);
  62875. }
  62876. }
  62877. function reinterpretAsCoverFormalsList(expressions) {
  62878. var i, len, param, params, defaults, defaultCount, options, rest;
  62879. params = [];
  62880. defaults = [];
  62881. defaultCount = 0;
  62882. rest = null;
  62883. options = {
  62884. paramSet: new StringMap()
  62885. };
  62886. for (i = 0, len = expressions.length; i < len; i += 1) {
  62887. param = expressions[i];
  62888. if (param.type === Syntax.Identifier) {
  62889. params.push(param);
  62890. defaults.push(null);
  62891. validateParam(options, param, param.name);
  62892. } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
  62893. reinterpretAsDestructuredParameter(options, param);
  62894. params.push(param);
  62895. defaults.push(null);
  62896. } else if (param.type === Syntax.SpreadElement) {
  62897. assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
  62898. if (param.argument.type !== Syntax.Identifier) {
  62899. throwError({}, Messages.InvalidLHSInFormalsList);
  62900. }
  62901. reinterpretAsDestructuredParameter(options, param.argument);
  62902. rest = param.argument;
  62903. } else if (param.type === Syntax.AssignmentExpression) {
  62904. params.push(param.left);
  62905. defaults.push(param.right);
  62906. ++defaultCount;
  62907. validateParam(options, param.left, param.left.name);
  62908. } else {
  62909. return null;
  62910. }
  62911. }
  62912. if (options.message === Messages.StrictParamDupe) {
  62913. throwError(
  62914. strict ? options.stricted : options.firstRestricted,
  62915. options.message
  62916. );
  62917. }
  62918. if (defaultCount === 0) {
  62919. defaults = [];
  62920. }
  62921. return {
  62922. params: params,
  62923. defaults: defaults,
  62924. rest: rest,
  62925. stricted: options.stricted,
  62926. firstRestricted: options.firstRestricted,
  62927. message: options.message
  62928. };
  62929. }
  62930. function parseArrowFunctionExpression(options, marker) {
  62931. var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
  62932. expect('=>');
  62933. previousStrict = strict;
  62934. previousYieldAllowed = state.yieldAllowed;
  62935. state.yieldAllowed = false;
  62936. previousAwaitAllowed = state.awaitAllowed;
  62937. state.awaitAllowed = !!options.async;
  62938. body = parseConciseBody();
  62939. if (strict && options.firstRestricted) {
  62940. throwError(options.firstRestricted, options.message);
  62941. }
  62942. if (strict && options.stricted) {
  62943. throwErrorTolerant(options.stricted, options.message);
  62944. }
  62945. strict = previousStrict;
  62946. state.yieldAllowed = previousYieldAllowed;
  62947. state.awaitAllowed = previousAwaitAllowed;
  62948. return markerApply(marker, delegate.createArrowFunctionExpression(
  62949. options.params,
  62950. options.defaults,
  62951. body,
  62952. options.rest,
  62953. body.type !== Syntax.BlockStatement,
  62954. !!options.async
  62955. ));
  62956. }
  62957. function parseAssignmentExpression() {
  62958. var marker, expr, token, params, oldParenthesizedCount,
  62959. startsWithParen = false, backtrackToken = lookahead,
  62960. possiblyAsync = false;
  62961. if (matchYield()) {
  62962. return parseYieldExpression();
  62963. }
  62964. if (matchAwait()) {
  62965. return parseAwaitExpression();
  62966. }
  62967. oldParenthesizedCount = state.parenthesizedCount;
  62968. marker = markerCreate();
  62969. if (matchAsyncFuncExprOrDecl()) {
  62970. return parseFunctionExpression();
  62971. }
  62972. if (matchAsync()) {
  62973. // We can't be completely sure that this 'async' token is
  62974. // actually a contextual keyword modifying a function
  62975. // expression, so we might have to un-lex() it later by
  62976. // calling rewind(backtrackToken).
  62977. possiblyAsync = true;
  62978. lex();
  62979. }
  62980. if (match('(')) {
  62981. token = lookahead2();
  62982. if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
  62983. params = parseParams();
  62984. if (!match('=>')) {
  62985. throwUnexpected(lex());
  62986. }
  62987. params.async = possiblyAsync;
  62988. return parseArrowFunctionExpression(params, marker);
  62989. }
  62990. startsWithParen = true;
  62991. }
  62992. token = lookahead;
  62993. // If the 'async' keyword is not followed by a '(' character or an
  62994. // identifier, then it can't be an arrow function modifier, and we
  62995. // should interpret it as a normal identifer.
  62996. if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
  62997. possiblyAsync = false;
  62998. rewind(backtrackToken);
  62999. }
  63000. expr = parseConditionalExpression();
  63001. if (match('=>') &&
  63002. (state.parenthesizedCount === oldParenthesizedCount ||
  63003. state.parenthesizedCount === (oldParenthesizedCount + 1))) {
  63004. if (expr.type === Syntax.Identifier) {
  63005. params = reinterpretAsCoverFormalsList([ expr ]);
  63006. } else if (expr.type === Syntax.AssignmentExpression ||
  63007. expr.type === Syntax.ArrayExpression ||
  63008. expr.type === Syntax.ObjectExpression) {
  63009. if (!startsWithParen) {
  63010. throwUnexpected(lex());
  63011. }
  63012. params = reinterpretAsCoverFormalsList([ expr ]);
  63013. } else if (expr.type === Syntax.SequenceExpression) {
  63014. params = reinterpretAsCoverFormalsList(expr.expressions);
  63015. }
  63016. if (params) {
  63017. params.async = possiblyAsync;
  63018. return parseArrowFunctionExpression(params, marker);
  63019. }
  63020. }
  63021. // If we haven't returned by now, then the 'async' keyword was not
  63022. // a function modifier, and we should rewind and interpret it as a
  63023. // normal identifier.
  63024. if (possiblyAsync) {
  63025. possiblyAsync = false;
  63026. rewind(backtrackToken);
  63027. expr = parseConditionalExpression();
  63028. }
  63029. if (matchAssign()) {
  63030. // 11.13.1
  63031. if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
  63032. throwErrorTolerant(token, Messages.StrictLHSAssignment);
  63033. }
  63034. // ES.next draf 11.13 Runtime Semantics step 1
  63035. if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
  63036. reinterpretAsAssignmentBindingPattern(expr);
  63037. } else if (!isLeftHandSide(expr)) {
  63038. throwError({}, Messages.InvalidLHSInAssignment);
  63039. }
  63040. expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
  63041. }
  63042. return expr;
  63043. }
  63044. // 11.14 Comma Operator
  63045. function parseExpression() {
  63046. var marker, expr, expressions, sequence, spreadFound, possibleArrow;
  63047. marker = markerCreate();
  63048. expr = parseAssignmentExpression();
  63049. expressions = [ expr ];
  63050. if (match(',')) {
  63051. while (index < length) {
  63052. if (!match(',')) {
  63053. break;
  63054. }
  63055. lex();
  63056. if (match(')')) {
  63057. possibleArrow = lookahead2();
  63058. if (
  63059. possibleArrow.type === Token.Punctuator &&
  63060. possibleArrow.value === '=>'
  63061. ) {
  63062. break;
  63063. }
  63064. }
  63065. expr = parseSpreadOrAssignmentExpression();
  63066. expressions.push(expr);
  63067. if (expr.type === Syntax.SpreadElement) {
  63068. spreadFound = true;
  63069. if (!match(')')) {
  63070. throwError({}, Messages.ElementAfterSpreadElement);
  63071. }
  63072. break;
  63073. }
  63074. }
  63075. if (expressions.length > 1) {
  63076. sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
  63077. }
  63078. }
  63079. if (spreadFound && lookahead2().value !== '=>') {
  63080. throwError({}, Messages.IllegalSpread);
  63081. }
  63082. return sequence || expr;
  63083. }
  63084. // 12.1 Block
  63085. function parseStatementList() {
  63086. var list = [],
  63087. statement;
  63088. while (index < length) {
  63089. if (match('}')) {
  63090. break;
  63091. }
  63092. statement = parseSourceElement();
  63093. if (typeof statement === 'undefined') {
  63094. break;
  63095. }
  63096. list.push(statement);
  63097. }
  63098. return list;
  63099. }
  63100. function parseBlock() {
  63101. var block, marker = markerCreate();
  63102. expect('{');
  63103. block = parseStatementList();
  63104. expect('}');
  63105. return markerApply(marker, delegate.createBlockStatement(block));
  63106. }
  63107. // 12.2 Variable Statement
  63108. function parseTypeParameterDeclaration() {
  63109. var marker = markerCreate(), paramTypes = [];
  63110. expect('<');
  63111. while (!match('>')) {
  63112. paramTypes.push(parseTypeAnnotatableIdentifier());
  63113. if (!match('>')) {
  63114. expect(',');
  63115. }
  63116. }
  63117. expect('>');
  63118. return markerApply(marker, delegate.createTypeParameterDeclaration(
  63119. paramTypes
  63120. ));
  63121. }
  63122. function parseTypeParameterInstantiation() {
  63123. var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
  63124. state.inType = true;
  63125. expect('<');
  63126. while (!match('>')) {
  63127. paramTypes.push(parseType());
  63128. if (!match('>')) {
  63129. expect(',');
  63130. }
  63131. }
  63132. expect('>');
  63133. state.inType = oldInType;
  63134. return markerApply(marker, delegate.createTypeParameterInstantiation(
  63135. paramTypes
  63136. ));
  63137. }
  63138. function parseObjectTypeIndexer(marker, isStatic) {
  63139. var id, key, value;
  63140. expect('[');
  63141. id = parseObjectPropertyKey();
  63142. expect(':');
  63143. key = parseType();
  63144. expect(']');
  63145. expect(':');
  63146. value = parseType();
  63147. return markerApply(marker, delegate.createObjectTypeIndexer(
  63148. id,
  63149. key,
  63150. value,
  63151. isStatic
  63152. ));
  63153. }
  63154. function parseObjectTypeMethodish(marker) {
  63155. var params = [], rest = null, returnType, typeParameters = null;
  63156. if (match('<')) {
  63157. typeParameters = parseTypeParameterDeclaration();
  63158. }
  63159. expect('(');
  63160. while (lookahead.type === Token.Identifier) {
  63161. params.push(parseFunctionTypeParam());
  63162. if (!match(')')) {
  63163. expect(',');
  63164. }
  63165. }
  63166. if (match('...')) {
  63167. lex();
  63168. rest = parseFunctionTypeParam();
  63169. }
  63170. expect(')');
  63171. expect(':');
  63172. returnType = parseType();
  63173. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  63174. params,
  63175. returnType,
  63176. rest,
  63177. typeParameters
  63178. ));
  63179. }
  63180. function parseObjectTypeMethod(marker, isStatic, key) {
  63181. var optional = false, value;
  63182. value = parseObjectTypeMethodish(marker);
  63183. return markerApply(marker, delegate.createObjectTypeProperty(
  63184. key,
  63185. value,
  63186. optional,
  63187. isStatic
  63188. ));
  63189. }
  63190. function parseObjectTypeCallProperty(marker, isStatic) {
  63191. var valueMarker = markerCreate();
  63192. return markerApply(marker, delegate.createObjectTypeCallProperty(
  63193. parseObjectTypeMethodish(valueMarker),
  63194. isStatic
  63195. ));
  63196. }
  63197. function parseObjectType(allowStatic) {
  63198. var callProperties = [], indexers = [], marker, optional = false,
  63199. properties = [], propertyKey, propertyTypeAnnotation,
  63200. token, isStatic, matchStatic;
  63201. expect('{');
  63202. while (!match('}')) {
  63203. marker = markerCreate();
  63204. matchStatic =
  63205. strict
  63206. ? matchKeyword('static')
  63207. : matchContextualKeyword('static');
  63208. if (allowStatic && matchStatic) {
  63209. token = lex();
  63210. isStatic = true;
  63211. }
  63212. if (match('[')) {
  63213. indexers.push(parseObjectTypeIndexer(marker, isStatic));
  63214. } else if (match('(') || match('<')) {
  63215. callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
  63216. } else {
  63217. if (isStatic && match(':')) {
  63218. propertyKey = markerApply(marker, delegate.createIdentifier(token));
  63219. throwErrorTolerant(token, Messages.StrictReservedWord);
  63220. } else {
  63221. propertyKey = parseObjectPropertyKey();
  63222. }
  63223. if (match('<') || match('(')) {
  63224. // This is a method property
  63225. properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
  63226. } else {
  63227. if (match('?')) {
  63228. lex();
  63229. optional = true;
  63230. }
  63231. expect(':');
  63232. propertyTypeAnnotation = parseType();
  63233. properties.push(markerApply(marker, delegate.createObjectTypeProperty(
  63234. propertyKey,
  63235. propertyTypeAnnotation,
  63236. optional,
  63237. isStatic
  63238. )));
  63239. }
  63240. }
  63241. if (match(';') || match(',')) {
  63242. lex();
  63243. } else if (!match('}')) {
  63244. throwUnexpected(lookahead);
  63245. }
  63246. }
  63247. expect('}');
  63248. return delegate.createObjectTypeAnnotation(
  63249. properties,
  63250. indexers,
  63251. callProperties
  63252. );
  63253. }
  63254. function parseGenericType() {
  63255. var marker = markerCreate(),
  63256. typeParameters = null, typeIdentifier;
  63257. typeIdentifier = parseVariableIdentifier();
  63258. while (match('.')) {
  63259. expect('.');
  63260. typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
  63261. typeIdentifier,
  63262. parseVariableIdentifier()
  63263. ));
  63264. }
  63265. if (match('<')) {
  63266. typeParameters = parseTypeParameterInstantiation();
  63267. }
  63268. return markerApply(marker, delegate.createGenericTypeAnnotation(
  63269. typeIdentifier,
  63270. typeParameters
  63271. ));
  63272. }
  63273. function parseVoidType() {
  63274. var marker = markerCreate();
  63275. expectKeyword('void');
  63276. return markerApply(marker, delegate.createVoidTypeAnnotation());
  63277. }
  63278. function parseTypeofType() {
  63279. var argument, marker = markerCreate();
  63280. expectKeyword('typeof');
  63281. argument = parsePrimaryType();
  63282. return markerApply(marker, delegate.createTypeofTypeAnnotation(
  63283. argument
  63284. ));
  63285. }
  63286. function parseTupleType() {
  63287. var marker = markerCreate(), types = [];
  63288. expect('[');
  63289. // We allow trailing commas
  63290. while (index < length && !match(']')) {
  63291. types.push(parseType());
  63292. if (match(']')) {
  63293. break;
  63294. }
  63295. expect(',');
  63296. }
  63297. expect(']');
  63298. return markerApply(marker, delegate.createTupleTypeAnnotation(
  63299. types
  63300. ));
  63301. }
  63302. function parseFunctionTypeParam() {
  63303. var marker = markerCreate(), name, optional = false, typeAnnotation;
  63304. name = parseVariableIdentifier();
  63305. if (match('?')) {
  63306. lex();
  63307. optional = true;
  63308. }
  63309. expect(':');
  63310. typeAnnotation = parseType();
  63311. return markerApply(marker, delegate.createFunctionTypeParam(
  63312. name,
  63313. typeAnnotation,
  63314. optional
  63315. ));
  63316. }
  63317. function parseFunctionTypeParams() {
  63318. var ret = { params: [], rest: null };
  63319. while (lookahead.type === Token.Identifier) {
  63320. ret.params.push(parseFunctionTypeParam());
  63321. if (!match(')')) {
  63322. expect(',');
  63323. }
  63324. }
  63325. if (match('...')) {
  63326. lex();
  63327. ret.rest = parseFunctionTypeParam();
  63328. }
  63329. return ret;
  63330. }
  63331. // The parsing of types roughly parallels the parsing of expressions, and
  63332. // primary types are kind of like primary expressions...they're the
  63333. // primitives with which other types are constructed.
  63334. function parsePrimaryType() {
  63335. var params = null, returnType = null,
  63336. marker = markerCreate(), rest = null, tmp,
  63337. typeParameters, token, type, isGroupedType = false;
  63338. switch (lookahead.type) {
  63339. case Token.Identifier:
  63340. switch (lookahead.value) {
  63341. case 'any':
  63342. lex();
  63343. return markerApply(marker, delegate.createAnyTypeAnnotation());
  63344. case 'bool': // fallthrough
  63345. case 'boolean':
  63346. lex();
  63347. return markerApply(marker, delegate.createBooleanTypeAnnotation());
  63348. case 'number':
  63349. lex();
  63350. return markerApply(marker, delegate.createNumberTypeAnnotation());
  63351. case 'string':
  63352. lex();
  63353. return markerApply(marker, delegate.createStringTypeAnnotation());
  63354. }
  63355. return markerApply(marker, parseGenericType());
  63356. case Token.Punctuator:
  63357. switch (lookahead.value) {
  63358. case '{':
  63359. return markerApply(marker, parseObjectType());
  63360. case '[':
  63361. return parseTupleType();
  63362. case '<':
  63363. typeParameters = parseTypeParameterDeclaration();
  63364. expect('(');
  63365. tmp = parseFunctionTypeParams();
  63366. params = tmp.params;
  63367. rest = tmp.rest;
  63368. expect(')');
  63369. expect('=>');
  63370. returnType = parseType();
  63371. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  63372. params,
  63373. returnType,
  63374. rest,
  63375. typeParameters
  63376. ));
  63377. case '(':
  63378. lex();
  63379. // Check to see if this is actually a grouped type
  63380. if (!match(')') && !match('...')) {
  63381. if (lookahead.type === Token.Identifier) {
  63382. token = lookahead2();
  63383. isGroupedType = token.value !== '?' && token.value !== ':';
  63384. } else {
  63385. isGroupedType = true;
  63386. }
  63387. }
  63388. if (isGroupedType) {
  63389. type = parseType();
  63390. expect(')');
  63391. // If we see a => next then someone was probably confused about
  63392. // function types, so we can provide a better error message
  63393. if (match('=>')) {
  63394. throwError({}, Messages.ConfusedAboutFunctionType);
  63395. }
  63396. return type;
  63397. }
  63398. tmp = parseFunctionTypeParams();
  63399. params = tmp.params;
  63400. rest = tmp.rest;
  63401. expect(')');
  63402. expect('=>');
  63403. returnType = parseType();
  63404. return markerApply(marker, delegate.createFunctionTypeAnnotation(
  63405. params,
  63406. returnType,
  63407. rest,
  63408. null /* typeParameters */
  63409. ));
  63410. }
  63411. break;
  63412. case Token.Keyword:
  63413. switch (lookahead.value) {
  63414. case 'void':
  63415. return markerApply(marker, parseVoidType());
  63416. case 'typeof':
  63417. return markerApply(marker, parseTypeofType());
  63418. }
  63419. break;
  63420. case Token.StringLiteral:
  63421. token = lex();
  63422. if (token.octal) {
  63423. throwError(token, Messages.StrictOctalLiteral);
  63424. }
  63425. return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
  63426. token
  63427. ));
  63428. }
  63429. throwUnexpected(lookahead);
  63430. }
  63431. function parsePostfixType() {
  63432. var marker = markerCreate(), t = parsePrimaryType();
  63433. if (match('[')) {
  63434. expect('[');
  63435. expect(']');
  63436. return markerApply(marker, delegate.createArrayTypeAnnotation(t));
  63437. }
  63438. return t;
  63439. }
  63440. function parsePrefixType() {
  63441. var marker = markerCreate();
  63442. if (match('?')) {
  63443. lex();
  63444. return markerApply(marker, delegate.createNullableTypeAnnotation(
  63445. parsePrefixType()
  63446. ));
  63447. }
  63448. return parsePostfixType();
  63449. }
  63450. function parseIntersectionType() {
  63451. var marker = markerCreate(), type, types;
  63452. type = parsePrefixType();
  63453. types = [type];
  63454. while (match('&')) {
  63455. lex();
  63456. types.push(parsePrefixType());
  63457. }
  63458. return types.length === 1 ?
  63459. type :
  63460. markerApply(marker, delegate.createIntersectionTypeAnnotation(
  63461. types
  63462. ));
  63463. }
  63464. function parseUnionType() {
  63465. var marker = markerCreate(), type, types;
  63466. type = parseIntersectionType();
  63467. types = [type];
  63468. while (match('|')) {
  63469. lex();
  63470. types.push(parseIntersectionType());
  63471. }
  63472. return types.length === 1 ?
  63473. type :
  63474. markerApply(marker, delegate.createUnionTypeAnnotation(
  63475. types
  63476. ));
  63477. }
  63478. function parseType() {
  63479. var oldInType = state.inType, type;
  63480. state.inType = true;
  63481. type = parseUnionType();
  63482. state.inType = oldInType;
  63483. return type;
  63484. }
  63485. function parseTypeAnnotation() {
  63486. var marker = markerCreate(), type;
  63487. expect(':');
  63488. type = parseType();
  63489. return markerApply(marker, delegate.createTypeAnnotation(type));
  63490. }
  63491. function parseVariableIdentifier() {
  63492. var marker = markerCreate(),
  63493. token = lex();
  63494. if (token.type !== Token.Identifier) {
  63495. throwUnexpected(token);
  63496. }
  63497. return markerApply(marker, delegate.createIdentifier(token.value));
  63498. }
  63499. function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
  63500. var marker = markerCreate(),
  63501. ident = parseVariableIdentifier(),
  63502. isOptionalParam = false;
  63503. if (canBeOptionalParam && match('?')) {
  63504. expect('?');
  63505. isOptionalParam = true;
  63506. }
  63507. if (requireTypeAnnotation || match(':')) {
  63508. ident.typeAnnotation = parseTypeAnnotation();
  63509. ident = markerApply(marker, ident);
  63510. }
  63511. if (isOptionalParam) {
  63512. ident.optional = true;
  63513. ident = markerApply(marker, ident);
  63514. }
  63515. return ident;
  63516. }
  63517. function parseVariableDeclaration(kind) {
  63518. var id,
  63519. marker = markerCreate(),
  63520. init = null,
  63521. typeAnnotationMarker = markerCreate();
  63522. if (match('{')) {
  63523. id = parseObjectInitialiser();
  63524. reinterpretAsAssignmentBindingPattern(id);
  63525. if (match(':')) {
  63526. id.typeAnnotation = parseTypeAnnotation();
  63527. markerApply(typeAnnotationMarker, id);
  63528. }
  63529. } else if (match('[')) {
  63530. id = parseArrayInitialiser();
  63531. reinterpretAsAssignmentBindingPattern(id);
  63532. if (match(':')) {
  63533. id.typeAnnotation = parseTypeAnnotation();
  63534. markerApply(typeAnnotationMarker, id);
  63535. }
  63536. } else {
  63537. /* istanbul ignore next */
  63538. id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
  63539. // 12.2.1
  63540. if (strict && isRestrictedWord(id.name)) {
  63541. throwErrorTolerant({}, Messages.StrictVarName);
  63542. }
  63543. }
  63544. if (kind === 'const') {
  63545. if (!match('=')) {
  63546. throwError({}, Messages.NoUninitializedConst);
  63547. }
  63548. expect('=');
  63549. init = parseAssignmentExpression();
  63550. } else if (match('=')) {
  63551. lex();
  63552. init = parseAssignmentExpression();
  63553. }
  63554. return markerApply(marker, delegate.createVariableDeclarator(id, init));
  63555. }
  63556. function parseVariableDeclarationList(kind) {
  63557. var list = [];
  63558. do {
  63559. list.push(parseVariableDeclaration(kind));
  63560. if (!match(',')) {
  63561. break;
  63562. }
  63563. lex();
  63564. } while (index < length);
  63565. return list;
  63566. }
  63567. function parseVariableStatement() {
  63568. var declarations, marker = markerCreate();
  63569. expectKeyword('var');
  63570. declarations = parseVariableDeclarationList();
  63571. consumeSemicolon();
  63572. return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
  63573. }
  63574. // kind may be `const` or `let`
  63575. // Both are experimental and not in the specification yet.
  63576. // see http://wiki.ecmascript.org/doku.php?id=harmony:const
  63577. // and http://wiki.ecmascript.org/doku.php?id=harmony:let
  63578. function parseConstLetDeclaration(kind) {
  63579. var declarations, marker = markerCreate();
  63580. expectKeyword(kind);
  63581. declarations = parseVariableDeclarationList(kind);
  63582. consumeSemicolon();
  63583. return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
  63584. }
  63585. // people.mozilla.org/~jorendorff/es6-draft.html
  63586. function parseModuleSpecifier() {
  63587. var marker = markerCreate(),
  63588. specifier;
  63589. if (lookahead.type !== Token.StringLiteral) {
  63590. throwError({}, Messages.InvalidModuleSpecifier);
  63591. }
  63592. specifier = delegate.createLiteral(lex());
  63593. return markerApply(marker, specifier);
  63594. }
  63595. function parseExportBatchSpecifier() {
  63596. var marker = markerCreate();
  63597. expect('*');
  63598. return markerApply(marker, delegate.createExportBatchSpecifier());
  63599. }
  63600. function parseExportSpecifier() {
  63601. var id, name = null, marker = markerCreate();
  63602. if (matchKeyword('default')) {
  63603. lex();
  63604. id = markerApply(marker, delegate.createIdentifier('default'));
  63605. // export {default} from "something";
  63606. } else {
  63607. id = parseVariableIdentifier();
  63608. }
  63609. if (matchContextualKeyword('as')) {
  63610. lex();
  63611. name = parseNonComputedProperty();
  63612. }
  63613. return markerApply(marker, delegate.createExportSpecifier(id, name));
  63614. }
  63615. function parseExportDeclaration() {
  63616. var declaration = null,
  63617. possibleIdentifierToken, sourceElement,
  63618. isExportFromIdentifier,
  63619. src = null, specifiers = [],
  63620. marker = markerCreate();
  63621. expectKeyword('export');
  63622. if (matchKeyword('default')) {
  63623. // covers:
  63624. // export default ...
  63625. lex();
  63626. if (matchKeyword('function') || matchKeyword('class')) {
  63627. possibleIdentifierToken = lookahead2();
  63628. if (isIdentifierName(possibleIdentifierToken)) {
  63629. // covers:
  63630. // export default function foo () {}
  63631. // export default class foo {}
  63632. sourceElement = parseSourceElement();
  63633. return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
  63634. }
  63635. // covers:
  63636. // export default function () {}
  63637. // export default class {}
  63638. switch (lookahead.value) {
  63639. case 'class':
  63640. return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
  63641. case 'function':
  63642. return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
  63643. }
  63644. }
  63645. if (matchContextualKeyword('from')) {
  63646. throwError({}, Messages.UnexpectedToken, lookahead.value);
  63647. }
  63648. // covers:
  63649. // export default {};
  63650. // export default [];
  63651. if (match('{')) {
  63652. declaration = parseObjectInitialiser();
  63653. } else if (match('[')) {
  63654. declaration = parseArrayInitialiser();
  63655. } else {
  63656. declaration = parseAssignmentExpression();
  63657. }
  63658. consumeSemicolon();
  63659. return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
  63660. }
  63661. // non-default export
  63662. if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
  63663. // covers:
  63664. // export var f = 1;
  63665. switch (lookahead.value) {
  63666. case 'type':
  63667. case 'let':
  63668. case 'const':
  63669. case 'var':
  63670. case 'class':
  63671. case 'function':
  63672. return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
  63673. }
  63674. }
  63675. if (match('*')) {
  63676. // covers:
  63677. // export * from "foo";
  63678. specifiers.push(parseExportBatchSpecifier());
  63679. if (!matchContextualKeyword('from')) {
  63680. throwError({}, lookahead.value ?
  63681. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  63682. }
  63683. lex();
  63684. src = parseModuleSpecifier();
  63685. consumeSemicolon();
  63686. return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
  63687. }
  63688. expect('{');
  63689. if (!match('}')) {
  63690. do {
  63691. isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
  63692. specifiers.push(parseExportSpecifier());
  63693. } while (match(',') && lex());
  63694. }
  63695. expect('}');
  63696. if (matchContextualKeyword('from')) {
  63697. // covering:
  63698. // export {default} from "foo";
  63699. // export {foo} from "foo";
  63700. lex();
  63701. src = parseModuleSpecifier();
  63702. consumeSemicolon();
  63703. } else if (isExportFromIdentifier) {
  63704. // covering:
  63705. // export {default}; // missing fromClause
  63706. throwError({}, lookahead.value ?
  63707. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  63708. } else {
  63709. // cover
  63710. // export {foo};
  63711. consumeSemicolon();
  63712. }
  63713. return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
  63714. }
  63715. function parseImportSpecifier() {
  63716. // import {<foo as bar>} ...;
  63717. var id, name = null, marker = markerCreate();
  63718. id = parseNonComputedProperty();
  63719. if (matchContextualKeyword('as')) {
  63720. lex();
  63721. name = parseVariableIdentifier();
  63722. }
  63723. return markerApply(marker, delegate.createImportSpecifier(id, name));
  63724. }
  63725. function parseNamedImports() {
  63726. var specifiers = [];
  63727. // {foo, bar as bas}
  63728. expect('{');
  63729. if (!match('}')) {
  63730. do {
  63731. specifiers.push(parseImportSpecifier());
  63732. } while (match(',') && lex());
  63733. }
  63734. expect('}');
  63735. return specifiers;
  63736. }
  63737. function parseImportDefaultSpecifier() {
  63738. // import <foo> ...;
  63739. var id, marker = markerCreate();
  63740. id = parseNonComputedProperty();
  63741. return markerApply(marker, delegate.createImportDefaultSpecifier(id));
  63742. }
  63743. function parseImportNamespaceSpecifier() {
  63744. // import <* as foo> ...;
  63745. var id, marker = markerCreate();
  63746. expect('*');
  63747. if (!matchContextualKeyword('as')) {
  63748. throwError({}, Messages.NoAsAfterImportNamespace);
  63749. }
  63750. lex();
  63751. id = parseNonComputedProperty();
  63752. return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
  63753. }
  63754. function parseImportDeclaration() {
  63755. var specifiers, src, marker = markerCreate(), isType = false, token2;
  63756. expectKeyword('import');
  63757. if (matchContextualKeyword('type')) {
  63758. token2 = lookahead2();
  63759. if ((token2.type === Token.Identifier && token2.value !== 'from') ||
  63760. (token2.type === Token.Punctuator &&
  63761. (token2.value === '{' || token2.value === '*'))) {
  63762. isType = true;
  63763. lex();
  63764. }
  63765. }
  63766. specifiers = [];
  63767. if (lookahead.type === Token.StringLiteral) {
  63768. // covers:
  63769. // import "foo";
  63770. src = parseModuleSpecifier();
  63771. consumeSemicolon();
  63772. return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
  63773. }
  63774. if (!matchKeyword('default') && isIdentifierName(lookahead)) {
  63775. // covers:
  63776. // import foo
  63777. // import foo, ...
  63778. specifiers.push(parseImportDefaultSpecifier());
  63779. if (match(',')) {
  63780. lex();
  63781. }
  63782. }
  63783. if (match('*')) {
  63784. // covers:
  63785. // import foo, * as foo
  63786. // import * as foo
  63787. specifiers.push(parseImportNamespaceSpecifier());
  63788. } else if (match('{')) {
  63789. // covers:
  63790. // import foo, {bar}
  63791. // import {bar}
  63792. specifiers = specifiers.concat(parseNamedImports());
  63793. }
  63794. if (!matchContextualKeyword('from')) {
  63795. throwError({}, lookahead.value ?
  63796. Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
  63797. }
  63798. lex();
  63799. src = parseModuleSpecifier();
  63800. consumeSemicolon();
  63801. return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
  63802. }
  63803. // 12.3 Empty Statement
  63804. function parseEmptyStatement() {
  63805. var marker = markerCreate();
  63806. expect(';');
  63807. return markerApply(marker, delegate.createEmptyStatement());
  63808. }
  63809. // 12.4 Expression Statement
  63810. function parseExpressionStatement() {
  63811. var marker = markerCreate(), expr = parseExpression();
  63812. consumeSemicolon();
  63813. return markerApply(marker, delegate.createExpressionStatement(expr));
  63814. }
  63815. // 12.5 If statement
  63816. function parseIfStatement() {
  63817. var test, consequent, alternate, marker = markerCreate();
  63818. expectKeyword('if');
  63819. expect('(');
  63820. test = parseExpression();
  63821. expect(')');
  63822. consequent = parseStatement();
  63823. if (matchKeyword('else')) {
  63824. lex();
  63825. alternate = parseStatement();
  63826. } else {
  63827. alternate = null;
  63828. }
  63829. return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
  63830. }
  63831. // 12.6 Iteration Statements
  63832. function parseDoWhileStatement() {
  63833. var body, test, oldInIteration, marker = markerCreate();
  63834. expectKeyword('do');
  63835. oldInIteration = state.inIteration;
  63836. state.inIteration = true;
  63837. body = parseStatement();
  63838. state.inIteration = oldInIteration;
  63839. expectKeyword('while');
  63840. expect('(');
  63841. test = parseExpression();
  63842. expect(')');
  63843. if (match(';')) {
  63844. lex();
  63845. }
  63846. return markerApply(marker, delegate.createDoWhileStatement(body, test));
  63847. }
  63848. function parseWhileStatement() {
  63849. var test, body, oldInIteration, marker = markerCreate();
  63850. expectKeyword('while');
  63851. expect('(');
  63852. test = parseExpression();
  63853. expect(')');
  63854. oldInIteration = state.inIteration;
  63855. state.inIteration = true;
  63856. body = parseStatement();
  63857. state.inIteration = oldInIteration;
  63858. return markerApply(marker, delegate.createWhileStatement(test, body));
  63859. }
  63860. function parseForVariableDeclaration() {
  63861. var marker = markerCreate(),
  63862. token = lex(),
  63863. declarations = parseVariableDeclarationList();
  63864. return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
  63865. }
  63866. function parseForStatement(opts) {
  63867. var init, test, update, left, right, body, operator, oldInIteration,
  63868. marker = markerCreate();
  63869. init = test = update = null;
  63870. expectKeyword('for');
  63871. // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
  63872. if (matchContextualKeyword('each')) {
  63873. throwError({}, Messages.EachNotAllowed);
  63874. }
  63875. expect('(');
  63876. if (match(';')) {
  63877. lex();
  63878. } else {
  63879. if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
  63880. state.allowIn = false;
  63881. init = parseForVariableDeclaration();
  63882. state.allowIn = true;
  63883. if (init.declarations.length === 1) {
  63884. if (matchKeyword('in') || matchContextualKeyword('of')) {
  63885. operator = lookahead;
  63886. if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
  63887. lex();
  63888. left = init;
  63889. right = parseExpression();
  63890. init = null;
  63891. }
  63892. }
  63893. }
  63894. } else {
  63895. state.allowIn = false;
  63896. init = parseExpression();
  63897. state.allowIn = true;
  63898. if (matchContextualKeyword('of')) {
  63899. operator = lex();
  63900. left = init;
  63901. right = parseExpression();
  63902. init = null;
  63903. } else if (matchKeyword('in')) {
  63904. // LeftHandSideExpression
  63905. if (!isAssignableLeftHandSide(init)) {
  63906. throwError({}, Messages.InvalidLHSInForIn);
  63907. }
  63908. operator = lex();
  63909. left = init;
  63910. right = parseExpression();
  63911. init = null;
  63912. }
  63913. }
  63914. if (typeof left === 'undefined') {
  63915. expect(';');
  63916. }
  63917. }
  63918. if (typeof left === 'undefined') {
  63919. if (!match(';')) {
  63920. test = parseExpression();
  63921. }
  63922. expect(';');
  63923. if (!match(')')) {
  63924. update = parseExpression();
  63925. }
  63926. }
  63927. expect(')');
  63928. oldInIteration = state.inIteration;
  63929. state.inIteration = true;
  63930. if (!(opts !== undefined && opts.ignoreBody)) {
  63931. body = parseStatement();
  63932. }
  63933. state.inIteration = oldInIteration;
  63934. if (typeof left === 'undefined') {
  63935. return markerApply(marker, delegate.createForStatement(init, test, update, body));
  63936. }
  63937. if (operator.value === 'in') {
  63938. return markerApply(marker, delegate.createForInStatement(left, right, body));
  63939. }
  63940. return markerApply(marker, delegate.createForOfStatement(left, right, body));
  63941. }
  63942. // 12.7 The continue statement
  63943. function parseContinueStatement() {
  63944. var label = null, marker = markerCreate();
  63945. expectKeyword('continue');
  63946. // Optimize the most common form: 'continue;'.
  63947. if (source.charCodeAt(index) === 59) {
  63948. lex();
  63949. if (!state.inIteration) {
  63950. throwError({}, Messages.IllegalContinue);
  63951. }
  63952. return markerApply(marker, delegate.createContinueStatement(null));
  63953. }
  63954. if (peekLineTerminator()) {
  63955. if (!state.inIteration) {
  63956. throwError({}, Messages.IllegalContinue);
  63957. }
  63958. return markerApply(marker, delegate.createContinueStatement(null));
  63959. }
  63960. if (lookahead.type === Token.Identifier) {
  63961. label = parseVariableIdentifier();
  63962. if (!state.labelSet.has(label.name)) {
  63963. throwError({}, Messages.UnknownLabel, label.name);
  63964. }
  63965. }
  63966. consumeSemicolon();
  63967. if (label === null && !state.inIteration) {
  63968. throwError({}, Messages.IllegalContinue);
  63969. }
  63970. return markerApply(marker, delegate.createContinueStatement(label));
  63971. }
  63972. // 12.8 The break statement
  63973. function parseBreakStatement() {
  63974. var label = null, marker = markerCreate();
  63975. expectKeyword('break');
  63976. // Catch the very common case first: immediately a semicolon (char #59).
  63977. if (source.charCodeAt(index) === 59) {
  63978. lex();
  63979. if (!(state.inIteration || state.inSwitch)) {
  63980. throwError({}, Messages.IllegalBreak);
  63981. }
  63982. return markerApply(marker, delegate.createBreakStatement(null));
  63983. }
  63984. if (peekLineTerminator()) {
  63985. if (!(state.inIteration || state.inSwitch)) {
  63986. throwError({}, Messages.IllegalBreak);
  63987. }
  63988. return markerApply(marker, delegate.createBreakStatement(null));
  63989. }
  63990. if (lookahead.type === Token.Identifier) {
  63991. label = parseVariableIdentifier();
  63992. if (!state.labelSet.has(label.name)) {
  63993. throwError({}, Messages.UnknownLabel, label.name);
  63994. }
  63995. }
  63996. consumeSemicolon();
  63997. if (label === null && !(state.inIteration || state.inSwitch)) {
  63998. throwError({}, Messages.IllegalBreak);
  63999. }
  64000. return markerApply(marker, delegate.createBreakStatement(label));
  64001. }
  64002. // 12.9 The return statement
  64003. function parseReturnStatement() {
  64004. var argument = null, marker = markerCreate();
  64005. expectKeyword('return');
  64006. if (!state.inFunctionBody) {
  64007. throwErrorTolerant({}, Messages.IllegalReturn);
  64008. }
  64009. // 'return' followed by a space and an identifier is very common.
  64010. if (source.charCodeAt(index) === 32) {
  64011. if (isIdentifierStart(source.charCodeAt(index + 1))) {
  64012. argument = parseExpression();
  64013. consumeSemicolon();
  64014. return markerApply(marker, delegate.createReturnStatement(argument));
  64015. }
  64016. }
  64017. if (peekLineTerminator()) {
  64018. return markerApply(marker, delegate.createReturnStatement(null));
  64019. }
  64020. if (!match(';')) {
  64021. if (!match('}') && lookahead.type !== Token.EOF) {
  64022. argument = parseExpression();
  64023. }
  64024. }
  64025. consumeSemicolon();
  64026. return markerApply(marker, delegate.createReturnStatement(argument));
  64027. }
  64028. // 12.10 The with statement
  64029. function parseWithStatement() {
  64030. var object, body, marker = markerCreate();
  64031. if (strict) {
  64032. throwErrorTolerant({}, Messages.StrictModeWith);
  64033. }
  64034. expectKeyword('with');
  64035. expect('(');
  64036. object = parseExpression();
  64037. expect(')');
  64038. body = parseStatement();
  64039. return markerApply(marker, delegate.createWithStatement(object, body));
  64040. }
  64041. // 12.10 The swith statement
  64042. function parseSwitchCase() {
  64043. var test,
  64044. consequent = [],
  64045. sourceElement,
  64046. marker = markerCreate();
  64047. if (matchKeyword('default')) {
  64048. lex();
  64049. test = null;
  64050. } else {
  64051. expectKeyword('case');
  64052. test = parseExpression();
  64053. }
  64054. expect(':');
  64055. while (index < length) {
  64056. if (match('}') || matchKeyword('default') || matchKeyword('case')) {
  64057. break;
  64058. }
  64059. sourceElement = parseSourceElement();
  64060. if (typeof sourceElement === 'undefined') {
  64061. break;
  64062. }
  64063. consequent.push(sourceElement);
  64064. }
  64065. return markerApply(marker, delegate.createSwitchCase(test, consequent));
  64066. }
  64067. function parseSwitchStatement() {
  64068. var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
  64069. expectKeyword('switch');
  64070. expect('(');
  64071. discriminant = parseExpression();
  64072. expect(')');
  64073. expect('{');
  64074. cases = [];
  64075. if (match('}')) {
  64076. lex();
  64077. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  64078. }
  64079. oldInSwitch = state.inSwitch;
  64080. state.inSwitch = true;
  64081. defaultFound = false;
  64082. while (index < length) {
  64083. if (match('}')) {
  64084. break;
  64085. }
  64086. clause = parseSwitchCase();
  64087. if (clause.test === null) {
  64088. if (defaultFound) {
  64089. throwError({}, Messages.MultipleDefaultsInSwitch);
  64090. }
  64091. defaultFound = true;
  64092. }
  64093. cases.push(clause);
  64094. }
  64095. state.inSwitch = oldInSwitch;
  64096. expect('}');
  64097. return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
  64098. }
  64099. // 12.13 The throw statement
  64100. function parseThrowStatement() {
  64101. var argument, marker = markerCreate();
  64102. expectKeyword('throw');
  64103. if (peekLineTerminator()) {
  64104. throwError({}, Messages.NewlineAfterThrow);
  64105. }
  64106. argument = parseExpression();
  64107. consumeSemicolon();
  64108. return markerApply(marker, delegate.createThrowStatement(argument));
  64109. }
  64110. // 12.14 The try statement
  64111. function parseCatchClause() {
  64112. var param, body, marker = markerCreate();
  64113. expectKeyword('catch');
  64114. expect('(');
  64115. if (match(')')) {
  64116. throwUnexpected(lookahead);
  64117. }
  64118. param = parseExpression();
  64119. // 12.14.1
  64120. if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
  64121. throwErrorTolerant({}, Messages.StrictCatchVariable);
  64122. }
  64123. expect(')');
  64124. body = parseBlock();
  64125. return markerApply(marker, delegate.createCatchClause(param, body));
  64126. }
  64127. function parseTryStatement() {
  64128. var block, handlers = [], finalizer = null, marker = markerCreate();
  64129. expectKeyword('try');
  64130. block = parseBlock();
  64131. if (matchKeyword('catch')) {
  64132. handlers.push(parseCatchClause());
  64133. }
  64134. if (matchKeyword('finally')) {
  64135. lex();
  64136. finalizer = parseBlock();
  64137. }
  64138. if (handlers.length === 0 && !finalizer) {
  64139. throwError({}, Messages.NoCatchOrFinally);
  64140. }
  64141. return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
  64142. }
  64143. // 12.15 The debugger statement
  64144. function parseDebuggerStatement() {
  64145. var marker = markerCreate();
  64146. expectKeyword('debugger');
  64147. consumeSemicolon();
  64148. return markerApply(marker, delegate.createDebuggerStatement());
  64149. }
  64150. // 12 Statements
  64151. function parseStatement() {
  64152. var type = lookahead.type,
  64153. marker,
  64154. expr,
  64155. labeledBody;
  64156. if (type === Token.EOF) {
  64157. throwUnexpected(lookahead);
  64158. }
  64159. if (type === Token.Punctuator) {
  64160. switch (lookahead.value) {
  64161. case ';':
  64162. return parseEmptyStatement();
  64163. case '{':
  64164. return parseBlock();
  64165. case '(':
  64166. return parseExpressionStatement();
  64167. default:
  64168. break;
  64169. }
  64170. }
  64171. if (type === Token.Keyword) {
  64172. switch (lookahead.value) {
  64173. case 'break':
  64174. return parseBreakStatement();
  64175. case 'continue':
  64176. return parseContinueStatement();
  64177. case 'debugger':
  64178. return parseDebuggerStatement();
  64179. case 'do':
  64180. return parseDoWhileStatement();
  64181. case 'for':
  64182. return parseForStatement();
  64183. case 'function':
  64184. return parseFunctionDeclaration();
  64185. case 'class':
  64186. return parseClassDeclaration();
  64187. case 'if':
  64188. return parseIfStatement();
  64189. case 'return':
  64190. return parseReturnStatement();
  64191. case 'switch':
  64192. return parseSwitchStatement();
  64193. case 'throw':
  64194. return parseThrowStatement();
  64195. case 'try':
  64196. return parseTryStatement();
  64197. case 'var':
  64198. return parseVariableStatement();
  64199. case 'while':
  64200. return parseWhileStatement();
  64201. case 'with':
  64202. return parseWithStatement();
  64203. default:
  64204. break;
  64205. }
  64206. }
  64207. if (matchAsyncFuncExprOrDecl()) {
  64208. return parseFunctionDeclaration();
  64209. }
  64210. marker = markerCreate();
  64211. expr = parseExpression();
  64212. // 12.12 Labelled Statements
  64213. if ((expr.type === Syntax.Identifier) && match(':')) {
  64214. lex();
  64215. if (state.labelSet.has(expr.name)) {
  64216. throwError({}, Messages.Redeclaration, 'Label', expr.name);
  64217. }
  64218. state.labelSet.set(expr.name, true);
  64219. labeledBody = parseStatement();
  64220. state.labelSet.delete(expr.name);
  64221. return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
  64222. }
  64223. consumeSemicolon();
  64224. return markerApply(marker, delegate.createExpressionStatement(expr));
  64225. }
  64226. // 13 Function Definition
  64227. function parseConciseBody() {
  64228. if (match('{')) {
  64229. return parseFunctionSourceElements();
  64230. }
  64231. return parseAssignmentExpression();
  64232. }
  64233. function parseFunctionSourceElements() {
  64234. var sourceElement, sourceElements = [], token, directive, firstRestricted,
  64235. oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
  64236. marker = markerCreate();
  64237. expect('{');
  64238. while (index < length) {
  64239. if (lookahead.type !== Token.StringLiteral) {
  64240. break;
  64241. }
  64242. token = lookahead;
  64243. sourceElement = parseSourceElement();
  64244. sourceElements.push(sourceElement);
  64245. if (sourceElement.expression.type !== Syntax.Literal) {
  64246. // this is not directive
  64247. break;
  64248. }
  64249. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  64250. if (directive === 'use strict') {
  64251. strict = true;
  64252. if (firstRestricted) {
  64253. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  64254. }
  64255. } else {
  64256. if (!firstRestricted && token.octal) {
  64257. firstRestricted = token;
  64258. }
  64259. }
  64260. }
  64261. oldLabelSet = state.labelSet;
  64262. oldInIteration = state.inIteration;
  64263. oldInSwitch = state.inSwitch;
  64264. oldInFunctionBody = state.inFunctionBody;
  64265. oldParenthesizedCount = state.parenthesizedCount;
  64266. state.labelSet = new StringMap();
  64267. state.inIteration = false;
  64268. state.inSwitch = false;
  64269. state.inFunctionBody = true;
  64270. state.parenthesizedCount = 0;
  64271. while (index < length) {
  64272. if (match('}')) {
  64273. break;
  64274. }
  64275. sourceElement = parseSourceElement();
  64276. if (typeof sourceElement === 'undefined') {
  64277. break;
  64278. }
  64279. sourceElements.push(sourceElement);
  64280. }
  64281. expect('}');
  64282. state.labelSet = oldLabelSet;
  64283. state.inIteration = oldInIteration;
  64284. state.inSwitch = oldInSwitch;
  64285. state.inFunctionBody = oldInFunctionBody;
  64286. state.parenthesizedCount = oldParenthesizedCount;
  64287. return markerApply(marker, delegate.createBlockStatement(sourceElements));
  64288. }
  64289. function validateParam(options, param, name) {
  64290. if (strict) {
  64291. if (isRestrictedWord(name)) {
  64292. options.stricted = param;
  64293. options.message = Messages.StrictParamName;
  64294. }
  64295. if (options.paramSet.has(name)) {
  64296. options.stricted = param;
  64297. options.message = Messages.StrictParamDupe;
  64298. }
  64299. } else if (!options.firstRestricted) {
  64300. if (isRestrictedWord(name)) {
  64301. options.firstRestricted = param;
  64302. options.message = Messages.StrictParamName;
  64303. } else if (isStrictModeReservedWord(name)) {
  64304. options.firstRestricted = param;
  64305. options.message = Messages.StrictReservedWord;
  64306. } else if (options.paramSet.has(name)) {
  64307. options.firstRestricted = param;
  64308. options.message = Messages.StrictParamDupe;
  64309. }
  64310. }
  64311. options.paramSet.set(name, true);
  64312. }
  64313. function parseParam(options) {
  64314. var marker, token, rest, param, def;
  64315. token = lookahead;
  64316. if (token.value === '...') {
  64317. token = lex();
  64318. rest = true;
  64319. }
  64320. if (match('[')) {
  64321. marker = markerCreate();
  64322. param = parseArrayInitialiser();
  64323. reinterpretAsDestructuredParameter(options, param);
  64324. if (match(':')) {
  64325. param.typeAnnotation = parseTypeAnnotation();
  64326. markerApply(marker, param);
  64327. }
  64328. } else if (match('{')) {
  64329. marker = markerCreate();
  64330. if (rest) {
  64331. throwError({}, Messages.ObjectPatternAsRestParameter);
  64332. }
  64333. param = parseObjectInitialiser();
  64334. reinterpretAsDestructuredParameter(options, param);
  64335. if (match(':')) {
  64336. param.typeAnnotation = parseTypeAnnotation();
  64337. markerApply(marker, param);
  64338. }
  64339. } else {
  64340. param =
  64341. rest
  64342. ? parseTypeAnnotatableIdentifier(
  64343. false, /* requireTypeAnnotation */
  64344. false /* canBeOptionalParam */
  64345. )
  64346. : parseTypeAnnotatableIdentifier(
  64347. false, /* requireTypeAnnotation */
  64348. true /* canBeOptionalParam */
  64349. );
  64350. validateParam(options, token, token.value);
  64351. }
  64352. if (match('=')) {
  64353. if (rest) {
  64354. throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
  64355. }
  64356. lex();
  64357. def = parseAssignmentExpression();
  64358. ++options.defaultCount;
  64359. }
  64360. if (rest) {
  64361. if (!match(')')) {
  64362. throwError({}, Messages.ParameterAfterRestParameter);
  64363. }
  64364. options.rest = param;
  64365. return false;
  64366. }
  64367. options.params.push(param);
  64368. options.defaults.push(def);
  64369. return !match(')');
  64370. }
  64371. function parseParams(firstRestricted) {
  64372. var options, marker = markerCreate();
  64373. options = {
  64374. params: [],
  64375. defaultCount: 0,
  64376. defaults: [],
  64377. rest: null,
  64378. firstRestricted: firstRestricted
  64379. };
  64380. expect('(');
  64381. if (!match(')')) {
  64382. options.paramSet = new StringMap();
  64383. while (index < length) {
  64384. if (!parseParam(options)) {
  64385. break;
  64386. }
  64387. expect(',');
  64388. if (!options.rest && match(')')) {
  64389. break;
  64390. }
  64391. }
  64392. }
  64393. expect(')');
  64394. if (options.defaultCount === 0) {
  64395. options.defaults = [];
  64396. }
  64397. if (match(':')) {
  64398. options.returnType = parseTypeAnnotation();
  64399. }
  64400. return markerApply(marker, options);
  64401. }
  64402. function parseFunctionDeclaration() {
  64403. var id, body, token, tmp, firstRestricted, message, generator, isAsync,
  64404. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  64405. marker = markerCreate(), typeParameters;
  64406. isAsync = false;
  64407. if (matchAsync()) {
  64408. lex();
  64409. isAsync = true;
  64410. }
  64411. expectKeyword('function');
  64412. generator = false;
  64413. if (match('*')) {
  64414. lex();
  64415. generator = true;
  64416. }
  64417. token = lookahead;
  64418. id = parseVariableIdentifier();
  64419. if (match('<')) {
  64420. typeParameters = parseTypeParameterDeclaration();
  64421. }
  64422. if (strict) {
  64423. if (isRestrictedWord(token.value)) {
  64424. throwErrorTolerant(token, Messages.StrictFunctionName);
  64425. }
  64426. } else {
  64427. if (isRestrictedWord(token.value)) {
  64428. firstRestricted = token;
  64429. message = Messages.StrictFunctionName;
  64430. } else if (isStrictModeReservedWord(token.value)) {
  64431. firstRestricted = token;
  64432. message = Messages.StrictReservedWord;
  64433. }
  64434. }
  64435. tmp = parseParams(firstRestricted);
  64436. firstRestricted = tmp.firstRestricted;
  64437. if (tmp.message) {
  64438. message = tmp.message;
  64439. }
  64440. previousStrict = strict;
  64441. previousYieldAllowed = state.yieldAllowed;
  64442. state.yieldAllowed = generator;
  64443. previousAwaitAllowed = state.awaitAllowed;
  64444. state.awaitAllowed = isAsync;
  64445. body = parseFunctionSourceElements();
  64446. if (strict && firstRestricted) {
  64447. throwError(firstRestricted, message);
  64448. }
  64449. if (strict && tmp.stricted) {
  64450. throwErrorTolerant(tmp.stricted, message);
  64451. }
  64452. strict = previousStrict;
  64453. state.yieldAllowed = previousYieldAllowed;
  64454. state.awaitAllowed = previousAwaitAllowed;
  64455. return markerApply(
  64456. marker,
  64457. delegate.createFunctionDeclaration(
  64458. id,
  64459. tmp.params,
  64460. tmp.defaults,
  64461. body,
  64462. tmp.rest,
  64463. generator,
  64464. false,
  64465. isAsync,
  64466. tmp.returnType,
  64467. typeParameters
  64468. )
  64469. );
  64470. }
  64471. function parseFunctionExpression() {
  64472. var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
  64473. previousStrict, previousYieldAllowed, previousAwaitAllowed,
  64474. marker = markerCreate(), typeParameters;
  64475. isAsync = false;
  64476. if (matchAsync()) {
  64477. lex();
  64478. isAsync = true;
  64479. }
  64480. expectKeyword('function');
  64481. generator = false;
  64482. if (match('*')) {
  64483. lex();
  64484. generator = true;
  64485. }
  64486. if (!match('(')) {
  64487. if (!match('<')) {
  64488. token = lookahead;
  64489. id = parseVariableIdentifier();
  64490. if (strict) {
  64491. if (isRestrictedWord(token.value)) {
  64492. throwErrorTolerant(token, Messages.StrictFunctionName);
  64493. }
  64494. } else {
  64495. if (isRestrictedWord(token.value)) {
  64496. firstRestricted = token;
  64497. message = Messages.StrictFunctionName;
  64498. } else if (isStrictModeReservedWord(token.value)) {
  64499. firstRestricted = token;
  64500. message = Messages.StrictReservedWord;
  64501. }
  64502. }
  64503. }
  64504. if (match('<')) {
  64505. typeParameters = parseTypeParameterDeclaration();
  64506. }
  64507. }
  64508. tmp = parseParams(firstRestricted);
  64509. firstRestricted = tmp.firstRestricted;
  64510. if (tmp.message) {
  64511. message = tmp.message;
  64512. }
  64513. previousStrict = strict;
  64514. previousYieldAllowed = state.yieldAllowed;
  64515. state.yieldAllowed = generator;
  64516. previousAwaitAllowed = state.awaitAllowed;
  64517. state.awaitAllowed = isAsync;
  64518. body = parseFunctionSourceElements();
  64519. if (strict && firstRestricted) {
  64520. throwError(firstRestricted, message);
  64521. }
  64522. if (strict && tmp.stricted) {
  64523. throwErrorTolerant(tmp.stricted, message);
  64524. }
  64525. strict = previousStrict;
  64526. state.yieldAllowed = previousYieldAllowed;
  64527. state.awaitAllowed = previousAwaitAllowed;
  64528. return markerApply(
  64529. marker,
  64530. delegate.createFunctionExpression(
  64531. id,
  64532. tmp.params,
  64533. tmp.defaults,
  64534. body,
  64535. tmp.rest,
  64536. generator,
  64537. false,
  64538. isAsync,
  64539. tmp.returnType,
  64540. typeParameters
  64541. )
  64542. );
  64543. }
  64544. function parseYieldExpression() {
  64545. var delegateFlag, expr, marker = markerCreate();
  64546. expectKeyword('yield', !strict);
  64547. delegateFlag = false;
  64548. if (match('*')) {
  64549. lex();
  64550. delegateFlag = true;
  64551. }
  64552. expr = parseAssignmentExpression();
  64553. return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
  64554. }
  64555. function parseAwaitExpression() {
  64556. var expr, marker = markerCreate();
  64557. expectContextualKeyword('await');
  64558. expr = parseAssignmentExpression();
  64559. return markerApply(marker, delegate.createAwaitExpression(expr));
  64560. }
  64561. // 14 Functions and classes
  64562. // 14.1 Functions is defined above (13 in ES5)
  64563. // 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
  64564. // 14.3 Method Definitions
  64565. // 14.3.7
  64566. function specialMethod(methodDefinition) {
  64567. return methodDefinition.kind === 'get' ||
  64568. methodDefinition.kind === 'set' ||
  64569. methodDefinition.value.generator;
  64570. }
  64571. function parseMethodDefinition(key, isStatic, generator, computed) {
  64572. var token, param, propType,
  64573. isAsync, typeParameters, tokenValue, returnType;
  64574. propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
  64575. if (generator) {
  64576. return delegate.createMethodDefinition(
  64577. propType,
  64578. '',
  64579. key,
  64580. parsePropertyMethodFunction({ generator: true }),
  64581. computed
  64582. );
  64583. }
  64584. tokenValue = key.type === 'Identifier' && key.name;
  64585. if (tokenValue === 'get' && !match('(')) {
  64586. key = parseObjectPropertyKey();
  64587. expect('(');
  64588. expect(')');
  64589. if (match(':')) {
  64590. returnType = parseTypeAnnotation();
  64591. }
  64592. return delegate.createMethodDefinition(
  64593. propType,
  64594. 'get',
  64595. key,
  64596. parsePropertyFunction({ generator: false, returnType: returnType }),
  64597. computed
  64598. );
  64599. }
  64600. if (tokenValue === 'set' && !match('(')) {
  64601. key = parseObjectPropertyKey();
  64602. expect('(');
  64603. token = lookahead;
  64604. param = [ parseTypeAnnotatableIdentifier() ];
  64605. expect(')');
  64606. if (match(':')) {
  64607. returnType = parseTypeAnnotation();
  64608. }
  64609. return delegate.createMethodDefinition(
  64610. propType,
  64611. 'set',
  64612. key,
  64613. parsePropertyFunction({
  64614. params: param,
  64615. generator: false,
  64616. name: token,
  64617. returnType: returnType
  64618. }),
  64619. computed
  64620. );
  64621. }
  64622. if (match('<')) {
  64623. typeParameters = parseTypeParameterDeclaration();
  64624. }
  64625. isAsync = tokenValue === 'async' && !match('(');
  64626. if (isAsync) {
  64627. key = parseObjectPropertyKey();
  64628. }
  64629. return delegate.createMethodDefinition(
  64630. propType,
  64631. '',
  64632. key,
  64633. parsePropertyMethodFunction({
  64634. generator: false,
  64635. async: isAsync,
  64636. typeParameters: typeParameters
  64637. }),
  64638. computed
  64639. );
  64640. }
  64641. function parseClassProperty(key, computed, isStatic) {
  64642. var typeAnnotation;
  64643. typeAnnotation = parseTypeAnnotation();
  64644. expect(';');
  64645. return delegate.createClassProperty(
  64646. key,
  64647. typeAnnotation,
  64648. computed,
  64649. isStatic
  64650. );
  64651. }
  64652. function parseClassElement() {
  64653. var computed = false, generator = false, key, marker = markerCreate(),
  64654. isStatic = false, possiblyOpenBracketToken;
  64655. if (match(';')) {
  64656. lex();
  64657. return undefined;
  64658. }
  64659. if (lookahead.value === 'static') {
  64660. lex();
  64661. isStatic = true;
  64662. }
  64663. if (match('*')) {
  64664. lex();
  64665. generator = true;
  64666. }
  64667. possiblyOpenBracketToken = lookahead;
  64668. if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
  64669. possiblyOpenBracketToken = lookahead2();
  64670. }
  64671. if (possiblyOpenBracketToken.type === Token.Punctuator
  64672. && possiblyOpenBracketToken.value === '[') {
  64673. computed = true;
  64674. }
  64675. key = parseObjectPropertyKey();
  64676. if (!generator && lookahead.value === ':') {
  64677. return markerApply(marker, parseClassProperty(key, computed, isStatic));
  64678. }
  64679. return markerApply(marker, parseMethodDefinition(
  64680. key,
  64681. isStatic,
  64682. generator,
  64683. computed
  64684. ));
  64685. }
  64686. function parseClassBody() {
  64687. var classElement, classElements = [], existingProps = {},
  64688. marker = markerCreate(), propName, propType;
  64689. existingProps[ClassPropertyType.static] = new StringMap();
  64690. existingProps[ClassPropertyType.prototype] = new StringMap();
  64691. expect('{');
  64692. while (index < length) {
  64693. if (match('}')) {
  64694. break;
  64695. }
  64696. classElement = parseClassElement(existingProps);
  64697. if (typeof classElement !== 'undefined') {
  64698. classElements.push(classElement);
  64699. propName = !classElement.computed && getFieldName(classElement.key);
  64700. if (propName !== false) {
  64701. propType = classElement.static ?
  64702. ClassPropertyType.static :
  64703. ClassPropertyType.prototype;
  64704. if (classElement.type === Syntax.MethodDefinition) {
  64705. if (propName === 'constructor' && !classElement.static) {
  64706. if (specialMethod(classElement)) {
  64707. throwError(classElement, Messages.IllegalClassConstructorProperty);
  64708. }
  64709. if (existingProps[ClassPropertyType.prototype].has('constructor')) {
  64710. throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
  64711. }
  64712. }
  64713. existingProps[propType].set(propName, true);
  64714. }
  64715. }
  64716. }
  64717. }
  64718. expect('}');
  64719. return markerApply(marker, delegate.createClassBody(classElements));
  64720. }
  64721. function parseClassImplements() {
  64722. var id, implemented = [], marker, typeParameters;
  64723. if (strict) {
  64724. expectKeyword('implements');
  64725. } else {
  64726. expectContextualKeyword('implements');
  64727. }
  64728. while (index < length) {
  64729. marker = markerCreate();
  64730. id = parseVariableIdentifier();
  64731. if (match('<')) {
  64732. typeParameters = parseTypeParameterInstantiation();
  64733. } else {
  64734. typeParameters = null;
  64735. }
  64736. implemented.push(markerApply(marker, delegate.createClassImplements(
  64737. id,
  64738. typeParameters
  64739. )));
  64740. if (!match(',')) {
  64741. break;
  64742. }
  64743. expect(',');
  64744. }
  64745. return implemented;
  64746. }
  64747. function parseClassExpression() {
  64748. var id, implemented, previousYieldAllowed, superClass = null,
  64749. superTypeParameters, marker = markerCreate(), typeParameters,
  64750. matchImplements;
  64751. expectKeyword('class');
  64752. matchImplements =
  64753. strict
  64754. ? matchKeyword('implements')
  64755. : matchContextualKeyword('implements');
  64756. if (!matchKeyword('extends') && !matchImplements && !match('{')) {
  64757. id = parseVariableIdentifier();
  64758. }
  64759. if (match('<')) {
  64760. typeParameters = parseTypeParameterDeclaration();
  64761. }
  64762. if (matchKeyword('extends')) {
  64763. expectKeyword('extends');
  64764. previousYieldAllowed = state.yieldAllowed;
  64765. state.yieldAllowed = false;
  64766. superClass = parseLeftHandSideExpressionAllowCall();
  64767. if (match('<')) {
  64768. superTypeParameters = parseTypeParameterInstantiation();
  64769. }
  64770. state.yieldAllowed = previousYieldAllowed;
  64771. }
  64772. if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
  64773. implemented = parseClassImplements();
  64774. }
  64775. return markerApply(marker, delegate.createClassExpression(
  64776. id,
  64777. superClass,
  64778. parseClassBody(),
  64779. typeParameters,
  64780. superTypeParameters,
  64781. implemented
  64782. ));
  64783. }
  64784. function parseClassDeclaration() {
  64785. var id, implemented, previousYieldAllowed, superClass = null,
  64786. superTypeParameters, marker = markerCreate(), typeParameters;
  64787. expectKeyword('class');
  64788. id = parseVariableIdentifier();
  64789. if (match('<')) {
  64790. typeParameters = parseTypeParameterDeclaration();
  64791. }
  64792. if (matchKeyword('extends')) {
  64793. expectKeyword('extends');
  64794. previousYieldAllowed = state.yieldAllowed;
  64795. state.yieldAllowed = false;
  64796. superClass = parseLeftHandSideExpressionAllowCall();
  64797. if (match('<')) {
  64798. superTypeParameters = parseTypeParameterInstantiation();
  64799. }
  64800. state.yieldAllowed = previousYieldAllowed;
  64801. }
  64802. if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
  64803. implemented = parseClassImplements();
  64804. }
  64805. return markerApply(marker, delegate.createClassDeclaration(
  64806. id,
  64807. superClass,
  64808. parseClassBody(),
  64809. typeParameters,
  64810. superTypeParameters,
  64811. implemented
  64812. ));
  64813. }
  64814. // 15 Program
  64815. function parseSourceElement() {
  64816. var token;
  64817. if (lookahead.type === Token.Keyword) {
  64818. switch (lookahead.value) {
  64819. case 'const':
  64820. case 'let':
  64821. return parseConstLetDeclaration(lookahead.value);
  64822. case 'function':
  64823. return parseFunctionDeclaration();
  64824. case 'export':
  64825. throwErrorTolerant({}, Messages.IllegalExportDeclaration);
  64826. return parseExportDeclaration();
  64827. case 'import':
  64828. throwErrorTolerant({}, Messages.IllegalImportDeclaration);
  64829. return parseImportDeclaration();
  64830. case 'interface':
  64831. if (lookahead2().type === Token.Identifier) {
  64832. return parseInterface();
  64833. }
  64834. return parseStatement();
  64835. default:
  64836. return parseStatement();
  64837. }
  64838. }
  64839. if (matchContextualKeyword('type')
  64840. && lookahead2().type === Token.Identifier) {
  64841. return parseTypeAlias();
  64842. }
  64843. if (matchContextualKeyword('interface')
  64844. && lookahead2().type === Token.Identifier) {
  64845. return parseInterface();
  64846. }
  64847. if (matchContextualKeyword('declare')) {
  64848. token = lookahead2();
  64849. if (token.type === Token.Keyword) {
  64850. switch (token.value) {
  64851. case 'class':
  64852. return parseDeclareClass();
  64853. case 'function':
  64854. return parseDeclareFunction();
  64855. case 'var':
  64856. return parseDeclareVariable();
  64857. }
  64858. } else if (token.type === Token.Identifier
  64859. && token.value === 'module') {
  64860. return parseDeclareModule();
  64861. }
  64862. }
  64863. if (lookahead.type !== Token.EOF) {
  64864. return parseStatement();
  64865. }
  64866. }
  64867. function parseProgramElement() {
  64868. var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
  64869. if (isModule && lookahead.type === Token.Keyword) {
  64870. switch (lookahead.value) {
  64871. case 'export':
  64872. return parseExportDeclaration();
  64873. case 'import':
  64874. return parseImportDeclaration();
  64875. }
  64876. }
  64877. return parseSourceElement();
  64878. }
  64879. function parseProgramElements() {
  64880. var sourceElement, sourceElements = [], token, directive, firstRestricted;
  64881. while (index < length) {
  64882. token = lookahead;
  64883. if (token.type !== Token.StringLiteral) {
  64884. break;
  64885. }
  64886. sourceElement = parseProgramElement();
  64887. sourceElements.push(sourceElement);
  64888. if (sourceElement.expression.type !== Syntax.Literal) {
  64889. // this is not directive
  64890. break;
  64891. }
  64892. directive = source.slice(token.range[0] + 1, token.range[1] - 1);
  64893. if (directive === 'use strict') {
  64894. strict = true;
  64895. if (firstRestricted) {
  64896. throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
  64897. }
  64898. } else {
  64899. if (!firstRestricted && token.octal) {
  64900. firstRestricted = token;
  64901. }
  64902. }
  64903. }
  64904. while (index < length) {
  64905. sourceElement = parseProgramElement();
  64906. if (typeof sourceElement === 'undefined') {
  64907. break;
  64908. }
  64909. sourceElements.push(sourceElement);
  64910. }
  64911. return sourceElements;
  64912. }
  64913. function parseProgram() {
  64914. var body, marker = markerCreate();
  64915. strict = extra.sourceType === 'module';
  64916. peek();
  64917. body = parseProgramElements();
  64918. return markerApply(marker, delegate.createProgram(body));
  64919. }
  64920. // 16 JSX
  64921. XHTMLEntities = {
  64922. quot: '\u0022',
  64923. amp: '&',
  64924. apos: '\u0027',
  64925. lt: '<',
  64926. gt: '>',
  64927. nbsp: '\u00A0',
  64928. iexcl: '\u00A1',
  64929. cent: '\u00A2',
  64930. pound: '\u00A3',
  64931. curren: '\u00A4',
  64932. yen: '\u00A5',
  64933. brvbar: '\u00A6',
  64934. sect: '\u00A7',
  64935. uml: '\u00A8',
  64936. copy: '\u00A9',
  64937. ordf: '\u00AA',
  64938. laquo: '\u00AB',
  64939. not: '\u00AC',
  64940. shy: '\u00AD',
  64941. reg: '\u00AE',
  64942. macr: '\u00AF',
  64943. deg: '\u00B0',
  64944. plusmn: '\u00B1',
  64945. sup2: '\u00B2',
  64946. sup3: '\u00B3',
  64947. acute: '\u00B4',
  64948. micro: '\u00B5',
  64949. para: '\u00B6',
  64950. middot: '\u00B7',
  64951. cedil: '\u00B8',
  64952. sup1: '\u00B9',
  64953. ordm: '\u00BA',
  64954. raquo: '\u00BB',
  64955. frac14: '\u00BC',
  64956. frac12: '\u00BD',
  64957. frac34: '\u00BE',
  64958. iquest: '\u00BF',
  64959. Agrave: '\u00C0',
  64960. Aacute: '\u00C1',
  64961. Acirc: '\u00C2',
  64962. Atilde: '\u00C3',
  64963. Auml: '\u00C4',
  64964. Aring: '\u00C5',
  64965. AElig: '\u00C6',
  64966. Ccedil: '\u00C7',
  64967. Egrave: '\u00C8',
  64968. Eacute: '\u00C9',
  64969. Ecirc: '\u00CA',
  64970. Euml: '\u00CB',
  64971. Igrave: '\u00CC',
  64972. Iacute: '\u00CD',
  64973. Icirc: '\u00CE',
  64974. Iuml: '\u00CF',
  64975. ETH: '\u00D0',
  64976. Ntilde: '\u00D1',
  64977. Ograve: '\u00D2',
  64978. Oacute: '\u00D3',
  64979. Ocirc: '\u00D4',
  64980. Otilde: '\u00D5',
  64981. Ouml: '\u00D6',
  64982. times: '\u00D7',
  64983. Oslash: '\u00D8',
  64984. Ugrave: '\u00D9',
  64985. Uacute: '\u00DA',
  64986. Ucirc: '\u00DB',
  64987. Uuml: '\u00DC',
  64988. Yacute: '\u00DD',
  64989. THORN: '\u00DE',
  64990. szlig: '\u00DF',
  64991. agrave: '\u00E0',
  64992. aacute: '\u00E1',
  64993. acirc: '\u00E2',
  64994. atilde: '\u00E3',
  64995. auml: '\u00E4',
  64996. aring: '\u00E5',
  64997. aelig: '\u00E6',
  64998. ccedil: '\u00E7',
  64999. egrave: '\u00E8',
  65000. eacute: '\u00E9',
  65001. ecirc: '\u00EA',
  65002. euml: '\u00EB',
  65003. igrave: '\u00EC',
  65004. iacute: '\u00ED',
  65005. icirc: '\u00EE',
  65006. iuml: '\u00EF',
  65007. eth: '\u00F0',
  65008. ntilde: '\u00F1',
  65009. ograve: '\u00F2',
  65010. oacute: '\u00F3',
  65011. ocirc: '\u00F4',
  65012. otilde: '\u00F5',
  65013. ouml: '\u00F6',
  65014. divide: '\u00F7',
  65015. oslash: '\u00F8',
  65016. ugrave: '\u00F9',
  65017. uacute: '\u00FA',
  65018. ucirc: '\u00FB',
  65019. uuml: '\u00FC',
  65020. yacute: '\u00FD',
  65021. thorn: '\u00FE',
  65022. yuml: '\u00FF',
  65023. OElig: '\u0152',
  65024. oelig: '\u0153',
  65025. Scaron: '\u0160',
  65026. scaron: '\u0161',
  65027. Yuml: '\u0178',
  65028. fnof: '\u0192',
  65029. circ: '\u02C6',
  65030. tilde: '\u02DC',
  65031. Alpha: '\u0391',
  65032. Beta: '\u0392',
  65033. Gamma: '\u0393',
  65034. Delta: '\u0394',
  65035. Epsilon: '\u0395',
  65036. Zeta: '\u0396',
  65037. Eta: '\u0397',
  65038. Theta: '\u0398',
  65039. Iota: '\u0399',
  65040. Kappa: '\u039A',
  65041. Lambda: '\u039B',
  65042. Mu: '\u039C',
  65043. Nu: '\u039D',
  65044. Xi: '\u039E',
  65045. Omicron: '\u039F',
  65046. Pi: '\u03A0',
  65047. Rho: '\u03A1',
  65048. Sigma: '\u03A3',
  65049. Tau: '\u03A4',
  65050. Upsilon: '\u03A5',
  65051. Phi: '\u03A6',
  65052. Chi: '\u03A7',
  65053. Psi: '\u03A8',
  65054. Omega: '\u03A9',
  65055. alpha: '\u03B1',
  65056. beta: '\u03B2',
  65057. gamma: '\u03B3',
  65058. delta: '\u03B4',
  65059. epsilon: '\u03B5',
  65060. zeta: '\u03B6',
  65061. eta: '\u03B7',
  65062. theta: '\u03B8',
  65063. iota: '\u03B9',
  65064. kappa: '\u03BA',
  65065. lambda: '\u03BB',
  65066. mu: '\u03BC',
  65067. nu: '\u03BD',
  65068. xi: '\u03BE',
  65069. omicron: '\u03BF',
  65070. pi: '\u03C0',
  65071. rho: '\u03C1',
  65072. sigmaf: '\u03C2',
  65073. sigma: '\u03C3',
  65074. tau: '\u03C4',
  65075. upsilon: '\u03C5',
  65076. phi: '\u03C6',
  65077. chi: '\u03C7',
  65078. psi: '\u03C8',
  65079. omega: '\u03C9',
  65080. thetasym: '\u03D1',
  65081. upsih: '\u03D2',
  65082. piv: '\u03D6',
  65083. ensp: '\u2002',
  65084. emsp: '\u2003',
  65085. thinsp: '\u2009',
  65086. zwnj: '\u200C',
  65087. zwj: '\u200D',
  65088. lrm: '\u200E',
  65089. rlm: '\u200F',
  65090. ndash: '\u2013',
  65091. mdash: '\u2014',
  65092. lsquo: '\u2018',
  65093. rsquo: '\u2019',
  65094. sbquo: '\u201A',
  65095. ldquo: '\u201C',
  65096. rdquo: '\u201D',
  65097. bdquo: '\u201E',
  65098. dagger: '\u2020',
  65099. Dagger: '\u2021',
  65100. bull: '\u2022',
  65101. hellip: '\u2026',
  65102. permil: '\u2030',
  65103. prime: '\u2032',
  65104. Prime: '\u2033',
  65105. lsaquo: '\u2039',
  65106. rsaquo: '\u203A',
  65107. oline: '\u203E',
  65108. frasl: '\u2044',
  65109. euro: '\u20AC',
  65110. image: '\u2111',
  65111. weierp: '\u2118',
  65112. real: '\u211C',
  65113. trade: '\u2122',
  65114. alefsym: '\u2135',
  65115. larr: '\u2190',
  65116. uarr: '\u2191',
  65117. rarr: '\u2192',
  65118. darr: '\u2193',
  65119. harr: '\u2194',
  65120. crarr: '\u21B5',
  65121. lArr: '\u21D0',
  65122. uArr: '\u21D1',
  65123. rArr: '\u21D2',
  65124. dArr: '\u21D3',
  65125. hArr: '\u21D4',
  65126. forall: '\u2200',
  65127. part: '\u2202',
  65128. exist: '\u2203',
  65129. empty: '\u2205',
  65130. nabla: '\u2207',
  65131. isin: '\u2208',
  65132. notin: '\u2209',
  65133. ni: '\u220B',
  65134. prod: '\u220F',
  65135. sum: '\u2211',
  65136. minus: '\u2212',
  65137. lowast: '\u2217',
  65138. radic: '\u221A',
  65139. prop: '\u221D',
  65140. infin: '\u221E',
  65141. ang: '\u2220',
  65142. and: '\u2227',
  65143. or: '\u2228',
  65144. cap: '\u2229',
  65145. cup: '\u222A',
  65146. 'int': '\u222B',
  65147. there4: '\u2234',
  65148. sim: '\u223C',
  65149. cong: '\u2245',
  65150. asymp: '\u2248',
  65151. ne: '\u2260',
  65152. equiv: '\u2261',
  65153. le: '\u2264',
  65154. ge: '\u2265',
  65155. sub: '\u2282',
  65156. sup: '\u2283',
  65157. nsub: '\u2284',
  65158. sube: '\u2286',
  65159. supe: '\u2287',
  65160. oplus: '\u2295',
  65161. otimes: '\u2297',
  65162. perp: '\u22A5',
  65163. sdot: '\u22C5',
  65164. lceil: '\u2308',
  65165. rceil: '\u2309',
  65166. lfloor: '\u230A',
  65167. rfloor: '\u230B',
  65168. lang: '\u2329',
  65169. rang: '\u232A',
  65170. loz: '\u25CA',
  65171. spades: '\u2660',
  65172. clubs: '\u2663',
  65173. hearts: '\u2665',
  65174. diams: '\u2666'
  65175. };
  65176. function getQualifiedJSXName(object) {
  65177. if (object.type === Syntax.JSXIdentifier) {
  65178. return object.name;
  65179. }
  65180. if (object.type === Syntax.JSXNamespacedName) {
  65181. return object.namespace.name + ':' + object.name.name;
  65182. }
  65183. /* istanbul ignore else */
  65184. if (object.type === Syntax.JSXMemberExpression) {
  65185. return (
  65186. getQualifiedJSXName(object.object) + '.' +
  65187. getQualifiedJSXName(object.property)
  65188. );
  65189. }
  65190. /* istanbul ignore next */
  65191. throwUnexpected(object);
  65192. }
  65193. function isJSXIdentifierStart(ch) {
  65194. // exclude backslash (\)
  65195. return (ch !== 92) && isIdentifierStart(ch);
  65196. }
  65197. function isJSXIdentifierPart(ch) {
  65198. // exclude backslash (\) and add hyphen (-)
  65199. return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
  65200. }
  65201. function scanJSXIdentifier() {
  65202. var ch, start, value = '';
  65203. start = index;
  65204. while (index < length) {
  65205. ch = source.charCodeAt(index);
  65206. if (!isJSXIdentifierPart(ch)) {
  65207. break;
  65208. }
  65209. value += source[index++];
  65210. }
  65211. return {
  65212. type: Token.JSXIdentifier,
  65213. value: value,
  65214. lineNumber: lineNumber,
  65215. lineStart: lineStart,
  65216. range: [start, index]
  65217. };
  65218. }
  65219. function scanJSXEntity() {
  65220. var ch, str = '', start = index, count = 0, code;
  65221. ch = source[index];
  65222. assert(ch === '&', 'Entity must start with an ampersand');
  65223. index++;
  65224. while (index < length && count++ < 10) {
  65225. ch = source[index++];
  65226. if (ch === ';') {
  65227. break;
  65228. }
  65229. str += ch;
  65230. }
  65231. // Well-formed entity (ending was found).
  65232. if (ch === ';') {
  65233. // Numeric entity.
  65234. if (str[0] === '#') {
  65235. if (str[1] === 'x') {
  65236. code = +('0' + str.substr(1));
  65237. } else {
  65238. // Removing leading zeros in order to avoid treating as octal in old browsers.
  65239. code = +str.substr(1).replace(Regex.LeadingZeros, '');
  65240. }
  65241. if (!isNaN(code)) {
  65242. return String.fromCharCode(code);
  65243. }
  65244. /* istanbul ignore else */
  65245. } else if (XHTMLEntities[str]) {
  65246. return XHTMLEntities[str];
  65247. }
  65248. }
  65249. // Treat non-entity sequences as regular text.
  65250. index = start + 1;
  65251. return '&';
  65252. }
  65253. function scanJSXText(stopChars) {
  65254. var ch, str = '', start;
  65255. start = index;
  65256. while (index < length) {
  65257. ch = source[index];
  65258. if (stopChars.indexOf(ch) !== -1) {
  65259. break;
  65260. }
  65261. if (ch === '&') {
  65262. str += scanJSXEntity();
  65263. } else {
  65264. index++;
  65265. if (ch === '\r' && source[index] === '\n') {
  65266. str += ch;
  65267. ch = source[index];
  65268. index++;
  65269. }
  65270. if (isLineTerminator(ch.charCodeAt(0))) {
  65271. ++lineNumber;
  65272. lineStart = index;
  65273. }
  65274. str += ch;
  65275. }
  65276. }
  65277. return {
  65278. type: Token.JSXText,
  65279. value: str,
  65280. lineNumber: lineNumber,
  65281. lineStart: lineStart,
  65282. range: [start, index]
  65283. };
  65284. }
  65285. function scanJSXStringLiteral() {
  65286. var innerToken, quote, start;
  65287. quote = source[index];
  65288. assert((quote === '\'' || quote === '"'),
  65289. 'String literal must starts with a quote');
  65290. start = index;
  65291. ++index;
  65292. innerToken = scanJSXText([quote]);
  65293. if (quote !== source[index]) {
  65294. throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
  65295. }
  65296. ++index;
  65297. innerToken.range = [start, index];
  65298. return innerToken;
  65299. }
  65300. /**
  65301. * Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
  65302. * is not another JSX tag and is not an expression wrapped by {} is text.
  65303. */
  65304. function advanceJSXChild() {
  65305. var ch = source.charCodeAt(index);
  65306. // '<' 60, '>' 62, '{' 123, '}' 125
  65307. if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
  65308. return scanJSXText(['<', '>', '{', '}']);
  65309. }
  65310. return scanPunctuator();
  65311. }
  65312. function parseJSXIdentifier() {
  65313. var token, marker = markerCreate();
  65314. if (lookahead.type !== Token.JSXIdentifier) {
  65315. throwUnexpected(lookahead);
  65316. }
  65317. token = lex();
  65318. return markerApply(marker, delegate.createJSXIdentifier(token.value));
  65319. }
  65320. function parseJSXNamespacedName() {
  65321. var namespace, name, marker = markerCreate();
  65322. namespace = parseJSXIdentifier();
  65323. expect(':');
  65324. name = parseJSXIdentifier();
  65325. return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
  65326. }
  65327. function parseJSXMemberExpression() {
  65328. var marker = markerCreate(),
  65329. expr = parseJSXIdentifier();
  65330. while (match('.')) {
  65331. lex();
  65332. expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
  65333. }
  65334. return expr;
  65335. }
  65336. function parseJSXElementName() {
  65337. if (lookahead2().value === ':') {
  65338. return parseJSXNamespacedName();
  65339. }
  65340. if (lookahead2().value === '.') {
  65341. return parseJSXMemberExpression();
  65342. }
  65343. return parseJSXIdentifier();
  65344. }
  65345. function parseJSXAttributeName() {
  65346. if (lookahead2().value === ':') {
  65347. return parseJSXNamespacedName();
  65348. }
  65349. return parseJSXIdentifier();
  65350. }
  65351. function parseJSXAttributeValue() {
  65352. var value, marker;
  65353. if (match('{')) {
  65354. value = parseJSXExpressionContainer();
  65355. if (value.expression.type === Syntax.JSXEmptyExpression) {
  65356. throwError(
  65357. value,
  65358. 'JSX attributes must only be assigned a non-empty ' +
  65359. 'expression'
  65360. );
  65361. }
  65362. } else if (match('<')) {
  65363. value = parseJSXElement();
  65364. } else if (lookahead.type === Token.JSXText) {
  65365. marker = markerCreate();
  65366. value = markerApply(marker, delegate.createLiteral(lex()));
  65367. } else {
  65368. throwError({}, Messages.InvalidJSXAttributeValue);
  65369. }
  65370. return value;
  65371. }
  65372. function parseJSXEmptyExpression() {
  65373. var ch, marker = markerCreatePreserveWhitespace();
  65374. while (index < length) {
  65375. ch = source.charCodeAt(index);
  65376. if (ch === 125) {
  65377. break;
  65378. } else if (isLineTerminator(ch)) {
  65379. if (ch === 13 && source.charCodeAt(index + 1) === 10) {
  65380. ++index;
  65381. }
  65382. ++lineNumber;
  65383. lineStart = index;
  65384. }
  65385. ++index;
  65386. }
  65387. return markerApply(marker, delegate.createJSXEmptyExpression());
  65388. }
  65389. function parseJSXExpressionContainer() {
  65390. var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
  65391. origInJSXChild = state.inJSXChild;
  65392. origInJSXTag = state.inJSXTag;
  65393. state.inJSXChild = false;
  65394. state.inJSXTag = false;
  65395. expect('{');
  65396. if (match('}')) {
  65397. expression = parseJSXEmptyExpression();
  65398. } else {
  65399. expression = parseExpression();
  65400. }
  65401. state.inJSXChild = origInJSXChild;
  65402. state.inJSXTag = origInJSXTag;
  65403. expect('}');
  65404. return markerApply(marker, delegate.createJSXExpressionContainer(expression));
  65405. }
  65406. function parseJSXSpreadAttribute() {
  65407. var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
  65408. origInJSXChild = state.inJSXChild;
  65409. origInJSXTag = state.inJSXTag;
  65410. state.inJSXChild = false;
  65411. state.inJSXTag = false;
  65412. expect('{');
  65413. expect('...');
  65414. expression = parseAssignmentExpression();
  65415. state.inJSXChild = origInJSXChild;
  65416. state.inJSXTag = origInJSXTag;
  65417. expect('}');
  65418. return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
  65419. }
  65420. function parseJSXAttribute() {
  65421. var name, marker;
  65422. if (match('{')) {
  65423. return parseJSXSpreadAttribute();
  65424. }
  65425. marker = markerCreate();
  65426. name = parseJSXAttributeName();
  65427. // HTML empty attribute
  65428. if (match('=')) {
  65429. lex();
  65430. return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
  65431. }
  65432. return markerApply(marker, delegate.createJSXAttribute(name));
  65433. }
  65434. function parseJSXChild() {
  65435. var token, marker;
  65436. if (match('{')) {
  65437. token = parseJSXExpressionContainer();
  65438. } else if (lookahead.type === Token.JSXText) {
  65439. marker = markerCreatePreserveWhitespace();
  65440. token = markerApply(marker, delegate.createLiteral(lex()));
  65441. } else if (match('<')) {
  65442. token = parseJSXElement();
  65443. } else {
  65444. throwUnexpected(lookahead);
  65445. }
  65446. return token;
  65447. }
  65448. function parseJSXClosingElement() {
  65449. var name, origInJSXChild, origInJSXTag, marker = markerCreate();
  65450. origInJSXChild = state.inJSXChild;
  65451. origInJSXTag = state.inJSXTag;
  65452. state.inJSXChild = false;
  65453. state.inJSXTag = true;
  65454. expect('<');
  65455. expect('/');
  65456. name = parseJSXElementName();
  65457. // Because advance() (called by lex() called by expect()) expects there
  65458. // to be a valid token after >, it needs to know whether to look for a
  65459. // standard JS token or an JSX text node
  65460. state.inJSXChild = origInJSXChild;
  65461. state.inJSXTag = origInJSXTag;
  65462. expect('>');
  65463. return markerApply(marker, delegate.createJSXClosingElement(name));
  65464. }
  65465. function parseJSXOpeningElement() {
  65466. var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
  65467. origInJSXChild = state.inJSXChild;
  65468. origInJSXTag = state.inJSXTag;
  65469. state.inJSXChild = false;
  65470. state.inJSXTag = true;
  65471. expect('<');
  65472. name = parseJSXElementName();
  65473. while (index < length &&
  65474. lookahead.value !== '/' &&
  65475. lookahead.value !== '>') {
  65476. attributes.push(parseJSXAttribute());
  65477. }
  65478. state.inJSXTag = origInJSXTag;
  65479. if (lookahead.value === '/') {
  65480. expect('/');
  65481. // Because advance() (called by lex() called by expect()) expects
  65482. // there to be a valid token after >, it needs to know whether to
  65483. // look for a standard JS token or an JSX text node
  65484. state.inJSXChild = origInJSXChild;
  65485. expect('>');
  65486. selfClosing = true;
  65487. } else {
  65488. state.inJSXChild = true;
  65489. expect('>');
  65490. }
  65491. return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
  65492. }
  65493. function parseJSXElement() {
  65494. var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
  65495. origInJSXChild = state.inJSXChild;
  65496. origInJSXTag = state.inJSXTag;
  65497. openingElement = parseJSXOpeningElement();
  65498. if (!openingElement.selfClosing) {
  65499. while (index < length) {
  65500. state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
  65501. if (lookahead.value === '<' && lookahead2().value === '/') {
  65502. break;
  65503. }
  65504. state.inJSXChild = true;
  65505. children.push(parseJSXChild());
  65506. }
  65507. state.inJSXChild = origInJSXChild;
  65508. state.inJSXTag = origInJSXTag;
  65509. closingElement = parseJSXClosingElement();
  65510. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  65511. throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
  65512. }
  65513. }
  65514. // When (erroneously) writing two adjacent tags like
  65515. //
  65516. // var x = <div>one</div><div>two</div>;
  65517. //
  65518. // the default error message is a bit incomprehensible. Since it's
  65519. // rarely (never?) useful to write a less-than sign after an JSX
  65520. // element, we disallow it here in the parser in order to provide a
  65521. // better error message. (In the rare case that the less-than operator
  65522. // was intended, the left tag can be wrapped in parentheses.)
  65523. if (!origInJSXChild && match('<')) {
  65524. throwError(lookahead, Messages.AdjacentJSXElements);
  65525. }
  65526. return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
  65527. }
  65528. function parseTypeAlias() {
  65529. var id, marker = markerCreate(), typeParameters = null, right;
  65530. expectContextualKeyword('type');
  65531. id = parseVariableIdentifier();
  65532. if (match('<')) {
  65533. typeParameters = parseTypeParameterDeclaration();
  65534. }
  65535. expect('=');
  65536. right = parseType();
  65537. consumeSemicolon();
  65538. return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
  65539. }
  65540. function parseInterfaceExtends() {
  65541. var marker = markerCreate(), id, typeParameters = null;
  65542. id = parseVariableIdentifier();
  65543. if (match('<')) {
  65544. typeParameters = parseTypeParameterInstantiation();
  65545. }
  65546. return markerApply(marker, delegate.createInterfaceExtends(
  65547. id,
  65548. typeParameters
  65549. ));
  65550. }
  65551. function parseInterfaceish(marker, allowStatic) {
  65552. var body, bodyMarker, extended = [], id,
  65553. typeParameters = null;
  65554. id = parseVariableIdentifier();
  65555. if (match('<')) {
  65556. typeParameters = parseTypeParameterDeclaration();
  65557. }
  65558. if (matchKeyword('extends')) {
  65559. expectKeyword('extends');
  65560. while (index < length) {
  65561. extended.push(parseInterfaceExtends());
  65562. if (!match(',')) {
  65563. break;
  65564. }
  65565. expect(',');
  65566. }
  65567. }
  65568. bodyMarker = markerCreate();
  65569. body = markerApply(bodyMarker, parseObjectType(allowStatic));
  65570. return markerApply(marker, delegate.createInterface(
  65571. id,
  65572. typeParameters,
  65573. body,
  65574. extended
  65575. ));
  65576. }
  65577. function parseInterface() {
  65578. var marker = markerCreate();
  65579. if (strict) {
  65580. expectKeyword('interface');
  65581. } else {
  65582. expectContextualKeyword('interface');
  65583. }
  65584. return parseInterfaceish(marker, /* allowStatic */false);
  65585. }
  65586. function parseDeclareClass() {
  65587. var marker = markerCreate(), ret;
  65588. expectContextualKeyword('declare');
  65589. expectKeyword('class');
  65590. ret = parseInterfaceish(marker, /* allowStatic */true);
  65591. ret.type = Syntax.DeclareClass;
  65592. return ret;
  65593. }
  65594. function parseDeclareFunction() {
  65595. var id, idMarker,
  65596. marker = markerCreate(), params, returnType, rest, tmp,
  65597. typeParameters = null, value, valueMarker;
  65598. expectContextualKeyword('declare');
  65599. expectKeyword('function');
  65600. idMarker = markerCreate();
  65601. id = parseVariableIdentifier();
  65602. valueMarker = markerCreate();
  65603. if (match('<')) {
  65604. typeParameters = parseTypeParameterDeclaration();
  65605. }
  65606. expect('(');
  65607. tmp = parseFunctionTypeParams();
  65608. params = tmp.params;
  65609. rest = tmp.rest;
  65610. expect(')');
  65611. expect(':');
  65612. returnType = parseType();
  65613. value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
  65614. params,
  65615. returnType,
  65616. rest,
  65617. typeParameters
  65618. ));
  65619. id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
  65620. value
  65621. ));
  65622. markerApply(idMarker, id);
  65623. consumeSemicolon();
  65624. return markerApply(marker, delegate.createDeclareFunction(
  65625. id
  65626. ));
  65627. }
  65628. function parseDeclareVariable() {
  65629. var id, marker = markerCreate();
  65630. expectContextualKeyword('declare');
  65631. expectKeyword('var');
  65632. id = parseTypeAnnotatableIdentifier();
  65633. consumeSemicolon();
  65634. return markerApply(marker, delegate.createDeclareVariable(
  65635. id
  65636. ));
  65637. }
  65638. function parseDeclareModule() {
  65639. var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
  65640. expectContextualKeyword('declare');
  65641. expectContextualKeyword('module');
  65642. if (lookahead.type === Token.StringLiteral) {
  65643. if (strict && lookahead.octal) {
  65644. throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
  65645. }
  65646. idMarker = markerCreate();
  65647. id = markerApply(idMarker, delegate.createLiteral(lex()));
  65648. } else {
  65649. id = parseVariableIdentifier();
  65650. }
  65651. bodyMarker = markerCreate();
  65652. expect('{');
  65653. while (index < length && !match('}')) {
  65654. token = lookahead2();
  65655. switch (token.value) {
  65656. case 'class':
  65657. body.push(parseDeclareClass());
  65658. break;
  65659. case 'function':
  65660. body.push(parseDeclareFunction());
  65661. break;
  65662. case 'var':
  65663. body.push(parseDeclareVariable());
  65664. break;
  65665. default:
  65666. throwUnexpected(lookahead);
  65667. }
  65668. }
  65669. expect('}');
  65670. return markerApply(marker, delegate.createDeclareModule(
  65671. id,
  65672. markerApply(bodyMarker, delegate.createBlockStatement(body))
  65673. ));
  65674. }
  65675. function collectToken() {
  65676. var loc, token, range, value, entry;
  65677. /* istanbul ignore else */
  65678. if (!state.inJSXChild) {
  65679. skipComment();
  65680. }
  65681. loc = {
  65682. start: {
  65683. line: lineNumber,
  65684. column: index - lineStart
  65685. }
  65686. };
  65687. token = extra.advance();
  65688. loc.end = {
  65689. line: lineNumber,
  65690. column: index - lineStart
  65691. };
  65692. if (token.type !== Token.EOF) {
  65693. range = [token.range[0], token.range[1]];
  65694. value = source.slice(token.range[0], token.range[1]);
  65695. entry = {
  65696. type: TokenName[token.type],
  65697. value: value,
  65698. range: range,
  65699. loc: loc
  65700. };
  65701. if (token.regex) {
  65702. entry.regex = {
  65703. pattern: token.regex.pattern,
  65704. flags: token.regex.flags
  65705. };
  65706. }
  65707. extra.tokens.push(entry);
  65708. }
  65709. return token;
  65710. }
  65711. function collectRegex() {
  65712. var pos, loc, regex, token;
  65713. skipComment();
  65714. pos = index;
  65715. loc = {
  65716. start: {
  65717. line: lineNumber,
  65718. column: index - lineStart
  65719. }
  65720. };
  65721. regex = extra.scanRegExp();
  65722. loc.end = {
  65723. line: lineNumber,
  65724. column: index - lineStart
  65725. };
  65726. if (!extra.tokenize) {
  65727. /* istanbul ignore next */
  65728. // Pop the previous token, which is likely '/' or '/='
  65729. if (extra.tokens.length > 0) {
  65730. token = extra.tokens[extra.tokens.length - 1];
  65731. if (token.range[0] === pos && token.type === 'Punctuator') {
  65732. if (token.value === '/' || token.value === '/=') {
  65733. extra.tokens.pop();
  65734. }
  65735. }
  65736. }
  65737. extra.tokens.push({
  65738. type: 'RegularExpression',
  65739. value: regex.literal,
  65740. regex: regex.regex,
  65741. range: [pos, index],
  65742. loc: loc
  65743. });
  65744. }
  65745. return regex;
  65746. }
  65747. function filterTokenLocation() {
  65748. var i, entry, token, tokens = [];
  65749. for (i = 0; i < extra.tokens.length; ++i) {
  65750. entry = extra.tokens[i];
  65751. token = {
  65752. type: entry.type,
  65753. value: entry.value
  65754. };
  65755. if (entry.regex) {
  65756. token.regex = {
  65757. pattern: entry.regex.pattern,
  65758. flags: entry.regex.flags
  65759. };
  65760. }
  65761. if (extra.range) {
  65762. token.range = entry.range;
  65763. }
  65764. if (extra.loc) {
  65765. token.loc = entry.loc;
  65766. }
  65767. tokens.push(token);
  65768. }
  65769. extra.tokens = tokens;
  65770. }
  65771. function patch() {
  65772. if (typeof extra.tokens !== 'undefined') {
  65773. extra.advance = advance;
  65774. extra.scanRegExp = scanRegExp;
  65775. advance = collectToken;
  65776. scanRegExp = collectRegex;
  65777. }
  65778. }
  65779. function unpatch() {
  65780. if (typeof extra.scanRegExp === 'function') {
  65781. advance = extra.advance;
  65782. scanRegExp = extra.scanRegExp;
  65783. }
  65784. }
  65785. // This is used to modify the delegate.
  65786. function extend(object, properties) {
  65787. var entry, result = {};
  65788. for (entry in object) {
  65789. /* istanbul ignore else */
  65790. if (object.hasOwnProperty(entry)) {
  65791. result[entry] = object[entry];
  65792. }
  65793. }
  65794. for (entry in properties) {
  65795. /* istanbul ignore else */
  65796. if (properties.hasOwnProperty(entry)) {
  65797. result[entry] = properties[entry];
  65798. }
  65799. }
  65800. return result;
  65801. }
  65802. function tokenize(code, options) {
  65803. var toString,
  65804. token,
  65805. tokens;
  65806. toString = String;
  65807. if (typeof code !== 'string' && !(code instanceof String)) {
  65808. code = toString(code);
  65809. }
  65810. delegate = SyntaxTreeDelegate;
  65811. source = code;
  65812. index = 0;
  65813. lineNumber = (source.length > 0) ? 1 : 0;
  65814. lineStart = 0;
  65815. length = source.length;
  65816. lookahead = null;
  65817. state = {
  65818. allowKeyword: true,
  65819. allowIn: true,
  65820. labelSet: new StringMap(),
  65821. inFunctionBody: false,
  65822. inIteration: false,
  65823. inSwitch: false,
  65824. lastCommentStart: -1,
  65825. curlyStack: [],
  65826. curlyLastIndex: 0
  65827. };
  65828. extra = {};
  65829. // Options matching.
  65830. options = options || {};
  65831. // Of course we collect tokens here.
  65832. options.tokens = true;
  65833. extra.tokens = [];
  65834. extra.tokenize = true;
  65835. // The following two fields are necessary to compute the Regex tokens.
  65836. extra.openParenToken = -1;
  65837. extra.openCurlyToken = -1;
  65838. extra.range = (typeof options.range === 'boolean') && options.range;
  65839. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  65840. if (typeof options.comment === 'boolean' && options.comment) {
  65841. extra.comments = [];
  65842. }
  65843. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  65844. extra.errors = [];
  65845. }
  65846. patch();
  65847. try {
  65848. peek();
  65849. if (lookahead.type === Token.EOF) {
  65850. return extra.tokens;
  65851. }
  65852. token = lex();
  65853. while (lookahead.type !== Token.EOF) {
  65854. try {
  65855. token = lex();
  65856. } catch (lexError) {
  65857. token = lookahead;
  65858. if (extra.errors) {
  65859. extra.errors.push(lexError);
  65860. // We have to break on the first error
  65861. // to avoid infinite loops.
  65862. break;
  65863. } else {
  65864. throw lexError;
  65865. }
  65866. }
  65867. }
  65868. filterTokenLocation();
  65869. tokens = extra.tokens;
  65870. if (typeof extra.comments !== 'undefined') {
  65871. tokens.comments = extra.comments;
  65872. }
  65873. if (typeof extra.errors !== 'undefined') {
  65874. tokens.errors = extra.errors;
  65875. }
  65876. } catch (e) {
  65877. throw e;
  65878. } finally {
  65879. unpatch();
  65880. extra = {};
  65881. }
  65882. return tokens;
  65883. }
  65884. function parse(code, options) {
  65885. var program, toString;
  65886. toString = String;
  65887. if (typeof code !== 'string' && !(code instanceof String)) {
  65888. code = toString(code);
  65889. }
  65890. delegate = SyntaxTreeDelegate;
  65891. source = code;
  65892. index = 0;
  65893. lineNumber = (source.length > 0) ? 1 : 0;
  65894. lineStart = 0;
  65895. length = source.length;
  65896. lookahead = null;
  65897. state = {
  65898. allowKeyword: false,
  65899. allowIn: true,
  65900. labelSet: new StringMap(),
  65901. parenthesizedCount: 0,
  65902. inFunctionBody: false,
  65903. inIteration: false,
  65904. inSwitch: false,
  65905. inJSXChild: false,
  65906. inJSXTag: false,
  65907. inType: false,
  65908. lastCommentStart: -1,
  65909. yieldAllowed: false,
  65910. awaitAllowed: false,
  65911. curlyPosition: 0,
  65912. curlyStack: [],
  65913. curlyLastIndex: 0
  65914. };
  65915. extra = {};
  65916. if (typeof options !== 'undefined') {
  65917. extra.range = (typeof options.range === 'boolean') && options.range;
  65918. extra.loc = (typeof options.loc === 'boolean') && options.loc;
  65919. extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
  65920. if (extra.loc && options.source !== null && options.source !== undefined) {
  65921. delegate = extend(delegate, {
  65922. 'postProcess': function (node) {
  65923. node.loc.source = toString(options.source);
  65924. return node;
  65925. }
  65926. });
  65927. }
  65928. extra.sourceType = options.sourceType;
  65929. if (typeof options.tokens === 'boolean' && options.tokens) {
  65930. extra.tokens = [];
  65931. }
  65932. if (typeof options.comment === 'boolean' && options.comment) {
  65933. extra.comments = [];
  65934. }
  65935. if (typeof options.tolerant === 'boolean' && options.tolerant) {
  65936. extra.errors = [];
  65937. }
  65938. if (extra.attachComment) {
  65939. extra.range = true;
  65940. extra.comments = [];
  65941. extra.bottomRightStack = [];
  65942. extra.trailingComments = [];
  65943. extra.leadingComments = [];
  65944. }
  65945. }
  65946. patch();
  65947. try {
  65948. program = parseProgram();
  65949. if (typeof extra.comments !== 'undefined') {
  65950. program.comments = extra.comments;
  65951. }
  65952. if (typeof extra.tokens !== 'undefined') {
  65953. filterTokenLocation();
  65954. program.tokens = extra.tokens;
  65955. }
  65956. if (typeof extra.errors !== 'undefined') {
  65957. program.errors = extra.errors;
  65958. }
  65959. } catch (e) {
  65960. throw e;
  65961. } finally {
  65962. unpatch();
  65963. extra = {};
  65964. }
  65965. return program;
  65966. }
  65967. // Sync with *.json manifests.
  65968. exports.version = '14001.1.0-dev-harmony-fb';
  65969. exports.tokenize = tokenize;
  65970. exports.parse = parse;
  65971. // Deep copy.
  65972. /* istanbul ignore next */
  65973. exports.Syntax = (function () {
  65974. var name, types = {};
  65975. if (typeof Object.create === 'function') {
  65976. types = Object.create(null);
  65977. }
  65978. for (name in Syntax) {
  65979. if (Syntax.hasOwnProperty(name)) {
  65980. types[name] = Syntax[name];
  65981. }
  65982. }
  65983. if (typeof Object.freeze === 'function') {
  65984. Object.freeze(types);
  65985. }
  65986. return types;
  65987. }());
  65988. }));
  65989. /* vim: set sw=4 ts=4 et tw=80 : */
  65990. },{}],471:[function(require,module,exports){
  65991. (function (process){
  65992. var Stream = require('stream')
  65993. // through
  65994. //
  65995. // a stream that does nothing but re-emit the input.
  65996. // useful for aggregating a series of changing but not ending streams into one stream)
  65997. exports = module.exports = through
  65998. through.through = through
  65999. //create a readable writable stream.
  66000. function through (write, end, opts) {
  66001. write = write || function (data) { this.queue(data) }
  66002. end = end || function () { this.queue(null) }
  66003. var ended = false, destroyed = false, buffer = [], _ended = false
  66004. var stream = new Stream()
  66005. stream.readable = stream.writable = true
  66006. stream.paused = false
  66007. // stream.autoPause = !(opts && opts.autoPause === false)
  66008. stream.autoDestroy = !(opts && opts.autoDestroy === false)
  66009. stream.write = function (data) {
  66010. write.call(this, data)
  66011. return !stream.paused
  66012. }
  66013. function drain() {
  66014. while(buffer.length && !stream.paused) {
  66015. var data = buffer.shift()
  66016. if(null === data)
  66017. return stream.emit('end')
  66018. else
  66019. stream.emit('data', data)
  66020. }
  66021. }
  66022. stream.queue = stream.push = function (data) {
  66023. // console.error(ended)
  66024. if(_ended) return stream
  66025. if(data === null) _ended = true
  66026. buffer.push(data)
  66027. drain()
  66028. return stream
  66029. }
  66030. //this will be registered as the first 'end' listener
  66031. //must call destroy next tick, to make sure we're after any
  66032. //stream piped from here.
  66033. //this is only a problem if end is not emitted synchronously.
  66034. //a nicer way to do this is to make sure this is the last listener for 'end'
  66035. stream.on('end', function () {
  66036. stream.readable = false
  66037. if(!stream.writable && stream.autoDestroy)
  66038. process.nextTick(function () {
  66039. stream.destroy()
  66040. })
  66041. })
  66042. function _end () {
  66043. stream.writable = false
  66044. end.call(stream)
  66045. if(!stream.readable && stream.autoDestroy)
  66046. stream.destroy()
  66047. }
  66048. stream.end = function (data) {
  66049. if(ended) return
  66050. ended = true
  66051. if(arguments.length) stream.write(data)
  66052. _end() // will emit or queue
  66053. return stream
  66054. }
  66055. stream.destroy = function () {
  66056. if(destroyed) return
  66057. destroyed = true
  66058. ended = true
  66059. buffer.length = 0
  66060. stream.writable = stream.readable = false
  66061. stream.emit('close')
  66062. return stream
  66063. }
  66064. stream.pause = function () {
  66065. if(stream.paused) return
  66066. stream.paused = true
  66067. return stream
  66068. }
  66069. stream.resume = function () {
  66070. if(stream.paused) {
  66071. stream.paused = false
  66072. stream.emit('resume')
  66073. }
  66074. drain()
  66075. //may have become paused again,
  66076. //as drain emits 'data'.
  66077. if(!stream.paused)
  66078. stream.emit('drain')
  66079. return stream
  66080. }
  66081. return stream
  66082. }
  66083. }).call(this,require('_process'))
  66084. },{"_process":200,"stream":212}],472:[function(require,module,exports){
  66085. (function (global){
  66086. /**
  66087. * Copyright (c) 2014, Facebook, Inc.
  66088. * All rights reserved.
  66089. *
  66090. * This source code is licensed under the BSD-style license found in the
  66091. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  66092. * additional grant of patent rights can be found in the PATENTS file in
  66093. * the same directory.
  66094. */
  66095. !(function(global) {
  66096. "use strict";
  66097. var hasOwn = Object.prototype.hasOwnProperty;
  66098. var undefined; // More compressible than void 0.
  66099. var iteratorSymbol =
  66100. typeof Symbol === "function" && Symbol.iterator || "@@iterator";
  66101. var inModule = typeof module === "object";
  66102. var runtime = global.regeneratorRuntime;
  66103. if (runtime) {
  66104. if (inModule) {
  66105. // If regeneratorRuntime is defined globally and we're in a module,
  66106. // make the exports object identical to regeneratorRuntime.
  66107. module.exports = runtime;
  66108. }
  66109. // Don't bother evaluating the rest of this file if the runtime was
  66110. // already defined globally.
  66111. return;
  66112. }
  66113. // Define the runtime globally (as expected by generated code) as either
  66114. // module.exports (if we're in a module) or a new, empty object.
  66115. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  66116. function wrap(innerFn, outerFn, self, tryLocsList) {
  66117. // If outerFn provided, then outerFn.prototype instanceof Generator.
  66118. var generator = Object.create((outerFn || Generator).prototype);
  66119. generator._invoke = makeInvokeMethod(
  66120. innerFn, self || null,
  66121. new Context(tryLocsList || [])
  66122. );
  66123. return generator;
  66124. }
  66125. runtime.wrap = wrap;
  66126. // Try/catch helper to minimize deoptimizations. Returns a completion
  66127. // record like context.tryEntries[i].completion. This interface could
  66128. // have been (and was previously) designed to take a closure to be
  66129. // invoked without arguments, but in all the cases we care about we
  66130. // already have an existing method we want to call, so there's no need
  66131. // to create a new function object. We can even get away with assuming
  66132. // the method takes exactly one argument, since that happens to be true
  66133. // in every case, so we don't have to touch the arguments object. The
  66134. // only additional allocation required is the completion record, which
  66135. // has a stable shape and so hopefully should be cheap to allocate.
  66136. function tryCatch(fn, obj, arg) {
  66137. try {
  66138. return { type: "normal", arg: fn.call(obj, arg) };
  66139. } catch (err) {
  66140. return { type: "throw", arg: err };
  66141. }
  66142. }
  66143. var GenStateSuspendedStart = "suspendedStart";
  66144. var GenStateSuspendedYield = "suspendedYield";
  66145. var GenStateExecuting = "executing";
  66146. var GenStateCompleted = "completed";
  66147. // Returning this object from the innerFn has the same effect as
  66148. // breaking out of the dispatch switch statement.
  66149. var ContinueSentinel = {};
  66150. // Dummy constructor functions that we use as the .constructor and
  66151. // .constructor.prototype properties for functions that return Generator
  66152. // objects. For full spec compliance, you may wish to configure your
  66153. // minifier not to mangle the names of these two functions.
  66154. function Generator() {}
  66155. function GeneratorFunction() {}
  66156. function GeneratorFunctionPrototype() {}
  66157. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
  66158. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  66159. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  66160. GeneratorFunction.displayName = "GeneratorFunction";
  66161. runtime.isGeneratorFunction = function(genFun) {
  66162. var ctor = typeof genFun === "function" && genFun.constructor;
  66163. return ctor
  66164. ? ctor === GeneratorFunction ||
  66165. // For the native GeneratorFunction constructor, the best we can
  66166. // do is to check its .name property.
  66167. (ctor.displayName || ctor.name) === "GeneratorFunction"
  66168. : false;
  66169. };
  66170. runtime.mark = function(genFun) {
  66171. genFun.__proto__ = GeneratorFunctionPrototype;
  66172. genFun.prototype = Object.create(Gp);
  66173. return genFun;
  66174. };
  66175. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  66176. return new Promise(function(resolve, reject) {
  66177. var generator = wrap(innerFn, outerFn, self, tryLocsList);
  66178. var callNext = step.bind(generator, "next");
  66179. var callThrow = step.bind(generator, "throw");
  66180. function step(method, arg) {
  66181. var record = tryCatch(generator[method], generator, arg);
  66182. if (record.type === "throw") {
  66183. reject(record.arg);
  66184. return;
  66185. }
  66186. var info = record.arg;
  66187. if (info.done) {
  66188. resolve(info.value);
  66189. } else {
  66190. Promise.resolve(info.value).then(callNext, callThrow);
  66191. }
  66192. }
  66193. callNext();
  66194. });
  66195. };
  66196. function makeInvokeMethod(innerFn, self, context) {
  66197. var state = GenStateSuspendedStart;
  66198. return function invoke(method, arg) {
  66199. if (state === GenStateExecuting) {
  66200. throw new Error("Generator is already running");
  66201. }
  66202. if (state === GenStateCompleted) {
  66203. // Be forgiving, per 25.3.3.3.3 of the spec:
  66204. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  66205. return doneResult();
  66206. }
  66207. while (true) {
  66208. var delegate = context.delegate;
  66209. if (delegate) {
  66210. if (method === "return" ||
  66211. (method === "throw" && delegate.iterator[method] === undefined)) {
  66212. // A return or throw (when the delegate iterator has no throw
  66213. // method) always terminates the yield* loop.
  66214. context.delegate = null;
  66215. // If the delegate iterator has a return method, give it a
  66216. // chance to clean up.
  66217. var returnMethod = delegate.iterator["return"];
  66218. if (returnMethod) {
  66219. var record = tryCatch(returnMethod, delegate.iterator, arg);
  66220. if (record.type === "throw") {
  66221. // If the return method threw an exception, let that
  66222. // exception prevail over the original return or throw.
  66223. method = "throw";
  66224. arg = record.arg;
  66225. continue;
  66226. }
  66227. }
  66228. if (method === "return") {
  66229. // Continue with the outer return, now that the delegate
  66230. // iterator has been terminated.
  66231. continue;
  66232. }
  66233. }
  66234. var record = tryCatch(
  66235. delegate.iterator[method],
  66236. delegate.iterator,
  66237. arg
  66238. );
  66239. if (record.type === "throw") {
  66240. context.delegate = null;
  66241. // Like returning generator.throw(uncaught), but without the
  66242. // overhead of an extra function call.
  66243. method = "throw";
  66244. arg = record.arg;
  66245. continue;
  66246. }
  66247. // Delegate generator ran and handled its own exceptions so
  66248. // regardless of what the method was, we continue as if it is
  66249. // "next" with an undefined arg.
  66250. method = "next";
  66251. arg = undefined;
  66252. var info = record.arg;
  66253. if (info.done) {
  66254. context[delegate.resultName] = info.value;
  66255. context.next = delegate.nextLoc;
  66256. } else {
  66257. state = GenStateSuspendedYield;
  66258. return info;
  66259. }
  66260. context.delegate = null;
  66261. }
  66262. if (method === "next") {
  66263. if (state === GenStateSuspendedYield) {
  66264. context.sent = arg;
  66265. } else {
  66266. delete context.sent;
  66267. }
  66268. } else if (method === "throw") {
  66269. if (state === GenStateSuspendedStart) {
  66270. state = GenStateCompleted;
  66271. throw arg;
  66272. }
  66273. if (context.dispatchException(arg)) {
  66274. // If the dispatched exception was caught by a catch block,
  66275. // then let that catch block handle the exception normally.
  66276. method = "next";
  66277. arg = undefined;
  66278. }
  66279. } else if (method === "return") {
  66280. context.abrupt("return", arg);
  66281. }
  66282. state = GenStateExecuting;
  66283. var record = tryCatch(innerFn, self, context);
  66284. if (record.type === "normal") {
  66285. // If an exception is thrown from innerFn, we leave state ===
  66286. // GenStateExecuting and loop back for another invocation.
  66287. state = context.done
  66288. ? GenStateCompleted
  66289. : GenStateSuspendedYield;
  66290. var info = {
  66291. value: record.arg,
  66292. done: context.done
  66293. };
  66294. if (record.arg === ContinueSentinel) {
  66295. if (context.delegate && method === "next") {
  66296. // Deliberately forget the last sent value so that we don't
  66297. // accidentally pass it on to the delegate.
  66298. arg = undefined;
  66299. }
  66300. } else {
  66301. return info;
  66302. }
  66303. } else if (record.type === "throw") {
  66304. state = GenStateCompleted;
  66305. // Dispatch the exception by looping back around to the
  66306. // context.dispatchException(arg) call above.
  66307. method = "throw";
  66308. arg = record.arg;
  66309. }
  66310. }
  66311. };
  66312. }
  66313. function defineGeneratorMethod(method) {
  66314. Gp[method] = function(arg) {
  66315. return this._invoke(method, arg);
  66316. };
  66317. }
  66318. defineGeneratorMethod("next");
  66319. defineGeneratorMethod("throw");
  66320. defineGeneratorMethod("return");
  66321. Gp[iteratorSymbol] = function() {
  66322. return this;
  66323. };
  66324. Gp.toString = function() {
  66325. return "[object Generator]";
  66326. };
  66327. function pushTryEntry(locs) {
  66328. var entry = { tryLoc: locs[0] };
  66329. if (1 in locs) {
  66330. entry.catchLoc = locs[1];
  66331. }
  66332. if (2 in locs) {
  66333. entry.finallyLoc = locs[2];
  66334. entry.afterLoc = locs[3];
  66335. }
  66336. this.tryEntries.push(entry);
  66337. }
  66338. function resetTryEntry(entry) {
  66339. var record = entry.completion || {};
  66340. record.type = "normal";
  66341. delete record.arg;
  66342. entry.completion = record;
  66343. }
  66344. function Context(tryLocsList) {
  66345. // The root entry object (effectively a try statement without a catch
  66346. // or a finally block) gives us a place to store values thrown from
  66347. // locations where there is no enclosing try statement.
  66348. this.tryEntries = [{ tryLoc: "root" }];
  66349. tryLocsList.forEach(pushTryEntry, this);
  66350. this.reset();
  66351. }
  66352. runtime.keys = function(object) {
  66353. var keys = [];
  66354. for (var key in object) {
  66355. keys.push(key);
  66356. }
  66357. keys.reverse();
  66358. // Rather than returning an object with a next method, we keep
  66359. // things simple and return the next function itself.
  66360. return function next() {
  66361. while (keys.length) {
  66362. var key = keys.pop();
  66363. if (key in object) {
  66364. next.value = key;
  66365. next.done = false;
  66366. return next;
  66367. }
  66368. }
  66369. // To avoid creating an additional object, we just hang the .value
  66370. // and .done properties off the next function object itself. This
  66371. // also ensures that the minifier will not anonymize the function.
  66372. next.done = true;
  66373. return next;
  66374. };
  66375. };
  66376. function values(iterable) {
  66377. if (iterable) {
  66378. var iteratorMethod = iterable[iteratorSymbol];
  66379. if (iteratorMethod) {
  66380. return iteratorMethod.call(iterable);
  66381. }
  66382. if (typeof iterable.next === "function") {
  66383. return iterable;
  66384. }
  66385. if (!isNaN(iterable.length)) {
  66386. var i = -1, next = function next() {
  66387. while (++i < iterable.length) {
  66388. if (hasOwn.call(iterable, i)) {
  66389. next.value = iterable[i];
  66390. next.done = false;
  66391. return next;
  66392. }
  66393. }
  66394. next.value = undefined;
  66395. next.done = true;
  66396. return next;
  66397. };
  66398. return next.next = next;
  66399. }
  66400. }
  66401. // Return an iterator with no values.
  66402. return { next: doneResult };
  66403. }
  66404. runtime.values = values;
  66405. function doneResult() {
  66406. return { value: undefined, done: true };
  66407. }
  66408. Context.prototype = {
  66409. constructor: Context,
  66410. reset: function() {
  66411. this.prev = 0;
  66412. this.next = 0;
  66413. this.sent = undefined;
  66414. this.done = false;
  66415. this.delegate = null;
  66416. this.tryEntries.forEach(resetTryEntry);
  66417. // Pre-initialize at least 20 temporary variables to enable hidden
  66418. // class optimizations for simple generators.
  66419. for (var tempIndex = 0, tempName;
  66420. hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
  66421. ++tempIndex) {
  66422. this[tempName] = null;
  66423. }
  66424. },
  66425. stop: function() {
  66426. this.done = true;
  66427. var rootEntry = this.tryEntries[0];
  66428. var rootRecord = rootEntry.completion;
  66429. if (rootRecord.type === "throw") {
  66430. throw rootRecord.arg;
  66431. }
  66432. return this.rval;
  66433. },
  66434. dispatchException: function(exception) {
  66435. if (this.done) {
  66436. throw exception;
  66437. }
  66438. var context = this;
  66439. function handle(loc, caught) {
  66440. record.type = "throw";
  66441. record.arg = exception;
  66442. context.next = loc;
  66443. return !!caught;
  66444. }
  66445. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66446. var entry = this.tryEntries[i];
  66447. var record = entry.completion;
  66448. if (entry.tryLoc === "root") {
  66449. // Exception thrown outside of any try block that could handle
  66450. // it, so set the completion value of the entire function to
  66451. // throw the exception.
  66452. return handle("end");
  66453. }
  66454. if (entry.tryLoc <= this.prev) {
  66455. var hasCatch = hasOwn.call(entry, "catchLoc");
  66456. var hasFinally = hasOwn.call(entry, "finallyLoc");
  66457. if (hasCatch && hasFinally) {
  66458. if (this.prev < entry.catchLoc) {
  66459. return handle(entry.catchLoc, true);
  66460. } else if (this.prev < entry.finallyLoc) {
  66461. return handle(entry.finallyLoc);
  66462. }
  66463. } else if (hasCatch) {
  66464. if (this.prev < entry.catchLoc) {
  66465. return handle(entry.catchLoc, true);
  66466. }
  66467. } else if (hasFinally) {
  66468. if (this.prev < entry.finallyLoc) {
  66469. return handle(entry.finallyLoc);
  66470. }
  66471. } else {
  66472. throw new Error("try statement without catch or finally");
  66473. }
  66474. }
  66475. }
  66476. },
  66477. abrupt: function(type, arg) {
  66478. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66479. var entry = this.tryEntries[i];
  66480. if (entry.tryLoc <= this.prev &&
  66481. hasOwn.call(entry, "finallyLoc") &&
  66482. this.prev < entry.finallyLoc) {
  66483. var finallyEntry = entry;
  66484. break;
  66485. }
  66486. }
  66487. if (finallyEntry &&
  66488. (type === "break" ||
  66489. type === "continue") &&
  66490. finallyEntry.tryLoc <= arg &&
  66491. arg <= finallyEntry.finallyLoc) {
  66492. // Ignore the finally entry if control is not jumping to a
  66493. // location outside the try/catch block.
  66494. finallyEntry = null;
  66495. }
  66496. var record = finallyEntry ? finallyEntry.completion : {};
  66497. record.type = type;
  66498. record.arg = arg;
  66499. if (finallyEntry) {
  66500. this.next = finallyEntry.finallyLoc;
  66501. } else {
  66502. this.complete(record);
  66503. }
  66504. return ContinueSentinel;
  66505. },
  66506. complete: function(record, afterLoc) {
  66507. if (record.type === "throw") {
  66508. throw record.arg;
  66509. }
  66510. if (record.type === "break" ||
  66511. record.type === "continue") {
  66512. this.next = record.arg;
  66513. } else if (record.type === "return") {
  66514. this.rval = record.arg;
  66515. this.next = "end";
  66516. } else if (record.type === "normal" && afterLoc) {
  66517. this.next = afterLoc;
  66518. }
  66519. return ContinueSentinel;
  66520. },
  66521. finish: function(finallyLoc) {
  66522. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66523. var entry = this.tryEntries[i];
  66524. if (entry.finallyLoc === finallyLoc) {
  66525. return this.complete(entry.completion, entry.afterLoc);
  66526. }
  66527. }
  66528. },
  66529. "catch": function(tryLoc) {
  66530. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66531. var entry = this.tryEntries[i];
  66532. if (entry.tryLoc === tryLoc) {
  66533. var record = entry.completion;
  66534. if (record.type === "throw") {
  66535. var thrown = record.arg;
  66536. resetTryEntry(entry);
  66537. }
  66538. return thrown;
  66539. }
  66540. }
  66541. // The context.catch method must only be called with a location
  66542. // argument that corresponds to a known catch block.
  66543. throw new Error("illegal catch attempt");
  66544. },
  66545. delegateYield: function(iterable, resultName, nextLoc) {
  66546. this.delegate = {
  66547. iterator: values(iterable),
  66548. resultName: resultName,
  66549. nextLoc: nextLoc
  66550. };
  66551. return ContinueSentinel;
  66552. }
  66553. };
  66554. })(
  66555. // Among the various tricks for obtaining a reference to the global
  66556. // object, this seems to be the most reliable technique that does not
  66557. // use indirect eval (which violates Content Security Policy).
  66558. typeof global === "object" ? global :
  66559. typeof window === "object" ? window :
  66560. typeof self === "object" ? self : this
  66561. );
  66562. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  66563. },{}],473:[function(require,module,exports){
  66564. // Generated by `/scripts/character-class-escape-sets.js`. Do not edit.
  66565. var regenerate = require('regenerate');
  66566. exports.REGULAR = {
  66567. 'd': regenerate()
  66568. .addRange(0x30, 0x39),
  66569. 'D': regenerate()
  66570. .addRange(0x0, 0x2F)
  66571. .addRange(0x3A, 0xFFFF),
  66572. 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
  66573. .addRange(0x9, 0xD)
  66574. .addRange(0x2000, 0x200A)
  66575. .addRange(0x2028, 0x2029),
  66576. 'S': regenerate()
  66577. .addRange(0x0, 0x8)
  66578. .addRange(0xE, 0x1F)
  66579. .addRange(0x21, 0x9F)
  66580. .addRange(0xA1, 0x167F)
  66581. .addRange(0x1681, 0x180D)
  66582. .addRange(0x180F, 0x1FFF)
  66583. .addRange(0x200B, 0x2027)
  66584. .addRange(0x202A, 0x202E)
  66585. .addRange(0x2030, 0x205E)
  66586. .addRange(0x2060, 0x2FFF)
  66587. .addRange(0x3001, 0xFEFE)
  66588. .addRange(0xFF00, 0xFFFF),
  66589. 'w': regenerate(0x5F)
  66590. .addRange(0x30, 0x39)
  66591. .addRange(0x41, 0x5A)
  66592. .addRange(0x61, 0x7A),
  66593. 'W': regenerate(0x60)
  66594. .addRange(0x0, 0x2F)
  66595. .addRange(0x3A, 0x40)
  66596. .addRange(0x5B, 0x5E)
  66597. .addRange(0x7B, 0xFFFF)
  66598. };
  66599. exports.UNICODE = {
  66600. 'd': regenerate()
  66601. .addRange(0x30, 0x39),
  66602. 'D': regenerate()
  66603. .addRange(0x0, 0x2F)
  66604. .addRange(0x3A, 0x10FFFF),
  66605. 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
  66606. .addRange(0x9, 0xD)
  66607. .addRange(0x2000, 0x200A)
  66608. .addRange(0x2028, 0x2029),
  66609. 'S': regenerate()
  66610. .addRange(0x0, 0x8)
  66611. .addRange(0xE, 0x1F)
  66612. .addRange(0x21, 0x9F)
  66613. .addRange(0xA1, 0x167F)
  66614. .addRange(0x1681, 0x180D)
  66615. .addRange(0x180F, 0x1FFF)
  66616. .addRange(0x200B, 0x2027)
  66617. .addRange(0x202A, 0x202E)
  66618. .addRange(0x2030, 0x205E)
  66619. .addRange(0x2060, 0x2FFF)
  66620. .addRange(0x3001, 0xFEFE)
  66621. .addRange(0xFF00, 0x10FFFF),
  66622. 'w': regenerate(0x5F)
  66623. .addRange(0x30, 0x39)
  66624. .addRange(0x41, 0x5A)
  66625. .addRange(0x61, 0x7A),
  66626. 'W': regenerate(0x60)
  66627. .addRange(0x0, 0x2F)
  66628. .addRange(0x3A, 0x40)
  66629. .addRange(0x5B, 0x5E)
  66630. .addRange(0x7B, 0x10FFFF)
  66631. };
  66632. exports.UNICODE_IGNORE_CASE = {
  66633. 'd': regenerate()
  66634. .addRange(0x30, 0x39),
  66635. 'D': regenerate()
  66636. .addRange(0x0, 0x2F)
  66637. .addRange(0x3A, 0x10FFFF),
  66638. 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
  66639. .addRange(0x9, 0xD)
  66640. .addRange(0x2000, 0x200A)
  66641. .addRange(0x2028, 0x2029),
  66642. 'S': regenerate()
  66643. .addRange(0x0, 0x8)
  66644. .addRange(0xE, 0x1F)
  66645. .addRange(0x21, 0x9F)
  66646. .addRange(0xA1, 0x167F)
  66647. .addRange(0x1681, 0x180D)
  66648. .addRange(0x180F, 0x1FFF)
  66649. .addRange(0x200B, 0x2027)
  66650. .addRange(0x202A, 0x202E)
  66651. .addRange(0x2030, 0x205E)
  66652. .addRange(0x2060, 0x2FFF)
  66653. .addRange(0x3001, 0xFEFE)
  66654. .addRange(0xFF00, 0x10FFFF),
  66655. 'w': regenerate(0x5F, 0x17F, 0x212A)
  66656. .addRange(0x30, 0x39)
  66657. .addRange(0x41, 0x5A)
  66658. .addRange(0x61, 0x7A),
  66659. 'W': regenerate(0x4B, 0x53, 0x60)
  66660. .addRange(0x0, 0x2F)
  66661. .addRange(0x3A, 0x40)
  66662. .addRange(0x5B, 0x5E)
  66663. .addRange(0x7B, 0x10FFFF)
  66664. };
  66665. },{"regenerate":475}],474:[function(require,module,exports){
  66666. module.exports={
  66667. "75": 8490,
  66668. "83": 383,
  66669. "107": 8490,
  66670. "115": 383,
  66671. "181": 924,
  66672. "197": 8491,
  66673. "383": 83,
  66674. "452": 453,
  66675. "453": 452,
  66676. "455": 456,
  66677. "456": 455,
  66678. "458": 459,
  66679. "459": 458,
  66680. "497": 498,
  66681. "498": 497,
  66682. "837": 8126,
  66683. "914": 976,
  66684. "917": 1013,
  66685. "920": 1012,
  66686. "921": 8126,
  66687. "922": 1008,
  66688. "924": 181,
  66689. "928": 982,
  66690. "929": 1009,
  66691. "931": 962,
  66692. "934": 981,
  66693. "937": 8486,
  66694. "962": 931,
  66695. "976": 914,
  66696. "977": 1012,
  66697. "981": 934,
  66698. "982": 928,
  66699. "1008": 922,
  66700. "1009": 929,
  66701. "1012": [
  66702. 920,
  66703. 977
  66704. ],
  66705. "1013": 917,
  66706. "7776": 7835,
  66707. "7835": 7776,
  66708. "8126": [
  66709. 837,
  66710. 921
  66711. ],
  66712. "8486": 937,
  66713. "8490": 75,
  66714. "8491": 197,
  66715. "66560": 66600,
  66716. "66561": 66601,
  66717. "66562": 66602,
  66718. "66563": 66603,
  66719. "66564": 66604,
  66720. "66565": 66605,
  66721. "66566": 66606,
  66722. "66567": 66607,
  66723. "66568": 66608,
  66724. "66569": 66609,
  66725. "66570": 66610,
  66726. "66571": 66611,
  66727. "66572": 66612,
  66728. "66573": 66613,
  66729. "66574": 66614,
  66730. "66575": 66615,
  66731. "66576": 66616,
  66732. "66577": 66617,
  66733. "66578": 66618,
  66734. "66579": 66619,
  66735. "66580": 66620,
  66736. "66581": 66621,
  66737. "66582": 66622,
  66738. "66583": 66623,
  66739. "66584": 66624,
  66740. "66585": 66625,
  66741. "66586": 66626,
  66742. "66587": 66627,
  66743. "66588": 66628,
  66744. "66589": 66629,
  66745. "66590": 66630,
  66746. "66591": 66631,
  66747. "66592": 66632,
  66748. "66593": 66633,
  66749. "66594": 66634,
  66750. "66595": 66635,
  66751. "66596": 66636,
  66752. "66597": 66637,
  66753. "66598": 66638,
  66754. "66599": 66639,
  66755. "66600": 66560,
  66756. "66601": 66561,
  66757. "66602": 66562,
  66758. "66603": 66563,
  66759. "66604": 66564,
  66760. "66605": 66565,
  66761. "66606": 66566,
  66762. "66607": 66567,
  66763. "66608": 66568,
  66764. "66609": 66569,
  66765. "66610": 66570,
  66766. "66611": 66571,
  66767. "66612": 66572,
  66768. "66613": 66573,
  66769. "66614": 66574,
  66770. "66615": 66575,
  66771. "66616": 66576,
  66772. "66617": 66577,
  66773. "66618": 66578,
  66774. "66619": 66579,
  66775. "66620": 66580,
  66776. "66621": 66581,
  66777. "66622": 66582,
  66778. "66623": 66583,
  66779. "66624": 66584,
  66780. "66625": 66585,
  66781. "66626": 66586,
  66782. "66627": 66587,
  66783. "66628": 66588,
  66784. "66629": 66589,
  66785. "66630": 66590,
  66786. "66631": 66591,
  66787. "66632": 66592,
  66788. "66633": 66593,
  66789. "66634": 66594,
  66790. "66635": 66595,
  66791. "66636": 66596,
  66792. "66637": 66597,
  66793. "66638": 66598,
  66794. "66639": 66599,
  66795. "71840": 71872,
  66796. "71841": 71873,
  66797. "71842": 71874,
  66798. "71843": 71875,
  66799. "71844": 71876,
  66800. "71845": 71877,
  66801. "71846": 71878,
  66802. "71847": 71879,
  66803. "71848": 71880,
  66804. "71849": 71881,
  66805. "71850": 71882,
  66806. "71851": 71883,
  66807. "71852": 71884,
  66808. "71853": 71885,
  66809. "71854": 71886,
  66810. "71855": 71887,
  66811. "71856": 71888,
  66812. "71857": 71889,
  66813. "71858": 71890,
  66814. "71859": 71891,
  66815. "71860": 71892,
  66816. "71861": 71893,
  66817. "71862": 71894,
  66818. "71863": 71895,
  66819. "71864": 71896,
  66820. "71865": 71897,
  66821. "71866": 71898,
  66822. "71867": 71899,
  66823. "71868": 71900,
  66824. "71869": 71901,
  66825. "71870": 71902,
  66826. "71871": 71903,
  66827. "71872": 71840,
  66828. "71873": 71841,
  66829. "71874": 71842,
  66830. "71875": 71843,
  66831. "71876": 71844,
  66832. "71877": 71845,
  66833. "71878": 71846,
  66834. "71879": 71847,
  66835. "71880": 71848,
  66836. "71881": 71849,
  66837. "71882": 71850,
  66838. "71883": 71851,
  66839. "71884": 71852,
  66840. "71885": 71853,
  66841. "71886": 71854,
  66842. "71887": 71855,
  66843. "71888": 71856,
  66844. "71889": 71857,
  66845. "71890": 71858,
  66846. "71891": 71859,
  66847. "71892": 71860,
  66848. "71893": 71861,
  66849. "71894": 71862,
  66850. "71895": 71863,
  66851. "71896": 71864,
  66852. "71897": 71865,
  66853. "71898": 71866,
  66854. "71899": 71867,
  66855. "71900": 71868,
  66856. "71901": 71869,
  66857. "71902": 71870,
  66858. "71903": 71871
  66859. }
  66860. },{}],475:[function(require,module,exports){
  66861. (function (global){
  66862. /*! https://mths.be/regenerate v1.2.0 by @mathias | MIT license */
  66863. ;(function(root) {
  66864. // Detect free variables `exports`.
  66865. var freeExports = typeof exports == 'object' && exports;
  66866. // Detect free variable `module`.
  66867. var freeModule = typeof module == 'object' && module &&
  66868. module.exports == freeExports && module;
  66869. // Detect free variable `global`, from Node.js or Browserified code,
  66870. // and use it as `root`.
  66871. var freeGlobal = typeof global == 'object' && global;
  66872. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  66873. root = freeGlobal;
  66874. }
  66875. /*--------------------------------------------------------------------------*/
  66876. var ERRORS = {
  66877. 'rangeOrder': 'A range\u2019s `stop` value must be greater than or equal ' +
  66878. 'to the `start` value.',
  66879. 'codePointRange': 'Invalid code point value. Code points range from ' +
  66880. 'U+000000 to U+10FFFF.'
  66881. };
  66882. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-pairs
  66883. var HIGH_SURROGATE_MIN = 0xD800;
  66884. var HIGH_SURROGATE_MAX = 0xDBFF;
  66885. var LOW_SURROGATE_MIN = 0xDC00;
  66886. var LOW_SURROGATE_MAX = 0xDFFF;
  66887. // In Regenerate output, `\0` will never be preceded by `\` because we sort
  66888. // by code point value, so let’s keep this regular expression simple.
  66889. var regexNull = /\\x00([^0123456789]|$)/g;
  66890. var object = {};
  66891. var hasOwnProperty = object.hasOwnProperty;
  66892. var extend = function(destination, source) {
  66893. var key;
  66894. for (key in source) {
  66895. if (hasOwnProperty.call(source, key)) {
  66896. destination[key] = source[key];
  66897. }
  66898. }
  66899. return destination;
  66900. };
  66901. var forEach = function(array, callback) {
  66902. var index = -1;
  66903. var length = array.length;
  66904. while (++index < length) {
  66905. callback(array[index], index);
  66906. }
  66907. };
  66908. var toString = object.toString;
  66909. var isArray = function(value) {
  66910. return toString.call(value) == '[object Array]';
  66911. };
  66912. var isNumber = function(value) {
  66913. return typeof value == 'number' ||
  66914. toString.call(value) == '[object Number]';
  66915. };
  66916. // This assumes that `number` is a positive integer that `toString()`s nicely
  66917. // (which is the case for all code point values).
  66918. var zeroes = '0000';
  66919. var pad = function(number, totalCharacters) {
  66920. var string = String(number);
  66921. return string.length < totalCharacters
  66922. ? (zeroes + string).slice(-totalCharacters)
  66923. : string;
  66924. };
  66925. var hex = function(number) {
  66926. return Number(number).toString(16).toUpperCase();
  66927. };
  66928. var slice = [].slice;
  66929. /*--------------------------------------------------------------------------*/
  66930. var dataFromCodePoints = function(codePoints) {
  66931. var index = -1;
  66932. var length = codePoints.length;
  66933. var max = length - 1;
  66934. var result = [];
  66935. var isStart = true;
  66936. var tmp;
  66937. var previous = 0;
  66938. while (++index < length) {
  66939. tmp = codePoints[index];
  66940. if (isStart) {
  66941. result.push(tmp);
  66942. previous = tmp;
  66943. isStart = false;
  66944. } else {
  66945. if (tmp == previous + 1) {
  66946. if (index != max) {
  66947. previous = tmp;
  66948. continue;
  66949. } else {
  66950. isStart = true;
  66951. result.push(tmp + 1);
  66952. }
  66953. } else {
  66954. // End the previous range and start a new one.
  66955. result.push(previous + 1, tmp);
  66956. previous = tmp;
  66957. }
  66958. }
  66959. }
  66960. if (!isStart) {
  66961. result.push(tmp + 1);
  66962. }
  66963. return result;
  66964. };
  66965. var dataRemove = function(data, codePoint) {
  66966. // Iterate over the data per `(start, end)` pair.
  66967. var index = 0;
  66968. var start;
  66969. var end;
  66970. var length = data.length;
  66971. while (index < length) {
  66972. start = data[index];
  66973. end = data[index + 1];
  66974. if (codePoint >= start && codePoint < end) {
  66975. // Modify this pair.
  66976. if (codePoint == start) {
  66977. if (end == start + 1) {
  66978. // Just remove `start` and `end`.
  66979. data.splice(index, 2);
  66980. return data;
  66981. } else {
  66982. // Just replace `start` with a new value.
  66983. data[index] = codePoint + 1;
  66984. return data;
  66985. }
  66986. } else if (codePoint == end - 1) {
  66987. // Just replace `end` with a new value.
  66988. data[index + 1] = codePoint;
  66989. return data;
  66990. } else {
  66991. // Replace `[start, end]` with `[startA, endA, startB, endB]`.
  66992. data.splice(index, 2, start, codePoint, codePoint + 1, end);
  66993. return data;
  66994. }
  66995. }
  66996. index += 2;
  66997. }
  66998. return data;
  66999. };
  67000. var dataRemoveRange = function(data, rangeStart, rangeEnd) {
  67001. if (rangeEnd < rangeStart) {
  67002. throw Error(ERRORS.rangeOrder);
  67003. }
  67004. // Iterate over the data per `(start, end)` pair.
  67005. var index = 0;
  67006. var start;
  67007. var end;
  67008. while (index < data.length) {
  67009. start = data[index];
  67010. end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
  67011. // Exit as soon as no more matching pairs can be found.
  67012. if (start > rangeEnd) {
  67013. return data;
  67014. }
  67015. // Check if this range pair is equal to, or forms a subset of, the range
  67016. // to be removed.
  67017. // E.g. we have `[0, 11, 40, 51]` and want to remove 0-10 → `[40, 51]`.
  67018. // E.g. we have `[40, 51]` and want to remove 0-100 → `[]`.
  67019. if (rangeStart <= start && rangeEnd >= end) {
  67020. // Remove this pair.
  67021. data.splice(index, 2);
  67022. continue;
  67023. }
  67024. // Check if both `rangeStart` and `rangeEnd` are within the bounds of
  67025. // this pair.
  67026. // E.g. we have `[0, 11]` and want to remove 4-6 → `[0, 4, 7, 11]`.
  67027. if (rangeStart >= start && rangeEnd < end) {
  67028. if (rangeStart == start) {
  67029. // Replace `[start, end]` with `[startB, endB]`.
  67030. data[index] = rangeEnd + 1;
  67031. data[index + 1] = end + 1;
  67032. return data;
  67033. }
  67034. // Replace `[start, end]` with `[startA, endA, startB, endB]`.
  67035. data.splice(index, 2, start, rangeStart, rangeEnd + 1, end + 1);
  67036. return data;
  67037. }
  67038. // Check if only `rangeStart` is within the bounds of this pair.
  67039. // E.g. we have `[0, 11]` and want to remove 4-20 → `[0, 4]`.
  67040. if (rangeStart >= start && rangeStart <= end) {
  67041. // Replace `end` with `rangeStart`.
  67042. data[index + 1] = rangeStart;
  67043. // Note: we cannot `return` just yet, in case any following pairs still
  67044. // contain matching code points.
  67045. // E.g. we have `[0, 11, 14, 31]` and want to remove 4-20
  67046. // → `[0, 4, 21, 31]`.
  67047. }
  67048. // Check if only `rangeEnd` is within the bounds of this pair.
  67049. // E.g. we have `[14, 31]` and want to remove 4-20 → `[21, 31]`.
  67050. else if (rangeEnd >= start && rangeEnd <= end) {
  67051. // Just replace `start`.
  67052. data[index] = rangeEnd + 1;
  67053. return data;
  67054. }
  67055. index += 2;
  67056. }
  67057. return data;
  67058. };
  67059. var dataAdd = function(data, codePoint) {
  67060. // Iterate over the data per `(start, end)` pair.
  67061. var index = 0;
  67062. var start;
  67063. var end;
  67064. var lastIndex = null;
  67065. var length = data.length;
  67066. if (codePoint < 0x0 || codePoint > 0x10FFFF) {
  67067. throw RangeError(ERRORS.codePointRange);
  67068. }
  67069. while (index < length) {
  67070. start = data[index];
  67071. end = data[index + 1];
  67072. // Check if the code point is already in the set.
  67073. if (codePoint >= start && codePoint < end) {
  67074. return data;
  67075. }
  67076. if (codePoint == start - 1) {
  67077. // Just replace `start` with a new value.
  67078. data[index] = codePoint;
  67079. return data;
  67080. }
  67081. // At this point, if `start` is `greater` than `codePoint`, insert a new
  67082. // `[start, end]` pair before the current pair, or after the current pair
  67083. // if there is a known `lastIndex`.
  67084. if (start > codePoint) {
  67085. data.splice(
  67086. lastIndex != null ? lastIndex + 2 : 0,
  67087. 0,
  67088. codePoint,
  67089. codePoint + 1
  67090. );
  67091. return data;
  67092. }
  67093. if (codePoint == end) {
  67094. // Check if adding this code point causes two separate ranges to become
  67095. // a single range, e.g. `dataAdd([0, 4, 5, 10], 4)` → `[0, 10]`.
  67096. if (codePoint + 1 == data[index + 2]) {
  67097. data.splice(index, 4, start, data[index + 3]);
  67098. return data;
  67099. }
  67100. // Else, just replace `end` with a new value.
  67101. data[index + 1] = codePoint + 1;
  67102. return data;
  67103. }
  67104. lastIndex = index;
  67105. index += 2;
  67106. }
  67107. // The loop has finished; add the new pair to the end of the data set.
  67108. data.push(codePoint, codePoint + 1);
  67109. return data;
  67110. };
  67111. var dataAddData = function(dataA, dataB) {
  67112. // Iterate over the data per `(start, end)` pair.
  67113. var index = 0;
  67114. var start;
  67115. var end;
  67116. var data = dataA.slice();
  67117. var length = dataB.length;
  67118. while (index < length) {
  67119. start = dataB[index];
  67120. end = dataB[index + 1] - 1;
  67121. if (start == end) {
  67122. data = dataAdd(data, start);
  67123. } else {
  67124. data = dataAddRange(data, start, end);
  67125. }
  67126. index += 2;
  67127. }
  67128. return data;
  67129. };
  67130. var dataRemoveData = function(dataA, dataB) {
  67131. // Iterate over the data per `(start, end)` pair.
  67132. var index = 0;
  67133. var start;
  67134. var end;
  67135. var data = dataA.slice();
  67136. var length = dataB.length;
  67137. while (index < length) {
  67138. start = dataB[index];
  67139. end = dataB[index + 1] - 1;
  67140. if (start == end) {
  67141. data = dataRemove(data, start);
  67142. } else {
  67143. data = dataRemoveRange(data, start, end);
  67144. }
  67145. index += 2;
  67146. }
  67147. return data;
  67148. };
  67149. var dataAddRange = function(data, rangeStart, rangeEnd) {
  67150. if (rangeEnd < rangeStart) {
  67151. throw Error(ERRORS.rangeOrder);
  67152. }
  67153. if (
  67154. rangeStart < 0x0 || rangeStart > 0x10FFFF ||
  67155. rangeEnd < 0x0 || rangeEnd > 0x10FFFF
  67156. ) {
  67157. throw RangeError(ERRORS.codePointRange);
  67158. }
  67159. // Iterate over the data per `(start, end)` pair.
  67160. var index = 0;
  67161. var start;
  67162. var end;
  67163. var added = false;
  67164. var length = data.length;
  67165. while (index < length) {
  67166. start = data[index];
  67167. end = data[index + 1];
  67168. if (added) {
  67169. // The range has already been added to the set; at this point, we just
  67170. // need to get rid of the following ranges in case they overlap.
  67171. // Check if this range can be combined with the previous range.
  67172. if (start == rangeEnd + 1) {
  67173. data.splice(index - 1, 2);
  67174. return data;
  67175. }
  67176. // Exit as soon as no more possibly overlapping pairs can be found.
  67177. if (start > rangeEnd) {
  67178. return data;
  67179. }
  67180. // E.g. `[0, 11, 12, 16]` and we’ve added 5-15, so we now have
  67181. // `[0, 16, 12, 16]`. Remove the `12,16` part, as it lies within the
  67182. // `0,16` range that was previously added.
  67183. if (start >= rangeStart && start <= rangeEnd) {
  67184. // `start` lies within the range that was previously added.
  67185. if (end > rangeStart && end - 1 <= rangeEnd) {
  67186. // `end` lies within the range that was previously added as well,
  67187. // so remove this pair.
  67188. data.splice(index, 2);
  67189. index -= 2;
  67190. // Note: we cannot `return` just yet, as there may still be other
  67191. // overlapping pairs.
  67192. } else {
  67193. // `start` lies within the range that was previously added, but
  67194. // `end` doesn’t. E.g. `[0, 11, 12, 31]` and we’ve added 5-15, so
  67195. // now we have `[0, 16, 12, 31]`. This must be written as `[0, 31]`.
  67196. // Remove the previously added `end` and the current `start`.
  67197. data.splice(index - 1, 2);
  67198. index -= 2;
  67199. }
  67200. // Note: we cannot return yet.
  67201. }
  67202. }
  67203. else if (start == rangeEnd + 1) {
  67204. data[index] = rangeStart;
  67205. return data;
  67206. }
  67207. // Check if a new pair must be inserted *before* the current one.
  67208. else if (start > rangeEnd) {
  67209. data.splice(index, 0, rangeStart, rangeEnd + 1);
  67210. return data;
  67211. }
  67212. else if (rangeStart >= start && rangeStart < end && rangeEnd + 1 <= end) {
  67213. // The new range lies entirely within an existing range pair. No action
  67214. // needed.
  67215. return data;
  67216. }
  67217. else if (
  67218. // E.g. `[0, 11]` and you add 5-15 → `[0, 16]`.
  67219. (rangeStart >= start && rangeStart < end) ||
  67220. // E.g. `[0, 3]` and you add 3-6 → `[0, 7]`.
  67221. end == rangeStart
  67222. ) {
  67223. // Replace `end` with the new value.
  67224. data[index + 1] = rangeEnd + 1;
  67225. // Make sure the next range pair doesn’t overlap, e.g. `[0, 11, 12, 14]`
  67226. // and you add 5-15 → `[0, 16]`, i.e. remove the `12,14` part.
  67227. added = true;
  67228. // Note: we cannot `return` just yet.
  67229. }
  67230. else if (rangeStart <= start && rangeEnd + 1 >= end) {
  67231. // The new range is a superset of the old range.
  67232. data[index] = rangeStart;
  67233. data[index + 1] = rangeEnd + 1;
  67234. added = true;
  67235. }
  67236. index += 2;
  67237. }
  67238. // The loop has finished without doing anything; add the new pair to the end
  67239. // of the data set.
  67240. if (!added) {
  67241. data.push(rangeStart, rangeEnd + 1);
  67242. }
  67243. return data;
  67244. };
  67245. var dataContains = function(data, codePoint) {
  67246. var index = 0;
  67247. var length = data.length;
  67248. // Exit early if `codePoint` is not within `data`’s overall range.
  67249. var start = data[index];
  67250. var end = data[length - 1];
  67251. if (length >= 2) {
  67252. if (codePoint < start || codePoint > end) {
  67253. return false;
  67254. }
  67255. }
  67256. // Iterate over the data per `(start, end)` pair.
  67257. while (index < length) {
  67258. start = data[index];
  67259. end = data[index + 1];
  67260. if (codePoint >= start && codePoint < end) {
  67261. return true;
  67262. }
  67263. index += 2;
  67264. }
  67265. return false;
  67266. };
  67267. var dataIntersection = function(data, codePoints) {
  67268. var index = 0;
  67269. var length = codePoints.length;
  67270. var codePoint;
  67271. var result = [];
  67272. while (index < length) {
  67273. codePoint = codePoints[index];
  67274. if (dataContains(data, codePoint)) {
  67275. result.push(codePoint);
  67276. }
  67277. ++index;
  67278. }
  67279. return dataFromCodePoints(result);
  67280. };
  67281. var dataIsEmpty = function(data) {
  67282. return !data.length;
  67283. };
  67284. var dataIsSingleton = function(data) {
  67285. // Check if the set only represents a single code point.
  67286. return data.length == 2 && data[0] + 1 == data[1];
  67287. };
  67288. var dataToArray = function(data) {
  67289. // Iterate over the data per `(start, end)` pair.
  67290. var index = 0;
  67291. var start;
  67292. var end;
  67293. var result = [];
  67294. var length = data.length;
  67295. while (index < length) {
  67296. start = data[index];
  67297. end = data[index + 1];
  67298. while (start < end) {
  67299. result.push(start);
  67300. ++start;
  67301. }
  67302. index += 2;
  67303. }
  67304. return result;
  67305. };
  67306. /*--------------------------------------------------------------------------*/
  67307. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  67308. var floor = Math.floor;
  67309. var highSurrogate = function(codePoint) {
  67310. return parseInt(
  67311. floor((codePoint - 0x10000) / 0x400) + HIGH_SURROGATE_MIN,
  67312. 10
  67313. );
  67314. };
  67315. var lowSurrogate = function(codePoint) {
  67316. return parseInt(
  67317. (codePoint - 0x10000) % 0x400 + LOW_SURROGATE_MIN,
  67318. 10
  67319. );
  67320. };
  67321. var stringFromCharCode = String.fromCharCode;
  67322. var codePointToString = function(codePoint) {
  67323. var string;
  67324. // https://mathiasbynens.be/notes/javascript-escapes#single
  67325. // Note: the `\b` escape sequence for U+0008 BACKSPACE in strings has a
  67326. // different meaning in regular expressions (word boundary), so it cannot
  67327. // be used here.
  67328. if (codePoint == 0x09) {
  67329. string = '\\t';
  67330. }
  67331. // Note: IE < 9 treats `'\v'` as `'v'`, so avoid using it.
  67332. // else if (codePoint == 0x0B) {
  67333. // string = '\\v';
  67334. // }
  67335. else if (codePoint == 0x0A) {
  67336. string = '\\n';
  67337. }
  67338. else if (codePoint == 0x0C) {
  67339. string = '\\f';
  67340. }
  67341. else if (codePoint == 0x0D) {
  67342. string = '\\r';
  67343. }
  67344. else if (codePoint == 0x5C) {
  67345. string = '\\\\';
  67346. }
  67347. else if (
  67348. codePoint == 0x24 ||
  67349. (codePoint >= 0x28 && codePoint <= 0x2B) ||
  67350. codePoint == 0x2D || codePoint == 0x2E || codePoint == 0x3F ||
  67351. (codePoint >= 0x5B && codePoint <= 0x5E) ||
  67352. (codePoint >= 0x7B && codePoint <= 0x7D)
  67353. ) {
  67354. // The code point maps to an unsafe printable ASCII character;
  67355. // backslash-escape it. Here’s the list of those symbols:
  67356. //
  67357. // $()*+-.?[\]^{|}
  67358. //
  67359. // See #7 for more info.
  67360. string = '\\' + stringFromCharCode(codePoint);
  67361. }
  67362. else if (codePoint >= 0x20 && codePoint <= 0x7E) {
  67363. // The code point maps to one of these printable ASCII symbols
  67364. // (including the space character):
  67365. //
  67366. // !"#%&',/0123456789:;<=>@ABCDEFGHIJKLMNO
  67367. // PQRSTUVWXYZ_`abcdefghijklmnopqrstuvwxyz~
  67368. //
  67369. // These can safely be used directly.
  67370. string = stringFromCharCode(codePoint);
  67371. }
  67372. else if (codePoint <= 0xFF) {
  67373. // https://mathiasbynens.be/notes/javascript-escapes#hexadecimal
  67374. string = '\\x' + pad(hex(codePoint), 2);
  67375. }
  67376. else { // `codePoint <= 0xFFFF` holds true.
  67377. // https://mathiasbynens.be/notes/javascript-escapes#unicode
  67378. string = '\\u' + pad(hex(codePoint), 4);
  67379. }
  67380. // There’s no need to account for astral symbols / surrogate pairs here,
  67381. // since `codePointToString` is private and only used for BMP code points.
  67382. // But if that’s what you need, just add an `else` block with this code:
  67383. //
  67384. // string = '\\u' + pad(hex(highSurrogate(codePoint)), 4)
  67385. // + '\\u' + pad(hex(lowSurrogate(codePoint)), 4);
  67386. return string;
  67387. };
  67388. var symbolToCodePoint = function(symbol) {
  67389. var length = symbol.length;
  67390. var first = symbol.charCodeAt(0);
  67391. var second;
  67392. if (
  67393. first >= HIGH_SURROGATE_MIN && first <= HIGH_SURROGATE_MAX &&
  67394. length > 1 // There is a next code unit.
  67395. ) {
  67396. // `first` is a high surrogate, and there is a next character. Assume
  67397. // it’s a low surrogate (else it’s invalid usage of Regenerate anyway).
  67398. second = symbol.charCodeAt(1);
  67399. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  67400. return (first - HIGH_SURROGATE_MIN) * 0x400 +
  67401. second - LOW_SURROGATE_MIN + 0x10000;
  67402. }
  67403. return first;
  67404. };
  67405. var createBMPCharacterClasses = function(data) {
  67406. // Iterate over the data per `(start, end)` pair.
  67407. var result = '';
  67408. var index = 0;
  67409. var start;
  67410. var end;
  67411. var length = data.length;
  67412. if (dataIsSingleton(data)) {
  67413. return codePointToString(data[0]);
  67414. }
  67415. while (index < length) {
  67416. start = data[index];
  67417. end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
  67418. if (start == end) {
  67419. result += codePointToString(start);
  67420. } else if (start + 1 == end) {
  67421. result += codePointToString(start) + codePointToString(end);
  67422. } else {
  67423. result += codePointToString(start) + '-' + codePointToString(end);
  67424. }
  67425. index += 2;
  67426. }
  67427. return '[' + result + ']';
  67428. };
  67429. var splitAtBMP = function(data) {
  67430. // Iterate over the data per `(start, end)` pair.
  67431. var loneHighSurrogates = [];
  67432. var loneLowSurrogates = [];
  67433. var bmp = [];
  67434. var astral = [];
  67435. var index = 0;
  67436. var start;
  67437. var end;
  67438. var length = data.length;
  67439. while (index < length) {
  67440. start = data[index];
  67441. end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
  67442. if (start < HIGH_SURROGATE_MIN) {
  67443. // The range starts and ends before the high surrogate range.
  67444. // E.g. (0, 0x10).
  67445. if (end < HIGH_SURROGATE_MIN) {
  67446. bmp.push(start, end + 1);
  67447. }
  67448. // The range starts before the high surrogate range and ends within it.
  67449. // E.g. (0, 0xD855).
  67450. if (end >= HIGH_SURROGATE_MIN && end <= HIGH_SURROGATE_MAX) {
  67451. bmp.push(start, HIGH_SURROGATE_MIN);
  67452. loneHighSurrogates.push(HIGH_SURROGATE_MIN, end + 1);
  67453. }
  67454. // The range starts before the high surrogate range and ends in the low
  67455. // surrogate range. E.g. (0, 0xDCFF).
  67456. if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
  67457. bmp.push(start, HIGH_SURROGATE_MIN);
  67458. loneHighSurrogates.push(HIGH_SURROGATE_MIN, HIGH_SURROGATE_MAX + 1);
  67459. loneLowSurrogates.push(LOW_SURROGATE_MIN, end + 1);
  67460. }
  67461. // The range starts before the high surrogate range and ends after the
  67462. // low surrogate range. E.g. (0, 0x10FFFF).
  67463. if (end > LOW_SURROGATE_MAX) {
  67464. bmp.push(start, HIGH_SURROGATE_MIN);
  67465. loneHighSurrogates.push(HIGH_SURROGATE_MIN, HIGH_SURROGATE_MAX + 1);
  67466. loneLowSurrogates.push(LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1);
  67467. if (end <= 0xFFFF) {
  67468. bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
  67469. } else {
  67470. bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
  67471. astral.push(0xFFFF + 1, end + 1);
  67472. }
  67473. }
  67474. } else if (start >= HIGH_SURROGATE_MIN && start <= HIGH_SURROGATE_MAX) {
  67475. // The range starts and ends in the high surrogate range.
  67476. // E.g. (0xD855, 0xD866).
  67477. if (end >= HIGH_SURROGATE_MIN && end <= HIGH_SURROGATE_MAX) {
  67478. loneHighSurrogates.push(start, end + 1);
  67479. }
  67480. // The range starts in the high surrogate range and ends in the low
  67481. // surrogate range. E.g. (0xD855, 0xDCFF).
  67482. if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
  67483. loneHighSurrogates.push(start, HIGH_SURROGATE_MAX + 1);
  67484. loneLowSurrogates.push(LOW_SURROGATE_MIN, end + 1);
  67485. }
  67486. // The range starts in the high surrogate range and ends after the low
  67487. // surrogate range. E.g. (0xD855, 0x10FFFF).
  67488. if (end > LOW_SURROGATE_MAX) {
  67489. loneHighSurrogates.push(start, HIGH_SURROGATE_MAX + 1);
  67490. loneLowSurrogates.push(LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1);
  67491. if (end <= 0xFFFF) {
  67492. bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
  67493. } else {
  67494. bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
  67495. astral.push(0xFFFF + 1, end + 1);
  67496. }
  67497. }
  67498. } else if (start >= LOW_SURROGATE_MIN && start <= LOW_SURROGATE_MAX) {
  67499. // The range starts and ends in the low surrogate range.
  67500. // E.g. (0xDCFF, 0xDDFF).
  67501. if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
  67502. loneLowSurrogates.push(start, end + 1);
  67503. }
  67504. // The range starts in the low surrogate range and ends after the low
  67505. // surrogate range. E.g. (0xDCFF, 0x10FFFF).
  67506. if (end > LOW_SURROGATE_MAX) {
  67507. loneLowSurrogates.push(start, LOW_SURROGATE_MAX + 1);
  67508. if (end <= 0xFFFF) {
  67509. bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
  67510. } else {
  67511. bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
  67512. astral.push(0xFFFF + 1, end + 1);
  67513. }
  67514. }
  67515. } else if (start > LOW_SURROGATE_MAX && start <= 0xFFFF) {
  67516. // The range starts and ends after the low surrogate range.
  67517. // E.g. (0xFFAA, 0x10FFFF).
  67518. if (end <= 0xFFFF) {
  67519. bmp.push(start, end + 1);
  67520. } else {
  67521. bmp.push(start, 0xFFFF + 1);
  67522. astral.push(0xFFFF + 1, end + 1);
  67523. }
  67524. } else {
  67525. // The range starts and ends in the astral range.
  67526. astral.push(start, end + 1);
  67527. }
  67528. index += 2;
  67529. }
  67530. return {
  67531. 'loneHighSurrogates': loneHighSurrogates,
  67532. 'loneLowSurrogates': loneLowSurrogates,
  67533. 'bmp': bmp,
  67534. 'astral': astral
  67535. };
  67536. };
  67537. var optimizeSurrogateMappings = function(surrogateMappings) {
  67538. var result = [];
  67539. var tmpLow = [];
  67540. var addLow = false;
  67541. var mapping;
  67542. var nextMapping;
  67543. var highSurrogates;
  67544. var lowSurrogates;
  67545. var nextHighSurrogates;
  67546. var nextLowSurrogates;
  67547. var index = -1;
  67548. var length = surrogateMappings.length;
  67549. while (++index < length) {
  67550. mapping = surrogateMappings[index];
  67551. nextMapping = surrogateMappings[index + 1];
  67552. if (!nextMapping) {
  67553. result.push(mapping);
  67554. continue;
  67555. }
  67556. highSurrogates = mapping[0];
  67557. lowSurrogates = mapping[1];
  67558. nextHighSurrogates = nextMapping[0];
  67559. nextLowSurrogates = nextMapping[1];
  67560. // Check for identical high surrogate ranges.
  67561. tmpLow = lowSurrogates;
  67562. while (
  67563. nextHighSurrogates &&
  67564. highSurrogates[0] == nextHighSurrogates[0] &&
  67565. highSurrogates[1] == nextHighSurrogates[1]
  67566. ) {
  67567. // Merge with the next item.
  67568. if (dataIsSingleton(nextLowSurrogates)) {
  67569. tmpLow = dataAdd(tmpLow, nextLowSurrogates[0]);
  67570. } else {
  67571. tmpLow = dataAddRange(
  67572. tmpLow,
  67573. nextLowSurrogates[0],
  67574. nextLowSurrogates[1] - 1
  67575. );
  67576. }
  67577. ++index;
  67578. mapping = surrogateMappings[index];
  67579. highSurrogates = mapping[0];
  67580. lowSurrogates = mapping[1];
  67581. nextMapping = surrogateMappings[index + 1];
  67582. nextHighSurrogates = nextMapping && nextMapping[0];
  67583. nextLowSurrogates = nextMapping && nextMapping[1];
  67584. addLow = true;
  67585. }
  67586. result.push([
  67587. highSurrogates,
  67588. addLow ? tmpLow : lowSurrogates
  67589. ]);
  67590. addLow = false;
  67591. }
  67592. return optimizeByLowSurrogates(result);
  67593. };
  67594. var optimizeByLowSurrogates = function(surrogateMappings) {
  67595. if (surrogateMappings.length == 1) {
  67596. return surrogateMappings;
  67597. }
  67598. var index = -1;
  67599. var innerIndex = -1;
  67600. while (++index < surrogateMappings.length) {
  67601. var mapping = surrogateMappings[index];
  67602. var lowSurrogates = mapping[1];
  67603. var lowSurrogateStart = lowSurrogates[0];
  67604. var lowSurrogateEnd = lowSurrogates[1];
  67605. innerIndex = index; // Note: the loop starts at the next index.
  67606. while (++innerIndex < surrogateMappings.length) {
  67607. var otherMapping = surrogateMappings[innerIndex];
  67608. var otherLowSurrogates = otherMapping[1];
  67609. var otherLowSurrogateStart = otherLowSurrogates[0];
  67610. var otherLowSurrogateEnd = otherLowSurrogates[1];
  67611. if (
  67612. lowSurrogateStart == otherLowSurrogateStart &&
  67613. lowSurrogateEnd == otherLowSurrogateEnd
  67614. ) {
  67615. // Add the code points in the other item to this one.
  67616. if (dataIsSingleton(otherMapping[0])) {
  67617. mapping[0] = dataAdd(mapping[0], otherMapping[0][0]);
  67618. } else {
  67619. mapping[0] = dataAddRange(
  67620. mapping[0],
  67621. otherMapping[0][0],
  67622. otherMapping[0][1] - 1
  67623. );
  67624. }
  67625. // Remove the other, now redundant, item.
  67626. surrogateMappings.splice(innerIndex, 1);
  67627. --innerIndex;
  67628. }
  67629. }
  67630. }
  67631. return surrogateMappings;
  67632. };
  67633. var surrogateSet = function(data) {
  67634. // Exit early if `data` is an empty set.
  67635. if (!data.length) {
  67636. return [];
  67637. }
  67638. // Iterate over the data per `(start, end)` pair.
  67639. var index = 0;
  67640. var start;
  67641. var end;
  67642. var startHigh;
  67643. var startLow;
  67644. var prevStartHigh = 0;
  67645. var prevEndHigh = 0;
  67646. var tmpLow = [];
  67647. var endHigh;
  67648. var endLow;
  67649. var surrogateMappings = [];
  67650. var length = data.length;
  67651. var dataHigh = [];
  67652. while (index < length) {
  67653. start = data[index];
  67654. end = data[index + 1] - 1;
  67655. startHigh = highSurrogate(start);
  67656. startLow = lowSurrogate(start);
  67657. endHigh = highSurrogate(end);
  67658. endLow = lowSurrogate(end);
  67659. var startsWithLowestLowSurrogate = startLow == LOW_SURROGATE_MIN;
  67660. var endsWithHighestLowSurrogate = endLow == LOW_SURROGATE_MAX;
  67661. var complete = false;
  67662. // Append the previous high-surrogate-to-low-surrogate mappings.
  67663. // Step 1: `(startHigh, startLow)` to `(startHigh, LOW_SURROGATE_MAX)`.
  67664. if (
  67665. startHigh == endHigh ||
  67666. startsWithLowestLowSurrogate && endsWithHighestLowSurrogate
  67667. ) {
  67668. surrogateMappings.push([
  67669. [startHigh, endHigh + 1],
  67670. [startLow, endLow + 1]
  67671. ]);
  67672. complete = true;
  67673. } else {
  67674. surrogateMappings.push([
  67675. [startHigh, startHigh + 1],
  67676. [startLow, LOW_SURROGATE_MAX + 1]
  67677. ]);
  67678. }
  67679. // Step 2: `(startHigh + 1, LOW_SURROGATE_MIN)` to
  67680. // `(endHigh - 1, LOW_SURROGATE_MAX)`.
  67681. if (!complete && startHigh + 1 < endHigh) {
  67682. if (endsWithHighestLowSurrogate) {
  67683. // Combine step 2 and step 3.
  67684. surrogateMappings.push([
  67685. [startHigh + 1, endHigh + 1],
  67686. [LOW_SURROGATE_MIN, endLow + 1]
  67687. ]);
  67688. complete = true;
  67689. } else {
  67690. surrogateMappings.push([
  67691. [startHigh + 1, endHigh],
  67692. [LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1]
  67693. ]);
  67694. }
  67695. }
  67696. // Step 3. `(endHigh, LOW_SURROGATE_MIN)` to `(endHigh, endLow)`.
  67697. if (!complete) {
  67698. surrogateMappings.push([
  67699. [endHigh, endHigh + 1],
  67700. [LOW_SURROGATE_MIN, endLow + 1]
  67701. ]);
  67702. }
  67703. prevStartHigh = startHigh;
  67704. prevEndHigh = endHigh;
  67705. index += 2;
  67706. }
  67707. // The format of `surrogateMappings` is as follows:
  67708. //
  67709. // [ surrogateMapping1, surrogateMapping2 ]
  67710. //
  67711. // i.e.:
  67712. //
  67713. // [
  67714. // [ highSurrogates1, lowSurrogates1 ],
  67715. // [ highSurrogates2, lowSurrogates2 ]
  67716. // ]
  67717. return optimizeSurrogateMappings(surrogateMappings);
  67718. };
  67719. var createSurrogateCharacterClasses = function(surrogateMappings) {
  67720. var result = [];
  67721. forEach(surrogateMappings, function(surrogateMapping) {
  67722. var highSurrogates = surrogateMapping[0];
  67723. var lowSurrogates = surrogateMapping[1];
  67724. result.push(
  67725. createBMPCharacterClasses(highSurrogates) +
  67726. createBMPCharacterClasses(lowSurrogates)
  67727. );
  67728. });
  67729. return result.join('|');
  67730. };
  67731. var createCharacterClassesFromData = function(data, bmpOnly) {
  67732. var result = [];
  67733. var parts = splitAtBMP(data);
  67734. var loneHighSurrogates = parts.loneHighSurrogates;
  67735. var loneLowSurrogates = parts.loneLowSurrogates;
  67736. var bmp = parts.bmp;
  67737. var astral = parts.astral;
  67738. var hasAstral = !dataIsEmpty(parts.astral);
  67739. var hasLoneHighSurrogates = !dataIsEmpty(loneHighSurrogates);
  67740. var hasLoneLowSurrogates = !dataIsEmpty(loneLowSurrogates);
  67741. var surrogateMappings = surrogateSet(astral);
  67742. if (bmpOnly) {
  67743. bmp = dataAddData(bmp, loneHighSurrogates);
  67744. hasLoneHighSurrogates = false;
  67745. bmp = dataAddData(bmp, loneLowSurrogates);
  67746. hasLoneLowSurrogates = false;
  67747. }
  67748. if (!dataIsEmpty(bmp)) {
  67749. // The data set contains BMP code points that are not high surrogates
  67750. // needed for astral code points in the set.
  67751. result.push(createBMPCharacterClasses(bmp));
  67752. }
  67753. if (surrogateMappings.length) {
  67754. // The data set contains astral code points; append character classes
  67755. // based on their surrogate pairs.
  67756. result.push(createSurrogateCharacterClasses(surrogateMappings));
  67757. }
  67758. // https://gist.github.com/mathiasbynens/bbe7f870208abcfec860
  67759. if (hasLoneHighSurrogates) {
  67760. result.push(
  67761. createBMPCharacterClasses(loneHighSurrogates) +
  67762. // Make sure the high surrogates aren’t part of a surrogate pair.
  67763. '(?![\\uDC00-\\uDFFF])'
  67764. );
  67765. }
  67766. if (hasLoneLowSurrogates) {
  67767. result.push(
  67768. // Make sure the low surrogates aren’t part of a surrogate pair.
  67769. '(?:[^\\uD800-\\uDBFF]|^)' +
  67770. createBMPCharacterClasses(loneLowSurrogates)
  67771. );
  67772. }
  67773. return result.join('|');
  67774. };
  67775. /*--------------------------------------------------------------------------*/
  67776. // `regenerate` can be used as a constructor (and new methods can be added to
  67777. // its prototype) but also as a regular function, the latter of which is the
  67778. // documented and most common usage. For that reason, it’s not capitalized.
  67779. var regenerate = function(value) {
  67780. if (arguments.length > 1) {
  67781. value = slice.call(arguments);
  67782. }
  67783. if (this instanceof regenerate) {
  67784. this.data = [];
  67785. return value ? this.add(value) : this;
  67786. }
  67787. return (new regenerate).add(value);
  67788. };
  67789. regenerate.version = '1.2.0';
  67790. var proto = regenerate.prototype;
  67791. extend(proto, {
  67792. 'add': function(value) {
  67793. var $this = this;
  67794. if (value == null) {
  67795. return $this;
  67796. }
  67797. if (value instanceof regenerate) {
  67798. // Allow passing other Regenerate instances.
  67799. $this.data = dataAddData($this.data, value.data);
  67800. return $this;
  67801. }
  67802. if (arguments.length > 1) {
  67803. value = slice.call(arguments);
  67804. }
  67805. if (isArray(value)) {
  67806. forEach(value, function(item) {
  67807. $this.add(item);
  67808. });
  67809. return $this;
  67810. }
  67811. $this.data = dataAdd(
  67812. $this.data,
  67813. isNumber(value) ? value : symbolToCodePoint(value)
  67814. );
  67815. return $this;
  67816. },
  67817. 'remove': function(value) {
  67818. var $this = this;
  67819. if (value == null) {
  67820. return $this;
  67821. }
  67822. if (value instanceof regenerate) {
  67823. // Allow passing other Regenerate instances.
  67824. $this.data = dataRemoveData($this.data, value.data);
  67825. return $this;
  67826. }
  67827. if (arguments.length > 1) {
  67828. value = slice.call(arguments);
  67829. }
  67830. if (isArray(value)) {
  67831. forEach(value, function(item) {
  67832. $this.remove(item);
  67833. });
  67834. return $this;
  67835. }
  67836. $this.data = dataRemove(
  67837. $this.data,
  67838. isNumber(value) ? value : symbolToCodePoint(value)
  67839. );
  67840. return $this;
  67841. },
  67842. 'addRange': function(start, end) {
  67843. var $this = this;
  67844. $this.data = dataAddRange($this.data,
  67845. isNumber(start) ? start : symbolToCodePoint(start),
  67846. isNumber(end) ? end : symbolToCodePoint(end)
  67847. );
  67848. return $this;
  67849. },
  67850. 'removeRange': function(start, end) {
  67851. var $this = this;
  67852. var startCodePoint = isNumber(start) ? start : symbolToCodePoint(start);
  67853. var endCodePoint = isNumber(end) ? end : symbolToCodePoint(end);
  67854. $this.data = dataRemoveRange(
  67855. $this.data,
  67856. startCodePoint,
  67857. endCodePoint
  67858. );
  67859. return $this;
  67860. },
  67861. 'intersection': function(argument) {
  67862. var $this = this;
  67863. // Allow passing other Regenerate instances.
  67864. // TODO: Optimize this by writing and using `dataIntersectionData()`.
  67865. var array = argument instanceof regenerate ?
  67866. dataToArray(argument.data) :
  67867. argument;
  67868. $this.data = dataIntersection($this.data, array);
  67869. return $this;
  67870. },
  67871. 'contains': function(codePoint) {
  67872. return dataContains(
  67873. this.data,
  67874. isNumber(codePoint) ? codePoint : symbolToCodePoint(codePoint)
  67875. );
  67876. },
  67877. 'clone': function() {
  67878. var set = new regenerate;
  67879. set.data = this.data.slice(0);
  67880. return set;
  67881. },
  67882. 'toString': function(options) {
  67883. var result = createCharacterClassesFromData(
  67884. this.data,
  67885. options ? options.bmpOnly : false
  67886. );
  67887. // Use `\0` instead of `\x00` where possible.
  67888. return result.replace(regexNull, '\\0$1');
  67889. },
  67890. 'toRegExp': function(flags) {
  67891. return RegExp(this.toString(), flags || '');
  67892. },
  67893. 'valueOf': function() { // Note: `valueOf` is aliased as `toArray`.
  67894. return dataToArray(this.data);
  67895. }
  67896. });
  67897. proto.toArray = proto.valueOf;
  67898. // Some AMD build optimizers, like r.js, check for specific condition patterns
  67899. // like the following:
  67900. if (
  67901. typeof define == 'function' &&
  67902. typeof define.amd == 'object' &&
  67903. define.amd
  67904. ) {
  67905. define(function() {
  67906. return regenerate;
  67907. });
  67908. } else if (freeExports && !freeExports.nodeType) {
  67909. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  67910. freeModule.exports = regenerate;
  67911. } else { // in Narwhal or RingoJS v0.7.0-
  67912. freeExports.regenerate = regenerate;
  67913. }
  67914. } else { // in Rhino or a web browser
  67915. root.regenerate = regenerate;
  67916. }
  67917. }(this));
  67918. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  67919. },{}],476:[function(require,module,exports){
  67920. (function (global){
  67921. /*!
  67922. * RegJSGen
  67923. * Copyright 2014 Benjamin Tan <https://d10.github.io/>
  67924. * Available under MIT license <http://d10.mit-license.org/>
  67925. */
  67926. ;(function() {
  67927. 'use strict';
  67928. /** Used to determine if values are of the language type `Object` */
  67929. var objectTypes = {
  67930. 'function': true,
  67931. 'object': true
  67932. };
  67933. /** Used as a reference to the global object */
  67934. var root = (objectTypes[typeof window] && window) || this;
  67935. /** Backup possible global object */
  67936. var oldRoot = root;
  67937. /** Detect free variable `exports` */
  67938. var freeExports = objectTypes[typeof exports] && exports;
  67939. /** Detect free variable `module` */
  67940. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  67941. /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
  67942. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
  67943. if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
  67944. root = freeGlobal;
  67945. }
  67946. /*--------------------------------------------------------------------------*/
  67947. /*! Based on https://mths.be/fromcodepoint v0.2.0 by @mathias */
  67948. var stringFromCharCode = String.fromCharCode;
  67949. var floor = Math.floor;
  67950. function fromCodePoint() {
  67951. var MAX_SIZE = 0x4000;
  67952. var codeUnits = [];
  67953. var highSurrogate;
  67954. var lowSurrogate;
  67955. var index = -1;
  67956. var length = arguments.length;
  67957. if (!length) {
  67958. return '';
  67959. }
  67960. var result = '';
  67961. while (++index < length) {
  67962. var codePoint = Number(arguments[index]);
  67963. if (
  67964. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  67965. codePoint < 0 || // not a valid Unicode code point
  67966. codePoint > 0x10FFFF || // not a valid Unicode code point
  67967. floor(codePoint) != codePoint // not an integer
  67968. ) {
  67969. throw RangeError('Invalid code point: ' + codePoint);
  67970. }
  67971. if (codePoint <= 0xFFFF) {
  67972. // BMP code point
  67973. codeUnits.push(codePoint);
  67974. } else {
  67975. // Astral code point; split in surrogate halves
  67976. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  67977. codePoint -= 0x10000;
  67978. highSurrogate = (codePoint >> 10) + 0xD800;
  67979. lowSurrogate = (codePoint % 0x400) + 0xDC00;
  67980. codeUnits.push(highSurrogate, lowSurrogate);
  67981. }
  67982. if (index + 1 == length || codeUnits.length > MAX_SIZE) {
  67983. result += stringFromCharCode.apply(null, codeUnits);
  67984. codeUnits.length = 0;
  67985. }
  67986. }
  67987. return result;
  67988. }
  67989. function assertType(type, expected) {
  67990. if (expected.indexOf('|') == -1) {
  67991. if (type == expected) {
  67992. return;
  67993. }
  67994. throw Error('Invalid node type: ' + type);
  67995. }
  67996. expected = assertType.hasOwnProperty(expected)
  67997. ? assertType[expected]
  67998. : (assertType[expected] = RegExp('^(?:' + expected + ')$'));
  67999. if (expected.test(type)) {
  68000. return;
  68001. }
  68002. throw Error('Invalid node type: ' + type);
  68003. }
  68004. /*--------------------------------------------------------------------------*/
  68005. function generate(node) {
  68006. var type = node.type;
  68007. if (generate.hasOwnProperty(type) && typeof generate[type] == 'function') {
  68008. return generate[type](node);
  68009. }
  68010. throw Error('Invalid node type: ' + type);
  68011. }
  68012. /*--------------------------------------------------------------------------*/
  68013. function generateAlternative(node) {
  68014. assertType(node.type, 'alternative');
  68015. var terms = node.body,
  68016. length = terms ? terms.length : 0;
  68017. if (length == 1) {
  68018. return generateTerm(terms[0]);
  68019. } else {
  68020. var i = -1,
  68021. result = '';
  68022. while (++i < length) {
  68023. result += generateTerm(terms[i]);
  68024. }
  68025. return result;
  68026. }
  68027. }
  68028. function generateAnchor(node) {
  68029. assertType(node.type, 'anchor');
  68030. switch (node.kind) {
  68031. case 'start':
  68032. return '^';
  68033. case 'end':
  68034. return '$';
  68035. case 'boundary':
  68036. return '\\b';
  68037. case 'not-boundary':
  68038. return '\\B';
  68039. default:
  68040. throw Error('Invalid assertion');
  68041. }
  68042. }
  68043. function generateAtom(node) {
  68044. assertType(node.type, 'anchor|characterClass|characterClassEscape|dot|group|reference|value');
  68045. return generate(node);
  68046. }
  68047. function generateCharacterClass(node) {
  68048. assertType(node.type, 'characterClass');
  68049. var classRanges = node.body,
  68050. length = classRanges ? classRanges.length : 0;
  68051. var i = -1,
  68052. result = '[';
  68053. if (node.negative) {
  68054. result += '^';
  68055. }
  68056. while (++i < length) {
  68057. result += generateClassAtom(classRanges[i]);
  68058. }
  68059. result += ']';
  68060. return result;
  68061. }
  68062. function generateCharacterClassEscape(node) {
  68063. assertType(node.type, 'characterClassEscape');
  68064. return '\\' + node.value;
  68065. }
  68066. function generateCharacterClassRange(node) {
  68067. assertType(node.type, 'characterClassRange');
  68068. var min = node.min,
  68069. max = node.max;
  68070. if (min.type == 'characterClassRange' || max.type == 'characterClassRange') {
  68071. throw Error('Invalid character class range');
  68072. }
  68073. return generateClassAtom(min) + '-' + generateClassAtom(max);
  68074. }
  68075. function generateClassAtom(node) {
  68076. assertType(node.type, 'anchor|characterClassEscape|characterClassRange|dot|value');
  68077. return generate(node);
  68078. }
  68079. function generateDisjunction(node) {
  68080. assertType(node.type, 'disjunction');
  68081. var body = node.body,
  68082. length = body ? body.length : 0;
  68083. if (length == 0) {
  68084. throw Error('No body');
  68085. } else if (length == 1) {
  68086. return generate(body[0]);
  68087. } else {
  68088. var i = -1,
  68089. result = '';
  68090. while (++i < length) {
  68091. if (i != 0) {
  68092. result += '|';
  68093. }
  68094. result += generate(body[i]);
  68095. }
  68096. return result;
  68097. }
  68098. }
  68099. function generateDot(node) {
  68100. assertType(node.type, 'dot');
  68101. return '.';
  68102. }
  68103. function generateGroup(node) {
  68104. assertType(node.type, 'group');
  68105. var result = '(';
  68106. switch (node.behavior) {
  68107. case 'normal':
  68108. break;
  68109. case 'ignore':
  68110. result += '?:';
  68111. break;
  68112. case 'lookahead':
  68113. result += '?=';
  68114. break;
  68115. case 'negativeLookahead':
  68116. result += '?!';
  68117. break;
  68118. default:
  68119. throw Error('Invalid behaviour: ' + node.behaviour);
  68120. }
  68121. var body = node.body,
  68122. length = body ? body.length : 0;
  68123. if (length == 1) {
  68124. result += generate(body[0]);
  68125. } else {
  68126. var i = -1;
  68127. while (++i < length) {
  68128. result += generate(body[i]);
  68129. }
  68130. }
  68131. result += ')';
  68132. return result;
  68133. }
  68134. function generateQuantifier(node) {
  68135. assertType(node.type, 'quantifier');
  68136. var quantifier = '',
  68137. min = node.min,
  68138. max = node.max;
  68139. switch (max) {
  68140. case undefined:
  68141. case null:
  68142. switch (min) {
  68143. case 0:
  68144. quantifier = '*'
  68145. break;
  68146. case 1:
  68147. quantifier = '+';
  68148. break;
  68149. default:
  68150. quantifier = '{' + min + ',}';
  68151. break;
  68152. }
  68153. break;
  68154. default:
  68155. if (min == max) {
  68156. quantifier = '{' + min + '}';
  68157. }
  68158. else if (min == 0 && max == 1) {
  68159. quantifier = '?';
  68160. } else {
  68161. quantifier = '{' + min + ',' + max + '}';
  68162. }
  68163. break;
  68164. }
  68165. if (!node.greedy) {
  68166. quantifier += '?';
  68167. }
  68168. return generateAtom(node.body[0]) + quantifier;
  68169. }
  68170. function generateReference(node) {
  68171. assertType(node.type, 'reference');
  68172. return '\\' + node.matchIndex;
  68173. }
  68174. function generateTerm(node) {
  68175. assertType(node.type, 'anchor|characterClass|characterClassEscape|empty|group|quantifier|reference|value');
  68176. return generate(node);
  68177. }
  68178. function generateValue(node) {
  68179. assertType(node.type, 'value');
  68180. var kind = node.kind,
  68181. codePoint = node.codePoint;
  68182. switch (kind) {
  68183. case 'controlLetter':
  68184. return '\\c' + fromCodePoint(codePoint + 64);
  68185. case 'hexadecimalEscape':
  68186. return '\\x' + ('00' + codePoint.toString(16).toUpperCase()).slice(-2);
  68187. case 'identifier':
  68188. return '\\' + fromCodePoint(codePoint);
  68189. case 'null':
  68190. return '\\' + codePoint;
  68191. case 'octal':
  68192. return '\\' + codePoint.toString(8);
  68193. case 'singleEscape':
  68194. switch (codePoint) {
  68195. case 0x0008:
  68196. return '\\b';
  68197. case 0x009:
  68198. return '\\t';
  68199. case 0x00A:
  68200. return '\\n';
  68201. case 0x00B:
  68202. return '\\v';
  68203. case 0x00C:
  68204. return '\\f';
  68205. case 0x00D:
  68206. return '\\r';
  68207. default:
  68208. throw Error('Invalid codepoint: ' + codePoint);
  68209. }
  68210. case 'symbol':
  68211. return fromCodePoint(codePoint);
  68212. case 'unicodeEscape':
  68213. return '\\u' + ('0000' + codePoint.toString(16).toUpperCase()).slice(-4);
  68214. case 'unicodeCodePointEscape':
  68215. return '\\u{' + codePoint.toString(16).toUpperCase() + '}';
  68216. default:
  68217. throw Error('Unsupported node kind: ' + kind);
  68218. }
  68219. }
  68220. /*--------------------------------------------------------------------------*/
  68221. generate.alternative = generateAlternative;
  68222. generate.anchor = generateAnchor;
  68223. generate.characterClass = generateCharacterClass;
  68224. generate.characterClassEscape = generateCharacterClassEscape;
  68225. generate.characterClassRange = generateCharacterClassRange;
  68226. generate.disjunction = generateDisjunction;
  68227. generate.dot = generateDot;
  68228. generate.group = generateGroup;
  68229. generate.quantifier = generateQuantifier;
  68230. generate.reference = generateReference;
  68231. generate.value = generateValue;
  68232. /*--------------------------------------------------------------------------*/
  68233. // export regjsgen
  68234. // some AMD build optimizers, like r.js, check for condition patterns like the following:
  68235. if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
  68236. // define as an anonymous module so, through path mapping, it can be aliased
  68237. define(function() {
  68238. return {
  68239. 'generate': generate
  68240. };
  68241. });
  68242. }
  68243. // check for `exports` after `define` in case a build optimizer adds an `exports` object
  68244. else if (freeExports && freeModule) {
  68245. // in Narwhal, Node.js, Rhino -require, or RingoJS
  68246. freeExports.generate = generate;
  68247. }
  68248. // in a browser or Rhino
  68249. else {
  68250. root.regjsgen = {
  68251. 'generate': generate
  68252. };
  68253. }
  68254. }.call(this));
  68255. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  68256. },{}],477:[function(require,module,exports){
  68257. // regjsparser
  68258. //
  68259. // ==================================================================
  68260. //
  68261. // See ECMA-262 Standard: 15.10.1
  68262. //
  68263. // NOTE: The ECMA-262 standard uses the term "Assertion" for /^/. Here the
  68264. // term "Anchor" is used.
  68265. //
  68266. // Pattern ::
  68267. // Disjunction
  68268. //
  68269. // Disjunction ::
  68270. // Alternative
  68271. // Alternative | Disjunction
  68272. //
  68273. // Alternative ::
  68274. // [empty]
  68275. // Alternative Term
  68276. //
  68277. // Term ::
  68278. // Anchor
  68279. // Atom
  68280. // Atom Quantifier
  68281. //
  68282. // Anchor ::
  68283. // ^
  68284. // $
  68285. // \ b
  68286. // \ B
  68287. // ( ? = Disjunction )
  68288. // ( ? ! Disjunction )
  68289. //
  68290. // Quantifier ::
  68291. // QuantifierPrefix
  68292. // QuantifierPrefix ?
  68293. //
  68294. // QuantifierPrefix ::
  68295. // *
  68296. // +
  68297. // ?
  68298. // { DecimalDigits }
  68299. // { DecimalDigits , }
  68300. // { DecimalDigits , DecimalDigits }
  68301. //
  68302. // Atom ::
  68303. // PatternCharacter
  68304. // .
  68305. // \ AtomEscape
  68306. // CharacterClass
  68307. // ( Disjunction )
  68308. // ( ? : Disjunction )
  68309. //
  68310. // PatternCharacter ::
  68311. // SourceCharacter but not any of: ^ $ \ . * + ? ( ) [ ] { } |
  68312. //
  68313. // AtomEscape ::
  68314. // DecimalEscape
  68315. // CharacterEscape
  68316. // CharacterClassEscape
  68317. //
  68318. // CharacterEscape[U] ::
  68319. // ControlEscape
  68320. // c ControlLetter
  68321. // HexEscapeSequence
  68322. // RegExpUnicodeEscapeSequence[?U] (ES6)
  68323. // IdentityEscape[?U]
  68324. //
  68325. // ControlEscape ::
  68326. // one of f n r t v
  68327. // ControlLetter ::
  68328. // one of
  68329. // a b c d e f g h i j k l m n o p q r s t u v w x y z
  68330. // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  68331. //
  68332. // IdentityEscape ::
  68333. // SourceCharacter but not IdentifierPart
  68334. // <ZWJ>
  68335. // <ZWNJ>
  68336. //
  68337. // DecimalEscape ::
  68338. // DecimalIntegerLiteral [lookahead ∉ DecimalDigit]
  68339. //
  68340. // CharacterClassEscape ::
  68341. // one of d D s S w W
  68342. //
  68343. // CharacterClass ::
  68344. // [ [lookahead ∉ {^}] ClassRanges ]
  68345. // [ ^ ClassRanges ]
  68346. //
  68347. // ClassRanges ::
  68348. // [empty]
  68349. // NonemptyClassRanges
  68350. //
  68351. // NonemptyClassRanges ::
  68352. // ClassAtom
  68353. // ClassAtom NonemptyClassRangesNoDash
  68354. // ClassAtom - ClassAtom ClassRanges
  68355. //
  68356. // NonemptyClassRangesNoDash ::
  68357. // ClassAtom
  68358. // ClassAtomNoDash NonemptyClassRangesNoDash
  68359. // ClassAtomNoDash - ClassAtom ClassRanges
  68360. //
  68361. // ClassAtom ::
  68362. // -
  68363. // ClassAtomNoDash
  68364. //
  68365. // ClassAtomNoDash ::
  68366. // SourceCharacter but not one of \ or ] or -
  68367. // \ ClassEscape
  68368. //
  68369. // ClassEscape ::
  68370. // DecimalEscape
  68371. // b
  68372. // CharacterEscape
  68373. // CharacterClassEscape
  68374. (function() {
  68375. function parse(str, flags) {
  68376. function addRaw(node) {
  68377. node.raw = str.substring(node.range[0], node.range[1]);
  68378. return node;
  68379. }
  68380. function updateRawStart(node, start) {
  68381. node.range[0] = start;
  68382. return addRaw(node);
  68383. }
  68384. function createAnchor(kind, rawLength) {
  68385. return addRaw({
  68386. type: 'anchor',
  68387. kind: kind,
  68388. range: [
  68389. pos - rawLength,
  68390. pos
  68391. ]
  68392. });
  68393. }
  68394. function createValue(kind, codePoint, from, to) {
  68395. return addRaw({
  68396. type: 'value',
  68397. kind: kind,
  68398. codePoint: codePoint,
  68399. range: [from, to]
  68400. });
  68401. }
  68402. function createEscaped(kind, codePoint, value, fromOffset) {
  68403. fromOffset = fromOffset || 0;
  68404. return createValue(kind, codePoint, pos - (value.length + fromOffset), pos);
  68405. }
  68406. function createCharacter(matches) {
  68407. var _char = matches[0];
  68408. var first = _char.charCodeAt(0);
  68409. if (hasUnicodeFlag) {
  68410. var second;
  68411. if (_char.length === 1 && first >= 0xD800 && first <= 0xDBFF) {
  68412. second = lookahead().charCodeAt(0);
  68413. if (second >= 0xDC00 && second <= 0xDFFF) {
  68414. // Unicode surrogate pair
  68415. pos++;
  68416. return createValue(
  68417. 'symbol',
  68418. (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000,
  68419. pos - 2, pos);
  68420. }
  68421. }
  68422. }
  68423. return createValue('symbol', first, pos - 1, pos);
  68424. }
  68425. function createDisjunction(alternatives, from, to) {
  68426. return addRaw({
  68427. type: 'disjunction',
  68428. body: alternatives,
  68429. range: [
  68430. from,
  68431. to
  68432. ]
  68433. });
  68434. }
  68435. function createDot() {
  68436. return addRaw({
  68437. type: 'dot',
  68438. range: [
  68439. pos - 1,
  68440. pos
  68441. ]
  68442. });
  68443. }
  68444. function createCharacterClassEscape(value) {
  68445. return addRaw({
  68446. type: 'characterClassEscape',
  68447. value: value,
  68448. range: [
  68449. pos - 2,
  68450. pos
  68451. ]
  68452. });
  68453. }
  68454. function createReference(matchIndex) {
  68455. return addRaw({
  68456. type: 'reference',
  68457. matchIndex: parseInt(matchIndex, 10),
  68458. range: [
  68459. pos - 1 - matchIndex.length,
  68460. pos
  68461. ]
  68462. });
  68463. }
  68464. function createGroup(behavior, disjunction, from, to) {
  68465. return addRaw({
  68466. type: 'group',
  68467. behavior: behavior,
  68468. body: disjunction,
  68469. range: [
  68470. from,
  68471. to
  68472. ]
  68473. });
  68474. }
  68475. function createQuantifier(min, max, from, to) {
  68476. if (to == null) {
  68477. from = pos - 1;
  68478. to = pos;
  68479. }
  68480. return addRaw({
  68481. type: 'quantifier',
  68482. min: min,
  68483. max: max,
  68484. greedy: true,
  68485. body: null, // set later on,
  68486. range: [
  68487. from,
  68488. to
  68489. ]
  68490. });
  68491. }
  68492. function createAlternative(terms, from, to) {
  68493. return addRaw({
  68494. type: 'alternative',
  68495. body: terms,
  68496. range: [
  68497. from,
  68498. to
  68499. ]
  68500. });
  68501. }
  68502. function createCharacterClass(classRanges, negative, from, to) {
  68503. return addRaw({
  68504. type: 'characterClass',
  68505. body: classRanges,
  68506. negative: negative,
  68507. range: [
  68508. from,
  68509. to
  68510. ]
  68511. });
  68512. }
  68513. function createClassRange(min, max, from, to) {
  68514. // See 15.10.2.15:
  68515. if (min.codePoint > max.codePoint) {
  68516. throw SyntaxError('invalid range in character class');
  68517. }
  68518. return addRaw({
  68519. type: 'characterClassRange',
  68520. min: min,
  68521. max: max,
  68522. range: [
  68523. from,
  68524. to
  68525. ]
  68526. });
  68527. }
  68528. function flattenBody(body) {
  68529. if (body.type === 'alternative') {
  68530. return body.body;
  68531. } else {
  68532. return [body];
  68533. }
  68534. }
  68535. function isEmpty(obj) {
  68536. return obj.type === 'empty';
  68537. }
  68538. function incr(amount) {
  68539. amount = (amount || 1);
  68540. var res = str.substring(pos, pos + amount);
  68541. pos += (amount || 1);
  68542. return res;
  68543. }
  68544. function skip(value) {
  68545. if (!match(value)) {
  68546. throw SyntaxError('character: ' + value);
  68547. }
  68548. }
  68549. function match(value) {
  68550. if (str.indexOf(value, pos) === pos) {
  68551. return incr(value.length);
  68552. }
  68553. }
  68554. function lookahead() {
  68555. return str[pos];
  68556. }
  68557. function current(value) {
  68558. return str.indexOf(value, pos) === pos;
  68559. }
  68560. function next(value) {
  68561. return str[pos + 1] === value;
  68562. }
  68563. function matchReg(regExp) {
  68564. var subStr = str.substring(pos);
  68565. var res = subStr.match(regExp);
  68566. if (res) {
  68567. res.range = [];
  68568. res.range[0] = pos;
  68569. incr(res[0].length);
  68570. res.range[1] = pos;
  68571. }
  68572. return res;
  68573. }
  68574. function parseDisjunction() {
  68575. // Disjunction ::
  68576. // Alternative
  68577. // Alternative | Disjunction
  68578. var res = [], from = pos;
  68579. res.push(parseAlternative());
  68580. while (match('|')) {
  68581. res.push(parseAlternative());
  68582. }
  68583. if (res.length === 1) {
  68584. return res[0];
  68585. }
  68586. return createDisjunction(res, from, pos);
  68587. }
  68588. function parseAlternative() {
  68589. var res = [], from = pos;
  68590. var term;
  68591. // Alternative ::
  68592. // [empty]
  68593. // Alternative Term
  68594. while (term = parseTerm()) {
  68595. res.push(term);
  68596. }
  68597. if (res.length === 1) {
  68598. return res[0];
  68599. }
  68600. return createAlternative(res, from, pos);
  68601. }
  68602. function parseTerm() {
  68603. // Term ::
  68604. // Anchor
  68605. // Atom
  68606. // Atom Quantifier
  68607. if (pos >= str.length || current('|') || current(')')) {
  68608. return null; /* Means: The term is empty */
  68609. }
  68610. var anchor = parseAnchor();
  68611. if (anchor) {
  68612. return anchor;
  68613. }
  68614. var atom = parseAtom();
  68615. if (!atom) {
  68616. throw SyntaxError('Expected atom')
  68617. }
  68618. var quantifier = parseQuantifier() || false;
  68619. if (quantifier) {
  68620. quantifier.body = flattenBody(atom);
  68621. // The quantifier contains the atom. Therefore, the beginning of the
  68622. // quantifier range is given by the beginning of the atom.
  68623. updateRawStart(quantifier, atom.range[0]);
  68624. return quantifier;
  68625. }
  68626. return atom;
  68627. }
  68628. function parseGroup(matchA, typeA, matchB, typeB) {
  68629. var type = null, from = pos;
  68630. if (match(matchA)) {
  68631. type = typeA;
  68632. } else if (match(matchB)) {
  68633. type = typeB;
  68634. } else {
  68635. return false;
  68636. }
  68637. var body = parseDisjunction();
  68638. if (!body) {
  68639. throw SyntaxError('Expected disjunction');
  68640. }
  68641. skip(')');
  68642. var group = createGroup(type, flattenBody(body), from, pos);
  68643. if (type == 'normal') {
  68644. // Keep track of the number of closed groups. This is required for
  68645. // parseDecimalEscape(). In case the string is parsed a second time the
  68646. // value already holds the total count and no incrementation is required.
  68647. if (firstIteration) {
  68648. closedCaptureCounter++;
  68649. }
  68650. }
  68651. return group;
  68652. }
  68653. function parseAnchor() {
  68654. // Anchor ::
  68655. // ^
  68656. // $
  68657. // \ b
  68658. // \ B
  68659. // ( ? = Disjunction )
  68660. // ( ? ! Disjunction )
  68661. var res, from = pos;
  68662. if (match('^')) {
  68663. return createAnchor('start', 1 /* rawLength */);
  68664. } else if (match('$')) {
  68665. return createAnchor('end', 1 /* rawLength */);
  68666. } else if (match('\\b')) {
  68667. return createAnchor('boundary', 2 /* rawLength */);
  68668. } else if (match('\\B')) {
  68669. return createAnchor('not-boundary', 2 /* rawLength */);
  68670. } else {
  68671. return parseGroup('(?=', 'lookahead', '(?!', 'negativeLookahead');
  68672. }
  68673. }
  68674. function parseQuantifier() {
  68675. // Quantifier ::
  68676. // QuantifierPrefix
  68677. // QuantifierPrefix ?
  68678. //
  68679. // QuantifierPrefix ::
  68680. // *
  68681. // +
  68682. // ?
  68683. // { DecimalDigits }
  68684. // { DecimalDigits , }
  68685. // { DecimalDigits , DecimalDigits }
  68686. var res;
  68687. var quantifier;
  68688. var min, max;
  68689. if (match('*')) {
  68690. quantifier = createQuantifier(0);
  68691. }
  68692. else if (match('+')) {
  68693. quantifier = createQuantifier(1);
  68694. }
  68695. else if (match('?')) {
  68696. quantifier = createQuantifier(0, 1);
  68697. }
  68698. else if (res = matchReg(/^\{([0-9]+)\}/)) {
  68699. min = parseInt(res[1], 10);
  68700. quantifier = createQuantifier(min, min, res.range[0], res.range[1]);
  68701. }
  68702. else if (res = matchReg(/^\{([0-9]+),\}/)) {
  68703. min = parseInt(res[1], 10);
  68704. quantifier = createQuantifier(min, undefined, res.range[0], res.range[1]);
  68705. }
  68706. else if (res = matchReg(/^\{([0-9]+),([0-9]+)\}/)) {
  68707. min = parseInt(res[1], 10);
  68708. max = parseInt(res[2], 10);
  68709. if (min > max) {
  68710. throw SyntaxError('numbers out of order in {} quantifier');
  68711. }
  68712. quantifier = createQuantifier(min, max, res.range[0], res.range[1]);
  68713. }
  68714. if (quantifier) {
  68715. if (match('?')) {
  68716. quantifier.greedy = false;
  68717. quantifier.range[1] += 1;
  68718. }
  68719. }
  68720. return quantifier;
  68721. }
  68722. function parseAtom() {
  68723. // Atom ::
  68724. // PatternCharacter
  68725. // .
  68726. // \ AtomEscape
  68727. // CharacterClass
  68728. // ( Disjunction )
  68729. // ( ? : Disjunction )
  68730. var res;
  68731. // jviereck: allow ']', '}' here as well to be compatible with browser's
  68732. // implementations: ']'.match(/]/);
  68733. // if (res = matchReg(/^[^^$\\.*+?()[\]{}|]/)) {
  68734. if (res = matchReg(/^[^^$\\.*+?(){[|]/)) {
  68735. // PatternCharacter
  68736. return createCharacter(res);
  68737. }
  68738. else if (match('.')) {
  68739. // .
  68740. return createDot();
  68741. }
  68742. else if (match('\\')) {
  68743. // \ AtomEscape
  68744. res = parseAtomEscape();
  68745. if (!res) {
  68746. throw SyntaxError('atomEscape');
  68747. }
  68748. return res;
  68749. }
  68750. else if (res = parseCharacterClass()) {
  68751. return res;
  68752. }
  68753. else {
  68754. // ( Disjunction )
  68755. // ( ? : Disjunction )
  68756. return parseGroup('(?:', 'ignore', '(', 'normal');
  68757. }
  68758. }
  68759. function parseUnicodeSurrogatePairEscape(firstEscape) {
  68760. if (hasUnicodeFlag) {
  68761. var first, second;
  68762. if (firstEscape.kind == 'unicodeEscape' &&
  68763. (first = firstEscape.codePoint) >= 0xD800 && first <= 0xDBFF &&
  68764. current('\\') && next('u') ) {
  68765. var prevPos = pos;
  68766. pos++;
  68767. var secondEscape = parseClassEscape();
  68768. if (secondEscape.kind == 'unicodeEscape' &&
  68769. (second = secondEscape.codePoint) >= 0xDC00 && second <= 0xDFFF) {
  68770. // Unicode surrogate pair
  68771. firstEscape.range[1] = secondEscape.range[1];
  68772. firstEscape.codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
  68773. firstEscape.type = 'value';
  68774. firstEscape.kind = 'unicodeCodePointEscape';
  68775. addRaw(firstEscape);
  68776. }
  68777. else {
  68778. pos = prevPos;
  68779. }
  68780. }
  68781. }
  68782. return firstEscape;
  68783. }
  68784. function parseClassEscape() {
  68785. return parseAtomEscape(true);
  68786. }
  68787. function parseAtomEscape(insideCharacterClass) {
  68788. // AtomEscape ::
  68789. // DecimalEscape
  68790. // CharacterEscape
  68791. // CharacterClassEscape
  68792. var res;
  68793. res = parseDecimalEscape();
  68794. if (res) {
  68795. return res;
  68796. }
  68797. // For ClassEscape
  68798. if (insideCharacterClass) {
  68799. if (match('b')) {
  68800. // 15.10.2.19
  68801. // The production ClassEscape :: b evaluates by returning the
  68802. // CharSet containing the one character <BS> (Unicode value 0008).
  68803. return createEscaped('singleEscape', 0x0008, '\\b');
  68804. } else if (match('B')) {
  68805. throw SyntaxError('\\B not possible inside of CharacterClass');
  68806. }
  68807. }
  68808. res = parseCharacterEscape();
  68809. return res;
  68810. }
  68811. function parseDecimalEscape() {
  68812. // DecimalEscape ::
  68813. // DecimalIntegerLiteral [lookahead ∉ DecimalDigit]
  68814. // CharacterClassEscape :: one of d D s S w W
  68815. var res, match;
  68816. if (res = matchReg(/^(?!0)\d+/)) {
  68817. match = res[0];
  68818. var refIdx = parseInt(res[0], 10);
  68819. if (refIdx <= closedCaptureCounter) {
  68820. // If the number is smaller than the normal-groups found so
  68821. // far, then it is a reference...
  68822. return createReference(res[0]);
  68823. } else {
  68824. // ... otherwise it needs to be interpreted as a octal (if the
  68825. // number is in an octal format). If it is NOT octal format,
  68826. // then the slash is ignored and the number is matched later
  68827. // as normal characters.
  68828. // Recall the negative decision to decide if the input must be parsed
  68829. // a second time with the total normal-groups.
  68830. backrefDenied.push(refIdx);
  68831. // Reset the position again, as maybe only parts of the previous
  68832. // matched numbers are actual octal numbers. E.g. in '019' only
  68833. // the '01' should be matched.
  68834. incr(-res[0].length);
  68835. if (res = matchReg(/^[0-7]{1,3}/)) {
  68836. return createEscaped('octal', parseInt(res[0], 8), res[0], 1);
  68837. } else {
  68838. // If we end up here, we have a case like /\91/. Then the
  68839. // first slash is to be ignored and the 9 & 1 to be treated
  68840. // like ordinary characters. Create a character for the
  68841. // first number only here - other number-characters
  68842. // (if available) will be matched later.
  68843. res = createCharacter(matchReg(/^[89]/));
  68844. return updateRawStart(res, res.range[0] - 1);
  68845. }
  68846. }
  68847. }
  68848. // Only allow octal numbers in the following. All matched numbers start
  68849. // with a zero (if the do not, the previous if-branch is executed).
  68850. // If the number is not octal format and starts with zero (e.g. `091`)
  68851. // then only the zeros `0` is treated here and the `91` are ordinary
  68852. // characters.
  68853. // Example:
  68854. // /\091/.exec('\091')[0].length === 3
  68855. else if (res = matchReg(/^[0-7]{1,3}/)) {
  68856. match = res[0];
  68857. if (/^0{1,3}$/.test(match)) {
  68858. // If they are all zeros, then only take the first one.
  68859. return createEscaped('null', 0x0000, '0', match.length + 1);
  68860. } else {
  68861. return createEscaped('octal', parseInt(match, 8), match, 1);
  68862. }
  68863. } else if (res = matchReg(/^[dDsSwW]/)) {
  68864. return createCharacterClassEscape(res[0]);
  68865. }
  68866. return false;
  68867. }
  68868. function parseCharacterEscape() {
  68869. // CharacterEscape ::
  68870. // ControlEscape
  68871. // c ControlLetter
  68872. // HexEscapeSequence
  68873. // UnicodeEscapeSequence
  68874. // IdentityEscape
  68875. var res;
  68876. if (res = matchReg(/^[fnrtv]/)) {
  68877. // ControlEscape
  68878. var codePoint = 0;
  68879. switch (res[0]) {
  68880. case 't': codePoint = 0x009; break;
  68881. case 'n': codePoint = 0x00A; break;
  68882. case 'v': codePoint = 0x00B; break;
  68883. case 'f': codePoint = 0x00C; break;
  68884. case 'r': codePoint = 0x00D; break;
  68885. }
  68886. return createEscaped('singleEscape', codePoint, '\\' + res[0]);
  68887. } else if (res = matchReg(/^c([a-zA-Z])/)) {
  68888. // c ControlLetter
  68889. return createEscaped('controlLetter', res[1].charCodeAt(0) % 32, res[1], 2);
  68890. } else if (res = matchReg(/^x([0-9a-fA-F]{2})/)) {
  68891. // HexEscapeSequence
  68892. return createEscaped('hexadecimalEscape', parseInt(res[1], 16), res[1], 2);
  68893. } else if (res = matchReg(/^u([0-9a-fA-F]{4})/)) {
  68894. // UnicodeEscapeSequence
  68895. return parseUnicodeSurrogatePairEscape(
  68896. createEscaped('unicodeEscape', parseInt(res[1], 16), res[1], 2)
  68897. );
  68898. } else if (hasUnicodeFlag && (res = matchReg(/^u\{([0-9a-fA-F]+)\}/))) {
  68899. // RegExpUnicodeEscapeSequence (ES6 Unicode code point escape)
  68900. return createEscaped('unicodeCodePointEscape', parseInt(res[1], 16), res[1], 4);
  68901. } else {
  68902. // IdentityEscape
  68903. return parseIdentityEscape();
  68904. }
  68905. }
  68906. // Taken from the Esprima parser.
  68907. function isIdentifierPart(ch) {
  68908. // Generated by `tools/generate-identifier-regex.js`.
  68909. var NonAsciiIdentifierPart = new RegExp('[\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-\u08B2\u08E4-\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\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\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\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\u0D57\u0D60-\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-\u13F4\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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-\uFE2D\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]');
  68910. return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
  68911. (ch >= 65 && ch <= 90) || // A..Z
  68912. (ch >= 97 && ch <= 122) || // a..z
  68913. (ch >= 48 && ch <= 57) || // 0..9
  68914. (ch === 92) || // \ (backslash)
  68915. ((ch >= 0x80) && NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
  68916. }
  68917. function parseIdentityEscape() {
  68918. // IdentityEscape ::
  68919. // SourceCharacter but not IdentifierPart
  68920. // <ZWJ>
  68921. // <ZWNJ>
  68922. var ZWJ = '\u200C';
  68923. var ZWNJ = '\u200D';
  68924. var res;
  68925. var tmp;
  68926. if (!isIdentifierPart(lookahead())) {
  68927. tmp = incr();
  68928. return createEscaped('identifier', tmp.charCodeAt(0), tmp, 1);
  68929. }
  68930. if (match(ZWJ)) {
  68931. // <ZWJ>
  68932. return createEscaped('identifier', 0x200C, ZWJ);
  68933. } else if (match(ZWNJ)) {
  68934. // <ZWNJ>
  68935. return createEscaped('identifier', 0x200D, ZWNJ);
  68936. }
  68937. return null;
  68938. }
  68939. function parseCharacterClass() {
  68940. // CharacterClass ::
  68941. // [ [lookahead ∉ {^}] ClassRanges ]
  68942. // [ ^ ClassRanges ]
  68943. var res, from = pos;
  68944. if (res = matchReg(/^\[\^/)) {
  68945. res = parseClassRanges();
  68946. skip(']');
  68947. return createCharacterClass(res, true, from, pos);
  68948. } else if (match('[')) {
  68949. res = parseClassRanges();
  68950. skip(']');
  68951. return createCharacterClass(res, false, from, pos);
  68952. }
  68953. return null;
  68954. }
  68955. function parseClassRanges() {
  68956. // ClassRanges ::
  68957. // [empty]
  68958. // NonemptyClassRanges
  68959. var res;
  68960. if (current(']')) {
  68961. // Empty array means nothing insinde of the ClassRange.
  68962. return [];
  68963. } else {
  68964. res = parseNonemptyClassRanges();
  68965. if (!res) {
  68966. throw SyntaxError('nonEmptyClassRanges');
  68967. }
  68968. return res;
  68969. }
  68970. }
  68971. function parseHelperClassRanges(atom) {
  68972. var from, to, res;
  68973. if (current('-') && !next(']')) {
  68974. // ClassAtom - ClassAtom ClassRanges
  68975. skip('-');
  68976. res = parseClassAtom();
  68977. if (!res) {
  68978. throw SyntaxError('classAtom');
  68979. }
  68980. to = pos;
  68981. var classRanges = parseClassRanges();
  68982. if (!classRanges) {
  68983. throw SyntaxError('classRanges');
  68984. }
  68985. from = atom.range[0];
  68986. if (classRanges.type === 'empty') {
  68987. return [createClassRange(atom, res, from, to)];
  68988. }
  68989. return [createClassRange(atom, res, from, to)].concat(classRanges);
  68990. }
  68991. res = parseNonemptyClassRangesNoDash();
  68992. if (!res) {
  68993. throw SyntaxError('nonEmptyClassRangesNoDash');
  68994. }
  68995. return [atom].concat(res);
  68996. }
  68997. function parseNonemptyClassRanges() {
  68998. // NonemptyClassRanges ::
  68999. // ClassAtom
  69000. // ClassAtom NonemptyClassRangesNoDash
  69001. // ClassAtom - ClassAtom ClassRanges
  69002. var atom = parseClassAtom();
  69003. if (!atom) {
  69004. throw SyntaxError('classAtom');
  69005. }
  69006. if (current(']')) {
  69007. // ClassAtom
  69008. return [atom];
  69009. }
  69010. // ClassAtom NonemptyClassRangesNoDash
  69011. // ClassAtom - ClassAtom ClassRanges
  69012. return parseHelperClassRanges(atom);
  69013. }
  69014. function parseNonemptyClassRangesNoDash() {
  69015. // NonemptyClassRangesNoDash ::
  69016. // ClassAtom
  69017. // ClassAtomNoDash NonemptyClassRangesNoDash
  69018. // ClassAtomNoDash - ClassAtom ClassRanges
  69019. var res = parseClassAtom();
  69020. if (!res) {
  69021. throw SyntaxError('classAtom');
  69022. }
  69023. if (current(']')) {
  69024. // ClassAtom
  69025. return res;
  69026. }
  69027. // ClassAtomNoDash NonemptyClassRangesNoDash
  69028. // ClassAtomNoDash - ClassAtom ClassRanges
  69029. return parseHelperClassRanges(res);
  69030. }
  69031. function parseClassAtom() {
  69032. // ClassAtom ::
  69033. // -
  69034. // ClassAtomNoDash
  69035. if (match('-')) {
  69036. return createCharacter('-');
  69037. } else {
  69038. return parseClassAtomNoDash();
  69039. }
  69040. }
  69041. function parseClassAtomNoDash() {
  69042. // ClassAtomNoDash ::
  69043. // SourceCharacter but not one of \ or ] or -
  69044. // \ ClassEscape
  69045. var res;
  69046. if (res = matchReg(/^[^\\\]-]/)) {
  69047. return createCharacter(res[0]);
  69048. } else if (match('\\')) {
  69049. res = parseClassEscape();
  69050. if (!res) {
  69051. throw SyntaxError('classEscape');
  69052. }
  69053. return parseUnicodeSurrogatePairEscape(res);
  69054. }
  69055. }
  69056. var backrefDenied = [];
  69057. var closedCaptureCounter = 0;
  69058. var firstIteration = true;
  69059. var hasUnicodeFlag = (flags || "").indexOf("u") !== -1;
  69060. var pos = 0;
  69061. // Convert the input to a string and treat the empty string special.
  69062. str = String(str);
  69063. if (str === '') {
  69064. str = '(?:)';
  69065. }
  69066. var result = parseDisjunction();
  69067. if (result.range[1] !== str.length) {
  69068. throw SyntaxError('Could not parse entire input - got stuck: ' + str);
  69069. }
  69070. // The spec requires to interpret the `\2` in `/\2()()/` as backreference.
  69071. // As the parser collects the number of capture groups as the string is
  69072. // parsed it is impossible to make these decisions at the point the `\2` is
  69073. // handled. In case the local decision turns out to be wrongq after the
  69074. // parsing has finished, the input string is parsed a second time with the
  69075. // total count of capture groups set.
  69076. //
  69077. // SEE: https://github.com/jviereck/regjsparser/issues/70
  69078. for (var i = 0; i < backrefDenied.length; i++) {
  69079. if (backrefDenied[i] <= closedCaptureCounter) {
  69080. // Parse the input a second time.
  69081. pos = 0;
  69082. firstIteration = false;
  69083. return parseDisjunction();
  69084. }
  69085. }
  69086. return result;
  69087. };
  69088. var regjsparser = {
  69089. parse: parse
  69090. };
  69091. if (typeof module !== 'undefined' && module.exports) {
  69092. module.exports = regjsparser;
  69093. } else {
  69094. window.regjsparser = regjsparser;
  69095. }
  69096. }());
  69097. },{}],478:[function(require,module,exports){
  69098. var generate = require('regjsgen').generate;
  69099. var parse = require('regjsparser').parse;
  69100. var regenerate = require('regenerate');
  69101. var iuMappings = require('./data/iu-mappings.json');
  69102. var ESCAPE_SETS = require('./data/character-class-escape-sets.js');
  69103. function getCharacterClassEscapeSet(character) {
  69104. if (unicode) {
  69105. if (ignoreCase) {
  69106. return ESCAPE_SETS.UNICODE_IGNORE_CASE[character];
  69107. }
  69108. return ESCAPE_SETS.UNICODE[character];
  69109. }
  69110. return ESCAPE_SETS.REGULAR[character];
  69111. }
  69112. var object = {};
  69113. var hasOwnProperty = object.hasOwnProperty;
  69114. function has(object, property) {
  69115. return hasOwnProperty.call(object, property);
  69116. }
  69117. // Prepare a Regenerate set containing all code points, used for negative
  69118. // character classes (if any).
  69119. var UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF);
  69120. // Without the `u` flag, the range stops at 0xFFFF.
  69121. // https://mths.be/es6#sec-pattern-semantics
  69122. var BMP_SET = regenerate().addRange(0x0, 0xFFFF);
  69123. // Prepare a Regenerate set containing all code points that are supposed to be
  69124. // matched by `/./u`. https://mths.be/es6#sec-atom
  69125. var DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points
  69126. .remove(
  69127. // minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators):
  69128. 0x000A, // Line Feed <LF>
  69129. 0x000D, // Carriage Return <CR>
  69130. 0x2028, // Line Separator <LS>
  69131. 0x2029 // Paragraph Separator <PS>
  69132. );
  69133. // Prepare a Regenerate set containing all code points that are supposed to be
  69134. // matched by `/./` (only BMP code points).
  69135. var DOT_SET = DOT_SET_UNICODE.clone()
  69136. .intersection(BMP_SET);
  69137. // Add a range of code points + any case-folded code points in that range to a
  69138. // set.
  69139. regenerate.prototype.iuAddRange = function(min, max) {
  69140. var $this = this;
  69141. do {
  69142. var folded = caseFold(min);
  69143. if (folded) {
  69144. $this.add(folded);
  69145. }
  69146. } while (++min <= max);
  69147. return $this;
  69148. };
  69149. function assign(target, source) {
  69150. for (var key in source) {
  69151. // Note: `hasOwnProperty` is not needed here.
  69152. target[key] = source[key];
  69153. }
  69154. }
  69155. function update(item, pattern) {
  69156. // TODO: Test if memoizing `pattern` here is worth the effort.
  69157. if (!pattern) {
  69158. return;
  69159. }
  69160. var tree = parse(pattern, '');
  69161. switch (tree.type) {
  69162. case 'characterClass':
  69163. case 'group':
  69164. case 'value':
  69165. // No wrapping needed.
  69166. break;
  69167. default:
  69168. // Wrap the pattern in a non-capturing group.
  69169. tree = wrap(tree, pattern);
  69170. }
  69171. assign(item, tree);
  69172. }
  69173. function wrap(tree, pattern) {
  69174. // Wrap the pattern in a non-capturing group.
  69175. return {
  69176. 'type': 'group',
  69177. 'behavior': 'ignore',
  69178. 'body': [tree],
  69179. 'raw': '(?:' + pattern + ')'
  69180. };
  69181. }
  69182. function caseFold(codePoint) {
  69183. return has(iuMappings, codePoint) ? iuMappings[codePoint] : false;
  69184. }
  69185. var ignoreCase = false;
  69186. var unicode = false;
  69187. function processCharacterClass(characterClassItem) {
  69188. var set = regenerate();
  69189. var body = characterClassItem.body.forEach(function(item) {
  69190. switch (item.type) {
  69191. case 'value':
  69192. set.add(item.codePoint);
  69193. if (ignoreCase && unicode) {
  69194. var folded = caseFold(item.codePoint);
  69195. if (folded) {
  69196. set.add(folded);
  69197. }
  69198. }
  69199. break;
  69200. case 'characterClassRange':
  69201. var min = item.min.codePoint;
  69202. var max = item.max.codePoint;
  69203. set.addRange(min, max);
  69204. if (ignoreCase && unicode) {
  69205. set.iuAddRange(min, max);
  69206. }
  69207. break;
  69208. case 'characterClassEscape':
  69209. set.add(getCharacterClassEscapeSet(item.value));
  69210. break;
  69211. // The `default` clause is only here as a safeguard; it should never be
  69212. // reached. Code coverage tools should ignore it.
  69213. /* istanbul ignore next */
  69214. default:
  69215. throw Error('Unknown term type: ' + item.type);
  69216. }
  69217. });
  69218. if (characterClassItem.negative) {
  69219. set = (unicode ? UNICODE_SET : BMP_SET).clone().remove(set);
  69220. }
  69221. update(characterClassItem, set.toString());
  69222. return characterClassItem;
  69223. }
  69224. function processTerm(item) {
  69225. switch (item.type) {
  69226. case 'dot':
  69227. update(
  69228. item,
  69229. (unicode ? DOT_SET_UNICODE : DOT_SET).toString()
  69230. );
  69231. break;
  69232. case 'characterClass':
  69233. item = processCharacterClass(item);
  69234. break;
  69235. case 'characterClassEscape':
  69236. update(
  69237. item,
  69238. getCharacterClassEscapeSet(item.value).toString()
  69239. );
  69240. break;
  69241. case 'alternative':
  69242. case 'disjunction':
  69243. case 'group':
  69244. case 'quantifier':
  69245. item.body = item.body.map(processTerm);
  69246. break;
  69247. case 'value':
  69248. var codePoint = item.codePoint;
  69249. var set = regenerate(codePoint);
  69250. if (ignoreCase && unicode) {
  69251. var folded = caseFold(codePoint);
  69252. if (folded) {
  69253. set.add(folded);
  69254. }
  69255. }
  69256. update(item, set.toString());
  69257. break;
  69258. case 'anchor':
  69259. case 'empty':
  69260. case 'group':
  69261. case 'reference':
  69262. // Nothing to do here.
  69263. break;
  69264. // The `default` clause is only here as a safeguard; it should never be
  69265. // reached. Code coverage tools should ignore it.
  69266. /* istanbul ignore next */
  69267. default:
  69268. throw Error('Unknown term type: ' + item.type);
  69269. }
  69270. return item;
  69271. };
  69272. module.exports = function(pattern, flags) {
  69273. var tree = parse(pattern, flags);
  69274. ignoreCase = flags ? flags.indexOf('i') > -1 : false;
  69275. unicode = flags ? flags.indexOf('u') > -1 : false;
  69276. assign(tree, processTerm(tree));
  69277. return generate(tree);
  69278. };
  69279. },{"./data/character-class-escape-sets.js":473,"./data/iu-mappings.json":474,"regenerate":475,"regjsgen":476,"regjsparser":477}],479:[function(require,module,exports){
  69280. 'use strict';
  69281. var isFinite = require('is-finite');
  69282. module.exports = function (str, n) {
  69283. if (typeof str !== 'string') {
  69284. throw new TypeError('Expected a string as the first argument');
  69285. }
  69286. if (n < 0 || !isFinite(n)) {
  69287. throw new TypeError('Expected a finite positive number');
  69288. }
  69289. var ret = '';
  69290. do {
  69291. if (n & 1) {
  69292. ret += str;
  69293. }
  69294. str += str;
  69295. } while (n = n >> 1);
  69296. return ret;
  69297. };
  69298. },{"is-finite":480}],480:[function(require,module,exports){
  69299. arguments[4][318][0].apply(exports,arguments)
  69300. },{"dup":318}],481:[function(require,module,exports){
  69301. 'use strict';
  69302. module.exports = /^#!.*/;
  69303. },{}],482:[function(require,module,exports){
  69304. 'use strict';
  69305. module.exports = function (str) {
  69306. var isExtendedLengthPath = /^\\\\\?\\/.test(str);
  69307. var hasNonAscii = /[^\x00-\x80]+/.test(str);
  69308. if (isExtendedLengthPath || hasNonAscii) {
  69309. return str;
  69310. }
  69311. return str.replace(/\\/g, '/');
  69312. };
  69313. },{}],483:[function(require,module,exports){
  69314. /*
  69315. * Copyright 2009-2011 Mozilla Foundation and contributors
  69316. * Licensed under the New BSD license. See LICENSE.txt or:
  69317. * http://opensource.org/licenses/BSD-3-Clause
  69318. */
  69319. exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
  69320. exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
  69321. exports.SourceNode = require('./source-map/source-node').SourceNode;
  69322. },{"./source-map/source-map-consumer":489,"./source-map/source-map-generator":490,"./source-map/source-node":491}],484:[function(require,module,exports){
  69323. /* -*- Mode: js; js-indent-level: 2; -*- */
  69324. /*
  69325. * Copyright 2011 Mozilla Foundation and contributors
  69326. * Licensed under the New BSD license. See LICENSE or:
  69327. * http://opensource.org/licenses/BSD-3-Clause
  69328. */
  69329. if (typeof define !== 'function') {
  69330. var define = require('amdefine')(module, require);
  69331. }
  69332. define(function (require, exports, module) {
  69333. var util = require('./util');
  69334. /**
  69335. * A data structure which is a combination of an array and a set. Adding a new
  69336. * member is O(1), testing for membership is O(1), and finding the index of an
  69337. * element is O(1). Removing elements from the set is not supported. Only
  69338. * strings are supported for membership.
  69339. */
  69340. function ArraySet() {
  69341. this._array = [];
  69342. this._set = {};
  69343. }
  69344. /**
  69345. * Static method for creating ArraySet instances from an existing array.
  69346. */
  69347. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  69348. var set = new ArraySet();
  69349. for (var i = 0, len = aArray.length; i < len; i++) {
  69350. set.add(aArray[i], aAllowDuplicates);
  69351. }
  69352. return set;
  69353. };
  69354. /**
  69355. * Add the given string to this set.
  69356. *
  69357. * @param String aStr
  69358. */
  69359. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  69360. var isDuplicate = this.has(aStr);
  69361. var idx = this._array.length;
  69362. if (!isDuplicate || aAllowDuplicates) {
  69363. this._array.push(aStr);
  69364. }
  69365. if (!isDuplicate) {
  69366. this._set[util.toSetString(aStr)] = idx;
  69367. }
  69368. };
  69369. /**
  69370. * Is the given string a member of this set?
  69371. *
  69372. * @param String aStr
  69373. */
  69374. ArraySet.prototype.has = function ArraySet_has(aStr) {
  69375. return Object.prototype.hasOwnProperty.call(this._set,
  69376. util.toSetString(aStr));
  69377. };
  69378. /**
  69379. * What is the index of the given string in the array?
  69380. *
  69381. * @param String aStr
  69382. */
  69383. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  69384. if (this.has(aStr)) {
  69385. return this._set[util.toSetString(aStr)];
  69386. }
  69387. throw new Error('"' + aStr + '" is not in the set.');
  69388. };
  69389. /**
  69390. * What is the element at the given index?
  69391. *
  69392. * @param Number aIdx
  69393. */
  69394. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  69395. if (aIdx >= 0 && aIdx < this._array.length) {
  69396. return this._array[aIdx];
  69397. }
  69398. throw new Error('No element indexed by ' + aIdx);
  69399. };
  69400. /**
  69401. * Returns the array representation of this set (which has the proper indices
  69402. * indicated by indexOf). Note that this is a copy of the internal array used
  69403. * for storing the members so that no one can mess with internal state.
  69404. */
  69405. ArraySet.prototype.toArray = function ArraySet_toArray() {
  69406. return this._array.slice();
  69407. };
  69408. exports.ArraySet = ArraySet;
  69409. });
  69410. },{"./util":492,"amdefine":493}],485:[function(require,module,exports){
  69411. /* -*- Mode: js; js-indent-level: 2; -*- */
  69412. /*
  69413. * Copyright 2011 Mozilla Foundation and contributors
  69414. * Licensed under the New BSD license. See LICENSE or:
  69415. * http://opensource.org/licenses/BSD-3-Clause
  69416. *
  69417. * Based on the Base 64 VLQ implementation in Closure Compiler:
  69418. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  69419. *
  69420. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  69421. * Redistribution and use in source and binary forms, with or without
  69422. * modification, are permitted provided that the following conditions are
  69423. * met:
  69424. *
  69425. * * Redistributions of source code must retain the above copyright
  69426. * notice, this list of conditions and the following disclaimer.
  69427. * * Redistributions in binary form must reproduce the above
  69428. * copyright notice, this list of conditions and the following
  69429. * disclaimer in the documentation and/or other materials provided
  69430. * with the distribution.
  69431. * * Neither the name of Google Inc. nor the names of its
  69432. * contributors may be used to endorse or promote products derived
  69433. * from this software without specific prior written permission.
  69434. *
  69435. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  69436. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  69437. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  69438. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  69439. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  69440. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  69441. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  69442. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  69443. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  69444. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  69445. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  69446. */
  69447. if (typeof define !== 'function') {
  69448. var define = require('amdefine')(module, require);
  69449. }
  69450. define(function (require, exports, module) {
  69451. var base64 = require('./base64');
  69452. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  69453. // length quantities we use in the source map spec, the first bit is the sign,
  69454. // the next four bits are the actual value, and the 6th bit is the
  69455. // continuation bit. The continuation bit tells us whether there are more
  69456. // digits in this value following this digit.
  69457. //
  69458. // Continuation
  69459. // | Sign
  69460. // | |
  69461. // V V
  69462. // 101011
  69463. var VLQ_BASE_SHIFT = 5;
  69464. // binary: 100000
  69465. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  69466. // binary: 011111
  69467. var VLQ_BASE_MASK = VLQ_BASE - 1;
  69468. // binary: 100000
  69469. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  69470. /**
  69471. * Converts from a two-complement value to a value where the sign bit is
  69472. * placed in the least significant bit. For example, as decimals:
  69473. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  69474. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  69475. */
  69476. function toVLQSigned(aValue) {
  69477. return aValue < 0
  69478. ? ((-aValue) << 1) + 1
  69479. : (aValue << 1) + 0;
  69480. }
  69481. /**
  69482. * Converts to a two-complement value from a value where the sign bit is
  69483. * placed in the least significant bit. For example, as decimals:
  69484. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  69485. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  69486. */
  69487. function fromVLQSigned(aValue) {
  69488. var isNegative = (aValue & 1) === 1;
  69489. var shifted = aValue >> 1;
  69490. return isNegative
  69491. ? -shifted
  69492. : shifted;
  69493. }
  69494. /**
  69495. * Returns the base 64 VLQ encoded value.
  69496. */
  69497. exports.encode = function base64VLQ_encode(aValue) {
  69498. var encoded = "";
  69499. var digit;
  69500. var vlq = toVLQSigned(aValue);
  69501. do {
  69502. digit = vlq & VLQ_BASE_MASK;
  69503. vlq >>>= VLQ_BASE_SHIFT;
  69504. if (vlq > 0) {
  69505. // There are still more digits in this value, so we must make sure the
  69506. // continuation bit is marked.
  69507. digit |= VLQ_CONTINUATION_BIT;
  69508. }
  69509. encoded += base64.encode(digit);
  69510. } while (vlq > 0);
  69511. return encoded;
  69512. };
  69513. /**
  69514. * Decodes the next base 64 VLQ value from the given string and returns the
  69515. * value and the rest of the string via the out parameter.
  69516. */
  69517. exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  69518. var strLen = aStr.length;
  69519. var result = 0;
  69520. var shift = 0;
  69521. var continuation, digit;
  69522. do {
  69523. if (aIndex >= strLen) {
  69524. throw new Error("Expected more digits in base 64 VLQ value.");
  69525. }
  69526. digit = base64.decode(aStr.charAt(aIndex++));
  69527. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  69528. digit &= VLQ_BASE_MASK;
  69529. result = result + (digit << shift);
  69530. shift += VLQ_BASE_SHIFT;
  69531. } while (continuation);
  69532. aOutParam.value = fromVLQSigned(result);
  69533. aOutParam.rest = aIndex;
  69534. };
  69535. });
  69536. },{"./base64":486,"amdefine":493}],486:[function(require,module,exports){
  69537. /* -*- Mode: js; js-indent-level: 2; -*- */
  69538. /*
  69539. * Copyright 2011 Mozilla Foundation and contributors
  69540. * Licensed under the New BSD license. See LICENSE or:
  69541. * http://opensource.org/licenses/BSD-3-Clause
  69542. */
  69543. if (typeof define !== 'function') {
  69544. var define = require('amdefine')(module, require);
  69545. }
  69546. define(function (require, exports, module) {
  69547. var charToIntMap = {};
  69548. var intToCharMap = {};
  69549. 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  69550. .split('')
  69551. .forEach(function (ch, index) {
  69552. charToIntMap[ch] = index;
  69553. intToCharMap[index] = ch;
  69554. });
  69555. /**
  69556. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  69557. */
  69558. exports.encode = function base64_encode(aNumber) {
  69559. if (aNumber in intToCharMap) {
  69560. return intToCharMap[aNumber];
  69561. }
  69562. throw new TypeError("Must be between 0 and 63: " + aNumber);
  69563. };
  69564. /**
  69565. * Decode a single base 64 digit to an integer.
  69566. */
  69567. exports.decode = function base64_decode(aChar) {
  69568. if (aChar in charToIntMap) {
  69569. return charToIntMap[aChar];
  69570. }
  69571. throw new TypeError("Not a valid base 64 digit: " + aChar);
  69572. };
  69573. });
  69574. },{"amdefine":493}],487:[function(require,module,exports){
  69575. /* -*- Mode: js; js-indent-level: 2; -*- */
  69576. /*
  69577. * Copyright 2011 Mozilla Foundation and contributors
  69578. * Licensed under the New BSD license. See LICENSE or:
  69579. * http://opensource.org/licenses/BSD-3-Clause
  69580. */
  69581. if (typeof define !== 'function') {
  69582. var define = require('amdefine')(module, require);
  69583. }
  69584. define(function (require, exports, module) {
  69585. exports.GREATEST_LOWER_BOUND = 1;
  69586. exports.LEAST_UPPER_BOUND = 2;
  69587. /**
  69588. * Recursive implementation of binary search.
  69589. *
  69590. * @param aLow Indices here and lower do not contain the needle.
  69591. * @param aHigh Indices here and higher do not contain the needle.
  69592. * @param aNeedle The element being searched for.
  69593. * @param aHaystack The non-empty array being searched.
  69594. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  69595. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  69596. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  69597. * closest element that is smaller than or greater than the one we are
  69598. * searching for, respectively, if the exact element cannot be found.
  69599. */
  69600. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  69601. // This function terminates when one of the following is true:
  69602. //
  69603. // 1. We find the exact element we are looking for.
  69604. //
  69605. // 2. We did not find the exact element, but we can return the index of
  69606. // the next-closest element.
  69607. //
  69608. // 3. We did not find the exact element, and there is no next-closest
  69609. // element than the one we are searching for, so we return -1.
  69610. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  69611. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  69612. if (cmp === 0) {
  69613. // Found the element we are looking for.
  69614. return mid;
  69615. }
  69616. else if (cmp > 0) {
  69617. // Our needle is greater than aHaystack[mid].
  69618. if (aHigh - mid > 1) {
  69619. // The element is in the upper half.
  69620. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  69621. }
  69622. // The exact needle element was not found in this haystack. Determine if
  69623. // we are in termination case (3) or (2) and return the appropriate thing.
  69624. if (aBias == exports.LEAST_UPPER_BOUND) {
  69625. return aHigh < aHaystack.length ? aHigh : -1;
  69626. } else {
  69627. return mid;
  69628. }
  69629. }
  69630. else {
  69631. // Our needle is less than aHaystack[mid].
  69632. if (mid - aLow > 1) {
  69633. // The element is in the lower half.
  69634. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  69635. }
  69636. // we are in termination case (3) or (2) and return the appropriate thing.
  69637. if (aBias == exports.LEAST_UPPER_BOUND) {
  69638. return mid;
  69639. } else {
  69640. return aLow < 0 ? -1 : aLow;
  69641. }
  69642. }
  69643. }
  69644. /**
  69645. * This is an implementation of binary search which will always try and return
  69646. * the index of the closest element if there is no exact hit. This is because
  69647. * mappings between original and generated line/col pairs are single points,
  69648. * and there is an implicit region between each of them, so a miss just means
  69649. * that you aren't on the very start of a region.
  69650. *
  69651. * @param aNeedle The element you are looking for.
  69652. * @param aHaystack The array that is being searched.
  69653. * @param aCompare A function which takes the needle and an element in the
  69654. * array and returns -1, 0, or 1 depending on whether the needle is less
  69655. * than, equal to, or greater than the element, respectively.
  69656. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  69657. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  69658. * closest element that is smaller than or greater than the one we are
  69659. * searching for, respectively, if the exact element cannot be found.
  69660. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  69661. */
  69662. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  69663. if (aHaystack.length === 0) {
  69664. return -1;
  69665. }
  69666. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  69667. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  69668. if (index < 0) {
  69669. return -1;
  69670. }
  69671. // We have found either the exact element, or the next-closest element than
  69672. // the one we are searching for. However, there may be more than one such
  69673. // element. Make sure we always return the smallest of these.
  69674. while (index - 1 >= 0) {
  69675. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  69676. break;
  69677. }
  69678. --index;
  69679. }
  69680. return index;
  69681. };
  69682. });
  69683. },{"amdefine":493}],488:[function(require,module,exports){
  69684. /* -*- Mode: js; js-indent-level: 2; -*- */
  69685. /*
  69686. * Copyright 2014 Mozilla Foundation and contributors
  69687. * Licensed under the New BSD license. See LICENSE or:
  69688. * http://opensource.org/licenses/BSD-3-Clause
  69689. */
  69690. if (typeof define !== 'function') {
  69691. var define = require('amdefine')(module, require);
  69692. }
  69693. define(function (require, exports, module) {
  69694. var util = require('./util');
  69695. /**
  69696. * Determine whether mappingB is after mappingA with respect to generated
  69697. * position.
  69698. */
  69699. function generatedPositionAfter(mappingA, mappingB) {
  69700. // Optimized for most common case
  69701. var lineA = mappingA.generatedLine;
  69702. var lineB = mappingB.generatedLine;
  69703. var columnA = mappingA.generatedColumn;
  69704. var columnB = mappingB.generatedColumn;
  69705. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  69706. util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
  69707. }
  69708. /**
  69709. * A data structure to provide a sorted view of accumulated mappings in a
  69710. * performance conscious manner. It trades a neglibable overhead in general
  69711. * case for a large speedup in case of mappings being added in order.
  69712. */
  69713. function MappingList() {
  69714. this._array = [];
  69715. this._sorted = true;
  69716. // Serves as infimum
  69717. this._last = {generatedLine: -1, generatedColumn: 0};
  69718. }
  69719. /**
  69720. * Iterate through internal items. This method takes the same arguments that
  69721. * `Array.prototype.forEach` takes.
  69722. *
  69723. * NOTE: The order of the mappings is NOT guaranteed.
  69724. */
  69725. MappingList.prototype.unsortedForEach =
  69726. function MappingList_forEach(aCallback, aThisArg) {
  69727. this._array.forEach(aCallback, aThisArg);
  69728. };
  69729. /**
  69730. * Add the given source mapping.
  69731. *
  69732. * @param Object aMapping
  69733. */
  69734. MappingList.prototype.add = function MappingList_add(aMapping) {
  69735. var mapping;
  69736. if (generatedPositionAfter(this._last, aMapping)) {
  69737. this._last = aMapping;
  69738. this._array.push(aMapping);
  69739. } else {
  69740. this._sorted = false;
  69741. this._array.push(aMapping);
  69742. }
  69743. };
  69744. /**
  69745. * Returns the flat, sorted array of mappings. The mappings are sorted by
  69746. * generated position.
  69747. *
  69748. * WARNING: This method returns internal data without copying, for
  69749. * performance. The return value must NOT be mutated, and should be treated as
  69750. * an immutable borrow. If you want to take ownership, you must make your own
  69751. * copy.
  69752. */
  69753. MappingList.prototype.toArray = function MappingList_toArray() {
  69754. if (!this._sorted) {
  69755. this._array.sort(util.compareByGeneratedPositions);
  69756. this._sorted = true;
  69757. }
  69758. return this._array;
  69759. };
  69760. exports.MappingList = MappingList;
  69761. });
  69762. },{"./util":492,"amdefine":493}],489:[function(require,module,exports){
  69763. /* -*- Mode: js; js-indent-level: 2; -*- */
  69764. /*
  69765. * Copyright 2011 Mozilla Foundation and contributors
  69766. * Licensed under the New BSD license. See LICENSE or:
  69767. * http://opensource.org/licenses/BSD-3-Clause
  69768. */
  69769. if (typeof define !== 'function') {
  69770. var define = require('amdefine')(module, require);
  69771. }
  69772. define(function (require, exports, module) {
  69773. var util = require('./util');
  69774. var binarySearch = require('./binary-search');
  69775. var ArraySet = require('./array-set').ArraySet;
  69776. var base64VLQ = require('./base64-vlq');
  69777. function SourceMapConsumer(aSourceMap) {
  69778. var sourceMap = aSourceMap;
  69779. if (typeof aSourceMap === 'string') {
  69780. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
  69781. }
  69782. return sourceMap.sections != null
  69783. ? new IndexedSourceMapConsumer(sourceMap)
  69784. : new BasicSourceMapConsumer(sourceMap);
  69785. }
  69786. SourceMapConsumer.fromSourceMap = function(aSourceMap) {
  69787. return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
  69788. }
  69789. /**
  69790. * The version of the source mapping spec that we are consuming.
  69791. */
  69792. SourceMapConsumer.prototype._version = 3;
  69793. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  69794. // parsed mapping coordinates from the source map's "mappings" attribute. They
  69795. // are lazily instantiated, accessed via the `_generatedMappings` and
  69796. // `_originalMappings` getters respectively, and we only parse the mappings
  69797. // and create these arrays once queried for a source location. We jump through
  69798. // these hoops because there can be many thousands of mappings, and parsing
  69799. // them is expensive, so we only want to do it if we must.
  69800. //
  69801. // Each object in the arrays is of the form:
  69802. //
  69803. // {
  69804. // generatedLine: The line number in the generated code,
  69805. // generatedColumn: The column number in the generated code,
  69806. // source: The path to the original source file that generated this
  69807. // chunk of code,
  69808. // originalLine: The line number in the original source that
  69809. // corresponds to this chunk of generated code,
  69810. // originalColumn: The column number in the original source that
  69811. // corresponds to this chunk of generated code,
  69812. // name: The name of the original symbol which generated this chunk of
  69813. // code.
  69814. // }
  69815. //
  69816. // All properties except for `generatedLine` and `generatedColumn` can be
  69817. // `null`.
  69818. //
  69819. // `_generatedMappings` is ordered by the generated positions.
  69820. //
  69821. // `_originalMappings` is ordered by the original positions.
  69822. SourceMapConsumer.prototype.__generatedMappings = null;
  69823. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  69824. get: function () {
  69825. if (!this.__generatedMappings) {
  69826. this.__generatedMappings = [];
  69827. this.__originalMappings = [];
  69828. this._parseMappings(this._mappings, this.sourceRoot);
  69829. }
  69830. return this.__generatedMappings;
  69831. }
  69832. });
  69833. SourceMapConsumer.prototype.__originalMappings = null;
  69834. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  69835. get: function () {
  69836. if (!this.__originalMappings) {
  69837. this.__generatedMappings = [];
  69838. this.__originalMappings = [];
  69839. this._parseMappings(this._mappings, this.sourceRoot);
  69840. }
  69841. return this.__originalMappings;
  69842. }
  69843. });
  69844. SourceMapConsumer.prototype._nextCharIsMappingSeparator =
  69845. function SourceMapConsumer_nextCharIsMappingSeparator(aStr, index) {
  69846. var c = aStr.charAt(index);
  69847. return c === ";" || c === ",";
  69848. };
  69849. /**
  69850. * Parse the mappings in a string in to a data structure which we can easily
  69851. * query (the ordered arrays in the `this.__generatedMappings` and
  69852. * `this.__originalMappings` properties).
  69853. */
  69854. SourceMapConsumer.prototype._parseMappings =
  69855. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  69856. throw new Error("Subclasses must implement _parseMappings");
  69857. };
  69858. SourceMapConsumer.GENERATED_ORDER = 1;
  69859. SourceMapConsumer.ORIGINAL_ORDER = 2;
  69860. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  69861. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  69862. /**
  69863. * Iterate over each mapping between an original source/line/column and a
  69864. * generated line/column in this source map.
  69865. *
  69866. * @param Function aCallback
  69867. * The function that is called with each mapping.
  69868. * @param Object aContext
  69869. * Optional. If specified, this object will be the value of `this` every
  69870. * time that `aCallback` is called.
  69871. * @param aOrder
  69872. * Either `SourceMapConsumer.GENERATED_ORDER` or
  69873. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  69874. * iterate over the mappings sorted by the generated file's line/column
  69875. * order or the original's source/line/column order, respectively. Defaults to
  69876. * `SourceMapConsumer.GENERATED_ORDER`.
  69877. */
  69878. SourceMapConsumer.prototype.eachMapping =
  69879. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  69880. var context = aContext || null;
  69881. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  69882. var mappings;
  69883. switch (order) {
  69884. case SourceMapConsumer.GENERATED_ORDER:
  69885. mappings = this._generatedMappings;
  69886. break;
  69887. case SourceMapConsumer.ORIGINAL_ORDER:
  69888. mappings = this._originalMappings;
  69889. break;
  69890. default:
  69891. throw new Error("Unknown order of iteration.");
  69892. }
  69893. var sourceRoot = this.sourceRoot;
  69894. mappings.map(function (mapping) {
  69895. var source = mapping.source;
  69896. if (source != null && sourceRoot != null) {
  69897. source = util.join(sourceRoot, source);
  69898. }
  69899. return {
  69900. source: source,
  69901. generatedLine: mapping.generatedLine,
  69902. generatedColumn: mapping.generatedColumn,
  69903. originalLine: mapping.originalLine,
  69904. originalColumn: mapping.originalColumn,
  69905. name: mapping.name
  69906. };
  69907. }).forEach(aCallback, context);
  69908. };
  69909. /**
  69910. * Returns all generated line and column information for the original source,
  69911. * line, and column provided. If no column is provided, returns all mappings
  69912. * corresponding to a single line. Otherwise, returns all mappings
  69913. * corresponding to a single line and column.
  69914. *
  69915. * The only argument is an object with the following properties:
  69916. *
  69917. * - source: The filename of the original source.
  69918. * - line: The line number in the original source.
  69919. * - column: Optional. the column number in the original source.
  69920. *
  69921. * and an array of objects is returned, each with the following properties:
  69922. *
  69923. * - line: The line number in the generated source, or null.
  69924. * - column: The column number in the generated source, or null.
  69925. */
  69926. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  69927. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  69928. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  69929. // returns the index of the closest mapping less than the needle. By
  69930. // setting needle.originalColumn to 0, we thus find the last mapping for
  69931. // the given line, provided such a mapping exists.
  69932. var needle = {
  69933. source: util.getArg(aArgs, 'source'),
  69934. originalLine: util.getArg(aArgs, 'line'),
  69935. originalColumn: util.getArg(aArgs, 'column', 0)
  69936. };
  69937. if (this.sourceRoot != null) {
  69938. needle.source = util.relative(this.sourceRoot, needle.source);
  69939. }
  69940. var mappings = [];
  69941. var index = this._findMapping(needle,
  69942. this._originalMappings,
  69943. "originalLine",
  69944. "originalColumn",
  69945. util.compareByOriginalPositions,
  69946. binarySearch.LEAST_UPPER_BOUND);
  69947. if (index >= 0) {
  69948. var mapping = this._originalMappings[index];
  69949. var originalLine = mapping.originalLine;
  69950. var originalColumn = mapping.originalColumn;
  69951. // Iterate until either we run out of mappings, or we run into
  69952. // a mapping for a different line. Since mappings are sorted, this is
  69953. // guaranteed to find all mappings for the line we are searching for.
  69954. while (mapping && mapping.originalLine === originalLine &&
  69955. (aArgs.column === undefined ||
  69956. mapping.originalColumn === originalColumn)) {
  69957. mappings.push({
  69958. line: util.getArg(mapping, 'generatedLine', null),
  69959. column: util.getArg(mapping, 'generatedColumn', null),
  69960. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  69961. });
  69962. mapping = this._originalMappings[++index];
  69963. }
  69964. }
  69965. return mappings;
  69966. };
  69967. exports.SourceMapConsumer = SourceMapConsumer;
  69968. /**
  69969. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  69970. * query for information about the original file positions by giving it a file
  69971. * position in the generated source.
  69972. *
  69973. * The only parameter is the raw source map (either as a JSON string, or
  69974. * already parsed to an object). According to the spec, source maps have the
  69975. * following attributes:
  69976. *
  69977. * - version: Which version of the source map spec this map is following.
  69978. * - sources: An array of URLs to the original source files.
  69979. * - names: An array of identifiers which can be referrenced by individual mappings.
  69980. * - sourceRoot: Optional. The URL root from which all sources are relative.
  69981. * - sourcesContent: Optional. An array of contents of the original source files.
  69982. * - mappings: A string of base64 VLQs which contain the actual mappings.
  69983. * - file: Optional. The generated file this source map is associated with.
  69984. *
  69985. * Here is an example source map, taken from the source map spec[0]:
  69986. *
  69987. * {
  69988. * version : 3,
  69989. * file: "out.js",
  69990. * sourceRoot : "",
  69991. * sources: ["foo.js", "bar.js"],
  69992. * names: ["src", "maps", "are", "fun"],
  69993. * mappings: "AA,AB;;ABCDE;"
  69994. * }
  69995. *
  69996. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  69997. */
  69998. function BasicSourceMapConsumer(aSourceMap) {
  69999. var sourceMap = aSourceMap;
  70000. if (typeof aSourceMap === 'string') {
  70001. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
  70002. }
  70003. var version = util.getArg(sourceMap, 'version');
  70004. var sources = util.getArg(sourceMap, 'sources');
  70005. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  70006. // requires the array) to play nice here.
  70007. var names = util.getArg(sourceMap, 'names', []);
  70008. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  70009. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  70010. var mappings = util.getArg(sourceMap, 'mappings');
  70011. var file = util.getArg(sourceMap, 'file', null);
  70012. // Once again, Sass deviates from the spec and supplies the version as a
  70013. // string rather than a number, so we use loose equality checking here.
  70014. if (version != this._version) {
  70015. throw new Error('Unsupported version: ' + version);
  70016. }
  70017. // Some source maps produce relative source paths like "./foo.js" instead of
  70018. // "foo.js". Normalize these first so that future comparisons will succeed.
  70019. // See bugzil.la/1090768.
  70020. sources = sources.map(util.normalize);
  70021. // Pass `true` below to allow duplicate names and sources. While source maps
  70022. // are intended to be compressed and deduplicated, the TypeScript compiler
  70023. // sometimes generates source maps with duplicates in them. See Github issue
  70024. // #72 and bugzil.la/889492.
  70025. this._names = ArraySet.fromArray(names, true);
  70026. this._sources = ArraySet.fromArray(sources, true);
  70027. this.sourceRoot = sourceRoot;
  70028. this.sourcesContent = sourcesContent;
  70029. this._mappings = mappings;
  70030. this.file = file;
  70031. }
  70032. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  70033. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  70034. /**
  70035. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  70036. *
  70037. * @param SourceMapGenerator aSourceMap
  70038. * The source map that will be consumed.
  70039. * @returns BasicSourceMapConsumer
  70040. */
  70041. BasicSourceMapConsumer.fromSourceMap =
  70042. function SourceMapConsumer_fromSourceMap(aSourceMap) {
  70043. var smc = Object.create(BasicSourceMapConsumer.prototype);
  70044. smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  70045. smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  70046. smc.sourceRoot = aSourceMap._sourceRoot;
  70047. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  70048. smc.sourceRoot);
  70049. smc.file = aSourceMap._file;
  70050. smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
  70051. smc.__originalMappings = aSourceMap._mappings.toArray().slice()
  70052. .sort(util.compareByOriginalPositions);
  70053. return smc;
  70054. };
  70055. /**
  70056. * The version of the source mapping spec that we are consuming.
  70057. */
  70058. BasicSourceMapConsumer.prototype._version = 3;
  70059. /**
  70060. * The list of original sources.
  70061. */
  70062. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  70063. get: function () {
  70064. return this._sources.toArray().map(function (s) {
  70065. return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
  70066. }, this);
  70067. }
  70068. });
  70069. /**
  70070. * Parse the mappings in a string in to a data structure which we can easily
  70071. * query (the ordered arrays in the `this.__generatedMappings` and
  70072. * `this.__originalMappings` properties).
  70073. */
  70074. BasicSourceMapConsumer.prototype._parseMappings =
  70075. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  70076. var generatedLine = 1;
  70077. var previousGeneratedColumn = 0;
  70078. var previousOriginalLine = 0;
  70079. var previousOriginalColumn = 0;
  70080. var previousSource = 0;
  70081. var previousName = 0;
  70082. var length = aStr.length;
  70083. var index = 0;
  70084. var cachedValues = {};
  70085. var temp = {};
  70086. var mapping, str, values, end, value;
  70087. while (index < length) {
  70088. if (aStr.charAt(index) === ';') {
  70089. generatedLine++;
  70090. ++index;
  70091. previousGeneratedColumn = 0;
  70092. }
  70093. else if (aStr.charAt(index) === ',') {
  70094. ++index;
  70095. }
  70096. else {
  70097. mapping = {};
  70098. mapping.generatedLine = generatedLine;
  70099. // Because each offset is encoded relative to the previous one,
  70100. // many segments often have the same encoding. We can exploit this
  70101. // fact by caching the parsed variable length fields of each segment,
  70102. // allowing us to avoid a second parse if we encounter the same
  70103. // segment again.
  70104. for (end = index; end < length; ++end) {
  70105. if (this._nextCharIsMappingSeparator(aStr, end)) {
  70106. break;
  70107. }
  70108. }
  70109. str = aStr.slice(index, end);
  70110. values = cachedValues[str];
  70111. if (values) {
  70112. index += str.length;
  70113. } else {
  70114. values = [];
  70115. while (index < end) {
  70116. base64VLQ.decode(aStr, index, temp);
  70117. value = temp.value;
  70118. index = temp.rest;
  70119. values.push(value);
  70120. }
  70121. cachedValues[str] = values;
  70122. }
  70123. // Generated column.
  70124. mapping.generatedColumn = previousGeneratedColumn + values[0];
  70125. previousGeneratedColumn = mapping.generatedColumn;
  70126. if (values.length > 1) {
  70127. // Original source.
  70128. mapping.source = this._sources.at(previousSource + values[1]);
  70129. previousSource += values[1];
  70130. if (values.length === 2) {
  70131. throw new Error('Found a source, but no line and column');
  70132. }
  70133. // Original line.
  70134. mapping.originalLine = previousOriginalLine + values[2];
  70135. previousOriginalLine = mapping.originalLine;
  70136. // Lines are stored 0-based
  70137. mapping.originalLine += 1;
  70138. if (values.length === 3) {
  70139. throw new Error('Found a source and line, but no column');
  70140. }
  70141. // Original column.
  70142. mapping.originalColumn = previousOriginalColumn + values[3];
  70143. previousOriginalColumn = mapping.originalColumn;
  70144. if (values.length > 4) {
  70145. // Original name.
  70146. mapping.name = this._names.at(previousName + values[4]);
  70147. previousName += values[4];
  70148. }
  70149. }
  70150. this.__generatedMappings.push(mapping);
  70151. if (typeof mapping.originalLine === 'number') {
  70152. this.__originalMappings.push(mapping);
  70153. }
  70154. }
  70155. }
  70156. this.__generatedMappings.sort(util.compareByGeneratedPositions);
  70157. this.__originalMappings.sort(util.compareByOriginalPositions);
  70158. };
  70159. /**
  70160. * Find the mapping that best matches the hypothetical "needle" mapping that
  70161. * we are searching for in the given "haystack" of mappings.
  70162. */
  70163. BasicSourceMapConsumer.prototype._findMapping =
  70164. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  70165. aColumnName, aComparator, aBias) {
  70166. // To return the position we are searching for, we must first find the
  70167. // mapping for the given position and then return the opposite position it
  70168. // points to. Because the mappings are sorted, we can use binary search to
  70169. // find the best mapping.
  70170. if (aNeedle[aLineName] <= 0) {
  70171. throw new TypeError('Line must be greater than or equal to 1, got '
  70172. + aNeedle[aLineName]);
  70173. }
  70174. if (aNeedle[aColumnName] < 0) {
  70175. throw new TypeError('Column must be greater than or equal to 0, got '
  70176. + aNeedle[aColumnName]);
  70177. }
  70178. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  70179. };
  70180. /**
  70181. * Compute the last column for each generated mapping. The last column is
  70182. * inclusive.
  70183. */
  70184. BasicSourceMapConsumer.prototype.computeColumnSpans =
  70185. function SourceMapConsumer_computeColumnSpans() {
  70186. for (var index = 0; index < this._generatedMappings.length; ++index) {
  70187. var mapping = this._generatedMappings[index];
  70188. // Mappings do not contain a field for the last generated columnt. We
  70189. // can come up with an optimistic estimate, however, by assuming that
  70190. // mappings are contiguous (i.e. given two consecutive mappings, the
  70191. // first mapping ends where the second one starts).
  70192. if (index + 1 < this._generatedMappings.length) {
  70193. var nextMapping = this._generatedMappings[index + 1];
  70194. if (mapping.generatedLine === nextMapping.generatedLine) {
  70195. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  70196. continue;
  70197. }
  70198. }
  70199. // The last mapping for each line spans the entire line.
  70200. mapping.lastGeneratedColumn = Infinity;
  70201. }
  70202. };
  70203. /**
  70204. * Returns the original source, line, and column information for the generated
  70205. * source's line and column positions provided. The only argument is an object
  70206. * with the following properties:
  70207. *
  70208. * - line: The line number in the generated source.
  70209. * - column: The column number in the generated source.
  70210. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  70211. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  70212. * closest element that is smaller than or greater than the one we are
  70213. * searching for, respectively, if the exact element cannot be found.
  70214. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  70215. *
  70216. * and an object is returned with the following properties:
  70217. *
  70218. * - source: The original source file, or null.
  70219. * - line: The line number in the original source, or null.
  70220. * - column: The column number in the original source, or null.
  70221. * - name: The original identifier, or null.
  70222. */
  70223. BasicSourceMapConsumer.prototype.originalPositionFor =
  70224. function SourceMapConsumer_originalPositionFor(aArgs) {
  70225. var needle = {
  70226. generatedLine: util.getArg(aArgs, 'line'),
  70227. generatedColumn: util.getArg(aArgs, 'column')
  70228. };
  70229. var index = this._findMapping(
  70230. needle,
  70231. this._generatedMappings,
  70232. "generatedLine",
  70233. "generatedColumn",
  70234. util.compareByGeneratedPositions,
  70235. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  70236. );
  70237. if (index >= 0) {
  70238. var mapping = this._generatedMappings[index];
  70239. if (mapping.generatedLine === needle.generatedLine) {
  70240. var source = util.getArg(mapping, 'source', null);
  70241. if (source != null && this.sourceRoot != null) {
  70242. source = util.join(this.sourceRoot, source);
  70243. }
  70244. return {
  70245. source: source,
  70246. line: util.getArg(mapping, 'originalLine', null),
  70247. column: util.getArg(mapping, 'originalColumn', null),
  70248. name: util.getArg(mapping, 'name', null)
  70249. };
  70250. }
  70251. }
  70252. return {
  70253. source: null,
  70254. line: null,
  70255. column: null,
  70256. name: null
  70257. };
  70258. };
  70259. /**
  70260. * Returns the original source content. The only argument is the url of the
  70261. * original source file. Returns null if no original source content is
  70262. * availible.
  70263. */
  70264. BasicSourceMapConsumer.prototype.sourceContentFor =
  70265. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  70266. if (!this.sourcesContent) {
  70267. return null;
  70268. }
  70269. if (this.sourceRoot != null) {
  70270. aSource = util.relative(this.sourceRoot, aSource);
  70271. }
  70272. if (this._sources.has(aSource)) {
  70273. return this.sourcesContent[this._sources.indexOf(aSource)];
  70274. }
  70275. var url;
  70276. if (this.sourceRoot != null
  70277. && (url = util.urlParse(this.sourceRoot))) {
  70278. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  70279. // many users. We can help them out when they expect file:// URIs to
  70280. // behave like it would if they were running a local HTTP server. See
  70281. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  70282. var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
  70283. if (url.scheme == "file"
  70284. && this._sources.has(fileUriAbsPath)) {
  70285. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  70286. }
  70287. if ((!url.path || url.path == "/")
  70288. && this._sources.has("/" + aSource)) {
  70289. return this.sourcesContent[this._sources.indexOf("/" + aSource)];
  70290. }
  70291. }
  70292. // This function is used recursively from
  70293. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  70294. // don't want to throw if we can't find the source - we just want to
  70295. // return null, so we provide a flag to exit gracefully.
  70296. if (nullOnMissing) {
  70297. return null;
  70298. }
  70299. else {
  70300. throw new Error('"' + aSource + '" is not in the SourceMap.');
  70301. }
  70302. };
  70303. /**
  70304. * Returns the generated line and column information for the original source,
  70305. * line, and column positions provided. The only argument is an object with
  70306. * the following properties:
  70307. *
  70308. * - source: The filename of the original source.
  70309. * - line: The line number in the original source.
  70310. * - column: The column number in the original source.
  70311. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  70312. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  70313. * closest element that is smaller than or greater than the one we are
  70314. * searching for, respectively, if the exact element cannot be found.
  70315. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  70316. *
  70317. * and an object is returned with the following properties:
  70318. *
  70319. * - line: The line number in the generated source, or null.
  70320. * - column: The column number in the generated source, or null.
  70321. */
  70322. BasicSourceMapConsumer.prototype.generatedPositionFor =
  70323. function SourceMapConsumer_generatedPositionFor(aArgs) {
  70324. var needle = {
  70325. source: util.getArg(aArgs, 'source'),
  70326. originalLine: util.getArg(aArgs, 'line'),
  70327. originalColumn: util.getArg(aArgs, 'column')
  70328. };
  70329. if (this.sourceRoot != null) {
  70330. needle.source = util.relative(this.sourceRoot, needle.source);
  70331. }
  70332. var index = this._findMapping(
  70333. needle,
  70334. this._originalMappings,
  70335. "originalLine",
  70336. "originalColumn",
  70337. util.compareByOriginalPositions,
  70338. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  70339. );
  70340. if (index >= 0) {
  70341. var mapping = this._originalMappings[index];
  70342. if (mapping.source === needle.source) {
  70343. return {
  70344. line: util.getArg(mapping, 'generatedLine', null),
  70345. column: util.getArg(mapping, 'generatedColumn', null),
  70346. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  70347. };
  70348. }
  70349. }
  70350. return {
  70351. line: null,
  70352. column: null,
  70353. lastColumn: null
  70354. };
  70355. };
  70356. exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
  70357. /**
  70358. * An IndexedSourceMapConsumer instance represents a parsed source map which
  70359. * we can query for information. It differs from BasicSourceMapConsumer in
  70360. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  70361. * input.
  70362. *
  70363. * The only parameter is a raw source map (either as a JSON string, or already
  70364. * parsed to an object). According to the spec for indexed source maps, they
  70365. * have the following attributes:
  70366. *
  70367. * - version: Which version of the source map spec this map is following.
  70368. * - file: Optional. The generated file this source map is associated with.
  70369. * - sections: A list of section definitions.
  70370. *
  70371. * Each value under the "sections" field has two fields:
  70372. * - offset: The offset into the original specified at which this section
  70373. * begins to apply, defined as an object with a "line" and "column"
  70374. * field.
  70375. * - map: A source map definition. This source map could also be indexed,
  70376. * but doesn't have to be.
  70377. *
  70378. * Instead of the "map" field, it's also possible to have a "url" field
  70379. * specifying a URL to retrieve a source map from, but that's currently
  70380. * unsupported.
  70381. *
  70382. * Here's an example source map, taken from the source map spec[0], but
  70383. * modified to omit a section which uses the "url" field.
  70384. *
  70385. * {
  70386. * version : 3,
  70387. * file: "app.js",
  70388. * sections: [{
  70389. * offset: {line:100, column:10},
  70390. * map: {
  70391. * version : 3,
  70392. * file: "section.js",
  70393. * sources: ["foo.js", "bar.js"],
  70394. * names: ["src", "maps", "are", "fun"],
  70395. * mappings: "AAAA,E;;ABCDE;"
  70396. * }
  70397. * }],
  70398. * }
  70399. *
  70400. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  70401. */
  70402. function IndexedSourceMapConsumer(aSourceMap) {
  70403. var sourceMap = aSourceMap;
  70404. if (typeof aSourceMap === 'string') {
  70405. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
  70406. }
  70407. var version = util.getArg(sourceMap, 'version');
  70408. var sections = util.getArg(sourceMap, 'sections');
  70409. if (version != this._version) {
  70410. throw new Error('Unsupported version: ' + version);
  70411. }
  70412. var lastOffset = {
  70413. line: -1,
  70414. column: 0
  70415. };
  70416. this._sections = sections.map(function (s) {
  70417. if (s.url) {
  70418. // The url field will require support for asynchronicity.
  70419. // See https://github.com/mozilla/source-map/issues/16
  70420. throw new Error('Support for url field in sections not implemented.');
  70421. }
  70422. var offset = util.getArg(s, 'offset');
  70423. var offsetLine = util.getArg(offset, 'line');
  70424. var offsetColumn = util.getArg(offset, 'column');
  70425. if (offsetLine < lastOffset.line ||
  70426. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  70427. throw new Error('Section offsets must be ordered and non-overlapping.');
  70428. }
  70429. lastOffset = offset;
  70430. return {
  70431. generatedOffset: {
  70432. // The offset fields are 0-based, but we use 1-based indices when
  70433. // encoding/decoding from VLQ.
  70434. generatedLine: offsetLine + 1,
  70435. generatedColumn: offsetColumn + 1
  70436. },
  70437. consumer: new SourceMapConsumer(util.getArg(s, 'map'))
  70438. }
  70439. });
  70440. }
  70441. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  70442. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  70443. /**
  70444. * The version of the source mapping spec that we are consuming.
  70445. */
  70446. IndexedSourceMapConsumer.prototype._version = 3;
  70447. /**
  70448. * The list of original sources.
  70449. */
  70450. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  70451. get: function () {
  70452. var sources = [];
  70453. for (var i = 0; i < this._sections.length; i++) {
  70454. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  70455. sources.push(this._sections[i].consumer.sources[j]);
  70456. }
  70457. };
  70458. return sources;
  70459. }
  70460. });
  70461. /**
  70462. * Returns the original source, line, and column information for the generated
  70463. * source's line and column positions provided. The only argument is an object
  70464. * with the following properties:
  70465. *
  70466. * - line: The line number in the generated source.
  70467. * - column: The column number in the generated source.
  70468. *
  70469. * and an object is returned with the following properties:
  70470. *
  70471. * - source: The original source file, or null.
  70472. * - line: The line number in the original source, or null.
  70473. * - column: The column number in the original source, or null.
  70474. * - name: The original identifier, or null.
  70475. */
  70476. IndexedSourceMapConsumer.prototype.originalPositionFor =
  70477. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  70478. var needle = {
  70479. generatedLine: util.getArg(aArgs, 'line'),
  70480. generatedColumn: util.getArg(aArgs, 'column')
  70481. };
  70482. // Find the section containing the generated position we're trying to map
  70483. // to an original position.
  70484. var sectionIndex = binarySearch.search(needle, this._sections,
  70485. function(needle, section) {
  70486. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  70487. if (cmp) {
  70488. return cmp;
  70489. }
  70490. return (needle.generatedColumn -
  70491. section.generatedOffset.generatedColumn);
  70492. });
  70493. var section = this._sections[sectionIndex];
  70494. if (!section) {
  70495. return {
  70496. source: null,
  70497. line: null,
  70498. column: null,
  70499. name: null
  70500. };
  70501. }
  70502. return section.consumer.originalPositionFor({
  70503. line: needle.generatedLine -
  70504. (section.generatedOffset.generatedLine - 1),
  70505. column: needle.generatedColumn -
  70506. (section.generatedOffset.generatedLine === needle.generatedLine
  70507. ? section.generatedOffset.generatedColumn - 1
  70508. : 0),
  70509. bias: aArgs.bias
  70510. });
  70511. };
  70512. /**
  70513. * Returns the original source content. The only argument is the url of the
  70514. * original source file. Returns null if no original source content is
  70515. * available.
  70516. */
  70517. IndexedSourceMapConsumer.prototype.sourceContentFor =
  70518. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  70519. for (var i = 0; i < this._sections.length; i++) {
  70520. var section = this._sections[i];
  70521. var content = section.consumer.sourceContentFor(aSource, true);
  70522. if (content) {
  70523. return content;
  70524. }
  70525. }
  70526. if (nullOnMissing) {
  70527. return null;
  70528. }
  70529. else {
  70530. throw new Error('"' + aSource + '" is not in the SourceMap.');
  70531. }
  70532. };
  70533. /**
  70534. * Returns the generated line and column information for the original source,
  70535. * line, and column positions provided. The only argument is an object with
  70536. * the following properties:
  70537. *
  70538. * - source: The filename of the original source.
  70539. * - line: The line number in the original source.
  70540. * - column: The column number in the original source.
  70541. *
  70542. * and an object is returned with the following properties:
  70543. *
  70544. * - line: The line number in the generated source, or null.
  70545. * - column: The column number in the generated source, or null.
  70546. */
  70547. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  70548. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  70549. for (var i = 0; i < this._sections.length; i++) {
  70550. var section = this._sections[i];
  70551. // Only consider this section if the requested source is in the list of
  70552. // sources of the consumer.
  70553. if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
  70554. continue;
  70555. }
  70556. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  70557. if (generatedPosition) {
  70558. var ret = {
  70559. line: generatedPosition.line +
  70560. (section.generatedOffset.generatedLine - 1),
  70561. column: generatedPosition.column +
  70562. (section.generatedOffset.generatedLine === generatedPosition.line
  70563. ? section.generatedOffset.generatedColumn - 1
  70564. : 0)
  70565. };
  70566. return ret;
  70567. }
  70568. }
  70569. return {
  70570. line: null,
  70571. column: null
  70572. };
  70573. };
  70574. /**
  70575. * Parse the mappings in a string in to a data structure which we can easily
  70576. * query (the ordered arrays in the `this.__generatedMappings` and
  70577. * `this.__originalMappings` properties).
  70578. */
  70579. IndexedSourceMapConsumer.prototype._parseMappings =
  70580. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  70581. this.__generatedMappings = [];
  70582. this.__originalMappings = [];
  70583. for (var i = 0; i < this._sections.length; i++) {
  70584. var section = this._sections[i];
  70585. var sectionMappings = section.consumer._generatedMappings;
  70586. for (var j = 0; j < sectionMappings.length; j++) {
  70587. var mapping = sectionMappings[i];
  70588. var source = mapping.source;
  70589. var sourceRoot = section.consumer.sourceRoot;
  70590. if (source != null && sourceRoot != null) {
  70591. source = util.join(sourceRoot, source);
  70592. }
  70593. // The mappings coming from the consumer for the section have
  70594. // generated positions relative to the start of the section, so we
  70595. // need to offset them to be relative to the start of the concatenated
  70596. // generated file.
  70597. var adjustedMapping = {
  70598. source: source,
  70599. generatedLine: mapping.generatedLine +
  70600. (section.generatedOffset.generatedLine - 1),
  70601. generatedColumn: mapping.column +
  70602. (section.generatedOffset.generatedLine === mapping.generatedLine)
  70603. ? section.generatedOffset.generatedColumn - 1
  70604. : 0,
  70605. originalLine: mapping.originalLine,
  70606. originalColumn: mapping.originalColumn,
  70607. name: mapping.name
  70608. };
  70609. this.__generatedMappings.push(adjustedMapping);
  70610. if (typeof adjustedMapping.originalLine === 'number') {
  70611. this.__originalMappings.push(adjustedMapping);
  70612. }
  70613. };
  70614. };
  70615. this.__generatedMappings.sort(util.compareByGeneratedPositions);
  70616. this.__originalMappings.sort(util.compareByOriginalPositions);
  70617. };
  70618. exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  70619. });
  70620. },{"./array-set":484,"./base64-vlq":485,"./binary-search":487,"./util":492,"amdefine":493}],490:[function(require,module,exports){
  70621. /* -*- Mode: js; js-indent-level: 2; -*- */
  70622. /*
  70623. * Copyright 2011 Mozilla Foundation and contributors
  70624. * Licensed under the New BSD license. See LICENSE or:
  70625. * http://opensource.org/licenses/BSD-3-Clause
  70626. */
  70627. if (typeof define !== 'function') {
  70628. var define = require('amdefine')(module, require);
  70629. }
  70630. define(function (require, exports, module) {
  70631. var base64VLQ = require('./base64-vlq');
  70632. var util = require('./util');
  70633. var ArraySet = require('./array-set').ArraySet;
  70634. var MappingList = require('./mapping-list').MappingList;
  70635. /**
  70636. * An instance of the SourceMapGenerator represents a source map which is
  70637. * being built incrementally. You may pass an object with the following
  70638. * properties:
  70639. *
  70640. * - file: The filename of the generated source.
  70641. * - sourceRoot: A root for all relative URLs in this source map.
  70642. */
  70643. function SourceMapGenerator(aArgs) {
  70644. if (!aArgs) {
  70645. aArgs = {};
  70646. }
  70647. this._file = util.getArg(aArgs, 'file', null);
  70648. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  70649. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  70650. this._sources = new ArraySet();
  70651. this._names = new ArraySet();
  70652. this._mappings = new MappingList();
  70653. this._sourcesContents = null;
  70654. }
  70655. SourceMapGenerator.prototype._version = 3;
  70656. /**
  70657. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  70658. *
  70659. * @param aSourceMapConsumer The SourceMap.
  70660. */
  70661. SourceMapGenerator.fromSourceMap =
  70662. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  70663. var sourceRoot = aSourceMapConsumer.sourceRoot;
  70664. var generator = new SourceMapGenerator({
  70665. file: aSourceMapConsumer.file,
  70666. sourceRoot: sourceRoot
  70667. });
  70668. aSourceMapConsumer.eachMapping(function (mapping) {
  70669. var newMapping = {
  70670. generated: {
  70671. line: mapping.generatedLine,
  70672. column: mapping.generatedColumn
  70673. }
  70674. };
  70675. if (mapping.source != null) {
  70676. newMapping.source = mapping.source;
  70677. if (sourceRoot != null) {
  70678. newMapping.source = util.relative(sourceRoot, newMapping.source);
  70679. }
  70680. newMapping.original = {
  70681. line: mapping.originalLine,
  70682. column: mapping.originalColumn
  70683. };
  70684. if (mapping.name != null) {
  70685. newMapping.name = mapping.name;
  70686. }
  70687. }
  70688. generator.addMapping(newMapping);
  70689. });
  70690. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  70691. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  70692. if (content != null) {
  70693. generator.setSourceContent(sourceFile, content);
  70694. }
  70695. });
  70696. return generator;
  70697. };
  70698. /**
  70699. * Add a single mapping from original source line and column to the generated
  70700. * source's line and column for this source map being created. The mapping
  70701. * object should have the following properties:
  70702. *
  70703. * - generated: An object with the generated line and column positions.
  70704. * - original: An object with the original line and column positions.
  70705. * - source: The original source file (relative to the sourceRoot).
  70706. * - name: An optional original token name for this mapping.
  70707. */
  70708. SourceMapGenerator.prototype.addMapping =
  70709. function SourceMapGenerator_addMapping(aArgs) {
  70710. var generated = util.getArg(aArgs, 'generated');
  70711. var original = util.getArg(aArgs, 'original', null);
  70712. var source = util.getArg(aArgs, 'source', null);
  70713. var name = util.getArg(aArgs, 'name', null);
  70714. if (!this._skipValidation) {
  70715. this._validateMapping(generated, original, source, name);
  70716. }
  70717. if (source != null && !this._sources.has(source)) {
  70718. this._sources.add(source);
  70719. }
  70720. if (name != null && !this._names.has(name)) {
  70721. this._names.add(name);
  70722. }
  70723. this._mappings.add({
  70724. generatedLine: generated.line,
  70725. generatedColumn: generated.column,
  70726. originalLine: original != null && original.line,
  70727. originalColumn: original != null && original.column,
  70728. source: source,
  70729. name: name
  70730. });
  70731. };
  70732. /**
  70733. * Set the source content for a source file.
  70734. */
  70735. SourceMapGenerator.prototype.setSourceContent =
  70736. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  70737. var source = aSourceFile;
  70738. if (this._sourceRoot != null) {
  70739. source = util.relative(this._sourceRoot, source);
  70740. }
  70741. if (aSourceContent != null) {
  70742. // Add the source content to the _sourcesContents map.
  70743. // Create a new _sourcesContents map if the property is null.
  70744. if (!this._sourcesContents) {
  70745. this._sourcesContents = {};
  70746. }
  70747. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  70748. } else if (this._sourcesContents) {
  70749. // Remove the source file from the _sourcesContents map.
  70750. // If the _sourcesContents map is empty, set the property to null.
  70751. delete this._sourcesContents[util.toSetString(source)];
  70752. if (Object.keys(this._sourcesContents).length === 0) {
  70753. this._sourcesContents = null;
  70754. }
  70755. }
  70756. };
  70757. /**
  70758. * Applies the mappings of a sub-source-map for a specific source file to the
  70759. * source map being generated. Each mapping to the supplied source file is
  70760. * rewritten using the supplied source map. Note: The resolution for the
  70761. * resulting mappings is the minimium of this map and the supplied map.
  70762. *
  70763. * @param aSourceMapConsumer The source map to be applied.
  70764. * @param aSourceFile Optional. The filename of the source file.
  70765. * If omitted, SourceMapConsumer's file property will be used.
  70766. * @param aSourceMapPath Optional. The dirname of the path to the source map
  70767. * to be applied. If relative, it is relative to the SourceMapConsumer.
  70768. * This parameter is needed when the two source maps aren't in the same
  70769. * directory, and the source map to be applied contains relative source
  70770. * paths. If so, those relative source paths need to be rewritten
  70771. * relative to the SourceMapGenerator.
  70772. */
  70773. SourceMapGenerator.prototype.applySourceMap =
  70774. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  70775. var sourceFile = aSourceFile;
  70776. // If aSourceFile is omitted, we will use the file property of the SourceMap
  70777. if (aSourceFile == null) {
  70778. if (aSourceMapConsumer.file == null) {
  70779. throw new Error(
  70780. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  70781. 'or the source map\'s "file" property. Both were omitted.'
  70782. );
  70783. }
  70784. sourceFile = aSourceMapConsumer.file;
  70785. }
  70786. var sourceRoot = this._sourceRoot;
  70787. // Make "sourceFile" relative if an absolute Url is passed.
  70788. if (sourceRoot != null) {
  70789. sourceFile = util.relative(sourceRoot, sourceFile);
  70790. }
  70791. // Applying the SourceMap can add and remove items from the sources and
  70792. // the names array.
  70793. var newSources = new ArraySet();
  70794. var newNames = new ArraySet();
  70795. // Find mappings for the "sourceFile"
  70796. this._mappings.unsortedForEach(function (mapping) {
  70797. if (mapping.source === sourceFile && mapping.originalLine != null) {
  70798. // Check if it can be mapped by the source map, then update the mapping.
  70799. var original = aSourceMapConsumer.originalPositionFor({
  70800. line: mapping.originalLine,
  70801. column: mapping.originalColumn
  70802. });
  70803. if (original.source != null) {
  70804. // Copy mapping
  70805. mapping.source = original.source;
  70806. if (aSourceMapPath != null) {
  70807. mapping.source = util.join(aSourceMapPath, mapping.source)
  70808. }
  70809. if (sourceRoot != null) {
  70810. mapping.source = util.relative(sourceRoot, mapping.source);
  70811. }
  70812. mapping.originalLine = original.line;
  70813. mapping.originalColumn = original.column;
  70814. if (original.name != null) {
  70815. mapping.name = original.name;
  70816. }
  70817. }
  70818. }
  70819. var source = mapping.source;
  70820. if (source != null && !newSources.has(source)) {
  70821. newSources.add(source);
  70822. }
  70823. var name = mapping.name;
  70824. if (name != null && !newNames.has(name)) {
  70825. newNames.add(name);
  70826. }
  70827. }, this);
  70828. this._sources = newSources;
  70829. this._names = newNames;
  70830. // Copy sourcesContents of applied map.
  70831. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  70832. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  70833. if (content != null) {
  70834. if (aSourceMapPath != null) {
  70835. sourceFile = util.join(aSourceMapPath, sourceFile);
  70836. }
  70837. if (sourceRoot != null) {
  70838. sourceFile = util.relative(sourceRoot, sourceFile);
  70839. }
  70840. this.setSourceContent(sourceFile, content);
  70841. }
  70842. }, this);
  70843. };
  70844. /**
  70845. * A mapping can have one of the three levels of data:
  70846. *
  70847. * 1. Just the generated position.
  70848. * 2. The Generated position, original position, and original source.
  70849. * 3. Generated and original position, original source, as well as a name
  70850. * token.
  70851. *
  70852. * To maintain consistency, we validate that any new mapping being added falls
  70853. * in to one of these categories.
  70854. */
  70855. SourceMapGenerator.prototype._validateMapping =
  70856. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  70857. aName) {
  70858. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  70859. && aGenerated.line > 0 && aGenerated.column >= 0
  70860. && !aOriginal && !aSource && !aName) {
  70861. // Case 1.
  70862. return;
  70863. }
  70864. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  70865. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  70866. && aGenerated.line > 0 && aGenerated.column >= 0
  70867. && aOriginal.line > 0 && aOriginal.column >= 0
  70868. && aSource) {
  70869. // Cases 2 and 3.
  70870. return;
  70871. }
  70872. else {
  70873. throw new Error('Invalid mapping: ' + JSON.stringify({
  70874. generated: aGenerated,
  70875. source: aSource,
  70876. original: aOriginal,
  70877. name: aName
  70878. }));
  70879. }
  70880. };
  70881. /**
  70882. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  70883. * specified by the source map format.
  70884. */
  70885. SourceMapGenerator.prototype._serializeMappings =
  70886. function SourceMapGenerator_serializeMappings() {
  70887. var previousGeneratedColumn = 0;
  70888. var previousGeneratedLine = 1;
  70889. var previousOriginalColumn = 0;
  70890. var previousOriginalLine = 0;
  70891. var previousName = 0;
  70892. var previousSource = 0;
  70893. var result = '';
  70894. var mapping;
  70895. var mappings = this._mappings.toArray();
  70896. for (var i = 0, len = mappings.length; i < len; i++) {
  70897. mapping = mappings[i];
  70898. if (mapping.generatedLine !== previousGeneratedLine) {
  70899. previousGeneratedColumn = 0;
  70900. while (mapping.generatedLine !== previousGeneratedLine) {
  70901. result += ';';
  70902. previousGeneratedLine++;
  70903. }
  70904. }
  70905. else {
  70906. if (i > 0) {
  70907. if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
  70908. continue;
  70909. }
  70910. result += ',';
  70911. }
  70912. }
  70913. result += base64VLQ.encode(mapping.generatedColumn
  70914. - previousGeneratedColumn);
  70915. previousGeneratedColumn = mapping.generatedColumn;
  70916. if (mapping.source != null) {
  70917. result += base64VLQ.encode(this._sources.indexOf(mapping.source)
  70918. - previousSource);
  70919. previousSource = this._sources.indexOf(mapping.source);
  70920. // lines are stored 0-based in SourceMap spec version 3
  70921. result += base64VLQ.encode(mapping.originalLine - 1
  70922. - previousOriginalLine);
  70923. previousOriginalLine = mapping.originalLine - 1;
  70924. result += base64VLQ.encode(mapping.originalColumn
  70925. - previousOriginalColumn);
  70926. previousOriginalColumn = mapping.originalColumn;
  70927. if (mapping.name != null) {
  70928. result += base64VLQ.encode(this._names.indexOf(mapping.name)
  70929. - previousName);
  70930. previousName = this._names.indexOf(mapping.name);
  70931. }
  70932. }
  70933. }
  70934. return result;
  70935. };
  70936. SourceMapGenerator.prototype._generateSourcesContent =
  70937. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  70938. return aSources.map(function (source) {
  70939. if (!this._sourcesContents) {
  70940. return null;
  70941. }
  70942. if (aSourceRoot != null) {
  70943. source = util.relative(aSourceRoot, source);
  70944. }
  70945. var key = util.toSetString(source);
  70946. return Object.prototype.hasOwnProperty.call(this._sourcesContents,
  70947. key)
  70948. ? this._sourcesContents[key]
  70949. : null;
  70950. }, this);
  70951. };
  70952. /**
  70953. * Externalize the source map.
  70954. */
  70955. SourceMapGenerator.prototype.toJSON =
  70956. function SourceMapGenerator_toJSON() {
  70957. var map = {
  70958. version: this._version,
  70959. sources: this._sources.toArray(),
  70960. names: this._names.toArray(),
  70961. mappings: this._serializeMappings()
  70962. };
  70963. if (this._file != null) {
  70964. map.file = this._file;
  70965. }
  70966. if (this._sourceRoot != null) {
  70967. map.sourceRoot = this._sourceRoot;
  70968. }
  70969. if (this._sourcesContents) {
  70970. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  70971. }
  70972. return map;
  70973. };
  70974. /**
  70975. * Render the source map being generated to a string.
  70976. */
  70977. SourceMapGenerator.prototype.toString =
  70978. function SourceMapGenerator_toString() {
  70979. return JSON.stringify(this.toJSON());
  70980. };
  70981. exports.SourceMapGenerator = SourceMapGenerator;
  70982. });
  70983. },{"./array-set":484,"./base64-vlq":485,"./mapping-list":488,"./util":492,"amdefine":493}],491:[function(require,module,exports){
  70984. /* -*- Mode: js; js-indent-level: 2; -*- */
  70985. /*
  70986. * Copyright 2011 Mozilla Foundation and contributors
  70987. * Licensed under the New BSD license. See LICENSE or:
  70988. * http://opensource.org/licenses/BSD-3-Clause
  70989. */
  70990. if (typeof define !== 'function') {
  70991. var define = require('amdefine')(module, require);
  70992. }
  70993. define(function (require, exports, module) {
  70994. var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
  70995. var util = require('./util');
  70996. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  70997. // operating systems these days (capturing the result).
  70998. var REGEX_NEWLINE = /(\r?\n)/;
  70999. // Newline character code for charCodeAt() comparisons
  71000. var NEWLINE_CODE = 10;
  71001. // Private symbol for identifying `SourceNode`s when multiple versions of
  71002. // the source-map library are loaded. This MUST NOT CHANGE across
  71003. // versions!
  71004. var isSourceNode = "$$$isSourceNode$$$";
  71005. /**
  71006. * SourceNodes provide a way to abstract over interpolating/concatenating
  71007. * snippets of generated JavaScript source code while maintaining the line and
  71008. * column information associated with the original source code.
  71009. *
  71010. * @param aLine The original line number.
  71011. * @param aColumn The original column number.
  71012. * @param aSource The original source's filename.
  71013. * @param aChunks Optional. An array of strings which are snippets of
  71014. * generated JS, or other SourceNodes.
  71015. * @param aName The original identifier.
  71016. */
  71017. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  71018. this.children = [];
  71019. this.sourceContents = {};
  71020. this.line = aLine == null ? null : aLine;
  71021. this.column = aColumn == null ? null : aColumn;
  71022. this.source = aSource == null ? null : aSource;
  71023. this.name = aName == null ? null : aName;
  71024. this[isSourceNode] = true;
  71025. if (aChunks != null) this.add(aChunks);
  71026. }
  71027. /**
  71028. * Creates a SourceNode from generated code and a SourceMapConsumer.
  71029. *
  71030. * @param aGeneratedCode The generated code
  71031. * @param aSourceMapConsumer The SourceMap for the generated code
  71032. * @param aRelativePath Optional. The path that relative sources in the
  71033. * SourceMapConsumer should be relative to.
  71034. */
  71035. SourceNode.fromStringWithSourceMap =
  71036. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  71037. // The SourceNode we want to fill with the generated code
  71038. // and the SourceMap
  71039. var node = new SourceNode();
  71040. // All even indices of this array are one line of the generated code,
  71041. // while all odd indices are the newlines between two adjacent lines
  71042. // (since `REGEX_NEWLINE` captures its match).
  71043. // Processed fragments are removed from this array, by calling `shiftNextLine`.
  71044. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  71045. var shiftNextLine = function() {
  71046. var lineContents = remainingLines.shift();
  71047. // The last line of a file might not have a newline.
  71048. var newLine = remainingLines.shift() || "";
  71049. return lineContents + newLine;
  71050. };
  71051. // We need to remember the position of "remainingLines"
  71052. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  71053. // The generate SourceNodes we need a code range.
  71054. // To extract it current and last mapping is used.
  71055. // Here we store the last mapping.
  71056. var lastMapping = null;
  71057. aSourceMapConsumer.eachMapping(function (mapping) {
  71058. if (lastMapping !== null) {
  71059. // We add the code from "lastMapping" to "mapping":
  71060. // First check if there is a new line in between.
  71061. if (lastGeneratedLine < mapping.generatedLine) {
  71062. var code = "";
  71063. // Associate first line with "lastMapping"
  71064. addMappingWithCode(lastMapping, shiftNextLine());
  71065. lastGeneratedLine++;
  71066. lastGeneratedColumn = 0;
  71067. // The remaining code is added without mapping
  71068. } else {
  71069. // There is no new line in between.
  71070. // Associate the code between "lastGeneratedColumn" and
  71071. // "mapping.generatedColumn" with "lastMapping"
  71072. var nextLine = remainingLines[0];
  71073. var code = nextLine.substr(0, mapping.generatedColumn -
  71074. lastGeneratedColumn);
  71075. remainingLines[0] = nextLine.substr(mapping.generatedColumn -
  71076. lastGeneratedColumn);
  71077. lastGeneratedColumn = mapping.generatedColumn;
  71078. addMappingWithCode(lastMapping, code);
  71079. // No more remaining code, continue
  71080. lastMapping = mapping;
  71081. return;
  71082. }
  71083. }
  71084. // We add the generated code until the first mapping
  71085. // to the SourceNode without any mapping.
  71086. // Each line is added as separate string.
  71087. while (lastGeneratedLine < mapping.generatedLine) {
  71088. node.add(shiftNextLine());
  71089. lastGeneratedLine++;
  71090. }
  71091. if (lastGeneratedColumn < mapping.generatedColumn) {
  71092. var nextLine = remainingLines[0];
  71093. node.add(nextLine.substr(0, mapping.generatedColumn));
  71094. remainingLines[0] = nextLine.substr(mapping.generatedColumn);
  71095. lastGeneratedColumn = mapping.generatedColumn;
  71096. }
  71097. lastMapping = mapping;
  71098. }, this);
  71099. // We have processed all mappings.
  71100. if (remainingLines.length > 0) {
  71101. if (lastMapping) {
  71102. // Associate the remaining code in the current line with "lastMapping"
  71103. addMappingWithCode(lastMapping, shiftNextLine());
  71104. }
  71105. // and add the remaining lines without any mapping
  71106. node.add(remainingLines.join(""));
  71107. }
  71108. // Copy sourcesContent into SourceNode
  71109. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  71110. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  71111. if (content != null) {
  71112. if (aRelativePath != null) {
  71113. sourceFile = util.join(aRelativePath, sourceFile);
  71114. }
  71115. node.setSourceContent(sourceFile, content);
  71116. }
  71117. });
  71118. return node;
  71119. function addMappingWithCode(mapping, code) {
  71120. if (mapping === null || mapping.source === undefined) {
  71121. node.add(code);
  71122. } else {
  71123. var source = aRelativePath
  71124. ? util.join(aRelativePath, mapping.source)
  71125. : mapping.source;
  71126. node.add(new SourceNode(mapping.originalLine,
  71127. mapping.originalColumn,
  71128. source,
  71129. code,
  71130. mapping.name));
  71131. }
  71132. }
  71133. };
  71134. /**
  71135. * Add a chunk of generated JS to this source node.
  71136. *
  71137. * @param aChunk A string snippet of generated JS code, another instance of
  71138. * SourceNode, or an array where each member is one of those things.
  71139. */
  71140. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  71141. if (Array.isArray(aChunk)) {
  71142. aChunk.forEach(function (chunk) {
  71143. this.add(chunk);
  71144. }, this);
  71145. }
  71146. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  71147. if (aChunk) {
  71148. this.children.push(aChunk);
  71149. }
  71150. }
  71151. else {
  71152. throw new TypeError(
  71153. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  71154. );
  71155. }
  71156. return this;
  71157. };
  71158. /**
  71159. * Add a chunk of generated JS to the beginning of this source node.
  71160. *
  71161. * @param aChunk A string snippet of generated JS code, another instance of
  71162. * SourceNode, or an array where each member is one of those things.
  71163. */
  71164. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  71165. if (Array.isArray(aChunk)) {
  71166. for (var i = aChunk.length-1; i >= 0; i--) {
  71167. this.prepend(aChunk[i]);
  71168. }
  71169. }
  71170. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  71171. this.children.unshift(aChunk);
  71172. }
  71173. else {
  71174. throw new TypeError(
  71175. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  71176. );
  71177. }
  71178. return this;
  71179. };
  71180. /**
  71181. * Walk over the tree of JS snippets in this node and its children. The
  71182. * walking function is called once for each snippet of JS and is passed that
  71183. * snippet and the its original associated source's line/column location.
  71184. *
  71185. * @param aFn The traversal function.
  71186. */
  71187. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  71188. var chunk;
  71189. for (var i = 0, len = this.children.length; i < len; i++) {
  71190. chunk = this.children[i];
  71191. if (chunk[isSourceNode]) {
  71192. chunk.walk(aFn);
  71193. }
  71194. else {
  71195. if (chunk !== '') {
  71196. aFn(chunk, { source: this.source,
  71197. line: this.line,
  71198. column: this.column,
  71199. name: this.name });
  71200. }
  71201. }
  71202. }
  71203. };
  71204. /**
  71205. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  71206. * each of `this.children`.
  71207. *
  71208. * @param aSep The separator.
  71209. */
  71210. SourceNode.prototype.join = function SourceNode_join(aSep) {
  71211. var newChildren;
  71212. var i;
  71213. var len = this.children.length;
  71214. if (len > 0) {
  71215. newChildren = [];
  71216. for (i = 0; i < len-1; i++) {
  71217. newChildren.push(this.children[i]);
  71218. newChildren.push(aSep);
  71219. }
  71220. newChildren.push(this.children[i]);
  71221. this.children = newChildren;
  71222. }
  71223. return this;
  71224. };
  71225. /**
  71226. * Call String.prototype.replace on the very right-most source snippet. Useful
  71227. * for trimming whitespace from the end of a source node, etc.
  71228. *
  71229. * @param aPattern The pattern to replace.
  71230. * @param aReplacement The thing to replace the pattern with.
  71231. */
  71232. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  71233. var lastChild = this.children[this.children.length - 1];
  71234. if (lastChild[isSourceNode]) {
  71235. lastChild.replaceRight(aPattern, aReplacement);
  71236. }
  71237. else if (typeof lastChild === 'string') {
  71238. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  71239. }
  71240. else {
  71241. this.children.push(''.replace(aPattern, aReplacement));
  71242. }
  71243. return this;
  71244. };
  71245. /**
  71246. * Set the source content for a source file. This will be added to the SourceMapGenerator
  71247. * in the sourcesContent field.
  71248. *
  71249. * @param aSourceFile The filename of the source file
  71250. * @param aSourceContent The content of the source file
  71251. */
  71252. SourceNode.prototype.setSourceContent =
  71253. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  71254. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  71255. };
  71256. /**
  71257. * Walk over the tree of SourceNodes. The walking function is called for each
  71258. * source file content and is passed the filename and source content.
  71259. *
  71260. * @param aFn The traversal function.
  71261. */
  71262. SourceNode.prototype.walkSourceContents =
  71263. function SourceNode_walkSourceContents(aFn) {
  71264. for (var i = 0, len = this.children.length; i < len; i++) {
  71265. if (this.children[i][isSourceNode]) {
  71266. this.children[i].walkSourceContents(aFn);
  71267. }
  71268. }
  71269. var sources = Object.keys(this.sourceContents);
  71270. for (var i = 0, len = sources.length; i < len; i++) {
  71271. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  71272. }
  71273. };
  71274. /**
  71275. * Return the string representation of this source node. Walks over the tree
  71276. * and concatenates all the various snippets together to one string.
  71277. */
  71278. SourceNode.prototype.toString = function SourceNode_toString() {
  71279. var str = "";
  71280. this.walk(function (chunk) {
  71281. str += chunk;
  71282. });
  71283. return str;
  71284. };
  71285. /**
  71286. * Returns the string representation of this source node along with a source
  71287. * map.
  71288. */
  71289. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  71290. var generated = {
  71291. code: "",
  71292. line: 1,
  71293. column: 0
  71294. };
  71295. var map = new SourceMapGenerator(aArgs);
  71296. var sourceMappingActive = false;
  71297. var lastOriginalSource = null;
  71298. var lastOriginalLine = null;
  71299. var lastOriginalColumn = null;
  71300. var lastOriginalName = null;
  71301. this.walk(function (chunk, original) {
  71302. generated.code += chunk;
  71303. if (original.source !== null
  71304. && original.line !== null
  71305. && original.column !== null) {
  71306. if(lastOriginalSource !== original.source
  71307. || lastOriginalLine !== original.line
  71308. || lastOriginalColumn !== original.column
  71309. || lastOriginalName !== original.name) {
  71310. map.addMapping({
  71311. source: original.source,
  71312. original: {
  71313. line: original.line,
  71314. column: original.column
  71315. },
  71316. generated: {
  71317. line: generated.line,
  71318. column: generated.column
  71319. },
  71320. name: original.name
  71321. });
  71322. }
  71323. lastOriginalSource = original.source;
  71324. lastOriginalLine = original.line;
  71325. lastOriginalColumn = original.column;
  71326. lastOriginalName = original.name;
  71327. sourceMappingActive = true;
  71328. } else if (sourceMappingActive) {
  71329. map.addMapping({
  71330. generated: {
  71331. line: generated.line,
  71332. column: generated.column
  71333. }
  71334. });
  71335. lastOriginalSource = null;
  71336. sourceMappingActive = false;
  71337. }
  71338. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  71339. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  71340. generated.line++;
  71341. generated.column = 0;
  71342. // Mappings end at eol
  71343. if (idx + 1 === length) {
  71344. lastOriginalSource = null;
  71345. sourceMappingActive = false;
  71346. } else if (sourceMappingActive) {
  71347. map.addMapping({
  71348. source: original.source,
  71349. original: {
  71350. line: original.line,
  71351. column: original.column
  71352. },
  71353. generated: {
  71354. line: generated.line,
  71355. column: generated.column
  71356. },
  71357. name: original.name
  71358. });
  71359. }
  71360. } else {
  71361. generated.column++;
  71362. }
  71363. }
  71364. });
  71365. this.walkSourceContents(function (sourceFile, sourceContent) {
  71366. map.setSourceContent(sourceFile, sourceContent);
  71367. });
  71368. return { code: generated.code, map: map };
  71369. };
  71370. exports.SourceNode = SourceNode;
  71371. });
  71372. },{"./source-map-generator":490,"./util":492,"amdefine":493}],492:[function(require,module,exports){
  71373. /* -*- Mode: js; js-indent-level: 2; -*- */
  71374. /*
  71375. * Copyright 2011 Mozilla Foundation and contributors
  71376. * Licensed under the New BSD license. See LICENSE or:
  71377. * http://opensource.org/licenses/BSD-3-Clause
  71378. */
  71379. if (typeof define !== 'function') {
  71380. var define = require('amdefine')(module, require);
  71381. }
  71382. define(function (require, exports, module) {
  71383. /**
  71384. * This is a helper function for getting values from parameter/options
  71385. * objects.
  71386. *
  71387. * @param args The object we are extracting values from
  71388. * @param name The name of the property we are getting.
  71389. * @param defaultValue An optional value to return if the property is missing
  71390. * from the object. If this is not specified and the property is missing, an
  71391. * error will be thrown.
  71392. */
  71393. function getArg(aArgs, aName, aDefaultValue) {
  71394. if (aName in aArgs) {
  71395. return aArgs[aName];
  71396. } else if (arguments.length === 3) {
  71397. return aDefaultValue;
  71398. } else {
  71399. throw new Error('"' + aName + '" is a required argument.');
  71400. }
  71401. }
  71402. exports.getArg = getArg;
  71403. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
  71404. var dataUrlRegexp = /^data:.+\,.+$/;
  71405. function urlParse(aUrl) {
  71406. var match = aUrl.match(urlRegexp);
  71407. if (!match) {
  71408. return null;
  71409. }
  71410. return {
  71411. scheme: match[1],
  71412. auth: match[2],
  71413. host: match[3],
  71414. port: match[4],
  71415. path: match[5]
  71416. };
  71417. }
  71418. exports.urlParse = urlParse;
  71419. function urlGenerate(aParsedUrl) {
  71420. var url = '';
  71421. if (aParsedUrl.scheme) {
  71422. url += aParsedUrl.scheme + ':';
  71423. }
  71424. url += '//';
  71425. if (aParsedUrl.auth) {
  71426. url += aParsedUrl.auth + '@';
  71427. }
  71428. if (aParsedUrl.host) {
  71429. url += aParsedUrl.host;
  71430. }
  71431. if (aParsedUrl.port) {
  71432. url += ":" + aParsedUrl.port
  71433. }
  71434. if (aParsedUrl.path) {
  71435. url += aParsedUrl.path;
  71436. }
  71437. return url;
  71438. }
  71439. exports.urlGenerate = urlGenerate;
  71440. /**
  71441. * Normalizes a path, or the path portion of a URL:
  71442. *
  71443. * - Replaces consequtive slashes with one slash.
  71444. * - Removes unnecessary '.' parts.
  71445. * - Removes unnecessary '<dir>/..' parts.
  71446. *
  71447. * Based on code in the Node.js 'path' core module.
  71448. *
  71449. * @param aPath The path or url to normalize.
  71450. */
  71451. function normalize(aPath) {
  71452. var path = aPath;
  71453. var url = urlParse(aPath);
  71454. if (url) {
  71455. if (!url.path) {
  71456. return aPath;
  71457. }
  71458. path = url.path;
  71459. }
  71460. var isAbsolute = (path.charAt(0) === '/');
  71461. var parts = path.split(/\/+/);
  71462. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  71463. part = parts[i];
  71464. if (part === '.') {
  71465. parts.splice(i, 1);
  71466. } else if (part === '..') {
  71467. up++;
  71468. } else if (up > 0) {
  71469. if (part === '') {
  71470. // The first part is blank if the path is absolute. Trying to go
  71471. // above the root is a no-op. Therefore we can remove all '..' parts
  71472. // directly after the root.
  71473. parts.splice(i + 1, up);
  71474. up = 0;
  71475. } else {
  71476. parts.splice(i, 2);
  71477. up--;
  71478. }
  71479. }
  71480. }
  71481. path = parts.join('/');
  71482. if (path === '') {
  71483. path = isAbsolute ? '/' : '.';
  71484. }
  71485. if (url) {
  71486. url.path = path;
  71487. return urlGenerate(url);
  71488. }
  71489. return path;
  71490. }
  71491. exports.normalize = normalize;
  71492. /**
  71493. * Joins two paths/URLs.
  71494. *
  71495. * @param aRoot The root path or URL.
  71496. * @param aPath The path or URL to be joined with the root.
  71497. *
  71498. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  71499. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  71500. * first.
  71501. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  71502. * is updated with the result and aRoot is returned. Otherwise the result
  71503. * is returned.
  71504. * - If aPath is absolute, the result is aPath.
  71505. * - Otherwise the two paths are joined with a slash.
  71506. * - Joining for example 'http://' and 'www.example.com' is also supported.
  71507. */
  71508. function join(aRoot, aPath) {
  71509. if (aRoot === "") {
  71510. aRoot = ".";
  71511. }
  71512. if (aPath === "") {
  71513. aPath = ".";
  71514. }
  71515. var aPathUrl = urlParse(aPath);
  71516. var aRootUrl = urlParse(aRoot);
  71517. if (aRootUrl) {
  71518. aRoot = aRootUrl.path || '/';
  71519. }
  71520. // `join(foo, '//www.example.org')`
  71521. if (aPathUrl && !aPathUrl.scheme) {
  71522. if (aRootUrl) {
  71523. aPathUrl.scheme = aRootUrl.scheme;
  71524. }
  71525. return urlGenerate(aPathUrl);
  71526. }
  71527. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  71528. return aPath;
  71529. }
  71530. // `join('http://', 'www.example.com')`
  71531. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  71532. aRootUrl.host = aPath;
  71533. return urlGenerate(aRootUrl);
  71534. }
  71535. var joined = aPath.charAt(0) === '/'
  71536. ? aPath
  71537. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  71538. if (aRootUrl) {
  71539. aRootUrl.path = joined;
  71540. return urlGenerate(aRootUrl);
  71541. }
  71542. return joined;
  71543. }
  71544. exports.join = join;
  71545. /**
  71546. * Make a path relative to a URL or another path.
  71547. *
  71548. * @param aRoot The root path or URL.
  71549. * @param aPath The path or URL to be made relative to aRoot.
  71550. */
  71551. function relative(aRoot, aPath) {
  71552. if (aRoot === "") {
  71553. aRoot = ".";
  71554. }
  71555. aRoot = aRoot.replace(/\/$/, '');
  71556. // XXX: It is possible to remove this block, and the tests still pass!
  71557. var url = urlParse(aRoot);
  71558. if (aPath.charAt(0) == "/" && url && url.path == "/") {
  71559. return aPath.slice(1);
  71560. }
  71561. return aPath.indexOf(aRoot + '/') === 0
  71562. ? aPath.substr(aRoot.length + 1)
  71563. : aPath;
  71564. }
  71565. exports.relative = relative;
  71566. /**
  71567. * Because behavior goes wacky when you set `__proto__` on objects, we
  71568. * have to prefix all the strings in our set with an arbitrary character.
  71569. *
  71570. * See https://github.com/mozilla/source-map/pull/31 and
  71571. * https://github.com/mozilla/source-map/issues/30
  71572. *
  71573. * @param String aStr
  71574. */
  71575. function toSetString(aStr) {
  71576. return '$' + aStr;
  71577. }
  71578. exports.toSetString = toSetString;
  71579. function fromSetString(aStr) {
  71580. return aStr.substr(1);
  71581. }
  71582. exports.fromSetString = fromSetString;
  71583. function strcmp(aStr1, aStr2) {
  71584. var s1 = aStr1 || "";
  71585. var s2 = aStr2 || "";
  71586. return (s1 > s2) - (s1 < s2);
  71587. }
  71588. /**
  71589. * Comparator between two mappings where the original positions are compared.
  71590. *
  71591. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  71592. * mappings with the same original source/line/column, but different generated
  71593. * line and column the same. Useful when searching for a mapping with a
  71594. * stubbed out mapping.
  71595. */
  71596. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  71597. var cmp;
  71598. cmp = strcmp(mappingA.source, mappingB.source);
  71599. if (cmp) {
  71600. return cmp;
  71601. }
  71602. cmp = mappingA.originalLine - mappingB.originalLine;
  71603. if (cmp) {
  71604. return cmp;
  71605. }
  71606. cmp = mappingA.originalColumn - mappingB.originalColumn;
  71607. if (cmp || onlyCompareOriginal) {
  71608. return cmp;
  71609. }
  71610. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  71611. if (cmp) {
  71612. return cmp;
  71613. }
  71614. cmp = mappingA.generatedLine - mappingB.generatedLine;
  71615. if (cmp) {
  71616. return cmp;
  71617. }
  71618. return strcmp(mappingA.name, mappingB.name);
  71619. };
  71620. exports.compareByOriginalPositions = compareByOriginalPositions;
  71621. /**
  71622. * Comparator between two mappings where the generated positions are
  71623. * compared.
  71624. *
  71625. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  71626. * mappings with the same generated line and column, but different
  71627. * source/name/original line and column the same. Useful when searching for a
  71628. * mapping with a stubbed out mapping.
  71629. */
  71630. function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
  71631. var cmp;
  71632. cmp = mappingA.generatedLine - mappingB.generatedLine;
  71633. if (cmp) {
  71634. return cmp;
  71635. }
  71636. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  71637. if (cmp || onlyCompareGenerated) {
  71638. return cmp;
  71639. }
  71640. cmp = strcmp(mappingA.source, mappingB.source);
  71641. if (cmp) {
  71642. return cmp;
  71643. }
  71644. cmp = mappingA.originalLine - mappingB.originalLine;
  71645. if (cmp) {
  71646. return cmp;
  71647. }
  71648. cmp = mappingA.originalColumn - mappingB.originalColumn;
  71649. if (cmp) {
  71650. return cmp;
  71651. }
  71652. return strcmp(mappingA.name, mappingB.name);
  71653. };
  71654. exports.compareByGeneratedPositions = compareByGeneratedPositions;
  71655. });
  71656. },{"amdefine":493}],493:[function(require,module,exports){
  71657. (function (process,__filename){
  71658. /** vim: et:ts=4:sw=4:sts=4
  71659. * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
  71660. * Available via the MIT or new BSD license.
  71661. * see: http://github.com/jrburke/amdefine for details
  71662. */
  71663. /*jslint node: true */
  71664. /*global module, process */
  71665. 'use strict';
  71666. /**
  71667. * Creates a define for node.
  71668. * @param {Object} module the "module" object that is defined by Node for the
  71669. * current module.
  71670. * @param {Function} [requireFn]. Node's require function for the current module.
  71671. * It only needs to be passed in Node versions before 0.5, when module.require
  71672. * did not exist.
  71673. * @returns {Function} a define function that is usable for the current node
  71674. * module.
  71675. */
  71676. function amdefine(module, requireFn) {
  71677. 'use strict';
  71678. var defineCache = {},
  71679. loaderCache = {},
  71680. alreadyCalled = false,
  71681. path = require('path'),
  71682. makeRequire, stringRequire;
  71683. /**
  71684. * Trims the . and .. from an array of path segments.
  71685. * It will keep a leading path segment if a .. will become
  71686. * the first path segment, to help with module name lookups,
  71687. * which act like paths, but can be remapped. But the end result,
  71688. * all paths that use this function should look normalized.
  71689. * NOTE: this method MODIFIES the input array.
  71690. * @param {Array} ary the array of path segments.
  71691. */
  71692. function trimDots(ary) {
  71693. var i, part;
  71694. for (i = 0; ary[i]; i+= 1) {
  71695. part = ary[i];
  71696. if (part === '.') {
  71697. ary.splice(i, 1);
  71698. i -= 1;
  71699. } else if (part === '..') {
  71700. if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
  71701. //End of the line. Keep at least one non-dot
  71702. //path segment at the front so it can be mapped
  71703. //correctly to disk. Otherwise, there is likely
  71704. //no path mapping for a path starting with '..'.
  71705. //This can still fail, but catches the most reasonable
  71706. //uses of ..
  71707. break;
  71708. } else if (i > 0) {
  71709. ary.splice(i - 1, 2);
  71710. i -= 2;
  71711. }
  71712. }
  71713. }
  71714. }
  71715. function normalize(name, baseName) {
  71716. var baseParts;
  71717. //Adjust any relative paths.
  71718. if (name && name.charAt(0) === '.') {
  71719. //If have a base name, try to normalize against it,
  71720. //otherwise, assume it is a top-level require that will
  71721. //be relative to baseUrl in the end.
  71722. if (baseName) {
  71723. baseParts = baseName.split('/');
  71724. baseParts = baseParts.slice(0, baseParts.length - 1);
  71725. baseParts = baseParts.concat(name.split('/'));
  71726. trimDots(baseParts);
  71727. name = baseParts.join('/');
  71728. }
  71729. }
  71730. return name;
  71731. }
  71732. /**
  71733. * Create the normalize() function passed to a loader plugin's
  71734. * normalize method.
  71735. */
  71736. function makeNormalize(relName) {
  71737. return function (name) {
  71738. return normalize(name, relName);
  71739. };
  71740. }
  71741. function makeLoad(id) {
  71742. function load(value) {
  71743. loaderCache[id] = value;
  71744. }
  71745. load.fromText = function (id, text) {
  71746. //This one is difficult because the text can/probably uses
  71747. //define, and any relative paths and requires should be relative
  71748. //to that id was it would be found on disk. But this would require
  71749. //bootstrapping a module/require fairly deeply from node core.
  71750. //Not sure how best to go about that yet.
  71751. throw new Error('amdefine does not implement load.fromText');
  71752. };
  71753. return load;
  71754. }
  71755. makeRequire = function (systemRequire, exports, module, relId) {
  71756. function amdRequire(deps, callback) {
  71757. if (typeof deps === 'string') {
  71758. //Synchronous, single module require('')
  71759. return stringRequire(systemRequire, exports, module, deps, relId);
  71760. } else {
  71761. //Array of dependencies with a callback.
  71762. //Convert the dependencies to modules.
  71763. deps = deps.map(function (depName) {
  71764. return stringRequire(systemRequire, exports, module, depName, relId);
  71765. });
  71766. //Wait for next tick to call back the require call.
  71767. process.nextTick(function () {
  71768. callback.apply(null, deps);
  71769. });
  71770. }
  71771. }
  71772. amdRequire.toUrl = function (filePath) {
  71773. if (filePath.indexOf('.') === 0) {
  71774. return normalize(filePath, path.dirname(module.filename));
  71775. } else {
  71776. return filePath;
  71777. }
  71778. };
  71779. return amdRequire;
  71780. };
  71781. //Favor explicit value, passed in if the module wants to support Node 0.4.
  71782. requireFn = requireFn || function req() {
  71783. return module.require.apply(module, arguments);
  71784. };
  71785. function runFactory(id, deps, factory) {
  71786. var r, e, m, result;
  71787. if (id) {
  71788. e = loaderCache[id] = {};
  71789. m = {
  71790. id: id,
  71791. uri: __filename,
  71792. exports: e
  71793. };
  71794. r = makeRequire(requireFn, e, m, id);
  71795. } else {
  71796. //Only support one define call per file
  71797. if (alreadyCalled) {
  71798. throw new Error('amdefine with no module ID cannot be called more than once per file.');
  71799. }
  71800. alreadyCalled = true;
  71801. //Use the real variables from node
  71802. //Use module.exports for exports, since
  71803. //the exports in here is amdefine exports.
  71804. e = module.exports;
  71805. m = module;
  71806. r = makeRequire(requireFn, e, m, module.id);
  71807. }
  71808. //If there are dependencies, they are strings, so need
  71809. //to convert them to dependency values.
  71810. if (deps) {
  71811. deps = deps.map(function (depName) {
  71812. return r(depName);
  71813. });
  71814. }
  71815. //Call the factory with the right dependencies.
  71816. if (typeof factory === 'function') {
  71817. result = factory.apply(m.exports, deps);
  71818. } else {
  71819. result = factory;
  71820. }
  71821. if (result !== undefined) {
  71822. m.exports = result;
  71823. if (id) {
  71824. loaderCache[id] = m.exports;
  71825. }
  71826. }
  71827. }
  71828. stringRequire = function (systemRequire, exports, module, id, relId) {
  71829. //Split the ID by a ! so that
  71830. var index = id.indexOf('!'),
  71831. originalId = id,
  71832. prefix, plugin;
  71833. if (index === -1) {
  71834. id = normalize(id, relId);
  71835. //Straight module lookup. If it is one of the special dependencies,
  71836. //deal with it, otherwise, delegate to node.
  71837. if (id === 'require') {
  71838. return makeRequire(systemRequire, exports, module, relId);
  71839. } else if (id === 'exports') {
  71840. return exports;
  71841. } else if (id === 'module') {
  71842. return module;
  71843. } else if (loaderCache.hasOwnProperty(id)) {
  71844. return loaderCache[id];
  71845. } else if (defineCache[id]) {
  71846. runFactory.apply(null, defineCache[id]);
  71847. return loaderCache[id];
  71848. } else {
  71849. if(systemRequire) {
  71850. return systemRequire(originalId);
  71851. } else {
  71852. throw new Error('No module with ID: ' + id);
  71853. }
  71854. }
  71855. } else {
  71856. //There is a plugin in play.
  71857. prefix = id.substring(0, index);
  71858. id = id.substring(index + 1, id.length);
  71859. plugin = stringRequire(systemRequire, exports, module, prefix, relId);
  71860. if (plugin.normalize) {
  71861. id = plugin.normalize(id, makeNormalize(relId));
  71862. } else {
  71863. //Normalize the ID normally.
  71864. id = normalize(id, relId);
  71865. }
  71866. if (loaderCache[id]) {
  71867. return loaderCache[id];
  71868. } else {
  71869. plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
  71870. return loaderCache[id];
  71871. }
  71872. }
  71873. };
  71874. //Create a define function specific to the module asking for amdefine.
  71875. function define(id, deps, factory) {
  71876. if (Array.isArray(id)) {
  71877. factory = deps;
  71878. deps = id;
  71879. id = undefined;
  71880. } else if (typeof id !== 'string') {
  71881. factory = id;
  71882. id = deps = undefined;
  71883. }
  71884. if (deps && !Array.isArray(deps)) {
  71885. factory = deps;
  71886. deps = undefined;
  71887. }
  71888. if (!deps) {
  71889. deps = ['require', 'exports', 'module'];
  71890. }
  71891. //Set up properties for this module. If an ID, then use
  71892. //internal cache. If no ID, then use the external variables
  71893. //for this node module.
  71894. if (id) {
  71895. //Put the module in deep freeze until there is a
  71896. //require call for it.
  71897. defineCache[id] = [id, deps, factory];
  71898. } else {
  71899. runFactory(id, deps, factory);
  71900. }
  71901. }
  71902. //define.require, which has access to all the values in the
  71903. //cache. Useful for AMD modules that all have IDs in the file,
  71904. //but need to finally export a value to node based on one of those
  71905. //IDs.
  71906. define.require = function (id) {
  71907. if (loaderCache[id]) {
  71908. return loaderCache[id];
  71909. }
  71910. if (defineCache[id]) {
  71911. runFactory.apply(null, defineCache[id]);
  71912. return loaderCache[id];
  71913. }
  71914. };
  71915. define.amd = {};
  71916. return define;
  71917. }
  71918. module.exports = amdefine;
  71919. }).call(this,require('_process'),"/node_modules/source-map/node_modules/amdefine/amdefine.js")
  71920. },{"_process":200,"path":199}],494:[function(require,module,exports){
  71921. /*!
  71922. strip-json-comments
  71923. Strip comments from JSON. Lets you use comments in your JSON files!
  71924. https://github.com/sindresorhus/strip-json-comments
  71925. by Sindre Sorhus
  71926. MIT License
  71927. */
  71928. (function () {
  71929. 'use strict';
  71930. function stripJsonComments(str) {
  71931. var currentChar;
  71932. var nextChar;
  71933. var insideString = false;
  71934. var insideComment = false;
  71935. var ret = '';
  71936. for (var i = 0; i < str.length; i++) {
  71937. currentChar = str[i];
  71938. nextChar = str[i + 1];
  71939. if (!insideComment && str[i - 1] !== '\\' && currentChar === '"') {
  71940. insideString = !insideString;
  71941. }
  71942. if (insideString) {
  71943. ret += currentChar;
  71944. continue;
  71945. }
  71946. if (!insideComment && currentChar + nextChar === '//') {
  71947. insideComment = 'single';
  71948. i++;
  71949. } else if (insideComment === 'single' && currentChar + nextChar === '\r\n') {
  71950. insideComment = false;
  71951. i++;
  71952. ret += currentChar;
  71953. ret += nextChar;
  71954. continue;
  71955. } else if (insideComment === 'single' && currentChar === '\n') {
  71956. insideComment = false;
  71957. } else if (!insideComment && currentChar + nextChar === '/*') {
  71958. insideComment = 'multi';
  71959. i++;
  71960. continue;
  71961. } else if (insideComment === 'multi' && currentChar + nextChar === '*/') {
  71962. insideComment = false;
  71963. i++;
  71964. continue;
  71965. }
  71966. if (insideComment) {
  71967. continue;
  71968. }
  71969. ret += currentChar;
  71970. }
  71971. return ret;
  71972. }
  71973. if (typeof module !== 'undefined' && module.exports) {
  71974. module.exports = stripJsonComments;
  71975. } else {
  71976. window.stripJsonComments = stripJsonComments;
  71977. }
  71978. })();
  71979. },{}],495:[function(require,module,exports){
  71980. 'use strict';
  71981. module.exports = function toFastProperties(obj) {
  71982. /*jshint -W027*/
  71983. function f() {}
  71984. f.prototype = obj;
  71985. new f();
  71986. return;
  71987. eval(obj);
  71988. };
  71989. },{}],496:[function(require,module,exports){
  71990. 'use strict';
  71991. module.exports = function (str) {
  71992. return str.replace(/[\s\uFEFF\xA0]+$/g, '');
  71993. };
  71994. },{}],497:[function(require,module,exports){
  71995. module.exports={
  71996. "name": "babel-core",
  71997. "description": "Turn ES6 code into readable vanilla ES5 with source maps",
  71998. "version": "5.4.3",
  71999. "author": "Sebastian McKenzie <sebmck@gmail.com>",
  72000. "homepage": "https://babeljs.io/",
  72001. "license": "MIT",
  72002. "repository": "babel/babel",
  72003. "main": "lib/babel/api/node.js",
  72004. "browser": {
  72005. "./lib/babel/api/register/node.js": "./lib/babel/api/register/browser.js"
  72006. },
  72007. "keywords": [
  72008. "harmony",
  72009. "classes",
  72010. "modules",
  72011. "let",
  72012. "const",
  72013. "var",
  72014. "es6",
  72015. "transpile",
  72016. "transpiler",
  72017. "6to5",
  72018. "babel"
  72019. ],
  72020. "scripts": {
  72021. "bench": "make bench",
  72022. "test": "make test"
  72023. },
  72024. "dependencies": {
  72025. "acorn-jsx": "^1.0.0",
  72026. "ast-types": "~0.7.0",
  72027. "bluebird": "^2.9.25",
  72028. "chalk": "^1.0.0",
  72029. "convert-source-map": "^1.1.0",
  72030. "core-js": "^0.9.0",
  72031. "debug": "^2.1.1",
  72032. "detect-indent": "^3.0.0",
  72033. "esquery": "^0.4.0",
  72034. "estraverse": "^4.0.0",
  72035. "esutils": "^2.0.0",
  72036. "fs-readdir-recursive": "^0.1.0",
  72037. "globals": "^6.4.0",
  72038. "is-integer": "^1.0.4",
  72039. "js-tokens": "1.0.0",
  72040. "leven": "^1.0.1",
  72041. "line-numbers": "0.2.0",
  72042. "lodash": "^3.6.0",
  72043. "minimatch": "^2.0.3",
  72044. "output-file-sync": "^1.1.0",
  72045. "path-is-absolute": "^1.0.0",
  72046. "private": "^0.1.6",
  72047. "regenerator": "^0.8.20",
  72048. "regexpu": "^1.1.2",
  72049. "repeating": "^1.1.2",
  72050. "resolve": "^1.1.6",
  72051. "shebang-regex": "^1.0.0",
  72052. "slash": "^1.0.0",
  72053. "source-map": "^0.4.0",
  72054. "source-map-support": "^0.2.10",
  72055. "strip-json-comments": "^1.0.2",
  72056. "to-fast-properties": "^1.0.0",
  72057. "trim-right": "^1.0.0",
  72058. "user-home": "^1.1.1"
  72059. },
  72060. "devDependencies": {
  72061. "babel": "5.3.1",
  72062. "browserify": "^9.0.8",
  72063. "chai": "^2.2.0",
  72064. "eslint": "^0.18.0",
  72065. "babel-eslint": "^2.0.0",
  72066. "esvalid": "^1.1.0",
  72067. "istanbul": "^0.3.5",
  72068. "matcha": "^0.6.0",
  72069. "mocha": "2.2.0",
  72070. "rimraf": "^2.3.2",
  72071. "uglify-js": "^2.4.16"
  72072. }
  72073. }
  72074. },{}],498:[function(require,module,exports){
  72075. module.exports={"abstract-expression-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceGet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-delete":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceDelete","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-get":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceGet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-set":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceSet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-comprehension-container":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-from":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-push":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"STATEMENT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"CONTEXT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-decorator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"DECORATOR","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-constructor-call-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-constructor-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-native-constructor-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"type":"SpreadElement","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__proto__","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"CLASS_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"default-parameter":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"VARIABLE_NAME","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARGUMENT_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"DEFAULT_VALUE","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARGUMENT_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"let","type":"VariableDeclaration","end":null}],"type":"Program","end":null},"exports-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-default-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"module","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-from-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"INIT","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-module-declaration-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-module-declaration":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"value":"__esModule","raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARR","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"BODY","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":null,"update":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"operator":">=","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"STEP_KEY","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"STEP_KEY","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":null,"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-async-to-generator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"fn","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"gen","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"fn","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Promise","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"reject","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"value":"next","raw":null,"type":"Literal","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"callThrow","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"value":"throw","raw":null,"type":"Literal","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"arg","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"gen","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arg","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"error","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"reject","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"error","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":null,"type":"ReturnStatement","end":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":null,"type":"TryStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Promise","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"then","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"callThrow","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-bind":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Function","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-class-call-check":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"instance","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"instance","type":"Identifier","end":null},"operator":"instanceof","right":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Cannot call a class as a function","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-class":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-decorated-class":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"initializers","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"||","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"The decorator for method ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is of the invalid type ","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"initializers","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoInitializers","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticInitializers","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoInitializers","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticInitializers","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-decorated-object":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"The decorator for method ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is of the invalid type ","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-default-props":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-defaults":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyNames","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-define-decorated-property-descriptor":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":null,"type":"ReturnStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null,"leadingComments":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForInStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-define-property":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-extends":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"assign","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":1,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-get":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getPrototypeOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-has-own":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-inherits":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"Super expression must either be null or a function, not ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"create","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"constructor","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__proto__","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-instanceof":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"hasInstance","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"hasInstance","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null},"operator":"instanceof","right":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require-default":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"alternate":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"value":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require-wildcard":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"alternate":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-object-destructuring-empty":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Cannot destructure undefined","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-object-without-properties":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"indexOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":">=","right":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-self-global":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"self","type":"Identifier","end":null},"alternate":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-set":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getPrototypeOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-slice":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"slice","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-sliced-to-array-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"in","right":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_iterator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_iterator","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Invalid attempt to destructure non-iterable instance","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-sliced-to-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"in","right":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null,"leadingComments":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":null,"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"type":"ThrowStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Invalid attempt to destructure non-iterable instance","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-tagged-template-literal-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-tagged-template-literal":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"freeze","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"freeze","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-temporal-assert-defined":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"val","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"name","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"undef","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"val","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undef","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"ReferenceError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"name","type":"Identifier","end":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is not defined - temporal dead zone","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-temporal-undefined":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null,"parenthesizedExpression":true},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-to-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-to-consumable-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-typeof":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"constructor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"value":"symbol","raw":null,"type":"Literal","end":null},"alternate":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"let-scoping-return":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"RETURN","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"object","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"RETURN","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"v","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"named-function":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"GET_OUTER_ID","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"property-method-assignment-wrapper-generator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"generator":true,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"delegate":true,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"YieldExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"property-method-assignment-wrapper":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"prototype-identifier":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"CLASS_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"require-assign-key":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"VARIABLE_NAME","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"require","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null}],"type":"Program","end":null},"require":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"require","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"rest":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LEN","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ARRAY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"ARRAY_LEN","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"START","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"operator":"<","right":{"start":null,"loc":null,"range":null,"name":"LEN","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARRAY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARRAY_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"self-contained-helpers-head":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"HELPER","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"system":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"System","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"register","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"MODULE_DEPENDENCIES","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"EXPORT_IDENTIFIER","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"setters","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"SETTERS","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"execute","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"EXECUTE","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"tail-call-body":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"AGAIN_ID","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"body":{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"AGAIN_ID","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"BLOCK","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"WhileStatement","end":null,"_paths":null},"label":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"LabeledStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null}],"type":"Program","end":null},"test-exports":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"test-module":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"module","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"umd-commonjs-strict":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"root","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"amd","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"AMD_ARGUMENTS","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"object","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"COMMON_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"BROWSER_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"UMD_ROOT","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FACTORY_PARAMETERS","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"FACTORY_BODY","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"umd-runner-body":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"amd","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"AMD_ARGUMENTS","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"COMMON_TEST","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"COMMON_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"BROWSER_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"GLOBAL_ARG","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null}}
  72076. },{}]},{},[19])(19)
  72077. });