pretty-print-worker.js 202 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904
  1. var Debugger =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId])
  11. /******/ return installedModules[moduleId].exports;
  12. /******/
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ exports: {},
  16. /******/ id: moduleId,
  17. /******/ loaded: false
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.loaded = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // __webpack_public_path__
  38. /******/ __webpack_require__.p = "/public/build";
  39. /******/
  40. /******/ // Load entry module and return exports
  41. /******/ return __webpack_require__(0);
  42. /******/ })
  43. /************************************************************************/
  44. /******/ ({
  45. /***/ 0:
  46. /***/ function(module, exports, __webpack_require__) {
  47. var prettyFast = __webpack_require__(460);
  48. var assert = __webpack_require__(247);
  49. function prettyPrint(_ref) {
  50. var url = _ref.url;
  51. var indent = _ref.indent;
  52. var source = _ref.source;
  53. try {
  54. var prettified = prettyFast(source, {
  55. url: url,
  56. indent: " ".repeat(indent)
  57. });
  58. return {
  59. code: prettified.code,
  60. mappings: prettified.map._mappings
  61. };
  62. } catch (e) {
  63. return new Error(e.message + "\n" + e.stack);
  64. }
  65. }
  66. function invertMappings(mappings) {
  67. return mappings._array.map(m => {
  68. var mapping = {
  69. generated: {
  70. line: m.originalLine,
  71. column: m.originalColumn
  72. }
  73. };
  74. if (m.source) {
  75. mapping.source = m.source;
  76. mapping.original = {
  77. line: m.generatedLine,
  78. column: m.generatedColumn
  79. };
  80. mapping.name = m.name;
  81. }
  82. return mapping;
  83. });
  84. }
  85. self.onmessage = function (msg) {
  86. var _msg$data = msg.data;
  87. var id = _msg$data.id;
  88. var args = _msg$data.args;
  89. assert(msg.data.method === "prettyPrint", "Method must be `prettyPrint`");
  90. try {
  91. var _prettyPrint = prettyPrint(args[0]);
  92. var code = _prettyPrint.code;
  93. var mappings = _prettyPrint.mappings;
  94. self.postMessage({ id, response: {
  95. code, mappings: invertMappings(mappings)
  96. } });
  97. } catch (e) {
  98. self.postMessage({ id, error: e });
  99. }
  100. };
  101. /***/ },
  102. /***/ 247:
  103. /***/ function(module, exports) {
  104. function assert(condition, message) {
  105. if (!condition) {
  106. throw new Error("Assertion failure: " + message);
  107. }
  108. }
  109. module.exports = assert;
  110. /***/ },
  111. /***/ 460:
  112. /***/ function(module, exports, __webpack_require__) {
  113. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/* -*- indent-tabs-mode: nil; js-indent-level: 2; fill-column: 80 -*- */
  114. /*
  115. * Copyright 2013 Mozilla Foundation and contributors
  116. * Licensed under the New BSD license. See LICENSE.md or:
  117. * http://opensource.org/licenses/BSD-2-Clause
  118. */
  119. (function (root, factory) {
  120. "use strict";
  121. if (true) {
  122. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  123. } else if (typeof exports === "object") {
  124. module.exports = factory();
  125. } else {
  126. root.prettyFast = factory();
  127. }
  128. }(this, function () {
  129. "use strict";
  130. var acorn = this.acorn || __webpack_require__(461);
  131. var sourceMap = this.sourceMap || __webpack_require__(462);
  132. var SourceNode = sourceMap.SourceNode;
  133. // If any of these tokens are seen before a "[" token, we know that "[" token
  134. // is the start of an array literal, rather than a property access.
  135. //
  136. // The only exception is "}", which would need to be disambiguated by
  137. // parsing. The majority of the time, an open bracket following a closing
  138. // curly is going to be an array literal, so we brush the complication under
  139. // the rug, and handle the ambiguity by always assuming that it will be an
  140. // array literal.
  141. var PRE_ARRAY_LITERAL_TOKENS = {
  142. "typeof": true,
  143. "void": true,
  144. "delete": true,
  145. "case": true,
  146. "do": true,
  147. "=": true,
  148. "in": true,
  149. "{": true,
  150. "*": true,
  151. "/": true,
  152. "%": true,
  153. "else": true,
  154. ";": true,
  155. "++": true,
  156. "--": true,
  157. "+": true,
  158. "-": true,
  159. "~": true,
  160. "!": true,
  161. ":": true,
  162. "?": true,
  163. ">>": true,
  164. ">>>": true,
  165. "<<": true,
  166. "||": true,
  167. "&&": true,
  168. "<": true,
  169. ">": true,
  170. "<=": true,
  171. ">=": true,
  172. "instanceof": true,
  173. "&": true,
  174. "^": true,
  175. "|": true,
  176. "==": true,
  177. "!=": true,
  178. "===": true,
  179. "!==": true,
  180. ",": true,
  181. "}": true
  182. };
  183. /**
  184. * Determines if we think that the given token starts an array literal.
  185. *
  186. * @param Object token
  187. * The token we want to determine if it is an array literal.
  188. * @param Object lastToken
  189. * The last token we added to the pretty printed results.
  190. *
  191. * @returns Boolean
  192. * True if we believe it is an array literal, false otherwise.
  193. */
  194. function isArrayLiteral(token, lastToken) {
  195. if (token.type.type != "[") {
  196. return false;
  197. }
  198. if (!lastToken) {
  199. return true;
  200. }
  201. if (lastToken.type.isAssign) {
  202. return true;
  203. }
  204. return !!PRE_ARRAY_LITERAL_TOKENS[
  205. lastToken.type.keyword || lastToken.type.type
  206. ];
  207. }
  208. // If any of these tokens are followed by a token on a new line, we know that
  209. // ASI cannot happen.
  210. var PREVENT_ASI_AFTER_TOKENS = {
  211. // Binary operators
  212. "*": true,
  213. "/": true,
  214. "%": true,
  215. "+": true,
  216. "-": true,
  217. "<<": true,
  218. ">>": true,
  219. ">>>": true,
  220. "<": true,
  221. ">": true,
  222. "<=": true,
  223. ">=": true,
  224. "instanceof": true,
  225. "in": true,
  226. "==": true,
  227. "!=": true,
  228. "===": true,
  229. "!==": true,
  230. "&": true,
  231. "^": true,
  232. "|": true,
  233. "&&": true,
  234. "||": true,
  235. ",": true,
  236. ".": true,
  237. "=": true,
  238. "*=": true,
  239. "/=": true,
  240. "%=": true,
  241. "+=": true,
  242. "-=": true,
  243. "<<=": true,
  244. ">>=": true,
  245. ">>>=": true,
  246. "&=": true,
  247. "^=": true,
  248. "|=": true,
  249. // Unary operators
  250. "delete": true,
  251. "void": true,
  252. "typeof": true,
  253. "~": true,
  254. "!": true,
  255. "new": true,
  256. // Function calls and grouped expressions
  257. "(": true
  258. };
  259. // If any of these tokens are on a line after the token before it, we know
  260. // that ASI cannot happen.
  261. var PREVENT_ASI_BEFORE_TOKENS = {
  262. // Binary operators
  263. "*": true,
  264. "/": true,
  265. "%": true,
  266. "<<": true,
  267. ">>": true,
  268. ">>>": true,
  269. "<": true,
  270. ">": true,
  271. "<=": true,
  272. ">=": true,
  273. "instanceof": true,
  274. "in": true,
  275. "==": true,
  276. "!=": true,
  277. "===": true,
  278. "!==": true,
  279. "&": true,
  280. "^": true,
  281. "|": true,
  282. "&&": true,
  283. "||": true,
  284. ",": true,
  285. ".": true,
  286. "=": true,
  287. "*=": true,
  288. "/=": true,
  289. "%=": true,
  290. "+=": true,
  291. "-=": true,
  292. "<<=": true,
  293. ">>=": true,
  294. ">>>=": true,
  295. "&=": true,
  296. "^=": true,
  297. "|=": true,
  298. // Function calls
  299. "(": true
  300. };
  301. /**
  302. * Determines if Automatic Semicolon Insertion (ASI) occurs between these
  303. * tokens.
  304. *
  305. * @param Object token
  306. * The current token.
  307. * @param Object lastToken
  308. * The last token we added to the pretty printed results.
  309. *
  310. * @returns Boolean
  311. * True if we believe ASI occurs.
  312. */
  313. function isASI(token, lastToken) {
  314. if (!lastToken) {
  315. return false;
  316. }
  317. if (token.startLoc.line === lastToken.startLoc.line) {
  318. return false;
  319. }
  320. if (PREVENT_ASI_AFTER_TOKENS[
  321. lastToken.type.type || lastToken.type.keyword
  322. ]) {
  323. return false;
  324. }
  325. if (PREVENT_ASI_BEFORE_TOKENS[token.type.type || token.type.keyword]) {
  326. return false;
  327. }
  328. return true;
  329. }
  330. /**
  331. * Determine if we have encountered a getter or setter.
  332. *
  333. * @param Object token
  334. * The current token. If this is a getter or setter, it would be the
  335. * property name.
  336. * @param Object lastToken
  337. * The last token we added to the pretty printed results. If this is a
  338. * getter or setter, it would be the `get` or `set` keyword
  339. * respectively.
  340. * @param Array stack
  341. * The stack of open parens/curlies/brackets/etc.
  342. *
  343. * @returns Boolean
  344. * True if this is a getter or setter.
  345. */
  346. function isGetterOrSetter(token, lastToken, stack) {
  347. return stack[stack.length - 1] == "{"
  348. && lastToken
  349. && lastToken.type.type == "name"
  350. && (lastToken.value == "get" || lastToken.value == "set")
  351. && token.type.type == "name";
  352. }
  353. /**
  354. * Determine if we should add a newline after the given token.
  355. *
  356. * @param Object token
  357. * The token we are looking at.
  358. * @param Array stack
  359. * The stack of open parens/curlies/brackets/etc.
  360. *
  361. * @returns Boolean
  362. * True if we should add a newline.
  363. */
  364. function isLineDelimiter(token, stack) {
  365. if (token.isArrayLiteral) {
  366. return true;
  367. }
  368. var ttt = token.type.type;
  369. var top = stack[stack.length - 1];
  370. return ttt == ";" && top != "("
  371. || ttt == "{"
  372. || ttt == "," && top != "("
  373. || ttt == ":" && (top == "case" || top == "default");
  374. }
  375. /**
  376. * Append the necessary whitespace to the result after we have added the given
  377. * token.
  378. *
  379. * @param Object token
  380. * The token that was just added to the result.
  381. * @param Function write
  382. * The function to write to the pretty printed results.
  383. * @param Array stack
  384. * The stack of open parens/curlies/brackets/etc.
  385. *
  386. * @returns Boolean
  387. * Returns true if we added a newline to result, false in all other
  388. * cases.
  389. */
  390. function appendNewline(token, write, stack) {
  391. if (isLineDelimiter(token, stack)) {
  392. write("\n", token.startLoc.line, token.startLoc.column);
  393. return true;
  394. }
  395. return false;
  396. }
  397. /**
  398. * Determines if we need to add a space between the last token we added and
  399. * the token we are about to add.
  400. *
  401. * @param Object token
  402. * The token we are about to add to the pretty printed code.
  403. * @param Object lastToken
  404. * The last token added to the pretty printed code.
  405. */
  406. function needsSpaceAfter(token, lastToken) {
  407. if (lastToken) {
  408. if (lastToken.type.isLoop) {
  409. return true;
  410. }
  411. if (lastToken.type.isAssign) {
  412. return true;
  413. }
  414. if (lastToken.type.binop != null) {
  415. return true;
  416. }
  417. var ltt = lastToken.type.type;
  418. if (ltt == "?") {
  419. return true;
  420. }
  421. if (ltt == ":") {
  422. return true;
  423. }
  424. if (ltt == ",") {
  425. return true;
  426. }
  427. if (ltt == ";") {
  428. return true;
  429. }
  430. var ltk = lastToken.type.keyword;
  431. if (ltk != null) {
  432. if (ltk == "break" || ltk == "continue" || ltk == "return") {
  433. return token.type.type != ";";
  434. }
  435. if (ltk != "debugger"
  436. && ltk != "null"
  437. && ltk != "true"
  438. && ltk != "false"
  439. && ltk != "this"
  440. && ltk != "default") {
  441. return true;
  442. }
  443. }
  444. if (ltt == ")" && (token.type.type != ")"
  445. && token.type.type != "]"
  446. && token.type.type != ";"
  447. && token.type.type != ","
  448. && token.type.type != ".")) {
  449. return true;
  450. }
  451. }
  452. if (token.type.isAssign) {
  453. return true;
  454. }
  455. if (token.type.binop != null) {
  456. return true;
  457. }
  458. if (token.type.type == "?") {
  459. return true;
  460. }
  461. return false;
  462. }
  463. /**
  464. * Add the required whitespace before this token, whether that is a single
  465. * space, newline, and/or the indent on fresh lines.
  466. *
  467. * @param Object token
  468. * The token we are about to add to the pretty printed code.
  469. * @param Object lastToken
  470. * The last token we added to the pretty printed code.
  471. * @param Boolean addedNewline
  472. * Whether we added a newline after adding the last token to the pretty
  473. * printed code.
  474. * @param Function write
  475. * The function to write pretty printed code to the result SourceNode.
  476. * @param Object options
  477. * The options object.
  478. * @param Number indentLevel
  479. * The number of indents deep we are.
  480. * @param Array stack
  481. * The stack of open curlies, brackets, etc.
  482. */
  483. function prependWhiteSpace(token, lastToken, addedNewline, write, options,
  484. indentLevel, stack) {
  485. var ttk = token.type.keyword;
  486. var ttt = token.type.type;
  487. var newlineAdded = addedNewline;
  488. var ltt = lastToken ? lastToken.type.type : null;
  489. // Handle whitespace and newlines after "}" here instead of in
  490. // `isLineDelimiter` because it is only a line delimiter some of the
  491. // time. For example, we don't want to put "else if" on a new line after
  492. // the first if's block.
  493. if (lastToken && ltt == "}") {
  494. if (ttk == "while" && stack[stack.length - 1] == "do") {
  495. write(" ",
  496. lastToken.startLoc.line,
  497. lastToken.startLoc.column);
  498. } else if (ttk == "else" ||
  499. ttk == "catch" ||
  500. ttk == "finally") {
  501. write(" ",
  502. lastToken.startLoc.line,
  503. lastToken.startLoc.column);
  504. } else if (ttt != "(" &&
  505. ttt != ";" &&
  506. ttt != "," &&
  507. ttt != ")" &&
  508. ttt != ".") {
  509. write("\n",
  510. lastToken.startLoc.line,
  511. lastToken.startLoc.column);
  512. newlineAdded = true;
  513. }
  514. }
  515. if (isGetterOrSetter(token, lastToken, stack)) {
  516. write(" ",
  517. lastToken.startLoc.line,
  518. lastToken.startLoc.column);
  519. }
  520. if (ttt == ":" && stack[stack.length - 1] == "?") {
  521. write(" ",
  522. lastToken.startLoc.line,
  523. lastToken.startLoc.column);
  524. }
  525. if (lastToken && ltt != "}" && ttk == "else") {
  526. write(" ",
  527. lastToken.startLoc.line,
  528. lastToken.startLoc.column);
  529. }
  530. function ensureNewline() {
  531. if (!newlineAdded) {
  532. write("\n",
  533. lastToken.startLoc.line,
  534. lastToken.startLoc.column);
  535. newlineAdded = true;
  536. }
  537. }
  538. if (isASI(token, lastToken)) {
  539. ensureNewline();
  540. }
  541. if (decrementsIndent(ttt, stack)) {
  542. ensureNewline();
  543. }
  544. if (newlineAdded) {
  545. if (ttk == "case" || ttk == "default") {
  546. write(repeat(options.indent, indentLevel - 1),
  547. token.startLoc.line,
  548. token.startLoc.column);
  549. } else {
  550. write(repeat(options.indent, indentLevel),
  551. token.startLoc.line,
  552. token.startLoc.column);
  553. }
  554. } else if (needsSpaceAfter(token, lastToken)) {
  555. write(" ",
  556. lastToken.startLoc.line,
  557. lastToken.startLoc.column);
  558. }
  559. }
  560. /**
  561. * Repeat the `str` string `n` times.
  562. *
  563. * @param String str
  564. * The string to be repeated.
  565. * @param Number n
  566. * The number of times to repeat the string.
  567. *
  568. * @returns String
  569. * The repeated string.
  570. */
  571. function repeat(str, n) {
  572. var result = "";
  573. while (n > 0) {
  574. if (n & 1) {
  575. result += str;
  576. }
  577. n >>= 1;
  578. str += str;
  579. }
  580. return result;
  581. }
  582. /**
  583. * Make sure that we output the escaped character combination inside string
  584. * literals instead of various problematic characters.
  585. */
  586. var sanitize = (function () {
  587. var escapeCharacters = {
  588. // Backslash
  589. "\\": "\\\\",
  590. // Newlines
  591. "\n": "\\n",
  592. // Carriage return
  593. "\r": "\\r",
  594. // Tab
  595. "\t": "\\t",
  596. // Vertical tab
  597. "\v": "\\v",
  598. // Form feed
  599. "\f": "\\f",
  600. // Null character
  601. "\0": "\\0",
  602. // Single quotes
  603. "'": "\\'"
  604. };
  605. var regExpString = "("
  606. + Object.keys(escapeCharacters)
  607. .map(function (c) { return escapeCharacters[c]; })
  608. .join("|")
  609. + ")";
  610. var escapeCharactersRegExp = new RegExp(regExpString, "g");
  611. return function (str) {
  612. return str.replace(escapeCharactersRegExp, function (_, c) {
  613. return escapeCharacters[c];
  614. });
  615. };
  616. }());
  617. /**
  618. * Add the given token to the pretty printed results.
  619. *
  620. * @param Object token
  621. * The token to add.
  622. * @param Function write
  623. * The function to write pretty printed code to the result SourceNode.
  624. */
  625. function addToken(token, write) {
  626. if (token.type.type == "string") {
  627. write("'" + sanitize(token.value) + "'",
  628. token.startLoc.line,
  629. token.startLoc.column);
  630. } else if (token.type.type == "regexp") {
  631. write(String(token.value.value),
  632. token.startLoc.line,
  633. token.startLoc.column);
  634. } else {
  635. write(String(token.value != null ? token.value : token.type.type),
  636. token.startLoc.line,
  637. token.startLoc.column);
  638. }
  639. }
  640. /**
  641. * Returns true if the given token type belongs on the stack.
  642. */
  643. function belongsOnStack(token) {
  644. var ttt = token.type.type;
  645. var ttk = token.type.keyword;
  646. return ttt == "{"
  647. || ttt == "("
  648. || ttt == "["
  649. || ttt == "?"
  650. || ttk == "do"
  651. || ttk == "switch"
  652. || ttk == "case"
  653. || ttk == "default";
  654. }
  655. /**
  656. * Returns true if the given token should cause us to pop the stack.
  657. */
  658. function shouldStackPop(token, stack) {
  659. var ttt = token.type.type;
  660. var ttk = token.type.keyword;
  661. var top = stack[stack.length - 1];
  662. return ttt == "]"
  663. || ttt == ")"
  664. || ttt == "}"
  665. || (ttt == ":" && (top == "case" || top == "default" || top == "?"))
  666. || (ttk == "while" && top == "do");
  667. }
  668. /**
  669. * Returns true if the given token type should cause us to decrement the
  670. * indent level.
  671. */
  672. function decrementsIndent(tokenType, stack) {
  673. return tokenType == "}"
  674. || (tokenType == "]" && stack[stack.length - 1] == "[\n");
  675. }
  676. /**
  677. * Returns true if the given token should cause us to increment the indent
  678. * level.
  679. */
  680. function incrementsIndent(token) {
  681. return token.type.type == "{"
  682. || token.isArrayLiteral
  683. || token.type.keyword == "switch";
  684. }
  685. /**
  686. * Add a comment to the pretty printed code.
  687. *
  688. * @param Function write
  689. * The function to write pretty printed code to the result SourceNode.
  690. * @param Number indentLevel
  691. * The number of indents deep we are.
  692. * @param Object options
  693. * The options object.
  694. * @param Boolean block
  695. * True if the comment is a multiline block style comment.
  696. * @param String text
  697. * The text of the comment.
  698. * @param Number line
  699. * The line number to comment appeared on.
  700. * @param Number column
  701. * The column number the comment appeared on.
  702. */
  703. function addComment(write, indentLevel, options, block, text, line, column) {
  704. var indentString = repeat(options.indent, indentLevel);
  705. write(indentString, line, column);
  706. if (block) {
  707. write("/*");
  708. write(text
  709. .split(new RegExp("/\n" + indentString + "/", "g"))
  710. .join("\n" + indentString));
  711. write("*/");
  712. } else {
  713. write("//");
  714. write(text);
  715. }
  716. write("\n");
  717. }
  718. /**
  719. * The main function.
  720. *
  721. * @param String input
  722. * The ugly JS code we want to pretty print.
  723. * @param Object options
  724. * The options object. Provides configurability of the pretty
  725. * printing. Properties:
  726. * - url: The URL string of the ugly JS code.
  727. * - indent: The string to indent code by.
  728. *
  729. * @returns Object
  730. * An object with the following properties:
  731. * - code: The pretty printed code string.
  732. * - map: A SourceMapGenerator instance.
  733. */
  734. return function prettyFast(input, options) {
  735. // The level of indents deep we are.
  736. var indentLevel = 0;
  737. // We will accumulate the pretty printed code in this SourceNode.
  738. var result = new SourceNode();
  739. /**
  740. * Write a pretty printed string to the result SourceNode.
  741. *
  742. * We buffer our writes so that we only create one mapping for each line in
  743. * the source map. This enhances performance by avoiding extraneous mapping
  744. * serialization, and flattening the tree that
  745. * `SourceNode#toStringWithSourceMap` will have to recursively walk. When
  746. * timing how long it takes to pretty print jQuery, this optimization
  747. * brought the time down from ~390 ms to ~190ms!
  748. *
  749. * @param String str
  750. * The string to be added to the result.
  751. * @param Number line
  752. * The line number the string came from in the ugly source.
  753. * @param Number column
  754. * The column number the string came from in the ugly source.
  755. */
  756. var write = (function () {
  757. var buffer = [];
  758. var bufferLine = -1;
  759. var bufferColumn = -1;
  760. return function write(str, line, column) {
  761. if (line != null && bufferLine === -1) {
  762. bufferLine = line;
  763. }
  764. if (column != null && bufferColumn === -1) {
  765. bufferColumn = column;
  766. }
  767. buffer.push(str);
  768. if (str == "\n") {
  769. var lineStr = "";
  770. for (var i = 0, len = buffer.length; i < len; i++) {
  771. lineStr += buffer[i];
  772. }
  773. result.add(new SourceNode(bufferLine, bufferColumn, options.url,
  774. lineStr));
  775. buffer.splice(0, buffer.length);
  776. bufferLine = -1;
  777. bufferColumn = -1;
  778. }
  779. };
  780. }());
  781. // Whether or not we added a newline on after we added the last token.
  782. var addedNewline = false;
  783. // The current token we will be adding to the pretty printed code.
  784. var token;
  785. // Shorthand for token.type.type, so we don't have to repeatedly access
  786. // properties.
  787. var ttt;
  788. // Shorthand for token.type.keyword, so we don't have to repeatedly access
  789. // properties.
  790. var ttk;
  791. // The last token we added to the pretty printed code.
  792. var lastToken;
  793. // Stack of token types/keywords that can affect whether we want to add a
  794. // newline or a space. We can make that decision based on what token type is
  795. // on the top of the stack. For example, a comma in a parameter list should
  796. // be followed by a space, while a comma in an object literal should be
  797. // followed by a newline.
  798. //
  799. // Strings that go on the stack:
  800. //
  801. // - "{"
  802. // - "("
  803. // - "["
  804. // - "[\n"
  805. // - "do"
  806. // - "?"
  807. // - "switch"
  808. // - "case"
  809. // - "default"
  810. //
  811. // The difference between "[" and "[\n" is that "[\n" is used when we are
  812. // treating "[" and "]" tokens as line delimiters and should increment and
  813. // decrement the indent level when we find them.
  814. var stack = [];
  815. // Acorn's tokenizer will always yield comments *before* the token they
  816. // follow (unless the very first thing in the source is a comment), so we
  817. // have to queue the comments in order to pretty print them in the correct
  818. // location. For example, the source file:
  819. //
  820. // foo
  821. // // a
  822. // // b
  823. // bar
  824. //
  825. // When tokenized by acorn, gives us the following token stream:
  826. //
  827. // [ '// a', '// b', foo, bar ]
  828. var commentQueue = [];
  829. var getToken = acorn.tokenize(input, {
  830. locations: true,
  831. sourceFile: options.url,
  832. onComment: function (block, text, start, end, startLoc, endLoc) {
  833. if (lastToken) {
  834. commentQueue.push({
  835. block: block,
  836. text: text,
  837. line: startLoc.line,
  838. column: startLoc.column,
  839. trailing: lastToken.endLoc.line == startLoc.line
  840. });
  841. } else {
  842. addComment(write, indentLevel, options, block, text, startLoc.line,
  843. startLoc.column);
  844. addedNewline = true;
  845. }
  846. }
  847. });
  848. for (;;) {
  849. token = getToken();
  850. ttk = token.type.keyword;
  851. ttt = token.type.type;
  852. if (ttt == "eof") {
  853. if (!addedNewline) {
  854. write("\n");
  855. }
  856. break;
  857. }
  858. token.isArrayLiteral = isArrayLiteral(token, lastToken);
  859. if (belongsOnStack(token)) {
  860. if (token.isArrayLiteral) {
  861. stack.push("[\n");
  862. } else {
  863. stack.push(ttt || ttk);
  864. }
  865. }
  866. if (decrementsIndent(ttt, stack)) {
  867. indentLevel--;
  868. if (ttt == "}"
  869. && stack.length > 1
  870. && stack[stack.length - 2] == "switch") {
  871. indentLevel--;
  872. }
  873. }
  874. prependWhiteSpace(token, lastToken, addedNewline, write, options,
  875. indentLevel, stack);
  876. addToken(token, write);
  877. if (commentQueue.length === 0 || !commentQueue[0].trailing) {
  878. addedNewline = appendNewline(token, write, stack);
  879. }
  880. if (shouldStackPop(token, stack)) {
  881. stack.pop();
  882. if (token == "}" && stack.length
  883. && stack[stack.length - 1] == "switch") {
  884. stack.pop();
  885. }
  886. }
  887. if (incrementsIndent(token)) {
  888. indentLevel++;
  889. }
  890. // Acorn's tokenizer re-uses tokens, so we have to copy the last token on
  891. // every iteration. We follow acorn's lead here, and reuse the lastToken
  892. // object the same way that acorn reuses the token object. This allows us
  893. // to avoid allocations and minimize GC pauses.
  894. if (!lastToken) {
  895. lastToken = { startLoc: {}, endLoc: {} };
  896. }
  897. lastToken.start = token.start;
  898. lastToken.end = token.end;
  899. lastToken.startLoc.line = token.startLoc.line;
  900. lastToken.startLoc.column = token.startLoc.column;
  901. lastToken.endLoc.line = token.endLoc.line;
  902. lastToken.endLoc.column = token.endLoc.column;
  903. lastToken.type = token.type;
  904. lastToken.value = token.value;
  905. lastToken.isArrayLiteral = token.isArrayLiteral;
  906. // Apply all the comments that have been queued up.
  907. if (commentQueue.length) {
  908. if (!addedNewline && !commentQueue[0].trailing) {
  909. write("\n");
  910. }
  911. if (commentQueue[0].trailing) {
  912. write(" ");
  913. }
  914. for (var i = 0, n = commentQueue.length; i < n; i++) {
  915. var comment = commentQueue[i];
  916. var commentIndentLevel = commentQueue[i].trailing ? 0 : indentLevel;
  917. addComment(write, commentIndentLevel, options, comment.block,
  918. comment.text, comment.line, comment.column);
  919. }
  920. addedNewline = true;
  921. commentQueue.splice(0, commentQueue.length);
  922. }
  923. }
  924. return result.toStringWithSourceMap({ file: options.url });
  925. };
  926. }.bind(this)));
  927. /***/ },
  928. /***/ 461:
  929. /***/ function(module, exports, __webpack_require__) {
  930. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Acorn is a tiny, fast JavaScript parser written in JavaScript.
  931. //
  932. // Acorn was written by Marijn Haverbeke and various contributors and
  933. // released under an MIT license. The Unicode regexps (for identifiers
  934. // and whitespace) were taken from [Esprima](http://esprima.org) by
  935. // Ariya Hidayat.
  936. //
  937. // Git repositories for Acorn are available at
  938. //
  939. // http://marijnhaverbeke.nl/git/acorn
  940. // https://github.com/marijnh/acorn.git
  941. //
  942. // Please use the [github bug tracker][ghbt] to report issues.
  943. //
  944. // [ghbt]: https://github.com/marijnh/acorn/issues
  945. //
  946. // This file defines the main parser interface. The library also comes
  947. // with a [error-tolerant parser][dammit] and an
  948. // [abstract syntax tree walker][walk], defined in other files.
  949. //
  950. // [dammit]: acorn_loose.js
  951. // [walk]: util/walk.js
  952. (function(root, mod) {
  953. if (true) return mod(exports); // CommonJS
  954. if (true) return !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (mod), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); // AMD
  955. mod(root.acorn || (root.acorn = {})); // Plain browser env
  956. })(this, function(exports) {
  957. "use strict";
  958. exports.version = "0.11.0";
  959. // The main exported interface (under `self.acorn` when in the
  960. // browser) is a `parse` function that takes a code string and
  961. // returns an abstract syntax tree as specified by [Mozilla parser
  962. // API][api], with the caveat that inline XML is not recognized.
  963. //
  964. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  965. var options, input, inputLen, sourceFile;
  966. exports.parse = function(inpt, opts) {
  967. input = String(inpt); inputLen = input.length;
  968. setOptions(opts);
  969. initTokenState();
  970. var startPos = options.locations ? [tokPos, curPosition()] : tokPos;
  971. initParserState();
  972. return parseTopLevel(options.program || startNodeAt(startPos));
  973. };
  974. // A second optional argument can be given to further configure
  975. // the parser process. These options are recognized:
  976. var defaultOptions = exports.defaultOptions = {
  977. // `ecmaVersion` indicates the ECMAScript version to parse. Must
  978. // be either 3, or 5, or 6. This influences support for strict
  979. // mode, the set of reserved words, support for getters and
  980. // setters and other features.
  981. ecmaVersion: 5,
  982. // Turn on `strictSemicolons` to prevent the parser from doing
  983. // automatic semicolon insertion.
  984. strictSemicolons: false,
  985. // When `allowTrailingCommas` is false, the parser will not allow
  986. // trailing commas in array and object literals.
  987. allowTrailingCommas: true,
  988. // By default, reserved words are not enforced. Enable
  989. // `forbidReserved` to enforce them. When this option has the
  990. // value "everywhere", reserved words and keywords can also not be
  991. // used as property names.
  992. forbidReserved: false,
  993. // When enabled, a return at the top level is not considered an
  994. // error.
  995. allowReturnOutsideFunction: false,
  996. // When enabled, import/export statements are not constrained to
  997. // appearing at the top of the program.
  998. allowImportExportEverywhere: false,
  999. // When `locations` is on, `loc` properties holding objects with
  1000. // `start` and `end` properties in `{line, column}` form (with
  1001. // line being 1-based and column 0-based) will be attached to the
  1002. // nodes.
  1003. locations: false,
  1004. // A function can be passed as `onToken` option, which will
  1005. // cause Acorn to call that function with object in the same
  1006. // format as tokenize() returns. Note that you are not
  1007. // allowed to call the parser from the callback—that will
  1008. // corrupt its internal state.
  1009. onToken: null,
  1010. // A function can be passed as `onComment` option, which will
  1011. // cause Acorn to call that function with `(block, text, start,
  1012. // end)` parameters whenever a comment is skipped. `block` is a
  1013. // boolean indicating whether this is a block (`/* */`) comment,
  1014. // `text` is the content of the comment, and `start` and `end` are
  1015. // character offsets that denote the start and end of the comment.
  1016. // When the `locations` option is on, two more parameters are
  1017. // passed, the full `{line, column}` locations of the start and
  1018. // end of the comments. Note that you are not allowed to call the
  1019. // parser from the callback—that will corrupt its internal state.
  1020. onComment: null,
  1021. // Nodes have their start and end characters offsets recorded in
  1022. // `start` and `end` properties (directly on the node, rather than
  1023. // the `loc` object, which holds line/column data. To also add a
  1024. // [semi-standardized][range] `range` property holding a `[start,
  1025. // end]` array with the same numbers, set the `ranges` option to
  1026. // `true`.
  1027. //
  1028. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  1029. ranges: false,
  1030. // It is possible to parse multiple files into a single AST by
  1031. // passing the tree produced by parsing the first file as
  1032. // `program` option in subsequent parses. This will add the
  1033. // toplevel forms of the parsed file to the `Program` (top) node
  1034. // of an existing parse tree.
  1035. program: null,
  1036. // When `locations` is on, you can pass this to record the source
  1037. // file in every node's `loc` object.
  1038. sourceFile: null,
  1039. // This value, if given, is stored in every node, whether
  1040. // `locations` is on or off.
  1041. directSourceFile: null,
  1042. // When enabled, parenthesized expressions are represented by
  1043. // (non-standard) ParenthesizedExpression nodes
  1044. preserveParens: false
  1045. };
  1046. // This function tries to parse a single expression at a given
  1047. // offset in a string. Useful for parsing mixed-language formats
  1048. // that embed JavaScript expressions.
  1049. exports.parseExpressionAt = function(inpt, pos, opts) {
  1050. input = String(inpt); inputLen = input.length;
  1051. setOptions(opts);
  1052. initTokenState(pos);
  1053. initParserState();
  1054. return parseExpression();
  1055. };
  1056. var isArray = function (obj) {
  1057. return Object.prototype.toString.call(obj) === "[object Array]";
  1058. };
  1059. function setOptions(opts) {
  1060. options = {};
  1061. for (var opt in defaultOptions)
  1062. options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
  1063. sourceFile = options.sourceFile || null;
  1064. if (isArray(options.onToken)) {
  1065. var tokens = options.onToken;
  1066. options.onToken = function (token) {
  1067. tokens.push(token);
  1068. };
  1069. }
  1070. if (isArray(options.onComment)) {
  1071. var comments = options.onComment;
  1072. options.onComment = function (block, text, start, end, startLoc, endLoc) {
  1073. var comment = {
  1074. type: block ? 'Block' : 'Line',
  1075. value: text,
  1076. start: start,
  1077. end: end
  1078. };
  1079. if (options.locations) {
  1080. comment.loc = new SourceLocation();
  1081. comment.loc.start = startLoc;
  1082. comment.loc.end = endLoc;
  1083. }
  1084. if (options.ranges)
  1085. comment.range = [start, end];
  1086. comments.push(comment);
  1087. };
  1088. }
  1089. isKeyword = options.ecmaVersion >= 6 ? isEcma6Keyword : isEcma5AndLessKeyword;
  1090. }
  1091. // The `getLineInfo` function is mostly useful when the
  1092. // `locations` option is off (for performance reasons) and you
  1093. // want to find the line/column position for a given character
  1094. // offset. `input` should be the code string that the offset refers
  1095. // into.
  1096. var getLineInfo = exports.getLineInfo = function(input, offset) {
  1097. for (var line = 1, cur = 0;;) {
  1098. lineBreak.lastIndex = cur;
  1099. var match = lineBreak.exec(input);
  1100. if (match && match.index < offset) {
  1101. ++line;
  1102. cur = match.index + match[0].length;
  1103. } else break;
  1104. }
  1105. return {line: line, column: offset - cur};
  1106. };
  1107. function Token() {
  1108. this.type = tokType;
  1109. this.value = tokVal;
  1110. this.start = tokStart;
  1111. this.end = tokEnd;
  1112. if (options.locations) {
  1113. this.loc = new SourceLocation();
  1114. this.loc.end = tokEndLoc;
  1115. // TODO: remove in next major release
  1116. this.startLoc = tokStartLoc;
  1117. this.endLoc = tokEndLoc;
  1118. }
  1119. if (options.ranges)
  1120. this.range = [tokStart, tokEnd];
  1121. }
  1122. exports.Token = Token;
  1123. // Acorn is organized as a tokenizer and a recursive-descent parser.
  1124. // The `tokenize` export provides an interface to the tokenizer.
  1125. // Because the tokenizer is optimized for being efficiently used by
  1126. // the Acorn parser itself, this interface is somewhat crude and not
  1127. // very modular. Performing another parse or call to `tokenize` will
  1128. // reset the internal state, and invalidate existing tokenizers.
  1129. exports.tokenize = function(inpt, opts) {
  1130. input = String(inpt); inputLen = input.length;
  1131. setOptions(opts);
  1132. initTokenState();
  1133. skipSpace();
  1134. function getToken(forceRegexp) {
  1135. lastEnd = tokEnd;
  1136. readToken(forceRegexp);
  1137. return new Token();
  1138. }
  1139. getToken.jumpTo = function(pos, reAllowed) {
  1140. tokPos = pos;
  1141. if (options.locations) {
  1142. tokCurLine = 1;
  1143. tokLineStart = lineBreak.lastIndex = 0;
  1144. var match;
  1145. while ((match = lineBreak.exec(input)) && match.index < pos) {
  1146. ++tokCurLine;
  1147. tokLineStart = match.index + match[0].length;
  1148. }
  1149. }
  1150. tokRegexpAllowed = reAllowed;
  1151. skipSpace();
  1152. };
  1153. getToken.noRegexp = function() {
  1154. tokRegexpAllowed = false;
  1155. };
  1156. getToken.options = options;
  1157. return getToken;
  1158. };
  1159. // State is kept in (closure-)global variables. We already saw the
  1160. // `options`, `input`, and `inputLen` variables above.
  1161. // The current position of the tokenizer in the input.
  1162. var tokPos;
  1163. // The start and end offsets of the current token.
  1164. var tokStart, tokEnd;
  1165. // When `options.locations` is true, these hold objects
  1166. // containing the tokens start and end line/column pairs.
  1167. var tokStartLoc, tokEndLoc;
  1168. // The type and value of the current token. Token types are objects,
  1169. // named by variables against which they can be compared, and
  1170. // holding properties that describe them (indicating, for example,
  1171. // the precedence of an infix operator, and the original name of a
  1172. // keyword token). The kind of value that's held in `tokVal` depends
  1173. // on the type of the token. For literals, it is the literal value,
  1174. // for operators, the operator name, and so on.
  1175. var tokType, tokVal;
  1176. // Internal state for the tokenizer. To distinguish between division
  1177. // operators and regular expressions, it remembers whether the last
  1178. // token was one that is allowed to be followed by an expression.
  1179. // (If it is, a slash is probably a regexp, if it isn't it's a
  1180. // division operator. See the `parseStatement` function for a
  1181. // caveat.)
  1182. var tokRegexpAllowed;
  1183. // When `options.locations` is true, these are used to keep
  1184. // track of the current line, and know when a new line has been
  1185. // entered.
  1186. var tokCurLine, tokLineStart;
  1187. // These store the position of the previous token, which is useful
  1188. // when finishing a node and assigning its `end` position.
  1189. var lastStart, lastEnd, lastEndLoc;
  1190. // This is the parser's state. `inFunction` is used to reject
  1191. // `return` statements outside of functions, `inGenerator` to
  1192. // reject `yield`s outside of generators, `labels` to verify
  1193. // that `break` and `continue` have somewhere to jump to, and
  1194. // `strict` indicates whether strict mode is on.
  1195. var inFunction, inGenerator, labels, strict;
  1196. // This counter is used for checking that arrow expressions did
  1197. // not contain nested parentheses in argument list.
  1198. var metParenL;
  1199. // This is used by the tokenizer to track the template strings it is
  1200. // inside, and count the amount of open braces seen inside them, to
  1201. // be able to switch back to a template token when the } to match ${
  1202. // is encountered. It will hold an array of integers.
  1203. var templates;
  1204. function initParserState() {
  1205. lastStart = lastEnd = tokPos;
  1206. if (options.locations) lastEndLoc = curPosition();
  1207. inFunction = inGenerator = strict = false;
  1208. labels = [];
  1209. skipSpace();
  1210. readToken();
  1211. }
  1212. // This function is used to raise exceptions on parse errors. It
  1213. // takes an offset integer (into the current `input`) to indicate
  1214. // the location of the error, attaches the position to the end
  1215. // of the error message, and then raises a `SyntaxError` with that
  1216. // message.
  1217. function raise(pos, message) {
  1218. var loc = getLineInfo(input, pos);
  1219. message += " (" + loc.line + ":" + loc.column + ")";
  1220. var err = new SyntaxError(message);
  1221. err.pos = pos; err.loc = loc; err.raisedAt = tokPos;
  1222. throw err;
  1223. }
  1224. // Reused empty array added for node fields that are always empty.
  1225. var empty = [];
  1226. // ## Token types
  1227. // The assignment of fine-grained, information-carrying type objects
  1228. // allows the tokenizer to store the information it has about a
  1229. // token in a way that is very cheap for the parser to look up.
  1230. // All token type variables start with an underscore, to make them
  1231. // easy to recognize.
  1232. // These are the general types. The `type` property is only used to
  1233. // make them recognizeable when debugging.
  1234. var _num = {type: "num"}, _regexp = {type: "regexp"}, _string = {type: "string"};
  1235. var _name = {type: "name"}, _eof = {type: "eof"};
  1236. // Keyword tokens. The `keyword` property (also used in keyword-like
  1237. // operators) indicates that the token originated from an
  1238. // identifier-like word, which is used when parsing property names.
  1239. //
  1240. // The `beforeExpr` property is used to disambiguate between regular
  1241. // expressions and divisions. It is set on all token types that can
  1242. // be followed by an expression (thus, a slash after them would be a
  1243. // regular expression).
  1244. //
  1245. // `isLoop` marks a keyword as starting a loop, which is important
  1246. // to know when parsing a label, in order to allow or disallow
  1247. // continue jumps to that label.
  1248. var _break = {keyword: "break"}, _case = {keyword: "case", beforeExpr: true}, _catch = {keyword: "catch"};
  1249. var _continue = {keyword: "continue"}, _debugger = {keyword: "debugger"}, _default = {keyword: "default"};
  1250. var _do = {keyword: "do", isLoop: true}, _else = {keyword: "else", beforeExpr: true};
  1251. var _finally = {keyword: "finally"}, _for = {keyword: "for", isLoop: true}, _function = {keyword: "function"};
  1252. var _if = {keyword: "if"}, _return = {keyword: "return", beforeExpr: true}, _switch = {keyword: "switch"};
  1253. var _throw = {keyword: "throw", beforeExpr: true}, _try = {keyword: "try"}, _var = {keyword: "var"};
  1254. var _let = {keyword: "let"}, _const = {keyword: "const"};
  1255. var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
  1256. var _this = {keyword: "this"};
  1257. var _class = {keyword: "class"}, _extends = {keyword: "extends", beforeExpr: true};
  1258. var _export = {keyword: "export"}, _import = {keyword: "import"};
  1259. var _yield = {keyword: "yield", beforeExpr: true};
  1260. // The keywords that denote values.
  1261. var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
  1262. var _false = {keyword: "false", atomValue: false};
  1263. // Some keywords are treated as regular operators. `in` sometimes
  1264. // (when parsing `for`) needs to be tested against specifically, so
  1265. // we assign a variable name to it for quick comparing.
  1266. var _in = {keyword: "in", binop: 7, beforeExpr: true};
  1267. // Map keyword names to token types.
  1268. var keywordTypes = {"break": _break, "case": _case, "catch": _catch,
  1269. "continue": _continue, "debugger": _debugger, "default": _default,
  1270. "do": _do, "else": _else, "finally": _finally, "for": _for,
  1271. "function": _function, "if": _if, "return": _return, "switch": _switch,
  1272. "throw": _throw, "try": _try, "var": _var, "let": _let, "const": _const,
  1273. "while": _while, "with": _with,
  1274. "null": _null, "true": _true, "false": _false, "new": _new, "in": _in,
  1275. "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this,
  1276. "typeof": {keyword: "typeof", prefix: true, beforeExpr: true},
  1277. "void": {keyword: "void", prefix: true, beforeExpr: true},
  1278. "delete": {keyword: "delete", prefix: true, beforeExpr: true},
  1279. "class": _class, "extends": _extends,
  1280. "export": _export, "import": _import, "yield": _yield};
  1281. // Punctuation token types. Again, the `type` property is purely for debugging.
  1282. var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
  1283. var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
  1284. var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
  1285. var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};
  1286. var _arrow = {type: "=>", beforeExpr: true}, _template = {type: "template"}, _templateContinued = {type: "templateContinued"};
  1287. var _ellipsis = {type: "...", prefix: true, beforeExpr: true};
  1288. // Operators. These carry several kinds of properties to help the
  1289. // parser use them properly (the presence of these properties is
  1290. // what categorizes them as operators).
  1291. //
  1292. // `binop`, when present, specifies that this operator is a binary
  1293. // operator, and will refer to its precedence.
  1294. //
  1295. // `prefix` and `postfix` mark the operator as a prefix or postfix
  1296. // unary operator. `isUpdate` specifies that the node produced by
  1297. // the operator should be of type UpdateExpression rather than
  1298. // simply UnaryExpression (`++` and `--`).
  1299. //
  1300. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  1301. // binary operators with a very low precedence, that should result
  1302. // in AssignmentExpression nodes.
  1303. var _slash = {binop: 10, beforeExpr: true}, _eq = {isAssign: true, beforeExpr: true};
  1304. var _assign = {isAssign: true, beforeExpr: true};
  1305. var _incDec = {postfix: true, prefix: true, isUpdate: true}, _prefix = {prefix: true, beforeExpr: true};
  1306. var _logicalOR = {binop: 1, beforeExpr: true};
  1307. var _logicalAND = {binop: 2, beforeExpr: true};
  1308. var _bitwiseOR = {binop: 3, beforeExpr: true};
  1309. var _bitwiseXOR = {binop: 4, beforeExpr: true};
  1310. var _bitwiseAND = {binop: 5, beforeExpr: true};
  1311. var _equality = {binop: 6, beforeExpr: true};
  1312. var _relational = {binop: 7, beforeExpr: true};
  1313. var _bitShift = {binop: 8, beforeExpr: true};
  1314. var _plusMin = {binop: 9, prefix: true, beforeExpr: true};
  1315. var _modulo = {binop: 10, beforeExpr: true};
  1316. // '*' may be multiply or have special meaning in ES6
  1317. var _star = {binop: 10, beforeExpr: true};
  1318. // Provide access to the token types for external users of the
  1319. // tokenizer.
  1320. exports.tokTypes = {bracketL: _bracketL, bracketR: _bracketR, braceL: _braceL, braceR: _braceR,
  1321. parenL: _parenL, parenR: _parenR, comma: _comma, semi: _semi, colon: _colon,
  1322. dot: _dot, ellipsis: _ellipsis, question: _question, slash: _slash, eq: _eq,
  1323. name: _name, eof: _eof, num: _num, regexp: _regexp, string: _string,
  1324. arrow: _arrow, template: _template, templateContinued: _templateContinued, star: _star,
  1325. assign: _assign};
  1326. for (var kw in keywordTypes) exports.tokTypes["_" + kw] = keywordTypes[kw];
  1327. // This is a trick taken from Esprima. It turns out that, on
  1328. // non-Chrome browsers, to check whether a string is in a set, a
  1329. // predicate containing a big ugly `switch` statement is faster than
  1330. // a regular expression, and on Chrome the two are about on par.
  1331. // This function uses `eval` (non-lexical) to produce such a
  1332. // predicate from a space-separated string of words.
  1333. //
  1334. // It starts by sorting the words by length.
  1335. function makePredicate(words) {
  1336. words = words.split(" ");
  1337. var f = "", cats = [];
  1338. out: for (var i = 0; i < words.length; ++i) {
  1339. for (var j = 0; j < cats.length; ++j)
  1340. if (cats[j][0].length == words[i].length) {
  1341. cats[j].push(words[i]);
  1342. continue out;
  1343. }
  1344. cats.push([words[i]]);
  1345. }
  1346. function compareTo(arr) {
  1347. if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";";
  1348. f += "switch(str){";
  1349. for (var i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":";
  1350. f += "return true}return false;";
  1351. }
  1352. // When there are more than three length categories, an outer
  1353. // switch first dispatches on the lengths, to save on comparisons.
  1354. if (cats.length > 3) {
  1355. cats.sort(function(a, b) {return b.length - a.length;});
  1356. f += "switch(str.length){";
  1357. for (var i = 0; i < cats.length; ++i) {
  1358. var cat = cats[i];
  1359. f += "case " + cat[0].length + ":";
  1360. compareTo(cat);
  1361. }
  1362. f += "}";
  1363. // Otherwise, simply generate a flat `switch` statement.
  1364. } else {
  1365. compareTo(words);
  1366. }
  1367. return new Function("str", f);
  1368. }
  1369. // The ECMAScript 3 reserved word list.
  1370. var isReservedWord3 = 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");
  1371. // ECMAScript 5 reserved words.
  1372. var isReservedWord5 = makePredicate("class enum extends super const export import");
  1373. // The additional reserved words in strict mode.
  1374. var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");
  1375. // The forbidden variable names in strict mode.
  1376. var isStrictBadIdWord = makePredicate("eval arguments");
  1377. // And the keywords.
  1378. 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";
  1379. var isEcma5AndLessKeyword = makePredicate(ecma5AndLessKeywords);
  1380. var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const class extends export import yield");
  1381. var isKeyword = isEcma5AndLessKeyword;
  1382. // ## Character categories
  1383. // Big ugly regular expressions that match characters in the
  1384. // whitespace, identifier, and identifier-start categories. These
  1385. // are only applied when a character is found to actually have a
  1386. // code point above 128.
  1387. // Generated by `tools/generate-identifier-regex.js`.
  1388. var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  1389. var nonASCIIidentifierStartChars = "\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";
  1390. var nonASCIIidentifierChars = "\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19B0-\u19C0\u19C8\u19C9\u19D0-\u19D9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F1\uA900-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F";
  1391. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  1392. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  1393. // Whether a single character denotes a newline.
  1394. var newline = /[\n\r\u2028\u2029]/;
  1395. function isNewLine(code) {
  1396. return code === 10 || code === 13 || code === 0x2028 || code == 0x2029;
  1397. }
  1398. // Matches a whole line break (where CRLF is considered a single
  1399. // line break). Used to count lines.
  1400. var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;
  1401. // Test whether a given character code starts an identifier.
  1402. var isIdentifierStart = exports.isIdentifierStart = function(code) {
  1403. if (code < 65) return code === 36;
  1404. if (code < 91) return true;
  1405. if (code < 97) return code === 95;
  1406. if (code < 123)return true;
  1407. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  1408. };
  1409. // Test whether a given character is part of an identifier.
  1410. var isIdentifierChar = exports.isIdentifierChar = function(code) {
  1411. if (code < 48) return code === 36;
  1412. if (code < 58) return true;
  1413. if (code < 65) return false;
  1414. if (code < 91) return true;
  1415. if (code < 97) return code === 95;
  1416. if (code < 123)return true;
  1417. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  1418. };
  1419. // ## Tokenizer
  1420. // These are used when `options.locations` is on, for the
  1421. // `tokStartLoc` and `tokEndLoc` properties.
  1422. function Position(line, col) {
  1423. this.line = line;
  1424. this.column = col;
  1425. }
  1426. Position.prototype.offset = function(n) {
  1427. return new Position(this.line, this.column + n);
  1428. }
  1429. function curPosition() {
  1430. return new Position(tokCurLine, tokPos - tokLineStart);
  1431. }
  1432. // Reset the token state. Used at the start of a parse.
  1433. function initTokenState(pos) {
  1434. if (pos) {
  1435. tokPos = pos;
  1436. tokLineStart = Math.max(0, input.lastIndexOf("\n", pos));
  1437. tokCurLine = input.slice(0, tokLineStart).split(newline).length;
  1438. } else {
  1439. tokCurLine = 1;
  1440. tokPos = tokLineStart = 0;
  1441. }
  1442. tokRegexpAllowed = true;
  1443. metParenL = 0;
  1444. templates = [];
  1445. }
  1446. // Called at the end of every token. Sets `tokEnd`, `tokVal`, and
  1447. // `tokRegexpAllowed`, and skips the space after the token, so that
  1448. // the next one's `tokStart` will point at the right position.
  1449. function finishToken(type, val, shouldSkipSpace) {
  1450. tokEnd = tokPos;
  1451. if (options.locations) tokEndLoc = curPosition();
  1452. tokType = type;
  1453. if (shouldSkipSpace !== false) skipSpace();
  1454. tokVal = val;
  1455. tokRegexpAllowed = type.beforeExpr;
  1456. if (options.onToken) {
  1457. options.onToken(new Token());
  1458. }
  1459. }
  1460. function skipBlockComment() {
  1461. var startLoc = options.onComment && options.locations && curPosition();
  1462. var start = tokPos, end = input.indexOf("*/", tokPos += 2);
  1463. if (end === -1) raise(tokPos - 2, "Unterminated comment");
  1464. tokPos = end + 2;
  1465. if (options.locations) {
  1466. lineBreak.lastIndex = start;
  1467. var match;
  1468. while ((match = lineBreak.exec(input)) && match.index < tokPos) {
  1469. ++tokCurLine;
  1470. tokLineStart = match.index + match[0].length;
  1471. }
  1472. }
  1473. if (options.onComment)
  1474. options.onComment(true, input.slice(start + 2, end), start, tokPos,
  1475. startLoc, options.locations && curPosition());
  1476. }
  1477. function skipLineComment(startSkip) {
  1478. var start = tokPos;
  1479. var startLoc = options.onComment && options.locations && curPosition();
  1480. var ch = input.charCodeAt(tokPos+=startSkip);
  1481. while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
  1482. ++tokPos;
  1483. ch = input.charCodeAt(tokPos);
  1484. }
  1485. if (options.onComment)
  1486. options.onComment(false, input.slice(start + startSkip, tokPos), start, tokPos,
  1487. startLoc, options.locations && curPosition());
  1488. }
  1489. // Called at the start of the parse and after every token. Skips
  1490. // whitespace and comments, and.
  1491. function skipSpace() {
  1492. while (tokPos < inputLen) {
  1493. var ch = input.charCodeAt(tokPos);
  1494. if (ch === 32) { // ' '
  1495. ++tokPos;
  1496. } else if (ch === 13) {
  1497. ++tokPos;
  1498. var next = input.charCodeAt(tokPos);
  1499. if (next === 10) {
  1500. ++tokPos;
  1501. }
  1502. if (options.locations) {
  1503. ++tokCurLine;
  1504. tokLineStart = tokPos;
  1505. }
  1506. } else if (ch === 10 || ch === 8232 || ch === 8233) {
  1507. ++tokPos;
  1508. if (options.locations) {
  1509. ++tokCurLine;
  1510. tokLineStart = tokPos;
  1511. }
  1512. } else if (ch > 8 && ch < 14) {
  1513. ++tokPos;
  1514. } else if (ch === 47) { // '/'
  1515. var next = input.charCodeAt(tokPos + 1);
  1516. if (next === 42) { // '*'
  1517. skipBlockComment();
  1518. } else if (next === 47) { // '/'
  1519. skipLineComment(2);
  1520. } else break;
  1521. } else if (ch === 160) { // '\xa0'
  1522. ++tokPos;
  1523. } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  1524. ++tokPos;
  1525. } else {
  1526. break;
  1527. }
  1528. }
  1529. }
  1530. // ### Token reading
  1531. // This is the function that is called to fetch the next token. It
  1532. // is somewhat obscure, because it works in character codes rather
  1533. // than characters, and because operator parsing has been inlined
  1534. // into it.
  1535. //
  1536. // All in the name of speed.
  1537. //
  1538. // The `forceRegexp` parameter is used in the one case where the
  1539. // `tokRegexpAllowed` trick does not work. See `parseStatement`.
  1540. function readToken_dot() {
  1541. var next = input.charCodeAt(tokPos + 1);
  1542. if (next >= 48 && next <= 57) return readNumber(true);
  1543. var next2 = input.charCodeAt(tokPos + 2);
  1544. if (options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
  1545. tokPos += 3;
  1546. return finishToken(_ellipsis);
  1547. } else {
  1548. ++tokPos;
  1549. return finishToken(_dot);
  1550. }
  1551. }
  1552. function readToken_slash() { // '/'
  1553. var next = input.charCodeAt(tokPos + 1);
  1554. if (tokRegexpAllowed) {++tokPos; return readRegexp();}
  1555. if (next === 61) return finishOp(_assign, 2);
  1556. return finishOp(_slash, 1);
  1557. }
  1558. function readToken_mult_modulo(code) { // '%*'
  1559. var next = input.charCodeAt(tokPos + 1);
  1560. if (next === 61) return finishOp(_assign, 2);
  1561. return finishOp(code === 42 ? _star : _modulo, 1);
  1562. }
  1563. function readToken_pipe_amp(code) { // '|&'
  1564. var next = input.charCodeAt(tokPos + 1);
  1565. if (next === code) return finishOp(code === 124 ? _logicalOR : _logicalAND, 2);
  1566. if (next === 61) return finishOp(_assign, 2);
  1567. return finishOp(code === 124 ? _bitwiseOR : _bitwiseAND, 1);
  1568. }
  1569. function readToken_caret() { // '^'
  1570. var next = input.charCodeAt(tokPos + 1);
  1571. if (next === 61) return finishOp(_assign, 2);
  1572. return finishOp(_bitwiseXOR, 1);
  1573. }
  1574. function readToken_plus_min(code) { // '+-'
  1575. var next = input.charCodeAt(tokPos + 1);
  1576. if (next === code) {
  1577. if (next == 45 && input.charCodeAt(tokPos + 2) == 62 &&
  1578. newline.test(input.slice(lastEnd, tokPos))) {
  1579. // A `-->` line comment
  1580. skipLineComment(3);
  1581. skipSpace();
  1582. return readToken();
  1583. }
  1584. return finishOp(_incDec, 2);
  1585. }
  1586. if (next === 61) return finishOp(_assign, 2);
  1587. return finishOp(_plusMin, 1);
  1588. }
  1589. function readToken_lt_gt(code) { // '<>'
  1590. var next = input.charCodeAt(tokPos + 1);
  1591. var size = 1;
  1592. if (next === code) {
  1593. size = code === 62 && input.charCodeAt(tokPos + 2) === 62 ? 3 : 2;
  1594. if (input.charCodeAt(tokPos + size) === 61) return finishOp(_assign, size + 1);
  1595. return finishOp(_bitShift, size);
  1596. }
  1597. if (next == 33 && code == 60 && input.charCodeAt(tokPos + 2) == 45 &&
  1598. input.charCodeAt(tokPos + 3) == 45) {
  1599. // `<!--`, an XML-style comment that should be interpreted as a line comment
  1600. skipLineComment(4);
  1601. skipSpace();
  1602. return readToken();
  1603. }
  1604. if (next === 61)
  1605. size = input.charCodeAt(tokPos + 2) === 61 ? 3 : 2;
  1606. return finishOp(_relational, size);
  1607. }
  1608. function readToken_eq_excl(code) { // '=!', '=>'
  1609. var next = input.charCodeAt(tokPos + 1);
  1610. if (next === 61) return finishOp(_equality, input.charCodeAt(tokPos + 2) === 61 ? 3 : 2);
  1611. if (code === 61 && next === 62 && options.ecmaVersion >= 6) { // '=>'
  1612. tokPos += 2;
  1613. return finishToken(_arrow);
  1614. }
  1615. return finishOp(code === 61 ? _eq : _prefix, 1);
  1616. }
  1617. function getTokenFromCode(code) {
  1618. switch (code) {
  1619. // The interpretation of a dot depends on whether it is followed
  1620. // by a digit or another two dots.
  1621. case 46: // '.'
  1622. return readToken_dot();
  1623. // Punctuation tokens.
  1624. case 40: ++tokPos; return finishToken(_parenL);
  1625. case 41: ++tokPos; return finishToken(_parenR);
  1626. case 59: ++tokPos; return finishToken(_semi);
  1627. case 44: ++tokPos; return finishToken(_comma);
  1628. case 91: ++tokPos; return finishToken(_bracketL);
  1629. case 93: ++tokPos; return finishToken(_bracketR);
  1630. case 123:
  1631. ++tokPos;
  1632. if (templates.length) ++templates[templates.length - 1];
  1633. return finishToken(_braceL);
  1634. case 125:
  1635. ++tokPos;
  1636. if (templates.length && --templates[templates.length - 1] === 0)
  1637. return readTemplateString(_templateContinued);
  1638. else
  1639. return finishToken(_braceR);
  1640. case 58: ++tokPos; return finishToken(_colon);
  1641. case 63: ++tokPos; return finishToken(_question);
  1642. case 96: // '`'
  1643. if (options.ecmaVersion >= 6) {
  1644. ++tokPos;
  1645. return readTemplateString(_template);
  1646. }
  1647. case 48: // '0'
  1648. var next = input.charCodeAt(tokPos + 1);
  1649. if (next === 120 || next === 88) return readRadixNumber(16); // '0x', '0X' - hex number
  1650. if (options.ecmaVersion >= 6) {
  1651. if (next === 111 || next === 79) return readRadixNumber(8); // '0o', '0O' - octal number
  1652. if (next === 98 || next === 66) return readRadixNumber(2); // '0b', '0B' - binary number
  1653. }
  1654. // Anything else beginning with a digit is an integer, octal
  1655. // number, or float.
  1656. case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
  1657. return readNumber(false);
  1658. // Quotes produce strings.
  1659. case 34: case 39: // '"', "'"
  1660. return readString(code);
  1661. // Operators are parsed inline in tiny state machines. '=' (61) is
  1662. // often referred to. `finishOp` simply skips the amount of
  1663. // characters it is given as second argument, and returns a token
  1664. // of the type given by its first argument.
  1665. case 47: // '/'
  1666. return readToken_slash();
  1667. case 37: case 42: // '%*'
  1668. return readToken_mult_modulo(code);
  1669. case 124: case 38: // '|&'
  1670. return readToken_pipe_amp(code);
  1671. case 94: // '^'
  1672. return readToken_caret();
  1673. case 43: case 45: // '+-'
  1674. return readToken_plus_min(code);
  1675. case 60: case 62: // '<>'
  1676. return readToken_lt_gt(code);
  1677. case 61: case 33: // '=!'
  1678. return readToken_eq_excl(code);
  1679. case 126: // '~'
  1680. return finishOp(_prefix, 1);
  1681. }
  1682. return false;
  1683. }
  1684. function readToken(forceRegexp) {
  1685. if (!forceRegexp) tokStart = tokPos;
  1686. else tokPos = tokStart + 1;
  1687. if (options.locations) tokStartLoc = curPosition();
  1688. if (forceRegexp) return readRegexp();
  1689. if (tokPos >= inputLen) return finishToken(_eof);
  1690. var code = input.charCodeAt(tokPos);
  1691. // Identifier or keyword. '\uXXXX' sequences are allowed in
  1692. // identifiers, so '\' also dispatches to that.
  1693. if (isIdentifierStart(code) || code === 92 /* '\' */) return readWord();
  1694. var tok = getTokenFromCode(code);
  1695. if (tok === false) {
  1696. // If we are here, we either found a non-ASCII identifier
  1697. // character, or something that's entirely disallowed.
  1698. var ch = String.fromCharCode(code);
  1699. if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord();
  1700. raise(tokPos, "Unexpected character '" + ch + "'");
  1701. }
  1702. return tok;
  1703. }
  1704. function finishOp(type, size) {
  1705. var str = input.slice(tokPos, tokPos + size);
  1706. tokPos += size;
  1707. finishToken(type, str);
  1708. }
  1709. var regexpUnicodeSupport = false;
  1710. try { new RegExp("\uffff", "u"); regexpUnicodeSupport = true; }
  1711. catch(e) {}
  1712. // Parse a regular expression. Some context-awareness is necessary,
  1713. // since a '/' inside a '[]' set does not end the expression.
  1714. function readRegexp() {
  1715. var content = "", escaped, inClass, start = tokPos;
  1716. for (;;) {
  1717. if (tokPos >= inputLen) raise(start, "Unterminated regular expression");
  1718. var ch = input.charAt(tokPos);
  1719. if (newline.test(ch)) raise(start, "Unterminated regular expression");
  1720. if (!escaped) {
  1721. if (ch === "[") inClass = true;
  1722. else if (ch === "]" && inClass) inClass = false;
  1723. else if (ch === "/" && !inClass) break;
  1724. escaped = ch === "\\";
  1725. } else escaped = false;
  1726. ++tokPos;
  1727. }
  1728. var content = input.slice(start, tokPos);
  1729. ++tokPos;
  1730. // Need to use `readWord1` because '\uXXXX' sequences are allowed
  1731. // here (don't ask).
  1732. var mods = readWord1();
  1733. var tmp = content;
  1734. if (mods) {
  1735. var validFlags = /^[gmsiy]*$/;
  1736. if (options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
  1737. if (!validFlags.test(mods)) raise(start, "Invalid regular expression flag");
  1738. if (mods.indexOf('u') >= 0 && !regexpUnicodeSupport) {
  1739. // Replace each astral symbol and every Unicode code point
  1740. // escape sequence that represents such a symbol with a single
  1741. // ASCII symbol to avoid throwing on regular expressions that
  1742. // are only valid in combination with the `/u` flag.
  1743. tmp = tmp
  1744. .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, "x")
  1745. .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
  1746. }
  1747. }
  1748. // Detect invalid regular expressions.
  1749. try {
  1750. new RegExp(tmp);
  1751. } catch (e) {
  1752. if (e instanceof SyntaxError) raise(start, "Error parsing regular expression: " + e.message);
  1753. raise(e);
  1754. }
  1755. // Get a regular expression object for this pattern-flag pair, or `null` in
  1756. // case the current environment doesn't support the flags it uses.
  1757. try {
  1758. var value = new RegExp(content, mods);
  1759. } catch (err) {
  1760. value = null;
  1761. }
  1762. return finishToken(_regexp, {pattern: content, flags: mods, value: value});
  1763. }
  1764. // Read an integer in the given radix. Return null if zero digits
  1765. // were read, the integer value otherwise. When `len` is given, this
  1766. // will return `null` unless the integer has exactly `len` digits.
  1767. function readInt(radix, len) {
  1768. var start = tokPos, total = 0;
  1769. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  1770. var code = input.charCodeAt(tokPos), val;
  1771. if (code >= 97) val = code - 97 + 10; // a
  1772. else if (code >= 65) val = code - 65 + 10; // A
  1773. else if (code >= 48 && code <= 57) val = code - 48; // 0-9
  1774. else val = Infinity;
  1775. if (val >= radix) break;
  1776. ++tokPos;
  1777. total = total * radix + val;
  1778. }
  1779. if (tokPos === start || len != null && tokPos - start !== len) return null;
  1780. return total;
  1781. }
  1782. function readRadixNumber(radix) {
  1783. tokPos += 2; // 0x
  1784. var val = readInt(radix);
  1785. if (val == null) raise(tokStart + 2, "Expected number in radix " + radix);
  1786. if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
  1787. return finishToken(_num, val);
  1788. }
  1789. // Read an integer, octal integer, or floating-point number.
  1790. function readNumber(startsWithDot) {
  1791. var start = tokPos, isFloat = false, octal = input.charCodeAt(tokPos) === 48;
  1792. if (!startsWithDot && readInt(10) === null) raise(start, "Invalid number");
  1793. if (input.charCodeAt(tokPos) === 46) {
  1794. ++tokPos;
  1795. readInt(10);
  1796. isFloat = true;
  1797. }
  1798. var next = input.charCodeAt(tokPos);
  1799. if (next === 69 || next === 101) { // 'eE'
  1800. next = input.charCodeAt(++tokPos);
  1801. if (next === 43 || next === 45) ++tokPos; // '+-'
  1802. if (readInt(10) === null) raise(start, "Invalid number");
  1803. isFloat = true;
  1804. }
  1805. if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
  1806. var str = input.slice(start, tokPos), val;
  1807. if (isFloat) val = parseFloat(str);
  1808. else if (!octal || str.length === 1) val = parseInt(str, 10);
  1809. else if (/[89]/.test(str) || strict) raise(start, "Invalid number");
  1810. else val = parseInt(str, 8);
  1811. return finishToken(_num, val);
  1812. }
  1813. // Read a string value, interpreting backslash-escapes.
  1814. function readCodePoint() {
  1815. var ch = input.charCodeAt(tokPos), code;
  1816. if (ch === 123) {
  1817. if (options.ecmaVersion < 6) unexpected();
  1818. ++tokPos;
  1819. code = readHexChar(input.indexOf('}', tokPos) - tokPos);
  1820. ++tokPos;
  1821. if (code > 0x10FFFF) unexpected();
  1822. } else {
  1823. code = readHexChar(4);
  1824. }
  1825. // UTF-16 Encoding
  1826. if (code <= 0xFFFF) {
  1827. return String.fromCharCode(code);
  1828. }
  1829. var cu1 = ((code - 0x10000) >> 10) + 0xD800;
  1830. var cu2 = ((code - 0x10000) & 1023) + 0xDC00;
  1831. return String.fromCharCode(cu1, cu2);
  1832. }
  1833. function readString(quote) {
  1834. ++tokPos;
  1835. var out = "";
  1836. for (;;) {
  1837. if (tokPos >= inputLen) raise(tokStart, "Unterminated string constant");
  1838. var ch = input.charCodeAt(tokPos);
  1839. if (ch === quote) {
  1840. ++tokPos;
  1841. return finishToken(_string, out);
  1842. }
  1843. if (ch === 92) { // '\'
  1844. out += readEscapedChar();
  1845. } else {
  1846. ++tokPos;
  1847. if (newline.test(String.fromCharCode(ch))) {
  1848. raise(tokStart, "Unterminated string constant");
  1849. }
  1850. out += String.fromCharCode(ch); // '\'
  1851. }
  1852. }
  1853. }
  1854. function readTemplateString(type) {
  1855. if (type == _templateContinued) templates.pop();
  1856. var out = "", start = tokPos;;
  1857. for (;;) {
  1858. if (tokPos >= inputLen) raise(tokStart, "Unterminated template");
  1859. var ch = input.charAt(tokPos);
  1860. if (ch === "`" || ch === "$" && input.charCodeAt(tokPos + 1) === 123) { // '`', '${'
  1861. var raw = input.slice(start, tokPos);
  1862. ++tokPos;
  1863. if (ch == "$") { ++tokPos; templates.push(1); }
  1864. return finishToken(type, {cooked: out, raw: raw});
  1865. }
  1866. if (ch === "\\") { // '\'
  1867. out += readEscapedChar();
  1868. } else {
  1869. ++tokPos;
  1870. if (newline.test(ch)) {
  1871. if (ch === "\r" && input.charCodeAt(tokPos) === 10) {
  1872. ++tokPos;
  1873. ch = "\n";
  1874. }
  1875. if (options.locations) {
  1876. ++tokCurLine;
  1877. tokLineStart = tokPos;
  1878. }
  1879. }
  1880. out += ch;
  1881. }
  1882. }
  1883. }
  1884. // Used to read escaped characters
  1885. function readEscapedChar() {
  1886. var ch = input.charCodeAt(++tokPos);
  1887. var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3));
  1888. if (octal) octal = octal[0];
  1889. while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
  1890. if (octal === "0") octal = null;
  1891. ++tokPos;
  1892. if (octal) {
  1893. if (strict) raise(tokPos - 2, "Octal literal in strict mode");
  1894. tokPos += octal.length - 1;
  1895. return String.fromCharCode(parseInt(octal, 8));
  1896. } else {
  1897. switch (ch) {
  1898. case 110: return "\n"; // 'n' -> '\n'
  1899. case 114: return "\r"; // 'r' -> '\r'
  1900. case 120: return String.fromCharCode(readHexChar(2)); // 'x'
  1901. case 117: return readCodePoint(); // 'u'
  1902. case 116: return "\t"; // 't' -> '\t'
  1903. case 98: return "\b"; // 'b' -> '\b'
  1904. case 118: return "\u000b"; // 'v' -> '\u000b'
  1905. case 102: return "\f"; // 'f' -> '\f'
  1906. case 48: return "\0"; // 0 -> '\0'
  1907. case 13: if (input.charCodeAt(tokPos) === 10) ++tokPos; // '\r\n'
  1908. case 10: // ' \n'
  1909. if (options.locations) { tokLineStart = tokPos; ++tokCurLine; }
  1910. return "";
  1911. default: return String.fromCharCode(ch);
  1912. }
  1913. }
  1914. }
  1915. // Used to read character escape sequences ('\x', '\u', '\U').
  1916. function readHexChar(len) {
  1917. var n = readInt(16, len);
  1918. if (n === null) raise(tokStart, "Bad character escape sequence");
  1919. return n;
  1920. }
  1921. // Used to signal to callers of `readWord1` whether the word
  1922. // contained any escape sequences. This is needed because words with
  1923. // escape sequences must not be interpreted as keywords.
  1924. var containsEsc;
  1925. // Read an identifier, and return it as a string. Sets `containsEsc`
  1926. // to whether the word contained a '\u' escape.
  1927. //
  1928. // Only builds up the word character-by-character when it actually
  1929. // containeds an escape, as a micro-optimization.
  1930. function readWord1() {
  1931. containsEsc = false;
  1932. var word, first = true, start = tokPos;
  1933. for (;;) {
  1934. var ch = input.charCodeAt(tokPos);
  1935. if (isIdentifierChar(ch)) {
  1936. if (containsEsc) word += input.charAt(tokPos);
  1937. ++tokPos;
  1938. } else if (ch === 92) { // "\"
  1939. if (!containsEsc) word = input.slice(start, tokPos);
  1940. containsEsc = true;
  1941. if (input.charCodeAt(++tokPos) != 117) // "u"
  1942. raise(tokPos, "Expecting Unicode escape sequence \\uXXXX");
  1943. ++tokPos;
  1944. var esc = readHexChar(4);
  1945. var escStr = String.fromCharCode(esc);
  1946. if (!escStr) raise(tokPos - 1, "Invalid Unicode escape");
  1947. if (!(first ? isIdentifierStart(esc) : isIdentifierChar(esc)))
  1948. raise(tokPos - 4, "Invalid Unicode escape");
  1949. word += escStr;
  1950. } else {
  1951. break;
  1952. }
  1953. first = false;
  1954. }
  1955. return containsEsc ? word : input.slice(start, tokPos);
  1956. }
  1957. // Read an identifier or keyword token. Will check for reserved
  1958. // words when necessary.
  1959. function readWord() {
  1960. var word = readWord1();
  1961. var type = _name;
  1962. if (!containsEsc && isKeyword(word))
  1963. type = keywordTypes[word];
  1964. return finishToken(type, word);
  1965. }
  1966. // ## Parser
  1967. // A recursive descent parser operates by defining functions for all
  1968. // syntactic elements, and recursively calling those, each function
  1969. // advancing the input stream and returning an AST node. Precedence
  1970. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  1971. // instead of `(!x)[1]` is handled by the fact that the parser
  1972. // function that parses unary prefix operators is called first, and
  1973. // in turn calls the function that parses `[]` subscripts — that
  1974. // way, it'll receive the node for `x[1]` already parsed, and wraps
  1975. // *that* in the unary operator node.
  1976. //
  1977. // Acorn uses an [operator precedence parser][opp] to handle binary
  1978. // operator precedence, because it is much more compact than using
  1979. // the technique outlined above, which uses different, nesting
  1980. // functions to specify precedence, for all of the ten binary
  1981. // precedence levels that JavaScript defines.
  1982. //
  1983. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  1984. // ### Parser utilities
  1985. // Continue to the next token.
  1986. function next() {
  1987. lastStart = tokStart;
  1988. lastEnd = tokEnd;
  1989. lastEndLoc = tokEndLoc;
  1990. readToken();
  1991. }
  1992. // Enter strict mode. Re-reads the next token to please pedantic
  1993. // tests ("use strict"; 010; -- should fail).
  1994. function setStrict(strct) {
  1995. strict = strct;
  1996. tokPos = tokStart;
  1997. if (options.locations) {
  1998. while (tokPos < tokLineStart) {
  1999. tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
  2000. --tokCurLine;
  2001. }
  2002. }
  2003. skipSpace();
  2004. readToken();
  2005. }
  2006. // Start an AST node, attaching a start offset.
  2007. function Node() {
  2008. this.type = null;
  2009. this.start = tokStart;
  2010. this.end = null;
  2011. }
  2012. exports.Node = Node;
  2013. function SourceLocation() {
  2014. this.start = tokStartLoc;
  2015. this.end = null;
  2016. if (sourceFile !== null) this.source = sourceFile;
  2017. }
  2018. function startNode() {
  2019. var node = new Node();
  2020. if (options.locations)
  2021. node.loc = new SourceLocation();
  2022. if (options.directSourceFile)
  2023. node.sourceFile = options.directSourceFile;
  2024. if (options.ranges)
  2025. node.range = [tokStart, 0];
  2026. return node;
  2027. }
  2028. // Sometimes, a node is only started *after* the token stream passed
  2029. // its start position. The functions below help storing a position
  2030. // and creating a node from a previous position.
  2031. function storeCurrentPos() {
  2032. return options.locations ? [tokStart, tokStartLoc] : tokStart;
  2033. }
  2034. function startNodeAt(pos) {
  2035. var node = new Node(), start = pos;
  2036. if (options.locations) {
  2037. node.loc = new SourceLocation();
  2038. node.loc.start = start[1];
  2039. start = pos[0];
  2040. }
  2041. node.start = start;
  2042. if (options.directSourceFile)
  2043. node.sourceFile = options.directSourceFile;
  2044. if (options.ranges)
  2045. node.range = [start, 0];
  2046. return node;
  2047. }
  2048. // Finish an AST node, adding `type` and `end` properties.
  2049. function finishNode(node, type) {
  2050. node.type = type;
  2051. node.end = lastEnd;
  2052. if (options.locations)
  2053. node.loc.end = lastEndLoc;
  2054. if (options.ranges)
  2055. node.range[1] = lastEnd;
  2056. return node;
  2057. }
  2058. function finishNodeAt(node, type, pos) {
  2059. if (options.locations) { node.loc.end = pos[1]; pos = pos[0]; }
  2060. node.type = type;
  2061. node.end = pos;
  2062. if (options.ranges)
  2063. node.range[1] = pos;
  2064. return node;
  2065. }
  2066. // Test whether a statement node is the string literal `"use strict"`.
  2067. function isUseStrict(stmt) {
  2068. return options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
  2069. stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
  2070. }
  2071. // Predicate that tests whether the next token is of the given
  2072. // type, and if yes, consumes it as a side effect.
  2073. function eat(type) {
  2074. if (tokType === type) {
  2075. next();
  2076. return true;
  2077. } else {
  2078. return false;
  2079. }
  2080. }
  2081. // Test whether a semicolon can be inserted at the current position.
  2082. function canInsertSemicolon() {
  2083. return !options.strictSemicolons &&
  2084. (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
  2085. }
  2086. // Consume a semicolon, or, failing that, see if we are allowed to
  2087. // pretend that there is a semicolon at this position.
  2088. function semicolon() {
  2089. if (!eat(_semi) && !canInsertSemicolon()) unexpected();
  2090. }
  2091. // Expect a token of a given type. If found, consume it, otherwise,
  2092. // raise an unexpected token error.
  2093. function expect(type) {
  2094. eat(type) || unexpected();
  2095. }
  2096. // Raise an unexpected token error.
  2097. function unexpected(pos) {
  2098. raise(pos != null ? pos : tokStart, "Unexpected token");
  2099. }
  2100. // Checks if hash object has a property.
  2101. function has(obj, propName) {
  2102. return Object.prototype.hasOwnProperty.call(obj, propName);
  2103. }
  2104. // Convert existing expression atom to assignable pattern
  2105. // if possible.
  2106. function toAssignable(node, allowSpread, checkType) {
  2107. if (options.ecmaVersion >= 6 && node) {
  2108. switch (node.type) {
  2109. case "Identifier":
  2110. case "MemberExpression":
  2111. break;
  2112. case "ObjectExpression":
  2113. node.type = "ObjectPattern";
  2114. for (var i = 0; i < node.properties.length; i++) {
  2115. var prop = node.properties[i];
  2116. if (prop.kind !== "init") unexpected(prop.key.start);
  2117. toAssignable(prop.value, false, checkType);
  2118. }
  2119. break;
  2120. case "ArrayExpression":
  2121. node.type = "ArrayPattern";
  2122. for (var i = 0, lastI = node.elements.length - 1; i <= lastI; i++) {
  2123. toAssignable(node.elements[i], i === lastI, checkType);
  2124. }
  2125. break;
  2126. case "SpreadElement":
  2127. if (allowSpread) {
  2128. toAssignable(node.argument, false, checkType);
  2129. checkSpreadAssign(node.argument);
  2130. } else {
  2131. unexpected(node.start);
  2132. }
  2133. break;
  2134. default:
  2135. if (checkType) unexpected(node.start);
  2136. }
  2137. }
  2138. return node;
  2139. }
  2140. // Checks if node can be assignable spread argument.
  2141. function checkSpreadAssign(node) {
  2142. if (node.type !== "Identifier" && node.type !== "ArrayPattern")
  2143. unexpected(node.start);
  2144. }
  2145. // Verify that argument names are not repeated, and it does not
  2146. // try to bind the words `eval` or `arguments`.
  2147. function checkFunctionParam(param, nameHash) {
  2148. switch (param.type) {
  2149. case "Identifier":
  2150. if (isStrictReservedWord(param.name) || isStrictBadIdWord(param.name))
  2151. raise(param.start, "Defining '" + param.name + "' in strict mode");
  2152. if (has(nameHash, param.name))
  2153. raise(param.start, "Argument name clash in strict mode");
  2154. nameHash[param.name] = true;
  2155. break;
  2156. case "ObjectPattern":
  2157. for (var i = 0; i < param.properties.length; i++)
  2158. checkFunctionParam(param.properties[i].value, nameHash);
  2159. break;
  2160. case "ArrayPattern":
  2161. for (var i = 0; i < param.elements.length; i++) {
  2162. var elem = param.elements[i];
  2163. if (elem) checkFunctionParam(elem, nameHash);
  2164. }
  2165. break;
  2166. }
  2167. }
  2168. // Check if property name clashes with already added.
  2169. // Object/class getters and setters are not allowed to clash —
  2170. // either with each other or with an init property — and in
  2171. // strict mode, init properties are also not allowed to be repeated.
  2172. function checkPropClash(prop, propHash) {
  2173. if (options.ecmaVersion >= 6) return;
  2174. var key = prop.key, name;
  2175. switch (key.type) {
  2176. case "Identifier": name = key.name; break;
  2177. case "Literal": name = String(key.value); break;
  2178. default: return;
  2179. }
  2180. var kind = prop.kind || "init", other;
  2181. if (has(propHash, name)) {
  2182. other = propHash[name];
  2183. var isGetSet = kind !== "init";
  2184. if ((strict || isGetSet) && other[kind] || !(isGetSet ^ other.init))
  2185. raise(key.start, "Redefinition of property");
  2186. } else {
  2187. other = propHash[name] = {
  2188. init: false,
  2189. get: false,
  2190. set: false
  2191. };
  2192. }
  2193. other[kind] = true;
  2194. }
  2195. // Verify that a node is an lval — something that can be assigned
  2196. // to.
  2197. function checkLVal(expr, isBinding) {
  2198. switch (expr.type) {
  2199. case "Identifier":
  2200. if (strict && (isStrictBadIdWord(expr.name) || isStrictReservedWord(expr.name)))
  2201. raise(expr.start, isBinding
  2202. ? "Binding " + expr.name + " in strict mode"
  2203. : "Assigning to " + expr.name + " in strict mode"
  2204. );
  2205. break;
  2206. case "MemberExpression":
  2207. if (!isBinding) break;
  2208. case "ObjectPattern":
  2209. for (var i = 0; i < expr.properties.length; i++)
  2210. checkLVal(expr.properties[i].value, isBinding);
  2211. break;
  2212. case "ArrayPattern":
  2213. for (var i = 0; i < expr.elements.length; i++) {
  2214. var elem = expr.elements[i];
  2215. if (elem) checkLVal(elem, isBinding);
  2216. }
  2217. break;
  2218. case "SpreadElement":
  2219. break;
  2220. default:
  2221. raise(expr.start, "Assigning to rvalue");
  2222. }
  2223. }
  2224. // ### Statement parsing
  2225. // Parse a program. Initializes the parser, reads any number of
  2226. // statements, and wraps them in a Program node. Optionally takes a
  2227. // `program` argument. If present, the statements will be appended
  2228. // to its body instead of creating a new node.
  2229. function parseTopLevel(node) {
  2230. var first = true;
  2231. if (!node.body) node.body = [];
  2232. while (tokType !== _eof) {
  2233. var stmt = parseStatement(true);
  2234. node.body.push(stmt);
  2235. if (first && isUseStrict(stmt)) setStrict(true);
  2236. first = false;
  2237. }
  2238. lastStart = tokStart;
  2239. lastEnd = tokEnd;
  2240. lastEndLoc = tokEndLoc;
  2241. return finishNode(node, "Program");
  2242. }
  2243. var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
  2244. // Parse a single statement.
  2245. //
  2246. // If expecting a statement and finding a slash operator, parse a
  2247. // regular expression literal. This is to handle cases like
  2248. // `if (foo) /blah/.exec(foo);`, where looking at the previous token
  2249. // does not help.
  2250. function parseStatement(topLevel) {
  2251. if (tokType === _slash || tokType === _assign && tokVal == "/=")
  2252. readToken(true);
  2253. var starttype = tokType, node = startNode();
  2254. // Most types of statements are recognized by the keyword they
  2255. // start with. Many are trivial to parse, some require a bit of
  2256. // complexity.
  2257. switch (starttype) {
  2258. case _break: case _continue: return parseBreakContinueStatement(node, starttype.keyword);
  2259. case _debugger: return parseDebuggerStatement(node);
  2260. case _do: return parseDoStatement(node);
  2261. case _for: return parseForStatement(node);
  2262. case _function: return parseFunctionStatement(node);
  2263. case _class: return parseClass(node, true);
  2264. case _if: return parseIfStatement(node);
  2265. case _return: return parseReturnStatement(node);
  2266. case _switch: return parseSwitchStatement(node);
  2267. case _throw: return parseThrowStatement(node);
  2268. case _try: return parseTryStatement(node);
  2269. case _var: case _let: case _const: return parseVarStatement(node, starttype.keyword);
  2270. case _while: return parseWhileStatement(node);
  2271. case _with: return parseWithStatement(node);
  2272. case _braceL: return parseBlock(); // no point creating a function for this
  2273. case _semi: return parseEmptyStatement(node);
  2274. case _export:
  2275. case _import:
  2276. if (!topLevel && !options.allowImportExportEverywhere)
  2277. raise(tokStart, "'import' and 'export' may only appear at the top level");
  2278. return starttype === _import ? parseImport(node) : parseExport(node);
  2279. // If the statement does not start with a statement keyword or a
  2280. // brace, it's an ExpressionStatement or LabeledStatement. We
  2281. // simply start parsing an expression, and afterwards, if the
  2282. // next token is a colon and the expression was a simple
  2283. // Identifier node, we switch to interpreting it as a label.
  2284. default:
  2285. var maybeName = tokVal, expr = parseExpression();
  2286. if (starttype === _name && expr.type === "Identifier" && eat(_colon))
  2287. return parseLabeledStatement(node, maybeName, expr);
  2288. else return parseExpressionStatement(node, expr);
  2289. }
  2290. }
  2291. function parseBreakContinueStatement(node, keyword) {
  2292. var isBreak = keyword == "break";
  2293. next();
  2294. if (eat(_semi) || canInsertSemicolon()) node.label = null;
  2295. else if (tokType !== _name) unexpected();
  2296. else {
  2297. node.label = parseIdent();
  2298. semicolon();
  2299. }
  2300. // Verify that there is an actual destination to break or
  2301. // continue to.
  2302. for (var i = 0; i < labels.length; ++i) {
  2303. var lab = labels[i];
  2304. if (node.label == null || lab.name === node.label.name) {
  2305. if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
  2306. if (node.label && isBreak) break;
  2307. }
  2308. }
  2309. if (i === labels.length) raise(node.start, "Unsyntactic " + keyword);
  2310. return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  2311. }
  2312. function parseDebuggerStatement(node) {
  2313. next();
  2314. semicolon();
  2315. return finishNode(node, "DebuggerStatement");
  2316. }
  2317. function parseDoStatement(node) {
  2318. next();
  2319. labels.push(loopLabel);
  2320. node.body = parseStatement();
  2321. labels.pop();
  2322. expect(_while);
  2323. node.test = parseParenExpression();
  2324. if (options.ecmaVersion >= 6)
  2325. eat(_semi);
  2326. else
  2327. semicolon();
  2328. return finishNode(node, "DoWhileStatement");
  2329. }
  2330. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  2331. // loop is non-trivial. Basically, we have to parse the init `var`
  2332. // statement or expression, disallowing the `in` operator (see
  2333. // the second parameter to `parseExpression`), and then check
  2334. // whether the next token is `in` or `of`. When there is no init
  2335. // part (semicolon immediately after the opening parenthesis), it
  2336. // is a regular `for` loop.
  2337. function parseForStatement(node) {
  2338. next();
  2339. labels.push(loopLabel);
  2340. expect(_parenL);
  2341. if (tokType === _semi) return parseFor(node, null);
  2342. if (tokType === _var || tokType === _let) {
  2343. var init = startNode(), varKind = tokType.keyword, isLet = tokType === _let;
  2344. next();
  2345. parseVar(init, true, varKind);
  2346. finishNode(init, "VariableDeclaration");
  2347. if ((tokType === _in || (options.ecmaVersion >= 6 && tokType === _name && tokVal === "of")) && init.declarations.length === 1 &&
  2348. !(isLet && init.declarations[0].init))
  2349. return parseForIn(node, init);
  2350. return parseFor(node, init);
  2351. }
  2352. var init = parseExpression(false, true);
  2353. if (tokType === _in || (options.ecmaVersion >= 6 && tokType === _name && tokVal === "of")) {
  2354. checkLVal(init);
  2355. return parseForIn(node, init);
  2356. }
  2357. return parseFor(node, init);
  2358. }
  2359. function parseFunctionStatement(node) {
  2360. next();
  2361. return parseFunction(node, true);
  2362. }
  2363. function parseIfStatement(node) {
  2364. next();
  2365. node.test = parseParenExpression();
  2366. node.consequent = parseStatement();
  2367. node.alternate = eat(_else) ? parseStatement() : null;
  2368. return finishNode(node, "IfStatement");
  2369. }
  2370. function parseReturnStatement(node) {
  2371. if (!inFunction && !options.allowReturnOutsideFunction)
  2372. raise(tokStart, "'return' outside of function");
  2373. next();
  2374. // In `return` (and `break`/`continue`), the keywords with
  2375. // optional arguments, we eagerly look for a semicolon or the
  2376. // possibility to insert one.
  2377. if (eat(_semi) || canInsertSemicolon()) node.argument = null;
  2378. else { node.argument = parseExpression(); semicolon(); }
  2379. return finishNode(node, "ReturnStatement");
  2380. }
  2381. function parseSwitchStatement(node) {
  2382. next();
  2383. node.discriminant = parseParenExpression();
  2384. node.cases = [];
  2385. expect(_braceL);
  2386. labels.push(switchLabel);
  2387. // Statements under must be grouped (by label) in SwitchCase
  2388. // nodes. `cur` is used to keep the node that we are currently
  2389. // adding statements to.
  2390. for (var cur, sawDefault; tokType != _braceR;) {
  2391. if (tokType === _case || tokType === _default) {
  2392. var isCase = tokType === _case;
  2393. if (cur) finishNode(cur, "SwitchCase");
  2394. node.cases.push(cur = startNode());
  2395. cur.consequent = [];
  2396. next();
  2397. if (isCase) cur.test = parseExpression();
  2398. else {
  2399. if (sawDefault) raise(lastStart, "Multiple default clauses"); sawDefault = true;
  2400. cur.test = null;
  2401. }
  2402. expect(_colon);
  2403. } else {
  2404. if (!cur) unexpected();
  2405. cur.consequent.push(parseStatement());
  2406. }
  2407. }
  2408. if (cur) finishNode(cur, "SwitchCase");
  2409. next(); // Closing brace
  2410. labels.pop();
  2411. return finishNode(node, "SwitchStatement");
  2412. }
  2413. function parseThrowStatement(node) {
  2414. next();
  2415. if (newline.test(input.slice(lastEnd, tokStart)))
  2416. raise(lastEnd, "Illegal newline after throw");
  2417. node.argument = parseExpression();
  2418. semicolon();
  2419. return finishNode(node, "ThrowStatement");
  2420. }
  2421. function parseTryStatement(node) {
  2422. next();
  2423. node.block = parseBlock();
  2424. node.handler = null;
  2425. if (tokType === _catch) {
  2426. var clause = startNode();
  2427. next();
  2428. expect(_parenL);
  2429. clause.param = parseIdent();
  2430. if (strict && isStrictBadIdWord(clause.param.name))
  2431. raise(clause.param.start, "Binding " + clause.param.name + " in strict mode");
  2432. expect(_parenR);
  2433. clause.guard = null;
  2434. clause.body = parseBlock();
  2435. node.handler = finishNode(clause, "CatchClause");
  2436. }
  2437. node.guardedHandlers = empty;
  2438. node.finalizer = eat(_finally) ? parseBlock() : null;
  2439. if (!node.handler && !node.finalizer)
  2440. raise(node.start, "Missing catch or finally clause");
  2441. return finishNode(node, "TryStatement");
  2442. }
  2443. function parseVarStatement(node, kind) {
  2444. next();
  2445. parseVar(node, false, kind);
  2446. semicolon();
  2447. return finishNode(node, "VariableDeclaration");
  2448. }
  2449. function parseWhileStatement(node) {
  2450. next();
  2451. node.test = parseParenExpression();
  2452. labels.push(loopLabel);
  2453. node.body = parseStatement();
  2454. labels.pop();
  2455. return finishNode(node, "WhileStatement");
  2456. }
  2457. function parseWithStatement(node) {
  2458. if (strict) raise(tokStart, "'with' in strict mode");
  2459. next();
  2460. node.object = parseParenExpression();
  2461. node.body = parseStatement();
  2462. return finishNode(node, "WithStatement");
  2463. }
  2464. function parseEmptyStatement(node) {
  2465. next();
  2466. return finishNode(node, "EmptyStatement");
  2467. }
  2468. function parseLabeledStatement(node, maybeName, expr) {
  2469. for (var i = 0; i < labels.length; ++i)
  2470. if (labels[i].name === maybeName) raise(expr.start, "Label '" + maybeName + "' is already declared");
  2471. var kind = tokType.isLoop ? "loop" : tokType === _switch ? "switch" : null;
  2472. labels.push({name: maybeName, kind: kind});
  2473. node.body = parseStatement();
  2474. labels.pop();
  2475. node.label = expr;
  2476. return finishNode(node, "LabeledStatement");
  2477. }
  2478. function parseExpressionStatement(node, expr) {
  2479. node.expression = expr;
  2480. semicolon();
  2481. return finishNode(node, "ExpressionStatement");
  2482. }
  2483. // Used for constructs like `switch` and `if` that insist on
  2484. // parentheses around their expression.
  2485. function parseParenExpression() {
  2486. expect(_parenL);
  2487. var val = parseExpression();
  2488. expect(_parenR);
  2489. return val;
  2490. }
  2491. // Parse a semicolon-enclosed block of statements, handling `"use
  2492. // strict"` declarations when `allowStrict` is true (used for
  2493. // function bodies).
  2494. function parseBlock(allowStrict) {
  2495. var node = startNode(), first = true, oldStrict;
  2496. node.body = [];
  2497. expect(_braceL);
  2498. while (!eat(_braceR)) {
  2499. var stmt = parseStatement();
  2500. node.body.push(stmt);
  2501. if (first && allowStrict && isUseStrict(stmt)) {
  2502. oldStrict = strict;
  2503. setStrict(strict = true);
  2504. }
  2505. first = false;
  2506. }
  2507. if (oldStrict === false) setStrict(false);
  2508. return finishNode(node, "BlockStatement");
  2509. }
  2510. // Parse a regular `for` loop. The disambiguation code in
  2511. // `parseStatement` will already have parsed the init statement or
  2512. // expression.
  2513. function parseFor(node, init) {
  2514. node.init = init;
  2515. expect(_semi);
  2516. node.test = tokType === _semi ? null : parseExpression();
  2517. expect(_semi);
  2518. node.update = tokType === _parenR ? null : parseExpression();
  2519. expect(_parenR);
  2520. node.body = parseStatement();
  2521. labels.pop();
  2522. return finishNode(node, "ForStatement");
  2523. }
  2524. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  2525. // same from parser's perspective.
  2526. function parseForIn(node, init) {
  2527. var type = tokType === _in ? "ForInStatement" : "ForOfStatement";
  2528. next();
  2529. node.left = init;
  2530. node.right = parseExpression();
  2531. expect(_parenR);
  2532. node.body = parseStatement();
  2533. labels.pop();
  2534. return finishNode(node, type);
  2535. }
  2536. // Parse a list of variable declarations.
  2537. function parseVar(node, noIn, kind) {
  2538. node.declarations = [];
  2539. node.kind = kind;
  2540. for (;;) {
  2541. var decl = startNode();
  2542. decl.id = options.ecmaVersion >= 6 ? toAssignable(parseExprAtom()) : parseIdent();
  2543. checkLVal(decl.id, true);
  2544. decl.init = eat(_eq) ? parseExpression(true, noIn) : (kind === _const.keyword ? unexpected() : null);
  2545. node.declarations.push(finishNode(decl, "VariableDeclarator"));
  2546. if (!eat(_comma)) break;
  2547. }
  2548. return node;
  2549. }
  2550. // ### Expression parsing
  2551. // These nest, from the most general expression type at the top to
  2552. // 'atomic', nondivisible expression types at the bottom. Most of
  2553. // the functions will simply let the function(s) below them parse,
  2554. // and, *if* the syntactic construct they handle is present, wrap
  2555. // the AST node that the inner parser gave them in another node.
  2556. // Parse a full expression. The arguments are used to forbid comma
  2557. // sequences (in argument lists, array literals, or object literals)
  2558. // or the `in` operator (in for loops initalization expressions).
  2559. function parseExpression(noComma, noIn) {
  2560. var start = storeCurrentPos();
  2561. var expr = parseMaybeAssign(noIn);
  2562. if (!noComma && tokType === _comma) {
  2563. var node = startNodeAt(start);
  2564. node.expressions = [expr];
  2565. while (eat(_comma)) node.expressions.push(parseMaybeAssign(noIn));
  2566. return finishNode(node, "SequenceExpression");
  2567. }
  2568. return expr;
  2569. }
  2570. // Parse an assignment expression. This includes applications of
  2571. // operators like `+=`.
  2572. function parseMaybeAssign(noIn) {
  2573. var start = storeCurrentPos();
  2574. var left = parseMaybeConditional(noIn);
  2575. if (tokType.isAssign) {
  2576. var node = startNodeAt(start);
  2577. node.operator = tokVal;
  2578. node.left = tokType === _eq ? toAssignable(left) : left;
  2579. checkLVal(left);
  2580. next();
  2581. node.right = parseMaybeAssign(noIn);
  2582. return finishNode(node, "AssignmentExpression");
  2583. }
  2584. return left;
  2585. }
  2586. // Parse a ternary conditional (`?:`) operator.
  2587. function parseMaybeConditional(noIn) {
  2588. var start = storeCurrentPos();
  2589. var expr = parseExprOps(noIn);
  2590. if (eat(_question)) {
  2591. var node = startNodeAt(start);
  2592. node.test = expr;
  2593. node.consequent = parseExpression(true);
  2594. expect(_colon);
  2595. node.alternate = parseExpression(true, noIn);
  2596. return finishNode(node, "ConditionalExpression");
  2597. }
  2598. return expr;
  2599. }
  2600. // Start the precedence parser.
  2601. function parseExprOps(noIn) {
  2602. var start = storeCurrentPos();
  2603. return parseExprOp(parseMaybeUnary(), start, -1, noIn);
  2604. }
  2605. // Parse binary operators with the operator precedence parsing
  2606. // algorithm. `left` is the left-hand side of the operator.
  2607. // `minPrec` provides context that allows the function to stop and
  2608. // defer further parser to one of its callers when it encounters an
  2609. // operator that has a lower precedence than the set it is parsing.
  2610. function parseExprOp(left, leftStart, minPrec, noIn) {
  2611. var prec = tokType.binop;
  2612. if (prec != null && (!noIn || tokType !== _in)) {
  2613. if (prec > minPrec) {
  2614. var node = startNodeAt(leftStart);
  2615. node.left = left;
  2616. node.operator = tokVal;
  2617. var op = tokType;
  2618. next();
  2619. var start = storeCurrentPos();
  2620. node.right = parseExprOp(parseMaybeUnary(), start, prec, noIn);
  2621. finishNode(node, (op === _logicalOR || op === _logicalAND) ? "LogicalExpression" : "BinaryExpression");
  2622. return parseExprOp(node, leftStart, minPrec, noIn);
  2623. }
  2624. }
  2625. return left;
  2626. }
  2627. // Parse unary operators, both prefix and postfix.
  2628. function parseMaybeUnary() {
  2629. if (tokType.prefix) {
  2630. var node = startNode(), update = tokType.isUpdate, nodeType;
  2631. if (tokType === _ellipsis) {
  2632. nodeType = "SpreadElement";
  2633. } else {
  2634. nodeType = update ? "UpdateExpression" : "UnaryExpression";
  2635. node.operator = tokVal;
  2636. node.prefix = true;
  2637. }
  2638. tokRegexpAllowed = true;
  2639. next();
  2640. node.argument = parseMaybeUnary();
  2641. if (update) checkLVal(node.argument);
  2642. else if (strict && node.operator === "delete" &&
  2643. node.argument.type === "Identifier")
  2644. raise(node.start, "Deleting local variable in strict mode");
  2645. return finishNode(node, nodeType);
  2646. }
  2647. var start = storeCurrentPos();
  2648. var expr = parseExprSubscripts();
  2649. while (tokType.postfix && !canInsertSemicolon()) {
  2650. var node = startNodeAt(start);
  2651. node.operator = tokVal;
  2652. node.prefix = false;
  2653. node.argument = expr;
  2654. checkLVal(expr);
  2655. next();
  2656. expr = finishNode(node, "UpdateExpression");
  2657. }
  2658. return expr;
  2659. }
  2660. // Parse call, dot, and `[]`-subscript expressions.
  2661. function parseExprSubscripts() {
  2662. var start = storeCurrentPos();
  2663. return parseSubscripts(parseExprAtom(), start);
  2664. }
  2665. function parseSubscripts(base, start, noCalls) {
  2666. if (eat(_dot)) {
  2667. var node = startNodeAt(start);
  2668. node.object = base;
  2669. node.property = parseIdent(true);
  2670. node.computed = false;
  2671. return parseSubscripts(finishNode(node, "MemberExpression"), start, noCalls);
  2672. } else if (eat(_bracketL)) {
  2673. var node = startNodeAt(start);
  2674. node.object = base;
  2675. node.property = parseExpression();
  2676. node.computed = true;
  2677. expect(_bracketR);
  2678. return parseSubscripts(finishNode(node, "MemberExpression"), start, noCalls);
  2679. } else if (!noCalls && eat(_parenL)) {
  2680. var node = startNodeAt(start);
  2681. node.callee = base;
  2682. node.arguments = parseExprList(_parenR, false);
  2683. return parseSubscripts(finishNode(node, "CallExpression"), start, noCalls);
  2684. } else if (tokType === _template) {
  2685. var node = startNodeAt(start);
  2686. node.tag = base;
  2687. node.quasi = parseTemplate();
  2688. return parseSubscripts(finishNode(node, "TaggedTemplateExpression"), start, noCalls);
  2689. } return base;
  2690. }
  2691. // Parse an atomic expression — either a single token that is an
  2692. // expression, an expression started by a keyword like `function` or
  2693. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  2694. // or `{}`.
  2695. function parseExprAtom() {
  2696. switch (tokType) {
  2697. case _this:
  2698. var node = startNode();
  2699. next();
  2700. return finishNode(node, "ThisExpression");
  2701. case _yield:
  2702. if (inGenerator) return parseYield();
  2703. case _name:
  2704. var start = storeCurrentPos();
  2705. var id = parseIdent(tokType !== _name);
  2706. if (eat(_arrow)) {
  2707. return parseArrowExpression(startNodeAt(start), [id]);
  2708. }
  2709. return id;
  2710. case _regexp:
  2711. var node = startNode();
  2712. node.regex = {pattern: tokVal.pattern, flags: tokVal.flags};
  2713. node.value = tokVal.value;
  2714. node.raw = input.slice(tokStart, tokEnd);
  2715. next();
  2716. return finishNode(node, "Literal");
  2717. case _num: case _string:
  2718. var node = startNode();
  2719. node.value = tokVal;
  2720. node.raw = input.slice(tokStart, tokEnd);
  2721. next();
  2722. return finishNode(node, "Literal");
  2723. case _null: case _true: case _false:
  2724. var node = startNode();
  2725. node.value = tokType.atomValue;
  2726. node.raw = tokType.keyword;
  2727. next();
  2728. return finishNode(node, "Literal");
  2729. case _parenL:
  2730. var start = storeCurrentPos();
  2731. var val, exprList;
  2732. next();
  2733. // check whether this is generator comprehension or regular expression
  2734. if (options.ecmaVersion >= 7 && tokType === _for) {
  2735. val = parseComprehension(startNodeAt(start), true);
  2736. } else {
  2737. var oldParenL = ++metParenL;
  2738. if (tokType !== _parenR) {
  2739. val = parseExpression();
  2740. exprList = val.type === "SequenceExpression" ? val.expressions : [val];
  2741. } else {
  2742. exprList = [];
  2743. }
  2744. expect(_parenR);
  2745. // if '=>' follows '(...)', convert contents to arguments
  2746. if (metParenL === oldParenL && eat(_arrow)) {
  2747. val = parseArrowExpression(startNodeAt(start), exprList);
  2748. } else {
  2749. // forbid '()' before everything but '=>'
  2750. if (!val) unexpected(lastStart);
  2751. // forbid '...' in sequence expressions
  2752. if (options.ecmaVersion >= 6) {
  2753. for (var i = 0; i < exprList.length; i++) {
  2754. if (exprList[i].type === "SpreadElement") unexpected();
  2755. }
  2756. }
  2757. if (options.preserveParens) {
  2758. var par = startNodeAt(start);
  2759. par.expression = val;
  2760. val = finishNode(par, "ParenthesizedExpression");
  2761. }
  2762. }
  2763. }
  2764. return val;
  2765. case _bracketL:
  2766. var node = startNode();
  2767. next();
  2768. // check whether this is array comprehension or regular array
  2769. if (options.ecmaVersion >= 7 && tokType === _for) {
  2770. return parseComprehension(node, false);
  2771. }
  2772. node.elements = parseExprList(_bracketR, true, true);
  2773. return finishNode(node, "ArrayExpression");
  2774. case _braceL:
  2775. return parseObj();
  2776. case _function:
  2777. var node = startNode();
  2778. next();
  2779. return parseFunction(node, false);
  2780. case _class:
  2781. return parseClass(startNode(), false);
  2782. case _new:
  2783. return parseNew();
  2784. case _template:
  2785. return parseTemplate();
  2786. default:
  2787. unexpected();
  2788. }
  2789. }
  2790. // New's precedence is slightly tricky. It must allow its argument
  2791. // to be a `[]` or dot subscript expression, but not a call — at
  2792. // least, not without wrapping it in parentheses. Thus, it uses the
  2793. function parseNew() {
  2794. var node = startNode();
  2795. next();
  2796. var start = storeCurrentPos();
  2797. node.callee = parseSubscripts(parseExprAtom(), start, true);
  2798. if (eat(_parenL)) node.arguments = parseExprList(_parenR, false);
  2799. else node.arguments = empty;
  2800. return finishNode(node, "NewExpression");
  2801. }
  2802. // Parse template expression.
  2803. function parseTemplateElement() {
  2804. var elem = startNodeAt(options.locations ? [tokStart + 1, tokStartLoc.offset(1)] : tokStart + 1);
  2805. elem.value = tokVal;
  2806. elem.tail = input.charCodeAt(tokEnd - 1) !== 123; // '{'
  2807. next();
  2808. var endOff = elem.tail ? 1 : 2;
  2809. return finishNodeAt(elem, "TemplateElement", options.locations ? [lastEnd - endOff, lastEndLoc.offset(-endOff)] : lastEnd - endOff);
  2810. }
  2811. function parseTemplate() {
  2812. var node = startNode();
  2813. node.expressions = [];
  2814. var curElt = parseTemplateElement();
  2815. node.quasis = [curElt];
  2816. while (!curElt.tail) {
  2817. node.expressions.push(parseExpression());
  2818. if (tokType !== _templateContinued) unexpected();
  2819. node.quasis.push(curElt = parseTemplateElement());
  2820. }
  2821. return finishNode(node, "TemplateLiteral");
  2822. }
  2823. // Parse an object literal.
  2824. function parseObj() {
  2825. var node = startNode(), first = true, propHash = {};
  2826. node.properties = [];
  2827. next();
  2828. while (!eat(_braceR)) {
  2829. if (!first) {
  2830. expect(_comma);
  2831. if (options.allowTrailingCommas && eat(_braceR)) break;
  2832. } else first = false;
  2833. var prop = startNode(), isGenerator;
  2834. if (options.ecmaVersion >= 6) {
  2835. prop.method = false;
  2836. prop.shorthand = false;
  2837. isGenerator = eat(_star);
  2838. }
  2839. parsePropertyName(prop);
  2840. if (eat(_colon)) {
  2841. prop.value = parseExpression(true);
  2842. prop.kind = "init";
  2843. } else if (options.ecmaVersion >= 6 && tokType === _parenL) {
  2844. prop.kind = "init";
  2845. prop.method = true;
  2846. prop.value = parseMethod(isGenerator);
  2847. } else if (options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  2848. (prop.key.name === "get" || prop.key.name === "set")) {
  2849. if (isGenerator) unexpected();
  2850. prop.kind = prop.key.name;
  2851. parsePropertyName(prop);
  2852. prop.value = parseMethod(false);
  2853. } else if (options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  2854. prop.kind = "init";
  2855. prop.value = prop.key;
  2856. prop.shorthand = true;
  2857. } else unexpected();
  2858. checkPropClash(prop, propHash);
  2859. node.properties.push(finishNode(prop, "Property"));
  2860. }
  2861. return finishNode(node, "ObjectExpression");
  2862. }
  2863. function parsePropertyName(prop) {
  2864. if (options.ecmaVersion >= 6) {
  2865. if (eat(_bracketL)) {
  2866. prop.computed = true;
  2867. prop.key = parseExpression();
  2868. expect(_bracketR);
  2869. return;
  2870. } else {
  2871. prop.computed = false;
  2872. }
  2873. }
  2874. prop.key = (tokType === _num || tokType === _string) ? parseExprAtom() : parseIdent(true);
  2875. }
  2876. // Initialize empty function node.
  2877. function initFunction(node) {
  2878. node.id = null;
  2879. node.params = [];
  2880. if (options.ecmaVersion >= 6) {
  2881. node.defaults = [];
  2882. node.rest = null;
  2883. node.generator = false;
  2884. }
  2885. }
  2886. // Parse a function declaration or literal (depending on the
  2887. // `isStatement` parameter).
  2888. function parseFunction(node, isStatement, allowExpressionBody) {
  2889. initFunction(node);
  2890. if (options.ecmaVersion >= 6) {
  2891. node.generator = eat(_star);
  2892. }
  2893. if (isStatement || tokType === _name) {
  2894. node.id = parseIdent();
  2895. }
  2896. parseFunctionParams(node);
  2897. parseFunctionBody(node, allowExpressionBody);
  2898. return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
  2899. }
  2900. // Parse object or class method.
  2901. function parseMethod(isGenerator) {
  2902. var node = startNode();
  2903. initFunction(node);
  2904. parseFunctionParams(node);
  2905. var allowExpressionBody;
  2906. if (options.ecmaVersion >= 6) {
  2907. node.generator = isGenerator;
  2908. allowExpressionBody = true;
  2909. } else {
  2910. allowExpressionBody = false;
  2911. }
  2912. parseFunctionBody(node, allowExpressionBody);
  2913. return finishNode(node, "FunctionExpression");
  2914. }
  2915. // Parse arrow function expression with given parameters.
  2916. function parseArrowExpression(node, params) {
  2917. initFunction(node);
  2918. var defaults = node.defaults, hasDefaults = false;
  2919. for (var i = 0, lastI = params.length - 1; i <= lastI; i++) {
  2920. var param = params[i];
  2921. if (param.type === "AssignmentExpression" && param.operator === "=") {
  2922. hasDefaults = true;
  2923. params[i] = param.left;
  2924. defaults.push(param.right);
  2925. } else {
  2926. toAssignable(param, i === lastI, true);
  2927. defaults.push(null);
  2928. if (param.type === "SpreadElement") {
  2929. params.length--;
  2930. node.rest = param.argument;
  2931. break;
  2932. }
  2933. }
  2934. }
  2935. node.params = params;
  2936. if (!hasDefaults) node.defaults = [];
  2937. parseFunctionBody(node, true);
  2938. return finishNode(node, "ArrowFunctionExpression");
  2939. }
  2940. // Parse function parameters.
  2941. function parseFunctionParams(node) {
  2942. var defaults = [], hasDefaults = false;
  2943. expect(_parenL);
  2944. for (;;) {
  2945. if (eat(_parenR)) {
  2946. break;
  2947. } else if (options.ecmaVersion >= 6 && eat(_ellipsis)) {
  2948. node.rest = toAssignable(parseExprAtom(), false, true);
  2949. checkSpreadAssign(node.rest);
  2950. expect(_parenR);
  2951. defaults.push(null);
  2952. break;
  2953. } else {
  2954. node.params.push(options.ecmaVersion >= 6 ? toAssignable(parseExprAtom(), false, true) : parseIdent());
  2955. if (options.ecmaVersion >= 6) {
  2956. if (eat(_eq)) {
  2957. hasDefaults = true;
  2958. defaults.push(parseExpression(true));
  2959. } else {
  2960. defaults.push(null);
  2961. }
  2962. }
  2963. if (!eat(_comma)) {
  2964. expect(_parenR);
  2965. break;
  2966. }
  2967. }
  2968. }
  2969. if (hasDefaults) node.defaults = defaults;
  2970. }
  2971. // Parse function body and check parameters.
  2972. function parseFunctionBody(node, allowExpression) {
  2973. var isExpression = allowExpression && tokType !== _braceL;
  2974. if (isExpression) {
  2975. node.body = parseExpression(true);
  2976. node.expression = true;
  2977. } else {
  2978. // Start a new scope with regard to labels and the `inFunction`
  2979. // flag (restore them to their old value afterwards).
  2980. var oldInFunc = inFunction, oldInGen = inGenerator, oldLabels = labels;
  2981. inFunction = true; inGenerator = node.generator; labels = [];
  2982. node.body = parseBlock(true);
  2983. node.expression = false;
  2984. inFunction = oldInFunc; inGenerator = oldInGen; labels = oldLabels;
  2985. }
  2986. // If this is a strict mode function, verify that argument names
  2987. // are not repeated, and it does not try to bind the words `eval`
  2988. // or `arguments`.
  2989. if (strict || !isExpression && node.body.body.length && isUseStrict(node.body.body[0])) {
  2990. var nameHash = {};
  2991. if (node.id)
  2992. checkFunctionParam(node.id, {});
  2993. for (var i = 0; i < node.params.length; i++)
  2994. checkFunctionParam(node.params[i], nameHash);
  2995. if (node.rest)
  2996. checkFunctionParam(node.rest, nameHash);
  2997. }
  2998. }
  2999. // Parse a class declaration or literal (depending on the
  3000. // `isStatement` parameter).
  3001. function parseClass(node, isStatement) {
  3002. next();
  3003. node.id = tokType === _name ? parseIdent() : isStatement ? unexpected() : null;
  3004. node.superClass = eat(_extends) ? parseExpression() : null;
  3005. var classBody = startNode();
  3006. classBody.body = [];
  3007. expect(_braceL);
  3008. while (!eat(_braceR)) {
  3009. var method = startNode();
  3010. if (tokType === _name && tokVal === "static") {
  3011. next();
  3012. method['static'] = true;
  3013. } else {
  3014. method['static'] = false;
  3015. }
  3016. var isGenerator = eat(_star);
  3017. parsePropertyName(method);
  3018. if (tokType !== _parenL && !method.computed && method.key.type === "Identifier" &&
  3019. (method.key.name === "get" || method.key.name === "set")) {
  3020. if (isGenerator) unexpected();
  3021. method.kind = method.key.name;
  3022. parsePropertyName(method);
  3023. } else {
  3024. method.kind = "";
  3025. }
  3026. method.value = parseMethod(isGenerator);
  3027. classBody.body.push(finishNode(method, "MethodDefinition"));
  3028. eat(_semi);
  3029. }
  3030. node.body = finishNode(classBody, "ClassBody");
  3031. return finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  3032. }
  3033. // Parses a comma-separated list of expressions, and returns them as
  3034. // an array. `close` is the token type that ends the list, and
  3035. // `allowEmpty` can be turned on to allow subsequent commas with
  3036. // nothing in between them to be parsed as `null` (which is needed
  3037. // for array literals).
  3038. function parseExprList(close, allowTrailingComma, allowEmpty) {
  3039. var elts = [], first = true;
  3040. while (!eat(close)) {
  3041. if (!first) {
  3042. expect(_comma);
  3043. if (allowTrailingComma && options.allowTrailingCommas && eat(close)) break;
  3044. } else first = false;
  3045. if (allowEmpty && tokType === _comma) elts.push(null);
  3046. else elts.push(parseExpression(true));
  3047. }
  3048. return elts;
  3049. }
  3050. // Parse the next token as an identifier. If `liberal` is true (used
  3051. // when parsing properties), it will also convert keywords into
  3052. // identifiers.
  3053. function parseIdent(liberal) {
  3054. var node = startNode();
  3055. if (liberal && options.forbidReserved == "everywhere") liberal = false;
  3056. if (tokType === _name) {
  3057. if (!liberal &&
  3058. (options.forbidReserved &&
  3059. (options.ecmaVersion === 3 ? isReservedWord3 : isReservedWord5)(tokVal) ||
  3060. strict && isStrictReservedWord(tokVal)) &&
  3061. input.slice(tokStart, tokEnd).indexOf("\\") == -1)
  3062. raise(tokStart, "The keyword '" + tokVal + "' is reserved");
  3063. node.name = tokVal;
  3064. } else if (liberal && tokType.keyword) {
  3065. node.name = tokType.keyword;
  3066. } else {
  3067. unexpected();
  3068. }
  3069. tokRegexpAllowed = false;
  3070. next();
  3071. return finishNode(node, "Identifier");
  3072. }
  3073. // Parses module export declaration.
  3074. function parseExport(node) {
  3075. next();
  3076. // export var|const|let|function|class ...;
  3077. if (tokType === _var || tokType === _const || tokType === _let || tokType === _function || tokType === _class) {
  3078. node.declaration = parseStatement();
  3079. node['default'] = false;
  3080. node.specifiers = null;
  3081. node.source = null;
  3082. } else
  3083. // export default ...;
  3084. if (eat(_default)) {
  3085. node.declaration = parseExpression(true);
  3086. node['default'] = true;
  3087. node.specifiers = null;
  3088. node.source = null;
  3089. semicolon();
  3090. } else {
  3091. // export * from '...';
  3092. // export { x, y as z } [from '...'];
  3093. var isBatch = tokType === _star;
  3094. node.declaration = null;
  3095. node['default'] = false;
  3096. node.specifiers = parseExportSpecifiers();
  3097. if (tokType === _name && tokVal === "from") {
  3098. next();
  3099. node.source = tokType === _string ? parseExprAtom() : unexpected();
  3100. } else {
  3101. if (isBatch) unexpected();
  3102. node.source = null;
  3103. }
  3104. semicolon();
  3105. }
  3106. return finishNode(node, "ExportDeclaration");
  3107. }
  3108. // Parses a comma-separated list of module exports.
  3109. function parseExportSpecifiers() {
  3110. var nodes = [], first = true;
  3111. if (tokType === _star) {
  3112. // export * from '...'
  3113. var node = startNode();
  3114. next();
  3115. nodes.push(finishNode(node, "ExportBatchSpecifier"));
  3116. } else {
  3117. // export { x, y as z } [from '...']
  3118. expect(_braceL);
  3119. while (!eat(_braceR)) {
  3120. if (!first) {
  3121. expect(_comma);
  3122. if (options.allowTrailingCommas && eat(_braceR)) break;
  3123. } else first = false;
  3124. var node = startNode();
  3125. node.id = parseIdent(tokType === _default);
  3126. if (tokType === _name && tokVal === "as") {
  3127. next();
  3128. node.name = parseIdent(true);
  3129. } else {
  3130. node.name = null;
  3131. }
  3132. nodes.push(finishNode(node, "ExportSpecifier"));
  3133. }
  3134. }
  3135. return nodes;
  3136. }
  3137. // Parses import declaration.
  3138. function parseImport(node) {
  3139. next();
  3140. // import '...';
  3141. if (tokType === _string) {
  3142. node.specifiers = [];
  3143. node.source = parseExprAtom();
  3144. node.kind = "";
  3145. } else {
  3146. node.specifiers = parseImportSpecifiers();
  3147. if (tokType !== _name || tokVal !== "from") unexpected();
  3148. next();
  3149. node.source = tokType === _string ? parseExprAtom() : unexpected();
  3150. }
  3151. semicolon();
  3152. return finishNode(node, "ImportDeclaration");
  3153. }
  3154. // Parses a comma-separated list of module imports.
  3155. function parseImportSpecifiers() {
  3156. var nodes = [], first = true;
  3157. if (tokType === _name) {
  3158. // import defaultObj, { x, y as z } from '...'
  3159. var node = startNode();
  3160. node.id = parseIdent();
  3161. checkLVal(node.id, true);
  3162. node.name = null;
  3163. node['default'] = true;
  3164. nodes.push(finishNode(node, "ImportSpecifier"));
  3165. if (!eat(_comma)) return nodes;
  3166. }
  3167. if (tokType === _star) {
  3168. var node = startNode();
  3169. next();
  3170. if (tokType !== _name || tokVal !== "as") unexpected();
  3171. next();
  3172. node.name = parseIdent();
  3173. checkLVal(node.name, true);
  3174. nodes.push(finishNode(node, "ImportBatchSpecifier"));
  3175. return nodes;
  3176. }
  3177. expect(_braceL);
  3178. while (!eat(_braceR)) {
  3179. if (!first) {
  3180. expect(_comma);
  3181. if (options.allowTrailingCommas && eat(_braceR)) break;
  3182. } else first = false;
  3183. var node = startNode();
  3184. node.id = parseIdent(true);
  3185. if (tokType === _name && tokVal === "as") {
  3186. next();
  3187. node.name = parseIdent();
  3188. } else {
  3189. node.name = null;
  3190. }
  3191. checkLVal(node.name || node.id, true);
  3192. node['default'] = false;
  3193. nodes.push(finishNode(node, "ImportSpecifier"));
  3194. }
  3195. return nodes;
  3196. }
  3197. // Parses yield expression inside generator.
  3198. function parseYield() {
  3199. var node = startNode();
  3200. next();
  3201. if (eat(_semi) || canInsertSemicolon()) {
  3202. node.delegate = false;
  3203. node.argument = null;
  3204. } else {
  3205. node.delegate = eat(_star);
  3206. node.argument = parseExpression(true);
  3207. }
  3208. return finishNode(node, "YieldExpression");
  3209. }
  3210. // Parses array and generator comprehensions.
  3211. function parseComprehension(node, isGenerator) {
  3212. node.blocks = [];
  3213. while (tokType === _for) {
  3214. var block = startNode();
  3215. next();
  3216. expect(_parenL);
  3217. block.left = toAssignable(parseExprAtom());
  3218. checkLVal(block.left, true);
  3219. if (tokType !== _name || tokVal !== "of") unexpected();
  3220. next();
  3221. // `of` property is here for compatibility with Esprima's AST
  3222. // which also supports deprecated [for (... in ...) expr]
  3223. block.of = true;
  3224. block.right = parseExpression();
  3225. expect(_parenR);
  3226. node.blocks.push(finishNode(block, "ComprehensionBlock"));
  3227. }
  3228. node.filter = eat(_if) ? parseParenExpression() : null;
  3229. node.body = parseExpression();
  3230. expect(isGenerator ? _parenR : _bracketR);
  3231. node.generator = isGenerator;
  3232. return finishNode(node, "ComprehensionExpression");
  3233. }
  3234. });
  3235. /***/ },
  3236. /***/ 462:
  3237. /***/ function(module, exports, __webpack_require__) {
  3238. /*
  3239. * Copyright 2009-2011 Mozilla Foundation and contributors
  3240. * Licensed under the New BSD license. See LICENSE.txt or:
  3241. * http://opensource.org/licenses/BSD-3-Clause
  3242. */
  3243. exports.SourceMapGenerator = __webpack_require__(463).SourceMapGenerator;
  3244. exports.SourceMapConsumer = __webpack_require__(469).SourceMapConsumer;
  3245. exports.SourceNode = __webpack_require__(471).SourceNode;
  3246. /***/ },
  3247. /***/ 463:
  3248. /***/ function(module, exports, __webpack_require__) {
  3249. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  3250. /*
  3251. * Copyright 2011 Mozilla Foundation and contributors
  3252. * Licensed under the New BSD license. See LICENSE or:
  3253. * http://opensource.org/licenses/BSD-3-Clause
  3254. */
  3255. if (false) {
  3256. var define = require('amdefine')(module, require);
  3257. }
  3258. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  3259. var base64VLQ = __webpack_require__(464);
  3260. var util = __webpack_require__(466);
  3261. var ArraySet = __webpack_require__(467).ArraySet;
  3262. var MappingList = __webpack_require__(468).MappingList;
  3263. /**
  3264. * An instance of the SourceMapGenerator represents a source map which is
  3265. * being built incrementally. You may pass an object with the following
  3266. * properties:
  3267. *
  3268. * - file: The filename of the generated source.
  3269. * - sourceRoot: A root for all relative URLs in this source map.
  3270. */
  3271. function SourceMapGenerator(aArgs) {
  3272. if (!aArgs) {
  3273. aArgs = {};
  3274. }
  3275. this._file = util.getArg(aArgs, 'file', null);
  3276. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  3277. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  3278. this._sources = new ArraySet();
  3279. this._names = new ArraySet();
  3280. this._mappings = new MappingList();
  3281. this._sourcesContents = null;
  3282. }
  3283. SourceMapGenerator.prototype._version = 3;
  3284. /**
  3285. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  3286. *
  3287. * @param aSourceMapConsumer The SourceMap.
  3288. */
  3289. SourceMapGenerator.fromSourceMap =
  3290. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  3291. var sourceRoot = aSourceMapConsumer.sourceRoot;
  3292. var generator = new SourceMapGenerator({
  3293. file: aSourceMapConsumer.file,
  3294. sourceRoot: sourceRoot
  3295. });
  3296. aSourceMapConsumer.eachMapping(function (mapping) {
  3297. var newMapping = {
  3298. generated: {
  3299. line: mapping.generatedLine,
  3300. column: mapping.generatedColumn
  3301. }
  3302. };
  3303. if (mapping.source != null) {
  3304. newMapping.source = mapping.source;
  3305. if (sourceRoot != null) {
  3306. newMapping.source = util.relative(sourceRoot, newMapping.source);
  3307. }
  3308. newMapping.original = {
  3309. line: mapping.originalLine,
  3310. column: mapping.originalColumn
  3311. };
  3312. if (mapping.name != null) {
  3313. newMapping.name = mapping.name;
  3314. }
  3315. }
  3316. generator.addMapping(newMapping);
  3317. });
  3318. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  3319. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  3320. if (content != null) {
  3321. generator.setSourceContent(sourceFile, content);
  3322. }
  3323. });
  3324. return generator;
  3325. };
  3326. /**
  3327. * Add a single mapping from original source line and column to the generated
  3328. * source's line and column for this source map being created. The mapping
  3329. * object should have the following properties:
  3330. *
  3331. * - generated: An object with the generated line and column positions.
  3332. * - original: An object with the original line and column positions.
  3333. * - source: The original source file (relative to the sourceRoot).
  3334. * - name: An optional original token name for this mapping.
  3335. */
  3336. SourceMapGenerator.prototype.addMapping =
  3337. function SourceMapGenerator_addMapping(aArgs) {
  3338. var generated = util.getArg(aArgs, 'generated');
  3339. var original = util.getArg(aArgs, 'original', null);
  3340. var source = util.getArg(aArgs, 'source', null);
  3341. var name = util.getArg(aArgs, 'name', null);
  3342. if (!this._skipValidation) {
  3343. this._validateMapping(generated, original, source, name);
  3344. }
  3345. if (source != null && !this._sources.has(source)) {
  3346. this._sources.add(source);
  3347. }
  3348. if (name != null && !this._names.has(name)) {
  3349. this._names.add(name);
  3350. }
  3351. this._mappings.add({
  3352. generatedLine: generated.line,
  3353. generatedColumn: generated.column,
  3354. originalLine: original != null && original.line,
  3355. originalColumn: original != null && original.column,
  3356. source: source,
  3357. name: name
  3358. });
  3359. };
  3360. /**
  3361. * Set the source content for a source file.
  3362. */
  3363. SourceMapGenerator.prototype.setSourceContent =
  3364. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  3365. var source = aSourceFile;
  3366. if (this._sourceRoot != null) {
  3367. source = util.relative(this._sourceRoot, source);
  3368. }
  3369. if (aSourceContent != null) {
  3370. // Add the source content to the _sourcesContents map.
  3371. // Create a new _sourcesContents map if the property is null.
  3372. if (!this._sourcesContents) {
  3373. this._sourcesContents = {};
  3374. }
  3375. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  3376. } else if (this._sourcesContents) {
  3377. // Remove the source file from the _sourcesContents map.
  3378. // If the _sourcesContents map is empty, set the property to null.
  3379. delete this._sourcesContents[util.toSetString(source)];
  3380. if (Object.keys(this._sourcesContents).length === 0) {
  3381. this._sourcesContents = null;
  3382. }
  3383. }
  3384. };
  3385. /**
  3386. * Applies the mappings of a sub-source-map for a specific source file to the
  3387. * source map being generated. Each mapping to the supplied source file is
  3388. * rewritten using the supplied source map. Note: The resolution for the
  3389. * resulting mappings is the minimium of this map and the supplied map.
  3390. *
  3391. * @param aSourceMapConsumer The source map to be applied.
  3392. * @param aSourceFile Optional. The filename of the source file.
  3393. * If omitted, SourceMapConsumer's file property will be used.
  3394. * @param aSourceMapPath Optional. The dirname of the path to the source map
  3395. * to be applied. If relative, it is relative to the SourceMapConsumer.
  3396. * This parameter is needed when the two source maps aren't in the same
  3397. * directory, and the source map to be applied contains relative source
  3398. * paths. If so, those relative source paths need to be rewritten
  3399. * relative to the SourceMapGenerator.
  3400. */
  3401. SourceMapGenerator.prototype.applySourceMap =
  3402. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  3403. var sourceFile = aSourceFile;
  3404. // If aSourceFile is omitted, we will use the file property of the SourceMap
  3405. if (aSourceFile == null) {
  3406. if (aSourceMapConsumer.file == null) {
  3407. throw new Error(
  3408. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  3409. 'or the source map\'s "file" property. Both were omitted.'
  3410. );
  3411. }
  3412. sourceFile = aSourceMapConsumer.file;
  3413. }
  3414. var sourceRoot = this._sourceRoot;
  3415. // Make "sourceFile" relative if an absolute Url is passed.
  3416. if (sourceRoot != null) {
  3417. sourceFile = util.relative(sourceRoot, sourceFile);
  3418. }
  3419. // Applying the SourceMap can add and remove items from the sources and
  3420. // the names array.
  3421. var newSources = new ArraySet();
  3422. var newNames = new ArraySet();
  3423. // Find mappings for the "sourceFile"
  3424. this._mappings.unsortedForEach(function (mapping) {
  3425. if (mapping.source === sourceFile && mapping.originalLine != null) {
  3426. // Check if it can be mapped by the source map, then update the mapping.
  3427. var original = aSourceMapConsumer.originalPositionFor({
  3428. line: mapping.originalLine,
  3429. column: mapping.originalColumn
  3430. });
  3431. if (original.source != null) {
  3432. // Copy mapping
  3433. mapping.source = original.source;
  3434. if (aSourceMapPath != null) {
  3435. mapping.source = util.join(aSourceMapPath, mapping.source)
  3436. }
  3437. if (sourceRoot != null) {
  3438. mapping.source = util.relative(sourceRoot, mapping.source);
  3439. }
  3440. mapping.originalLine = original.line;
  3441. mapping.originalColumn = original.column;
  3442. if (original.name != null) {
  3443. mapping.name = original.name;
  3444. }
  3445. }
  3446. }
  3447. var source = mapping.source;
  3448. if (source != null && !newSources.has(source)) {
  3449. newSources.add(source);
  3450. }
  3451. var name = mapping.name;
  3452. if (name != null && !newNames.has(name)) {
  3453. newNames.add(name);
  3454. }
  3455. }, this);
  3456. this._sources = newSources;
  3457. this._names = newNames;
  3458. // Copy sourcesContents of applied map.
  3459. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  3460. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  3461. if (content != null) {
  3462. if (aSourceMapPath != null) {
  3463. sourceFile = util.join(aSourceMapPath, sourceFile);
  3464. }
  3465. if (sourceRoot != null) {
  3466. sourceFile = util.relative(sourceRoot, sourceFile);
  3467. }
  3468. this.setSourceContent(sourceFile, content);
  3469. }
  3470. }, this);
  3471. };
  3472. /**
  3473. * A mapping can have one of the three levels of data:
  3474. *
  3475. * 1. Just the generated position.
  3476. * 2. The Generated position, original position, and original source.
  3477. * 3. Generated and original position, original source, as well as a name
  3478. * token.
  3479. *
  3480. * To maintain consistency, we validate that any new mapping being added falls
  3481. * in to one of these categories.
  3482. */
  3483. SourceMapGenerator.prototype._validateMapping =
  3484. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  3485. aName) {
  3486. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3487. && aGenerated.line > 0 && aGenerated.column >= 0
  3488. && !aOriginal && !aSource && !aName) {
  3489. // Case 1.
  3490. return;
  3491. }
  3492. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3493. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  3494. && aGenerated.line > 0 && aGenerated.column >= 0
  3495. && aOriginal.line > 0 && aOriginal.column >= 0
  3496. && aSource) {
  3497. // Cases 2 and 3.
  3498. return;
  3499. }
  3500. else {
  3501. throw new Error('Invalid mapping: ' + JSON.stringify({
  3502. generated: aGenerated,
  3503. source: aSource,
  3504. original: aOriginal,
  3505. name: aName
  3506. }));
  3507. }
  3508. };
  3509. /**
  3510. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  3511. * specified by the source map format.
  3512. */
  3513. SourceMapGenerator.prototype._serializeMappings =
  3514. function SourceMapGenerator_serializeMappings() {
  3515. var previousGeneratedColumn = 0;
  3516. var previousGeneratedLine = 1;
  3517. var previousOriginalColumn = 0;
  3518. var previousOriginalLine = 0;
  3519. var previousName = 0;
  3520. var previousSource = 0;
  3521. var result = '';
  3522. var mapping;
  3523. var mappings = this._mappings.toArray();
  3524. for (var i = 0, len = mappings.length; i < len; i++) {
  3525. mapping = mappings[i];
  3526. if (mapping.generatedLine !== previousGeneratedLine) {
  3527. previousGeneratedColumn = 0;
  3528. while (mapping.generatedLine !== previousGeneratedLine) {
  3529. result += ';';
  3530. previousGeneratedLine++;
  3531. }
  3532. }
  3533. else {
  3534. if (i > 0) {
  3535. if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
  3536. continue;
  3537. }
  3538. result += ',';
  3539. }
  3540. }
  3541. result += base64VLQ.encode(mapping.generatedColumn
  3542. - previousGeneratedColumn);
  3543. previousGeneratedColumn = mapping.generatedColumn;
  3544. if (mapping.source != null) {
  3545. result += base64VLQ.encode(this._sources.indexOf(mapping.source)
  3546. - previousSource);
  3547. previousSource = this._sources.indexOf(mapping.source);
  3548. // lines are stored 0-based in SourceMap spec version 3
  3549. result += base64VLQ.encode(mapping.originalLine - 1
  3550. - previousOriginalLine);
  3551. previousOriginalLine = mapping.originalLine - 1;
  3552. result += base64VLQ.encode(mapping.originalColumn
  3553. - previousOriginalColumn);
  3554. previousOriginalColumn = mapping.originalColumn;
  3555. if (mapping.name != null) {
  3556. result += base64VLQ.encode(this._names.indexOf(mapping.name)
  3557. - previousName);
  3558. previousName = this._names.indexOf(mapping.name);
  3559. }
  3560. }
  3561. }
  3562. return result;
  3563. };
  3564. SourceMapGenerator.prototype._generateSourcesContent =
  3565. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  3566. return aSources.map(function (source) {
  3567. if (!this._sourcesContents) {
  3568. return null;
  3569. }
  3570. if (aSourceRoot != null) {
  3571. source = util.relative(aSourceRoot, source);
  3572. }
  3573. var key = util.toSetString(source);
  3574. return Object.prototype.hasOwnProperty.call(this._sourcesContents,
  3575. key)
  3576. ? this._sourcesContents[key]
  3577. : null;
  3578. }, this);
  3579. };
  3580. /**
  3581. * Externalize the source map.
  3582. */
  3583. SourceMapGenerator.prototype.toJSON =
  3584. function SourceMapGenerator_toJSON() {
  3585. var map = {
  3586. version: this._version,
  3587. sources: this._sources.toArray(),
  3588. names: this._names.toArray(),
  3589. mappings: this._serializeMappings()
  3590. };
  3591. if (this._file != null) {
  3592. map.file = this._file;
  3593. }
  3594. if (this._sourceRoot != null) {
  3595. map.sourceRoot = this._sourceRoot;
  3596. }
  3597. if (this._sourcesContents) {
  3598. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  3599. }
  3600. return map;
  3601. };
  3602. /**
  3603. * Render the source map being generated to a string.
  3604. */
  3605. SourceMapGenerator.prototype.toString =
  3606. function SourceMapGenerator_toString() {
  3607. return JSON.stringify(this);
  3608. };
  3609. exports.SourceMapGenerator = SourceMapGenerator;
  3610. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3611. /***/ },
  3612. /***/ 464:
  3613. /***/ function(module, exports, __webpack_require__) {
  3614. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  3615. /*
  3616. * Copyright 2011 Mozilla Foundation and contributors
  3617. * Licensed under the New BSD license. See LICENSE or:
  3618. * http://opensource.org/licenses/BSD-3-Clause
  3619. *
  3620. * Based on the Base 64 VLQ implementation in Closure Compiler:
  3621. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  3622. *
  3623. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  3624. * Redistribution and use in source and binary forms, with or without
  3625. * modification, are permitted provided that the following conditions are
  3626. * met:
  3627. *
  3628. * * Redistributions of source code must retain the above copyright
  3629. * notice, this list of conditions and the following disclaimer.
  3630. * * Redistributions in binary form must reproduce the above
  3631. * copyright notice, this list of conditions and the following
  3632. * disclaimer in the documentation and/or other materials provided
  3633. * with the distribution.
  3634. * * Neither the name of Google Inc. nor the names of its
  3635. * contributors may be used to endorse or promote products derived
  3636. * from this software without specific prior written permission.
  3637. *
  3638. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  3639. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  3640. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  3641. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  3642. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  3643. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3644. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  3645. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3646. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3647. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  3648. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3649. */
  3650. if (false) {
  3651. var define = require('amdefine')(module, require);
  3652. }
  3653. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  3654. var base64 = __webpack_require__(465);
  3655. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  3656. // length quantities we use in the source map spec, the first bit is the sign,
  3657. // the next four bits are the actual value, and the 6th bit is the
  3658. // continuation bit. The continuation bit tells us whether there are more
  3659. // digits in this value following this digit.
  3660. //
  3661. // Continuation
  3662. // | Sign
  3663. // | |
  3664. // V V
  3665. // 101011
  3666. var VLQ_BASE_SHIFT = 5;
  3667. // binary: 100000
  3668. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  3669. // binary: 011111
  3670. var VLQ_BASE_MASK = VLQ_BASE - 1;
  3671. // binary: 100000
  3672. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  3673. /**
  3674. * Converts from a two-complement value to a value where the sign bit is
  3675. * placed in the least significant bit. For example, as decimals:
  3676. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  3677. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  3678. */
  3679. function toVLQSigned(aValue) {
  3680. return aValue < 0
  3681. ? ((-aValue) << 1) + 1
  3682. : (aValue << 1) + 0;
  3683. }
  3684. /**
  3685. * Converts to a two-complement value from a value where the sign bit is
  3686. * placed in the least significant bit. For example, as decimals:
  3687. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  3688. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  3689. */
  3690. function fromVLQSigned(aValue) {
  3691. var isNegative = (aValue & 1) === 1;
  3692. var shifted = aValue >> 1;
  3693. return isNegative
  3694. ? -shifted
  3695. : shifted;
  3696. }
  3697. /**
  3698. * Returns the base 64 VLQ encoded value.
  3699. */
  3700. exports.encode = function base64VLQ_encode(aValue) {
  3701. var encoded = "";
  3702. var digit;
  3703. var vlq = toVLQSigned(aValue);
  3704. do {
  3705. digit = vlq & VLQ_BASE_MASK;
  3706. vlq >>>= VLQ_BASE_SHIFT;
  3707. if (vlq > 0) {
  3708. // There are still more digits in this value, so we must make sure the
  3709. // continuation bit is marked.
  3710. digit |= VLQ_CONTINUATION_BIT;
  3711. }
  3712. encoded += base64.encode(digit);
  3713. } while (vlq > 0);
  3714. return encoded;
  3715. };
  3716. /**
  3717. * Decodes the next base 64 VLQ value from the given string and returns the
  3718. * value and the rest of the string via the out parameter.
  3719. */
  3720. exports.decode = function base64VLQ_decode(aStr, aOutParam) {
  3721. var i = 0;
  3722. var strLen = aStr.length;
  3723. var result = 0;
  3724. var shift = 0;
  3725. var continuation, digit;
  3726. do {
  3727. if (i >= strLen) {
  3728. throw new Error("Expected more digits in base 64 VLQ value.");
  3729. }
  3730. digit = base64.decode(aStr.charAt(i++));
  3731. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  3732. digit &= VLQ_BASE_MASK;
  3733. result = result + (digit << shift);
  3734. shift += VLQ_BASE_SHIFT;
  3735. } while (continuation);
  3736. aOutParam.value = fromVLQSigned(result);
  3737. aOutParam.rest = aStr.slice(i);
  3738. };
  3739. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3740. /***/ },
  3741. /***/ 465:
  3742. /***/ function(module, exports, __webpack_require__) {
  3743. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  3744. /*
  3745. * Copyright 2011 Mozilla Foundation and contributors
  3746. * Licensed under the New BSD license. See LICENSE or:
  3747. * http://opensource.org/licenses/BSD-3-Clause
  3748. */
  3749. if (false) {
  3750. var define = require('amdefine')(module, require);
  3751. }
  3752. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  3753. var charToIntMap = {};
  3754. var intToCharMap = {};
  3755. 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  3756. .split('')
  3757. .forEach(function (ch, index) {
  3758. charToIntMap[ch] = index;
  3759. intToCharMap[index] = ch;
  3760. });
  3761. /**
  3762. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  3763. */
  3764. exports.encode = function base64_encode(aNumber) {
  3765. if (aNumber in intToCharMap) {
  3766. return intToCharMap[aNumber];
  3767. }
  3768. throw new TypeError("Must be between 0 and 63: " + aNumber);
  3769. };
  3770. /**
  3771. * Decode a single base 64 digit to an integer.
  3772. */
  3773. exports.decode = function base64_decode(aChar) {
  3774. if (aChar in charToIntMap) {
  3775. return charToIntMap[aChar];
  3776. }
  3777. throw new TypeError("Not a valid base 64 digit: " + aChar);
  3778. };
  3779. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3780. /***/ },
  3781. /***/ 466:
  3782. /***/ function(module, exports, __webpack_require__) {
  3783. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  3784. /*
  3785. * Copyright 2011 Mozilla Foundation and contributors
  3786. * Licensed under the New BSD license. See LICENSE or:
  3787. * http://opensource.org/licenses/BSD-3-Clause
  3788. */
  3789. if (false) {
  3790. var define = require('amdefine')(module, require);
  3791. }
  3792. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  3793. /**
  3794. * This is a helper function for getting values from parameter/options
  3795. * objects.
  3796. *
  3797. * @param args The object we are extracting values from
  3798. * @param name The name of the property we are getting.
  3799. * @param defaultValue An optional value to return if the property is missing
  3800. * from the object. If this is not specified and the property is missing, an
  3801. * error will be thrown.
  3802. */
  3803. function getArg(aArgs, aName, aDefaultValue) {
  3804. if (aName in aArgs) {
  3805. return aArgs[aName];
  3806. } else if (arguments.length === 3) {
  3807. return aDefaultValue;
  3808. } else {
  3809. throw new Error('"' + aName + '" is a required argument.');
  3810. }
  3811. }
  3812. exports.getArg = getArg;
  3813. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
  3814. var dataUrlRegexp = /^data:.+\,.+$/;
  3815. function urlParse(aUrl) {
  3816. var match = aUrl.match(urlRegexp);
  3817. if (!match) {
  3818. return null;
  3819. }
  3820. return {
  3821. scheme: match[1],
  3822. auth: match[2],
  3823. host: match[3],
  3824. port: match[4],
  3825. path: match[5]
  3826. };
  3827. }
  3828. exports.urlParse = urlParse;
  3829. function urlGenerate(aParsedUrl) {
  3830. var url = '';
  3831. if (aParsedUrl.scheme) {
  3832. url += aParsedUrl.scheme + ':';
  3833. }
  3834. url += '//';
  3835. if (aParsedUrl.auth) {
  3836. url += aParsedUrl.auth + '@';
  3837. }
  3838. if (aParsedUrl.host) {
  3839. url += aParsedUrl.host;
  3840. }
  3841. if (aParsedUrl.port) {
  3842. url += ":" + aParsedUrl.port
  3843. }
  3844. if (aParsedUrl.path) {
  3845. url += aParsedUrl.path;
  3846. }
  3847. return url;
  3848. }
  3849. exports.urlGenerate = urlGenerate;
  3850. /**
  3851. * Normalizes a path, or the path portion of a URL:
  3852. *
  3853. * - Replaces consequtive slashes with one slash.
  3854. * - Removes unnecessary '.' parts.
  3855. * - Removes unnecessary '<dir>/..' parts.
  3856. *
  3857. * Based on code in the Node.js 'path' core module.
  3858. *
  3859. * @param aPath The path or url to normalize.
  3860. */
  3861. function normalize(aPath) {
  3862. var path = aPath;
  3863. var url = urlParse(aPath);
  3864. if (url) {
  3865. if (!url.path) {
  3866. return aPath;
  3867. }
  3868. path = url.path;
  3869. }
  3870. var isAbsolute = (path.charAt(0) === '/');
  3871. var parts = path.split(/\/+/);
  3872. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  3873. part = parts[i];
  3874. if (part === '.') {
  3875. parts.splice(i, 1);
  3876. } else if (part === '..') {
  3877. up++;
  3878. } else if (up > 0) {
  3879. if (part === '') {
  3880. // The first part is blank if the path is absolute. Trying to go
  3881. // above the root is a no-op. Therefore we can remove all '..' parts
  3882. // directly after the root.
  3883. parts.splice(i + 1, up);
  3884. up = 0;
  3885. } else {
  3886. parts.splice(i, 2);
  3887. up--;
  3888. }
  3889. }
  3890. }
  3891. path = parts.join('/');
  3892. if (path === '') {
  3893. path = isAbsolute ? '/' : '.';
  3894. }
  3895. if (url) {
  3896. url.path = path;
  3897. return urlGenerate(url);
  3898. }
  3899. return path;
  3900. }
  3901. exports.normalize = normalize;
  3902. /**
  3903. * Joins two paths/URLs.
  3904. *
  3905. * @param aRoot The root path or URL.
  3906. * @param aPath The path or URL to be joined with the root.
  3907. *
  3908. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  3909. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  3910. * first.
  3911. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  3912. * is updated with the result and aRoot is returned. Otherwise the result
  3913. * is returned.
  3914. * - If aPath is absolute, the result is aPath.
  3915. * - Otherwise the two paths are joined with a slash.
  3916. * - Joining for example 'http://' and 'www.example.com' is also supported.
  3917. */
  3918. function join(aRoot, aPath) {
  3919. if (aRoot === "") {
  3920. aRoot = ".";
  3921. }
  3922. if (aPath === "") {
  3923. aPath = ".";
  3924. }
  3925. var aPathUrl = urlParse(aPath);
  3926. var aRootUrl = urlParse(aRoot);
  3927. if (aRootUrl) {
  3928. aRoot = aRootUrl.path || '/';
  3929. }
  3930. // `join(foo, '//www.example.org')`
  3931. if (aPathUrl && !aPathUrl.scheme) {
  3932. if (aRootUrl) {
  3933. aPathUrl.scheme = aRootUrl.scheme;
  3934. }
  3935. return urlGenerate(aPathUrl);
  3936. }
  3937. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  3938. return aPath;
  3939. }
  3940. // `join('http://', 'www.example.com')`
  3941. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  3942. aRootUrl.host = aPath;
  3943. return urlGenerate(aRootUrl);
  3944. }
  3945. var joined = aPath.charAt(0) === '/'
  3946. ? aPath
  3947. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  3948. if (aRootUrl) {
  3949. aRootUrl.path = joined;
  3950. return urlGenerate(aRootUrl);
  3951. }
  3952. return joined;
  3953. }
  3954. exports.join = join;
  3955. /**
  3956. * Make a path relative to a URL or another path.
  3957. *
  3958. * @param aRoot The root path or URL.
  3959. * @param aPath The path or URL to be made relative to aRoot.
  3960. */
  3961. function relative(aRoot, aPath) {
  3962. if (aRoot === "") {
  3963. aRoot = ".";
  3964. }
  3965. aRoot = aRoot.replace(/\/$/, '');
  3966. // XXX: It is possible to remove this block, and the tests still pass!
  3967. var url = urlParse(aRoot);
  3968. if (aPath.charAt(0) == "/" && url && url.path == "/") {
  3969. return aPath.slice(1);
  3970. }
  3971. return aPath.indexOf(aRoot + '/') === 0
  3972. ? aPath.substr(aRoot.length + 1)
  3973. : aPath;
  3974. }
  3975. exports.relative = relative;
  3976. /**
  3977. * Because behavior goes wacky when you set `__proto__` on objects, we
  3978. * have to prefix all the strings in our set with an arbitrary character.
  3979. *
  3980. * See https://github.com/mozilla/source-map/pull/31 and
  3981. * https://github.com/mozilla/source-map/issues/30
  3982. *
  3983. * @param String aStr
  3984. */
  3985. function toSetString(aStr) {
  3986. return '$' + aStr;
  3987. }
  3988. exports.toSetString = toSetString;
  3989. function fromSetString(aStr) {
  3990. return aStr.substr(1);
  3991. }
  3992. exports.fromSetString = fromSetString;
  3993. function strcmp(aStr1, aStr2) {
  3994. var s1 = aStr1 || "";
  3995. var s2 = aStr2 || "";
  3996. return (s1 > s2) - (s1 < s2);
  3997. }
  3998. /**
  3999. * Comparator between two mappings where the original positions are compared.
  4000. *
  4001. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  4002. * mappings with the same original source/line/column, but different generated
  4003. * line and column the same. Useful when searching for a mapping with a
  4004. * stubbed out mapping.
  4005. */
  4006. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  4007. var cmp;
  4008. cmp = strcmp(mappingA.source, mappingB.source);
  4009. if (cmp) {
  4010. return cmp;
  4011. }
  4012. cmp = mappingA.originalLine - mappingB.originalLine;
  4013. if (cmp) {
  4014. return cmp;
  4015. }
  4016. cmp = mappingA.originalColumn - mappingB.originalColumn;
  4017. if (cmp || onlyCompareOriginal) {
  4018. return cmp;
  4019. }
  4020. cmp = strcmp(mappingA.name, mappingB.name);
  4021. if (cmp) {
  4022. return cmp;
  4023. }
  4024. cmp = mappingA.generatedLine - mappingB.generatedLine;
  4025. if (cmp) {
  4026. return cmp;
  4027. }
  4028. return mappingA.generatedColumn - mappingB.generatedColumn;
  4029. };
  4030. exports.compareByOriginalPositions = compareByOriginalPositions;
  4031. /**
  4032. * Comparator between two mappings where the generated positions are
  4033. * compared.
  4034. *
  4035. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  4036. * mappings with the same generated line and column, but different
  4037. * source/name/original line and column the same. Useful when searching for a
  4038. * mapping with a stubbed out mapping.
  4039. */
  4040. function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
  4041. var cmp;
  4042. cmp = mappingA.generatedLine - mappingB.generatedLine;
  4043. if (cmp) {
  4044. return cmp;
  4045. }
  4046. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  4047. if (cmp || onlyCompareGenerated) {
  4048. return cmp;
  4049. }
  4050. cmp = strcmp(mappingA.source, mappingB.source);
  4051. if (cmp) {
  4052. return cmp;
  4053. }
  4054. cmp = mappingA.originalLine - mappingB.originalLine;
  4055. if (cmp) {
  4056. return cmp;
  4057. }
  4058. cmp = mappingA.originalColumn - mappingB.originalColumn;
  4059. if (cmp) {
  4060. return cmp;
  4061. }
  4062. return strcmp(mappingA.name, mappingB.name);
  4063. };
  4064. exports.compareByGeneratedPositions = compareByGeneratedPositions;
  4065. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4066. /***/ },
  4067. /***/ 467:
  4068. /***/ function(module, exports, __webpack_require__) {
  4069. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  4070. /*
  4071. * Copyright 2011 Mozilla Foundation and contributors
  4072. * Licensed under the New BSD license. See LICENSE or:
  4073. * http://opensource.org/licenses/BSD-3-Clause
  4074. */
  4075. if (false) {
  4076. var define = require('amdefine')(module, require);
  4077. }
  4078. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  4079. var util = __webpack_require__(466);
  4080. /**
  4081. * A data structure which is a combination of an array and a set. Adding a new
  4082. * member is O(1), testing for membership is O(1), and finding the index of an
  4083. * element is O(1). Removing elements from the set is not supported. Only
  4084. * strings are supported for membership.
  4085. */
  4086. function ArraySet() {
  4087. this._array = [];
  4088. this._set = {};
  4089. }
  4090. /**
  4091. * Static method for creating ArraySet instances from an existing array.
  4092. */
  4093. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  4094. var set = new ArraySet();
  4095. for (var i = 0, len = aArray.length; i < len; i++) {
  4096. set.add(aArray[i], aAllowDuplicates);
  4097. }
  4098. return set;
  4099. };
  4100. /**
  4101. * Add the given string to this set.
  4102. *
  4103. * @param String aStr
  4104. */
  4105. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  4106. var isDuplicate = this.has(aStr);
  4107. var idx = this._array.length;
  4108. if (!isDuplicate || aAllowDuplicates) {
  4109. this._array.push(aStr);
  4110. }
  4111. if (!isDuplicate) {
  4112. this._set[util.toSetString(aStr)] = idx;
  4113. }
  4114. };
  4115. /**
  4116. * Is the given string a member of this set?
  4117. *
  4118. * @param String aStr
  4119. */
  4120. ArraySet.prototype.has = function ArraySet_has(aStr) {
  4121. return Object.prototype.hasOwnProperty.call(this._set,
  4122. util.toSetString(aStr));
  4123. };
  4124. /**
  4125. * What is the index of the given string in the array?
  4126. *
  4127. * @param String aStr
  4128. */
  4129. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  4130. if (this.has(aStr)) {
  4131. return this._set[util.toSetString(aStr)];
  4132. }
  4133. throw new Error('"' + aStr + '" is not in the set.');
  4134. };
  4135. /**
  4136. * What is the element at the given index?
  4137. *
  4138. * @param Number aIdx
  4139. */
  4140. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  4141. if (aIdx >= 0 && aIdx < this._array.length) {
  4142. return this._array[aIdx];
  4143. }
  4144. throw new Error('No element indexed by ' + aIdx);
  4145. };
  4146. /**
  4147. * Returns the array representation of this set (which has the proper indices
  4148. * indicated by indexOf). Note that this is a copy of the internal array used
  4149. * for storing the members so that no one can mess with internal state.
  4150. */
  4151. ArraySet.prototype.toArray = function ArraySet_toArray() {
  4152. return this._array.slice();
  4153. };
  4154. exports.ArraySet = ArraySet;
  4155. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4156. /***/ },
  4157. /***/ 468:
  4158. /***/ function(module, exports, __webpack_require__) {
  4159. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  4160. /*
  4161. * Copyright 2014 Mozilla Foundation and contributors
  4162. * Licensed under the New BSD license. See LICENSE or:
  4163. * http://opensource.org/licenses/BSD-3-Clause
  4164. */
  4165. if (false) {
  4166. var define = require('amdefine')(module, require);
  4167. }
  4168. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  4169. var util = __webpack_require__(466);
  4170. /**
  4171. * Determine whether mappingB is after mappingA with respect to generated
  4172. * position.
  4173. */
  4174. function generatedPositionAfter(mappingA, mappingB) {
  4175. // Optimized for most common case
  4176. var lineA = mappingA.generatedLine;
  4177. var lineB = mappingB.generatedLine;
  4178. var columnA = mappingA.generatedColumn;
  4179. var columnB = mappingB.generatedColumn;
  4180. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  4181. util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
  4182. }
  4183. /**
  4184. * A data structure to provide a sorted view of accumulated mappings in a
  4185. * performance conscious manner. It trades a neglibable overhead in general
  4186. * case for a large speedup in case of mappings being added in order.
  4187. */
  4188. function MappingList() {
  4189. this._array = [];
  4190. this._sorted = true;
  4191. // Serves as infimum
  4192. this._last = {generatedLine: -1, generatedColumn: 0};
  4193. }
  4194. /**
  4195. * Iterate through internal items. This method takes the same arguments that
  4196. * `Array.prototype.forEach` takes.
  4197. *
  4198. * NOTE: The order of the mappings is NOT guaranteed.
  4199. */
  4200. MappingList.prototype.unsortedForEach =
  4201. function MappingList_forEach(aCallback, aThisArg) {
  4202. this._array.forEach(aCallback, aThisArg);
  4203. };
  4204. /**
  4205. * Add the given source mapping.
  4206. *
  4207. * @param Object aMapping
  4208. */
  4209. MappingList.prototype.add = function MappingList_add(aMapping) {
  4210. var mapping;
  4211. if (generatedPositionAfter(this._last, aMapping)) {
  4212. this._last = aMapping;
  4213. this._array.push(aMapping);
  4214. } else {
  4215. this._sorted = false;
  4216. this._array.push(aMapping);
  4217. }
  4218. };
  4219. /**
  4220. * Returns the flat, sorted array of mappings. The mappings are sorted by
  4221. * generated position.
  4222. *
  4223. * WARNING: This method returns internal data without copying, for
  4224. * performance. The return value must NOT be mutated, and should be treated as
  4225. * an immutable borrow. If you want to take ownership, you must make your own
  4226. * copy.
  4227. */
  4228. MappingList.prototype.toArray = function MappingList_toArray() {
  4229. if (!this._sorted) {
  4230. this._array.sort(util.compareByGeneratedPositions);
  4231. this._sorted = true;
  4232. }
  4233. return this._array;
  4234. };
  4235. exports.MappingList = MappingList;
  4236. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4237. /***/ },
  4238. /***/ 469:
  4239. /***/ function(module, exports, __webpack_require__) {
  4240. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  4241. /*
  4242. * Copyright 2011 Mozilla Foundation and contributors
  4243. * Licensed under the New BSD license. See LICENSE or:
  4244. * http://opensource.org/licenses/BSD-3-Clause
  4245. */
  4246. if (false) {
  4247. var define = require('amdefine')(module, require);
  4248. }
  4249. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  4250. var util = __webpack_require__(466);
  4251. var binarySearch = __webpack_require__(470);
  4252. var ArraySet = __webpack_require__(467).ArraySet;
  4253. var base64VLQ = __webpack_require__(464);
  4254. /**
  4255. * A SourceMapConsumer instance represents a parsed source map which we can
  4256. * query for information about the original file positions by giving it a file
  4257. * position in the generated source.
  4258. *
  4259. * The only parameter is the raw source map (either as a JSON string, or
  4260. * already parsed to an object). According to the spec, source maps have the
  4261. * following attributes:
  4262. *
  4263. * - version: Which version of the source map spec this map is following.
  4264. * - sources: An array of URLs to the original source files.
  4265. * - names: An array of identifiers which can be referrenced by individual mappings.
  4266. * - sourceRoot: Optional. The URL root from which all sources are relative.
  4267. * - sourcesContent: Optional. An array of contents of the original source files.
  4268. * - mappings: A string of base64 VLQs which contain the actual mappings.
  4269. * - file: Optional. The generated file this source map is associated with.
  4270. *
  4271. * Here is an example source map, taken from the source map spec[0]:
  4272. *
  4273. * {
  4274. * version : 3,
  4275. * file: "out.js",
  4276. * sourceRoot : "",
  4277. * sources: ["foo.js", "bar.js"],
  4278. * names: ["src", "maps", "are", "fun"],
  4279. * mappings: "AA,AB;;ABCDE;"
  4280. * }
  4281. *
  4282. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  4283. */
  4284. function SourceMapConsumer(aSourceMap) {
  4285. var sourceMap = aSourceMap;
  4286. if (typeof aSourceMap === 'string') {
  4287. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
  4288. }
  4289. var version = util.getArg(sourceMap, 'version');
  4290. var sources = util.getArg(sourceMap, 'sources');
  4291. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  4292. // requires the array) to play nice here.
  4293. var names = util.getArg(sourceMap, 'names', []);
  4294. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  4295. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  4296. var mappings = util.getArg(sourceMap, 'mappings');
  4297. var file = util.getArg(sourceMap, 'file', null);
  4298. // Once again, Sass deviates from the spec and supplies the version as a
  4299. // string rather than a number, so we use loose equality checking here.
  4300. if (version != this._version) {
  4301. throw new Error('Unsupported version: ' + version);
  4302. }
  4303. // Some source maps produce relative source paths like "./foo.js" instead of
  4304. // "foo.js". Normalize these first so that future comparisons will succeed.
  4305. // See bugzil.la/1090768.
  4306. sources = sources.map(util.normalize);
  4307. // Pass `true` below to allow duplicate names and sources. While source maps
  4308. // are intended to be compressed and deduplicated, the TypeScript compiler
  4309. // sometimes generates source maps with duplicates in them. See Github issue
  4310. // #72 and bugzil.la/889492.
  4311. this._names = ArraySet.fromArray(names, true);
  4312. this._sources = ArraySet.fromArray(sources, true);
  4313. this.sourceRoot = sourceRoot;
  4314. this.sourcesContent = sourcesContent;
  4315. this._mappings = mappings;
  4316. this.file = file;
  4317. }
  4318. /**
  4319. * Create a SourceMapConsumer from a SourceMapGenerator.
  4320. *
  4321. * @param SourceMapGenerator aSourceMap
  4322. * The source map that will be consumed.
  4323. * @returns SourceMapConsumer
  4324. */
  4325. SourceMapConsumer.fromSourceMap =
  4326. function SourceMapConsumer_fromSourceMap(aSourceMap) {
  4327. var smc = Object.create(SourceMapConsumer.prototype);
  4328. smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  4329. smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  4330. smc.sourceRoot = aSourceMap._sourceRoot;
  4331. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  4332. smc.sourceRoot);
  4333. smc.file = aSourceMap._file;
  4334. smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
  4335. smc.__originalMappings = aSourceMap._mappings.toArray().slice()
  4336. .sort(util.compareByOriginalPositions);
  4337. return smc;
  4338. };
  4339. /**
  4340. * The version of the source mapping spec that we are consuming.
  4341. */
  4342. SourceMapConsumer.prototype._version = 3;
  4343. /**
  4344. * The list of original sources.
  4345. */
  4346. Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
  4347. get: function () {
  4348. return this._sources.toArray().map(function (s) {
  4349. return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
  4350. }, this);
  4351. }
  4352. });
  4353. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  4354. // parsed mapping coordinates from the source map's "mappings" attribute. They
  4355. // are lazily instantiated, accessed via the `_generatedMappings` and
  4356. // `_originalMappings` getters respectively, and we only parse the mappings
  4357. // and create these arrays once queried for a source location. We jump through
  4358. // these hoops because there can be many thousands of mappings, and parsing
  4359. // them is expensive, so we only want to do it if we must.
  4360. //
  4361. // Each object in the arrays is of the form:
  4362. //
  4363. // {
  4364. // generatedLine: The line number in the generated code,
  4365. // generatedColumn: The column number in the generated code,
  4366. // source: The path to the original source file that generated this
  4367. // chunk of code,
  4368. // originalLine: The line number in the original source that
  4369. // corresponds to this chunk of generated code,
  4370. // originalColumn: The column number in the original source that
  4371. // corresponds to this chunk of generated code,
  4372. // name: The name of the original symbol which generated this chunk of
  4373. // code.
  4374. // }
  4375. //
  4376. // All properties except for `generatedLine` and `generatedColumn` can be
  4377. // `null`.
  4378. //
  4379. // `_generatedMappings` is ordered by the generated positions.
  4380. //
  4381. // `_originalMappings` is ordered by the original positions.
  4382. SourceMapConsumer.prototype.__generatedMappings = null;
  4383. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  4384. get: function () {
  4385. if (!this.__generatedMappings) {
  4386. this.__generatedMappings = [];
  4387. this.__originalMappings = [];
  4388. this._parseMappings(this._mappings, this.sourceRoot);
  4389. }
  4390. return this.__generatedMappings;
  4391. }
  4392. });
  4393. SourceMapConsumer.prototype.__originalMappings = null;
  4394. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  4395. get: function () {
  4396. if (!this.__originalMappings) {
  4397. this.__generatedMappings = [];
  4398. this.__originalMappings = [];
  4399. this._parseMappings(this._mappings, this.sourceRoot);
  4400. }
  4401. return this.__originalMappings;
  4402. }
  4403. });
  4404. SourceMapConsumer.prototype._nextCharIsMappingSeparator =
  4405. function SourceMapConsumer_nextCharIsMappingSeparator(aStr) {
  4406. var c = aStr.charAt(0);
  4407. return c === ";" || c === ",";
  4408. };
  4409. /**
  4410. * Parse the mappings in a string in to a data structure which we can easily
  4411. * query (the ordered arrays in the `this.__generatedMappings` and
  4412. * `this.__originalMappings` properties).
  4413. */
  4414. SourceMapConsumer.prototype._parseMappings =
  4415. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  4416. var generatedLine = 1;
  4417. var previousGeneratedColumn = 0;
  4418. var previousOriginalLine = 0;
  4419. var previousOriginalColumn = 0;
  4420. var previousSource = 0;
  4421. var previousName = 0;
  4422. var str = aStr;
  4423. var temp = {};
  4424. var mapping;
  4425. while (str.length > 0) {
  4426. if (str.charAt(0) === ';') {
  4427. generatedLine++;
  4428. str = str.slice(1);
  4429. previousGeneratedColumn = 0;
  4430. }
  4431. else if (str.charAt(0) === ',') {
  4432. str = str.slice(1);
  4433. }
  4434. else {
  4435. mapping = {};
  4436. mapping.generatedLine = generatedLine;
  4437. // Generated column.
  4438. base64VLQ.decode(str, temp);
  4439. mapping.generatedColumn = previousGeneratedColumn + temp.value;
  4440. previousGeneratedColumn = mapping.generatedColumn;
  4441. str = temp.rest;
  4442. if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
  4443. // Original source.
  4444. base64VLQ.decode(str, temp);
  4445. mapping.source = this._sources.at(previousSource + temp.value);
  4446. previousSource += temp.value;
  4447. str = temp.rest;
  4448. if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
  4449. throw new Error('Found a source, but no line and column');
  4450. }
  4451. // Original line.
  4452. base64VLQ.decode(str, temp);
  4453. mapping.originalLine = previousOriginalLine + temp.value;
  4454. previousOriginalLine = mapping.originalLine;
  4455. // Lines are stored 0-based
  4456. mapping.originalLine += 1;
  4457. str = temp.rest;
  4458. if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
  4459. throw new Error('Found a source and line, but no column');
  4460. }
  4461. // Original column.
  4462. base64VLQ.decode(str, temp);
  4463. mapping.originalColumn = previousOriginalColumn + temp.value;
  4464. previousOriginalColumn = mapping.originalColumn;
  4465. str = temp.rest;
  4466. if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
  4467. // Original name.
  4468. base64VLQ.decode(str, temp);
  4469. mapping.name = this._names.at(previousName + temp.value);
  4470. previousName += temp.value;
  4471. str = temp.rest;
  4472. }
  4473. }
  4474. this.__generatedMappings.push(mapping);
  4475. if (typeof mapping.originalLine === 'number') {
  4476. this.__originalMappings.push(mapping);
  4477. }
  4478. }
  4479. }
  4480. this.__generatedMappings.sort(util.compareByGeneratedPositions);
  4481. this.__originalMappings.sort(util.compareByOriginalPositions);
  4482. };
  4483. /**
  4484. * Find the mapping that best matches the hypothetical "needle" mapping that
  4485. * we are searching for in the given "haystack" of mappings.
  4486. */
  4487. SourceMapConsumer.prototype._findMapping =
  4488. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  4489. aColumnName, aComparator) {
  4490. // To return the position we are searching for, we must first find the
  4491. // mapping for the given position and then return the opposite position it
  4492. // points to. Because the mappings are sorted, we can use binary search to
  4493. // find the best mapping.
  4494. if (aNeedle[aLineName] <= 0) {
  4495. throw new TypeError('Line must be greater than or equal to 1, got '
  4496. + aNeedle[aLineName]);
  4497. }
  4498. if (aNeedle[aColumnName] < 0) {
  4499. throw new TypeError('Column must be greater than or equal to 0, got '
  4500. + aNeedle[aColumnName]);
  4501. }
  4502. return binarySearch.search(aNeedle, aMappings, aComparator);
  4503. };
  4504. /**
  4505. * Compute the last column for each generated mapping. The last column is
  4506. * inclusive.
  4507. */
  4508. SourceMapConsumer.prototype.computeColumnSpans =
  4509. function SourceMapConsumer_computeColumnSpans() {
  4510. for (var index = 0; index < this._generatedMappings.length; ++index) {
  4511. var mapping = this._generatedMappings[index];
  4512. // Mappings do not contain a field for the last generated columnt. We
  4513. // can come up with an optimistic estimate, however, by assuming that
  4514. // mappings are contiguous (i.e. given two consecutive mappings, the
  4515. // first mapping ends where the second one starts).
  4516. if (index + 1 < this._generatedMappings.length) {
  4517. var nextMapping = this._generatedMappings[index + 1];
  4518. if (mapping.generatedLine === nextMapping.generatedLine) {
  4519. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  4520. continue;
  4521. }
  4522. }
  4523. // The last mapping for each line spans the entire line.
  4524. mapping.lastGeneratedColumn = Infinity;
  4525. }
  4526. };
  4527. /**
  4528. * Returns the original source, line, and column information for the generated
  4529. * source's line and column positions provided. The only argument is an object
  4530. * with the following properties:
  4531. *
  4532. * - line: The line number in the generated source.
  4533. * - column: The column number in the generated source.
  4534. *
  4535. * and an object is returned with the following properties:
  4536. *
  4537. * - source: The original source file, or null.
  4538. * - line: The line number in the original source, or null.
  4539. * - column: The column number in the original source, or null.
  4540. * - name: The original identifier, or null.
  4541. */
  4542. SourceMapConsumer.prototype.originalPositionFor =
  4543. function SourceMapConsumer_originalPositionFor(aArgs) {
  4544. var needle = {
  4545. generatedLine: util.getArg(aArgs, 'line'),
  4546. generatedColumn: util.getArg(aArgs, 'column')
  4547. };
  4548. var index = this._findMapping(needle,
  4549. this._generatedMappings,
  4550. "generatedLine",
  4551. "generatedColumn",
  4552. util.compareByGeneratedPositions);
  4553. if (index >= 0) {
  4554. var mapping = this._generatedMappings[index];
  4555. if (mapping.generatedLine === needle.generatedLine) {
  4556. var source = util.getArg(mapping, 'source', null);
  4557. if (source != null && this.sourceRoot != null) {
  4558. source = util.join(this.sourceRoot, source);
  4559. }
  4560. return {
  4561. source: source,
  4562. line: util.getArg(mapping, 'originalLine', null),
  4563. column: util.getArg(mapping, 'originalColumn', null),
  4564. name: util.getArg(mapping, 'name', null)
  4565. };
  4566. }
  4567. }
  4568. return {
  4569. source: null,
  4570. line: null,
  4571. column: null,
  4572. name: null
  4573. };
  4574. };
  4575. /**
  4576. * Returns the original source content. The only argument is the url of the
  4577. * original source file. Returns null if no original source content is
  4578. * availible.
  4579. */
  4580. SourceMapConsumer.prototype.sourceContentFor =
  4581. function SourceMapConsumer_sourceContentFor(aSource) {
  4582. if (!this.sourcesContent) {
  4583. return null;
  4584. }
  4585. if (this.sourceRoot != null) {
  4586. aSource = util.relative(this.sourceRoot, aSource);
  4587. }
  4588. if (this._sources.has(aSource)) {
  4589. return this.sourcesContent[this._sources.indexOf(aSource)];
  4590. }
  4591. var url;
  4592. if (this.sourceRoot != null
  4593. && (url = util.urlParse(this.sourceRoot))) {
  4594. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  4595. // many users. We can help them out when they expect file:// URIs to
  4596. // behave like it would if they were running a local HTTP server. See
  4597. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  4598. var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
  4599. if (url.scheme == "file"
  4600. && this._sources.has(fileUriAbsPath)) {
  4601. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  4602. }
  4603. if ((!url.path || url.path == "/")
  4604. && this._sources.has("/" + aSource)) {
  4605. return this.sourcesContent[this._sources.indexOf("/" + aSource)];
  4606. }
  4607. }
  4608. throw new Error('"' + aSource + '" is not in the SourceMap.');
  4609. };
  4610. /**
  4611. * Returns the generated line and column information for the original source,
  4612. * line, and column positions provided. The only argument is an object with
  4613. * the following properties:
  4614. *
  4615. * - source: The filename of the original source.
  4616. * - line: The line number in the original source.
  4617. * - column: The column number in the original source.
  4618. *
  4619. * and an object is returned with the following properties:
  4620. *
  4621. * - line: The line number in the generated source, or null.
  4622. * - column: The column number in the generated source, or null.
  4623. */
  4624. SourceMapConsumer.prototype.generatedPositionFor =
  4625. function SourceMapConsumer_generatedPositionFor(aArgs) {
  4626. var needle = {
  4627. source: util.getArg(aArgs, 'source'),
  4628. originalLine: util.getArg(aArgs, 'line'),
  4629. originalColumn: util.getArg(aArgs, 'column')
  4630. };
  4631. if (this.sourceRoot != null) {
  4632. needle.source = util.relative(this.sourceRoot, needle.source);
  4633. }
  4634. var index = this._findMapping(needle,
  4635. this._originalMappings,
  4636. "originalLine",
  4637. "originalColumn",
  4638. util.compareByOriginalPositions);
  4639. if (index >= 0) {
  4640. var mapping = this._originalMappings[index];
  4641. return {
  4642. line: util.getArg(mapping, 'generatedLine', null),
  4643. column: util.getArg(mapping, 'generatedColumn', null),
  4644. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  4645. };
  4646. }
  4647. return {
  4648. line: null,
  4649. column: null,
  4650. lastColumn: null
  4651. };
  4652. };
  4653. /**
  4654. * Returns all generated line and column information for the original source
  4655. * and line provided. The only argument is an object with the following
  4656. * properties:
  4657. *
  4658. * - source: The filename of the original source.
  4659. * - line: The line number in the original source.
  4660. *
  4661. * and an array of objects is returned, each with the following properties:
  4662. *
  4663. * - line: The line number in the generated source, or null.
  4664. * - column: The column number in the generated source, or null.
  4665. */
  4666. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  4667. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  4668. // When there is no exact match, SourceMapConsumer.prototype._findMapping
  4669. // returns the index of the closest mapping less than the needle. By
  4670. // setting needle.originalColumn to Infinity, we thus find the last
  4671. // mapping for the given line, provided such a mapping exists.
  4672. var needle = {
  4673. source: util.getArg(aArgs, 'source'),
  4674. originalLine: util.getArg(aArgs, 'line'),
  4675. originalColumn: Infinity
  4676. };
  4677. if (this.sourceRoot != null) {
  4678. needle.source = util.relative(this.sourceRoot, needle.source);
  4679. }
  4680. var mappings = [];
  4681. var index = this._findMapping(needle,
  4682. this._originalMappings,
  4683. "originalLine",
  4684. "originalColumn",
  4685. util.compareByOriginalPositions);
  4686. if (index >= 0) {
  4687. var mapping = this._originalMappings[index];
  4688. while (mapping && mapping.originalLine === needle.originalLine) {
  4689. mappings.push({
  4690. line: util.getArg(mapping, 'generatedLine', null),
  4691. column: util.getArg(mapping, 'generatedColumn', null),
  4692. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  4693. });
  4694. mapping = this._originalMappings[--index];
  4695. }
  4696. }
  4697. return mappings.reverse();
  4698. };
  4699. SourceMapConsumer.GENERATED_ORDER = 1;
  4700. SourceMapConsumer.ORIGINAL_ORDER = 2;
  4701. /**
  4702. * Iterate over each mapping between an original source/line/column and a
  4703. * generated line/column in this source map.
  4704. *
  4705. * @param Function aCallback
  4706. * The function that is called with each mapping.
  4707. * @param Object aContext
  4708. * Optional. If specified, this object will be the value of `this` every
  4709. * time that `aCallback` is called.
  4710. * @param aOrder
  4711. * Either `SourceMapConsumer.GENERATED_ORDER` or
  4712. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  4713. * iterate over the mappings sorted by the generated file's line/column
  4714. * order or the original's source/line/column order, respectively. Defaults to
  4715. * `SourceMapConsumer.GENERATED_ORDER`.
  4716. */
  4717. SourceMapConsumer.prototype.eachMapping =
  4718. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  4719. var context = aContext || null;
  4720. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  4721. var mappings;
  4722. switch (order) {
  4723. case SourceMapConsumer.GENERATED_ORDER:
  4724. mappings = this._generatedMappings;
  4725. break;
  4726. case SourceMapConsumer.ORIGINAL_ORDER:
  4727. mappings = this._originalMappings;
  4728. break;
  4729. default:
  4730. throw new Error("Unknown order of iteration.");
  4731. }
  4732. var sourceRoot = this.sourceRoot;
  4733. mappings.map(function (mapping) {
  4734. var source = mapping.source;
  4735. if (source != null && sourceRoot != null) {
  4736. source = util.join(sourceRoot, source);
  4737. }
  4738. return {
  4739. source: source,
  4740. generatedLine: mapping.generatedLine,
  4741. generatedColumn: mapping.generatedColumn,
  4742. originalLine: mapping.originalLine,
  4743. originalColumn: mapping.originalColumn,
  4744. name: mapping.name
  4745. };
  4746. }).forEach(aCallback, context);
  4747. };
  4748. exports.SourceMapConsumer = SourceMapConsumer;
  4749. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4750. /***/ },
  4751. /***/ 470:
  4752. /***/ function(module, exports, __webpack_require__) {
  4753. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  4754. /*
  4755. * Copyright 2011 Mozilla Foundation and contributors
  4756. * Licensed under the New BSD license. See LICENSE or:
  4757. * http://opensource.org/licenses/BSD-3-Clause
  4758. */
  4759. if (false) {
  4760. var define = require('amdefine')(module, require);
  4761. }
  4762. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  4763. /**
  4764. * Recursive implementation of binary search.
  4765. *
  4766. * @param aLow Indices here and lower do not contain the needle.
  4767. * @param aHigh Indices here and higher do not contain the needle.
  4768. * @param aNeedle The element being searched for.
  4769. * @param aHaystack The non-empty array being searched.
  4770. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  4771. */
  4772. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
  4773. // This function terminates when one of the following is true:
  4774. //
  4775. // 1. We find the exact element we are looking for.
  4776. //
  4777. // 2. We did not find the exact element, but we can return the index of
  4778. // the next closest element that is less than that element.
  4779. //
  4780. // 3. We did not find the exact element, and there is no next-closest
  4781. // element which is less than the one we are searching for, so we
  4782. // return -1.
  4783. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  4784. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  4785. if (cmp === 0) {
  4786. // Found the element we are looking for.
  4787. return mid;
  4788. }
  4789. else if (cmp > 0) {
  4790. // aHaystack[mid] is greater than our needle.
  4791. if (aHigh - mid > 1) {
  4792. // The element is in the upper half.
  4793. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
  4794. }
  4795. // We did not find an exact match, return the next closest one
  4796. // (termination case 2).
  4797. return mid;
  4798. }
  4799. else {
  4800. // aHaystack[mid] is less than our needle.
  4801. if (mid - aLow > 1) {
  4802. // The element is in the lower half.
  4803. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
  4804. }
  4805. // The exact needle element was not found in this haystack. Determine if
  4806. // we are in termination case (2) or (3) and return the appropriate thing.
  4807. return aLow < 0 ? -1 : aLow;
  4808. }
  4809. }
  4810. /**
  4811. * This is an implementation of binary search which will always try and return
  4812. * the index of next lowest value checked if there is no exact hit. This is
  4813. * because mappings between original and generated line/col pairs are single
  4814. * points, and there is an implicit region between each of them, so a miss
  4815. * just means that you aren't on the very start of a region.
  4816. *
  4817. * @param aNeedle The element you are looking for.
  4818. * @param aHaystack The array that is being searched.
  4819. * @param aCompare A function which takes the needle and an element in the
  4820. * array and returns -1, 0, or 1 depending on whether the needle is less
  4821. * than, equal to, or greater than the element, respectively.
  4822. */
  4823. exports.search = function search(aNeedle, aHaystack, aCompare) {
  4824. if (aHaystack.length === 0) {
  4825. return -1;
  4826. }
  4827. return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
  4828. };
  4829. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4830. /***/ },
  4831. /***/ 471:
  4832. /***/ function(module, exports, __webpack_require__) {
  4833. var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- Mode: js; js-indent-level: 2; -*- */
  4834. /*
  4835. * Copyright 2011 Mozilla Foundation and contributors
  4836. * Licensed under the New BSD license. See LICENSE or:
  4837. * http://opensource.org/licenses/BSD-3-Clause
  4838. */
  4839. if (false) {
  4840. var define = require('amdefine')(module, require);
  4841. }
  4842. !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
  4843. var SourceMapGenerator = __webpack_require__(463).SourceMapGenerator;
  4844. var util = __webpack_require__(466);
  4845. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  4846. // operating systems these days (capturing the result).
  4847. var REGEX_NEWLINE = /(\r?\n)/;
  4848. // Newline character code for charCodeAt() comparisons
  4849. var NEWLINE_CODE = 10;
  4850. // Private symbol for identifying `SourceNode`s when multiple versions of
  4851. // the source-map library are loaded. This MUST NOT CHANGE across
  4852. // versions!
  4853. var isSourceNode = "$$$isSourceNode$$$";
  4854. /**
  4855. * SourceNodes provide a way to abstract over interpolating/concatenating
  4856. * snippets of generated JavaScript source code while maintaining the line and
  4857. * column information associated with the original source code.
  4858. *
  4859. * @param aLine The original line number.
  4860. * @param aColumn The original column number.
  4861. * @param aSource The original source's filename.
  4862. * @param aChunks Optional. An array of strings which are snippets of
  4863. * generated JS, or other SourceNodes.
  4864. * @param aName The original identifier.
  4865. */
  4866. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  4867. this.children = [];
  4868. this.sourceContents = {};
  4869. this.line = aLine == null ? null : aLine;
  4870. this.column = aColumn == null ? null : aColumn;
  4871. this.source = aSource == null ? null : aSource;
  4872. this.name = aName == null ? null : aName;
  4873. this[isSourceNode] = true;
  4874. if (aChunks != null) this.add(aChunks);
  4875. }
  4876. /**
  4877. * Creates a SourceNode from generated code and a SourceMapConsumer.
  4878. *
  4879. * @param aGeneratedCode The generated code
  4880. * @param aSourceMapConsumer The SourceMap for the generated code
  4881. * @param aRelativePath Optional. The path that relative sources in the
  4882. * SourceMapConsumer should be relative to.
  4883. */
  4884. SourceNode.fromStringWithSourceMap =
  4885. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  4886. // The SourceNode we want to fill with the generated code
  4887. // and the SourceMap
  4888. var node = new SourceNode();
  4889. // All even indices of this array are one line of the generated code,
  4890. // while all odd indices are the newlines between two adjacent lines
  4891. // (since `REGEX_NEWLINE` captures its match).
  4892. // Processed fragments are removed from this array, by calling `shiftNextLine`.
  4893. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  4894. var shiftNextLine = function() {
  4895. var lineContents = remainingLines.shift();
  4896. // The last line of a file might not have a newline.
  4897. var newLine = remainingLines.shift() || "";
  4898. return lineContents + newLine;
  4899. };
  4900. // We need to remember the position of "remainingLines"
  4901. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  4902. // The generate SourceNodes we need a code range.
  4903. // To extract it current and last mapping is used.
  4904. // Here we store the last mapping.
  4905. var lastMapping = null;
  4906. aSourceMapConsumer.eachMapping(function (mapping) {
  4907. if (lastMapping !== null) {
  4908. // We add the code from "lastMapping" to "mapping":
  4909. // First check if there is a new line in between.
  4910. if (lastGeneratedLine < mapping.generatedLine) {
  4911. var code = "";
  4912. // Associate first line with "lastMapping"
  4913. addMappingWithCode(lastMapping, shiftNextLine());
  4914. lastGeneratedLine++;
  4915. lastGeneratedColumn = 0;
  4916. // The remaining code is added without mapping
  4917. } else {
  4918. // There is no new line in between.
  4919. // Associate the code between "lastGeneratedColumn" and
  4920. // "mapping.generatedColumn" with "lastMapping"
  4921. var nextLine = remainingLines[0];
  4922. var code = nextLine.substr(0, mapping.generatedColumn -
  4923. lastGeneratedColumn);
  4924. remainingLines[0] = nextLine.substr(mapping.generatedColumn -
  4925. lastGeneratedColumn);
  4926. lastGeneratedColumn = mapping.generatedColumn;
  4927. addMappingWithCode(lastMapping, code);
  4928. // No more remaining code, continue
  4929. lastMapping = mapping;
  4930. return;
  4931. }
  4932. }
  4933. // We add the generated code until the first mapping
  4934. // to the SourceNode without any mapping.
  4935. // Each line is added as separate string.
  4936. while (lastGeneratedLine < mapping.generatedLine) {
  4937. node.add(shiftNextLine());
  4938. lastGeneratedLine++;
  4939. }
  4940. if (lastGeneratedColumn < mapping.generatedColumn) {
  4941. var nextLine = remainingLines[0];
  4942. node.add(nextLine.substr(0, mapping.generatedColumn));
  4943. remainingLines[0] = nextLine.substr(mapping.generatedColumn);
  4944. lastGeneratedColumn = mapping.generatedColumn;
  4945. }
  4946. lastMapping = mapping;
  4947. }, this);
  4948. // We have processed all mappings.
  4949. if (remainingLines.length > 0) {
  4950. if (lastMapping) {
  4951. // Associate the remaining code in the current line with "lastMapping"
  4952. addMappingWithCode(lastMapping, shiftNextLine());
  4953. }
  4954. // and add the remaining lines without any mapping
  4955. node.add(remainingLines.join(""));
  4956. }
  4957. // Copy sourcesContent into SourceNode
  4958. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  4959. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  4960. if (content != null) {
  4961. if (aRelativePath != null) {
  4962. sourceFile = util.join(aRelativePath, sourceFile);
  4963. }
  4964. node.setSourceContent(sourceFile, content);
  4965. }
  4966. });
  4967. return node;
  4968. function addMappingWithCode(mapping, code) {
  4969. if (mapping === null || mapping.source === undefined) {
  4970. node.add(code);
  4971. } else {
  4972. var source = aRelativePath
  4973. ? util.join(aRelativePath, mapping.source)
  4974. : mapping.source;
  4975. node.add(new SourceNode(mapping.originalLine,
  4976. mapping.originalColumn,
  4977. source,
  4978. code,
  4979. mapping.name));
  4980. }
  4981. }
  4982. };
  4983. /**
  4984. * Add a chunk of generated JS to this source node.
  4985. *
  4986. * @param aChunk A string snippet of generated JS code, another instance of
  4987. * SourceNode, or an array where each member is one of those things.
  4988. */
  4989. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  4990. if (Array.isArray(aChunk)) {
  4991. aChunk.forEach(function (chunk) {
  4992. this.add(chunk);
  4993. }, this);
  4994. }
  4995. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  4996. if (aChunk) {
  4997. this.children.push(aChunk);
  4998. }
  4999. }
  5000. else {
  5001. throw new TypeError(
  5002. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  5003. );
  5004. }
  5005. return this;
  5006. };
  5007. /**
  5008. * Add a chunk of generated JS to the beginning of this source node.
  5009. *
  5010. * @param aChunk A string snippet of generated JS code, another instance of
  5011. * SourceNode, or an array where each member is one of those things.
  5012. */
  5013. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  5014. if (Array.isArray(aChunk)) {
  5015. for (var i = aChunk.length-1; i >= 0; i--) {
  5016. this.prepend(aChunk[i]);
  5017. }
  5018. }
  5019. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  5020. this.children.unshift(aChunk);
  5021. }
  5022. else {
  5023. throw new TypeError(
  5024. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  5025. );
  5026. }
  5027. return this;
  5028. };
  5029. /**
  5030. * Walk over the tree of JS snippets in this node and its children. The
  5031. * walking function is called once for each snippet of JS and is passed that
  5032. * snippet and the its original associated source's line/column location.
  5033. *
  5034. * @param aFn The traversal function.
  5035. */
  5036. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  5037. var chunk;
  5038. for (var i = 0, len = this.children.length; i < len; i++) {
  5039. chunk = this.children[i];
  5040. if (chunk[isSourceNode]) {
  5041. chunk.walk(aFn);
  5042. }
  5043. else {
  5044. if (chunk !== '') {
  5045. aFn(chunk, { source: this.source,
  5046. line: this.line,
  5047. column: this.column,
  5048. name: this.name });
  5049. }
  5050. }
  5051. }
  5052. };
  5053. /**
  5054. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  5055. * each of `this.children`.
  5056. *
  5057. * @param aSep The separator.
  5058. */
  5059. SourceNode.prototype.join = function SourceNode_join(aSep) {
  5060. var newChildren;
  5061. var i;
  5062. var len = this.children.length;
  5063. if (len > 0) {
  5064. newChildren = [];
  5065. for (i = 0; i < len-1; i++) {
  5066. newChildren.push(this.children[i]);
  5067. newChildren.push(aSep);
  5068. }
  5069. newChildren.push(this.children[i]);
  5070. this.children = newChildren;
  5071. }
  5072. return this;
  5073. };
  5074. /**
  5075. * Call String.prototype.replace on the very right-most source snippet. Useful
  5076. * for trimming whitespace from the end of a source node, etc.
  5077. *
  5078. * @param aPattern The pattern to replace.
  5079. * @param aReplacement The thing to replace the pattern with.
  5080. */
  5081. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  5082. var lastChild = this.children[this.children.length - 1];
  5083. if (lastChild[isSourceNode]) {
  5084. lastChild.replaceRight(aPattern, aReplacement);
  5085. }
  5086. else if (typeof lastChild === 'string') {
  5087. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  5088. }
  5089. else {
  5090. this.children.push(''.replace(aPattern, aReplacement));
  5091. }
  5092. return this;
  5093. };
  5094. /**
  5095. * Set the source content for a source file. This will be added to the SourceMapGenerator
  5096. * in the sourcesContent field.
  5097. *
  5098. * @param aSourceFile The filename of the source file
  5099. * @param aSourceContent The content of the source file
  5100. */
  5101. SourceNode.prototype.setSourceContent =
  5102. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  5103. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  5104. };
  5105. /**
  5106. * Walk over the tree of SourceNodes. The walking function is called for each
  5107. * source file content and is passed the filename and source content.
  5108. *
  5109. * @param aFn The traversal function.
  5110. */
  5111. SourceNode.prototype.walkSourceContents =
  5112. function SourceNode_walkSourceContents(aFn) {
  5113. for (var i = 0, len = this.children.length; i < len; i++) {
  5114. if (this.children[i][isSourceNode]) {
  5115. this.children[i].walkSourceContents(aFn);
  5116. }
  5117. }
  5118. var sources = Object.keys(this.sourceContents);
  5119. for (var i = 0, len = sources.length; i < len; i++) {
  5120. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  5121. }
  5122. };
  5123. /**
  5124. * Return the string representation of this source node. Walks over the tree
  5125. * and concatenates all the various snippets together to one string.
  5126. */
  5127. SourceNode.prototype.toString = function SourceNode_toString() {
  5128. var str = "";
  5129. this.walk(function (chunk) {
  5130. str += chunk;
  5131. });
  5132. return str;
  5133. };
  5134. /**
  5135. * Returns the string representation of this source node along with a source
  5136. * map.
  5137. */
  5138. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  5139. var generated = {
  5140. code: "",
  5141. line: 1,
  5142. column: 0
  5143. };
  5144. var map = new SourceMapGenerator(aArgs);
  5145. var sourceMappingActive = false;
  5146. var lastOriginalSource = null;
  5147. var lastOriginalLine = null;
  5148. var lastOriginalColumn = null;
  5149. var lastOriginalName = null;
  5150. this.walk(function (chunk, original) {
  5151. generated.code += chunk;
  5152. if (original.source !== null
  5153. && original.line !== null
  5154. && original.column !== null) {
  5155. if(lastOriginalSource !== original.source
  5156. || lastOriginalLine !== original.line
  5157. || lastOriginalColumn !== original.column
  5158. || lastOriginalName !== original.name) {
  5159. map.addMapping({
  5160. source: original.source,
  5161. original: {
  5162. line: original.line,
  5163. column: original.column
  5164. },
  5165. generated: {
  5166. line: generated.line,
  5167. column: generated.column
  5168. },
  5169. name: original.name
  5170. });
  5171. }
  5172. lastOriginalSource = original.source;
  5173. lastOriginalLine = original.line;
  5174. lastOriginalColumn = original.column;
  5175. lastOriginalName = original.name;
  5176. sourceMappingActive = true;
  5177. } else if (sourceMappingActive) {
  5178. map.addMapping({
  5179. generated: {
  5180. line: generated.line,
  5181. column: generated.column
  5182. }
  5183. });
  5184. lastOriginalSource = null;
  5185. sourceMappingActive = false;
  5186. }
  5187. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  5188. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  5189. generated.line++;
  5190. generated.column = 0;
  5191. // Mappings end at eol
  5192. if (idx + 1 === length) {
  5193. lastOriginalSource = null;
  5194. sourceMappingActive = false;
  5195. } else if (sourceMappingActive) {
  5196. map.addMapping({
  5197. source: original.source,
  5198. original: {
  5199. line: original.line,
  5200. column: original.column
  5201. },
  5202. generated: {
  5203. line: generated.line,
  5204. column: generated.column
  5205. },
  5206. name: original.name
  5207. });
  5208. }
  5209. } else {
  5210. generated.column++;
  5211. }
  5212. }
  5213. });
  5214. this.walkSourceContents(function (sourceFile, sourceContent) {
  5215. map.setSourceContent(sourceFile, sourceContent);
  5216. });
  5217. return { code: generated.code, map: map };
  5218. };
  5219. exports.SourceNode = SourceNode;
  5220. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5221. /***/ }
  5222. /******/ });
  5223. //# sourceMappingURL=pretty-print-worker.js.map