terser.js 1019 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876
  1. 'use strict';
  2. var require$$0 = require('url');
  3. var require$$0$1 = require('fs');
  4. var require$$1 = require('path');
  5. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
  6. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
  7. var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
  8. var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
  9. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  10. var bundle_min$1 = {exports: {}};
  11. var sourceMap = {};
  12. var sourceMapGenerator = {};
  13. var base64Vlq = {};
  14. var base64$1 = {};
  15. /* -*- Mode: js; js-indent-level: 2; -*- */
  16. /*
  17. * Copyright 2011 Mozilla Foundation and contributors
  18. * Licensed under the New BSD license. See LICENSE or:
  19. * http://opensource.org/licenses/BSD-3-Clause
  20. */
  21. const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
  22. /**
  23. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  24. */
  25. base64$1.encode = function(number) {
  26. if (0 <= number && number < intToCharMap.length) {
  27. return intToCharMap[number];
  28. }
  29. throw new TypeError("Must be between 0 and 63: " + number);
  30. };
  31. /* -*- Mode: js; js-indent-level: 2; -*- */
  32. /*
  33. * Copyright 2011 Mozilla Foundation and contributors
  34. * Licensed under the New BSD license. See LICENSE or:
  35. * http://opensource.org/licenses/BSD-3-Clause
  36. *
  37. * Based on the Base 64 VLQ implementation in Closure Compiler:
  38. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  39. *
  40. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  41. * Redistribution and use in source and binary forms, with or without
  42. * modification, are permitted provided that the following conditions are
  43. * met:
  44. *
  45. * * Redistributions of source code must retain the above copyright
  46. * notice, this list of conditions and the following disclaimer.
  47. * * Redistributions in binary form must reproduce the above
  48. * copyright notice, this list of conditions and the following
  49. * disclaimer in the documentation and/or other materials provided
  50. * with the distribution.
  51. * * Neither the name of Google Inc. nor the names of its
  52. * contributors may be used to endorse or promote products derived
  53. * from this software without specific prior written permission.
  54. *
  55. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  56. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  57. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  58. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  59. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  60. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  61. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  62. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  63. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  64. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  65. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  66. */
  67. const base64 = base64$1;
  68. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  69. // length quantities we use in the source map spec, the first bit is the sign,
  70. // the next four bits are the actual value, and the 6th bit is the
  71. // continuation bit. The continuation bit tells us whether there are more
  72. // digits in this value following this digit.
  73. //
  74. // Continuation
  75. // | Sign
  76. // | |
  77. // V V
  78. // 101011
  79. const VLQ_BASE_SHIFT = 5;
  80. // binary: 100000
  81. const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  82. // binary: 011111
  83. const VLQ_BASE_MASK = VLQ_BASE - 1;
  84. // binary: 100000
  85. const VLQ_CONTINUATION_BIT = VLQ_BASE;
  86. /**
  87. * Converts from a two-complement value to a value where the sign bit is
  88. * placed in the least significant bit. For example, as decimals:
  89. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  90. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  91. */
  92. function toVLQSigned(aValue) {
  93. return aValue < 0
  94. ? ((-aValue) << 1) + 1
  95. : (aValue << 1) + 0;
  96. }
  97. /**
  98. * Returns the base 64 VLQ encoded value.
  99. */
  100. base64Vlq.encode = function base64VLQ_encode(aValue) {
  101. let encoded = "";
  102. let digit;
  103. let vlq = toVLQSigned(aValue);
  104. do {
  105. digit = vlq & VLQ_BASE_MASK;
  106. vlq >>>= VLQ_BASE_SHIFT;
  107. if (vlq > 0) {
  108. // There are still more digits in this value, so we must make sure the
  109. // continuation bit is marked.
  110. digit |= VLQ_CONTINUATION_BIT;
  111. }
  112. encoded += base64.encode(digit);
  113. } while (vlq > 0);
  114. return encoded;
  115. };
  116. var util$4 = {};
  117. /* -*- Mode: js; js-indent-level: 2; -*- */
  118. // Note: This file is overridden in the 'package.json#browser' field to
  119. // substitute lib/url-browser.js instead.
  120. // Use the URL global for Node 10, and the 'url' module for Node 8.
  121. var url = typeof URL === "function" ? URL : require$$0__default.URL;
  122. /* -*- Mode: js; js-indent-level: 2; -*- */
  123. /*
  124. * Copyright 2011 Mozilla Foundation and contributors
  125. * Licensed under the New BSD license. See LICENSE or:
  126. * http://opensource.org/licenses/BSD-3-Clause
  127. */
  128. const URL$1 = url;
  129. /**
  130. * This is a helper function for getting values from parameter/options
  131. * objects.
  132. *
  133. * @param args The object we are extracting values from
  134. * @param name The name of the property we are getting.
  135. * @param defaultValue An optional value to return if the property is missing
  136. * from the object. If this is not specified and the property is missing, an
  137. * error will be thrown.
  138. */
  139. function getArg(aArgs, aName, aDefaultValue) {
  140. if (aName in aArgs) {
  141. return aArgs[aName];
  142. } else if (arguments.length === 3) {
  143. return aDefaultValue;
  144. }
  145. throw new Error('"' + aName + '" is a required argument.');
  146. }
  147. util$4.getArg = getArg;
  148. const supportsNullProto = (function() {
  149. const obj = Object.create(null);
  150. return !("__proto__" in obj);
  151. }());
  152. function identity(s) {
  153. return s;
  154. }
  155. /**
  156. * Because behavior goes wacky when you set `__proto__` on objects, we
  157. * have to prefix all the strings in our set with an arbitrary character.
  158. *
  159. * See https://github.com/mozilla/source-map/pull/31 and
  160. * https://github.com/mozilla/source-map/issues/30
  161. *
  162. * @param String aStr
  163. */
  164. function toSetString(aStr) {
  165. if (isProtoString(aStr)) {
  166. return "$" + aStr;
  167. }
  168. return aStr;
  169. }
  170. util$4.toSetString = supportsNullProto ? identity : toSetString;
  171. function fromSetString(aStr) {
  172. if (isProtoString(aStr)) {
  173. return aStr.slice(1);
  174. }
  175. return aStr;
  176. }
  177. util$4.fromSetString = supportsNullProto ? identity : fromSetString;
  178. function isProtoString(s) {
  179. if (!s) {
  180. return false;
  181. }
  182. const length = s.length;
  183. if (length < 9 /* "__proto__".length */) {
  184. return false;
  185. }
  186. /* eslint-disable no-multi-spaces */
  187. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  188. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  189. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  190. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  191. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  192. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  193. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  194. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  195. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  196. return false;
  197. }
  198. /* eslint-enable no-multi-spaces */
  199. for (let i = length - 10; i >= 0; i--) {
  200. if (s.charCodeAt(i) !== 36 /* '$' */) {
  201. return false;
  202. }
  203. }
  204. return true;
  205. }
  206. function strcmp(aStr1, aStr2) {
  207. if (aStr1 === aStr2) {
  208. return 0;
  209. }
  210. if (aStr1 === null) {
  211. return 1; // aStr2 !== null
  212. }
  213. if (aStr2 === null) {
  214. return -1; // aStr1 !== null
  215. }
  216. if (aStr1 > aStr2) {
  217. return 1;
  218. }
  219. return -1;
  220. }
  221. /**
  222. * Comparator between two mappings with inflated source and name strings where
  223. * the generated positions are compared.
  224. */
  225. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  226. let cmp = mappingA.generatedLine - mappingB.generatedLine;
  227. if (cmp !== 0) {
  228. return cmp;
  229. }
  230. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  231. if (cmp !== 0) {
  232. return cmp;
  233. }
  234. cmp = strcmp(mappingA.source, mappingB.source);
  235. if (cmp !== 0) {
  236. return cmp;
  237. }
  238. cmp = mappingA.originalLine - mappingB.originalLine;
  239. if (cmp !== 0) {
  240. return cmp;
  241. }
  242. cmp = mappingA.originalColumn - mappingB.originalColumn;
  243. if (cmp !== 0) {
  244. return cmp;
  245. }
  246. return strcmp(mappingA.name, mappingB.name);
  247. }
  248. util$4.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  249. /**
  250. * Strip any JSON XSSI avoidance prefix from the string (as documented
  251. * in the source maps specification), and then parse the string as
  252. * JSON.
  253. */
  254. function parseSourceMapInput(str) {
  255. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
  256. }
  257. util$4.parseSourceMapInput = parseSourceMapInput;
  258. // We use 'http' as the base here because we want URLs processed relative
  259. // to the safe base to be treated as "special" URLs during parsing using
  260. // the WHATWG URL parsing. This ensures that backslash normalization
  261. // applies to the path and such.
  262. const PROTOCOL = "http:";
  263. const PROTOCOL_AND_HOST = `${PROTOCOL}//host`;
  264. /**
  265. * Make it easy to create small utilities that tweak a URL's path.
  266. */
  267. function createSafeHandler(cb) {
  268. return input => {
  269. const type = getURLType(input);
  270. const base = buildSafeBase(input);
  271. const url = new URL$1(input, base);
  272. cb(url);
  273. const result = url.toString();
  274. if (type === "absolute") {
  275. return result;
  276. } else if (type === "scheme-relative") {
  277. return result.slice(PROTOCOL.length);
  278. } else if (type === "path-absolute") {
  279. return result.slice(PROTOCOL_AND_HOST.length);
  280. }
  281. // This assumes that the callback will only change
  282. // the path, search and hash values.
  283. return computeRelativeURL(base, result);
  284. };
  285. }
  286. function withBase(url, base) {
  287. return new URL$1(url, base).toString();
  288. }
  289. function buildUniqueSegment(prefix, str) {
  290. let id = 0;
  291. do {
  292. const ident = prefix + (id++);
  293. if (str.indexOf(ident) === -1) return ident;
  294. } while (true);
  295. }
  296. function buildSafeBase(str) {
  297. const maxDotParts = str.split("..").length - 1;
  298. // If we used a segment that also existed in `str`, then we would be unable
  299. // to compute relative paths. For example, if `segment` were just "a":
  300. //
  301. // const url = "../../a/"
  302. // const base = buildSafeBase(url); // http://host/a/a/
  303. // const joined = "http://host/a/";
  304. // const result = relative(base, joined);
  305. //
  306. // Expected: "../../a/";
  307. // Actual: "a/"
  308. //
  309. const segment = buildUniqueSegment("p", str);
  310. let base = `${PROTOCOL_AND_HOST}/`;
  311. for (let i = 0; i < maxDotParts; i++) {
  312. base += `${segment}/`;
  313. }
  314. return base;
  315. }
  316. const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;
  317. function getURLType(url) {
  318. if (url[0] === "/") {
  319. if (url[1] === "/") return "scheme-relative";
  320. return "path-absolute";
  321. }
  322. return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
  323. }
  324. /**
  325. * Given two URLs that are assumed to be on the same
  326. * protocol/host/user/password build a relative URL from the
  327. * path, params, and hash values.
  328. *
  329. * @param rootURL The root URL that the target will be relative to.
  330. * @param targetURL The target that the relative URL points to.
  331. * @return A rootURL-relative, normalized URL value.
  332. */
  333. function computeRelativeURL(rootURL, targetURL) {
  334. if (typeof rootURL === "string") rootURL = new URL$1(rootURL);
  335. if (typeof targetURL === "string") targetURL = new URL$1(targetURL);
  336. const targetParts = targetURL.pathname.split("/");
  337. const rootParts = rootURL.pathname.split("/");
  338. // If we've got a URL path ending with a "/", we remove it since we'd
  339. // otherwise be relative to the wrong location.
  340. if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) {
  341. rootParts.pop();
  342. }
  343. while (
  344. targetParts.length > 0 &&
  345. rootParts.length > 0 &&
  346. targetParts[0] === rootParts[0]
  347. ) {
  348. targetParts.shift();
  349. rootParts.shift();
  350. }
  351. const relativePath = rootParts
  352. .map(() => "..")
  353. .concat(targetParts)
  354. .join("/");
  355. return relativePath + targetURL.search + targetURL.hash;
  356. }
  357. /**
  358. * Given a URL, ensure that it is treated as a directory URL.
  359. *
  360. * @param url
  361. * @return A normalized URL value.
  362. */
  363. const ensureDirectory = createSafeHandler(url => {
  364. url.pathname = url.pathname.replace(/\/?$/, "/");
  365. });
  366. /**
  367. * Given a URL, strip off any filename if one is present.
  368. *
  369. * @param url
  370. * @return A normalized URL value.
  371. */
  372. const trimFilename = createSafeHandler(url => {
  373. url.href = new URL$1(".", url.toString()).toString();
  374. });
  375. /**
  376. * Normalize a given URL.
  377. * * Convert backslashes.
  378. * * Remove any ".." and "." segments.
  379. *
  380. * @param url
  381. * @return A normalized URL value.
  382. */
  383. const normalize = createSafeHandler(url => {});
  384. util$4.normalize = normalize;
  385. /**
  386. * Joins two paths/URLs.
  387. *
  388. * All returned URLs will be normalized.
  389. *
  390. * @param aRoot The root path or URL. Assumed to reference a directory.
  391. * @param aPath The path or URL to be joined with the root.
  392. * @return A joined and normalized URL value.
  393. */
  394. function join(aRoot, aPath) {
  395. const pathType = getURLType(aPath);
  396. const rootType = getURLType(aRoot);
  397. aRoot = ensureDirectory(aRoot);
  398. if (pathType === "absolute") {
  399. return withBase(aPath, undefined);
  400. }
  401. if (rootType === "absolute") {
  402. return withBase(aPath, aRoot);
  403. }
  404. if (pathType === "scheme-relative") {
  405. return normalize(aPath);
  406. }
  407. if (rootType === "scheme-relative") {
  408. return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL.length);
  409. }
  410. if (pathType === "path-absolute") {
  411. return normalize(aPath);
  412. }
  413. if (rootType === "path-absolute") {
  414. return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);
  415. }
  416. const base = buildSafeBase(aPath + aRoot);
  417. const newPath = withBase(aPath, withBase(aRoot, base));
  418. return computeRelativeURL(base, newPath);
  419. }
  420. util$4.join = join;
  421. /**
  422. * Make a path relative to a URL or another path. If returning a
  423. * relative URL is not possible, the original target will be returned.
  424. * All returned URLs will be normalized.
  425. *
  426. * @param aRoot The root path or URL.
  427. * @param aPath The path or URL to be made relative to aRoot.
  428. * @return A rootURL-relative (if possible), normalized URL value.
  429. */
  430. function relative(rootURL, targetURL) {
  431. const result = relativeIfPossible(rootURL, targetURL);
  432. return typeof result === "string" ? result : normalize(targetURL);
  433. }
  434. util$4.relative = relative;
  435. function relativeIfPossible(rootURL, targetURL) {
  436. const urlType = getURLType(rootURL);
  437. if (urlType !== getURLType(targetURL)) {
  438. return null;
  439. }
  440. const base = buildSafeBase(rootURL + targetURL);
  441. const root = new URL$1(rootURL, base);
  442. const target = new URL$1(targetURL, base);
  443. try {
  444. new URL$1("", target.toString());
  445. } catch (err) {
  446. // Bail if the URL doesn't support things being relative to it,
  447. // For example, data: and blob: URLs.
  448. return null;
  449. }
  450. if (
  451. target.protocol !== root.protocol ||
  452. target.user !== root.user ||
  453. target.password !== root.password ||
  454. target.hostname !== root.hostname ||
  455. target.port !== root.port
  456. ) {
  457. return null;
  458. }
  459. return computeRelativeURL(root, target);
  460. }
  461. /**
  462. * Compute the URL of a source given the the source root, the source's
  463. * URL, and the source map's URL.
  464. */
  465. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  466. // The source map spec states that "sourceRoot" and "sources" entries are to be appended. While
  467. // that is a little vague, implementations have generally interpreted that as joining the
  468. // URLs with a `/` between then, assuming the "sourceRoot" doesn't already end with one.
  469. // For example,
  470. //
  471. // sourceRoot: "some-dir",
  472. // sources: ["/some-path.js"]
  473. //
  474. // and
  475. //
  476. // sourceRoot: "some-dir/",
  477. // sources: ["/some-path.js"]
  478. //
  479. // must behave as "some-dir/some-path.js".
  480. //
  481. // With this library's the transition to a more URL-focused implementation, that behavior is
  482. // preserved here. To acheive that, we trim the "/" from absolute-path when a sourceRoot value
  483. // is present in order to make the sources entries behave as if they are relative to the
  484. // "sourceRoot", as they would have if the two strings were simply concated.
  485. if (sourceRoot && getURLType(sourceURL) === "path-absolute") {
  486. sourceURL = sourceURL.replace(/^\//, "");
  487. }
  488. let url = normalize(sourceURL || "");
  489. // Parsing URLs can be expensive, so we only perform these joins when needed.
  490. if (sourceRoot) url = join(sourceRoot, url);
  491. if (sourceMapURL) url = join(trimFilename(sourceMapURL), url);
  492. return url;
  493. }
  494. util$4.computeSourceURL = computeSourceURL;
  495. var arraySet = {};
  496. /* -*- Mode: js; js-indent-level: 2; -*- */
  497. /*
  498. * Copyright 2011 Mozilla Foundation and contributors
  499. * Licensed under the New BSD license. See LICENSE or:
  500. * http://opensource.org/licenses/BSD-3-Clause
  501. */
  502. /**
  503. * A data structure which is a combination of an array and a set. Adding a new
  504. * member is O(1), testing for membership is O(1), and finding the index of an
  505. * element is O(1). Removing elements from the set is not supported. Only
  506. * strings are supported for membership.
  507. */
  508. class ArraySet$2 {
  509. constructor() {
  510. this._array = [];
  511. this._set = new Map();
  512. }
  513. /**
  514. * Static method for creating ArraySet instances from an existing array.
  515. */
  516. static fromArray(aArray, aAllowDuplicates) {
  517. const set = new ArraySet$2();
  518. for (let i = 0, len = aArray.length; i < len; i++) {
  519. set.add(aArray[i], aAllowDuplicates);
  520. }
  521. return set;
  522. }
  523. /**
  524. * Return how many unique items are in this ArraySet. If duplicates have been
  525. * added, than those do not count towards the size.
  526. *
  527. * @returns Number
  528. */
  529. size() {
  530. return this._set.size;
  531. }
  532. /**
  533. * Add the given string to this set.
  534. *
  535. * @param String aStr
  536. */
  537. add(aStr, aAllowDuplicates) {
  538. const isDuplicate = this.has(aStr);
  539. const idx = this._array.length;
  540. if (!isDuplicate || aAllowDuplicates) {
  541. this._array.push(aStr);
  542. }
  543. if (!isDuplicate) {
  544. this._set.set(aStr, idx);
  545. }
  546. }
  547. /**
  548. * Is the given string a member of this set?
  549. *
  550. * @param String aStr
  551. */
  552. has(aStr) {
  553. return this._set.has(aStr);
  554. }
  555. /**
  556. * What is the index of the given string in the array?
  557. *
  558. * @param String aStr
  559. */
  560. indexOf(aStr) {
  561. const idx = this._set.get(aStr);
  562. if (idx >= 0) {
  563. return idx;
  564. }
  565. throw new Error('"' + aStr + '" is not in the set.');
  566. }
  567. /**
  568. * What is the element at the given index?
  569. *
  570. * @param Number aIdx
  571. */
  572. at(aIdx) {
  573. if (aIdx >= 0 && aIdx < this._array.length) {
  574. return this._array[aIdx];
  575. }
  576. throw new Error("No element indexed by " + aIdx);
  577. }
  578. /**
  579. * Returns the array representation of this set (which has the proper indices
  580. * indicated by indexOf). Note that this is a copy of the internal array used
  581. * for storing the members so that no one can mess with internal state.
  582. */
  583. toArray() {
  584. return this._array.slice();
  585. }
  586. }
  587. arraySet.ArraySet = ArraySet$2;
  588. var mappingList = {};
  589. /* -*- Mode: js; js-indent-level: 2; -*- */
  590. /*
  591. * Copyright 2014 Mozilla Foundation and contributors
  592. * Licensed under the New BSD license. See LICENSE or:
  593. * http://opensource.org/licenses/BSD-3-Clause
  594. */
  595. const util$3 = util$4;
  596. /**
  597. * Determine whether mappingB is after mappingA with respect to generated
  598. * position.
  599. */
  600. function generatedPositionAfter(mappingA, mappingB) {
  601. // Optimized for most common case
  602. const lineA = mappingA.generatedLine;
  603. const lineB = mappingB.generatedLine;
  604. const columnA = mappingA.generatedColumn;
  605. const columnB = mappingB.generatedColumn;
  606. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  607. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  608. }
  609. /**
  610. * A data structure to provide a sorted view of accumulated mappings in a
  611. * performance conscious manner. It trades a negligible overhead in general
  612. * case for a large speedup in case of mappings being added in order.
  613. */
  614. class MappingList$1 {
  615. constructor() {
  616. this._array = [];
  617. this._sorted = true;
  618. // Serves as infimum
  619. this._last = {generatedLine: -1, generatedColumn: 0};
  620. }
  621. /**
  622. * Iterate through internal items. This method takes the same arguments that
  623. * `Array.prototype.forEach` takes.
  624. *
  625. * NOTE: The order of the mappings is NOT guaranteed.
  626. */
  627. unsortedForEach(aCallback, aThisArg) {
  628. this._array.forEach(aCallback, aThisArg);
  629. }
  630. /**
  631. * Add the given source mapping.
  632. *
  633. * @param Object aMapping
  634. */
  635. add(aMapping) {
  636. if (generatedPositionAfter(this._last, aMapping)) {
  637. this._last = aMapping;
  638. this._array.push(aMapping);
  639. } else {
  640. this._sorted = false;
  641. this._array.push(aMapping);
  642. }
  643. }
  644. /**
  645. * Returns the flat, sorted array of mappings. The mappings are sorted by
  646. * generated position.
  647. *
  648. * WARNING: This method returns internal data without copying, for
  649. * performance. The return value must NOT be mutated, and should be treated as
  650. * an immutable borrow. If you want to take ownership, you must make your own
  651. * copy.
  652. */
  653. toArray() {
  654. if (!this._sorted) {
  655. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  656. this._sorted = true;
  657. }
  658. return this._array;
  659. }
  660. }
  661. mappingList.MappingList = MappingList$1;
  662. /* -*- Mode: js; js-indent-level: 2; -*- */
  663. /*
  664. * Copyright 2011 Mozilla Foundation and contributors
  665. * Licensed under the New BSD license. See LICENSE or:
  666. * http://opensource.org/licenses/BSD-3-Clause
  667. */
  668. const base64VLQ = base64Vlq;
  669. const util$2 = util$4;
  670. const ArraySet$1 = arraySet.ArraySet;
  671. const MappingList = mappingList.MappingList;
  672. /**
  673. * An instance of the SourceMapGenerator represents a source map which is
  674. * being built incrementally. You may pass an object with the following
  675. * properties:
  676. *
  677. * - file: The filename of the generated source.
  678. * - sourceRoot: A root for all relative URLs in this source map.
  679. */
  680. class SourceMapGenerator$1 {
  681. constructor(aArgs) {
  682. if (!aArgs) {
  683. aArgs = {};
  684. }
  685. this._file = util$2.getArg(aArgs, "file", null);
  686. this._sourceRoot = util$2.getArg(aArgs, "sourceRoot", null);
  687. this._skipValidation = util$2.getArg(aArgs, "skipValidation", false);
  688. this._sources = new ArraySet$1();
  689. this._names = new ArraySet$1();
  690. this._mappings = new MappingList();
  691. this._sourcesContents = null;
  692. }
  693. /**
  694. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  695. *
  696. * @param aSourceMapConsumer The SourceMap.
  697. */
  698. static fromSourceMap(aSourceMapConsumer) {
  699. const sourceRoot = aSourceMapConsumer.sourceRoot;
  700. const generator = new SourceMapGenerator$1({
  701. file: aSourceMapConsumer.file,
  702. sourceRoot
  703. });
  704. aSourceMapConsumer.eachMapping(function(mapping) {
  705. const newMapping = {
  706. generated: {
  707. line: mapping.generatedLine,
  708. column: mapping.generatedColumn
  709. }
  710. };
  711. if (mapping.source != null) {
  712. newMapping.source = mapping.source;
  713. if (sourceRoot != null) {
  714. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  715. }
  716. newMapping.original = {
  717. line: mapping.originalLine,
  718. column: mapping.originalColumn
  719. };
  720. if (mapping.name != null) {
  721. newMapping.name = mapping.name;
  722. }
  723. }
  724. generator.addMapping(newMapping);
  725. });
  726. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  727. let sourceRelative = sourceFile;
  728. if (sourceRoot !== null) {
  729. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  730. }
  731. if (!generator._sources.has(sourceRelative)) {
  732. generator._sources.add(sourceRelative);
  733. }
  734. const content = aSourceMapConsumer.sourceContentFor(sourceFile);
  735. if (content != null) {
  736. generator.setSourceContent(sourceFile, content);
  737. }
  738. });
  739. return generator;
  740. }
  741. /**
  742. * Add a single mapping from original source line and column to the generated
  743. * source's line and column for this source map being created. The mapping
  744. * object should have the following properties:
  745. *
  746. * - generated: An object with the generated line and column positions.
  747. * - original: An object with the original line and column positions.
  748. * - source: The original source file (relative to the sourceRoot).
  749. * - name: An optional original token name for this mapping.
  750. */
  751. addMapping(aArgs) {
  752. const generated = util$2.getArg(aArgs, "generated");
  753. const original = util$2.getArg(aArgs, "original", null);
  754. let source = util$2.getArg(aArgs, "source", null);
  755. let name = util$2.getArg(aArgs, "name", null);
  756. if (!this._skipValidation) {
  757. this._validateMapping(generated, original, source, name);
  758. }
  759. if (source != null) {
  760. source = String(source);
  761. if (!this._sources.has(source)) {
  762. this._sources.add(source);
  763. }
  764. }
  765. if (name != null) {
  766. name = String(name);
  767. if (!this._names.has(name)) {
  768. this._names.add(name);
  769. }
  770. }
  771. this._mappings.add({
  772. generatedLine: generated.line,
  773. generatedColumn: generated.column,
  774. originalLine: original != null && original.line,
  775. originalColumn: original != null && original.column,
  776. source,
  777. name
  778. });
  779. }
  780. /**
  781. * Set the source content for a source file.
  782. */
  783. setSourceContent(aSourceFile, aSourceContent) {
  784. let source = aSourceFile;
  785. if (this._sourceRoot != null) {
  786. source = util$2.relative(this._sourceRoot, source);
  787. }
  788. if (aSourceContent != null) {
  789. // Add the source content to the _sourcesContents map.
  790. // Create a new _sourcesContents map if the property is null.
  791. if (!this._sourcesContents) {
  792. this._sourcesContents = Object.create(null);
  793. }
  794. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  795. } else if (this._sourcesContents) {
  796. // Remove the source file from the _sourcesContents map.
  797. // If the _sourcesContents map is empty, set the property to null.
  798. delete this._sourcesContents[util$2.toSetString(source)];
  799. if (Object.keys(this._sourcesContents).length === 0) {
  800. this._sourcesContents = null;
  801. }
  802. }
  803. }
  804. /**
  805. * Applies the mappings of a sub-source-map for a specific source file to the
  806. * source map being generated. Each mapping to the supplied source file is
  807. * rewritten using the supplied source map. Note: The resolution for the
  808. * resulting mappings is the minimium of this map and the supplied map.
  809. *
  810. * @param aSourceMapConsumer The source map to be applied.
  811. * @param aSourceFile Optional. The filename of the source file.
  812. * If omitted, SourceMapConsumer's file property will be used.
  813. * @param aSourceMapPath Optional. The dirname of the path to the source map
  814. * to be applied. If relative, it is relative to the SourceMapConsumer.
  815. * This parameter is needed when the two source maps aren't in the same
  816. * directory, and the source map to be applied contains relative source
  817. * paths. If so, those relative source paths need to be rewritten
  818. * relative to the SourceMapGenerator.
  819. */
  820. applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  821. let sourceFile = aSourceFile;
  822. // If aSourceFile is omitted, we will use the file property of the SourceMap
  823. if (aSourceFile == null) {
  824. if (aSourceMapConsumer.file == null) {
  825. throw new Error(
  826. "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
  827. 'or the source map\'s "file" property. Both were omitted.'
  828. );
  829. }
  830. sourceFile = aSourceMapConsumer.file;
  831. }
  832. const sourceRoot = this._sourceRoot;
  833. // Make "sourceFile" relative if an absolute Url is passed.
  834. if (sourceRoot != null) {
  835. sourceFile = util$2.relative(sourceRoot, sourceFile);
  836. }
  837. // Applying the SourceMap can add and remove items from the sources and
  838. // the names array.
  839. const newSources = this._mappings.toArray().length > 0
  840. ? new ArraySet$1()
  841. : this._sources;
  842. const newNames = new ArraySet$1();
  843. // Find mappings for the "sourceFile"
  844. this._mappings.unsortedForEach(function(mapping) {
  845. if (mapping.source === sourceFile && mapping.originalLine != null) {
  846. // Check if it can be mapped by the source map, then update the mapping.
  847. const original = aSourceMapConsumer.originalPositionFor({
  848. line: mapping.originalLine,
  849. column: mapping.originalColumn
  850. });
  851. if (original.source != null) {
  852. // Copy mapping
  853. mapping.source = original.source;
  854. if (aSourceMapPath != null) {
  855. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  856. }
  857. if (sourceRoot != null) {
  858. mapping.source = util$2.relative(sourceRoot, mapping.source);
  859. }
  860. mapping.originalLine = original.line;
  861. mapping.originalColumn = original.column;
  862. if (original.name != null) {
  863. mapping.name = original.name;
  864. }
  865. }
  866. }
  867. const source = mapping.source;
  868. if (source != null && !newSources.has(source)) {
  869. newSources.add(source);
  870. }
  871. const name = mapping.name;
  872. if (name != null && !newNames.has(name)) {
  873. newNames.add(name);
  874. }
  875. }, this);
  876. this._sources = newSources;
  877. this._names = newNames;
  878. // Copy sourcesContents of applied map.
  879. aSourceMapConsumer.sources.forEach(function(srcFile) {
  880. const content = aSourceMapConsumer.sourceContentFor(srcFile);
  881. if (content != null) {
  882. if (aSourceMapPath != null) {
  883. srcFile = util$2.join(aSourceMapPath, srcFile);
  884. }
  885. if (sourceRoot != null) {
  886. srcFile = util$2.relative(sourceRoot, srcFile);
  887. }
  888. this.setSourceContent(srcFile, content);
  889. }
  890. }, this);
  891. }
  892. /**
  893. * A mapping can have one of the three levels of data:
  894. *
  895. * 1. Just the generated position.
  896. * 2. The Generated position, original position, and original source.
  897. * 3. Generated and original position, original source, as well as a name
  898. * token.
  899. *
  900. * To maintain consistency, we validate that any new mapping being added falls
  901. * in to one of these categories.
  902. */
  903. _validateMapping(aGenerated, aOriginal, aSource, aName) {
  904. // When aOriginal is truthy but has empty values for .line and .column,
  905. // it is most likely a programmer error. In this case we throw a very
  906. // specific error message to try to guide them the right way.
  907. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  908. if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
  909. throw new Error(
  910. "original.line and original.column are not numbers -- you probably meant to omit " +
  911. "the original mapping entirely and only map the generated position. If so, pass " +
  912. "null for the original mapping instead of an object with empty or null values."
  913. );
  914. }
  915. if (aGenerated && "line" in aGenerated && "column" in aGenerated
  916. && aGenerated.line > 0 && aGenerated.column >= 0
  917. && !aOriginal && !aSource && !aName) ; else if (aGenerated && "line" in aGenerated && "column" in aGenerated
  918. && aOriginal && "line" in aOriginal && "column" in aOriginal
  919. && aGenerated.line > 0 && aGenerated.column >= 0
  920. && aOriginal.line > 0 && aOriginal.column >= 0
  921. && aSource) ; else {
  922. throw new Error("Invalid mapping: " + JSON.stringify({
  923. generated: aGenerated,
  924. source: aSource,
  925. original: aOriginal,
  926. name: aName
  927. }));
  928. }
  929. }
  930. /**
  931. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  932. * specified by the source map format.
  933. */
  934. _serializeMappings() {
  935. let previousGeneratedColumn = 0;
  936. let previousGeneratedLine = 1;
  937. let previousOriginalColumn = 0;
  938. let previousOriginalLine = 0;
  939. let previousName = 0;
  940. let previousSource = 0;
  941. let result = "";
  942. let next;
  943. let mapping;
  944. let nameIdx;
  945. let sourceIdx;
  946. const mappings = this._mappings.toArray();
  947. for (let i = 0, len = mappings.length; i < len; i++) {
  948. mapping = mappings[i];
  949. next = "";
  950. if (mapping.generatedLine !== previousGeneratedLine) {
  951. previousGeneratedColumn = 0;
  952. while (mapping.generatedLine !== previousGeneratedLine) {
  953. next += ";";
  954. previousGeneratedLine++;
  955. }
  956. } else if (i > 0) {
  957. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  958. continue;
  959. }
  960. next += ",";
  961. }
  962. next += base64VLQ.encode(mapping.generatedColumn
  963. - previousGeneratedColumn);
  964. previousGeneratedColumn = mapping.generatedColumn;
  965. if (mapping.source != null) {
  966. sourceIdx = this._sources.indexOf(mapping.source);
  967. next += base64VLQ.encode(sourceIdx - previousSource);
  968. previousSource = sourceIdx;
  969. // lines are stored 0-based in SourceMap spec version 3
  970. next += base64VLQ.encode(mapping.originalLine - 1
  971. - previousOriginalLine);
  972. previousOriginalLine = mapping.originalLine - 1;
  973. next += base64VLQ.encode(mapping.originalColumn
  974. - previousOriginalColumn);
  975. previousOriginalColumn = mapping.originalColumn;
  976. if (mapping.name != null) {
  977. nameIdx = this._names.indexOf(mapping.name);
  978. next += base64VLQ.encode(nameIdx - previousName);
  979. previousName = nameIdx;
  980. }
  981. }
  982. result += next;
  983. }
  984. return result;
  985. }
  986. _generateSourcesContent(aSources, aSourceRoot) {
  987. return aSources.map(function(source) {
  988. if (!this._sourcesContents) {
  989. return null;
  990. }
  991. if (aSourceRoot != null) {
  992. source = util$2.relative(aSourceRoot, source);
  993. }
  994. const key = util$2.toSetString(source);
  995. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  996. ? this._sourcesContents[key]
  997. : null;
  998. }, this);
  999. }
  1000. /**
  1001. * Externalize the source map.
  1002. */
  1003. toJSON() {
  1004. const map = {
  1005. version: this._version,
  1006. sources: this._sources.toArray(),
  1007. names: this._names.toArray(),
  1008. mappings: this._serializeMappings()
  1009. };
  1010. if (this._file != null) {
  1011. map.file = this._file;
  1012. }
  1013. if (this._sourceRoot != null) {
  1014. map.sourceRoot = this._sourceRoot;
  1015. }
  1016. if (this._sourcesContents) {
  1017. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  1018. }
  1019. return map;
  1020. }
  1021. /**
  1022. * Render the source map being generated to a string.
  1023. */
  1024. toString() {
  1025. return JSON.stringify(this.toJSON());
  1026. }
  1027. }
  1028. SourceMapGenerator$1.prototype._version = 3;
  1029. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$1;
  1030. var sourceMapConsumer = {};
  1031. var binarySearch$1 = {};
  1032. /* -*- Mode: js; js-indent-level: 2; -*- */
  1033. (function (exports) {
  1034. /*
  1035. * Copyright 2011 Mozilla Foundation and contributors
  1036. * Licensed under the New BSD license. See LICENSE or:
  1037. * http://opensource.org/licenses/BSD-3-Clause
  1038. */
  1039. exports.GREATEST_LOWER_BOUND = 1;
  1040. exports.LEAST_UPPER_BOUND = 2;
  1041. /**
  1042. * Recursive implementation of binary search.
  1043. *
  1044. * @param aLow Indices here and lower do not contain the needle.
  1045. * @param aHigh Indices here and higher do not contain the needle.
  1046. * @param aNeedle The element being searched for.
  1047. * @param aHaystack The non-empty array being searched.
  1048. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  1049. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  1050. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  1051. * closest element that is smaller than or greater than the one we are
  1052. * searching for, respectively, if the exact element cannot be found.
  1053. */
  1054. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  1055. // This function terminates when one of the following is true:
  1056. //
  1057. // 1. We find the exact element we are looking for.
  1058. //
  1059. // 2. We did not find the exact element, but we can return the index of
  1060. // the next-closest element.
  1061. //
  1062. // 3. We did not find the exact element, and there is no next-closest
  1063. // element than the one we are searching for, so we return -1.
  1064. const mid = Math.floor((aHigh - aLow) / 2) + aLow;
  1065. const cmp = aCompare(aNeedle, aHaystack[mid], true);
  1066. if (cmp === 0) {
  1067. // Found the element we are looking for.
  1068. return mid;
  1069. } else if (cmp > 0) {
  1070. // Our needle is greater than aHaystack[mid].
  1071. if (aHigh - mid > 1) {
  1072. // The element is in the upper half.
  1073. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  1074. }
  1075. // The exact needle element was not found in this haystack. Determine if
  1076. // we are in termination case (3) or (2) and return the appropriate thing.
  1077. if (aBias == exports.LEAST_UPPER_BOUND) {
  1078. return aHigh < aHaystack.length ? aHigh : -1;
  1079. }
  1080. return mid;
  1081. }
  1082. // Our needle is less than aHaystack[mid].
  1083. if (mid - aLow > 1) {
  1084. // The element is in the lower half.
  1085. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  1086. }
  1087. // we are in termination case (3) or (2) and return the appropriate thing.
  1088. if (aBias == exports.LEAST_UPPER_BOUND) {
  1089. return mid;
  1090. }
  1091. return aLow < 0 ? -1 : aLow;
  1092. }
  1093. /**
  1094. * This is an implementation of binary search which will always try and return
  1095. * the index of the closest element if there is no exact hit. This is because
  1096. * mappings between original and generated line/col pairs are single points,
  1097. * and there is an implicit region between each of them, so a miss just means
  1098. * that you aren't on the very start of a region.
  1099. *
  1100. * @param aNeedle The element you are looking for.
  1101. * @param aHaystack The array that is being searched.
  1102. * @param aCompare A function which takes the needle and an element in the
  1103. * array and returns -1, 0, or 1 depending on whether the needle is less
  1104. * than, equal to, or greater than the element, respectively.
  1105. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  1106. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  1107. * closest element that is smaller than or greater than the one we are
  1108. * searching for, respectively, if the exact element cannot be found.
  1109. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  1110. */
  1111. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  1112. if (aHaystack.length === 0) {
  1113. return -1;
  1114. }
  1115. let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  1116. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  1117. if (index < 0) {
  1118. return -1;
  1119. }
  1120. // We have found either the exact element, or the next-closest element than
  1121. // the one we are searching for. However, there may be more than one such
  1122. // element. Make sure we always return the smallest of these.
  1123. while (index - 1 >= 0) {
  1124. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  1125. break;
  1126. }
  1127. --index;
  1128. }
  1129. return index;
  1130. };
  1131. }(binarySearch$1));
  1132. var readWasm$2 = {exports: {}};
  1133. // Note: This file is replaced with "read-wasm-browser.js" when this module is
  1134. // bundled with a packager that takes package.json#browser fields into account.
  1135. const fs = require$$0__default$1;
  1136. const path = require$$1__default;
  1137. readWasm$2.exports = function readWasm() {
  1138. return new Promise((resolve, reject) => {
  1139. const wasmPath = path.join(__dirname, "mappings.wasm");
  1140. fs.readFile(wasmPath, null, (error, data) => {
  1141. if (error) {
  1142. reject(error);
  1143. return;
  1144. }
  1145. resolve(data.buffer);
  1146. });
  1147. });
  1148. };
  1149. readWasm$2.exports.initialize = _ => {
  1150. console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
  1151. };
  1152. const readWasm$1 = readWasm$2.exports;
  1153. /**
  1154. * Provide the JIT with a nice shape / hidden class.
  1155. */
  1156. function Mapping() {
  1157. this.generatedLine = 0;
  1158. this.generatedColumn = 0;
  1159. this.lastGeneratedColumn = null;
  1160. this.source = null;
  1161. this.originalLine = null;
  1162. this.originalColumn = null;
  1163. this.name = null;
  1164. }
  1165. let cachedWasm = null;
  1166. var wasm$1 = function wasm() {
  1167. if (cachedWasm) {
  1168. return cachedWasm;
  1169. }
  1170. const callbackStack = [];
  1171. cachedWasm = readWasm$1().then(buffer => {
  1172. return WebAssembly.instantiate(buffer, {
  1173. env: {
  1174. mapping_callback(
  1175. generatedLine,
  1176. generatedColumn,
  1177. hasLastGeneratedColumn,
  1178. lastGeneratedColumn,
  1179. hasOriginal,
  1180. source,
  1181. originalLine,
  1182. originalColumn,
  1183. hasName,
  1184. name
  1185. ) {
  1186. const mapping = new Mapping();
  1187. // JS uses 1-based line numbers, wasm uses 0-based.
  1188. mapping.generatedLine = generatedLine + 1;
  1189. mapping.generatedColumn = generatedColumn;
  1190. if (hasLastGeneratedColumn) {
  1191. // JS uses inclusive last generated column, wasm uses exclusive.
  1192. mapping.lastGeneratedColumn = lastGeneratedColumn - 1;
  1193. }
  1194. if (hasOriginal) {
  1195. mapping.source = source;
  1196. // JS uses 1-based line numbers, wasm uses 0-based.
  1197. mapping.originalLine = originalLine + 1;
  1198. mapping.originalColumn = originalColumn;
  1199. if (hasName) {
  1200. mapping.name = name;
  1201. }
  1202. }
  1203. callbackStack[callbackStack.length - 1](mapping);
  1204. },
  1205. start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
  1206. end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
  1207. start_compute_column_spans() { console.time("compute_column_spans"); },
  1208. end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
  1209. start_generated_location_for() { console.time("generated_location_for"); },
  1210. end_generated_location_for() { console.timeEnd("generated_location_for"); },
  1211. start_original_location_for() { console.time("original_location_for"); },
  1212. end_original_location_for() { console.timeEnd("original_location_for"); },
  1213. start_parse_mappings() { console.time("parse_mappings"); },
  1214. end_parse_mappings() { console.timeEnd("parse_mappings"); },
  1215. start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
  1216. end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
  1217. start_sort_by_original_location() { console.time("sort_by_original_location"); },
  1218. end_sort_by_original_location() { console.timeEnd("sort_by_original_location"); },
  1219. }
  1220. });
  1221. }).then(Wasm => {
  1222. return {
  1223. exports: Wasm.instance.exports,
  1224. withMappingCallback: (mappingCallback, f) => {
  1225. callbackStack.push(mappingCallback);
  1226. try {
  1227. f();
  1228. } finally {
  1229. callbackStack.pop();
  1230. }
  1231. }
  1232. };
  1233. }).then(null, e => {
  1234. cachedWasm = null;
  1235. throw e;
  1236. });
  1237. return cachedWasm;
  1238. };
  1239. /* -*- Mode: js; js-indent-level: 2; -*- */
  1240. /*
  1241. * Copyright 2011 Mozilla Foundation and contributors
  1242. * Licensed under the New BSD license. See LICENSE or:
  1243. * http://opensource.org/licenses/BSD-3-Clause
  1244. */
  1245. const util$1 = util$4;
  1246. const binarySearch = binarySearch$1;
  1247. const ArraySet = arraySet.ArraySet;
  1248. const readWasm = readWasm$2.exports;
  1249. const wasm = wasm$1;
  1250. const INTERNAL = Symbol("smcInternal");
  1251. class SourceMapConsumer {
  1252. constructor(aSourceMap, aSourceMapURL) {
  1253. // If the constructor was called by super(), just return Promise<this>.
  1254. // Yes, this is a hack to retain the pre-existing API of the base-class
  1255. // constructor also being an async factory function.
  1256. if (aSourceMap == INTERNAL) {
  1257. return Promise.resolve(this);
  1258. }
  1259. return _factory(aSourceMap, aSourceMapURL);
  1260. }
  1261. static initialize(opts) {
  1262. readWasm.initialize(opts["lib/mappings.wasm"]);
  1263. }
  1264. static fromSourceMap(aSourceMap, aSourceMapURL) {
  1265. return _factoryBSM(aSourceMap, aSourceMapURL);
  1266. }
  1267. /**
  1268. * Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
  1269. * (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
  1270. * function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
  1271. * for `f` to complete, call `destroy` on the consumer, and return `f`'s return
  1272. * value.
  1273. *
  1274. * You must not use the consumer after `f` completes!
  1275. *
  1276. * By using `with`, you do not have to remember to manually call `destroy` on
  1277. * the consumer, since it will be called automatically once `f` completes.
  1278. *
  1279. * ```js
  1280. * const xSquared = await SourceMapConsumer.with(
  1281. * myRawSourceMap,
  1282. * null,
  1283. * async function (consumer) {
  1284. * // Use `consumer` inside here and don't worry about remembering
  1285. * // to call `destroy`.
  1286. *
  1287. * const x = await whatever(consumer);
  1288. * return x * x;
  1289. * }
  1290. * );
  1291. *
  1292. * // You may not use that `consumer` anymore out here; it has
  1293. * // been destroyed. But you can use `xSquared`.
  1294. * console.log(xSquared);
  1295. * ```
  1296. */
  1297. static async with(rawSourceMap, sourceMapUrl, f) {
  1298. const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl);
  1299. try {
  1300. return await f(consumer);
  1301. } finally {
  1302. consumer.destroy();
  1303. }
  1304. }
  1305. /**
  1306. * Iterate over each mapping between an original source/line/column and a
  1307. * generated line/column in this source map.
  1308. *
  1309. * @param Function aCallback
  1310. * The function that is called with each mapping.
  1311. * @param Object aContext
  1312. * Optional. If specified, this object will be the value of `this` every
  1313. * time that `aCallback` is called.
  1314. * @param aOrder
  1315. * Either `SourceMapConsumer.GENERATED_ORDER` or
  1316. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  1317. * iterate over the mappings sorted by the generated file's line/column
  1318. * order or the original's source/line/column order, respectively. Defaults to
  1319. * `SourceMapConsumer.GENERATED_ORDER`.
  1320. */
  1321. eachMapping(aCallback, aContext, aOrder) {
  1322. throw new Error("Subclasses must implement eachMapping");
  1323. }
  1324. /**
  1325. * Returns all generated line and column information for the original source,
  1326. * line, and column provided. If no column is provided, returns all mappings
  1327. * corresponding to a either the line we are searching for or the next
  1328. * closest line that has any mappings. Otherwise, returns all mappings
  1329. * corresponding to the given line and either the column we are searching for
  1330. * or the next closest column that has any offsets.
  1331. *
  1332. * The only argument is an object with the following properties:
  1333. *
  1334. * - source: The filename of the original source.
  1335. * - line: The line number in the original source. The line number is 1-based.
  1336. * - column: Optional. the column number in the original source.
  1337. * The column number is 0-based.
  1338. *
  1339. * and an array of objects is returned, each with the following properties:
  1340. *
  1341. * - line: The line number in the generated source, or null. The
  1342. * line number is 1-based.
  1343. * - column: The column number in the generated source, or null.
  1344. * The column number is 0-based.
  1345. */
  1346. allGeneratedPositionsFor(aArgs) {
  1347. throw new Error("Subclasses must implement allGeneratedPositionsFor");
  1348. }
  1349. destroy() {
  1350. throw new Error("Subclasses must implement destroy");
  1351. }
  1352. }
  1353. /**
  1354. * The version of the source mapping spec that we are consuming.
  1355. */
  1356. SourceMapConsumer.prototype._version = 3;
  1357. SourceMapConsumer.GENERATED_ORDER = 1;
  1358. SourceMapConsumer.ORIGINAL_ORDER = 2;
  1359. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  1360. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  1361. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer;
  1362. /**
  1363. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  1364. * query for information about the original file positions by giving it a file
  1365. * position in the generated source.
  1366. *
  1367. * The first parameter is the raw source map (either as a JSON string, or
  1368. * already parsed to an object). According to the spec, source maps have the
  1369. * following attributes:
  1370. *
  1371. * - version: Which version of the source map spec this map is following.
  1372. * - sources: An array of URLs to the original source files.
  1373. * - names: An array of identifiers which can be referenced by individual mappings.
  1374. * - sourceRoot: Optional. The URL root from which all sources are relative.
  1375. * - sourcesContent: Optional. An array of contents of the original source files.
  1376. * - mappings: A string of base64 VLQs which contain the actual mappings.
  1377. * - file: Optional. The generated file this source map is associated with.
  1378. *
  1379. * Here is an example source map, taken from the source map spec[0]:
  1380. *
  1381. * {
  1382. * version : 3,
  1383. * file: "out.js",
  1384. * sourceRoot : "",
  1385. * sources: ["foo.js", "bar.js"],
  1386. * names: ["src", "maps", "are", "fun"],
  1387. * mappings: "AA,AB;;ABCDE;"
  1388. * }
  1389. *
  1390. * The second parameter, if given, is a string whose value is the URL
  1391. * at which the source map was found. This URL is used to compute the
  1392. * sources array.
  1393. *
  1394. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  1395. */
  1396. class BasicSourceMapConsumer extends SourceMapConsumer {
  1397. constructor(aSourceMap, aSourceMapURL) {
  1398. return super(INTERNAL).then(that => {
  1399. let sourceMap = aSourceMap;
  1400. if (typeof aSourceMap === "string") {
  1401. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  1402. }
  1403. const version = util$1.getArg(sourceMap, "version");
  1404. const sources = util$1.getArg(sourceMap, "sources").map(String);
  1405. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  1406. // requires the array) to play nice here.
  1407. const names = util$1.getArg(sourceMap, "names", []);
  1408. const sourceRoot = util$1.getArg(sourceMap, "sourceRoot", null);
  1409. const sourcesContent = util$1.getArg(sourceMap, "sourcesContent", null);
  1410. const mappings = util$1.getArg(sourceMap, "mappings");
  1411. const file = util$1.getArg(sourceMap, "file", null);
  1412. // Once again, Sass deviates from the spec and supplies the version as a
  1413. // string rather than a number, so we use loose equality checking here.
  1414. if (version != that._version) {
  1415. throw new Error("Unsupported version: " + version);
  1416. }
  1417. that._sourceLookupCache = new Map();
  1418. // Pass `true` below to allow duplicate names and sources. While source maps
  1419. // are intended to be compressed and deduplicated, the TypeScript compiler
  1420. // sometimes generates source maps with duplicates in them. See Github issue
  1421. // #72 and bugzil.la/889492.
  1422. that._names = ArraySet.fromArray(names.map(String), true);
  1423. that._sources = ArraySet.fromArray(sources, true);
  1424. that._absoluteSources = ArraySet.fromArray(that._sources.toArray().map(function(s) {
  1425. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  1426. }), true);
  1427. that.sourceRoot = sourceRoot;
  1428. that.sourcesContent = sourcesContent;
  1429. that._mappings = mappings;
  1430. that._sourceMapURL = aSourceMapURL;
  1431. that.file = file;
  1432. that._computedColumnSpans = false;
  1433. that._mappingsPtr = 0;
  1434. that._wasm = null;
  1435. return wasm().then(w => {
  1436. that._wasm = w;
  1437. return that;
  1438. });
  1439. });
  1440. }
  1441. /**
  1442. * Utility function to find the index of a source. Returns -1 if not
  1443. * found.
  1444. */
  1445. _findSourceIndex(aSource) {
  1446. // In the most common usecases, we'll be constantly looking up the index for the same source
  1447. // files, so we cache the index lookup to avoid constantly recomputing the full URLs.
  1448. const cachedIndex = this._sourceLookupCache.get(aSource);
  1449. if (typeof cachedIndex === "number") {
  1450. return cachedIndex;
  1451. }
  1452. // Treat the source as map-relative overall by default.
  1453. const sourceAsMapRelative = util$1.computeSourceURL(null, aSource, this._sourceMapURL);
  1454. if (this._absoluteSources.has(sourceAsMapRelative)) {
  1455. const index = this._absoluteSources.indexOf(sourceAsMapRelative);
  1456. this._sourceLookupCache.set(aSource, index);
  1457. return index;
  1458. }
  1459. // Fall back to treating the source as sourceRoot-relative.
  1460. const sourceAsSourceRootRelative = util$1.computeSourceURL(this.sourceRoot, aSource, this._sourceMapURL);
  1461. if (this._absoluteSources.has(sourceAsSourceRootRelative)) {
  1462. const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);
  1463. this._sourceLookupCache.set(aSource, index);
  1464. return index;
  1465. }
  1466. // To avoid this cache growing forever, we do not cache lookup misses.
  1467. return -1;
  1468. }
  1469. /**
  1470. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  1471. *
  1472. * @param SourceMapGenerator aSourceMap
  1473. * The source map that will be consumed.
  1474. * @param String aSourceMapURL
  1475. * The URL at which the source map can be found (optional)
  1476. * @returns BasicSourceMapConsumer
  1477. */
  1478. static fromSourceMap(aSourceMap, aSourceMapURL) {
  1479. return new BasicSourceMapConsumer(aSourceMap.toString());
  1480. }
  1481. get sources() {
  1482. return this._absoluteSources.toArray();
  1483. }
  1484. _getMappingsPtr() {
  1485. if (this._mappingsPtr === 0) {
  1486. this._parseMappings();
  1487. }
  1488. return this._mappingsPtr;
  1489. }
  1490. /**
  1491. * Parse the mappings in a string in to a data structure which we can easily
  1492. * query (the ordered arrays in the `this.__generatedMappings` and
  1493. * `this.__originalMappings` properties).
  1494. */
  1495. _parseMappings() {
  1496. const aStr = this._mappings;
  1497. const size = aStr.length;
  1498. const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
  1499. const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
  1500. for (let i = 0; i < size; i++) {
  1501. mappingsBuf[i] = aStr.charCodeAt(i);
  1502. }
  1503. const mappingsPtr = this._wasm.exports.parse_mappings(mappingsBufPtr);
  1504. if (!mappingsPtr) {
  1505. const error = this._wasm.exports.get_last_error();
  1506. let msg = `Error parsing mappings (code ${error}): `;
  1507. // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
  1508. switch (error) {
  1509. case 1:
  1510. msg += "the mappings contained a negative line, column, source index, or name index";
  1511. break;
  1512. case 2:
  1513. msg += "the mappings contained a number larger than 2**32";
  1514. break;
  1515. case 3:
  1516. msg += "reached EOF while in the middle of parsing a VLQ";
  1517. break;
  1518. case 4:
  1519. msg += "invalid base 64 character while parsing a VLQ";
  1520. break;
  1521. default:
  1522. msg += "unknown error code";
  1523. break;
  1524. }
  1525. throw new Error(msg);
  1526. }
  1527. this._mappingsPtr = mappingsPtr;
  1528. }
  1529. eachMapping(aCallback, aContext, aOrder) {
  1530. const context = aContext || null;
  1531. const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  1532. this._wasm.withMappingCallback(
  1533. mapping => {
  1534. if (mapping.source !== null) {
  1535. mapping.source = this._absoluteSources.at(mapping.source);
  1536. if (mapping.name !== null) {
  1537. mapping.name = this._names.at(mapping.name);
  1538. }
  1539. }
  1540. if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) {
  1541. mapping.lastGeneratedColumn = Infinity;
  1542. }
  1543. aCallback.call(context, mapping);
  1544. },
  1545. () => {
  1546. switch (order) {
  1547. case SourceMapConsumer.GENERATED_ORDER:
  1548. this._wasm.exports.by_generated_location(this._getMappingsPtr());
  1549. break;
  1550. case SourceMapConsumer.ORIGINAL_ORDER:
  1551. this._wasm.exports.by_original_location(this._getMappingsPtr());
  1552. break;
  1553. default:
  1554. throw new Error("Unknown order of iteration.");
  1555. }
  1556. }
  1557. );
  1558. }
  1559. allGeneratedPositionsFor(aArgs) {
  1560. let source = util$1.getArg(aArgs, "source");
  1561. const originalLine = util$1.getArg(aArgs, "line");
  1562. const originalColumn = aArgs.column || 0;
  1563. source = this._findSourceIndex(source);
  1564. if (source < 0) {
  1565. return [];
  1566. }
  1567. if (originalLine < 1) {
  1568. throw new Error("Line numbers must be >= 1");
  1569. }
  1570. if (originalColumn < 0) {
  1571. throw new Error("Column numbers must be >= 0");
  1572. }
  1573. const mappings = [];
  1574. this._wasm.withMappingCallback(
  1575. m => {
  1576. let lastColumn = m.lastGeneratedColumn;
  1577. if (this._computedColumnSpans && lastColumn === null) {
  1578. lastColumn = Infinity;
  1579. }
  1580. mappings.push({
  1581. line: m.generatedLine,
  1582. column: m.generatedColumn,
  1583. lastColumn,
  1584. });
  1585. }, () => {
  1586. this._wasm.exports.all_generated_locations_for(
  1587. this._getMappingsPtr(),
  1588. source,
  1589. originalLine - 1,
  1590. "column" in aArgs,
  1591. originalColumn
  1592. );
  1593. }
  1594. );
  1595. return mappings;
  1596. }
  1597. destroy() {
  1598. if (this._mappingsPtr !== 0) {
  1599. this._wasm.exports.free_mappings(this._mappingsPtr);
  1600. this._mappingsPtr = 0;
  1601. }
  1602. }
  1603. /**
  1604. * Compute the last column for each generated mapping. The last column is
  1605. * inclusive.
  1606. */
  1607. computeColumnSpans() {
  1608. if (this._computedColumnSpans) {
  1609. return;
  1610. }
  1611. this._wasm.exports.compute_column_spans(this._getMappingsPtr());
  1612. this._computedColumnSpans = true;
  1613. }
  1614. /**
  1615. * Returns the original source, line, and column information for the generated
  1616. * source's line and column positions provided. The only argument is an object
  1617. * with the following properties:
  1618. *
  1619. * - line: The line number in the generated source. The line number
  1620. * is 1-based.
  1621. * - column: The column number in the generated source. The column
  1622. * number is 0-based.
  1623. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  1624. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  1625. * closest element that is smaller than or greater than the one we are
  1626. * searching for, respectively, if the exact element cannot be found.
  1627. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  1628. *
  1629. * and an object is returned with the following properties:
  1630. *
  1631. * - source: The original source file, or null.
  1632. * - line: The line number in the original source, or null. The
  1633. * line number is 1-based.
  1634. * - column: The column number in the original source, or null. The
  1635. * column number is 0-based.
  1636. * - name: The original identifier, or null.
  1637. */
  1638. originalPositionFor(aArgs) {
  1639. const needle = {
  1640. generatedLine: util$1.getArg(aArgs, "line"),
  1641. generatedColumn: util$1.getArg(aArgs, "column")
  1642. };
  1643. if (needle.generatedLine < 1) {
  1644. throw new Error("Line numbers must be >= 1");
  1645. }
  1646. if (needle.generatedColumn < 0) {
  1647. throw new Error("Column numbers must be >= 0");
  1648. }
  1649. let bias = util$1.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
  1650. if (bias == null) {
  1651. bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
  1652. }
  1653. let mapping;
  1654. this._wasm.withMappingCallback(m => mapping = m, () => {
  1655. this._wasm.exports.original_location_for(
  1656. this._getMappingsPtr(),
  1657. needle.generatedLine - 1,
  1658. needle.generatedColumn,
  1659. bias
  1660. );
  1661. });
  1662. if (mapping) {
  1663. if (mapping.generatedLine === needle.generatedLine) {
  1664. let source = util$1.getArg(mapping, "source", null);
  1665. if (source !== null) {
  1666. source = this._absoluteSources.at(source);
  1667. }
  1668. let name = util$1.getArg(mapping, "name", null);
  1669. if (name !== null) {
  1670. name = this._names.at(name);
  1671. }
  1672. return {
  1673. source,
  1674. line: util$1.getArg(mapping, "originalLine", null),
  1675. column: util$1.getArg(mapping, "originalColumn", null),
  1676. name
  1677. };
  1678. }
  1679. }
  1680. return {
  1681. source: null,
  1682. line: null,
  1683. column: null,
  1684. name: null
  1685. };
  1686. }
  1687. /**
  1688. * Return true if we have the source content for every source in the source
  1689. * map, false otherwise.
  1690. */
  1691. hasContentsOfAllSources() {
  1692. if (!this.sourcesContent) {
  1693. return false;
  1694. }
  1695. return this.sourcesContent.length >= this._sources.size() &&
  1696. !this.sourcesContent.some(function(sc) { return sc == null; });
  1697. }
  1698. /**
  1699. * Returns the original source content. The only argument is the url of the
  1700. * original source file. Returns null if no original source content is
  1701. * available.
  1702. */
  1703. sourceContentFor(aSource, nullOnMissing) {
  1704. if (!this.sourcesContent) {
  1705. return null;
  1706. }
  1707. const index = this._findSourceIndex(aSource);
  1708. if (index >= 0) {
  1709. return this.sourcesContent[index];
  1710. }
  1711. // This function is used recursively from
  1712. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  1713. // don't want to throw if we can't find the source - we just want to
  1714. // return null, so we provide a flag to exit gracefully.
  1715. if (nullOnMissing) {
  1716. return null;
  1717. }
  1718. throw new Error('"' + aSource + '" is not in the SourceMap.');
  1719. }
  1720. /**
  1721. * Returns the generated line and column information for the original source,
  1722. * line, and column positions provided. The only argument is an object with
  1723. * the following properties:
  1724. *
  1725. * - source: The filename of the original source.
  1726. * - line: The line number in the original source. The line number
  1727. * is 1-based.
  1728. * - column: The column number in the original source. The column
  1729. * number is 0-based.
  1730. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  1731. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  1732. * closest element that is smaller than or greater than the one we are
  1733. * searching for, respectively, if the exact element cannot be found.
  1734. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  1735. *
  1736. * and an object is returned with the following properties:
  1737. *
  1738. * - line: The line number in the generated source, or null. The
  1739. * line number is 1-based.
  1740. * - column: The column number in the generated source, or null.
  1741. * The column number is 0-based.
  1742. */
  1743. generatedPositionFor(aArgs) {
  1744. let source = util$1.getArg(aArgs, "source");
  1745. source = this._findSourceIndex(source);
  1746. if (source < 0) {
  1747. return {
  1748. line: null,
  1749. column: null,
  1750. lastColumn: null
  1751. };
  1752. }
  1753. const needle = {
  1754. source,
  1755. originalLine: util$1.getArg(aArgs, "line"),
  1756. originalColumn: util$1.getArg(aArgs, "column")
  1757. };
  1758. if (needle.originalLine < 1) {
  1759. throw new Error("Line numbers must be >= 1");
  1760. }
  1761. if (needle.originalColumn < 0) {
  1762. throw new Error("Column numbers must be >= 0");
  1763. }
  1764. let bias = util$1.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
  1765. if (bias == null) {
  1766. bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
  1767. }
  1768. let mapping;
  1769. this._wasm.withMappingCallback(m => mapping = m, () => {
  1770. this._wasm.exports.generated_location_for(
  1771. this._getMappingsPtr(),
  1772. needle.source,
  1773. needle.originalLine - 1,
  1774. needle.originalColumn,
  1775. bias
  1776. );
  1777. });
  1778. if (mapping) {
  1779. if (mapping.source === needle.source) {
  1780. let lastColumn = mapping.lastGeneratedColumn;
  1781. if (this._computedColumnSpans && lastColumn === null) {
  1782. lastColumn = Infinity;
  1783. }
  1784. return {
  1785. line: util$1.getArg(mapping, "generatedLine", null),
  1786. column: util$1.getArg(mapping, "generatedColumn", null),
  1787. lastColumn,
  1788. };
  1789. }
  1790. }
  1791. return {
  1792. line: null,
  1793. column: null,
  1794. lastColumn: null
  1795. };
  1796. }
  1797. }
  1798. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  1799. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  1800. /**
  1801. * An IndexedSourceMapConsumer instance represents a parsed source map which
  1802. * we can query for information. It differs from BasicSourceMapConsumer in
  1803. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  1804. * input.
  1805. *
  1806. * The first parameter is a raw source map (either as a JSON string, or already
  1807. * parsed to an object). According to the spec for indexed source maps, they
  1808. * have the following attributes:
  1809. *
  1810. * - version: Which version of the source map spec this map is following.
  1811. * - file: Optional. The generated file this source map is associated with.
  1812. * - sections: A list of section definitions.
  1813. *
  1814. * Each value under the "sections" field has two fields:
  1815. * - offset: The offset into the original specified at which this section
  1816. * begins to apply, defined as an object with a "line" and "column"
  1817. * field.
  1818. * - map: A source map definition. This source map could also be indexed,
  1819. * but doesn't have to be.
  1820. *
  1821. * Instead of the "map" field, it's also possible to have a "url" field
  1822. * specifying a URL to retrieve a source map from, but that's currently
  1823. * unsupported.
  1824. *
  1825. * Here's an example source map, taken from the source map spec[0], but
  1826. * modified to omit a section which uses the "url" field.
  1827. *
  1828. * {
  1829. * version : 3,
  1830. * file: "app.js",
  1831. * sections: [{
  1832. * offset: {line:100, column:10},
  1833. * map: {
  1834. * version : 3,
  1835. * file: "section.js",
  1836. * sources: ["foo.js", "bar.js"],
  1837. * names: ["src", "maps", "are", "fun"],
  1838. * mappings: "AAAA,E;;ABCDE;"
  1839. * }
  1840. * }],
  1841. * }
  1842. *
  1843. * The second parameter, if given, is a string whose value is the URL
  1844. * at which the source map was found. This URL is used to compute the
  1845. * sources array.
  1846. *
  1847. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  1848. */
  1849. class IndexedSourceMapConsumer extends SourceMapConsumer {
  1850. constructor(aSourceMap, aSourceMapURL) {
  1851. return super(INTERNAL).then(that => {
  1852. let sourceMap = aSourceMap;
  1853. if (typeof aSourceMap === "string") {
  1854. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  1855. }
  1856. const version = util$1.getArg(sourceMap, "version");
  1857. const sections = util$1.getArg(sourceMap, "sections");
  1858. if (version != that._version) {
  1859. throw new Error("Unsupported version: " + version);
  1860. }
  1861. let lastOffset = {
  1862. line: -1,
  1863. column: 0
  1864. };
  1865. return Promise.all(sections.map(s => {
  1866. if (s.url) {
  1867. // The url field will require support for asynchronicity.
  1868. // See https://github.com/mozilla/source-map/issues/16
  1869. throw new Error("Support for url field in sections not implemented.");
  1870. }
  1871. const offset = util$1.getArg(s, "offset");
  1872. const offsetLine = util$1.getArg(offset, "line");
  1873. const offsetColumn = util$1.getArg(offset, "column");
  1874. if (offsetLine < lastOffset.line ||
  1875. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  1876. throw new Error("Section offsets must be ordered and non-overlapping.");
  1877. }
  1878. lastOffset = offset;
  1879. const cons = new SourceMapConsumer(util$1.getArg(s, "map"), aSourceMapURL);
  1880. return cons.then(consumer => {
  1881. return {
  1882. generatedOffset: {
  1883. // The offset fields are 0-based, but we use 1-based indices when
  1884. // encoding/decoding from VLQ.
  1885. generatedLine: offsetLine + 1,
  1886. generatedColumn: offsetColumn + 1
  1887. },
  1888. consumer
  1889. };
  1890. });
  1891. })).then(s => {
  1892. that._sections = s;
  1893. return that;
  1894. });
  1895. });
  1896. }
  1897. /**
  1898. * The list of original sources.
  1899. */
  1900. get sources() {
  1901. const sources = [];
  1902. for (let i = 0; i < this._sections.length; i++) {
  1903. for (let j = 0; j < this._sections[i].consumer.sources.length; j++) {
  1904. sources.push(this._sections[i].consumer.sources[j]);
  1905. }
  1906. }
  1907. return sources;
  1908. }
  1909. /**
  1910. * Returns the original source, line, and column information for the generated
  1911. * source's line and column positions provided. The only argument is an object
  1912. * with the following properties:
  1913. *
  1914. * - line: The line number in the generated source. The line number
  1915. * is 1-based.
  1916. * - column: The column number in the generated source. The column
  1917. * number is 0-based.
  1918. *
  1919. * and an object is returned with the following properties:
  1920. *
  1921. * - source: The original source file, or null.
  1922. * - line: The line number in the original source, or null. The
  1923. * line number is 1-based.
  1924. * - column: The column number in the original source, or null. The
  1925. * column number is 0-based.
  1926. * - name: The original identifier, or null.
  1927. */
  1928. originalPositionFor(aArgs) {
  1929. const needle = {
  1930. generatedLine: util$1.getArg(aArgs, "line"),
  1931. generatedColumn: util$1.getArg(aArgs, "column")
  1932. };
  1933. // Find the section containing the generated position we're trying to map
  1934. // to an original position.
  1935. const sectionIndex = binarySearch.search(needle, this._sections,
  1936. function(aNeedle, section) {
  1937. const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
  1938. if (cmp) {
  1939. return cmp;
  1940. }
  1941. return (aNeedle.generatedColumn -
  1942. section.generatedOffset.generatedColumn);
  1943. });
  1944. const section = this._sections[sectionIndex];
  1945. if (!section) {
  1946. return {
  1947. source: null,
  1948. line: null,
  1949. column: null,
  1950. name: null
  1951. };
  1952. }
  1953. return section.consumer.originalPositionFor({
  1954. line: needle.generatedLine -
  1955. (section.generatedOffset.generatedLine - 1),
  1956. column: needle.generatedColumn -
  1957. (section.generatedOffset.generatedLine === needle.generatedLine
  1958. ? section.generatedOffset.generatedColumn - 1
  1959. : 0),
  1960. bias: aArgs.bias
  1961. });
  1962. }
  1963. /**
  1964. * Return true if we have the source content for every source in the source
  1965. * map, false otherwise.
  1966. */
  1967. hasContentsOfAllSources() {
  1968. return this._sections.every(function(s) {
  1969. return s.consumer.hasContentsOfAllSources();
  1970. });
  1971. }
  1972. /**
  1973. * Returns the original source content. The only argument is the url of the
  1974. * original source file. Returns null if no original source content is
  1975. * available.
  1976. */
  1977. sourceContentFor(aSource, nullOnMissing) {
  1978. for (let i = 0; i < this._sections.length; i++) {
  1979. const section = this._sections[i];
  1980. const content = section.consumer.sourceContentFor(aSource, true);
  1981. if (content) {
  1982. return content;
  1983. }
  1984. }
  1985. if (nullOnMissing) {
  1986. return null;
  1987. }
  1988. throw new Error('"' + aSource + '" is not in the SourceMap.');
  1989. }
  1990. _findSectionIndex(source) {
  1991. for (let i = 0; i < this._sections.length; i++) {
  1992. const { consumer } = this._sections[i];
  1993. if (consumer._findSourceIndex(source) !== -1) {
  1994. return i;
  1995. }
  1996. }
  1997. return -1;
  1998. }
  1999. /**
  2000. * Returns the generated line and column information for the original source,
  2001. * line, and column positions provided. The only argument is an object with
  2002. * the following properties:
  2003. *
  2004. * - source: The filename of the original source.
  2005. * - line: The line number in the original source. The line number
  2006. * is 1-based.
  2007. * - column: The column number in the original source. The column
  2008. * number is 0-based.
  2009. *
  2010. * and an object is returned with the following properties:
  2011. *
  2012. * - line: The line number in the generated source, or null. The
  2013. * line number is 1-based.
  2014. * - column: The column number in the generated source, or null.
  2015. * The column number is 0-based.
  2016. */
  2017. generatedPositionFor(aArgs) {
  2018. const index = this._findSectionIndex(util$1.getArg(aArgs, "source"));
  2019. const section = index >= 0 ? this._sections[index] : null;
  2020. const nextSection =
  2021. index >= 0 && index + 1 < this._sections.length
  2022. ? this._sections[index + 1]
  2023. : null;
  2024. const generatedPosition =
  2025. section && section.consumer.generatedPositionFor(aArgs);
  2026. if (generatedPosition && generatedPosition.line !== null) {
  2027. const lineShift = section.generatedOffset.generatedLine - 1;
  2028. const columnShift = section.generatedOffset.generatedColumn - 1;
  2029. if (generatedPosition.line === 1) {
  2030. generatedPosition.column += columnShift;
  2031. if (typeof generatedPosition.lastColumn === "number") {
  2032. generatedPosition.lastColumn += columnShift;
  2033. }
  2034. }
  2035. if (
  2036. generatedPosition.lastColumn === Infinity &&
  2037. nextSection &&
  2038. generatedPosition.line === nextSection.generatedOffset.generatedLine
  2039. ) {
  2040. generatedPosition.lastColumn =
  2041. nextSection.generatedOffset.generatedColumn - 2;
  2042. }
  2043. generatedPosition.line += lineShift;
  2044. return generatedPosition;
  2045. }
  2046. return {
  2047. line: null,
  2048. column: null,
  2049. lastColumn: null
  2050. };
  2051. }
  2052. allGeneratedPositionsFor(aArgs) {
  2053. const index = this._findSectionIndex(util$1.getArg(aArgs, "source"));
  2054. const section = index >= 0 ? this._sections[index] : null;
  2055. const nextSection =
  2056. index >= 0 && index + 1 < this._sections.length
  2057. ? this._sections[index + 1]
  2058. : null;
  2059. if (!section) return [];
  2060. return section.consumer.allGeneratedPositionsFor(aArgs).map(
  2061. generatedPosition => {
  2062. const lineShift = section.generatedOffset.generatedLine - 1;
  2063. const columnShift = section.generatedOffset.generatedColumn - 1;
  2064. if (generatedPosition.line === 1) {
  2065. generatedPosition.column += columnShift;
  2066. if (typeof generatedPosition.lastColumn === "number") {
  2067. generatedPosition.lastColumn += columnShift;
  2068. }
  2069. }
  2070. if (
  2071. generatedPosition.lastColumn === Infinity &&
  2072. nextSection &&
  2073. generatedPosition.line === nextSection.generatedOffset.generatedLine
  2074. ) {
  2075. generatedPosition.lastColumn =
  2076. nextSection.generatedOffset.generatedColumn - 2;
  2077. }
  2078. generatedPosition.line += lineShift;
  2079. return generatedPosition;
  2080. }
  2081. );
  2082. }
  2083. eachMapping(aCallback, aContext, aOrder) {
  2084. this._sections.forEach((section, index) => {
  2085. const nextSection =
  2086. index + 1 < this._sections.length
  2087. ? this._sections[index + 1]
  2088. : null;
  2089. const { generatedOffset } = section;
  2090. const lineShift = generatedOffset.generatedLine - 1;
  2091. const columnShift = generatedOffset.generatedColumn - 1;
  2092. section.consumer.eachMapping(function(mapping) {
  2093. if (mapping.generatedLine === 1) {
  2094. mapping.generatedColumn += columnShift;
  2095. if (typeof mapping.lastGeneratedColumn === "number") {
  2096. mapping.lastGeneratedColumn += columnShift;
  2097. }
  2098. }
  2099. if (
  2100. mapping.lastGeneratedColumn === Infinity &&
  2101. nextSection &&
  2102. mapping.generatedLine === nextSection.generatedOffset.generatedLine
  2103. ) {
  2104. mapping.lastGeneratedColumn =
  2105. nextSection.generatedOffset.generatedColumn - 2;
  2106. }
  2107. mapping.generatedLine += lineShift;
  2108. aCallback.call(this, mapping);
  2109. }, aContext, aOrder);
  2110. });
  2111. }
  2112. computeColumnSpans() {
  2113. for (let i = 0; i < this._sections.length; i++) {
  2114. this._sections[i].consumer.computeColumnSpans();
  2115. }
  2116. }
  2117. destroy() {
  2118. for (let i = 0; i < this._sections.length; i++) {
  2119. this._sections[i].consumer.destroy();
  2120. }
  2121. }
  2122. }
  2123. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  2124. /*
  2125. * Cheat to get around inter-twingled classes. `factory()` can be at the end
  2126. * where it has access to non-hoisted classes, but it gets hoisted itself.
  2127. */
  2128. function _factory(aSourceMap, aSourceMapURL) {
  2129. let sourceMap = aSourceMap;
  2130. if (typeof aSourceMap === "string") {
  2131. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  2132. }
  2133. const consumer = sourceMap.sections != null
  2134. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  2135. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  2136. return Promise.resolve(consumer);
  2137. }
  2138. function _factoryBSM(aSourceMap, aSourceMapURL) {
  2139. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  2140. }
  2141. var sourceNode = {};
  2142. /* -*- Mode: js; js-indent-level: 2; -*- */
  2143. /*
  2144. * Copyright 2011 Mozilla Foundation and contributors
  2145. * Licensed under the New BSD license. See LICENSE or:
  2146. * http://opensource.org/licenses/BSD-3-Clause
  2147. */
  2148. const SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  2149. const util = util$4;
  2150. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  2151. // operating systems these days (capturing the result).
  2152. const REGEX_NEWLINE = /(\r?\n)/;
  2153. // Newline character code for charCodeAt() comparisons
  2154. const NEWLINE_CODE = 10;
  2155. // Private symbol for identifying `SourceNode`s when multiple versions of
  2156. // the source-map library are loaded. This MUST NOT CHANGE across
  2157. // versions!
  2158. const isSourceNode = "$$$isSourceNode$$$";
  2159. /**
  2160. * SourceNodes provide a way to abstract over interpolating/concatenating
  2161. * snippets of generated JavaScript source code while maintaining the line and
  2162. * column information associated with the original source code.
  2163. *
  2164. * @param aLine The original line number.
  2165. * @param aColumn The original column number.
  2166. * @param aSource The original source's filename.
  2167. * @param aChunks Optional. An array of strings which are snippets of
  2168. * generated JS, or other SourceNodes.
  2169. * @param aName The original identifier.
  2170. */
  2171. class SourceNode {
  2172. constructor(aLine, aColumn, aSource, aChunks, aName) {
  2173. this.children = [];
  2174. this.sourceContents = {};
  2175. this.line = aLine == null ? null : aLine;
  2176. this.column = aColumn == null ? null : aColumn;
  2177. this.source = aSource == null ? null : aSource;
  2178. this.name = aName == null ? null : aName;
  2179. this[isSourceNode] = true;
  2180. if (aChunks != null) this.add(aChunks);
  2181. }
  2182. /**
  2183. * Creates a SourceNode from generated code and a SourceMapConsumer.
  2184. *
  2185. * @param aGeneratedCode The generated code
  2186. * @param aSourceMapConsumer The SourceMap for the generated code
  2187. * @param aRelativePath Optional. The path that relative sources in the
  2188. * SourceMapConsumer should be relative to.
  2189. */
  2190. static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  2191. // The SourceNode we want to fill with the generated code
  2192. // and the SourceMap
  2193. const node = new SourceNode();
  2194. // All even indices of this array are one line of the generated code,
  2195. // while all odd indices are the newlines between two adjacent lines
  2196. // (since `REGEX_NEWLINE` captures its match).
  2197. // Processed fragments are accessed by calling `shiftNextLine`.
  2198. const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  2199. let remainingLinesIndex = 0;
  2200. const shiftNextLine = function() {
  2201. const lineContents = getNextLine();
  2202. // The last line of a file might not have a newline.
  2203. const newLine = getNextLine() || "";
  2204. return lineContents + newLine;
  2205. function getNextLine() {
  2206. return remainingLinesIndex < remainingLines.length ?
  2207. remainingLines[remainingLinesIndex++] : undefined;
  2208. }
  2209. };
  2210. // We need to remember the position of "remainingLines"
  2211. let lastGeneratedLine = 1, lastGeneratedColumn = 0;
  2212. // The generate SourceNodes we need a code range.
  2213. // To extract it current and last mapping is used.
  2214. // Here we store the last mapping.
  2215. let lastMapping = null;
  2216. let nextLine;
  2217. aSourceMapConsumer.eachMapping(function(mapping) {
  2218. if (lastMapping !== null) {
  2219. // We add the code from "lastMapping" to "mapping":
  2220. // First check if there is a new line in between.
  2221. if (lastGeneratedLine < mapping.generatedLine) {
  2222. // Associate first line with "lastMapping"
  2223. addMappingWithCode(lastMapping, shiftNextLine());
  2224. lastGeneratedLine++;
  2225. lastGeneratedColumn = 0;
  2226. // The remaining code is added without mapping
  2227. } else {
  2228. // There is no new line in between.
  2229. // Associate the code between "lastGeneratedColumn" and
  2230. // "mapping.generatedColumn" with "lastMapping"
  2231. nextLine = remainingLines[remainingLinesIndex] || "";
  2232. const code = nextLine.substr(0, mapping.generatedColumn -
  2233. lastGeneratedColumn);
  2234. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  2235. lastGeneratedColumn);
  2236. lastGeneratedColumn = mapping.generatedColumn;
  2237. addMappingWithCode(lastMapping, code);
  2238. // No more remaining code, continue
  2239. lastMapping = mapping;
  2240. return;
  2241. }
  2242. }
  2243. // We add the generated code until the first mapping
  2244. // to the SourceNode without any mapping.
  2245. // Each line is added as separate string.
  2246. while (lastGeneratedLine < mapping.generatedLine) {
  2247. node.add(shiftNextLine());
  2248. lastGeneratedLine++;
  2249. }
  2250. if (lastGeneratedColumn < mapping.generatedColumn) {
  2251. nextLine = remainingLines[remainingLinesIndex] || "";
  2252. node.add(nextLine.substr(0, mapping.generatedColumn));
  2253. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  2254. lastGeneratedColumn = mapping.generatedColumn;
  2255. }
  2256. lastMapping = mapping;
  2257. }, this);
  2258. // We have processed all mappings.
  2259. if (remainingLinesIndex < remainingLines.length) {
  2260. if (lastMapping) {
  2261. // Associate the remaining code in the current line with "lastMapping"
  2262. addMappingWithCode(lastMapping, shiftNextLine());
  2263. }
  2264. // and add the remaining lines without any mapping
  2265. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  2266. }
  2267. // Copy sourcesContent into SourceNode
  2268. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  2269. const content = aSourceMapConsumer.sourceContentFor(sourceFile);
  2270. if (content != null) {
  2271. if (aRelativePath != null) {
  2272. sourceFile = util.join(aRelativePath, sourceFile);
  2273. }
  2274. node.setSourceContent(sourceFile, content);
  2275. }
  2276. });
  2277. return node;
  2278. function addMappingWithCode(mapping, code) {
  2279. if (mapping === null || mapping.source === undefined) {
  2280. node.add(code);
  2281. } else {
  2282. const source = aRelativePath
  2283. ? util.join(aRelativePath, mapping.source)
  2284. : mapping.source;
  2285. node.add(new SourceNode(mapping.originalLine,
  2286. mapping.originalColumn,
  2287. source,
  2288. code,
  2289. mapping.name));
  2290. }
  2291. }
  2292. }
  2293. /**
  2294. * Add a chunk of generated JS to this source node.
  2295. *
  2296. * @param aChunk A string snippet of generated JS code, another instance of
  2297. * SourceNode, or an array where each member is one of those things.
  2298. */
  2299. add(aChunk) {
  2300. if (Array.isArray(aChunk)) {
  2301. aChunk.forEach(function(chunk) {
  2302. this.add(chunk);
  2303. }, this);
  2304. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  2305. if (aChunk) {
  2306. this.children.push(aChunk);
  2307. }
  2308. } else {
  2309. throw new TypeError(
  2310. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  2311. );
  2312. }
  2313. return this;
  2314. }
  2315. /**
  2316. * Add a chunk of generated JS to the beginning of this source node.
  2317. *
  2318. * @param aChunk A string snippet of generated JS code, another instance of
  2319. * SourceNode, or an array where each member is one of those things.
  2320. */
  2321. prepend(aChunk) {
  2322. if (Array.isArray(aChunk)) {
  2323. for (let i = aChunk.length - 1; i >= 0; i--) {
  2324. this.prepend(aChunk[i]);
  2325. }
  2326. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  2327. this.children.unshift(aChunk);
  2328. } else {
  2329. throw new TypeError(
  2330. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  2331. );
  2332. }
  2333. return this;
  2334. }
  2335. /**
  2336. * Walk over the tree of JS snippets in this node and its children. The
  2337. * walking function is called once for each snippet of JS and is passed that
  2338. * snippet and the its original associated source's line/column location.
  2339. *
  2340. * @param aFn The traversal function.
  2341. */
  2342. walk(aFn) {
  2343. let chunk;
  2344. for (let i = 0, len = this.children.length; i < len; i++) {
  2345. chunk = this.children[i];
  2346. if (chunk[isSourceNode]) {
  2347. chunk.walk(aFn);
  2348. } else if (chunk !== "") {
  2349. aFn(chunk, { source: this.source,
  2350. line: this.line,
  2351. column: this.column,
  2352. name: this.name });
  2353. }
  2354. }
  2355. }
  2356. /**
  2357. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  2358. * each of `this.children`.
  2359. *
  2360. * @param aSep The separator.
  2361. */
  2362. join(aSep) {
  2363. let newChildren;
  2364. let i;
  2365. const len = this.children.length;
  2366. if (len > 0) {
  2367. newChildren = [];
  2368. for (i = 0; i < len - 1; i++) {
  2369. newChildren.push(this.children[i]);
  2370. newChildren.push(aSep);
  2371. }
  2372. newChildren.push(this.children[i]);
  2373. this.children = newChildren;
  2374. }
  2375. return this;
  2376. }
  2377. /**
  2378. * Call String.prototype.replace on the very right-most source snippet. Useful
  2379. * for trimming whitespace from the end of a source node, etc.
  2380. *
  2381. * @param aPattern The pattern to replace.
  2382. * @param aReplacement The thing to replace the pattern with.
  2383. */
  2384. replaceRight(aPattern, aReplacement) {
  2385. const lastChild = this.children[this.children.length - 1];
  2386. if (lastChild[isSourceNode]) {
  2387. lastChild.replaceRight(aPattern, aReplacement);
  2388. } else if (typeof lastChild === "string") {
  2389. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  2390. } else {
  2391. this.children.push("".replace(aPattern, aReplacement));
  2392. }
  2393. return this;
  2394. }
  2395. /**
  2396. * Set the source content for a source file. This will be added to the SourceMapGenerator
  2397. * in the sourcesContent field.
  2398. *
  2399. * @param aSourceFile The filename of the source file
  2400. * @param aSourceContent The content of the source file
  2401. */
  2402. setSourceContent(aSourceFile, aSourceContent) {
  2403. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  2404. }
  2405. /**
  2406. * Walk over the tree of SourceNodes. The walking function is called for each
  2407. * source file content and is passed the filename and source content.
  2408. *
  2409. * @param aFn The traversal function.
  2410. */
  2411. walkSourceContents(aFn) {
  2412. for (let i = 0, len = this.children.length; i < len; i++) {
  2413. if (this.children[i][isSourceNode]) {
  2414. this.children[i].walkSourceContents(aFn);
  2415. }
  2416. }
  2417. const sources = Object.keys(this.sourceContents);
  2418. for (let i = 0, len = sources.length; i < len; i++) {
  2419. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  2420. }
  2421. }
  2422. /**
  2423. * Return the string representation of this source node. Walks over the tree
  2424. * and concatenates all the various snippets together to one string.
  2425. */
  2426. toString() {
  2427. let str = "";
  2428. this.walk(function(chunk) {
  2429. str += chunk;
  2430. });
  2431. return str;
  2432. }
  2433. /**
  2434. * Returns the string representation of this source node along with a source
  2435. * map.
  2436. */
  2437. toStringWithSourceMap(aArgs) {
  2438. const generated = {
  2439. code: "",
  2440. line: 1,
  2441. column: 0
  2442. };
  2443. const map = new SourceMapGenerator(aArgs);
  2444. let sourceMappingActive = false;
  2445. let lastOriginalSource = null;
  2446. let lastOriginalLine = null;
  2447. let lastOriginalColumn = null;
  2448. let lastOriginalName = null;
  2449. this.walk(function(chunk, original) {
  2450. generated.code += chunk;
  2451. if (original.source !== null
  2452. && original.line !== null
  2453. && original.column !== null) {
  2454. if (lastOriginalSource !== original.source
  2455. || lastOriginalLine !== original.line
  2456. || lastOriginalColumn !== original.column
  2457. || lastOriginalName !== original.name) {
  2458. map.addMapping({
  2459. source: original.source,
  2460. original: {
  2461. line: original.line,
  2462. column: original.column
  2463. },
  2464. generated: {
  2465. line: generated.line,
  2466. column: generated.column
  2467. },
  2468. name: original.name
  2469. });
  2470. }
  2471. lastOriginalSource = original.source;
  2472. lastOriginalLine = original.line;
  2473. lastOriginalColumn = original.column;
  2474. lastOriginalName = original.name;
  2475. sourceMappingActive = true;
  2476. } else if (sourceMappingActive) {
  2477. map.addMapping({
  2478. generated: {
  2479. line: generated.line,
  2480. column: generated.column
  2481. }
  2482. });
  2483. lastOriginalSource = null;
  2484. sourceMappingActive = false;
  2485. }
  2486. for (let idx = 0, length = chunk.length; idx < length; idx++) {
  2487. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  2488. generated.line++;
  2489. generated.column = 0;
  2490. // Mappings end at eol
  2491. if (idx + 1 === length) {
  2492. lastOriginalSource = null;
  2493. sourceMappingActive = false;
  2494. } else if (sourceMappingActive) {
  2495. map.addMapping({
  2496. source: original.source,
  2497. original: {
  2498. line: original.line,
  2499. column: original.column
  2500. },
  2501. generated: {
  2502. line: generated.line,
  2503. column: generated.column
  2504. },
  2505. name: original.name
  2506. });
  2507. }
  2508. } else {
  2509. generated.column++;
  2510. }
  2511. }
  2512. });
  2513. this.walkSourceContents(function(sourceFile, sourceContent) {
  2514. map.setSourceContent(sourceFile, sourceContent);
  2515. });
  2516. return { code: generated.code, map };
  2517. }
  2518. }
  2519. sourceNode.SourceNode = SourceNode;
  2520. /*
  2521. * Copyright 2009-2011 Mozilla Foundation and contributors
  2522. * Licensed under the New BSD license. See LICENSE.txt or:
  2523. * http://opensource.org/licenses/BSD-3-Clause
  2524. */
  2525. sourceMap.SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  2526. sourceMap.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  2527. sourceMap.SourceNode = sourceNode.SourceNode;
  2528. (function (module, exports) {
  2529. (function (global, factory) {
  2530. factory(exports, sourceMap) ;
  2531. }(commonjsGlobal, (function (exports, MOZ_SourceMap) {
  2532. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  2533. var MOZ_SourceMap__default = /*#__PURE__*/_interopDefaultLegacy(MOZ_SourceMap);
  2534. /***********************************************************************
  2535. A JavaScript tokenizer / parser / beautifier / compressor.
  2536. https://github.com/mishoo/UglifyJS2
  2537. -------------------------------- (C) ---------------------------------
  2538. Author: Mihai Bazon
  2539. <mihai.bazon@gmail.com>
  2540. http://mihai.bazon.net/blog
  2541. Distributed under the BSD license:
  2542. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  2543. Redistribution and use in source and binary forms, with or without
  2544. modification, are permitted provided that the following conditions
  2545. are met:
  2546. * Redistributions of source code must retain the above
  2547. copyright notice, this list of conditions and the following
  2548. disclaimer.
  2549. * Redistributions in binary form must reproduce the above
  2550. copyright notice, this list of conditions and the following
  2551. disclaimer in the documentation and/or other materials
  2552. provided with the distribution.
  2553. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  2554. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2555. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  2556. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  2557. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  2558. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  2559. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  2560. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2561. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  2562. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  2563. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2564. SUCH DAMAGE.
  2565. ***********************************************************************/
  2566. function characters(str) {
  2567. return str.split("");
  2568. }
  2569. function member(name, array) {
  2570. return array.includes(name);
  2571. }
  2572. class DefaultsError extends Error {
  2573. constructor(msg, defs) {
  2574. super();
  2575. this.name = "DefaultsError";
  2576. this.message = msg;
  2577. this.defs = defs;
  2578. }
  2579. }
  2580. function defaults(args, defs, croak) {
  2581. if (args === true) {
  2582. args = {};
  2583. } else if (args != null && typeof args === "object") {
  2584. args = {...args};
  2585. }
  2586. const ret = args || {};
  2587. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  2588. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  2589. }
  2590. for (const i in defs) if (HOP(defs, i)) {
  2591. if (!args || !HOP(args, i)) {
  2592. ret[i] = defs[i];
  2593. } else if (i === "ecma") {
  2594. let ecma = args[i] | 0;
  2595. if (ecma > 5 && ecma < 2015) ecma += 2009;
  2596. ret[i] = ecma;
  2597. } else {
  2598. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  2599. }
  2600. }
  2601. return ret;
  2602. }
  2603. function noop() {}
  2604. function return_false() { return false; }
  2605. function return_true() { return true; }
  2606. function return_this() { return this; }
  2607. function return_null() { return null; }
  2608. var MAP = (function() {
  2609. function MAP(a, f, backwards) {
  2610. var ret = [], top = [], i;
  2611. function doit() {
  2612. var val = f(a[i], i);
  2613. var is_last = val instanceof Last;
  2614. if (is_last) val = val.v;
  2615. if (val instanceof AtTop) {
  2616. val = val.v;
  2617. if (val instanceof Splice) {
  2618. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  2619. } else {
  2620. top.push(val);
  2621. }
  2622. } else if (val !== skip) {
  2623. if (val instanceof Splice) {
  2624. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  2625. } else {
  2626. ret.push(val);
  2627. }
  2628. }
  2629. return is_last;
  2630. }
  2631. if (Array.isArray(a)) {
  2632. if (backwards) {
  2633. for (i = a.length; --i >= 0;) if (doit()) break;
  2634. ret.reverse();
  2635. top.reverse();
  2636. } else {
  2637. for (i = 0; i < a.length; ++i) if (doit()) break;
  2638. }
  2639. } else {
  2640. for (i in a) if (HOP(a, i)) if (doit()) break;
  2641. }
  2642. return top.concat(ret);
  2643. }
  2644. MAP.at_top = function(val) { return new AtTop(val); };
  2645. MAP.splice = function(val) { return new Splice(val); };
  2646. MAP.last = function(val) { return new Last(val); };
  2647. var skip = MAP.skip = {};
  2648. function AtTop(val) { this.v = val; }
  2649. function Splice(val) { this.v = val; }
  2650. function Last(val) { this.v = val; }
  2651. return MAP;
  2652. })();
  2653. function make_node(ctor, orig, props) {
  2654. if (!props) props = {};
  2655. if (orig) {
  2656. if (!props.start) props.start = orig.start;
  2657. if (!props.end) props.end = orig.end;
  2658. }
  2659. return new ctor(props);
  2660. }
  2661. function push_uniq(array, el) {
  2662. if (!array.includes(el))
  2663. array.push(el);
  2664. }
  2665. function string_template(text, props) {
  2666. return text.replace(/{(.+?)}/g, function(str, p) {
  2667. return props && props[p];
  2668. });
  2669. }
  2670. function remove(array, el) {
  2671. for (var i = array.length; --i >= 0;) {
  2672. if (array[i] === el) array.splice(i, 1);
  2673. }
  2674. }
  2675. function mergeSort(array, cmp) {
  2676. if (array.length < 2) return array.slice();
  2677. function merge(a, b) {
  2678. var r = [], ai = 0, bi = 0, i = 0;
  2679. while (ai < a.length && bi < b.length) {
  2680. cmp(a[ai], b[bi]) <= 0
  2681. ? r[i++] = a[ai++]
  2682. : r[i++] = b[bi++];
  2683. }
  2684. if (ai < a.length) r.push.apply(r, a.slice(ai));
  2685. if (bi < b.length) r.push.apply(r, b.slice(bi));
  2686. return r;
  2687. }
  2688. function _ms(a) {
  2689. if (a.length <= 1)
  2690. return a;
  2691. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  2692. left = _ms(left);
  2693. right = _ms(right);
  2694. return merge(left, right);
  2695. }
  2696. return _ms(array);
  2697. }
  2698. function makePredicate(words) {
  2699. if (!Array.isArray(words)) words = words.split(" ");
  2700. return new Set(words.sort());
  2701. }
  2702. function map_add(map, key, value) {
  2703. if (map.has(key)) {
  2704. map.get(key).push(value);
  2705. } else {
  2706. map.set(key, [ value ]);
  2707. }
  2708. }
  2709. function map_from_object(obj) {
  2710. var map = new Map();
  2711. for (var key in obj) {
  2712. if (HOP(obj, key) && key.charAt(0) === "$") {
  2713. map.set(key.substr(1), obj[key]);
  2714. }
  2715. }
  2716. return map;
  2717. }
  2718. function map_to_object(map) {
  2719. var obj = Object.create(null);
  2720. map.forEach(function (value, key) {
  2721. obj["$" + key] = value;
  2722. });
  2723. return obj;
  2724. }
  2725. function HOP(obj, prop) {
  2726. return Object.prototype.hasOwnProperty.call(obj, prop);
  2727. }
  2728. function keep_name(keep_setting, name) {
  2729. return keep_setting === true
  2730. || (keep_setting instanceof RegExp && keep_setting.test(name));
  2731. }
  2732. var lineTerminatorEscape = {
  2733. "\0": "0",
  2734. "\n": "n",
  2735. "\r": "r",
  2736. "\u2028": "u2028",
  2737. "\u2029": "u2029",
  2738. };
  2739. function regexp_source_fix(source) {
  2740. // V8 does not escape line terminators in regexp patterns in node 12
  2741. // We'll also remove literal \0
  2742. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  2743. var escaped = source[offset - 1] == "\\"
  2744. && (source[offset - 2] != "\\"
  2745. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  2746. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  2747. });
  2748. }
  2749. const all_flags = "gimuy";
  2750. function sort_regexp_flags(flags) {
  2751. const existing_flags = new Set(flags.split(""));
  2752. let out = "";
  2753. for (const flag of all_flags) {
  2754. if (existing_flags.has(flag)) {
  2755. out += flag;
  2756. existing_flags.delete(flag);
  2757. }
  2758. }
  2759. if (existing_flags.size) {
  2760. // Flags Terser doesn't know about
  2761. existing_flags.forEach(flag => { out += flag; });
  2762. }
  2763. return out;
  2764. }
  2765. function has_annotation(node, annotation) {
  2766. return node._annotations & annotation;
  2767. }
  2768. function set_annotation(node, annotation) {
  2769. node._annotations |= annotation;
  2770. }
  2771. /***********************************************************************
  2772. A JavaScript tokenizer / parser / beautifier / compressor.
  2773. https://github.com/mishoo/UglifyJS2
  2774. -------------------------------- (C) ---------------------------------
  2775. Author: Mihai Bazon
  2776. <mihai.bazon@gmail.com>
  2777. http://mihai.bazon.net/blog
  2778. Distributed under the BSD license:
  2779. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  2780. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  2781. Redistribution and use in source and binary forms, with or without
  2782. modification, are permitted provided that the following conditions
  2783. are met:
  2784. * Redistributions of source code must retain the above
  2785. copyright notice, this list of conditions and the following
  2786. disclaimer.
  2787. * Redistributions in binary form must reproduce the above
  2788. copyright notice, this list of conditions and the following
  2789. disclaimer in the documentation and/or other materials
  2790. provided with the distribution.
  2791. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  2792. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2793. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  2794. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  2795. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  2796. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  2797. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  2798. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2799. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  2800. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  2801. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2802. SUCH DAMAGE.
  2803. ***********************************************************************/
  2804. var LATEST_RAW = ""; // Only used for numbers and template strings
  2805. var LATEST_TEMPLATE_END = true;
  2806. var KEYWORDS = "break case catch class const continue debugger default delete do else export extends finally for function if in instanceof let new return switch throw try typeof var void while with";
  2807. var KEYWORDS_ATOM = "false null true";
  2808. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  2809. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  2810. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  2811. KEYWORDS = makePredicate(KEYWORDS);
  2812. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  2813. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  2814. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  2815. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  2816. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  2817. var RE_NUM_LITERAL = /[0-9a-f]/i;
  2818. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  2819. var RE_OCT_NUMBER = /^0[0-7]+$/;
  2820. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  2821. var RE_BIN_NUMBER = /^0b[01]+$/i;
  2822. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  2823. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  2824. var OPERATORS = makePredicate([
  2825. "in",
  2826. "instanceof",
  2827. "typeof",
  2828. "new",
  2829. "void",
  2830. "delete",
  2831. "++",
  2832. "--",
  2833. "+",
  2834. "-",
  2835. "!",
  2836. "~",
  2837. "&",
  2838. "|",
  2839. "^",
  2840. "*",
  2841. "**",
  2842. "/",
  2843. "%",
  2844. ">>",
  2845. "<<",
  2846. ">>>",
  2847. "<",
  2848. ">",
  2849. "<=",
  2850. ">=",
  2851. "==",
  2852. "===",
  2853. "!=",
  2854. "!==",
  2855. "?",
  2856. "=",
  2857. "+=",
  2858. "-=",
  2859. "||=",
  2860. "&&=",
  2861. "??=",
  2862. "/=",
  2863. "*=",
  2864. "**=",
  2865. "%=",
  2866. ">>=",
  2867. "<<=",
  2868. ">>>=",
  2869. "|=",
  2870. "^=",
  2871. "&=",
  2872. "&&",
  2873. "??",
  2874. "||",
  2875. ]);
  2876. var WHITESPACE_CHARS = makePredicate(characters(" \u00a0\n\r\t\f\u000b\u200b\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\uFEFF"));
  2877. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  2878. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  2879. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  2880. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  2881. /* -----[ Tokenizer ]----- */
  2882. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  2883. var UNICODE = {
  2884. ID_Start: /[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
  2885. ID_Continue: /(?:[$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF])+/,
  2886. };
  2887. function get_full_char(str, pos) {
  2888. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  2889. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  2890. return str.charAt(pos) + str.charAt(pos + 1);
  2891. }
  2892. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  2893. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  2894. return str.charAt(pos - 1) + str.charAt(pos);
  2895. }
  2896. }
  2897. return str.charAt(pos);
  2898. }
  2899. function get_full_char_code(str, pos) {
  2900. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  2901. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  2902. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  2903. }
  2904. return str.charCodeAt(pos);
  2905. }
  2906. function get_full_char_length(str) {
  2907. var surrogates = 0;
  2908. for (var i = 0; i < str.length; i++) {
  2909. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  2910. surrogates++;
  2911. i++;
  2912. }
  2913. }
  2914. return str.length - surrogates;
  2915. }
  2916. function from_char_code(code) {
  2917. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  2918. if (code > 0xFFFF) {
  2919. code -= 0x10000;
  2920. return (String.fromCharCode((code >> 10) + 0xD800) +
  2921. String.fromCharCode((code % 0x400) + 0xDC00));
  2922. }
  2923. return String.fromCharCode(code);
  2924. }
  2925. function is_surrogate_pair_head(code) {
  2926. return code >= 0xd800 && code <= 0xdbff;
  2927. }
  2928. function is_surrogate_pair_tail(code) {
  2929. return code >= 0xdc00 && code <= 0xdfff;
  2930. }
  2931. function is_digit(code) {
  2932. return code >= 48 && code <= 57;
  2933. }
  2934. function is_identifier_start(ch) {
  2935. return UNICODE.ID_Start.test(ch);
  2936. }
  2937. function is_identifier_char(ch) {
  2938. return UNICODE.ID_Continue.test(ch);
  2939. }
  2940. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  2941. function is_basic_identifier_string(str) {
  2942. return BASIC_IDENT.test(str);
  2943. }
  2944. function is_identifier_string(str, allow_surrogates) {
  2945. if (BASIC_IDENT.test(str)) {
  2946. return true;
  2947. }
  2948. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  2949. return false;
  2950. }
  2951. var match = UNICODE.ID_Start.exec(str);
  2952. if (!match || match.index !== 0) {
  2953. return false;
  2954. }
  2955. str = str.slice(match[0].length);
  2956. if (!str) {
  2957. return true;
  2958. }
  2959. match = UNICODE.ID_Continue.exec(str);
  2960. return !!match && match[0].length === str.length;
  2961. }
  2962. function parse_js_number(num, allow_e = true) {
  2963. if (!allow_e && num.includes("e")) {
  2964. return NaN;
  2965. }
  2966. if (RE_HEX_NUMBER.test(num)) {
  2967. return parseInt(num.substr(2), 16);
  2968. } else if (RE_OCT_NUMBER.test(num)) {
  2969. return parseInt(num.substr(1), 8);
  2970. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  2971. return parseInt(num.substr(2), 8);
  2972. } else if (RE_BIN_NUMBER.test(num)) {
  2973. return parseInt(num.substr(2), 2);
  2974. } else if (RE_DEC_NUMBER.test(num)) {
  2975. return parseFloat(num);
  2976. } else {
  2977. var val = parseFloat(num);
  2978. if (val == num) return val;
  2979. }
  2980. }
  2981. class JS_Parse_Error extends Error {
  2982. constructor(message, filename, line, col, pos) {
  2983. super();
  2984. this.name = "SyntaxError";
  2985. this.message = message;
  2986. this.filename = filename;
  2987. this.line = line;
  2988. this.col = col;
  2989. this.pos = pos;
  2990. }
  2991. }
  2992. function js_error(message, filename, line, col, pos) {
  2993. throw new JS_Parse_Error(message, filename, line, col, pos);
  2994. }
  2995. function is_token(token, type, val) {
  2996. return token.type == type && (val == null || token.value == val);
  2997. }
  2998. var EX_EOF = {};
  2999. function tokenizer($TEXT, filename, html5_comments, shebang) {
  3000. var S = {
  3001. text : $TEXT,
  3002. filename : filename,
  3003. pos : 0,
  3004. tokpos : 0,
  3005. line : 1,
  3006. tokline : 0,
  3007. col : 0,
  3008. tokcol : 0,
  3009. newline_before : false,
  3010. regex_allowed : false,
  3011. brace_counter : 0,
  3012. template_braces : [],
  3013. comments_before : [],
  3014. directives : {},
  3015. directive_stack : []
  3016. };
  3017. function peek() { return get_full_char(S.text, S.pos); }
  3018. // Used because parsing ?. involves a lookahead for a digit
  3019. function is_option_chain_op() {
  3020. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  3021. if (!must_be_dot) return false;
  3022. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  3023. return cannot_be_digit < 48 || cannot_be_digit > 57;
  3024. }
  3025. function next(signal_eof, in_string) {
  3026. var ch = get_full_char(S.text, S.pos++);
  3027. if (signal_eof && !ch)
  3028. throw EX_EOF;
  3029. if (NEWLINE_CHARS.has(ch)) {
  3030. S.newline_before = S.newline_before || !in_string;
  3031. ++S.line;
  3032. S.col = 0;
  3033. if (ch == "\r" && peek() == "\n") {
  3034. // treat a \r\n sequence as a single \n
  3035. ++S.pos;
  3036. ch = "\n";
  3037. }
  3038. } else {
  3039. if (ch.length > 1) {
  3040. ++S.pos;
  3041. ++S.col;
  3042. }
  3043. ++S.col;
  3044. }
  3045. return ch;
  3046. }
  3047. function forward(i) {
  3048. while (i--) next();
  3049. }
  3050. function looking_at(str) {
  3051. return S.text.substr(S.pos, str.length) == str;
  3052. }
  3053. function find_eol() {
  3054. var text = S.text;
  3055. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  3056. var ch = text[i];
  3057. if (NEWLINE_CHARS.has(ch))
  3058. return i;
  3059. }
  3060. return -1;
  3061. }
  3062. function find(what, signal_eof) {
  3063. var pos = S.text.indexOf(what, S.pos);
  3064. if (signal_eof && pos == -1) throw EX_EOF;
  3065. return pos;
  3066. }
  3067. function start_token() {
  3068. S.tokline = S.line;
  3069. S.tokcol = S.col;
  3070. S.tokpos = S.pos;
  3071. }
  3072. var prev_was_dot = false;
  3073. var previous_token = null;
  3074. function token(type, value, is_comment) {
  3075. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  3076. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  3077. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  3078. (type == "arrow");
  3079. if (type == "punc" && (value == "." || value == "?.")) {
  3080. prev_was_dot = true;
  3081. } else if (!is_comment) {
  3082. prev_was_dot = false;
  3083. }
  3084. const line = S.tokline;
  3085. const col = S.tokcol;
  3086. const pos = S.tokpos;
  3087. const nlb = S.newline_before;
  3088. const file = filename;
  3089. let comments_before = [];
  3090. let comments_after = [];
  3091. if (!is_comment) {
  3092. comments_before = S.comments_before;
  3093. comments_after = S.comments_before = [];
  3094. }
  3095. S.newline_before = false;
  3096. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  3097. if (!is_comment) previous_token = tok;
  3098. return tok;
  3099. }
  3100. function skip_whitespace() {
  3101. while (WHITESPACE_CHARS.has(peek()))
  3102. next();
  3103. }
  3104. function read_while(pred) {
  3105. var ret = "", ch, i = 0;
  3106. while ((ch = peek()) && pred(ch, i++))
  3107. ret += next();
  3108. return ret;
  3109. }
  3110. function parse_error(err) {
  3111. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  3112. }
  3113. function read_num(prefix) {
  3114. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  3115. var num = read_while(function(ch, i) {
  3116. if (is_big_int) return false;
  3117. var code = ch.charCodeAt(0);
  3118. switch (code) {
  3119. case 95: // _
  3120. return (numeric_separator = true);
  3121. case 98: case 66: // bB
  3122. return (has_x = true); // Can occur in hex sequence, don't return false yet
  3123. case 111: case 79: // oO
  3124. case 120: case 88: // xX
  3125. return has_x ? false : (has_x = true);
  3126. case 101: case 69: // eE
  3127. return has_x ? true : has_e ? false : (has_e = after_e = true);
  3128. case 45: // -
  3129. return after_e || (i == 0 && !prefix);
  3130. case 43: // +
  3131. return after_e;
  3132. case (after_e = false, 46): // .
  3133. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  3134. }
  3135. if (ch === "n") {
  3136. is_big_int = true;
  3137. return true;
  3138. }
  3139. return RE_NUM_LITERAL.test(ch);
  3140. });
  3141. if (prefix) num = prefix + num;
  3142. LATEST_RAW = num;
  3143. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  3144. parse_error("Legacy octal literals are not allowed in strict mode");
  3145. }
  3146. if (numeric_separator) {
  3147. if (num.endsWith("_")) {
  3148. parse_error("Numeric separators are not allowed at the end of numeric literals");
  3149. } else if (num.includes("__")) {
  3150. parse_error("Only one underscore is allowed as numeric separator");
  3151. }
  3152. num = num.replace(/_/g, "");
  3153. }
  3154. if (num.endsWith("n")) {
  3155. const without_n = num.slice(0, -1);
  3156. const allow_e = RE_HEX_NUMBER.test(without_n);
  3157. const valid = parse_js_number(without_n, allow_e);
  3158. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  3159. return token("big_int", without_n);
  3160. parse_error("Invalid or unexpected token");
  3161. }
  3162. var valid = parse_js_number(num);
  3163. if (!isNaN(valid)) {
  3164. return token("num", valid);
  3165. } else {
  3166. parse_error("Invalid syntax: " + num);
  3167. }
  3168. }
  3169. function is_octal(ch) {
  3170. return ch >= "0" && ch <= "7";
  3171. }
  3172. function read_escaped_char(in_string, strict_hex, template_string) {
  3173. var ch = next(true, in_string);
  3174. switch (ch.charCodeAt(0)) {
  3175. case 110 : return "\n";
  3176. case 114 : return "\r";
  3177. case 116 : return "\t";
  3178. case 98 : return "\b";
  3179. case 118 : return "\u000b"; // \v
  3180. case 102 : return "\f";
  3181. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  3182. case 117 : // \u
  3183. if (peek() == "{") {
  3184. next(true);
  3185. if (peek() === "}")
  3186. parse_error("Expecting hex-character between {}");
  3187. while (peek() == "0") next(true); // No significance
  3188. var result, length = find("}", true) - S.pos;
  3189. // Avoid 32 bit integer overflow (1 << 32 === 1)
  3190. // We know first character isn't 0 and thus out of range anyway
  3191. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  3192. parse_error("Unicode reference out of bounds");
  3193. }
  3194. next(true);
  3195. return from_char_code(result);
  3196. }
  3197. return String.fromCharCode(hex_bytes(4, strict_hex));
  3198. case 10 : return ""; // newline
  3199. case 13 : // \r
  3200. if (peek() == "\n") { // DOS newline
  3201. next(true, in_string);
  3202. return "";
  3203. }
  3204. }
  3205. if (is_octal(ch)) {
  3206. if (template_string && strict_hex) {
  3207. const represents_null_character = ch === "0" && !is_octal(peek());
  3208. if (!represents_null_character) {
  3209. parse_error("Octal escape sequences are not allowed in template strings");
  3210. }
  3211. }
  3212. return read_octal_escape_sequence(ch, strict_hex);
  3213. }
  3214. return ch;
  3215. }
  3216. function read_octal_escape_sequence(ch, strict_octal) {
  3217. // Read
  3218. var p = peek();
  3219. if (p >= "0" && p <= "7") {
  3220. ch += next(true);
  3221. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  3222. ch += next(true);
  3223. }
  3224. // Parse
  3225. if (ch === "0") return "\0";
  3226. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  3227. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  3228. return String.fromCharCode(parseInt(ch, 8));
  3229. }
  3230. function hex_bytes(n, strict_hex) {
  3231. var num = 0;
  3232. for (; n > 0; --n) {
  3233. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  3234. return parseInt(num, 16) || "";
  3235. }
  3236. var digit = next(true);
  3237. if (isNaN(parseInt(digit, 16)))
  3238. parse_error("Invalid hex-character pattern in string");
  3239. num += digit;
  3240. }
  3241. return parseInt(num, 16);
  3242. }
  3243. var read_string = with_eof_error("Unterminated string constant", function() {
  3244. const start_pos = S.pos;
  3245. var quote = next(), ret = [];
  3246. for (;;) {
  3247. var ch = next(true, true);
  3248. if (ch == "\\") ch = read_escaped_char(true, true);
  3249. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  3250. else if (ch == quote) break;
  3251. ret.push(ch);
  3252. }
  3253. var tok = token("string", ret.join(""));
  3254. LATEST_RAW = S.text.slice(start_pos, S.pos);
  3255. tok.quote = quote;
  3256. return tok;
  3257. });
  3258. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  3259. if (begin) {
  3260. S.template_braces.push(S.brace_counter);
  3261. }
  3262. var content = "", raw = "", ch, tok;
  3263. next(true, true);
  3264. while ((ch = next(true, true)) != "`") {
  3265. if (ch == "\r") {
  3266. if (peek() == "\n") ++S.pos;
  3267. ch = "\n";
  3268. } else if (ch == "$" && peek() == "{") {
  3269. next(true, true);
  3270. S.brace_counter++;
  3271. tok = token(begin ? "template_head" : "template_substitution", content);
  3272. LATEST_RAW = raw;
  3273. LATEST_TEMPLATE_END = false;
  3274. return tok;
  3275. }
  3276. raw += ch;
  3277. if (ch == "\\") {
  3278. var tmp = S.pos;
  3279. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  3280. ch = read_escaped_char(true, !prev_is_tag, true);
  3281. raw += S.text.substr(tmp, S.pos - tmp);
  3282. }
  3283. content += ch;
  3284. }
  3285. S.template_braces.pop();
  3286. tok = token(begin ? "template_head" : "template_substitution", content);
  3287. LATEST_RAW = raw;
  3288. LATEST_TEMPLATE_END = true;
  3289. return tok;
  3290. });
  3291. function skip_line_comment(type) {
  3292. var regex_allowed = S.regex_allowed;
  3293. var i = find_eol(), ret;
  3294. if (i == -1) {
  3295. ret = S.text.substr(S.pos);
  3296. S.pos = S.text.length;
  3297. } else {
  3298. ret = S.text.substring(S.pos, i);
  3299. S.pos = i;
  3300. }
  3301. S.col = S.tokcol + (S.pos - S.tokpos);
  3302. S.comments_before.push(token(type, ret, true));
  3303. S.regex_allowed = regex_allowed;
  3304. return next_token;
  3305. }
  3306. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  3307. var regex_allowed = S.regex_allowed;
  3308. var i = find("*/", true);
  3309. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  3310. // update stream position
  3311. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  3312. S.comments_before.push(token("comment2", text, true));
  3313. S.newline_before = S.newline_before || text.includes("\n");
  3314. S.regex_allowed = regex_allowed;
  3315. return next_token;
  3316. });
  3317. var read_name = with_eof_error("Unterminated identifier name", function() {
  3318. var name = [], ch, escaped = false;
  3319. var read_escaped_identifier_char = function() {
  3320. escaped = true;
  3321. next();
  3322. if (peek() !== "u") {
  3323. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  3324. }
  3325. return read_escaped_char(false, true);
  3326. };
  3327. // Read first character (ID_Start)
  3328. if ((ch = peek()) === "\\") {
  3329. ch = read_escaped_identifier_char();
  3330. if (!is_identifier_start(ch)) {
  3331. parse_error("First identifier char is an invalid identifier char");
  3332. }
  3333. } else if (is_identifier_start(ch)) {
  3334. next();
  3335. } else {
  3336. return "";
  3337. }
  3338. name.push(ch);
  3339. // Read ID_Continue
  3340. while ((ch = peek()) != null) {
  3341. if ((ch = peek()) === "\\") {
  3342. ch = read_escaped_identifier_char();
  3343. if (!is_identifier_char(ch)) {
  3344. parse_error("Invalid escaped identifier char");
  3345. }
  3346. } else {
  3347. if (!is_identifier_char(ch)) {
  3348. break;
  3349. }
  3350. next();
  3351. }
  3352. name.push(ch);
  3353. }
  3354. const name_str = name.join("");
  3355. if (RESERVED_WORDS.has(name_str) && escaped) {
  3356. parse_error("Escaped characters are not allowed in keywords");
  3357. }
  3358. return name_str;
  3359. });
  3360. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  3361. var prev_backslash = false, ch, in_class = false;
  3362. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  3363. parse_error("Unexpected line terminator");
  3364. } else if (prev_backslash) {
  3365. source += "\\" + ch;
  3366. prev_backslash = false;
  3367. } else if (ch == "[") {
  3368. in_class = true;
  3369. source += ch;
  3370. } else if (ch == "]" && in_class) {
  3371. in_class = false;
  3372. source += ch;
  3373. } else if (ch == "/" && !in_class) {
  3374. break;
  3375. } else if (ch == "\\") {
  3376. prev_backslash = true;
  3377. } else {
  3378. source += ch;
  3379. }
  3380. const flags = read_name();
  3381. return token("regexp", "/" + source + "/" + flags);
  3382. });
  3383. function read_operator(prefix) {
  3384. function grow(op) {
  3385. if (!peek()) return op;
  3386. var bigger = op + peek();
  3387. if (OPERATORS.has(bigger)) {
  3388. next();
  3389. return grow(bigger);
  3390. } else {
  3391. return op;
  3392. }
  3393. }
  3394. return token("operator", grow(prefix || next()));
  3395. }
  3396. function handle_slash() {
  3397. next();
  3398. switch (peek()) {
  3399. case "/":
  3400. next();
  3401. return skip_line_comment("comment1");
  3402. case "*":
  3403. next();
  3404. return skip_multiline_comment();
  3405. }
  3406. return S.regex_allowed ? read_regexp("") : read_operator("/");
  3407. }
  3408. function handle_eq_sign() {
  3409. next();
  3410. if (peek() === ">") {
  3411. next();
  3412. return token("arrow", "=>");
  3413. } else {
  3414. return read_operator("=");
  3415. }
  3416. }
  3417. function handle_dot() {
  3418. next();
  3419. if (is_digit(peek().charCodeAt(0))) {
  3420. return read_num(".");
  3421. }
  3422. if (peek() === ".") {
  3423. next(); // Consume second dot
  3424. next(); // Consume third dot
  3425. return token("expand", "...");
  3426. }
  3427. return token("punc", ".");
  3428. }
  3429. function read_word() {
  3430. var word = read_name();
  3431. if (prev_was_dot) return token("name", word);
  3432. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  3433. : !KEYWORDS.has(word) ? token("name", word)
  3434. : OPERATORS.has(word) ? token("operator", word)
  3435. : token("keyword", word);
  3436. }
  3437. function read_private_word() {
  3438. next();
  3439. return token("privatename", read_name());
  3440. }
  3441. function with_eof_error(eof_error, cont) {
  3442. return function(x) {
  3443. try {
  3444. return cont(x);
  3445. } catch(ex) {
  3446. if (ex === EX_EOF) parse_error(eof_error);
  3447. else throw ex;
  3448. }
  3449. };
  3450. }
  3451. function next_token(force_regexp) {
  3452. if (force_regexp != null)
  3453. return read_regexp(force_regexp);
  3454. if (shebang && S.pos == 0 && looking_at("#!")) {
  3455. start_token();
  3456. forward(2);
  3457. skip_line_comment("comment5");
  3458. }
  3459. for (;;) {
  3460. skip_whitespace();
  3461. start_token();
  3462. if (html5_comments) {
  3463. if (looking_at("<!--")) {
  3464. forward(4);
  3465. skip_line_comment("comment3");
  3466. continue;
  3467. }
  3468. if (looking_at("-->") && S.newline_before) {
  3469. forward(3);
  3470. skip_line_comment("comment4");
  3471. continue;
  3472. }
  3473. }
  3474. var ch = peek();
  3475. if (!ch) return token("eof");
  3476. var code = ch.charCodeAt(0);
  3477. switch (code) {
  3478. case 34: case 39: return read_string();
  3479. case 46: return handle_dot();
  3480. case 47: {
  3481. var tok = handle_slash();
  3482. if (tok === next_token) continue;
  3483. return tok;
  3484. }
  3485. case 61: return handle_eq_sign();
  3486. case 63: {
  3487. if (!is_option_chain_op()) break; // Handled below
  3488. next(); // ?
  3489. next(); // .
  3490. return token("punc", "?.");
  3491. }
  3492. case 96: return read_template_characters(true);
  3493. case 123:
  3494. S.brace_counter++;
  3495. break;
  3496. case 125:
  3497. S.brace_counter--;
  3498. if (S.template_braces.length > 0
  3499. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  3500. return read_template_characters(false);
  3501. break;
  3502. }
  3503. if (is_digit(code)) return read_num();
  3504. if (PUNC_CHARS.has(ch)) return token("punc", next());
  3505. if (OPERATOR_CHARS.has(ch)) return read_operator();
  3506. if (code == 92 || is_identifier_start(ch)) return read_word();
  3507. if (code == 35) return read_private_word();
  3508. break;
  3509. }
  3510. parse_error("Unexpected character '" + ch + "'");
  3511. }
  3512. next_token.next = next;
  3513. next_token.peek = peek;
  3514. next_token.context = function(nc) {
  3515. if (nc) S = nc;
  3516. return S;
  3517. };
  3518. next_token.add_directive = function(directive) {
  3519. S.directive_stack[S.directive_stack.length - 1].push(directive);
  3520. if (S.directives[directive] === undefined) {
  3521. S.directives[directive] = 1;
  3522. } else {
  3523. S.directives[directive]++;
  3524. }
  3525. };
  3526. next_token.push_directives_stack = function() {
  3527. S.directive_stack.push([]);
  3528. };
  3529. next_token.pop_directives_stack = function() {
  3530. var directives = S.directive_stack[S.directive_stack.length - 1];
  3531. for (var i = 0; i < directives.length; i++) {
  3532. S.directives[directives[i]]--;
  3533. }
  3534. S.directive_stack.pop();
  3535. };
  3536. next_token.has_directive = function(directive) {
  3537. return S.directives[directive] > 0;
  3538. };
  3539. return next_token;
  3540. }
  3541. /* -----[ Parser (constants) ]----- */
  3542. var UNARY_PREFIX = makePredicate([
  3543. "typeof",
  3544. "void",
  3545. "delete",
  3546. "--",
  3547. "++",
  3548. "!",
  3549. "~",
  3550. "-",
  3551. "+"
  3552. ]);
  3553. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  3554. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  3555. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  3556. var PRECEDENCE = (function(a, ret) {
  3557. for (var i = 0; i < a.length; ++i) {
  3558. var b = a[i];
  3559. for (var j = 0; j < b.length; ++j) {
  3560. ret[b[j]] = i + 1;
  3561. }
  3562. }
  3563. return ret;
  3564. })(
  3565. [
  3566. ["||"],
  3567. ["??"],
  3568. ["&&"],
  3569. ["|"],
  3570. ["^"],
  3571. ["&"],
  3572. ["==", "===", "!=", "!=="],
  3573. ["<", ">", "<=", ">=", "in", "instanceof"],
  3574. [">>", "<<", ">>>"],
  3575. ["+", "-"],
  3576. ["*", "/", "%"],
  3577. ["**"]
  3578. ],
  3579. {}
  3580. );
  3581. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name" ]);
  3582. /* -----[ Parser ]----- */
  3583. function parse($TEXT, options) {
  3584. // maps start tokens to count of comments found outside of their parens
  3585. // Example: /* I count */ ( /* I don't */ foo() )
  3586. // Useful because comments_before property of call with parens outside
  3587. // contains both comments inside and outside these parens. Used to find the
  3588. const outer_comments_before_counts = new WeakMap();
  3589. options = defaults(options, {
  3590. bare_returns : false,
  3591. ecma : null, // Legacy
  3592. expression : false,
  3593. filename : null,
  3594. html5_comments : true,
  3595. module : false,
  3596. shebang : true,
  3597. strict : false,
  3598. toplevel : null,
  3599. }, true);
  3600. var S = {
  3601. input : (typeof $TEXT == "string"
  3602. ? tokenizer($TEXT, options.filename,
  3603. options.html5_comments, options.shebang)
  3604. : $TEXT),
  3605. token : null,
  3606. prev : null,
  3607. peeked : null,
  3608. in_function : 0,
  3609. in_async : -1,
  3610. in_generator : -1,
  3611. in_directives : true,
  3612. in_loop : 0,
  3613. labels : []
  3614. };
  3615. S.token = next();
  3616. function is(type, value) {
  3617. return is_token(S.token, type, value);
  3618. }
  3619. function peek() { return S.peeked || (S.peeked = S.input()); }
  3620. function next() {
  3621. S.prev = S.token;
  3622. if (!S.peeked) peek();
  3623. S.token = S.peeked;
  3624. S.peeked = null;
  3625. S.in_directives = S.in_directives && (
  3626. S.token.type == "string" || is("punc", ";")
  3627. );
  3628. return S.token;
  3629. }
  3630. function prev() {
  3631. return S.prev;
  3632. }
  3633. function croak(msg, line, col, pos) {
  3634. var ctx = S.input.context();
  3635. js_error(msg,
  3636. ctx.filename,
  3637. line != null ? line : ctx.tokline,
  3638. col != null ? col : ctx.tokcol,
  3639. pos != null ? pos : ctx.tokpos);
  3640. }
  3641. function token_error(token, msg) {
  3642. croak(msg, token.line, token.col);
  3643. }
  3644. function unexpected(token) {
  3645. if (token == null)
  3646. token = S.token;
  3647. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  3648. }
  3649. function expect_token(type, val) {
  3650. if (is(type, val)) {
  3651. return next();
  3652. }
  3653. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  3654. }
  3655. function expect(punc) { return expect_token("punc", punc); }
  3656. function has_newline_before(token) {
  3657. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  3658. }
  3659. function can_insert_semicolon() {
  3660. return !options.strict
  3661. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  3662. }
  3663. function is_in_generator() {
  3664. return S.in_generator === S.in_function;
  3665. }
  3666. function is_in_async() {
  3667. return S.in_async === S.in_function;
  3668. }
  3669. function can_await() {
  3670. return (
  3671. S.in_async === S.in_function
  3672. || S.in_function === 0 && S.input.has_directive("use strict")
  3673. );
  3674. }
  3675. function semicolon(optional) {
  3676. if (is("punc", ";")) next();
  3677. else if (!optional && !can_insert_semicolon()) unexpected();
  3678. }
  3679. function parenthesised() {
  3680. expect("(");
  3681. var exp = expression(true);
  3682. expect(")");
  3683. return exp;
  3684. }
  3685. function embed_tokens(parser) {
  3686. return function _embed_tokens_wrapper(...args) {
  3687. const start = S.token;
  3688. const expr = parser(...args);
  3689. expr.start = start;
  3690. expr.end = prev();
  3691. return expr;
  3692. };
  3693. }
  3694. function handle_regexp() {
  3695. if (is("operator", "/") || is("operator", "/=")) {
  3696. S.peeked = null;
  3697. S.token = S.input(S.token.value.substr(1)); // force regexp
  3698. }
  3699. }
  3700. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  3701. handle_regexp();
  3702. switch (S.token.type) {
  3703. case "string":
  3704. if (S.in_directives) {
  3705. var token = peek();
  3706. if (!LATEST_RAW.includes("\\")
  3707. && (is_token(token, "punc", ";")
  3708. || is_token(token, "punc", "}")
  3709. || has_newline_before(token)
  3710. || is_token(token, "eof"))) {
  3711. S.input.add_directive(S.token.value);
  3712. } else {
  3713. S.in_directives = false;
  3714. }
  3715. }
  3716. var dir = S.in_directives, stat = simple_statement();
  3717. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  3718. case "template_head":
  3719. case "num":
  3720. case "big_int":
  3721. case "regexp":
  3722. case "operator":
  3723. case "atom":
  3724. return simple_statement();
  3725. case "name":
  3726. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  3727. next();
  3728. next();
  3729. if (is_for_body) {
  3730. croak("functions are not allowed as the body of a loop");
  3731. }
  3732. return function_(AST_Defun, false, true, is_export_default);
  3733. }
  3734. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  3735. next();
  3736. var node = import_statement();
  3737. semicolon();
  3738. return node;
  3739. }
  3740. return is_token(peek(), "punc", ":")
  3741. ? labeled_statement()
  3742. : simple_statement();
  3743. case "punc":
  3744. switch (S.token.value) {
  3745. case "{":
  3746. return new AST_BlockStatement({
  3747. start : S.token,
  3748. body : block_(),
  3749. end : prev()
  3750. });
  3751. case "[":
  3752. case "(":
  3753. return simple_statement();
  3754. case ";":
  3755. S.in_directives = false;
  3756. next();
  3757. return new AST_EmptyStatement();
  3758. default:
  3759. unexpected();
  3760. }
  3761. case "keyword":
  3762. switch (S.token.value) {
  3763. case "break":
  3764. next();
  3765. return break_cont(AST_Break);
  3766. case "continue":
  3767. next();
  3768. return break_cont(AST_Continue);
  3769. case "debugger":
  3770. next();
  3771. semicolon();
  3772. return new AST_Debugger();
  3773. case "do":
  3774. next();
  3775. var body = in_loop(statement);
  3776. expect_token("keyword", "while");
  3777. var condition = parenthesised();
  3778. semicolon(true);
  3779. return new AST_Do({
  3780. body : body,
  3781. condition : condition
  3782. });
  3783. case "while":
  3784. next();
  3785. return new AST_While({
  3786. condition : parenthesised(),
  3787. body : in_loop(function() { return statement(false, true); })
  3788. });
  3789. case "for":
  3790. next();
  3791. return for_();
  3792. case "class":
  3793. next();
  3794. if (is_for_body) {
  3795. croak("classes are not allowed as the body of a loop");
  3796. }
  3797. if (is_if_body) {
  3798. croak("classes are not allowed as the body of an if");
  3799. }
  3800. return class_(AST_DefClass, is_export_default);
  3801. case "function":
  3802. next();
  3803. if (is_for_body) {
  3804. croak("functions are not allowed as the body of a loop");
  3805. }
  3806. return function_(AST_Defun, false, false, is_export_default);
  3807. case "if":
  3808. next();
  3809. return if_();
  3810. case "return":
  3811. if (S.in_function == 0 && !options.bare_returns)
  3812. croak("'return' outside of function");
  3813. next();
  3814. var value = null;
  3815. if (is("punc", ";")) {
  3816. next();
  3817. } else if (!can_insert_semicolon()) {
  3818. value = expression(true);
  3819. semicolon();
  3820. }
  3821. return new AST_Return({
  3822. value: value
  3823. });
  3824. case "switch":
  3825. next();
  3826. return new AST_Switch({
  3827. expression : parenthesised(),
  3828. body : in_loop(switch_body_)
  3829. });
  3830. case "throw":
  3831. next();
  3832. if (has_newline_before(S.token))
  3833. croak("Illegal newline after 'throw'");
  3834. var value = expression(true);
  3835. semicolon();
  3836. return new AST_Throw({
  3837. value: value
  3838. });
  3839. case "try":
  3840. next();
  3841. return try_();
  3842. case "var":
  3843. next();
  3844. var node = var_();
  3845. semicolon();
  3846. return node;
  3847. case "let":
  3848. next();
  3849. var node = let_();
  3850. semicolon();
  3851. return node;
  3852. case "const":
  3853. next();
  3854. var node = const_();
  3855. semicolon();
  3856. return node;
  3857. case "with":
  3858. if (S.input.has_directive("use strict")) {
  3859. croak("Strict mode may not include a with statement");
  3860. }
  3861. next();
  3862. return new AST_With({
  3863. expression : parenthesised(),
  3864. body : statement()
  3865. });
  3866. case "export":
  3867. if (!is_token(peek(), "punc", "(")) {
  3868. next();
  3869. var node = export_statement();
  3870. if (is("punc", ";")) semicolon();
  3871. return node;
  3872. }
  3873. }
  3874. }
  3875. unexpected();
  3876. });
  3877. function labeled_statement() {
  3878. var label = as_symbol(AST_Label);
  3879. if (label.name === "await" && is_in_async()) {
  3880. token_error(S.prev, "await cannot be used as label inside async function");
  3881. }
  3882. if (S.labels.some((l) => l.name === label.name)) {
  3883. // ECMA-262, 12.12: An ECMAScript program is considered
  3884. // syntactically incorrect if it contains a
  3885. // LabelledStatement that is enclosed by a
  3886. // LabelledStatement with the same Identifier as label.
  3887. croak("Label " + label.name + " defined twice");
  3888. }
  3889. expect(":");
  3890. S.labels.push(label);
  3891. var stat = statement();
  3892. S.labels.pop();
  3893. if (!(stat instanceof AST_IterationStatement)) {
  3894. // check for `continue` that refers to this label.
  3895. // those should be reported as syntax errors.
  3896. // https://github.com/mishoo/UglifyJS2/issues/287
  3897. label.references.forEach(function(ref) {
  3898. if (ref instanceof AST_Continue) {
  3899. ref = ref.label.start;
  3900. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  3901. ref.line, ref.col, ref.pos);
  3902. }
  3903. });
  3904. }
  3905. return new AST_LabeledStatement({ body: stat, label: label });
  3906. }
  3907. function simple_statement(tmp) {
  3908. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  3909. }
  3910. function break_cont(type) {
  3911. var label = null, ldef;
  3912. if (!can_insert_semicolon()) {
  3913. label = as_symbol(AST_LabelRef, true);
  3914. }
  3915. if (label != null) {
  3916. ldef = S.labels.find((l) => l.name === label.name);
  3917. if (!ldef)
  3918. croak("Undefined label " + label.name);
  3919. label.thedef = ldef;
  3920. } else if (S.in_loop == 0)
  3921. croak(type.TYPE + " not inside a loop or switch");
  3922. semicolon();
  3923. var stat = new type({ label: label });
  3924. if (ldef) ldef.references.push(stat);
  3925. return stat;
  3926. }
  3927. function for_() {
  3928. var for_await_error = "`for await` invalid in this context";
  3929. var await_tok = S.token;
  3930. if (await_tok.type == "name" && await_tok.value == "await") {
  3931. if (!can_await()) {
  3932. token_error(await_tok, for_await_error);
  3933. }
  3934. next();
  3935. } else {
  3936. await_tok = false;
  3937. }
  3938. expect("(");
  3939. var init = null;
  3940. if (!is("punc", ";")) {
  3941. init =
  3942. is("keyword", "var") ? (next(), var_(true)) :
  3943. is("keyword", "let") ? (next(), let_(true)) :
  3944. is("keyword", "const") ? (next(), const_(true)) :
  3945. expression(true, true);
  3946. var is_in = is("operator", "in");
  3947. var is_of = is("name", "of");
  3948. if (await_tok && !is_of) {
  3949. token_error(await_tok, for_await_error);
  3950. }
  3951. if (is_in || is_of) {
  3952. if (init instanceof AST_Definitions) {
  3953. if (init.definitions.length > 1)
  3954. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  3955. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  3956. token_error(init.start, "Invalid left-hand side in for..in loop");
  3957. }
  3958. next();
  3959. if (is_in) {
  3960. return for_in(init);
  3961. } else {
  3962. return for_of(init, !!await_tok);
  3963. }
  3964. }
  3965. } else if (await_tok) {
  3966. token_error(await_tok, for_await_error);
  3967. }
  3968. return regular_for(init);
  3969. }
  3970. function regular_for(init) {
  3971. expect(";");
  3972. var test = is("punc", ";") ? null : expression(true);
  3973. expect(";");
  3974. var step = is("punc", ")") ? null : expression(true);
  3975. expect(")");
  3976. return new AST_For({
  3977. init : init,
  3978. condition : test,
  3979. step : step,
  3980. body : in_loop(function() { return statement(false, true); })
  3981. });
  3982. }
  3983. function for_of(init, is_await) {
  3984. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  3985. var obj = expression(true);
  3986. expect(")");
  3987. return new AST_ForOf({
  3988. await : is_await,
  3989. init : init,
  3990. name : lhs,
  3991. object : obj,
  3992. body : in_loop(function() { return statement(false, true); })
  3993. });
  3994. }
  3995. function for_in(init) {
  3996. var obj = expression(true);
  3997. expect(")");
  3998. return new AST_ForIn({
  3999. init : init,
  4000. object : obj,
  4001. body : in_loop(function() { return statement(false, true); })
  4002. });
  4003. }
  4004. var arrow_function = function(start, argnames, is_async) {
  4005. if (has_newline_before(S.token)) {
  4006. croak("Unexpected newline before arrow (=>)");
  4007. }
  4008. expect_token("arrow", "=>");
  4009. var body = _function_body(is("punc", "{"), false, is_async);
  4010. var end =
  4011. body instanceof Array && body.length ? body[body.length - 1].end :
  4012. body instanceof Array ? start :
  4013. body.end;
  4014. return new AST_Arrow({
  4015. start : start,
  4016. end : end,
  4017. async : is_async,
  4018. argnames : argnames,
  4019. body : body
  4020. });
  4021. };
  4022. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  4023. var in_statement = ctor === AST_Defun;
  4024. var is_generator = is("operator", "*");
  4025. if (is_generator) {
  4026. next();
  4027. }
  4028. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  4029. if (in_statement && !name) {
  4030. if (is_export_default) {
  4031. ctor = AST_Function;
  4032. } else {
  4033. unexpected();
  4034. }
  4035. }
  4036. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  4037. unexpected(prev());
  4038. var args = [];
  4039. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  4040. return new ctor({
  4041. start : args.start,
  4042. end : body.end,
  4043. is_generator: is_generator,
  4044. async : is_async,
  4045. name : name,
  4046. argnames: args,
  4047. body : body
  4048. });
  4049. };
  4050. class UsedParametersTracker {
  4051. constructor(is_parameter, strict, duplicates_ok = false) {
  4052. this.is_parameter = is_parameter;
  4053. this.duplicates_ok = duplicates_ok;
  4054. this.parameters = new Set();
  4055. this.duplicate = null;
  4056. this.default_assignment = false;
  4057. this.spread = false;
  4058. this.strict_mode = !!strict;
  4059. }
  4060. add_parameter(token) {
  4061. if (this.parameters.has(token.value)) {
  4062. if (this.duplicate === null) {
  4063. this.duplicate = token;
  4064. }
  4065. this.check_strict();
  4066. } else {
  4067. this.parameters.add(token.value);
  4068. if (this.is_parameter) {
  4069. switch (token.value) {
  4070. case "arguments":
  4071. case "eval":
  4072. case "yield":
  4073. if (this.strict_mode) {
  4074. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  4075. }
  4076. break;
  4077. default:
  4078. if (RESERVED_WORDS.has(token.value)) {
  4079. unexpected();
  4080. }
  4081. }
  4082. }
  4083. }
  4084. }
  4085. mark_default_assignment(token) {
  4086. if (this.default_assignment === false) {
  4087. this.default_assignment = token;
  4088. }
  4089. }
  4090. mark_spread(token) {
  4091. if (this.spread === false) {
  4092. this.spread = token;
  4093. }
  4094. }
  4095. mark_strict_mode() {
  4096. this.strict_mode = true;
  4097. }
  4098. is_strict() {
  4099. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  4100. }
  4101. check_strict() {
  4102. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  4103. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  4104. }
  4105. }
  4106. }
  4107. function parameters(params) {
  4108. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  4109. expect("(");
  4110. while (!is("punc", ")")) {
  4111. var param = parameter(used_parameters);
  4112. params.push(param);
  4113. if (!is("punc", ")")) {
  4114. expect(",");
  4115. }
  4116. if (param instanceof AST_Expansion) {
  4117. break;
  4118. }
  4119. }
  4120. next();
  4121. }
  4122. function parameter(used_parameters, symbol_type) {
  4123. var param;
  4124. var expand = false;
  4125. if (used_parameters === undefined) {
  4126. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  4127. }
  4128. if (is("expand", "...")) {
  4129. expand = S.token;
  4130. used_parameters.mark_spread(S.token);
  4131. next();
  4132. }
  4133. param = binding_element(used_parameters, symbol_type);
  4134. if (is("operator", "=") && expand === false) {
  4135. used_parameters.mark_default_assignment(S.token);
  4136. next();
  4137. param = new AST_DefaultAssign({
  4138. start: param.start,
  4139. left: param,
  4140. operator: "=",
  4141. right: expression(false),
  4142. end: S.token
  4143. });
  4144. }
  4145. if (expand !== false) {
  4146. if (!is("punc", ")")) {
  4147. unexpected();
  4148. }
  4149. param = new AST_Expansion({
  4150. start: expand,
  4151. expression: param,
  4152. end: expand
  4153. });
  4154. }
  4155. used_parameters.check_strict();
  4156. return param;
  4157. }
  4158. function binding_element(used_parameters, symbol_type) {
  4159. var elements = [];
  4160. var first = true;
  4161. var is_expand = false;
  4162. var expand_token;
  4163. var first_token = S.token;
  4164. if (used_parameters === undefined) {
  4165. const strict = S.input.has_directive("use strict");
  4166. const duplicates_ok = symbol_type === AST_SymbolVar;
  4167. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  4168. }
  4169. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  4170. if (is("punc", "[")) {
  4171. next();
  4172. while (!is("punc", "]")) {
  4173. if (first) {
  4174. first = false;
  4175. } else {
  4176. expect(",");
  4177. }
  4178. if (is("expand", "...")) {
  4179. is_expand = true;
  4180. expand_token = S.token;
  4181. used_parameters.mark_spread(S.token);
  4182. next();
  4183. }
  4184. if (is("punc")) {
  4185. switch (S.token.value) {
  4186. case ",":
  4187. elements.push(new AST_Hole({
  4188. start: S.token,
  4189. end: S.token
  4190. }));
  4191. continue;
  4192. case "]": // Trailing comma after last element
  4193. break;
  4194. case "[":
  4195. case "{":
  4196. elements.push(binding_element(used_parameters, symbol_type));
  4197. break;
  4198. default:
  4199. unexpected();
  4200. }
  4201. } else if (is("name")) {
  4202. used_parameters.add_parameter(S.token);
  4203. elements.push(as_symbol(symbol_type));
  4204. } else {
  4205. croak("Invalid function parameter");
  4206. }
  4207. if (is("operator", "=") && is_expand === false) {
  4208. used_parameters.mark_default_assignment(S.token);
  4209. next();
  4210. elements[elements.length - 1] = new AST_DefaultAssign({
  4211. start: elements[elements.length - 1].start,
  4212. left: elements[elements.length - 1],
  4213. operator: "=",
  4214. right: expression(false),
  4215. end: S.token
  4216. });
  4217. }
  4218. if (is_expand) {
  4219. if (!is("punc", "]")) {
  4220. croak("Rest element must be last element");
  4221. }
  4222. elements[elements.length - 1] = new AST_Expansion({
  4223. start: expand_token,
  4224. expression: elements[elements.length - 1],
  4225. end: expand_token
  4226. });
  4227. }
  4228. }
  4229. expect("]");
  4230. used_parameters.check_strict();
  4231. return new AST_Destructuring({
  4232. start: first_token,
  4233. names: elements,
  4234. is_array: true,
  4235. end: prev()
  4236. });
  4237. } else if (is("punc", "{")) {
  4238. next();
  4239. while (!is("punc", "}")) {
  4240. if (first) {
  4241. first = false;
  4242. } else {
  4243. expect(",");
  4244. }
  4245. if (is("expand", "...")) {
  4246. is_expand = true;
  4247. expand_token = S.token;
  4248. used_parameters.mark_spread(S.token);
  4249. next();
  4250. }
  4251. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  4252. used_parameters.add_parameter(S.token);
  4253. var start = prev();
  4254. var value = as_symbol(symbol_type);
  4255. if (is_expand) {
  4256. elements.push(new AST_Expansion({
  4257. start: expand_token,
  4258. expression: value,
  4259. end: value.end,
  4260. }));
  4261. } else {
  4262. elements.push(new AST_ObjectKeyVal({
  4263. start: start,
  4264. key: value.name,
  4265. value: value,
  4266. end: value.end,
  4267. }));
  4268. }
  4269. } else if (is("punc", "}")) {
  4270. continue; // Allow trailing hole
  4271. } else {
  4272. var property_token = S.token;
  4273. var property = as_property_name();
  4274. if (property === null) {
  4275. unexpected(prev());
  4276. } else if (prev().type === "name" && !is("punc", ":")) {
  4277. elements.push(new AST_ObjectKeyVal({
  4278. start: prev(),
  4279. key: property,
  4280. value: new symbol_type({
  4281. start: prev(),
  4282. name: property,
  4283. end: prev()
  4284. }),
  4285. end: prev()
  4286. }));
  4287. } else {
  4288. expect(":");
  4289. elements.push(new AST_ObjectKeyVal({
  4290. start: property_token,
  4291. quote: property_token.quote,
  4292. key: property,
  4293. value: binding_element(used_parameters, symbol_type),
  4294. end: prev()
  4295. }));
  4296. }
  4297. }
  4298. if (is_expand) {
  4299. if (!is("punc", "}")) {
  4300. croak("Rest element must be last element");
  4301. }
  4302. } else if (is("operator", "=")) {
  4303. used_parameters.mark_default_assignment(S.token);
  4304. next();
  4305. elements[elements.length - 1].value = new AST_DefaultAssign({
  4306. start: elements[elements.length - 1].value.start,
  4307. left: elements[elements.length - 1].value,
  4308. operator: "=",
  4309. right: expression(false),
  4310. end: S.token
  4311. });
  4312. }
  4313. }
  4314. expect("}");
  4315. used_parameters.check_strict();
  4316. return new AST_Destructuring({
  4317. start: first_token,
  4318. names: elements,
  4319. is_array: false,
  4320. end: prev()
  4321. });
  4322. } else if (is("name")) {
  4323. used_parameters.add_parameter(S.token);
  4324. return as_symbol(symbol_type);
  4325. } else {
  4326. croak("Invalid function parameter");
  4327. }
  4328. }
  4329. function params_or_seq_(allow_arrows, maybe_sequence) {
  4330. var spread_token;
  4331. var invalid_sequence;
  4332. var trailing_comma;
  4333. var a = [];
  4334. expect("(");
  4335. while (!is("punc", ")")) {
  4336. if (spread_token) unexpected(spread_token);
  4337. if (is("expand", "...")) {
  4338. spread_token = S.token;
  4339. if (maybe_sequence) invalid_sequence = S.token;
  4340. next();
  4341. a.push(new AST_Expansion({
  4342. start: prev(),
  4343. expression: expression(),
  4344. end: S.token,
  4345. }));
  4346. } else {
  4347. a.push(expression());
  4348. }
  4349. if (!is("punc", ")")) {
  4350. expect(",");
  4351. if (is("punc", ")")) {
  4352. trailing_comma = prev();
  4353. if (maybe_sequence) invalid_sequence = trailing_comma;
  4354. }
  4355. }
  4356. }
  4357. expect(")");
  4358. if (allow_arrows && is("arrow", "=>")) {
  4359. if (spread_token && trailing_comma) unexpected(trailing_comma);
  4360. } else if (invalid_sequence) {
  4361. unexpected(invalid_sequence);
  4362. }
  4363. return a;
  4364. }
  4365. function _function_body(block, generator, is_async, name, args) {
  4366. var loop = S.in_loop;
  4367. var labels = S.labels;
  4368. var current_generator = S.in_generator;
  4369. var current_async = S.in_async;
  4370. ++S.in_function;
  4371. if (generator)
  4372. S.in_generator = S.in_function;
  4373. if (is_async)
  4374. S.in_async = S.in_function;
  4375. if (args) parameters(args);
  4376. if (block)
  4377. S.in_directives = true;
  4378. S.in_loop = 0;
  4379. S.labels = [];
  4380. if (block) {
  4381. S.input.push_directives_stack();
  4382. var a = block_();
  4383. if (name) _verify_symbol(name);
  4384. if (args) args.forEach(_verify_symbol);
  4385. S.input.pop_directives_stack();
  4386. } else {
  4387. var a = [new AST_Return({
  4388. start: S.token,
  4389. value: expression(false),
  4390. end: S.token
  4391. })];
  4392. }
  4393. --S.in_function;
  4394. S.in_loop = loop;
  4395. S.labels = labels;
  4396. S.in_generator = current_generator;
  4397. S.in_async = current_async;
  4398. return a;
  4399. }
  4400. function _await_expression() {
  4401. // Previous token must be "await" and not be interpreted as an identifier
  4402. if (!can_await()) {
  4403. croak("Unexpected await expression outside async function",
  4404. S.prev.line, S.prev.col, S.prev.pos);
  4405. }
  4406. // the await expression is parsed as a unary expression in Babel
  4407. return new AST_Await({
  4408. start: prev(),
  4409. end: S.token,
  4410. expression : maybe_unary(true),
  4411. });
  4412. }
  4413. function _yield_expression() {
  4414. // Previous token must be keyword yield and not be interpret as an identifier
  4415. if (!is_in_generator()) {
  4416. croak("Unexpected yield expression outside generator function",
  4417. S.prev.line, S.prev.col, S.prev.pos);
  4418. }
  4419. var start = S.token;
  4420. var star = false;
  4421. var has_expression = true;
  4422. // Attempt to get expression or star (and then the mandatory expression)
  4423. // behind yield on the same line.
  4424. //
  4425. // If nothing follows on the same line of the yieldExpression,
  4426. // it should default to the value `undefined` for yield to return.
  4427. // In that case, the `undefined` stored as `null` in ast.
  4428. //
  4429. // Note 1: It isn't allowed for yield* to close without an expression
  4430. // Note 2: If there is a nlb between yield and star, it is interpret as
  4431. // yield <explicit undefined> <inserted automatic semicolon> *
  4432. if (can_insert_semicolon() ||
  4433. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  4434. has_expression = false;
  4435. } else if (is("operator", "*")) {
  4436. star = true;
  4437. next();
  4438. }
  4439. return new AST_Yield({
  4440. start : start,
  4441. is_star : star,
  4442. expression : has_expression ? expression() : null,
  4443. end : prev()
  4444. });
  4445. }
  4446. function if_() {
  4447. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  4448. if (is("keyword", "else")) {
  4449. next();
  4450. belse = statement(false, false, true);
  4451. }
  4452. return new AST_If({
  4453. condition : cond,
  4454. body : body,
  4455. alternative : belse
  4456. });
  4457. }
  4458. function block_() {
  4459. expect("{");
  4460. var a = [];
  4461. while (!is("punc", "}")) {
  4462. if (is("eof")) unexpected();
  4463. a.push(statement());
  4464. }
  4465. next();
  4466. return a;
  4467. }
  4468. function switch_body_() {
  4469. expect("{");
  4470. var a = [], cur = null, branch = null, tmp;
  4471. while (!is("punc", "}")) {
  4472. if (is("eof")) unexpected();
  4473. if (is("keyword", "case")) {
  4474. if (branch) branch.end = prev();
  4475. cur = [];
  4476. branch = new AST_Case({
  4477. start : (tmp = S.token, next(), tmp),
  4478. expression : expression(true),
  4479. body : cur
  4480. });
  4481. a.push(branch);
  4482. expect(":");
  4483. } else if (is("keyword", "default")) {
  4484. if (branch) branch.end = prev();
  4485. cur = [];
  4486. branch = new AST_Default({
  4487. start : (tmp = S.token, next(), expect(":"), tmp),
  4488. body : cur
  4489. });
  4490. a.push(branch);
  4491. } else {
  4492. if (!cur) unexpected();
  4493. cur.push(statement());
  4494. }
  4495. }
  4496. if (branch) branch.end = prev();
  4497. next();
  4498. return a;
  4499. }
  4500. function try_() {
  4501. var body = block_(), bcatch = null, bfinally = null;
  4502. if (is("keyword", "catch")) {
  4503. var start = S.token;
  4504. next();
  4505. if (is("punc", "{")) {
  4506. var name = null;
  4507. } else {
  4508. expect("(");
  4509. var name = parameter(undefined, AST_SymbolCatch);
  4510. expect(")");
  4511. }
  4512. bcatch = new AST_Catch({
  4513. start : start,
  4514. argname : name,
  4515. body : block_(),
  4516. end : prev()
  4517. });
  4518. }
  4519. if (is("keyword", "finally")) {
  4520. var start = S.token;
  4521. next();
  4522. bfinally = new AST_Finally({
  4523. start : start,
  4524. body : block_(),
  4525. end : prev()
  4526. });
  4527. }
  4528. if (!bcatch && !bfinally)
  4529. croak("Missing catch/finally blocks");
  4530. return new AST_Try({
  4531. body : body,
  4532. bcatch : bcatch,
  4533. bfinally : bfinally
  4534. });
  4535. }
  4536. function vardefs(no_in, kind) {
  4537. var a = [];
  4538. var def;
  4539. for (;;) {
  4540. var sym_type =
  4541. kind === "var" ? AST_SymbolVar :
  4542. kind === "const" ? AST_SymbolConst :
  4543. kind === "let" ? AST_SymbolLet : null;
  4544. if (is("punc", "{") || is("punc", "[")) {
  4545. def = new AST_VarDef({
  4546. start: S.token,
  4547. name: binding_element(undefined, sym_type),
  4548. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  4549. end: prev()
  4550. });
  4551. } else {
  4552. def = new AST_VarDef({
  4553. start : S.token,
  4554. name : as_symbol(sym_type),
  4555. value : is("operator", "=")
  4556. ? (next(), expression(false, no_in))
  4557. : !no_in && kind === "const"
  4558. ? croak("Missing initializer in const declaration") : null,
  4559. end : prev()
  4560. });
  4561. if (def.name.name == "import") croak("Unexpected token: import");
  4562. }
  4563. a.push(def);
  4564. if (!is("punc", ","))
  4565. break;
  4566. next();
  4567. }
  4568. return a;
  4569. }
  4570. var var_ = function(no_in) {
  4571. return new AST_Var({
  4572. start : prev(),
  4573. definitions : vardefs(no_in, "var"),
  4574. end : prev()
  4575. });
  4576. };
  4577. var let_ = function(no_in) {
  4578. return new AST_Let({
  4579. start : prev(),
  4580. definitions : vardefs(no_in, "let"),
  4581. end : prev()
  4582. });
  4583. };
  4584. var const_ = function(no_in) {
  4585. return new AST_Const({
  4586. start : prev(),
  4587. definitions : vardefs(no_in, "const"),
  4588. end : prev()
  4589. });
  4590. };
  4591. var new_ = function(allow_calls) {
  4592. var start = S.token;
  4593. expect_token("operator", "new");
  4594. if (is("punc", ".")) {
  4595. next();
  4596. expect_token("name", "target");
  4597. return subscripts(new AST_NewTarget({
  4598. start : start,
  4599. end : prev()
  4600. }), allow_calls);
  4601. }
  4602. var newexp = expr_atom(false), args;
  4603. if (is("punc", "(")) {
  4604. next();
  4605. args = expr_list(")", true);
  4606. } else {
  4607. args = [];
  4608. }
  4609. var call = new AST_New({
  4610. start : start,
  4611. expression : newexp,
  4612. args : args,
  4613. end : prev()
  4614. });
  4615. annotate(call);
  4616. return subscripts(call, allow_calls);
  4617. };
  4618. function as_atom_node() {
  4619. var tok = S.token, ret;
  4620. switch (tok.type) {
  4621. case "name":
  4622. ret = _make_symbol(AST_SymbolRef);
  4623. break;
  4624. case "num":
  4625. ret = new AST_Number({
  4626. start: tok,
  4627. end: tok,
  4628. value: tok.value,
  4629. raw: LATEST_RAW
  4630. });
  4631. break;
  4632. case "big_int":
  4633. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  4634. break;
  4635. case "string":
  4636. ret = new AST_String({
  4637. start : tok,
  4638. end : tok,
  4639. value : tok.value,
  4640. quote : tok.quote
  4641. });
  4642. break;
  4643. case "regexp":
  4644. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  4645. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  4646. break;
  4647. case "atom":
  4648. switch (tok.value) {
  4649. case "false":
  4650. ret = new AST_False({ start: tok, end: tok });
  4651. break;
  4652. case "true":
  4653. ret = new AST_True({ start: tok, end: tok });
  4654. break;
  4655. case "null":
  4656. ret = new AST_Null({ start: tok, end: tok });
  4657. break;
  4658. }
  4659. break;
  4660. }
  4661. next();
  4662. return ret;
  4663. }
  4664. function to_fun_args(ex, default_seen_above) {
  4665. var insert_default = function(ex, default_value) {
  4666. if (default_value) {
  4667. return new AST_DefaultAssign({
  4668. start: ex.start,
  4669. left: ex,
  4670. operator: "=",
  4671. right: default_value,
  4672. end: default_value.end
  4673. });
  4674. }
  4675. return ex;
  4676. };
  4677. if (ex instanceof AST_Object) {
  4678. return insert_default(new AST_Destructuring({
  4679. start: ex.start,
  4680. end: ex.end,
  4681. is_array: false,
  4682. names: ex.properties.map(prop => to_fun_args(prop))
  4683. }), default_seen_above);
  4684. } else if (ex instanceof AST_ObjectKeyVal) {
  4685. ex.value = to_fun_args(ex.value);
  4686. return insert_default(ex, default_seen_above);
  4687. } else if (ex instanceof AST_Hole) {
  4688. return ex;
  4689. } else if (ex instanceof AST_Destructuring) {
  4690. ex.names = ex.names.map(name => to_fun_args(name));
  4691. return insert_default(ex, default_seen_above);
  4692. } else if (ex instanceof AST_SymbolRef) {
  4693. return insert_default(new AST_SymbolFunarg({
  4694. name: ex.name,
  4695. start: ex.start,
  4696. end: ex.end
  4697. }), default_seen_above);
  4698. } else if (ex instanceof AST_Expansion) {
  4699. ex.expression = to_fun_args(ex.expression);
  4700. return insert_default(ex, default_seen_above);
  4701. } else if (ex instanceof AST_Array) {
  4702. return insert_default(new AST_Destructuring({
  4703. start: ex.start,
  4704. end: ex.end,
  4705. is_array: true,
  4706. names: ex.elements.map(elm => to_fun_args(elm))
  4707. }), default_seen_above);
  4708. } else if (ex instanceof AST_Assign) {
  4709. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  4710. } else if (ex instanceof AST_DefaultAssign) {
  4711. ex.left = to_fun_args(ex.left);
  4712. return ex;
  4713. } else {
  4714. croak("Invalid function parameter", ex.start.line, ex.start.col);
  4715. }
  4716. }
  4717. var expr_atom = function(allow_calls, allow_arrows) {
  4718. if (is("operator", "new")) {
  4719. return new_(allow_calls);
  4720. }
  4721. if (is("operator", "import")) {
  4722. return import_meta();
  4723. }
  4724. var start = S.token;
  4725. var peeked;
  4726. var async = is("name", "async")
  4727. && (peeked = peek()).value != "["
  4728. && peeked.type != "arrow"
  4729. && as_atom_node();
  4730. if (is("punc")) {
  4731. switch (S.token.value) {
  4732. case "(":
  4733. if (async && !allow_calls) break;
  4734. var exprs = params_or_seq_(allow_arrows, !async);
  4735. if (allow_arrows && is("arrow", "=>")) {
  4736. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  4737. }
  4738. var ex = async ? new AST_Call({
  4739. expression: async,
  4740. args: exprs
  4741. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  4742. expressions: exprs
  4743. });
  4744. if (ex.start) {
  4745. const outer_comments_before = start.comments_before.length;
  4746. outer_comments_before_counts.set(start, outer_comments_before);
  4747. ex.start.comments_before.unshift(...start.comments_before);
  4748. start.comments_before = ex.start.comments_before;
  4749. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  4750. var comment = start.comments_before[0];
  4751. if (!comment.nlb) {
  4752. comment.nlb = start.nlb;
  4753. start.nlb = false;
  4754. }
  4755. }
  4756. start.comments_after = ex.start.comments_after;
  4757. }
  4758. ex.start = start;
  4759. var end = prev();
  4760. if (ex.end) {
  4761. end.comments_before = ex.end.comments_before;
  4762. ex.end.comments_after.push(...end.comments_after);
  4763. end.comments_after = ex.end.comments_after;
  4764. }
  4765. ex.end = end;
  4766. if (ex instanceof AST_Call) annotate(ex);
  4767. return subscripts(ex, allow_calls);
  4768. case "[":
  4769. return subscripts(array_(), allow_calls);
  4770. case "{":
  4771. return subscripts(object_or_destructuring_(), allow_calls);
  4772. }
  4773. if (!async) unexpected();
  4774. }
  4775. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  4776. var param = new AST_SymbolFunarg({
  4777. name: S.token.value,
  4778. start: start,
  4779. end: start,
  4780. });
  4781. next();
  4782. return arrow_function(start, [param], !!async);
  4783. }
  4784. if (is("keyword", "function")) {
  4785. next();
  4786. var func = function_(AST_Function, false, !!async);
  4787. func.start = start;
  4788. func.end = prev();
  4789. return subscripts(func, allow_calls);
  4790. }
  4791. if (async) return subscripts(async, allow_calls);
  4792. if (is("keyword", "class")) {
  4793. next();
  4794. var cls = class_(AST_ClassExpression);
  4795. cls.start = start;
  4796. cls.end = prev();
  4797. return subscripts(cls, allow_calls);
  4798. }
  4799. if (is("template_head")) {
  4800. return subscripts(template_string(), allow_calls);
  4801. }
  4802. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  4803. return subscripts(as_atom_node(), allow_calls);
  4804. }
  4805. unexpected();
  4806. };
  4807. function template_string() {
  4808. var segments = [], start = S.token;
  4809. segments.push(new AST_TemplateSegment({
  4810. start: S.token,
  4811. raw: LATEST_RAW,
  4812. value: S.token.value,
  4813. end: S.token
  4814. }));
  4815. while (!LATEST_TEMPLATE_END) {
  4816. next();
  4817. handle_regexp();
  4818. segments.push(expression(true));
  4819. segments.push(new AST_TemplateSegment({
  4820. start: S.token,
  4821. raw: LATEST_RAW,
  4822. value: S.token.value,
  4823. end: S.token
  4824. }));
  4825. }
  4826. next();
  4827. return new AST_TemplateString({
  4828. start: start,
  4829. segments: segments,
  4830. end: S.token
  4831. });
  4832. }
  4833. function expr_list(closing, allow_trailing_comma, allow_empty) {
  4834. var first = true, a = [];
  4835. while (!is("punc", closing)) {
  4836. if (first) first = false; else expect(",");
  4837. if (allow_trailing_comma && is("punc", closing)) break;
  4838. if (is("punc", ",") && allow_empty) {
  4839. a.push(new AST_Hole({ start: S.token, end: S.token }));
  4840. } else if (is("expand", "...")) {
  4841. next();
  4842. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  4843. } else {
  4844. a.push(expression(false));
  4845. }
  4846. }
  4847. next();
  4848. return a;
  4849. }
  4850. var array_ = embed_tokens(function() {
  4851. expect("[");
  4852. return new AST_Array({
  4853. elements: expr_list("]", !options.strict, true)
  4854. });
  4855. });
  4856. var create_accessor = embed_tokens((is_generator, is_async) => {
  4857. return function_(AST_Accessor, is_generator, is_async);
  4858. });
  4859. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  4860. var start = S.token, first = true, a = [];
  4861. expect("{");
  4862. while (!is("punc", "}")) {
  4863. if (first) first = false; else expect(",");
  4864. if (!options.strict && is("punc", "}"))
  4865. // allow trailing comma
  4866. break;
  4867. start = S.token;
  4868. if (start.type == "expand") {
  4869. next();
  4870. a.push(new AST_Expansion({
  4871. start: start,
  4872. expression: expression(false),
  4873. end: prev(),
  4874. }));
  4875. continue;
  4876. }
  4877. var name = as_property_name();
  4878. var value;
  4879. // Check property and fetch value
  4880. if (!is("punc", ":")) {
  4881. var concise = concise_method_or_getset(name, start);
  4882. if (concise) {
  4883. a.push(concise);
  4884. continue;
  4885. }
  4886. value = new AST_SymbolRef({
  4887. start: prev(),
  4888. name: name,
  4889. end: prev()
  4890. });
  4891. } else if (name === null) {
  4892. unexpected(prev());
  4893. } else {
  4894. next(); // `:` - see first condition
  4895. value = expression(false);
  4896. }
  4897. // Check for default value and alter value accordingly if necessary
  4898. if (is("operator", "=")) {
  4899. next();
  4900. value = new AST_Assign({
  4901. start: start,
  4902. left: value,
  4903. operator: "=",
  4904. right: expression(false),
  4905. logical: false,
  4906. end: prev()
  4907. });
  4908. }
  4909. // Create property
  4910. a.push(new AST_ObjectKeyVal({
  4911. start: start,
  4912. quote: start.quote,
  4913. key: name instanceof AST_Node ? name : "" + name,
  4914. value: value,
  4915. end: prev()
  4916. }));
  4917. }
  4918. next();
  4919. return new AST_Object({ properties: a });
  4920. });
  4921. function class_(KindOfClass, is_export_default) {
  4922. var start, method, class_name, extends_, a = [];
  4923. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  4924. S.input.add_directive("use strict");
  4925. if (S.token.type == "name" && S.token.value != "extends") {
  4926. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  4927. }
  4928. if (KindOfClass === AST_DefClass && !class_name) {
  4929. if (is_export_default) {
  4930. KindOfClass = AST_ClassExpression;
  4931. } else {
  4932. unexpected();
  4933. }
  4934. }
  4935. if (S.token.value == "extends") {
  4936. next();
  4937. extends_ = expression(true);
  4938. }
  4939. expect("{");
  4940. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  4941. while (!is("punc", "}")) {
  4942. start = S.token;
  4943. method = concise_method_or_getset(as_property_name(), start, true);
  4944. if (!method) { unexpected(); }
  4945. a.push(method);
  4946. while (is("punc", ";")) { next(); }
  4947. }
  4948. S.input.pop_directives_stack();
  4949. next();
  4950. return new KindOfClass({
  4951. start: start,
  4952. name: class_name,
  4953. extends: extends_,
  4954. properties: a,
  4955. end: prev(),
  4956. });
  4957. }
  4958. function concise_method_or_getset(name, start, is_class) {
  4959. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  4960. if (typeof name === "string" || typeof name === "number") {
  4961. return new SymbolClass({
  4962. start,
  4963. name: "" + name,
  4964. end: prev()
  4965. });
  4966. } else if (name === null) {
  4967. unexpected();
  4968. }
  4969. return name;
  4970. };
  4971. const is_not_method_start = () =>
  4972. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  4973. var is_async = false;
  4974. var is_static = false;
  4975. var is_generator = false;
  4976. var is_private = false;
  4977. var accessor_type = null;
  4978. if (is_class && name === "static" && is_not_method_start()) {
  4979. is_static = true;
  4980. name = as_property_name();
  4981. }
  4982. if (name === "async" && is_not_method_start()) {
  4983. is_async = true;
  4984. name = as_property_name();
  4985. }
  4986. if (prev().type === "operator" && prev().value === "*") {
  4987. is_generator = true;
  4988. name = as_property_name();
  4989. }
  4990. if ((name === "get" || name === "set") && is_not_method_start()) {
  4991. accessor_type = name;
  4992. name = as_property_name();
  4993. }
  4994. if (prev().type === "privatename") {
  4995. is_private = true;
  4996. }
  4997. const property_token = prev();
  4998. if (accessor_type != null) {
  4999. if (!is_private) {
  5000. const AccessorClass = accessor_type === "get"
  5001. ? AST_ObjectGetter
  5002. : AST_ObjectSetter;
  5003. name = get_symbol_ast(name);
  5004. return new AccessorClass({
  5005. start,
  5006. static: is_static,
  5007. key: name,
  5008. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  5009. value: create_accessor(),
  5010. end: prev()
  5011. });
  5012. } else {
  5013. const AccessorClass = accessor_type === "get"
  5014. ? AST_PrivateGetter
  5015. : AST_PrivateSetter;
  5016. return new AccessorClass({
  5017. start,
  5018. static: is_static,
  5019. key: get_symbol_ast(name),
  5020. value: create_accessor(),
  5021. end: prev(),
  5022. });
  5023. }
  5024. }
  5025. if (is("punc", "(")) {
  5026. name = get_symbol_ast(name);
  5027. const AST_MethodVariant = is_private
  5028. ? AST_PrivateMethod
  5029. : AST_ConciseMethod;
  5030. var node = new AST_MethodVariant({
  5031. start : start,
  5032. static : is_static,
  5033. is_generator: is_generator,
  5034. async : is_async,
  5035. key : name,
  5036. quote : name instanceof AST_SymbolMethod ?
  5037. property_token.quote : undefined,
  5038. value : create_accessor(is_generator, is_async),
  5039. end : prev()
  5040. });
  5041. return node;
  5042. }
  5043. if (is_class) {
  5044. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  5045. const quote = key instanceof AST_SymbolClassProperty
  5046. ? property_token.quote
  5047. : undefined;
  5048. const AST_ClassPropertyVariant = is_private
  5049. ? AST_ClassPrivateProperty
  5050. : AST_ClassProperty;
  5051. if (is("operator", "=")) {
  5052. next();
  5053. return new AST_ClassPropertyVariant({
  5054. start,
  5055. static: is_static,
  5056. quote,
  5057. key,
  5058. value: expression(false),
  5059. end: prev()
  5060. });
  5061. } else if (
  5062. is("name")
  5063. || is("privatename")
  5064. || is("operator", "*")
  5065. || is("punc", ";")
  5066. || is("punc", "}")
  5067. ) {
  5068. return new AST_ClassPropertyVariant({
  5069. start,
  5070. static: is_static,
  5071. quote,
  5072. key,
  5073. end: prev()
  5074. });
  5075. }
  5076. }
  5077. }
  5078. function maybe_import_assertion() {
  5079. if (is("name", "assert") && !has_newline_before(S.token)) {
  5080. next();
  5081. return object_or_destructuring_();
  5082. }
  5083. return null;
  5084. }
  5085. function import_statement() {
  5086. var start = prev();
  5087. var imported_name;
  5088. var imported_names;
  5089. if (is("name")) {
  5090. imported_name = as_symbol(AST_SymbolImport);
  5091. }
  5092. if (is("punc", ",")) {
  5093. next();
  5094. }
  5095. imported_names = map_names(true);
  5096. if (imported_names || imported_name) {
  5097. expect_token("name", "from");
  5098. }
  5099. var mod_str = S.token;
  5100. if (mod_str.type !== "string") {
  5101. unexpected();
  5102. }
  5103. next();
  5104. const assert_clause = maybe_import_assertion();
  5105. return new AST_Import({
  5106. start,
  5107. imported_name,
  5108. imported_names,
  5109. module_name: new AST_String({
  5110. start: mod_str,
  5111. value: mod_str.value,
  5112. quote: mod_str.quote,
  5113. end: mod_str,
  5114. }),
  5115. assert_clause,
  5116. end: S.token,
  5117. });
  5118. }
  5119. function import_meta() {
  5120. var start = S.token;
  5121. expect_token("operator", "import");
  5122. expect_token("punc", ".");
  5123. expect_token("name", "meta");
  5124. return subscripts(new AST_ImportMeta({
  5125. start: start,
  5126. end: prev()
  5127. }), false);
  5128. }
  5129. function map_name(is_import) {
  5130. function make_symbol(type) {
  5131. return new type({
  5132. name: as_property_name(),
  5133. start: prev(),
  5134. end: prev()
  5135. });
  5136. }
  5137. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  5138. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  5139. var start = S.token;
  5140. var foreign_name;
  5141. var name;
  5142. if (is_import) {
  5143. foreign_name = make_symbol(foreign_type);
  5144. } else {
  5145. name = make_symbol(type);
  5146. }
  5147. if (is("name", "as")) {
  5148. next(); // The "as" word
  5149. if (is_import) {
  5150. name = make_symbol(type);
  5151. } else {
  5152. foreign_name = make_symbol(foreign_type);
  5153. }
  5154. } else if (is_import) {
  5155. name = new type(foreign_name);
  5156. } else {
  5157. foreign_name = new foreign_type(name);
  5158. }
  5159. return new AST_NameMapping({
  5160. start: start,
  5161. foreign_name: foreign_name,
  5162. name: name,
  5163. end: prev(),
  5164. });
  5165. }
  5166. function map_nameAsterisk(is_import, name) {
  5167. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  5168. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  5169. var start = S.token;
  5170. var foreign_name;
  5171. var end = prev();
  5172. name = name || new type({
  5173. name: "*",
  5174. start: start,
  5175. end: end,
  5176. });
  5177. foreign_name = new foreign_type({
  5178. name: "*",
  5179. start: start,
  5180. end: end,
  5181. });
  5182. return new AST_NameMapping({
  5183. start: start,
  5184. foreign_name: foreign_name,
  5185. name: name,
  5186. end: end,
  5187. });
  5188. }
  5189. function map_names(is_import) {
  5190. var names;
  5191. if (is("punc", "{")) {
  5192. next();
  5193. names = [];
  5194. while (!is("punc", "}")) {
  5195. names.push(map_name(is_import));
  5196. if (is("punc", ",")) {
  5197. next();
  5198. }
  5199. }
  5200. next();
  5201. } else if (is("operator", "*")) {
  5202. var name;
  5203. next();
  5204. if (is_import && is("name", "as")) {
  5205. next(); // The "as" word
  5206. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  5207. }
  5208. names = [map_nameAsterisk(is_import, name)];
  5209. }
  5210. return names;
  5211. }
  5212. function export_statement() {
  5213. var start = S.token;
  5214. var is_default;
  5215. var exported_names;
  5216. if (is("keyword", "default")) {
  5217. is_default = true;
  5218. next();
  5219. } else if (exported_names = map_names(false)) {
  5220. if (is("name", "from")) {
  5221. next();
  5222. var mod_str = S.token;
  5223. if (mod_str.type !== "string") {
  5224. unexpected();
  5225. }
  5226. next();
  5227. const assert_clause = maybe_import_assertion();
  5228. return new AST_Export({
  5229. start: start,
  5230. is_default: is_default,
  5231. exported_names: exported_names,
  5232. module_name: new AST_String({
  5233. start: mod_str,
  5234. value: mod_str.value,
  5235. quote: mod_str.quote,
  5236. end: mod_str,
  5237. }),
  5238. end: prev(),
  5239. assert_clause
  5240. });
  5241. } else {
  5242. return new AST_Export({
  5243. start: start,
  5244. is_default: is_default,
  5245. exported_names: exported_names,
  5246. end: prev(),
  5247. });
  5248. }
  5249. }
  5250. var node;
  5251. var exported_value;
  5252. var exported_definition;
  5253. if (is("punc", "{")
  5254. || is_default
  5255. && (is("keyword", "class") || is("keyword", "function"))
  5256. && is_token(peek(), "punc")) {
  5257. exported_value = expression(false);
  5258. semicolon();
  5259. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  5260. unexpected(node.start);
  5261. } else if (
  5262. node instanceof AST_Definitions
  5263. || node instanceof AST_Defun
  5264. || node instanceof AST_DefClass
  5265. ) {
  5266. exported_definition = node;
  5267. } else if (
  5268. node instanceof AST_ClassExpression
  5269. || node instanceof AST_Function
  5270. ) {
  5271. exported_value = node;
  5272. } else if (node instanceof AST_SimpleStatement) {
  5273. exported_value = node.body;
  5274. } else {
  5275. unexpected(node.start);
  5276. }
  5277. return new AST_Export({
  5278. start: start,
  5279. is_default: is_default,
  5280. exported_value: exported_value,
  5281. exported_definition: exported_definition,
  5282. end: prev(),
  5283. assert_clause: null
  5284. });
  5285. }
  5286. function as_property_name() {
  5287. var tmp = S.token;
  5288. switch (tmp.type) {
  5289. case "punc":
  5290. if (tmp.value === "[") {
  5291. next();
  5292. var ex = expression(false);
  5293. expect("]");
  5294. return ex;
  5295. } else unexpected(tmp);
  5296. case "operator":
  5297. if (tmp.value === "*") {
  5298. next();
  5299. return null;
  5300. }
  5301. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  5302. unexpected(tmp);
  5303. }
  5304. /* falls through */
  5305. case "name":
  5306. case "privatename":
  5307. case "string":
  5308. case "num":
  5309. case "big_int":
  5310. case "keyword":
  5311. case "atom":
  5312. next();
  5313. return tmp.value;
  5314. default:
  5315. unexpected(tmp);
  5316. }
  5317. }
  5318. function as_name() {
  5319. var tmp = S.token;
  5320. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  5321. next();
  5322. return tmp.value;
  5323. }
  5324. function _make_symbol(type) {
  5325. var name = S.token.value;
  5326. return new (name == "this" ? AST_This :
  5327. name == "super" ? AST_Super :
  5328. type)({
  5329. name : String(name),
  5330. start : S.token,
  5331. end : S.token
  5332. });
  5333. }
  5334. function _verify_symbol(sym) {
  5335. var name = sym.name;
  5336. if (is_in_generator() && name == "yield") {
  5337. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  5338. }
  5339. if (S.input.has_directive("use strict")) {
  5340. if (name == "yield") {
  5341. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  5342. }
  5343. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  5344. token_error(sym.start, "Unexpected " + name + " in strict mode");
  5345. }
  5346. }
  5347. }
  5348. function as_symbol(type, noerror) {
  5349. if (!is("name")) {
  5350. if (!noerror) croak("Name expected");
  5351. return null;
  5352. }
  5353. var sym = _make_symbol(type);
  5354. _verify_symbol(sym);
  5355. next();
  5356. return sym;
  5357. }
  5358. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  5359. function annotate(node) {
  5360. var start = node.start;
  5361. var comments = start.comments_before;
  5362. const comments_outside_parens = outer_comments_before_counts.get(start);
  5363. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  5364. while (--i >= 0) {
  5365. var comment = comments[i];
  5366. if (/[@#]__/.test(comment.value)) {
  5367. if (/[@#]__PURE__/.test(comment.value)) {
  5368. set_annotation(node, _PURE);
  5369. break;
  5370. }
  5371. if (/[@#]__INLINE__/.test(comment.value)) {
  5372. set_annotation(node, _INLINE);
  5373. break;
  5374. }
  5375. if (/[@#]__NOINLINE__/.test(comment.value)) {
  5376. set_annotation(node, _NOINLINE);
  5377. break;
  5378. }
  5379. }
  5380. }
  5381. }
  5382. var subscripts = function(expr, allow_calls, is_chain) {
  5383. var start = expr.start;
  5384. if (is("punc", ".")) {
  5385. next();
  5386. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  5387. return subscripts(new AST_DotVariant({
  5388. start : start,
  5389. expression : expr,
  5390. optional : false,
  5391. property : as_name(),
  5392. end : prev()
  5393. }), allow_calls, is_chain);
  5394. }
  5395. if (is("punc", "[")) {
  5396. next();
  5397. var prop = expression(true);
  5398. expect("]");
  5399. return subscripts(new AST_Sub({
  5400. start : start,
  5401. expression : expr,
  5402. optional : false,
  5403. property : prop,
  5404. end : prev()
  5405. }), allow_calls, is_chain);
  5406. }
  5407. if (allow_calls && is("punc", "(")) {
  5408. next();
  5409. var call = new AST_Call({
  5410. start : start,
  5411. expression : expr,
  5412. optional : false,
  5413. args : call_args(),
  5414. end : prev()
  5415. });
  5416. annotate(call);
  5417. return subscripts(call, true, is_chain);
  5418. }
  5419. if (is("punc", "?.")) {
  5420. next();
  5421. let chain_contents;
  5422. if (allow_calls && is("punc", "(")) {
  5423. next();
  5424. const call = new AST_Call({
  5425. start,
  5426. optional: true,
  5427. expression: expr,
  5428. args: call_args(),
  5429. end: prev()
  5430. });
  5431. annotate(call);
  5432. chain_contents = subscripts(call, true, true);
  5433. } else if (is("name") || is("privatename")) {
  5434. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  5435. chain_contents = subscripts(new AST_DotVariant({
  5436. start,
  5437. expression: expr,
  5438. optional: true,
  5439. property: as_name(),
  5440. end: prev()
  5441. }), allow_calls, true);
  5442. } else if (is("punc", "[")) {
  5443. next();
  5444. const property = expression(true);
  5445. expect("]");
  5446. chain_contents = subscripts(new AST_Sub({
  5447. start,
  5448. expression: expr,
  5449. optional: true,
  5450. property,
  5451. end: prev()
  5452. }), allow_calls, true);
  5453. }
  5454. if (!chain_contents) unexpected();
  5455. if (chain_contents instanceof AST_Chain) return chain_contents;
  5456. return new AST_Chain({
  5457. start,
  5458. expression: chain_contents,
  5459. end: prev()
  5460. });
  5461. }
  5462. if (is("template_head")) {
  5463. if (is_chain) {
  5464. // a?.b`c` is a syntax error
  5465. unexpected();
  5466. }
  5467. return subscripts(new AST_PrefixedTemplateString({
  5468. start: start,
  5469. prefix: expr,
  5470. template_string: template_string(),
  5471. end: prev()
  5472. }), allow_calls);
  5473. }
  5474. return expr;
  5475. };
  5476. function call_args() {
  5477. var args = [];
  5478. while (!is("punc", ")")) {
  5479. if (is("expand", "...")) {
  5480. next();
  5481. args.push(new AST_Expansion({
  5482. start: prev(),
  5483. expression: expression(false),
  5484. end: prev()
  5485. }));
  5486. } else {
  5487. args.push(expression(false));
  5488. }
  5489. if (!is("punc", ")")) {
  5490. expect(",");
  5491. }
  5492. }
  5493. next();
  5494. return args;
  5495. }
  5496. var maybe_unary = function(allow_calls, allow_arrows) {
  5497. var start = S.token;
  5498. if (start.type == "name" && start.value == "await" && can_await()) {
  5499. next();
  5500. return _await_expression();
  5501. }
  5502. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  5503. next();
  5504. handle_regexp();
  5505. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  5506. ex.start = start;
  5507. ex.end = prev();
  5508. return ex;
  5509. }
  5510. var val = expr_atom(allow_calls, allow_arrows);
  5511. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  5512. if (val instanceof AST_Arrow) unexpected();
  5513. val = make_unary(AST_UnaryPostfix, S.token, val);
  5514. val.start = start;
  5515. val.end = S.token;
  5516. next();
  5517. }
  5518. return val;
  5519. };
  5520. function make_unary(ctor, token, expr) {
  5521. var op = token.value;
  5522. switch (op) {
  5523. case "++":
  5524. case "--":
  5525. if (!is_assignable(expr))
  5526. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  5527. break;
  5528. case "delete":
  5529. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  5530. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  5531. break;
  5532. }
  5533. return new ctor({ operator: op, expression: expr });
  5534. }
  5535. var expr_op = function(left, min_prec, no_in) {
  5536. var op = is("operator") ? S.token.value : null;
  5537. if (op == "in" && no_in) op = null;
  5538. if (op == "**" && left instanceof AST_UnaryPrefix
  5539. /* unary token in front not allowed - parenthesis required */
  5540. && !is_token(left.start, "punc", "(")
  5541. && left.operator !== "--" && left.operator !== "++")
  5542. unexpected(left.start);
  5543. var prec = op != null ? PRECEDENCE[op] : null;
  5544. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  5545. next();
  5546. var right = expr_op(maybe_unary(true), prec, no_in);
  5547. return expr_op(new AST_Binary({
  5548. start : left.start,
  5549. left : left,
  5550. operator : op,
  5551. right : right,
  5552. end : right.end
  5553. }), min_prec, no_in);
  5554. }
  5555. return left;
  5556. };
  5557. function expr_ops(no_in) {
  5558. return expr_op(maybe_unary(true, true), 0, no_in);
  5559. }
  5560. var maybe_conditional = function(no_in) {
  5561. var start = S.token;
  5562. var expr = expr_ops(no_in);
  5563. if (is("operator", "?")) {
  5564. next();
  5565. var yes = expression(false);
  5566. expect(":");
  5567. return new AST_Conditional({
  5568. start : start,
  5569. condition : expr,
  5570. consequent : yes,
  5571. alternative : expression(false, no_in),
  5572. end : prev()
  5573. });
  5574. }
  5575. return expr;
  5576. };
  5577. function is_assignable(expr) {
  5578. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  5579. }
  5580. function to_destructuring(node) {
  5581. if (node instanceof AST_Object) {
  5582. node = new AST_Destructuring({
  5583. start: node.start,
  5584. names: node.properties.map(to_destructuring),
  5585. is_array: false,
  5586. end: node.end
  5587. });
  5588. } else if (node instanceof AST_Array) {
  5589. var names = [];
  5590. for (var i = 0; i < node.elements.length; i++) {
  5591. // Only allow expansion as last element
  5592. if (node.elements[i] instanceof AST_Expansion) {
  5593. if (i + 1 !== node.elements.length) {
  5594. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  5595. }
  5596. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  5597. }
  5598. names.push(to_destructuring(node.elements[i]));
  5599. }
  5600. node = new AST_Destructuring({
  5601. start: node.start,
  5602. names: names,
  5603. is_array: true,
  5604. end: node.end
  5605. });
  5606. } else if (node instanceof AST_ObjectProperty) {
  5607. node.value = to_destructuring(node.value);
  5608. } else if (node instanceof AST_Assign) {
  5609. node = new AST_DefaultAssign({
  5610. start: node.start,
  5611. left: node.left,
  5612. operator: "=",
  5613. right: node.right,
  5614. end: node.end
  5615. });
  5616. }
  5617. return node;
  5618. }
  5619. // In ES6, AssignmentExpression can also be an ArrowFunction
  5620. var maybe_assign = function(no_in) {
  5621. handle_regexp();
  5622. var start = S.token;
  5623. if (start.type == "name" && start.value == "yield") {
  5624. if (is_in_generator()) {
  5625. next();
  5626. return _yield_expression();
  5627. } else if (S.input.has_directive("use strict")) {
  5628. token_error(S.token, "Unexpected yield identifier inside strict mode");
  5629. }
  5630. }
  5631. var left = maybe_conditional(no_in);
  5632. var val = S.token.value;
  5633. if (is("operator") && ASSIGNMENT.has(val)) {
  5634. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  5635. next();
  5636. return new AST_Assign({
  5637. start : start,
  5638. left : left,
  5639. operator : val,
  5640. right : maybe_assign(no_in),
  5641. logical : LOGICAL_ASSIGNMENT.has(val),
  5642. end : prev()
  5643. });
  5644. }
  5645. croak("Invalid assignment");
  5646. }
  5647. return left;
  5648. };
  5649. var expression = function(commas, no_in) {
  5650. var start = S.token;
  5651. var exprs = [];
  5652. while (true) {
  5653. exprs.push(maybe_assign(no_in));
  5654. if (!commas || !is("punc", ",")) break;
  5655. next();
  5656. commas = true;
  5657. }
  5658. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  5659. start : start,
  5660. expressions : exprs,
  5661. end : peek()
  5662. });
  5663. };
  5664. function in_loop(cont) {
  5665. ++S.in_loop;
  5666. var ret = cont();
  5667. --S.in_loop;
  5668. return ret;
  5669. }
  5670. if (options.expression) {
  5671. return expression(true);
  5672. }
  5673. return (function parse_toplevel() {
  5674. var start = S.token;
  5675. var body = [];
  5676. S.input.push_directives_stack();
  5677. if (options.module) S.input.add_directive("use strict");
  5678. while (!is("eof")) {
  5679. body.push(statement());
  5680. }
  5681. S.input.pop_directives_stack();
  5682. var end = prev();
  5683. var toplevel = options.toplevel;
  5684. if (toplevel) {
  5685. toplevel.body = toplevel.body.concat(body);
  5686. toplevel.end = end;
  5687. } else {
  5688. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  5689. }
  5690. return toplevel;
  5691. })();
  5692. }
  5693. /***********************************************************************
  5694. A JavaScript tokenizer / parser / beautifier / compressor.
  5695. https://github.com/mishoo/UglifyJS2
  5696. -------------------------------- (C) ---------------------------------
  5697. Author: Mihai Bazon
  5698. <mihai.bazon@gmail.com>
  5699. http://mihai.bazon.net/blog
  5700. Distributed under the BSD license:
  5701. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  5702. Redistribution and use in source and binary forms, with or without
  5703. modification, are permitted provided that the following conditions
  5704. are met:
  5705. * Redistributions of source code must retain the above
  5706. copyright notice, this list of conditions and the following
  5707. disclaimer.
  5708. * Redistributions in binary form must reproduce the above
  5709. copyright notice, this list of conditions and the following
  5710. disclaimer in the documentation and/or other materials
  5711. provided with the distribution.
  5712. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  5713. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5714. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  5715. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  5716. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  5717. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  5718. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  5719. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  5720. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  5721. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  5722. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5723. SUCH DAMAGE.
  5724. ***********************************************************************/
  5725. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  5726. if (!props) props = [];
  5727. else props = props.split(/\s+/);
  5728. var self_props = props;
  5729. if (base && base.PROPS)
  5730. props = props.concat(base.PROPS);
  5731. const proto = base && Object.create(base.prototype);
  5732. if (proto) {
  5733. ctor.prototype = proto;
  5734. ctor.BASE = base;
  5735. }
  5736. if (base) base.SUBCLASSES.push(ctor);
  5737. ctor.prototype.CTOR = ctor;
  5738. ctor.prototype.constructor = ctor;
  5739. ctor.PROPS = props || null;
  5740. ctor.SELF_PROPS = self_props;
  5741. ctor.SUBCLASSES = [];
  5742. if (type) {
  5743. ctor.prototype.TYPE = ctor.TYPE = type;
  5744. }
  5745. if (methods) for (let i in methods) if (HOP(methods, i)) {
  5746. if (i[0] === "$") {
  5747. ctor[i.substr(1)] = methods[i];
  5748. } else {
  5749. ctor.prototype[i] = methods[i];
  5750. }
  5751. }
  5752. ctor.DEFMETHOD = function(name, method) {
  5753. this.prototype[name] = method;
  5754. };
  5755. return ctor;
  5756. }
  5757. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  5758. const set_tok_flag = (tok, flag, truth) => {
  5759. if (truth) {
  5760. tok.flags |= flag;
  5761. } else {
  5762. tok.flags &= ~flag;
  5763. }
  5764. };
  5765. const TOK_FLAG_NLB = 0b0001;
  5766. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  5767. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  5768. class AST_Token {
  5769. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  5770. this.flags = (nlb ? 1 : 0);
  5771. this.type = type;
  5772. this.value = value;
  5773. this.line = line;
  5774. this.col = col;
  5775. this.pos = pos;
  5776. this.comments_before = comments_before;
  5777. this.comments_after = comments_after;
  5778. this.file = file;
  5779. Object.seal(this);
  5780. }
  5781. get nlb() {
  5782. return has_tok_flag(this, TOK_FLAG_NLB);
  5783. }
  5784. set nlb(new_nlb) {
  5785. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  5786. }
  5787. get quote() {
  5788. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  5789. ? ""
  5790. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  5791. }
  5792. set quote(quote_type) {
  5793. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  5794. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  5795. }
  5796. }
  5797. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  5798. if (props) {
  5799. this.start = props.start;
  5800. this.end = props.end;
  5801. }
  5802. this.flags = 0;
  5803. }, {
  5804. _clone: function(deep) {
  5805. if (deep) {
  5806. var self = this.clone();
  5807. return self.transform(new TreeTransformer(function(node) {
  5808. if (node !== self) {
  5809. return node.clone(true);
  5810. }
  5811. }));
  5812. }
  5813. return new this.CTOR(this);
  5814. },
  5815. clone: function(deep) {
  5816. return this._clone(deep);
  5817. },
  5818. $documentation: "Base class of all AST nodes",
  5819. $propdoc: {
  5820. start: "[AST_Token] The first token of this node",
  5821. end: "[AST_Token] The last token of this node"
  5822. },
  5823. _walk: function(visitor) {
  5824. return visitor._visit(this);
  5825. },
  5826. walk: function(visitor) {
  5827. return this._walk(visitor); // not sure the indirection will be any help
  5828. },
  5829. _children_backwards: () => {}
  5830. }, null);
  5831. /* -----[ statements ]----- */
  5832. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  5833. if (props) {
  5834. this.start = props.start;
  5835. this.end = props.end;
  5836. }
  5837. this.flags = 0;
  5838. }, {
  5839. $documentation: "Base class of all statements",
  5840. });
  5841. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  5842. if (props) {
  5843. this.start = props.start;
  5844. this.end = props.end;
  5845. }
  5846. this.flags = 0;
  5847. }, {
  5848. $documentation: "Represents a debugger statement",
  5849. }, AST_Statement);
  5850. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  5851. if (props) {
  5852. this.value = props.value;
  5853. this.quote = props.quote;
  5854. this.start = props.start;
  5855. this.end = props.end;
  5856. }
  5857. this.flags = 0;
  5858. }, {
  5859. $documentation: "Represents a directive, like \"use strict\";",
  5860. $propdoc: {
  5861. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  5862. quote: "[string] the original quote character"
  5863. },
  5864. }, AST_Statement);
  5865. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  5866. if (props) {
  5867. this.body = props.body;
  5868. this.start = props.start;
  5869. this.end = props.end;
  5870. }
  5871. this.flags = 0;
  5872. }, {
  5873. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  5874. $propdoc: {
  5875. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  5876. },
  5877. _walk: function(visitor) {
  5878. return visitor._visit(this, function() {
  5879. this.body._walk(visitor);
  5880. });
  5881. },
  5882. _children_backwards(push) {
  5883. push(this.body);
  5884. }
  5885. }, AST_Statement);
  5886. function walk_body(node, visitor) {
  5887. const body = node.body;
  5888. for (var i = 0, len = body.length; i < len; i++) {
  5889. body[i]._walk(visitor);
  5890. }
  5891. }
  5892. function clone_block_scope(deep) {
  5893. var clone = this._clone(deep);
  5894. if (this.block_scope) {
  5895. clone.block_scope = this.block_scope.clone();
  5896. }
  5897. return clone;
  5898. }
  5899. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  5900. if (props) {
  5901. this.body = props.body;
  5902. this.block_scope = props.block_scope;
  5903. this.start = props.start;
  5904. this.end = props.end;
  5905. }
  5906. this.flags = 0;
  5907. }, {
  5908. $documentation: "A body of statements (usually braced)",
  5909. $propdoc: {
  5910. body: "[AST_Statement*] an array of statements",
  5911. block_scope: "[AST_Scope] the block scope"
  5912. },
  5913. _walk: function(visitor) {
  5914. return visitor._visit(this, function() {
  5915. walk_body(this, visitor);
  5916. });
  5917. },
  5918. _children_backwards(push) {
  5919. let i = this.body.length;
  5920. while (i--) push(this.body[i]);
  5921. },
  5922. clone: clone_block_scope
  5923. }, AST_Statement);
  5924. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  5925. if (props) {
  5926. this.body = props.body;
  5927. this.block_scope = props.block_scope;
  5928. this.start = props.start;
  5929. this.end = props.end;
  5930. }
  5931. this.flags = 0;
  5932. }, {
  5933. $documentation: "A block statement",
  5934. }, AST_Block);
  5935. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  5936. if (props) {
  5937. this.start = props.start;
  5938. this.end = props.end;
  5939. }
  5940. this.flags = 0;
  5941. }, {
  5942. $documentation: "The empty statement (empty block or simply a semicolon)"
  5943. }, AST_Statement);
  5944. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  5945. if (props) {
  5946. this.body = props.body;
  5947. this.start = props.start;
  5948. this.end = props.end;
  5949. }
  5950. this.flags = 0;
  5951. }, {
  5952. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  5953. $propdoc: {
  5954. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  5955. }
  5956. }, AST_Statement);
  5957. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  5958. if (props) {
  5959. this.label = props.label;
  5960. this.body = props.body;
  5961. this.start = props.start;
  5962. this.end = props.end;
  5963. }
  5964. this.flags = 0;
  5965. }, {
  5966. $documentation: "Statement with a label",
  5967. $propdoc: {
  5968. label: "[AST_Label] a label definition"
  5969. },
  5970. _walk: function(visitor) {
  5971. return visitor._visit(this, function() {
  5972. this.label._walk(visitor);
  5973. this.body._walk(visitor);
  5974. });
  5975. },
  5976. _children_backwards(push) {
  5977. push(this.body);
  5978. push(this.label);
  5979. },
  5980. clone: function(deep) {
  5981. var node = this._clone(deep);
  5982. if (deep) {
  5983. var label = node.label;
  5984. var def = this.label;
  5985. node.walk(new TreeWalker(function(node) {
  5986. if (node instanceof AST_LoopControl
  5987. && node.label && node.label.thedef === def) {
  5988. node.label.thedef = label;
  5989. label.references.push(node);
  5990. }
  5991. }));
  5992. }
  5993. return node;
  5994. }
  5995. }, AST_StatementWithBody);
  5996. var AST_IterationStatement = DEFNODE(
  5997. "IterationStatement",
  5998. "block_scope",
  5999. function AST_IterationStatement(props) {
  6000. if (props) {
  6001. this.block_scope = props.block_scope;
  6002. this.body = props.body;
  6003. this.start = props.start;
  6004. this.end = props.end;
  6005. }
  6006. this.flags = 0;
  6007. },
  6008. {
  6009. $documentation: "Internal class. All loops inherit from it.",
  6010. $propdoc: {
  6011. block_scope: "[AST_Scope] the block scope for this iteration statement."
  6012. },
  6013. clone: clone_block_scope
  6014. },
  6015. AST_StatementWithBody
  6016. );
  6017. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  6018. if (props) {
  6019. this.condition = props.condition;
  6020. this.block_scope = props.block_scope;
  6021. this.body = props.body;
  6022. this.start = props.start;
  6023. this.end = props.end;
  6024. }
  6025. this.flags = 0;
  6026. }, {
  6027. $documentation: "Base class for do/while statements",
  6028. $propdoc: {
  6029. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  6030. }
  6031. }, AST_IterationStatement);
  6032. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  6033. if (props) {
  6034. this.condition = props.condition;
  6035. this.block_scope = props.block_scope;
  6036. this.body = props.body;
  6037. this.start = props.start;
  6038. this.end = props.end;
  6039. }
  6040. this.flags = 0;
  6041. }, {
  6042. $documentation: "A `do` statement",
  6043. _walk: function(visitor) {
  6044. return visitor._visit(this, function() {
  6045. this.body._walk(visitor);
  6046. this.condition._walk(visitor);
  6047. });
  6048. },
  6049. _children_backwards(push) {
  6050. push(this.condition);
  6051. push(this.body);
  6052. }
  6053. }, AST_DWLoop);
  6054. var AST_While = DEFNODE("While", null, function AST_While(props) {
  6055. if (props) {
  6056. this.condition = props.condition;
  6057. this.block_scope = props.block_scope;
  6058. this.body = props.body;
  6059. this.start = props.start;
  6060. this.end = props.end;
  6061. }
  6062. this.flags = 0;
  6063. }, {
  6064. $documentation: "A `while` statement",
  6065. _walk: function(visitor) {
  6066. return visitor._visit(this, function() {
  6067. this.condition._walk(visitor);
  6068. this.body._walk(visitor);
  6069. });
  6070. },
  6071. _children_backwards(push) {
  6072. push(this.body);
  6073. push(this.condition);
  6074. },
  6075. }, AST_DWLoop);
  6076. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  6077. if (props) {
  6078. this.init = props.init;
  6079. this.condition = props.condition;
  6080. this.step = props.step;
  6081. this.block_scope = props.block_scope;
  6082. this.body = props.body;
  6083. this.start = props.start;
  6084. this.end = props.end;
  6085. }
  6086. this.flags = 0;
  6087. }, {
  6088. $documentation: "A `for` statement",
  6089. $propdoc: {
  6090. init: "[AST_Node?] the `for` initialization code, or null if empty",
  6091. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  6092. step: "[AST_Node?] the `for` update clause, or null if empty"
  6093. },
  6094. _walk: function(visitor) {
  6095. return visitor._visit(this, function() {
  6096. if (this.init) this.init._walk(visitor);
  6097. if (this.condition) this.condition._walk(visitor);
  6098. if (this.step) this.step._walk(visitor);
  6099. this.body._walk(visitor);
  6100. });
  6101. },
  6102. _children_backwards(push) {
  6103. push(this.body);
  6104. if (this.step) push(this.step);
  6105. if (this.condition) push(this.condition);
  6106. if (this.init) push(this.init);
  6107. },
  6108. }, AST_IterationStatement);
  6109. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  6110. if (props) {
  6111. this.init = props.init;
  6112. this.object = props.object;
  6113. this.block_scope = props.block_scope;
  6114. this.body = props.body;
  6115. this.start = props.start;
  6116. this.end = props.end;
  6117. }
  6118. this.flags = 0;
  6119. }, {
  6120. $documentation: "A `for ... in` statement",
  6121. $propdoc: {
  6122. init: "[AST_Node] the `for/in` initialization code",
  6123. object: "[AST_Node] the object that we're looping through"
  6124. },
  6125. _walk: function(visitor) {
  6126. return visitor._visit(this, function() {
  6127. this.init._walk(visitor);
  6128. this.object._walk(visitor);
  6129. this.body._walk(visitor);
  6130. });
  6131. },
  6132. _children_backwards(push) {
  6133. push(this.body);
  6134. if (this.object) push(this.object);
  6135. if (this.init) push(this.init);
  6136. },
  6137. }, AST_IterationStatement);
  6138. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  6139. if (props) {
  6140. this.await = props.await;
  6141. this.init = props.init;
  6142. this.object = props.object;
  6143. this.block_scope = props.block_scope;
  6144. this.body = props.body;
  6145. this.start = props.start;
  6146. this.end = props.end;
  6147. }
  6148. this.flags = 0;
  6149. }, {
  6150. $documentation: "A `for ... of` statement",
  6151. }, AST_ForIn);
  6152. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  6153. if (props) {
  6154. this.expression = props.expression;
  6155. this.body = props.body;
  6156. this.start = props.start;
  6157. this.end = props.end;
  6158. }
  6159. this.flags = 0;
  6160. }, {
  6161. $documentation: "A `with` statement",
  6162. $propdoc: {
  6163. expression: "[AST_Node] the `with` expression"
  6164. },
  6165. _walk: function(visitor) {
  6166. return visitor._visit(this, function() {
  6167. this.expression._walk(visitor);
  6168. this.body._walk(visitor);
  6169. });
  6170. },
  6171. _children_backwards(push) {
  6172. push(this.body);
  6173. push(this.expression);
  6174. },
  6175. }, AST_StatementWithBody);
  6176. /* -----[ scope and functions ]----- */
  6177. var AST_Scope = DEFNODE(
  6178. "Scope",
  6179. "variables functions uses_with uses_eval parent_scope enclosed cname",
  6180. function AST_Scope(props) {
  6181. if (props) {
  6182. this.variables = props.variables;
  6183. this.functions = props.functions;
  6184. this.uses_with = props.uses_with;
  6185. this.uses_eval = props.uses_eval;
  6186. this.parent_scope = props.parent_scope;
  6187. this.enclosed = props.enclosed;
  6188. this.cname = props.cname;
  6189. this.body = props.body;
  6190. this.block_scope = props.block_scope;
  6191. this.start = props.start;
  6192. this.end = props.end;
  6193. }
  6194. this.flags = 0;
  6195. },
  6196. {
  6197. $documentation: "Base class for all statements introducing a lexical scope",
  6198. $propdoc: {
  6199. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  6200. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  6201. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  6202. parent_scope: "[AST_Scope?/S] link to the parent scope",
  6203. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  6204. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  6205. },
  6206. get_defun_scope: function() {
  6207. var self = this;
  6208. while (self.is_block_scope()) {
  6209. self = self.parent_scope;
  6210. }
  6211. return self;
  6212. },
  6213. clone: function(deep, toplevel) {
  6214. var node = this._clone(deep);
  6215. if (deep && this.variables && toplevel && !this._block_scope) {
  6216. node.figure_out_scope({}, {
  6217. toplevel: toplevel,
  6218. parent_scope: this.parent_scope
  6219. });
  6220. } else {
  6221. if (this.variables) node.variables = new Map(this.variables);
  6222. if (this.enclosed) node.enclosed = this.enclosed.slice();
  6223. if (this._block_scope) node._block_scope = this._block_scope;
  6224. }
  6225. return node;
  6226. },
  6227. pinned: function() {
  6228. return this.uses_eval || this.uses_with;
  6229. }
  6230. },
  6231. AST_Block
  6232. );
  6233. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  6234. if (props) {
  6235. this.globals = props.globals;
  6236. this.variables = props.variables;
  6237. this.functions = props.functions;
  6238. this.uses_with = props.uses_with;
  6239. this.uses_eval = props.uses_eval;
  6240. this.parent_scope = props.parent_scope;
  6241. this.enclosed = props.enclosed;
  6242. this.cname = props.cname;
  6243. this.body = props.body;
  6244. this.block_scope = props.block_scope;
  6245. this.start = props.start;
  6246. this.end = props.end;
  6247. }
  6248. this.flags = 0;
  6249. }, {
  6250. $documentation: "The toplevel scope",
  6251. $propdoc: {
  6252. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  6253. },
  6254. wrap_commonjs: function(name) {
  6255. var body = this.body;
  6256. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  6257. wrapped_tl = parse(wrapped_tl);
  6258. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  6259. if (node instanceof AST_Directive && node.value == "$ORIG") {
  6260. return MAP.splice(body);
  6261. }
  6262. }));
  6263. return wrapped_tl;
  6264. },
  6265. wrap_enclose: function(args_values) {
  6266. if (typeof args_values != "string") args_values = "";
  6267. var index = args_values.indexOf(":");
  6268. if (index < 0) index = args_values.length;
  6269. var body = this.body;
  6270. return parse([
  6271. "(function(",
  6272. args_values.slice(0, index),
  6273. '){"$ORIG"})(',
  6274. args_values.slice(index + 1),
  6275. ")"
  6276. ].join("")).transform(new TreeTransformer(function(node) {
  6277. if (node instanceof AST_Directive && node.value == "$ORIG") {
  6278. return MAP.splice(body);
  6279. }
  6280. }));
  6281. }
  6282. }, AST_Scope);
  6283. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  6284. if (props) {
  6285. this.expression = props.expression;
  6286. this.start = props.start;
  6287. this.end = props.end;
  6288. }
  6289. this.flags = 0;
  6290. }, {
  6291. $documentation: "An expandible argument, such as ...rest, a splat, such as [1,2,...all], or an expansion in a variable declaration, such as var [first, ...rest] = list",
  6292. $propdoc: {
  6293. expression: "[AST_Node] the thing to be expanded"
  6294. },
  6295. _walk: function(visitor) {
  6296. return visitor._visit(this, function() {
  6297. this.expression.walk(visitor);
  6298. });
  6299. },
  6300. _children_backwards(push) {
  6301. push(this.expression);
  6302. },
  6303. });
  6304. var AST_Lambda = DEFNODE(
  6305. "Lambda",
  6306. "name argnames uses_arguments is_generator async",
  6307. function AST_Lambda(props) {
  6308. if (props) {
  6309. this.name = props.name;
  6310. this.argnames = props.argnames;
  6311. this.uses_arguments = props.uses_arguments;
  6312. this.is_generator = props.is_generator;
  6313. this.async = props.async;
  6314. this.variables = props.variables;
  6315. this.functions = props.functions;
  6316. this.uses_with = props.uses_with;
  6317. this.uses_eval = props.uses_eval;
  6318. this.parent_scope = props.parent_scope;
  6319. this.enclosed = props.enclosed;
  6320. this.cname = props.cname;
  6321. this.body = props.body;
  6322. this.block_scope = props.block_scope;
  6323. this.start = props.start;
  6324. this.end = props.end;
  6325. }
  6326. this.flags = 0;
  6327. },
  6328. {
  6329. $documentation: "Base class for functions",
  6330. $propdoc: {
  6331. name: "[AST_SymbolDeclaration?] the name of this function",
  6332. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  6333. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  6334. is_generator: "[boolean] is this a generator method",
  6335. async: "[boolean] is this method async",
  6336. },
  6337. args_as_names: function () {
  6338. var out = [];
  6339. for (var i = 0; i < this.argnames.length; i++) {
  6340. if (this.argnames[i] instanceof AST_Destructuring) {
  6341. out.push(...this.argnames[i].all_symbols());
  6342. } else {
  6343. out.push(this.argnames[i]);
  6344. }
  6345. }
  6346. return out;
  6347. },
  6348. _walk: function(visitor) {
  6349. return visitor._visit(this, function() {
  6350. if (this.name) this.name._walk(visitor);
  6351. var argnames = this.argnames;
  6352. for (var i = 0, len = argnames.length; i < len; i++) {
  6353. argnames[i]._walk(visitor);
  6354. }
  6355. walk_body(this, visitor);
  6356. });
  6357. },
  6358. _children_backwards(push) {
  6359. let i = this.body.length;
  6360. while (i--) push(this.body[i]);
  6361. i = this.argnames.length;
  6362. while (i--) push(this.argnames[i]);
  6363. if (this.name) push(this.name);
  6364. },
  6365. is_braceless() {
  6366. return this.body[0] instanceof AST_Return && this.body[0].value;
  6367. },
  6368. // Default args and expansion don't count, so .argnames.length doesn't cut it
  6369. length_property() {
  6370. let length = 0;
  6371. for (const arg of this.argnames) {
  6372. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  6373. length++;
  6374. }
  6375. }
  6376. return length;
  6377. }
  6378. },
  6379. AST_Scope
  6380. );
  6381. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  6382. if (props) {
  6383. this.name = props.name;
  6384. this.argnames = props.argnames;
  6385. this.uses_arguments = props.uses_arguments;
  6386. this.is_generator = props.is_generator;
  6387. this.async = props.async;
  6388. this.variables = props.variables;
  6389. this.functions = props.functions;
  6390. this.uses_with = props.uses_with;
  6391. this.uses_eval = props.uses_eval;
  6392. this.parent_scope = props.parent_scope;
  6393. this.enclosed = props.enclosed;
  6394. this.cname = props.cname;
  6395. this.body = props.body;
  6396. this.block_scope = props.block_scope;
  6397. this.start = props.start;
  6398. this.end = props.end;
  6399. }
  6400. this.flags = 0;
  6401. }, {
  6402. $documentation: "A setter/getter function. The `name` property is always null."
  6403. }, AST_Lambda);
  6404. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  6405. if (props) {
  6406. this.name = props.name;
  6407. this.argnames = props.argnames;
  6408. this.uses_arguments = props.uses_arguments;
  6409. this.is_generator = props.is_generator;
  6410. this.async = props.async;
  6411. this.variables = props.variables;
  6412. this.functions = props.functions;
  6413. this.uses_with = props.uses_with;
  6414. this.uses_eval = props.uses_eval;
  6415. this.parent_scope = props.parent_scope;
  6416. this.enclosed = props.enclosed;
  6417. this.cname = props.cname;
  6418. this.body = props.body;
  6419. this.block_scope = props.block_scope;
  6420. this.start = props.start;
  6421. this.end = props.end;
  6422. }
  6423. this.flags = 0;
  6424. }, {
  6425. $documentation: "A function expression"
  6426. }, AST_Lambda);
  6427. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  6428. if (props) {
  6429. this.name = props.name;
  6430. this.argnames = props.argnames;
  6431. this.uses_arguments = props.uses_arguments;
  6432. this.is_generator = props.is_generator;
  6433. this.async = props.async;
  6434. this.variables = props.variables;
  6435. this.functions = props.functions;
  6436. this.uses_with = props.uses_with;
  6437. this.uses_eval = props.uses_eval;
  6438. this.parent_scope = props.parent_scope;
  6439. this.enclosed = props.enclosed;
  6440. this.cname = props.cname;
  6441. this.body = props.body;
  6442. this.block_scope = props.block_scope;
  6443. this.start = props.start;
  6444. this.end = props.end;
  6445. }
  6446. this.flags = 0;
  6447. }, {
  6448. $documentation: "An ES6 Arrow function ((a) => b)"
  6449. }, AST_Lambda);
  6450. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  6451. if (props) {
  6452. this.name = props.name;
  6453. this.argnames = props.argnames;
  6454. this.uses_arguments = props.uses_arguments;
  6455. this.is_generator = props.is_generator;
  6456. this.async = props.async;
  6457. this.variables = props.variables;
  6458. this.functions = props.functions;
  6459. this.uses_with = props.uses_with;
  6460. this.uses_eval = props.uses_eval;
  6461. this.parent_scope = props.parent_scope;
  6462. this.enclosed = props.enclosed;
  6463. this.cname = props.cname;
  6464. this.body = props.body;
  6465. this.block_scope = props.block_scope;
  6466. this.start = props.start;
  6467. this.end = props.end;
  6468. }
  6469. this.flags = 0;
  6470. }, {
  6471. $documentation: "A function definition"
  6472. }, AST_Lambda);
  6473. /* -----[ DESTRUCTURING ]----- */
  6474. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  6475. if (props) {
  6476. this.names = props.names;
  6477. this.is_array = props.is_array;
  6478. this.start = props.start;
  6479. this.end = props.end;
  6480. }
  6481. this.flags = 0;
  6482. }, {
  6483. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  6484. $propdoc: {
  6485. "names": "[AST_Node*] Array of properties or elements",
  6486. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  6487. },
  6488. _walk: function(visitor) {
  6489. return visitor._visit(this, function() {
  6490. this.names.forEach(function(name) {
  6491. name._walk(visitor);
  6492. });
  6493. });
  6494. },
  6495. _children_backwards(push) {
  6496. let i = this.names.length;
  6497. while (i--) push(this.names[i]);
  6498. },
  6499. all_symbols: function() {
  6500. var out = [];
  6501. this.walk(new TreeWalker(function (node) {
  6502. if (node instanceof AST_Symbol) {
  6503. out.push(node);
  6504. }
  6505. }));
  6506. return out;
  6507. }
  6508. });
  6509. var AST_PrefixedTemplateString = DEFNODE(
  6510. "PrefixedTemplateString",
  6511. "template_string prefix",
  6512. function AST_PrefixedTemplateString(props) {
  6513. if (props) {
  6514. this.template_string = props.template_string;
  6515. this.prefix = props.prefix;
  6516. this.start = props.start;
  6517. this.end = props.end;
  6518. }
  6519. this.flags = 0;
  6520. },
  6521. {
  6522. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  6523. $propdoc: {
  6524. template_string: "[AST_TemplateString] The template string",
  6525. prefix: "[AST_Node] The prefix, which will get called."
  6526. },
  6527. _walk: function(visitor) {
  6528. return visitor._visit(this, function () {
  6529. this.prefix._walk(visitor);
  6530. this.template_string._walk(visitor);
  6531. });
  6532. },
  6533. _children_backwards(push) {
  6534. push(this.template_string);
  6535. push(this.prefix);
  6536. },
  6537. }
  6538. );
  6539. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  6540. if (props) {
  6541. this.segments = props.segments;
  6542. this.start = props.start;
  6543. this.end = props.end;
  6544. }
  6545. this.flags = 0;
  6546. }, {
  6547. $documentation: "A template string literal",
  6548. $propdoc: {
  6549. segments: "[AST_Node*] One or more segments, starting with AST_TemplateSegment. AST_Node may follow AST_TemplateSegment, but each AST_Node must be followed by AST_TemplateSegment."
  6550. },
  6551. _walk: function(visitor) {
  6552. return visitor._visit(this, function() {
  6553. this.segments.forEach(function(seg) {
  6554. seg._walk(visitor);
  6555. });
  6556. });
  6557. },
  6558. _children_backwards(push) {
  6559. let i = this.segments.length;
  6560. while (i--) push(this.segments[i]);
  6561. }
  6562. });
  6563. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  6564. if (props) {
  6565. this.value = props.value;
  6566. this.raw = props.raw;
  6567. this.start = props.start;
  6568. this.end = props.end;
  6569. }
  6570. this.flags = 0;
  6571. }, {
  6572. $documentation: "A segment of a template string literal",
  6573. $propdoc: {
  6574. value: "Content of the segment",
  6575. raw: "Raw source of the segment",
  6576. }
  6577. });
  6578. /* -----[ JUMPS ]----- */
  6579. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  6580. if (props) {
  6581. this.start = props.start;
  6582. this.end = props.end;
  6583. }
  6584. this.flags = 0;
  6585. }, {
  6586. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  6587. }, AST_Statement);
  6588. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  6589. if (props) {
  6590. this.value = props.value;
  6591. this.start = props.start;
  6592. this.end = props.end;
  6593. }
  6594. this.flags = 0;
  6595. }, {
  6596. $documentation: "Base class for “exits” (`return` and `throw`)",
  6597. $propdoc: {
  6598. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  6599. },
  6600. _walk: function(visitor) {
  6601. return visitor._visit(this, this.value && function() {
  6602. this.value._walk(visitor);
  6603. });
  6604. },
  6605. _children_backwards(push) {
  6606. if (this.value) push(this.value);
  6607. },
  6608. }, AST_Jump);
  6609. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  6610. if (props) {
  6611. this.value = props.value;
  6612. this.start = props.start;
  6613. this.end = props.end;
  6614. }
  6615. this.flags = 0;
  6616. }, {
  6617. $documentation: "A `return` statement"
  6618. }, AST_Exit);
  6619. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  6620. if (props) {
  6621. this.value = props.value;
  6622. this.start = props.start;
  6623. this.end = props.end;
  6624. }
  6625. this.flags = 0;
  6626. }, {
  6627. $documentation: "A `throw` statement"
  6628. }, AST_Exit);
  6629. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  6630. if (props) {
  6631. this.label = props.label;
  6632. this.start = props.start;
  6633. this.end = props.end;
  6634. }
  6635. this.flags = 0;
  6636. }, {
  6637. $documentation: "Base class for loop control statements (`break` and `continue`)",
  6638. $propdoc: {
  6639. label: "[AST_LabelRef?] the label, or null if none",
  6640. },
  6641. _walk: function(visitor) {
  6642. return visitor._visit(this, this.label && function() {
  6643. this.label._walk(visitor);
  6644. });
  6645. },
  6646. _children_backwards(push) {
  6647. if (this.label) push(this.label);
  6648. },
  6649. }, AST_Jump);
  6650. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  6651. if (props) {
  6652. this.label = props.label;
  6653. this.start = props.start;
  6654. this.end = props.end;
  6655. }
  6656. this.flags = 0;
  6657. }, {
  6658. $documentation: "A `break` statement"
  6659. }, AST_LoopControl);
  6660. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  6661. if (props) {
  6662. this.label = props.label;
  6663. this.start = props.start;
  6664. this.end = props.end;
  6665. }
  6666. this.flags = 0;
  6667. }, {
  6668. $documentation: "A `continue` statement"
  6669. }, AST_LoopControl);
  6670. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  6671. if (props) {
  6672. this.expression = props.expression;
  6673. this.start = props.start;
  6674. this.end = props.end;
  6675. }
  6676. this.flags = 0;
  6677. }, {
  6678. $documentation: "An `await` statement",
  6679. $propdoc: {
  6680. expression: "[AST_Node] the mandatory expression being awaited",
  6681. },
  6682. _walk: function(visitor) {
  6683. return visitor._visit(this, function() {
  6684. this.expression._walk(visitor);
  6685. });
  6686. },
  6687. _children_backwards(push) {
  6688. push(this.expression);
  6689. },
  6690. });
  6691. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  6692. if (props) {
  6693. this.expression = props.expression;
  6694. this.is_star = props.is_star;
  6695. this.start = props.start;
  6696. this.end = props.end;
  6697. }
  6698. this.flags = 0;
  6699. }, {
  6700. $documentation: "A `yield` statement",
  6701. $propdoc: {
  6702. expression: "[AST_Node?] the value returned or thrown by this statement; could be null (representing undefined) but only when is_star is set to false",
  6703. is_star: "[Boolean] Whether this is a yield or yield* statement"
  6704. },
  6705. _walk: function(visitor) {
  6706. return visitor._visit(this, this.expression && function() {
  6707. this.expression._walk(visitor);
  6708. });
  6709. },
  6710. _children_backwards(push) {
  6711. if (this.expression) push(this.expression);
  6712. }
  6713. });
  6714. /* -----[ IF ]----- */
  6715. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  6716. if (props) {
  6717. this.condition = props.condition;
  6718. this.alternative = props.alternative;
  6719. this.body = props.body;
  6720. this.start = props.start;
  6721. this.end = props.end;
  6722. }
  6723. this.flags = 0;
  6724. }, {
  6725. $documentation: "A `if` statement",
  6726. $propdoc: {
  6727. condition: "[AST_Node] the `if` condition",
  6728. alternative: "[AST_Statement?] the `else` part, or null if not present"
  6729. },
  6730. _walk: function(visitor) {
  6731. return visitor._visit(this, function() {
  6732. this.condition._walk(visitor);
  6733. this.body._walk(visitor);
  6734. if (this.alternative) this.alternative._walk(visitor);
  6735. });
  6736. },
  6737. _children_backwards(push) {
  6738. if (this.alternative) {
  6739. push(this.alternative);
  6740. }
  6741. push(this.body);
  6742. push(this.condition);
  6743. }
  6744. }, AST_StatementWithBody);
  6745. /* -----[ SWITCH ]----- */
  6746. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  6747. if (props) {
  6748. this.expression = props.expression;
  6749. this.body = props.body;
  6750. this.block_scope = props.block_scope;
  6751. this.start = props.start;
  6752. this.end = props.end;
  6753. }
  6754. this.flags = 0;
  6755. }, {
  6756. $documentation: "A `switch` statement",
  6757. $propdoc: {
  6758. expression: "[AST_Node] the `switch` “discriminant”"
  6759. },
  6760. _walk: function(visitor) {
  6761. return visitor._visit(this, function() {
  6762. this.expression._walk(visitor);
  6763. walk_body(this, visitor);
  6764. });
  6765. },
  6766. _children_backwards(push) {
  6767. let i = this.body.length;
  6768. while (i--) push(this.body[i]);
  6769. push(this.expression);
  6770. }
  6771. }, AST_Block);
  6772. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  6773. if (props) {
  6774. this.body = props.body;
  6775. this.block_scope = props.block_scope;
  6776. this.start = props.start;
  6777. this.end = props.end;
  6778. }
  6779. this.flags = 0;
  6780. }, {
  6781. $documentation: "Base class for `switch` branches",
  6782. }, AST_Block);
  6783. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  6784. if (props) {
  6785. this.body = props.body;
  6786. this.block_scope = props.block_scope;
  6787. this.start = props.start;
  6788. this.end = props.end;
  6789. }
  6790. this.flags = 0;
  6791. }, {
  6792. $documentation: "A `default` switch branch",
  6793. }, AST_SwitchBranch);
  6794. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  6795. if (props) {
  6796. this.expression = props.expression;
  6797. this.body = props.body;
  6798. this.block_scope = props.block_scope;
  6799. this.start = props.start;
  6800. this.end = props.end;
  6801. }
  6802. this.flags = 0;
  6803. }, {
  6804. $documentation: "A `case` switch branch",
  6805. $propdoc: {
  6806. expression: "[AST_Node] the `case` expression"
  6807. },
  6808. _walk: function(visitor) {
  6809. return visitor._visit(this, function() {
  6810. this.expression._walk(visitor);
  6811. walk_body(this, visitor);
  6812. });
  6813. },
  6814. _children_backwards(push) {
  6815. let i = this.body.length;
  6816. while (i--) push(this.body[i]);
  6817. push(this.expression);
  6818. },
  6819. }, AST_SwitchBranch);
  6820. /* -----[ EXCEPTIONS ]----- */
  6821. var AST_Try = DEFNODE("Try", "bcatch bfinally", function AST_Try(props) {
  6822. if (props) {
  6823. this.bcatch = props.bcatch;
  6824. this.bfinally = props.bfinally;
  6825. this.body = props.body;
  6826. this.block_scope = props.block_scope;
  6827. this.start = props.start;
  6828. this.end = props.end;
  6829. }
  6830. this.flags = 0;
  6831. }, {
  6832. $documentation: "A `try` statement",
  6833. $propdoc: {
  6834. bcatch: "[AST_Catch?] the catch block, or null if not present",
  6835. bfinally: "[AST_Finally?] the finally block, or null if not present"
  6836. },
  6837. _walk: function(visitor) {
  6838. return visitor._visit(this, function() {
  6839. walk_body(this, visitor);
  6840. if (this.bcatch) this.bcatch._walk(visitor);
  6841. if (this.bfinally) this.bfinally._walk(visitor);
  6842. });
  6843. },
  6844. _children_backwards(push) {
  6845. if (this.bfinally) push(this.bfinally);
  6846. if (this.bcatch) push(this.bcatch);
  6847. let i = this.body.length;
  6848. while (i--) push(this.body[i]);
  6849. },
  6850. }, AST_Block);
  6851. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  6852. if (props) {
  6853. this.argname = props.argname;
  6854. this.body = props.body;
  6855. this.block_scope = props.block_scope;
  6856. this.start = props.start;
  6857. this.end = props.end;
  6858. }
  6859. this.flags = 0;
  6860. }, {
  6861. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  6862. $propdoc: {
  6863. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  6864. },
  6865. _walk: function(visitor) {
  6866. return visitor._visit(this, function() {
  6867. if (this.argname) this.argname._walk(visitor);
  6868. walk_body(this, visitor);
  6869. });
  6870. },
  6871. _children_backwards(push) {
  6872. let i = this.body.length;
  6873. while (i--) push(this.body[i]);
  6874. if (this.argname) push(this.argname);
  6875. },
  6876. }, AST_Block);
  6877. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  6878. if (props) {
  6879. this.body = props.body;
  6880. this.block_scope = props.block_scope;
  6881. this.start = props.start;
  6882. this.end = props.end;
  6883. }
  6884. this.flags = 0;
  6885. }, {
  6886. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  6887. }, AST_Block);
  6888. /* -----[ VAR/CONST ]----- */
  6889. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  6890. if (props) {
  6891. this.definitions = props.definitions;
  6892. this.start = props.start;
  6893. this.end = props.end;
  6894. }
  6895. this.flags = 0;
  6896. }, {
  6897. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  6898. $propdoc: {
  6899. definitions: "[AST_VarDef*] array of variable definitions"
  6900. },
  6901. _walk: function(visitor) {
  6902. return visitor._visit(this, function() {
  6903. var definitions = this.definitions;
  6904. for (var i = 0, len = definitions.length; i < len; i++) {
  6905. definitions[i]._walk(visitor);
  6906. }
  6907. });
  6908. },
  6909. _children_backwards(push) {
  6910. let i = this.definitions.length;
  6911. while (i--) push(this.definitions[i]);
  6912. },
  6913. }, AST_Statement);
  6914. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  6915. if (props) {
  6916. this.definitions = props.definitions;
  6917. this.start = props.start;
  6918. this.end = props.end;
  6919. }
  6920. this.flags = 0;
  6921. }, {
  6922. $documentation: "A `var` statement"
  6923. }, AST_Definitions);
  6924. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  6925. if (props) {
  6926. this.definitions = props.definitions;
  6927. this.start = props.start;
  6928. this.end = props.end;
  6929. }
  6930. this.flags = 0;
  6931. }, {
  6932. $documentation: "A `let` statement"
  6933. }, AST_Definitions);
  6934. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  6935. if (props) {
  6936. this.definitions = props.definitions;
  6937. this.start = props.start;
  6938. this.end = props.end;
  6939. }
  6940. this.flags = 0;
  6941. }, {
  6942. $documentation: "A `const` statement"
  6943. }, AST_Definitions);
  6944. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  6945. if (props) {
  6946. this.name = props.name;
  6947. this.value = props.value;
  6948. this.start = props.start;
  6949. this.end = props.end;
  6950. }
  6951. this.flags = 0;
  6952. }, {
  6953. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  6954. $propdoc: {
  6955. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  6956. value: "[AST_Node?] initializer, or null of there's no initializer"
  6957. },
  6958. _walk: function(visitor) {
  6959. return visitor._visit(this, function() {
  6960. this.name._walk(visitor);
  6961. if (this.value) this.value._walk(visitor);
  6962. });
  6963. },
  6964. _children_backwards(push) {
  6965. if (this.value) push(this.value);
  6966. push(this.name);
  6967. },
  6968. });
  6969. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  6970. if (props) {
  6971. this.foreign_name = props.foreign_name;
  6972. this.name = props.name;
  6973. this.start = props.start;
  6974. this.end = props.end;
  6975. }
  6976. this.flags = 0;
  6977. }, {
  6978. $documentation: "The part of the export/import statement that declare names from a module.",
  6979. $propdoc: {
  6980. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  6981. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  6982. },
  6983. _walk: function (visitor) {
  6984. return visitor._visit(this, function() {
  6985. this.foreign_name._walk(visitor);
  6986. this.name._walk(visitor);
  6987. });
  6988. },
  6989. _children_backwards(push) {
  6990. push(this.name);
  6991. push(this.foreign_name);
  6992. },
  6993. });
  6994. var AST_Import = DEFNODE(
  6995. "Import",
  6996. "imported_name imported_names module_name assert_clause",
  6997. function AST_Import(props) {
  6998. if (props) {
  6999. this.imported_name = props.imported_name;
  7000. this.imported_names = props.imported_names;
  7001. this.module_name = props.module_name;
  7002. this.assert_clause = props.assert_clause;
  7003. this.start = props.start;
  7004. this.end = props.end;
  7005. }
  7006. this.flags = 0;
  7007. },
  7008. {
  7009. $documentation: "An `import` statement",
  7010. $propdoc: {
  7011. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  7012. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  7013. module_name: "[AST_String] String literal describing where this module came from",
  7014. assert_clause: "[AST_Object?] The import assertion"
  7015. },
  7016. _walk: function(visitor) {
  7017. return visitor._visit(this, function() {
  7018. if (this.imported_name) {
  7019. this.imported_name._walk(visitor);
  7020. }
  7021. if (this.imported_names) {
  7022. this.imported_names.forEach(function(name_import) {
  7023. name_import._walk(visitor);
  7024. });
  7025. }
  7026. this.module_name._walk(visitor);
  7027. });
  7028. },
  7029. _children_backwards(push) {
  7030. push(this.module_name);
  7031. if (this.imported_names) {
  7032. let i = this.imported_names.length;
  7033. while (i--) push(this.imported_names[i]);
  7034. }
  7035. if (this.imported_name) push(this.imported_name);
  7036. },
  7037. }
  7038. );
  7039. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  7040. if (props) {
  7041. this.start = props.start;
  7042. this.end = props.end;
  7043. }
  7044. this.flags = 0;
  7045. }, {
  7046. $documentation: "A reference to import.meta",
  7047. });
  7048. var AST_Export = DEFNODE(
  7049. "Export",
  7050. "exported_definition exported_value is_default exported_names module_name assert_clause",
  7051. function AST_Export(props) {
  7052. if (props) {
  7053. this.exported_definition = props.exported_definition;
  7054. this.exported_value = props.exported_value;
  7055. this.is_default = props.is_default;
  7056. this.exported_names = props.exported_names;
  7057. this.module_name = props.module_name;
  7058. this.assert_clause = props.assert_clause;
  7059. this.start = props.start;
  7060. this.end = props.end;
  7061. }
  7062. this.flags = 0;
  7063. },
  7064. {
  7065. $documentation: "An `export` statement",
  7066. $propdoc: {
  7067. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  7068. exported_value: "[AST_Node?] An exported value",
  7069. exported_names: "[AST_NameMapping*?] List of exported names",
  7070. module_name: "[AST_String?] Name of the file to load exports from",
  7071. is_default: "[Boolean] Whether this is the default exported value of this module",
  7072. assert_clause: "[AST_Object?] The import assertion"
  7073. },
  7074. _walk: function (visitor) {
  7075. return visitor._visit(this, function () {
  7076. if (this.exported_definition) {
  7077. this.exported_definition._walk(visitor);
  7078. }
  7079. if (this.exported_value) {
  7080. this.exported_value._walk(visitor);
  7081. }
  7082. if (this.exported_names) {
  7083. this.exported_names.forEach(function(name_export) {
  7084. name_export._walk(visitor);
  7085. });
  7086. }
  7087. if (this.module_name) {
  7088. this.module_name._walk(visitor);
  7089. }
  7090. });
  7091. },
  7092. _children_backwards(push) {
  7093. if (this.module_name) push(this.module_name);
  7094. if (this.exported_names) {
  7095. let i = this.exported_names.length;
  7096. while (i--) push(this.exported_names[i]);
  7097. }
  7098. if (this.exported_value) push(this.exported_value);
  7099. if (this.exported_definition) push(this.exported_definition);
  7100. }
  7101. },
  7102. AST_Statement
  7103. );
  7104. /* -----[ OTHER ]----- */
  7105. var AST_Call = DEFNODE(
  7106. "Call",
  7107. "expression args optional _annotations",
  7108. function AST_Call(props) {
  7109. if (props) {
  7110. this.expression = props.expression;
  7111. this.args = props.args;
  7112. this.optional = props.optional;
  7113. this._annotations = props._annotations;
  7114. this.start = props.start;
  7115. this.end = props.end;
  7116. this.initialize();
  7117. }
  7118. this.flags = 0;
  7119. },
  7120. {
  7121. $documentation: "A function call expression",
  7122. $propdoc: {
  7123. expression: "[AST_Node] expression to invoke as function",
  7124. args: "[AST_Node*] array of arguments",
  7125. optional: "[boolean] whether this is an optional call (IE ?.() )",
  7126. _annotations: "[number] bitfield containing information about the call"
  7127. },
  7128. initialize() {
  7129. if (this._annotations == null) this._annotations = 0;
  7130. },
  7131. _walk(visitor) {
  7132. return visitor._visit(this, function() {
  7133. var args = this.args;
  7134. for (var i = 0, len = args.length; i < len; i++) {
  7135. args[i]._walk(visitor);
  7136. }
  7137. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  7138. });
  7139. },
  7140. _children_backwards(push) {
  7141. let i = this.args.length;
  7142. while (i--) push(this.args[i]);
  7143. push(this.expression);
  7144. },
  7145. }
  7146. );
  7147. var AST_New = DEFNODE("New", null, function AST_New(props) {
  7148. if (props) {
  7149. this.expression = props.expression;
  7150. this.args = props.args;
  7151. this.optional = props.optional;
  7152. this._annotations = props._annotations;
  7153. this.start = props.start;
  7154. this.end = props.end;
  7155. this.initialize();
  7156. }
  7157. this.flags = 0;
  7158. }, {
  7159. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  7160. }, AST_Call);
  7161. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  7162. if (props) {
  7163. this.expressions = props.expressions;
  7164. this.start = props.start;
  7165. this.end = props.end;
  7166. }
  7167. this.flags = 0;
  7168. }, {
  7169. $documentation: "A sequence expression (comma-separated expressions)",
  7170. $propdoc: {
  7171. expressions: "[AST_Node*] array of expressions (at least two)"
  7172. },
  7173. _walk: function(visitor) {
  7174. return visitor._visit(this, function() {
  7175. this.expressions.forEach(function(node) {
  7176. node._walk(visitor);
  7177. });
  7178. });
  7179. },
  7180. _children_backwards(push) {
  7181. let i = this.expressions.length;
  7182. while (i--) push(this.expressions[i]);
  7183. },
  7184. });
  7185. var AST_PropAccess = DEFNODE(
  7186. "PropAccess",
  7187. "expression property optional",
  7188. function AST_PropAccess(props) {
  7189. if (props) {
  7190. this.expression = props.expression;
  7191. this.property = props.property;
  7192. this.optional = props.optional;
  7193. this.start = props.start;
  7194. this.end = props.end;
  7195. }
  7196. this.flags = 0;
  7197. },
  7198. {
  7199. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  7200. $propdoc: {
  7201. expression: "[AST_Node] the “container” expression",
  7202. property: "[AST_Node|string] the property to access. For AST_Dot & AST_DotHash this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
  7203. optional: "[boolean] whether this is an optional property access (IE ?.)"
  7204. }
  7205. }
  7206. );
  7207. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  7208. if (props) {
  7209. this.quote = props.quote;
  7210. this.expression = props.expression;
  7211. this.property = props.property;
  7212. this.optional = props.optional;
  7213. this.start = props.start;
  7214. this.end = props.end;
  7215. }
  7216. this.flags = 0;
  7217. }, {
  7218. $documentation: "A dotted property access expression",
  7219. $propdoc: {
  7220. quote: "[string] the original quote character when transformed from AST_Sub",
  7221. },
  7222. _walk: function(visitor) {
  7223. return visitor._visit(this, function() {
  7224. this.expression._walk(visitor);
  7225. });
  7226. },
  7227. _children_backwards(push) {
  7228. push(this.expression);
  7229. },
  7230. }, AST_PropAccess);
  7231. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  7232. if (props) {
  7233. this.expression = props.expression;
  7234. this.property = props.property;
  7235. this.optional = props.optional;
  7236. this.start = props.start;
  7237. this.end = props.end;
  7238. }
  7239. this.flags = 0;
  7240. }, {
  7241. $documentation: "A dotted property access to a private property",
  7242. _walk: function(visitor) {
  7243. return visitor._visit(this, function() {
  7244. this.expression._walk(visitor);
  7245. });
  7246. },
  7247. _children_backwards(push) {
  7248. push(this.expression);
  7249. },
  7250. }, AST_PropAccess);
  7251. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  7252. if (props) {
  7253. this.expression = props.expression;
  7254. this.property = props.property;
  7255. this.optional = props.optional;
  7256. this.start = props.start;
  7257. this.end = props.end;
  7258. }
  7259. this.flags = 0;
  7260. }, {
  7261. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  7262. _walk: function(visitor) {
  7263. return visitor._visit(this, function() {
  7264. this.expression._walk(visitor);
  7265. this.property._walk(visitor);
  7266. });
  7267. },
  7268. _children_backwards(push) {
  7269. push(this.property);
  7270. push(this.expression);
  7271. },
  7272. }, AST_PropAccess);
  7273. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  7274. if (props) {
  7275. this.expression = props.expression;
  7276. this.start = props.start;
  7277. this.end = props.end;
  7278. }
  7279. this.flags = 0;
  7280. }, {
  7281. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  7282. $propdoc: {
  7283. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  7284. },
  7285. _walk: function (visitor) {
  7286. return visitor._visit(this, function() {
  7287. this.expression._walk(visitor);
  7288. });
  7289. },
  7290. _children_backwards(push) {
  7291. push(this.expression);
  7292. },
  7293. });
  7294. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  7295. if (props) {
  7296. this.operator = props.operator;
  7297. this.expression = props.expression;
  7298. this.start = props.start;
  7299. this.end = props.end;
  7300. }
  7301. this.flags = 0;
  7302. }, {
  7303. $documentation: "Base class for unary expressions",
  7304. $propdoc: {
  7305. operator: "[string] the operator",
  7306. expression: "[AST_Node] expression that this unary operator applies to"
  7307. },
  7308. _walk: function(visitor) {
  7309. return visitor._visit(this, function() {
  7310. this.expression._walk(visitor);
  7311. });
  7312. },
  7313. _children_backwards(push) {
  7314. push(this.expression);
  7315. },
  7316. });
  7317. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  7318. if (props) {
  7319. this.operator = props.operator;
  7320. this.expression = props.expression;
  7321. this.start = props.start;
  7322. this.end = props.end;
  7323. }
  7324. this.flags = 0;
  7325. }, {
  7326. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  7327. }, AST_Unary);
  7328. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  7329. if (props) {
  7330. this.operator = props.operator;
  7331. this.expression = props.expression;
  7332. this.start = props.start;
  7333. this.end = props.end;
  7334. }
  7335. this.flags = 0;
  7336. }, {
  7337. $documentation: "Unary postfix expression, i.e. `i++`"
  7338. }, AST_Unary);
  7339. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  7340. if (props) {
  7341. this.operator = props.operator;
  7342. this.left = props.left;
  7343. this.right = props.right;
  7344. this.start = props.start;
  7345. this.end = props.end;
  7346. }
  7347. this.flags = 0;
  7348. }, {
  7349. $documentation: "Binary expression, i.e. `a + b`",
  7350. $propdoc: {
  7351. left: "[AST_Node] left-hand side expression",
  7352. operator: "[string] the operator",
  7353. right: "[AST_Node] right-hand side expression"
  7354. },
  7355. _walk: function(visitor) {
  7356. return visitor._visit(this, function() {
  7357. this.left._walk(visitor);
  7358. this.right._walk(visitor);
  7359. });
  7360. },
  7361. _children_backwards(push) {
  7362. push(this.right);
  7363. push(this.left);
  7364. },
  7365. });
  7366. var AST_Conditional = DEFNODE(
  7367. "Conditional",
  7368. "condition consequent alternative",
  7369. function AST_Conditional(props) {
  7370. if (props) {
  7371. this.condition = props.condition;
  7372. this.consequent = props.consequent;
  7373. this.alternative = props.alternative;
  7374. this.start = props.start;
  7375. this.end = props.end;
  7376. }
  7377. this.flags = 0;
  7378. },
  7379. {
  7380. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  7381. $propdoc: {
  7382. condition: "[AST_Node]",
  7383. consequent: "[AST_Node]",
  7384. alternative: "[AST_Node]"
  7385. },
  7386. _walk: function(visitor) {
  7387. return visitor._visit(this, function() {
  7388. this.condition._walk(visitor);
  7389. this.consequent._walk(visitor);
  7390. this.alternative._walk(visitor);
  7391. });
  7392. },
  7393. _children_backwards(push) {
  7394. push(this.alternative);
  7395. push(this.consequent);
  7396. push(this.condition);
  7397. },
  7398. }
  7399. );
  7400. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  7401. if (props) {
  7402. this.logical = props.logical;
  7403. this.operator = props.operator;
  7404. this.left = props.left;
  7405. this.right = props.right;
  7406. this.start = props.start;
  7407. this.end = props.end;
  7408. }
  7409. this.flags = 0;
  7410. }, {
  7411. $documentation: "An assignment expression — `a = b + 5`",
  7412. $propdoc: {
  7413. logical: "Whether it's a logical assignment"
  7414. }
  7415. }, AST_Binary);
  7416. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  7417. if (props) {
  7418. this.operator = props.operator;
  7419. this.left = props.left;
  7420. this.right = props.right;
  7421. this.start = props.start;
  7422. this.end = props.end;
  7423. }
  7424. this.flags = 0;
  7425. }, {
  7426. $documentation: "A default assignment expression like in `(a = 3) => a`"
  7427. }, AST_Binary);
  7428. /* -----[ LITERALS ]----- */
  7429. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  7430. if (props) {
  7431. this.elements = props.elements;
  7432. this.start = props.start;
  7433. this.end = props.end;
  7434. }
  7435. this.flags = 0;
  7436. }, {
  7437. $documentation: "An array literal",
  7438. $propdoc: {
  7439. elements: "[AST_Node*] array of elements"
  7440. },
  7441. _walk: function(visitor) {
  7442. return visitor._visit(this, function() {
  7443. var elements = this.elements;
  7444. for (var i = 0, len = elements.length; i < len; i++) {
  7445. elements[i]._walk(visitor);
  7446. }
  7447. });
  7448. },
  7449. _children_backwards(push) {
  7450. let i = this.elements.length;
  7451. while (i--) push(this.elements[i]);
  7452. },
  7453. });
  7454. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  7455. if (props) {
  7456. this.properties = props.properties;
  7457. this.start = props.start;
  7458. this.end = props.end;
  7459. }
  7460. this.flags = 0;
  7461. }, {
  7462. $documentation: "An object literal",
  7463. $propdoc: {
  7464. properties: "[AST_ObjectProperty*] array of properties"
  7465. },
  7466. _walk: function(visitor) {
  7467. return visitor._visit(this, function() {
  7468. var properties = this.properties;
  7469. for (var i = 0, len = properties.length; i < len; i++) {
  7470. properties[i]._walk(visitor);
  7471. }
  7472. });
  7473. },
  7474. _children_backwards(push) {
  7475. let i = this.properties.length;
  7476. while (i--) push(this.properties[i]);
  7477. },
  7478. });
  7479. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  7480. if (props) {
  7481. this.key = props.key;
  7482. this.value = props.value;
  7483. this.start = props.start;
  7484. this.end = props.end;
  7485. }
  7486. this.flags = 0;
  7487. }, {
  7488. $documentation: "Base class for literal object properties",
  7489. $propdoc: {
  7490. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  7491. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  7492. },
  7493. _walk: function(visitor) {
  7494. return visitor._visit(this, function() {
  7495. if (this.key instanceof AST_Node)
  7496. this.key._walk(visitor);
  7497. this.value._walk(visitor);
  7498. });
  7499. },
  7500. _children_backwards(push) {
  7501. push(this.value);
  7502. if (this.key instanceof AST_Node) push(this.key);
  7503. }
  7504. });
  7505. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  7506. if (props) {
  7507. this.quote = props.quote;
  7508. this.key = props.key;
  7509. this.value = props.value;
  7510. this.start = props.start;
  7511. this.end = props.end;
  7512. }
  7513. this.flags = 0;
  7514. }, {
  7515. $documentation: "A key: value object property",
  7516. $propdoc: {
  7517. quote: "[string] the original quote character"
  7518. },
  7519. computed_key() {
  7520. return this.key instanceof AST_Node;
  7521. }
  7522. }, AST_ObjectProperty);
  7523. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  7524. if (props) {
  7525. this.static = props.static;
  7526. this.key = props.key;
  7527. this.value = props.value;
  7528. this.start = props.start;
  7529. this.end = props.end;
  7530. }
  7531. this.flags = 0;
  7532. }, {
  7533. $propdoc: {
  7534. static: "[boolean] whether this is a static private setter"
  7535. },
  7536. $documentation: "A private setter property",
  7537. computed_key() {
  7538. return false;
  7539. }
  7540. }, AST_ObjectProperty);
  7541. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  7542. if (props) {
  7543. this.static = props.static;
  7544. this.key = props.key;
  7545. this.value = props.value;
  7546. this.start = props.start;
  7547. this.end = props.end;
  7548. }
  7549. this.flags = 0;
  7550. }, {
  7551. $propdoc: {
  7552. static: "[boolean] whether this is a static private getter"
  7553. },
  7554. $documentation: "A private getter property",
  7555. computed_key() {
  7556. return false;
  7557. }
  7558. }, AST_ObjectProperty);
  7559. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  7560. if (props) {
  7561. this.quote = props.quote;
  7562. this.static = props.static;
  7563. this.key = props.key;
  7564. this.value = props.value;
  7565. this.start = props.start;
  7566. this.end = props.end;
  7567. }
  7568. this.flags = 0;
  7569. }, {
  7570. $propdoc: {
  7571. quote: "[string|undefined] the original quote character, if any",
  7572. static: "[boolean] whether this is a static setter (classes only)"
  7573. },
  7574. $documentation: "An object setter property",
  7575. computed_key() {
  7576. return !(this.key instanceof AST_SymbolMethod);
  7577. }
  7578. }, AST_ObjectProperty);
  7579. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  7580. if (props) {
  7581. this.quote = props.quote;
  7582. this.static = props.static;
  7583. this.key = props.key;
  7584. this.value = props.value;
  7585. this.start = props.start;
  7586. this.end = props.end;
  7587. }
  7588. this.flags = 0;
  7589. }, {
  7590. $propdoc: {
  7591. quote: "[string|undefined] the original quote character, if any",
  7592. static: "[boolean] whether this is a static getter (classes only)"
  7593. },
  7594. $documentation: "An object getter property",
  7595. computed_key() {
  7596. return !(this.key instanceof AST_SymbolMethod);
  7597. }
  7598. }, AST_ObjectProperty);
  7599. var AST_ConciseMethod = DEFNODE(
  7600. "ConciseMethod",
  7601. "quote static is_generator async",
  7602. function AST_ConciseMethod(props) {
  7603. if (props) {
  7604. this.quote = props.quote;
  7605. this.static = props.static;
  7606. this.is_generator = props.is_generator;
  7607. this.async = props.async;
  7608. this.key = props.key;
  7609. this.value = props.value;
  7610. this.start = props.start;
  7611. this.end = props.end;
  7612. }
  7613. this.flags = 0;
  7614. },
  7615. {
  7616. $propdoc: {
  7617. quote: "[string|undefined] the original quote character, if any",
  7618. static: "[boolean] is this method static (classes only)",
  7619. is_generator: "[boolean] is this a generator method",
  7620. async: "[boolean] is this method async",
  7621. },
  7622. $documentation: "An ES6 concise method inside an object or class",
  7623. computed_key() {
  7624. return !(this.key instanceof AST_SymbolMethod);
  7625. }
  7626. },
  7627. AST_ObjectProperty
  7628. );
  7629. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  7630. if (props) {
  7631. this.quote = props.quote;
  7632. this.static = props.static;
  7633. this.is_generator = props.is_generator;
  7634. this.async = props.async;
  7635. this.key = props.key;
  7636. this.value = props.value;
  7637. this.start = props.start;
  7638. this.end = props.end;
  7639. }
  7640. this.flags = 0;
  7641. }, {
  7642. $documentation: "A private class method inside a class",
  7643. }, AST_ConciseMethod);
  7644. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  7645. if (props) {
  7646. this.name = props.name;
  7647. this.extends = props.extends;
  7648. this.properties = props.properties;
  7649. this.variables = props.variables;
  7650. this.functions = props.functions;
  7651. this.uses_with = props.uses_with;
  7652. this.uses_eval = props.uses_eval;
  7653. this.parent_scope = props.parent_scope;
  7654. this.enclosed = props.enclosed;
  7655. this.cname = props.cname;
  7656. this.body = props.body;
  7657. this.block_scope = props.block_scope;
  7658. this.start = props.start;
  7659. this.end = props.end;
  7660. }
  7661. this.flags = 0;
  7662. }, {
  7663. $propdoc: {
  7664. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  7665. extends: "[AST_Node]? optional parent class",
  7666. properties: "[AST_ObjectProperty*] array of properties"
  7667. },
  7668. $documentation: "An ES6 class",
  7669. _walk: function(visitor) {
  7670. return visitor._visit(this, function() {
  7671. if (this.name) {
  7672. this.name._walk(visitor);
  7673. }
  7674. if (this.extends) {
  7675. this.extends._walk(visitor);
  7676. }
  7677. this.properties.forEach((prop) => prop._walk(visitor));
  7678. });
  7679. },
  7680. _children_backwards(push) {
  7681. let i = this.properties.length;
  7682. while (i--) push(this.properties[i]);
  7683. if (this.extends) push(this.extends);
  7684. if (this.name) push(this.name);
  7685. },
  7686. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  7687. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  7688. if (props) {
  7689. this.static = props.static;
  7690. this.quote = props.quote;
  7691. this.key = props.key;
  7692. this.value = props.value;
  7693. this.start = props.start;
  7694. this.end = props.end;
  7695. }
  7696. this.flags = 0;
  7697. }, {
  7698. $documentation: "A class property",
  7699. $propdoc: {
  7700. static: "[boolean] whether this is a static key",
  7701. quote: "[string] which quote is being used"
  7702. },
  7703. _walk: function(visitor) {
  7704. return visitor._visit(this, function() {
  7705. if (this.key instanceof AST_Node)
  7706. this.key._walk(visitor);
  7707. if (this.value instanceof AST_Node)
  7708. this.value._walk(visitor);
  7709. });
  7710. },
  7711. _children_backwards(push) {
  7712. if (this.value instanceof AST_Node) push(this.value);
  7713. if (this.key instanceof AST_Node) push(this.key);
  7714. },
  7715. computed_key() {
  7716. return !(this.key instanceof AST_SymbolClassProperty);
  7717. }
  7718. }, AST_ObjectProperty);
  7719. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  7720. if (props) {
  7721. this.static = props.static;
  7722. this.quote = props.quote;
  7723. this.key = props.key;
  7724. this.value = props.value;
  7725. this.start = props.start;
  7726. this.end = props.end;
  7727. }
  7728. this.flags = 0;
  7729. }, {
  7730. $documentation: "A class property for a private property",
  7731. }, AST_ClassProperty);
  7732. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  7733. if (props) {
  7734. this.name = props.name;
  7735. this.extends = props.extends;
  7736. this.properties = props.properties;
  7737. this.variables = props.variables;
  7738. this.functions = props.functions;
  7739. this.uses_with = props.uses_with;
  7740. this.uses_eval = props.uses_eval;
  7741. this.parent_scope = props.parent_scope;
  7742. this.enclosed = props.enclosed;
  7743. this.cname = props.cname;
  7744. this.body = props.body;
  7745. this.block_scope = props.block_scope;
  7746. this.start = props.start;
  7747. this.end = props.end;
  7748. }
  7749. this.flags = 0;
  7750. }, {
  7751. $documentation: "A class definition",
  7752. }, AST_Class);
  7753. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  7754. if (props) {
  7755. this.name = props.name;
  7756. this.extends = props.extends;
  7757. this.properties = props.properties;
  7758. this.variables = props.variables;
  7759. this.functions = props.functions;
  7760. this.uses_with = props.uses_with;
  7761. this.uses_eval = props.uses_eval;
  7762. this.parent_scope = props.parent_scope;
  7763. this.enclosed = props.enclosed;
  7764. this.cname = props.cname;
  7765. this.body = props.body;
  7766. this.block_scope = props.block_scope;
  7767. this.start = props.start;
  7768. this.end = props.end;
  7769. }
  7770. this.flags = 0;
  7771. }, {
  7772. $documentation: "A class expression."
  7773. }, AST_Class);
  7774. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  7775. if (props) {
  7776. this.scope = props.scope;
  7777. this.name = props.name;
  7778. this.thedef = props.thedef;
  7779. this.start = props.start;
  7780. this.end = props.end;
  7781. }
  7782. this.flags = 0;
  7783. }, {
  7784. $propdoc: {
  7785. name: "[string] name of this symbol",
  7786. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  7787. thedef: "[SymbolDef/S] the definition of this symbol"
  7788. },
  7789. $documentation: "Base class for all symbols"
  7790. });
  7791. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  7792. if (props) {
  7793. this.start = props.start;
  7794. this.end = props.end;
  7795. }
  7796. this.flags = 0;
  7797. }, {
  7798. $documentation: "A reference to new.target"
  7799. });
  7800. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  7801. if (props) {
  7802. this.init = props.init;
  7803. this.scope = props.scope;
  7804. this.name = props.name;
  7805. this.thedef = props.thedef;
  7806. this.start = props.start;
  7807. this.end = props.end;
  7808. }
  7809. this.flags = 0;
  7810. }, {
  7811. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  7812. }, AST_Symbol);
  7813. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  7814. if (props) {
  7815. this.init = props.init;
  7816. this.scope = props.scope;
  7817. this.name = props.name;
  7818. this.thedef = props.thedef;
  7819. this.start = props.start;
  7820. this.end = props.end;
  7821. }
  7822. this.flags = 0;
  7823. }, {
  7824. $documentation: "Symbol defining a variable",
  7825. }, AST_SymbolDeclaration);
  7826. var AST_SymbolBlockDeclaration = DEFNODE(
  7827. "SymbolBlockDeclaration",
  7828. null,
  7829. function AST_SymbolBlockDeclaration(props) {
  7830. if (props) {
  7831. this.init = props.init;
  7832. this.scope = props.scope;
  7833. this.name = props.name;
  7834. this.thedef = props.thedef;
  7835. this.start = props.start;
  7836. this.end = props.end;
  7837. }
  7838. this.flags = 0;
  7839. },
  7840. {
  7841. $documentation: "Base class for block-scoped declaration symbols"
  7842. },
  7843. AST_SymbolDeclaration
  7844. );
  7845. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  7846. if (props) {
  7847. this.init = props.init;
  7848. this.scope = props.scope;
  7849. this.name = props.name;
  7850. this.thedef = props.thedef;
  7851. this.start = props.start;
  7852. this.end = props.end;
  7853. }
  7854. this.flags = 0;
  7855. }, {
  7856. $documentation: "A constant declaration"
  7857. }, AST_SymbolBlockDeclaration);
  7858. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  7859. if (props) {
  7860. this.init = props.init;
  7861. this.scope = props.scope;
  7862. this.name = props.name;
  7863. this.thedef = props.thedef;
  7864. this.start = props.start;
  7865. this.end = props.end;
  7866. }
  7867. this.flags = 0;
  7868. }, {
  7869. $documentation: "A block-scoped `let` declaration"
  7870. }, AST_SymbolBlockDeclaration);
  7871. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  7872. if (props) {
  7873. this.init = props.init;
  7874. this.scope = props.scope;
  7875. this.name = props.name;
  7876. this.thedef = props.thedef;
  7877. this.start = props.start;
  7878. this.end = props.end;
  7879. }
  7880. this.flags = 0;
  7881. }, {
  7882. $documentation: "Symbol naming a function argument",
  7883. }, AST_SymbolVar);
  7884. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  7885. if (props) {
  7886. this.init = props.init;
  7887. this.scope = props.scope;
  7888. this.name = props.name;
  7889. this.thedef = props.thedef;
  7890. this.start = props.start;
  7891. this.end = props.end;
  7892. }
  7893. this.flags = 0;
  7894. }, {
  7895. $documentation: "Symbol defining a function",
  7896. }, AST_SymbolDeclaration);
  7897. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  7898. if (props) {
  7899. this.scope = props.scope;
  7900. this.name = props.name;
  7901. this.thedef = props.thedef;
  7902. this.start = props.start;
  7903. this.end = props.end;
  7904. }
  7905. this.flags = 0;
  7906. }, {
  7907. $documentation: "Symbol in an object defining a method",
  7908. }, AST_Symbol);
  7909. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  7910. if (props) {
  7911. this.scope = props.scope;
  7912. this.name = props.name;
  7913. this.thedef = props.thedef;
  7914. this.start = props.start;
  7915. this.end = props.end;
  7916. }
  7917. this.flags = 0;
  7918. }, {
  7919. $documentation: "Symbol for a class property",
  7920. }, AST_Symbol);
  7921. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  7922. if (props) {
  7923. this.init = props.init;
  7924. this.scope = props.scope;
  7925. this.name = props.name;
  7926. this.thedef = props.thedef;
  7927. this.start = props.start;
  7928. this.end = props.end;
  7929. }
  7930. this.flags = 0;
  7931. }, {
  7932. $documentation: "Symbol naming a function expression",
  7933. }, AST_SymbolDeclaration);
  7934. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  7935. if (props) {
  7936. this.init = props.init;
  7937. this.scope = props.scope;
  7938. this.name = props.name;
  7939. this.thedef = props.thedef;
  7940. this.start = props.start;
  7941. this.end = props.end;
  7942. }
  7943. this.flags = 0;
  7944. }, {
  7945. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  7946. }, AST_SymbolBlockDeclaration);
  7947. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  7948. if (props) {
  7949. this.init = props.init;
  7950. this.scope = props.scope;
  7951. this.name = props.name;
  7952. this.thedef = props.thedef;
  7953. this.start = props.start;
  7954. this.end = props.end;
  7955. }
  7956. this.flags = 0;
  7957. }, {
  7958. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  7959. }, AST_SymbolDeclaration);
  7960. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  7961. if (props) {
  7962. this.init = props.init;
  7963. this.scope = props.scope;
  7964. this.name = props.name;
  7965. this.thedef = props.thedef;
  7966. this.start = props.start;
  7967. this.end = props.end;
  7968. }
  7969. this.flags = 0;
  7970. }, {
  7971. $documentation: "Symbol naming the exception in catch",
  7972. }, AST_SymbolBlockDeclaration);
  7973. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  7974. if (props) {
  7975. this.init = props.init;
  7976. this.scope = props.scope;
  7977. this.name = props.name;
  7978. this.thedef = props.thedef;
  7979. this.start = props.start;
  7980. this.end = props.end;
  7981. }
  7982. this.flags = 0;
  7983. }, {
  7984. $documentation: "Symbol referring to an imported name",
  7985. }, AST_SymbolBlockDeclaration);
  7986. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  7987. if (props) {
  7988. this.scope = props.scope;
  7989. this.name = props.name;
  7990. this.thedef = props.thedef;
  7991. this.start = props.start;
  7992. this.end = props.end;
  7993. }
  7994. this.flags = 0;
  7995. }, {
  7996. $documentation: "A symbol imported from a module, but it is defined in the other module, and its real name is irrelevant for this module's purposes",
  7997. }, AST_Symbol);
  7998. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  7999. if (props) {
  8000. this.references = props.references;
  8001. this.scope = props.scope;
  8002. this.name = props.name;
  8003. this.thedef = props.thedef;
  8004. this.start = props.start;
  8005. this.end = props.end;
  8006. this.initialize();
  8007. }
  8008. this.flags = 0;
  8009. }, {
  8010. $documentation: "Symbol naming a label (declaration)",
  8011. $propdoc: {
  8012. references: "[AST_LoopControl*] a list of nodes referring to this label"
  8013. },
  8014. initialize: function() {
  8015. this.references = [];
  8016. this.thedef = this;
  8017. }
  8018. }, AST_Symbol);
  8019. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  8020. if (props) {
  8021. this.scope = props.scope;
  8022. this.name = props.name;
  8023. this.thedef = props.thedef;
  8024. this.start = props.start;
  8025. this.end = props.end;
  8026. }
  8027. this.flags = 0;
  8028. }, {
  8029. $documentation: "Reference to some symbol (not definition/declaration)",
  8030. }, AST_Symbol);
  8031. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  8032. if (props) {
  8033. this.scope = props.scope;
  8034. this.name = props.name;
  8035. this.thedef = props.thedef;
  8036. this.start = props.start;
  8037. this.end = props.end;
  8038. }
  8039. this.flags = 0;
  8040. }, {
  8041. $documentation: "Symbol referring to a name to export",
  8042. }, AST_SymbolRef);
  8043. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  8044. if (props) {
  8045. this.scope = props.scope;
  8046. this.name = props.name;
  8047. this.thedef = props.thedef;
  8048. this.start = props.start;
  8049. this.end = props.end;
  8050. }
  8051. this.flags = 0;
  8052. }, {
  8053. $documentation: "A symbol exported from this module, but it is used in the other module, and its real name is irrelevant for this module's purposes",
  8054. }, AST_Symbol);
  8055. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  8056. if (props) {
  8057. this.scope = props.scope;
  8058. this.name = props.name;
  8059. this.thedef = props.thedef;
  8060. this.start = props.start;
  8061. this.end = props.end;
  8062. }
  8063. this.flags = 0;
  8064. }, {
  8065. $documentation: "Reference to a label symbol",
  8066. }, AST_Symbol);
  8067. var AST_This = DEFNODE("This", null, function AST_This(props) {
  8068. if (props) {
  8069. this.scope = props.scope;
  8070. this.name = props.name;
  8071. this.thedef = props.thedef;
  8072. this.start = props.start;
  8073. this.end = props.end;
  8074. }
  8075. this.flags = 0;
  8076. }, {
  8077. $documentation: "The `this` symbol",
  8078. }, AST_Symbol);
  8079. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  8080. if (props) {
  8081. this.scope = props.scope;
  8082. this.name = props.name;
  8083. this.thedef = props.thedef;
  8084. this.start = props.start;
  8085. this.end = props.end;
  8086. }
  8087. this.flags = 0;
  8088. }, {
  8089. $documentation: "The `super` symbol",
  8090. }, AST_This);
  8091. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  8092. if (props) {
  8093. this.start = props.start;
  8094. this.end = props.end;
  8095. }
  8096. this.flags = 0;
  8097. }, {
  8098. $documentation: "Base class for all constants",
  8099. getValue: function() {
  8100. return this.value;
  8101. }
  8102. });
  8103. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  8104. if (props) {
  8105. this.value = props.value;
  8106. this.quote = props.quote;
  8107. this.start = props.start;
  8108. this.end = props.end;
  8109. }
  8110. this.flags = 0;
  8111. }, {
  8112. $documentation: "A string literal",
  8113. $propdoc: {
  8114. value: "[string] the contents of this string",
  8115. quote: "[string] the original quote character"
  8116. }
  8117. }, AST_Constant);
  8118. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  8119. if (props) {
  8120. this.value = props.value;
  8121. this.raw = props.raw;
  8122. this.start = props.start;
  8123. this.end = props.end;
  8124. }
  8125. this.flags = 0;
  8126. }, {
  8127. $documentation: "A number literal",
  8128. $propdoc: {
  8129. value: "[number] the numeric value",
  8130. raw: "[string] numeric value as string"
  8131. }
  8132. }, AST_Constant);
  8133. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  8134. if (props) {
  8135. this.value = props.value;
  8136. this.start = props.start;
  8137. this.end = props.end;
  8138. }
  8139. this.flags = 0;
  8140. }, {
  8141. $documentation: "A big int literal",
  8142. $propdoc: {
  8143. value: "[string] big int value"
  8144. }
  8145. }, AST_Constant);
  8146. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  8147. if (props) {
  8148. this.value = props.value;
  8149. this.start = props.start;
  8150. this.end = props.end;
  8151. }
  8152. this.flags = 0;
  8153. }, {
  8154. $documentation: "A regexp literal",
  8155. $propdoc: {
  8156. value: "[RegExp] the actual regexp",
  8157. }
  8158. }, AST_Constant);
  8159. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  8160. if (props) {
  8161. this.start = props.start;
  8162. this.end = props.end;
  8163. }
  8164. this.flags = 0;
  8165. }, {
  8166. $documentation: "Base class for atoms",
  8167. }, AST_Constant);
  8168. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  8169. if (props) {
  8170. this.start = props.start;
  8171. this.end = props.end;
  8172. }
  8173. this.flags = 0;
  8174. }, {
  8175. $documentation: "The `null` atom",
  8176. value: null
  8177. }, AST_Atom);
  8178. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  8179. if (props) {
  8180. this.start = props.start;
  8181. this.end = props.end;
  8182. }
  8183. this.flags = 0;
  8184. }, {
  8185. $documentation: "The impossible value",
  8186. value: 0/0
  8187. }, AST_Atom);
  8188. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  8189. if (props) {
  8190. this.start = props.start;
  8191. this.end = props.end;
  8192. }
  8193. this.flags = 0;
  8194. }, {
  8195. $documentation: "The `undefined` value",
  8196. value: (function() {}())
  8197. }, AST_Atom);
  8198. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  8199. if (props) {
  8200. this.start = props.start;
  8201. this.end = props.end;
  8202. }
  8203. this.flags = 0;
  8204. }, {
  8205. $documentation: "A hole in an array",
  8206. value: (function() {}())
  8207. }, AST_Atom);
  8208. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  8209. if (props) {
  8210. this.start = props.start;
  8211. this.end = props.end;
  8212. }
  8213. this.flags = 0;
  8214. }, {
  8215. $documentation: "The `Infinity` value",
  8216. value: 1/0
  8217. }, AST_Atom);
  8218. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  8219. if (props) {
  8220. this.start = props.start;
  8221. this.end = props.end;
  8222. }
  8223. this.flags = 0;
  8224. }, {
  8225. $documentation: "Base class for booleans",
  8226. }, AST_Atom);
  8227. var AST_False = DEFNODE("False", null, function AST_False(props) {
  8228. if (props) {
  8229. this.start = props.start;
  8230. this.end = props.end;
  8231. }
  8232. this.flags = 0;
  8233. }, {
  8234. $documentation: "The `false` atom",
  8235. value: false
  8236. }, AST_Boolean);
  8237. var AST_True = DEFNODE("True", null, function AST_True(props) {
  8238. if (props) {
  8239. this.start = props.start;
  8240. this.end = props.end;
  8241. }
  8242. this.flags = 0;
  8243. }, {
  8244. $documentation: "The `true` atom",
  8245. value: true
  8246. }, AST_Boolean);
  8247. /* -----[ Walk function ]---- */
  8248. /**
  8249. * Walk nodes in depth-first search fashion.
  8250. * Callback can return `walk_abort` symbol to stop iteration.
  8251. * It can also return `true` to stop iteration just for child nodes.
  8252. * Iteration can be stopped and continued by passing the `to_visit` argument,
  8253. * which is given to the callback in the second argument.
  8254. **/
  8255. function walk(node, cb, to_visit = [node]) {
  8256. const push = to_visit.push.bind(to_visit);
  8257. while (to_visit.length) {
  8258. const node = to_visit.pop();
  8259. const ret = cb(node, to_visit);
  8260. if (ret) {
  8261. if (ret === walk_abort) return true;
  8262. continue;
  8263. }
  8264. node._children_backwards(push);
  8265. }
  8266. return false;
  8267. }
  8268. /**
  8269. * Walks an AST node and its children.
  8270. *
  8271. * {cb} can return `walk_abort` to interrupt the walk.
  8272. *
  8273. * @param node
  8274. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  8275. *
  8276. * @returns {boolean} whether the walk was aborted
  8277. *
  8278. * @example
  8279. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  8280. * if (some_cond(node, parent())) return walk_abort
  8281. * });
  8282. */
  8283. function walk_parent(node, cb, initial_stack) {
  8284. const to_visit = [node];
  8285. const push = to_visit.push.bind(to_visit);
  8286. const stack = initial_stack ? initial_stack.slice() : [];
  8287. const parent_pop_indices = [];
  8288. let current;
  8289. const info = {
  8290. parent: (n = 0) => {
  8291. if (n === -1) {
  8292. return current;
  8293. }
  8294. // [ p1 p0 ] [ 1 0 ]
  8295. if (initial_stack && n >= stack.length) {
  8296. n -= stack.length;
  8297. return initial_stack[
  8298. initial_stack.length - (n + 1)
  8299. ];
  8300. }
  8301. return stack[stack.length - (1 + n)];
  8302. },
  8303. };
  8304. while (to_visit.length) {
  8305. current = to_visit.pop();
  8306. while (
  8307. parent_pop_indices.length &&
  8308. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  8309. ) {
  8310. stack.pop();
  8311. parent_pop_indices.pop();
  8312. }
  8313. const ret = cb(current, info);
  8314. if (ret) {
  8315. if (ret === walk_abort) return true;
  8316. continue;
  8317. }
  8318. const visit_length = to_visit.length;
  8319. current._children_backwards(push);
  8320. // Push only if we're going to traverse the children
  8321. if (to_visit.length > visit_length) {
  8322. stack.push(current);
  8323. parent_pop_indices.push(visit_length - 1);
  8324. }
  8325. }
  8326. return false;
  8327. }
  8328. const walk_abort = Symbol("abort walk");
  8329. /* -----[ TreeWalker ]----- */
  8330. class TreeWalker {
  8331. constructor(callback) {
  8332. this.visit = callback;
  8333. this.stack = [];
  8334. this.directives = Object.create(null);
  8335. }
  8336. _visit(node, descend) {
  8337. this.push(node);
  8338. var ret = this.visit(node, descend ? function() {
  8339. descend.call(node);
  8340. } : noop);
  8341. if (!ret && descend) {
  8342. descend.call(node);
  8343. }
  8344. this.pop();
  8345. return ret;
  8346. }
  8347. parent(n) {
  8348. return this.stack[this.stack.length - 2 - (n || 0)];
  8349. }
  8350. push(node) {
  8351. if (node instanceof AST_Lambda) {
  8352. this.directives = Object.create(this.directives);
  8353. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  8354. this.directives[node.value] = node;
  8355. } else if (node instanceof AST_Class) {
  8356. this.directives = Object.create(this.directives);
  8357. if (!this.directives["use strict"]) {
  8358. this.directives["use strict"] = node;
  8359. }
  8360. }
  8361. this.stack.push(node);
  8362. }
  8363. pop() {
  8364. var node = this.stack.pop();
  8365. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  8366. this.directives = Object.getPrototypeOf(this.directives);
  8367. }
  8368. }
  8369. self() {
  8370. return this.stack[this.stack.length - 1];
  8371. }
  8372. find_parent(type) {
  8373. var stack = this.stack;
  8374. for (var i = stack.length; --i >= 0;) {
  8375. var x = stack[i];
  8376. if (x instanceof type) return x;
  8377. }
  8378. }
  8379. find_scope() {
  8380. for (let i = 0;;i++) {
  8381. const p = this.parent(i);
  8382. if (p instanceof AST_Toplevel) return p;
  8383. if (p instanceof AST_Lambda) return p;
  8384. if (p.block_scope) return p.block_scope;
  8385. }
  8386. }
  8387. has_directive(type) {
  8388. var dir = this.directives[type];
  8389. if (dir) return dir;
  8390. var node = this.stack[this.stack.length - 1];
  8391. if (node instanceof AST_Scope && node.body) {
  8392. for (var i = 0; i < node.body.length; ++i) {
  8393. var st = node.body[i];
  8394. if (!(st instanceof AST_Directive)) break;
  8395. if (st.value == type) return st;
  8396. }
  8397. }
  8398. }
  8399. loopcontrol_target(node) {
  8400. var stack = this.stack;
  8401. if (node.label) for (var i = stack.length; --i >= 0;) {
  8402. var x = stack[i];
  8403. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  8404. return x.body;
  8405. } else for (var i = stack.length; --i >= 0;) {
  8406. var x = stack[i];
  8407. if (x instanceof AST_IterationStatement
  8408. || node instanceof AST_Break && x instanceof AST_Switch)
  8409. return x;
  8410. }
  8411. }
  8412. }
  8413. // Tree transformer helpers.
  8414. class TreeTransformer extends TreeWalker {
  8415. constructor(before, after) {
  8416. super();
  8417. this.before = before;
  8418. this.after = after;
  8419. }
  8420. }
  8421. const _PURE = 0b00000001;
  8422. const _INLINE = 0b00000010;
  8423. const _NOINLINE = 0b00000100;
  8424. /***********************************************************************
  8425. A JavaScript tokenizer / parser / beautifier / compressor.
  8426. https://github.com/mishoo/UglifyJS2
  8427. -------------------------------- (C) ---------------------------------
  8428. Author: Mihai Bazon
  8429. <mihai.bazon@gmail.com>
  8430. http://mihai.bazon.net/blog
  8431. Distributed under the BSD license:
  8432. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8433. Redistribution and use in source and binary forms, with or without
  8434. modification, are permitted provided that the following conditions
  8435. are met:
  8436. * Redistributions of source code must retain the above
  8437. copyright notice, this list of conditions and the following
  8438. disclaimer.
  8439. * Redistributions in binary form must reproduce the above
  8440. copyright notice, this list of conditions and the following
  8441. disclaimer in the documentation and/or other materials
  8442. provided with the distribution.
  8443. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8444. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8445. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8446. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8447. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8448. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8449. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8450. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8451. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8452. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8453. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8454. SUCH DAMAGE.
  8455. ***********************************************************************/
  8456. function def_transform(node, descend) {
  8457. node.DEFMETHOD("transform", function(tw, in_list) {
  8458. let transformed = undefined;
  8459. tw.push(this);
  8460. if (tw.before) transformed = tw.before(this, descend, in_list);
  8461. if (transformed === undefined) {
  8462. transformed = this;
  8463. descend(transformed, tw);
  8464. if (tw.after) {
  8465. const after_ret = tw.after(transformed, in_list);
  8466. if (after_ret !== undefined) transformed = after_ret;
  8467. }
  8468. }
  8469. tw.pop();
  8470. return transformed;
  8471. });
  8472. }
  8473. function do_list(list, tw) {
  8474. return MAP(list, function(node) {
  8475. return node.transform(tw, true);
  8476. });
  8477. }
  8478. def_transform(AST_Node, noop);
  8479. def_transform(AST_LabeledStatement, function(self, tw) {
  8480. self.label = self.label.transform(tw);
  8481. self.body = self.body.transform(tw);
  8482. });
  8483. def_transform(AST_SimpleStatement, function(self, tw) {
  8484. self.body = self.body.transform(tw);
  8485. });
  8486. def_transform(AST_Block, function(self, tw) {
  8487. self.body = do_list(self.body, tw);
  8488. });
  8489. def_transform(AST_Do, function(self, tw) {
  8490. self.body = self.body.transform(tw);
  8491. self.condition = self.condition.transform(tw);
  8492. });
  8493. def_transform(AST_While, function(self, tw) {
  8494. self.condition = self.condition.transform(tw);
  8495. self.body = self.body.transform(tw);
  8496. });
  8497. def_transform(AST_For, function(self, tw) {
  8498. if (self.init) self.init = self.init.transform(tw);
  8499. if (self.condition) self.condition = self.condition.transform(tw);
  8500. if (self.step) self.step = self.step.transform(tw);
  8501. self.body = self.body.transform(tw);
  8502. });
  8503. def_transform(AST_ForIn, function(self, tw) {
  8504. self.init = self.init.transform(tw);
  8505. self.object = self.object.transform(tw);
  8506. self.body = self.body.transform(tw);
  8507. });
  8508. def_transform(AST_With, function(self, tw) {
  8509. self.expression = self.expression.transform(tw);
  8510. self.body = self.body.transform(tw);
  8511. });
  8512. def_transform(AST_Exit, function(self, tw) {
  8513. if (self.value) self.value = self.value.transform(tw);
  8514. });
  8515. def_transform(AST_LoopControl, function(self, tw) {
  8516. if (self.label) self.label = self.label.transform(tw);
  8517. });
  8518. def_transform(AST_If, function(self, tw) {
  8519. self.condition = self.condition.transform(tw);
  8520. self.body = self.body.transform(tw);
  8521. if (self.alternative) self.alternative = self.alternative.transform(tw);
  8522. });
  8523. def_transform(AST_Switch, function(self, tw) {
  8524. self.expression = self.expression.transform(tw);
  8525. self.body = do_list(self.body, tw);
  8526. });
  8527. def_transform(AST_Case, function(self, tw) {
  8528. self.expression = self.expression.transform(tw);
  8529. self.body = do_list(self.body, tw);
  8530. });
  8531. def_transform(AST_Try, function(self, tw) {
  8532. self.body = do_list(self.body, tw);
  8533. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  8534. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  8535. });
  8536. def_transform(AST_Catch, function(self, tw) {
  8537. if (self.argname) self.argname = self.argname.transform(tw);
  8538. self.body = do_list(self.body, tw);
  8539. });
  8540. def_transform(AST_Definitions, function(self, tw) {
  8541. self.definitions = do_list(self.definitions, tw);
  8542. });
  8543. def_transform(AST_VarDef, function(self, tw) {
  8544. self.name = self.name.transform(tw);
  8545. if (self.value) self.value = self.value.transform(tw);
  8546. });
  8547. def_transform(AST_Destructuring, function(self, tw) {
  8548. self.names = do_list(self.names, tw);
  8549. });
  8550. def_transform(AST_Lambda, function(self, tw) {
  8551. if (self.name) self.name = self.name.transform(tw);
  8552. self.argnames = do_list(self.argnames, tw);
  8553. if (self.body instanceof AST_Node) {
  8554. self.body = self.body.transform(tw);
  8555. } else {
  8556. self.body = do_list(self.body, tw);
  8557. }
  8558. });
  8559. def_transform(AST_Call, function(self, tw) {
  8560. self.expression = self.expression.transform(tw);
  8561. self.args = do_list(self.args, tw);
  8562. });
  8563. def_transform(AST_Sequence, function(self, tw) {
  8564. const result = do_list(self.expressions, tw);
  8565. self.expressions = result.length
  8566. ? result
  8567. : [new AST_Number({ value: 0 })];
  8568. });
  8569. def_transform(AST_PropAccess, function(self, tw) {
  8570. self.expression = self.expression.transform(tw);
  8571. });
  8572. def_transform(AST_Sub, function(self, tw) {
  8573. self.expression = self.expression.transform(tw);
  8574. self.property = self.property.transform(tw);
  8575. });
  8576. def_transform(AST_Chain, function(self, tw) {
  8577. self.expression = self.expression.transform(tw);
  8578. });
  8579. def_transform(AST_Yield, function(self, tw) {
  8580. if (self.expression) self.expression = self.expression.transform(tw);
  8581. });
  8582. def_transform(AST_Await, function(self, tw) {
  8583. self.expression = self.expression.transform(tw);
  8584. });
  8585. def_transform(AST_Unary, function(self, tw) {
  8586. self.expression = self.expression.transform(tw);
  8587. });
  8588. def_transform(AST_Binary, function(self, tw) {
  8589. self.left = self.left.transform(tw);
  8590. self.right = self.right.transform(tw);
  8591. });
  8592. def_transform(AST_Conditional, function(self, tw) {
  8593. self.condition = self.condition.transform(tw);
  8594. self.consequent = self.consequent.transform(tw);
  8595. self.alternative = self.alternative.transform(tw);
  8596. });
  8597. def_transform(AST_Array, function(self, tw) {
  8598. self.elements = do_list(self.elements, tw);
  8599. });
  8600. def_transform(AST_Object, function(self, tw) {
  8601. self.properties = do_list(self.properties, tw);
  8602. });
  8603. def_transform(AST_ObjectProperty, function(self, tw) {
  8604. if (self.key instanceof AST_Node) {
  8605. self.key = self.key.transform(tw);
  8606. }
  8607. if (self.value) self.value = self.value.transform(tw);
  8608. });
  8609. def_transform(AST_Class, function(self, tw) {
  8610. if (self.name) self.name = self.name.transform(tw);
  8611. if (self.extends) self.extends = self.extends.transform(tw);
  8612. self.properties = do_list(self.properties, tw);
  8613. });
  8614. def_transform(AST_Expansion, function(self, tw) {
  8615. self.expression = self.expression.transform(tw);
  8616. });
  8617. def_transform(AST_NameMapping, function(self, tw) {
  8618. self.foreign_name = self.foreign_name.transform(tw);
  8619. self.name = self.name.transform(tw);
  8620. });
  8621. def_transform(AST_Import, function(self, tw) {
  8622. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  8623. if (self.imported_names) do_list(self.imported_names, tw);
  8624. self.module_name = self.module_name.transform(tw);
  8625. });
  8626. def_transform(AST_Export, function(self, tw) {
  8627. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  8628. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  8629. if (self.exported_names) do_list(self.exported_names, tw);
  8630. if (self.module_name) self.module_name = self.module_name.transform(tw);
  8631. });
  8632. def_transform(AST_TemplateString, function(self, tw) {
  8633. self.segments = do_list(self.segments, tw);
  8634. });
  8635. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  8636. self.prefix = self.prefix.transform(tw);
  8637. self.template_string = self.template_string.transform(tw);
  8638. });
  8639. /***********************************************************************
  8640. A JavaScript tokenizer / parser / beautifier / compressor.
  8641. https://github.com/mishoo/UglifyJS2
  8642. -------------------------------- (C) ---------------------------------
  8643. Author: Mihai Bazon
  8644. <mihai.bazon@gmail.com>
  8645. http://mihai.bazon.net/blog
  8646. Distributed under the BSD license:
  8647. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8648. Redistribution and use in source and binary forms, with or without
  8649. modification, are permitted provided that the following conditions
  8650. are met:
  8651. * Redistributions of source code must retain the above
  8652. copyright notice, this list of conditions and the following
  8653. disclaimer.
  8654. * Redistributions in binary form must reproduce the above
  8655. copyright notice, this list of conditions and the following
  8656. disclaimer in the documentation and/or other materials
  8657. provided with the distribution.
  8658. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8659. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8660. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8661. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8662. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8663. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8664. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8665. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8666. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8667. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8668. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8669. SUCH DAMAGE.
  8670. ***********************************************************************/
  8671. (function() {
  8672. var normalize_directives = function(body) {
  8673. var in_directive = true;
  8674. for (var i = 0; i < body.length; i++) {
  8675. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  8676. body[i] = new AST_Directive({
  8677. start: body[i].start,
  8678. end: body[i].end,
  8679. value: body[i].body.value
  8680. });
  8681. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  8682. in_directive = false;
  8683. }
  8684. }
  8685. return body;
  8686. };
  8687. const assert_clause_from_moz = (assertions) => {
  8688. if (assertions && assertions.length > 0) {
  8689. return new AST_Object({
  8690. start: my_start_token(assertions),
  8691. end: my_end_token(assertions),
  8692. properties: assertions.map((assertion_kv) =>
  8693. new AST_ObjectKeyVal({
  8694. start: my_start_token(assertion_kv),
  8695. end: my_end_token(assertion_kv),
  8696. key: assertion_kv.key.name || assertion_kv.key.value,
  8697. value: from_moz(assertion_kv.value)
  8698. })
  8699. )
  8700. });
  8701. }
  8702. return null;
  8703. };
  8704. var MOZ_TO_ME = {
  8705. Program: function(M) {
  8706. return new AST_Toplevel({
  8707. start: my_start_token(M),
  8708. end: my_end_token(M),
  8709. body: normalize_directives(M.body.map(from_moz))
  8710. });
  8711. },
  8712. ArrayPattern: function(M) {
  8713. return new AST_Destructuring({
  8714. start: my_start_token(M),
  8715. end: my_end_token(M),
  8716. names: M.elements.map(function(elm) {
  8717. if (elm === null) {
  8718. return new AST_Hole();
  8719. }
  8720. return from_moz(elm);
  8721. }),
  8722. is_array: true
  8723. });
  8724. },
  8725. ObjectPattern: function(M) {
  8726. return new AST_Destructuring({
  8727. start: my_start_token(M),
  8728. end: my_end_token(M),
  8729. names: M.properties.map(from_moz),
  8730. is_array: false
  8731. });
  8732. },
  8733. AssignmentPattern: function(M) {
  8734. return new AST_DefaultAssign({
  8735. start: my_start_token(M),
  8736. end: my_end_token(M),
  8737. left: from_moz(M.left),
  8738. operator: "=",
  8739. right: from_moz(M.right)
  8740. });
  8741. },
  8742. SpreadElement: function(M) {
  8743. return new AST_Expansion({
  8744. start: my_start_token(M),
  8745. end: my_end_token(M),
  8746. expression: from_moz(M.argument)
  8747. });
  8748. },
  8749. RestElement: function(M) {
  8750. return new AST_Expansion({
  8751. start: my_start_token(M),
  8752. end: my_end_token(M),
  8753. expression: from_moz(M.argument)
  8754. });
  8755. },
  8756. TemplateElement: function(M) {
  8757. return new AST_TemplateSegment({
  8758. start: my_start_token(M),
  8759. end: my_end_token(M),
  8760. value: M.value.cooked,
  8761. raw: M.value.raw
  8762. });
  8763. },
  8764. TemplateLiteral: function(M) {
  8765. var segments = [];
  8766. for (var i = 0; i < M.quasis.length; i++) {
  8767. segments.push(from_moz(M.quasis[i]));
  8768. if (M.expressions[i]) {
  8769. segments.push(from_moz(M.expressions[i]));
  8770. }
  8771. }
  8772. return new AST_TemplateString({
  8773. start: my_start_token(M),
  8774. end: my_end_token(M),
  8775. segments: segments
  8776. });
  8777. },
  8778. TaggedTemplateExpression: function(M) {
  8779. return new AST_PrefixedTemplateString({
  8780. start: my_start_token(M),
  8781. end: my_end_token(M),
  8782. template_string: from_moz(M.quasi),
  8783. prefix: from_moz(M.tag)
  8784. });
  8785. },
  8786. FunctionDeclaration: function(M) {
  8787. return new AST_Defun({
  8788. start: my_start_token(M),
  8789. end: my_end_token(M),
  8790. name: from_moz(M.id),
  8791. argnames: M.params.map(from_moz),
  8792. is_generator: M.generator,
  8793. async: M.async,
  8794. body: normalize_directives(from_moz(M.body).body)
  8795. });
  8796. },
  8797. FunctionExpression: function(M) {
  8798. return new AST_Function({
  8799. start: my_start_token(M),
  8800. end: my_end_token(M),
  8801. name: from_moz(M.id),
  8802. argnames: M.params.map(from_moz),
  8803. is_generator: M.generator,
  8804. async: M.async,
  8805. body: normalize_directives(from_moz(M.body).body)
  8806. });
  8807. },
  8808. ArrowFunctionExpression: function(M) {
  8809. const body = M.body.type === "BlockStatement"
  8810. ? from_moz(M.body).body
  8811. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  8812. return new AST_Arrow({
  8813. start: my_start_token(M),
  8814. end: my_end_token(M),
  8815. argnames: M.params.map(from_moz),
  8816. body,
  8817. async: M.async,
  8818. });
  8819. },
  8820. ExpressionStatement: function(M) {
  8821. return new AST_SimpleStatement({
  8822. start: my_start_token(M),
  8823. end: my_end_token(M),
  8824. body: from_moz(M.expression)
  8825. });
  8826. },
  8827. TryStatement: function(M) {
  8828. var handlers = M.handlers || [M.handler];
  8829. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  8830. throw new Error("Multiple catch clauses are not supported.");
  8831. }
  8832. return new AST_Try({
  8833. start : my_start_token(M),
  8834. end : my_end_token(M),
  8835. body : from_moz(M.block).body,
  8836. bcatch : from_moz(handlers[0]),
  8837. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  8838. });
  8839. },
  8840. Property: function(M) {
  8841. var key = M.key;
  8842. var args = {
  8843. start : my_start_token(key || M.value),
  8844. end : my_end_token(M.value),
  8845. key : key.type == "Identifier" ? key.name : key.value,
  8846. value : from_moz(M.value)
  8847. };
  8848. if (M.computed) {
  8849. args.key = from_moz(M.key);
  8850. }
  8851. if (M.method) {
  8852. args.is_generator = M.value.generator;
  8853. args.async = M.value.async;
  8854. if (!M.computed) {
  8855. args.key = new AST_SymbolMethod({ name: args.key });
  8856. } else {
  8857. args.key = from_moz(M.key);
  8858. }
  8859. return new AST_ConciseMethod(args);
  8860. }
  8861. if (M.kind == "init") {
  8862. if (key.type != "Identifier" && key.type != "Literal") {
  8863. args.key = from_moz(key);
  8864. }
  8865. return new AST_ObjectKeyVal(args);
  8866. }
  8867. if (typeof args.key === "string" || typeof args.key === "number") {
  8868. args.key = new AST_SymbolMethod({
  8869. name: args.key
  8870. });
  8871. }
  8872. args.value = new AST_Accessor(args.value);
  8873. if (M.kind == "get") return new AST_ObjectGetter(args);
  8874. if (M.kind == "set") return new AST_ObjectSetter(args);
  8875. if (M.kind == "method") {
  8876. args.async = M.value.async;
  8877. args.is_generator = M.value.generator;
  8878. args.quote = M.computed ? "\"" : null;
  8879. return new AST_ConciseMethod(args);
  8880. }
  8881. },
  8882. MethodDefinition: function(M) {
  8883. var args = {
  8884. start : my_start_token(M),
  8885. end : my_end_token(M),
  8886. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  8887. value : from_moz(M.value),
  8888. static : M.static,
  8889. };
  8890. if (M.kind == "get") {
  8891. return new AST_ObjectGetter(args);
  8892. }
  8893. if (M.kind == "set") {
  8894. return new AST_ObjectSetter(args);
  8895. }
  8896. args.is_generator = M.value.generator;
  8897. args.async = M.value.async;
  8898. return new AST_ConciseMethod(args);
  8899. },
  8900. FieldDefinition: function(M) {
  8901. let key;
  8902. if (M.computed) {
  8903. key = from_moz(M.key);
  8904. } else {
  8905. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  8906. key = from_moz(M.key);
  8907. }
  8908. return new AST_ClassProperty({
  8909. start : my_start_token(M),
  8910. end : my_end_token(M),
  8911. key,
  8912. value : from_moz(M.value),
  8913. static : M.static,
  8914. });
  8915. },
  8916. PropertyDefinition: function(M) {
  8917. let key;
  8918. if (M.computed) {
  8919. key = from_moz(M.key);
  8920. } else {
  8921. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
  8922. key = from_moz(M.key);
  8923. }
  8924. return new AST_ClassProperty({
  8925. start : my_start_token(M),
  8926. end : my_end_token(M),
  8927. key,
  8928. value : from_moz(M.value),
  8929. static : M.static,
  8930. });
  8931. },
  8932. ArrayExpression: function(M) {
  8933. return new AST_Array({
  8934. start : my_start_token(M),
  8935. end : my_end_token(M),
  8936. elements : M.elements.map(function(elem) {
  8937. return elem === null ? new AST_Hole() : from_moz(elem);
  8938. })
  8939. });
  8940. },
  8941. ObjectExpression: function(M) {
  8942. return new AST_Object({
  8943. start : my_start_token(M),
  8944. end : my_end_token(M),
  8945. properties : M.properties.map(function(prop) {
  8946. if (prop.type === "SpreadElement") {
  8947. return from_moz(prop);
  8948. }
  8949. prop.type = "Property";
  8950. return from_moz(prop);
  8951. })
  8952. });
  8953. },
  8954. SequenceExpression: function(M) {
  8955. return new AST_Sequence({
  8956. start : my_start_token(M),
  8957. end : my_end_token(M),
  8958. expressions: M.expressions.map(from_moz)
  8959. });
  8960. },
  8961. MemberExpression: function(M) {
  8962. return new (M.computed ? AST_Sub : AST_Dot)({
  8963. start : my_start_token(M),
  8964. end : my_end_token(M),
  8965. property : M.computed ? from_moz(M.property) : M.property.name,
  8966. expression : from_moz(M.object),
  8967. optional : M.optional || false
  8968. });
  8969. },
  8970. ChainExpression: function(M) {
  8971. return new AST_Chain({
  8972. start : my_start_token(M),
  8973. end : my_end_token(M),
  8974. expression : from_moz(M.expression)
  8975. });
  8976. },
  8977. SwitchCase: function(M) {
  8978. return new (M.test ? AST_Case : AST_Default)({
  8979. start : my_start_token(M),
  8980. end : my_end_token(M),
  8981. expression : from_moz(M.test),
  8982. body : M.consequent.map(from_moz)
  8983. });
  8984. },
  8985. VariableDeclaration: function(M) {
  8986. return new (M.kind === "const" ? AST_Const :
  8987. M.kind === "let" ? AST_Let : AST_Var)({
  8988. start : my_start_token(M),
  8989. end : my_end_token(M),
  8990. definitions : M.declarations.map(from_moz)
  8991. });
  8992. },
  8993. ImportDeclaration: function(M) {
  8994. var imported_name = null;
  8995. var imported_names = null;
  8996. M.specifiers.forEach(function (specifier) {
  8997. if (specifier.type === "ImportSpecifier") {
  8998. if (!imported_names) { imported_names = []; }
  8999. imported_names.push(new AST_NameMapping({
  9000. start: my_start_token(specifier),
  9001. end: my_end_token(specifier),
  9002. foreign_name: from_moz(specifier.imported),
  9003. name: from_moz(specifier.local)
  9004. }));
  9005. } else if (specifier.type === "ImportDefaultSpecifier") {
  9006. imported_name = from_moz(specifier.local);
  9007. } else if (specifier.type === "ImportNamespaceSpecifier") {
  9008. if (!imported_names) { imported_names = []; }
  9009. imported_names.push(new AST_NameMapping({
  9010. start: my_start_token(specifier),
  9011. end: my_end_token(specifier),
  9012. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  9013. name: from_moz(specifier.local)
  9014. }));
  9015. }
  9016. });
  9017. return new AST_Import({
  9018. start : my_start_token(M),
  9019. end : my_end_token(M),
  9020. imported_name: imported_name,
  9021. imported_names : imported_names,
  9022. module_name : from_moz(M.source),
  9023. assert_clause: assert_clause_from_moz(M.assertions)
  9024. });
  9025. },
  9026. ExportAllDeclaration: function(M) {
  9027. return new AST_Export({
  9028. start: my_start_token(M),
  9029. end: my_end_token(M),
  9030. exported_names: [
  9031. new AST_NameMapping({
  9032. name: new AST_SymbolExportForeign({ name: "*" }),
  9033. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  9034. })
  9035. ],
  9036. module_name: from_moz(M.source),
  9037. assert_clause: assert_clause_from_moz(M.assertions)
  9038. });
  9039. },
  9040. ExportNamedDeclaration: function(M) {
  9041. return new AST_Export({
  9042. start: my_start_token(M),
  9043. end: my_end_token(M),
  9044. exported_definition: from_moz(M.declaration),
  9045. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  9046. return new AST_NameMapping({
  9047. foreign_name: from_moz(specifier.exported),
  9048. name: from_moz(specifier.local)
  9049. });
  9050. }) : null,
  9051. module_name: from_moz(M.source),
  9052. assert_clause: assert_clause_from_moz(M.assertions)
  9053. });
  9054. },
  9055. ExportDefaultDeclaration: function(M) {
  9056. return new AST_Export({
  9057. start: my_start_token(M),
  9058. end: my_end_token(M),
  9059. exported_value: from_moz(M.declaration),
  9060. is_default: true
  9061. });
  9062. },
  9063. Literal: function(M) {
  9064. var val = M.value, args = {
  9065. start : my_start_token(M),
  9066. end : my_end_token(M)
  9067. };
  9068. var rx = M.regex;
  9069. if (rx && rx.pattern) {
  9070. // RegExpLiteral as per ESTree AST spec
  9071. args.value = {
  9072. source: rx.pattern,
  9073. flags: rx.flags
  9074. };
  9075. return new AST_RegExp(args);
  9076. } else if (rx) {
  9077. // support legacy RegExp
  9078. const rx_source = M.raw || val;
  9079. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  9080. if (!match) throw new Error("Invalid regex source " + rx_source);
  9081. const [_, source, flags] = match;
  9082. args.value = { source, flags };
  9083. return new AST_RegExp(args);
  9084. }
  9085. if (val === null) return new AST_Null(args);
  9086. switch (typeof val) {
  9087. case "string":
  9088. args.value = val;
  9089. return new AST_String(args);
  9090. case "number":
  9091. args.value = val;
  9092. args.raw = M.raw || val.toString();
  9093. return new AST_Number(args);
  9094. case "boolean":
  9095. return new (val ? AST_True : AST_False)(args);
  9096. }
  9097. },
  9098. MetaProperty: function(M) {
  9099. if (M.meta.name === "new" && M.property.name === "target") {
  9100. return new AST_NewTarget({
  9101. start: my_start_token(M),
  9102. end: my_end_token(M)
  9103. });
  9104. } else if (M.meta.name === "import" && M.property.name === "meta") {
  9105. return new AST_ImportMeta({
  9106. start: my_start_token(M),
  9107. end: my_end_token(M)
  9108. });
  9109. }
  9110. },
  9111. Identifier: function(M) {
  9112. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  9113. return new ( p.type == "LabeledStatement" ? AST_Label
  9114. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  9115. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  9116. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  9117. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  9118. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  9119. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  9120. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  9121. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  9122. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  9123. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  9124. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  9125. : p.type == "CatchClause" ? AST_SymbolCatch
  9126. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  9127. : AST_SymbolRef)({
  9128. start : my_start_token(M),
  9129. end : my_end_token(M),
  9130. name : M.name
  9131. });
  9132. },
  9133. BigIntLiteral(M) {
  9134. return new AST_BigInt({
  9135. start : my_start_token(M),
  9136. end : my_end_token(M),
  9137. value : M.value
  9138. });
  9139. },
  9140. EmptyStatement: function(M) {
  9141. return new AST_EmptyStatement({
  9142. start: my_start_token(M),
  9143. end: my_end_token(M)
  9144. });
  9145. },
  9146. BlockStatement: function(M) {
  9147. return new AST_BlockStatement({
  9148. start: my_start_token(M),
  9149. end: my_end_token(M),
  9150. body: M.body.map(from_moz)
  9151. });
  9152. },
  9153. IfStatement: function(M) {
  9154. return new AST_If({
  9155. start: my_start_token(M),
  9156. end: my_end_token(M),
  9157. condition: from_moz(M.test),
  9158. body: from_moz(M.consequent),
  9159. alternative: from_moz(M.alternate)
  9160. });
  9161. },
  9162. LabeledStatement: function(M) {
  9163. return new AST_LabeledStatement({
  9164. start: my_start_token(M),
  9165. end: my_end_token(M),
  9166. label: from_moz(M.label),
  9167. body: from_moz(M.body)
  9168. });
  9169. },
  9170. BreakStatement: function(M) {
  9171. return new AST_Break({
  9172. start: my_start_token(M),
  9173. end: my_end_token(M),
  9174. label: from_moz(M.label)
  9175. });
  9176. },
  9177. ContinueStatement: function(M) {
  9178. return new AST_Continue({
  9179. start: my_start_token(M),
  9180. end: my_end_token(M),
  9181. label: from_moz(M.label)
  9182. });
  9183. },
  9184. WithStatement: function(M) {
  9185. return new AST_With({
  9186. start: my_start_token(M),
  9187. end: my_end_token(M),
  9188. expression: from_moz(M.object),
  9189. body: from_moz(M.body)
  9190. });
  9191. },
  9192. SwitchStatement: function(M) {
  9193. return new AST_Switch({
  9194. start: my_start_token(M),
  9195. end: my_end_token(M),
  9196. expression: from_moz(M.discriminant),
  9197. body: M.cases.map(from_moz)
  9198. });
  9199. },
  9200. ReturnStatement: function(M) {
  9201. return new AST_Return({
  9202. start: my_start_token(M),
  9203. end: my_end_token(M),
  9204. value: from_moz(M.argument)
  9205. });
  9206. },
  9207. ThrowStatement: function(M) {
  9208. return new AST_Throw({
  9209. start: my_start_token(M),
  9210. end: my_end_token(M),
  9211. value: from_moz(M.argument)
  9212. });
  9213. },
  9214. WhileStatement: function(M) {
  9215. return new AST_While({
  9216. start: my_start_token(M),
  9217. end: my_end_token(M),
  9218. condition: from_moz(M.test),
  9219. body: from_moz(M.body)
  9220. });
  9221. },
  9222. DoWhileStatement: function(M) {
  9223. return new AST_Do({
  9224. start: my_start_token(M),
  9225. end: my_end_token(M),
  9226. condition: from_moz(M.test),
  9227. body: from_moz(M.body)
  9228. });
  9229. },
  9230. ForStatement: function(M) {
  9231. return new AST_For({
  9232. start: my_start_token(M),
  9233. end: my_end_token(M),
  9234. init: from_moz(M.init),
  9235. condition: from_moz(M.test),
  9236. step: from_moz(M.update),
  9237. body: from_moz(M.body)
  9238. });
  9239. },
  9240. ForInStatement: function(M) {
  9241. return new AST_ForIn({
  9242. start: my_start_token(M),
  9243. end: my_end_token(M),
  9244. init: from_moz(M.left),
  9245. object: from_moz(M.right),
  9246. body: from_moz(M.body)
  9247. });
  9248. },
  9249. ForOfStatement: function(M) {
  9250. return new AST_ForOf({
  9251. start: my_start_token(M),
  9252. end: my_end_token(M),
  9253. init: from_moz(M.left),
  9254. object: from_moz(M.right),
  9255. body: from_moz(M.body),
  9256. await: M.await
  9257. });
  9258. },
  9259. AwaitExpression: function(M) {
  9260. return new AST_Await({
  9261. start: my_start_token(M),
  9262. end: my_end_token(M),
  9263. expression: from_moz(M.argument)
  9264. });
  9265. },
  9266. YieldExpression: function(M) {
  9267. return new AST_Yield({
  9268. start: my_start_token(M),
  9269. end: my_end_token(M),
  9270. expression: from_moz(M.argument),
  9271. is_star: M.delegate
  9272. });
  9273. },
  9274. DebuggerStatement: function(M) {
  9275. return new AST_Debugger({
  9276. start: my_start_token(M),
  9277. end: my_end_token(M)
  9278. });
  9279. },
  9280. VariableDeclarator: function(M) {
  9281. return new AST_VarDef({
  9282. start: my_start_token(M),
  9283. end: my_end_token(M),
  9284. name: from_moz(M.id),
  9285. value: from_moz(M.init)
  9286. });
  9287. },
  9288. CatchClause: function(M) {
  9289. return new AST_Catch({
  9290. start: my_start_token(M),
  9291. end: my_end_token(M),
  9292. argname: from_moz(M.param),
  9293. body: from_moz(M.body).body
  9294. });
  9295. },
  9296. ThisExpression: function(M) {
  9297. return new AST_This({
  9298. start: my_start_token(M),
  9299. end: my_end_token(M)
  9300. });
  9301. },
  9302. Super: function(M) {
  9303. return new AST_Super({
  9304. start: my_start_token(M),
  9305. end: my_end_token(M)
  9306. });
  9307. },
  9308. BinaryExpression: function(M) {
  9309. return new AST_Binary({
  9310. start: my_start_token(M),
  9311. end: my_end_token(M),
  9312. operator: M.operator,
  9313. left: from_moz(M.left),
  9314. right: from_moz(M.right)
  9315. });
  9316. },
  9317. LogicalExpression: function(M) {
  9318. return new AST_Binary({
  9319. start: my_start_token(M),
  9320. end: my_end_token(M),
  9321. operator: M.operator,
  9322. left: from_moz(M.left),
  9323. right: from_moz(M.right)
  9324. });
  9325. },
  9326. AssignmentExpression: function(M) {
  9327. return new AST_Assign({
  9328. start: my_start_token(M),
  9329. end: my_end_token(M),
  9330. operator: M.operator,
  9331. left: from_moz(M.left),
  9332. right: from_moz(M.right)
  9333. });
  9334. },
  9335. ConditionalExpression: function(M) {
  9336. return new AST_Conditional({
  9337. start: my_start_token(M),
  9338. end: my_end_token(M),
  9339. condition: from_moz(M.test),
  9340. consequent: from_moz(M.consequent),
  9341. alternative: from_moz(M.alternate)
  9342. });
  9343. },
  9344. NewExpression: function(M) {
  9345. return new AST_New({
  9346. start: my_start_token(M),
  9347. end: my_end_token(M),
  9348. expression: from_moz(M.callee),
  9349. args: M.arguments.map(from_moz)
  9350. });
  9351. },
  9352. CallExpression: function(M) {
  9353. return new AST_Call({
  9354. start: my_start_token(M),
  9355. end: my_end_token(M),
  9356. expression: from_moz(M.callee),
  9357. optional: M.optional,
  9358. args: M.arguments.map(from_moz)
  9359. });
  9360. }
  9361. };
  9362. MOZ_TO_ME.UpdateExpression =
  9363. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  9364. var prefix = "prefix" in M ? M.prefix
  9365. : M.type == "UnaryExpression" ? true : false;
  9366. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  9367. start : my_start_token(M),
  9368. end : my_end_token(M),
  9369. operator : M.operator,
  9370. expression : from_moz(M.argument)
  9371. });
  9372. };
  9373. MOZ_TO_ME.ClassDeclaration =
  9374. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  9375. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  9376. start : my_start_token(M),
  9377. end : my_end_token(M),
  9378. name : from_moz(M.id),
  9379. extends : from_moz(M.superClass),
  9380. properties: M.body.body.map(from_moz)
  9381. });
  9382. };
  9383. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  9384. return {
  9385. type: "EmptyStatement"
  9386. };
  9387. });
  9388. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  9389. return {
  9390. type: "BlockStatement",
  9391. body: M.body.map(to_moz)
  9392. };
  9393. });
  9394. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  9395. return {
  9396. type: "IfStatement",
  9397. test: to_moz(M.condition),
  9398. consequent: to_moz(M.body),
  9399. alternate: to_moz(M.alternative)
  9400. };
  9401. });
  9402. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  9403. return {
  9404. type: "LabeledStatement",
  9405. label: to_moz(M.label),
  9406. body: to_moz(M.body)
  9407. };
  9408. });
  9409. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  9410. return {
  9411. type: "BreakStatement",
  9412. label: to_moz(M.label)
  9413. };
  9414. });
  9415. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  9416. return {
  9417. type: "ContinueStatement",
  9418. label: to_moz(M.label)
  9419. };
  9420. });
  9421. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  9422. return {
  9423. type: "WithStatement",
  9424. object: to_moz(M.expression),
  9425. body: to_moz(M.body)
  9426. };
  9427. });
  9428. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  9429. return {
  9430. type: "SwitchStatement",
  9431. discriminant: to_moz(M.expression),
  9432. cases: M.body.map(to_moz)
  9433. };
  9434. });
  9435. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  9436. return {
  9437. type: "ReturnStatement",
  9438. argument: to_moz(M.value)
  9439. };
  9440. });
  9441. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  9442. return {
  9443. type: "ThrowStatement",
  9444. argument: to_moz(M.value)
  9445. };
  9446. });
  9447. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  9448. return {
  9449. type: "WhileStatement",
  9450. test: to_moz(M.condition),
  9451. body: to_moz(M.body)
  9452. };
  9453. });
  9454. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  9455. return {
  9456. type: "DoWhileStatement",
  9457. test: to_moz(M.condition),
  9458. body: to_moz(M.body)
  9459. };
  9460. });
  9461. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  9462. return {
  9463. type: "ForStatement",
  9464. init: to_moz(M.init),
  9465. test: to_moz(M.condition),
  9466. update: to_moz(M.step),
  9467. body: to_moz(M.body)
  9468. };
  9469. });
  9470. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  9471. return {
  9472. type: "ForInStatement",
  9473. left: to_moz(M.init),
  9474. right: to_moz(M.object),
  9475. body: to_moz(M.body)
  9476. };
  9477. });
  9478. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  9479. return {
  9480. type: "ForOfStatement",
  9481. left: to_moz(M.init),
  9482. right: to_moz(M.object),
  9483. body: to_moz(M.body),
  9484. await: M.await
  9485. };
  9486. });
  9487. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  9488. return {
  9489. type: "AwaitExpression",
  9490. argument: to_moz(M.expression)
  9491. };
  9492. });
  9493. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  9494. return {
  9495. type: "YieldExpression",
  9496. argument: to_moz(M.expression),
  9497. delegate: M.is_star
  9498. };
  9499. });
  9500. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  9501. return {
  9502. type: "DebuggerStatement"
  9503. };
  9504. });
  9505. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  9506. return {
  9507. type: "VariableDeclarator",
  9508. id: to_moz(M.name),
  9509. init: to_moz(M.value)
  9510. };
  9511. });
  9512. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  9513. return {
  9514. type: "CatchClause",
  9515. param: to_moz(M.argname),
  9516. body: to_moz_block(M)
  9517. };
  9518. });
  9519. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  9520. return {
  9521. type: "ThisExpression"
  9522. };
  9523. });
  9524. def_to_moz(AST_Super, function To_Moz_Super() {
  9525. return {
  9526. type: "Super"
  9527. };
  9528. });
  9529. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  9530. return {
  9531. type: "BinaryExpression",
  9532. operator: M.operator,
  9533. left: to_moz(M.left),
  9534. right: to_moz(M.right)
  9535. };
  9536. });
  9537. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  9538. return {
  9539. type: "LogicalExpression",
  9540. operator: M.operator,
  9541. left: to_moz(M.left),
  9542. right: to_moz(M.right)
  9543. };
  9544. });
  9545. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  9546. return {
  9547. type: "AssignmentExpression",
  9548. operator: M.operator,
  9549. left: to_moz(M.left),
  9550. right: to_moz(M.right)
  9551. };
  9552. });
  9553. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  9554. return {
  9555. type: "ConditionalExpression",
  9556. test: to_moz(M.condition),
  9557. consequent: to_moz(M.consequent),
  9558. alternate: to_moz(M.alternative)
  9559. };
  9560. });
  9561. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  9562. return {
  9563. type: "NewExpression",
  9564. callee: to_moz(M.expression),
  9565. arguments: M.args.map(to_moz)
  9566. };
  9567. });
  9568. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  9569. return {
  9570. type: "CallExpression",
  9571. callee: to_moz(M.expression),
  9572. optional: M.optional,
  9573. arguments: M.args.map(to_moz)
  9574. };
  9575. });
  9576. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  9577. return to_moz_scope("Program", M);
  9578. });
  9579. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  9580. return {
  9581. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  9582. argument: to_moz(M.expression)
  9583. };
  9584. });
  9585. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  9586. return {
  9587. type: "TaggedTemplateExpression",
  9588. tag: to_moz(M.prefix),
  9589. quasi: to_moz(M.template_string)
  9590. };
  9591. });
  9592. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  9593. var quasis = [];
  9594. var expressions = [];
  9595. for (var i = 0; i < M.segments.length; i++) {
  9596. if (i % 2 !== 0) {
  9597. expressions.push(to_moz(M.segments[i]));
  9598. } else {
  9599. quasis.push({
  9600. type: "TemplateElement",
  9601. value: {
  9602. raw: M.segments[i].raw,
  9603. cooked: M.segments[i].value
  9604. },
  9605. tail: i === M.segments.length - 1
  9606. });
  9607. }
  9608. }
  9609. return {
  9610. type: "TemplateLiteral",
  9611. quasis: quasis,
  9612. expressions: expressions
  9613. };
  9614. });
  9615. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  9616. return {
  9617. type: "FunctionDeclaration",
  9618. id: to_moz(M.name),
  9619. params: M.argnames.map(to_moz),
  9620. generator: M.is_generator,
  9621. async: M.async,
  9622. body: to_moz_scope("BlockStatement", M)
  9623. };
  9624. });
  9625. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  9626. var is_generator = parent.is_generator !== undefined ?
  9627. parent.is_generator : M.is_generator;
  9628. return {
  9629. type: "FunctionExpression",
  9630. id: to_moz(M.name),
  9631. params: M.argnames.map(to_moz),
  9632. generator: is_generator,
  9633. async: M.async,
  9634. body: to_moz_scope("BlockStatement", M)
  9635. };
  9636. });
  9637. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  9638. var body = {
  9639. type: "BlockStatement",
  9640. body: M.body.map(to_moz)
  9641. };
  9642. return {
  9643. type: "ArrowFunctionExpression",
  9644. params: M.argnames.map(to_moz),
  9645. async: M.async,
  9646. body: body
  9647. };
  9648. });
  9649. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  9650. if (M.is_array) {
  9651. return {
  9652. type: "ArrayPattern",
  9653. elements: M.names.map(to_moz)
  9654. };
  9655. }
  9656. return {
  9657. type: "ObjectPattern",
  9658. properties: M.names.map(to_moz)
  9659. };
  9660. });
  9661. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  9662. return {
  9663. type: "ExpressionStatement",
  9664. expression: {
  9665. type: "Literal",
  9666. value: M.value,
  9667. raw: M.print_to_string()
  9668. },
  9669. directive: M.value
  9670. };
  9671. });
  9672. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  9673. return {
  9674. type: "ExpressionStatement",
  9675. expression: to_moz(M.body)
  9676. };
  9677. });
  9678. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  9679. return {
  9680. type: "SwitchCase",
  9681. test: to_moz(M.expression),
  9682. consequent: M.body.map(to_moz)
  9683. };
  9684. });
  9685. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  9686. return {
  9687. type: "TryStatement",
  9688. block: to_moz_block(M),
  9689. handler: to_moz(M.bcatch),
  9690. guardedHandlers: [],
  9691. finalizer: to_moz(M.bfinally)
  9692. };
  9693. });
  9694. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  9695. return {
  9696. type: "CatchClause",
  9697. param: to_moz(M.argname),
  9698. guard: null,
  9699. body: to_moz_block(M)
  9700. };
  9701. });
  9702. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  9703. return {
  9704. type: "VariableDeclaration",
  9705. kind:
  9706. M instanceof AST_Const ? "const" :
  9707. M instanceof AST_Let ? "let" : "var",
  9708. declarations: M.definitions.map(to_moz)
  9709. };
  9710. });
  9711. const assert_clause_to_moz = assert_clause => {
  9712. const assertions = [];
  9713. if (assert_clause) {
  9714. for (const { key, value } of assert_clause.properties) {
  9715. const key_moz = is_basic_identifier_string(key)
  9716. ? { type: "Identifier", name: key }
  9717. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  9718. assertions.push({
  9719. type: "ImportAttribute",
  9720. key: key_moz,
  9721. value: to_moz(value)
  9722. });
  9723. }
  9724. }
  9725. return assertions;
  9726. };
  9727. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  9728. if (M.exported_names) {
  9729. if (M.exported_names[0].name.name === "*") {
  9730. return {
  9731. type: "ExportAllDeclaration",
  9732. source: to_moz(M.module_name),
  9733. assertions: assert_clause_to_moz(M.assert_clause)
  9734. };
  9735. }
  9736. return {
  9737. type: "ExportNamedDeclaration",
  9738. specifiers: M.exported_names.map(function (name_mapping) {
  9739. return {
  9740. type: "ExportSpecifier",
  9741. exported: to_moz(name_mapping.foreign_name),
  9742. local: to_moz(name_mapping.name)
  9743. };
  9744. }),
  9745. declaration: to_moz(M.exported_definition),
  9746. source: to_moz(M.module_name),
  9747. assertions: assert_clause_to_moz(M.assert_clause)
  9748. };
  9749. }
  9750. return {
  9751. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  9752. declaration: to_moz(M.exported_value || M.exported_definition)
  9753. };
  9754. });
  9755. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  9756. var specifiers = [];
  9757. if (M.imported_name) {
  9758. specifiers.push({
  9759. type: "ImportDefaultSpecifier",
  9760. local: to_moz(M.imported_name)
  9761. });
  9762. }
  9763. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  9764. specifiers.push({
  9765. type: "ImportNamespaceSpecifier",
  9766. local: to_moz(M.imported_names[0].name)
  9767. });
  9768. } else if (M.imported_names) {
  9769. M.imported_names.forEach(function(name_mapping) {
  9770. specifiers.push({
  9771. type: "ImportSpecifier",
  9772. local: to_moz(name_mapping.name),
  9773. imported: to_moz(name_mapping.foreign_name)
  9774. });
  9775. });
  9776. }
  9777. return {
  9778. type: "ImportDeclaration",
  9779. specifiers: specifiers,
  9780. source: to_moz(M.module_name),
  9781. assertions: assert_clause_to_moz(M.assert_clause)
  9782. };
  9783. });
  9784. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  9785. return {
  9786. type: "MetaProperty",
  9787. meta: {
  9788. type: "Identifier",
  9789. name: "import"
  9790. },
  9791. property: {
  9792. type: "Identifier",
  9793. name: "meta"
  9794. }
  9795. };
  9796. });
  9797. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  9798. return {
  9799. type: "SequenceExpression",
  9800. expressions: M.expressions.map(to_moz)
  9801. };
  9802. });
  9803. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  9804. return {
  9805. type: "MemberExpression",
  9806. object: to_moz(M.expression),
  9807. computed: false,
  9808. property: {
  9809. type: "PrivateIdentifier",
  9810. name: M.property
  9811. },
  9812. optional: M.optional
  9813. };
  9814. });
  9815. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  9816. var isComputed = M instanceof AST_Sub;
  9817. return {
  9818. type: "MemberExpression",
  9819. object: to_moz(M.expression),
  9820. computed: isComputed,
  9821. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  9822. optional: M.optional
  9823. };
  9824. });
  9825. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  9826. return {
  9827. type: "ChainExpression",
  9828. expression: to_moz(M.expression)
  9829. };
  9830. });
  9831. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  9832. return {
  9833. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  9834. operator: M.operator,
  9835. prefix: M instanceof AST_UnaryPrefix,
  9836. argument: to_moz(M.expression)
  9837. };
  9838. });
  9839. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  9840. if (M.operator == "=" && to_moz_in_destructuring()) {
  9841. return {
  9842. type: "AssignmentPattern",
  9843. left: to_moz(M.left),
  9844. right: to_moz(M.right)
  9845. };
  9846. }
  9847. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  9848. ? "LogicalExpression"
  9849. : "BinaryExpression";
  9850. return {
  9851. type,
  9852. left: to_moz(M.left),
  9853. operator: M.operator,
  9854. right: to_moz(M.right)
  9855. };
  9856. });
  9857. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  9858. return {
  9859. type: "ArrayExpression",
  9860. elements: M.elements.map(to_moz)
  9861. };
  9862. });
  9863. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  9864. return {
  9865. type: "ObjectExpression",
  9866. properties: M.properties.map(to_moz)
  9867. };
  9868. });
  9869. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  9870. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  9871. type: "Identifier",
  9872. value: M.key
  9873. };
  9874. if (typeof M.key === "number") {
  9875. key = {
  9876. type: "Literal",
  9877. value: Number(M.key)
  9878. };
  9879. }
  9880. if (typeof M.key === "string") {
  9881. key = {
  9882. type: "Identifier",
  9883. name: M.key
  9884. };
  9885. }
  9886. var kind;
  9887. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  9888. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  9889. if (M instanceof AST_ObjectKeyVal) {
  9890. kind = "init";
  9891. computed = !string_or_num;
  9892. } else
  9893. if (M instanceof AST_ObjectGetter) {
  9894. kind = "get";
  9895. } else
  9896. if (M instanceof AST_ObjectSetter) {
  9897. kind = "set";
  9898. }
  9899. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  9900. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  9901. return {
  9902. type: "MethodDefinition",
  9903. computed: false,
  9904. kind: kind,
  9905. static: M.static,
  9906. key: {
  9907. type: "PrivateIdentifier",
  9908. name: M.key.name
  9909. },
  9910. value: to_moz(M.value)
  9911. };
  9912. }
  9913. if (M instanceof AST_ClassPrivateProperty) {
  9914. return {
  9915. type: "PropertyDefinition",
  9916. key: {
  9917. type: "PrivateIdentifier",
  9918. name: M.key.name
  9919. },
  9920. value: to_moz(M.value),
  9921. computed: false,
  9922. static: M.static
  9923. };
  9924. }
  9925. if (M instanceof AST_ClassProperty) {
  9926. return {
  9927. type: "PropertyDefinition",
  9928. key,
  9929. value: to_moz(M.value),
  9930. computed,
  9931. static: M.static
  9932. };
  9933. }
  9934. if (parent instanceof AST_Class) {
  9935. return {
  9936. type: "MethodDefinition",
  9937. computed: computed,
  9938. kind: kind,
  9939. static: M.static,
  9940. key: to_moz(M.key),
  9941. value: to_moz(M.value)
  9942. };
  9943. }
  9944. return {
  9945. type: "Property",
  9946. computed: computed,
  9947. kind: kind,
  9948. key: key,
  9949. value: to_moz(M.value)
  9950. };
  9951. });
  9952. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  9953. if (parent instanceof AST_Object) {
  9954. return {
  9955. type: "Property",
  9956. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  9957. kind: "init",
  9958. method: true,
  9959. shorthand: false,
  9960. key: to_moz(M.key),
  9961. value: to_moz(M.value)
  9962. };
  9963. }
  9964. const key = M instanceof AST_PrivateMethod
  9965. ? {
  9966. type: "PrivateIdentifier",
  9967. name: M.key.name
  9968. }
  9969. : to_moz(M.key);
  9970. return {
  9971. type: "MethodDefinition",
  9972. kind: M.key === "constructor" ? "constructor" : "method",
  9973. key,
  9974. value: to_moz(M.value),
  9975. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  9976. static: M.static,
  9977. };
  9978. });
  9979. def_to_moz(AST_Class, function To_Moz_Class(M) {
  9980. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  9981. return {
  9982. type: type,
  9983. superClass: to_moz(M.extends),
  9984. id: M.name ? to_moz(M.name) : null,
  9985. body: {
  9986. type: "ClassBody",
  9987. body: M.properties.map(to_moz)
  9988. }
  9989. };
  9990. });
  9991. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  9992. return {
  9993. type: "MetaProperty",
  9994. meta: {
  9995. type: "Identifier",
  9996. name: "new"
  9997. },
  9998. property: {
  9999. type: "Identifier",
  10000. name: "target"
  10001. }
  10002. };
  10003. });
  10004. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  10005. if (M instanceof AST_SymbolMethod && parent.quote) {
  10006. return {
  10007. type: "Literal",
  10008. value: M.name
  10009. };
  10010. }
  10011. var def = M.definition();
  10012. return {
  10013. type: "Identifier",
  10014. name: def ? def.mangled_name || def.name : M.name
  10015. };
  10016. });
  10017. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  10018. const pattern = M.value.source;
  10019. const flags = M.value.flags;
  10020. return {
  10021. type: "Literal",
  10022. value: null,
  10023. raw: M.print_to_string(),
  10024. regex: { pattern, flags }
  10025. };
  10026. });
  10027. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  10028. var value = M.value;
  10029. return {
  10030. type: "Literal",
  10031. value: value,
  10032. raw: M.raw || M.print_to_string()
  10033. };
  10034. });
  10035. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  10036. return {
  10037. type: "Identifier",
  10038. name: String(M.value)
  10039. };
  10040. });
  10041. def_to_moz(AST_BigInt, M => ({
  10042. type: "BigIntLiteral",
  10043. value: M.value
  10044. }));
  10045. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  10046. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  10047. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  10048. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  10049. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  10050. /* -----[ tools ]----- */
  10051. function my_start_token(moznode) {
  10052. var loc = moznode.loc, start = loc && loc.start;
  10053. var range = moznode.range;
  10054. return new AST_Token(
  10055. "",
  10056. "",
  10057. start && start.line || 0,
  10058. start && start.column || 0,
  10059. range ? range [0] : moznode.start,
  10060. false,
  10061. [],
  10062. [],
  10063. loc && loc.source,
  10064. );
  10065. }
  10066. function my_end_token(moznode) {
  10067. var loc = moznode.loc, end = loc && loc.end;
  10068. var range = moznode.range;
  10069. return new AST_Token(
  10070. "",
  10071. "",
  10072. end && end.line || 0,
  10073. end && end.column || 0,
  10074. range ? range [0] : moznode.end,
  10075. false,
  10076. [],
  10077. [],
  10078. loc && loc.source,
  10079. );
  10080. }
  10081. var FROM_MOZ_STACK = null;
  10082. function from_moz(node) {
  10083. FROM_MOZ_STACK.push(node);
  10084. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  10085. FROM_MOZ_STACK.pop();
  10086. return ret;
  10087. }
  10088. AST_Node.from_mozilla_ast = function(node) {
  10089. var save_stack = FROM_MOZ_STACK;
  10090. FROM_MOZ_STACK = [];
  10091. var ast = from_moz(node);
  10092. FROM_MOZ_STACK = save_stack;
  10093. return ast;
  10094. };
  10095. function set_moz_loc(mynode, moznode) {
  10096. var start = mynode.start;
  10097. var end = mynode.end;
  10098. if (!(start && end)) {
  10099. return moznode;
  10100. }
  10101. if (start.pos != null && end.endpos != null) {
  10102. moznode.range = [start.pos, end.endpos];
  10103. }
  10104. if (start.line) {
  10105. moznode.loc = {
  10106. start: {line: start.line, column: start.col},
  10107. end: end.endline ? {line: end.endline, column: end.endcol} : null
  10108. };
  10109. if (start.file) {
  10110. moznode.loc.source = start.file;
  10111. }
  10112. }
  10113. return moznode;
  10114. }
  10115. function def_to_moz(mytype, handler) {
  10116. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  10117. return set_moz_loc(this, handler(this, parent));
  10118. });
  10119. }
  10120. var TO_MOZ_STACK = null;
  10121. function to_moz(node) {
  10122. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  10123. TO_MOZ_STACK.push(node);
  10124. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  10125. TO_MOZ_STACK.pop();
  10126. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  10127. return ast;
  10128. }
  10129. function to_moz_in_destructuring() {
  10130. var i = TO_MOZ_STACK.length;
  10131. while (i--) {
  10132. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  10133. return true;
  10134. }
  10135. }
  10136. return false;
  10137. }
  10138. function to_moz_block(node) {
  10139. return {
  10140. type: "BlockStatement",
  10141. body: node.body.map(to_moz)
  10142. };
  10143. }
  10144. function to_moz_scope(type, node) {
  10145. var body = node.body.map(to_moz);
  10146. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  10147. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  10148. }
  10149. return {
  10150. type: type,
  10151. body: body
  10152. };
  10153. }
  10154. })();
  10155. // return true if the node at the top of the stack (that means the
  10156. // innermost node in the current output) is lexically the first in
  10157. // a statement.
  10158. function first_in_statement(stack) {
  10159. let node = stack.parent(-1);
  10160. for (let i = 0, p; p = stack.parent(i); i++) {
  10161. if (p instanceof AST_Statement && p.body === node)
  10162. return true;
  10163. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  10164. (p.TYPE === "Call" && p.expression === node) ||
  10165. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  10166. (p instanceof AST_Dot && p.expression === node) ||
  10167. (p instanceof AST_Sub && p.expression === node) ||
  10168. (p instanceof AST_Conditional && p.condition === node) ||
  10169. (p instanceof AST_Binary && p.left === node) ||
  10170. (p instanceof AST_UnaryPostfix && p.expression === node)
  10171. ) {
  10172. node = p;
  10173. } else {
  10174. return false;
  10175. }
  10176. }
  10177. }
  10178. // Returns whether the leftmost item in the expression is an object
  10179. function left_is_object(node) {
  10180. if (node instanceof AST_Object) return true;
  10181. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  10182. if (node.TYPE === "Call") return left_is_object(node.expression);
  10183. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  10184. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  10185. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  10186. if (node instanceof AST_Binary) return left_is_object(node.left);
  10187. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  10188. return false;
  10189. }
  10190. /***********************************************************************
  10191. A JavaScript tokenizer / parser / beautifier / compressor.
  10192. https://github.com/mishoo/UglifyJS2
  10193. -------------------------------- (C) ---------------------------------
  10194. Author: Mihai Bazon
  10195. <mihai.bazon@gmail.com>
  10196. http://mihai.bazon.net/blog
  10197. Distributed under the BSD license:
  10198. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10199. Redistribution and use in source and binary forms, with or without
  10200. modification, are permitted provided that the following conditions
  10201. are met:
  10202. * Redistributions of source code must retain the above
  10203. copyright notice, this list of conditions and the following
  10204. disclaimer.
  10205. * Redistributions in binary form must reproduce the above
  10206. copyright notice, this list of conditions and the following
  10207. disclaimer in the documentation and/or other materials
  10208. provided with the distribution.
  10209. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10210. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10211. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10212. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10213. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10214. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10215. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10216. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10217. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10218. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10219. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10220. SUCH DAMAGE.
  10221. ***********************************************************************/
  10222. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  10223. const CODE_LINE_BREAK = 10;
  10224. const CODE_SPACE = 32;
  10225. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  10226. function is_some_comments(comment) {
  10227. // multiline comment
  10228. return (
  10229. (comment.type === "comment2" || comment.type === "comment1")
  10230. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  10231. );
  10232. }
  10233. class Rope {
  10234. constructor() {
  10235. this.committed = "";
  10236. this.current = "";
  10237. }
  10238. append(str) {
  10239. this.current += str;
  10240. }
  10241. insertAt(char, index) {
  10242. const { committed, current } = this;
  10243. if (index < committed.length) {
  10244. this.committed = committed.slice(0, index) + char + committed.slice(index);
  10245. } else if (index === committed.length) {
  10246. this.committed += char;
  10247. } else {
  10248. index -= committed.length;
  10249. this.committed += current.slice(0, index) + char;
  10250. this.current = current.slice(index);
  10251. }
  10252. }
  10253. charAt(index) {
  10254. const { committed } = this;
  10255. if (index < committed.length) return committed[index];
  10256. return this.current[index - committed.length];
  10257. }
  10258. curLength() {
  10259. return this.current.length;
  10260. }
  10261. length() {
  10262. return this.committed.length + this.current.length;
  10263. }
  10264. toString() {
  10265. return this.committed + this.current;
  10266. }
  10267. }
  10268. function OutputStream(options) {
  10269. var readonly = !options;
  10270. options = defaults(options, {
  10271. ascii_only : false,
  10272. beautify : false,
  10273. braces : false,
  10274. comments : "some",
  10275. ecma : 5,
  10276. ie8 : false,
  10277. indent_level : 4,
  10278. indent_start : 0,
  10279. inline_script : true,
  10280. keep_numbers : false,
  10281. keep_quoted_props : false,
  10282. max_line_len : false,
  10283. preamble : null,
  10284. preserve_annotations : false,
  10285. quote_keys : false,
  10286. quote_style : 0,
  10287. safari10 : false,
  10288. semicolons : true,
  10289. shebang : true,
  10290. shorthand : undefined,
  10291. source_map : null,
  10292. webkit : false,
  10293. width : 80,
  10294. wrap_iife : false,
  10295. wrap_func_args : true,
  10296. }, true);
  10297. if (options.shorthand === undefined)
  10298. options.shorthand = options.ecma > 5;
  10299. // Convert comment option to RegExp if neccessary and set up comments filter
  10300. var comment_filter = return_false; // Default case, throw all comments away
  10301. if (options.comments) {
  10302. let comments = options.comments;
  10303. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  10304. var regex_pos = options.comments.lastIndexOf("/");
  10305. comments = new RegExp(
  10306. options.comments.substr(1, regex_pos - 1),
  10307. options.comments.substr(regex_pos + 1)
  10308. );
  10309. }
  10310. if (comments instanceof RegExp) {
  10311. comment_filter = function(comment) {
  10312. return comment.type != "comment5" && comments.test(comment.value);
  10313. };
  10314. } else if (typeof comments === "function") {
  10315. comment_filter = function(comment) {
  10316. return comment.type != "comment5" && comments(this, comment);
  10317. };
  10318. } else if (comments === "some") {
  10319. comment_filter = is_some_comments;
  10320. } else { // NOTE includes "all" option
  10321. comment_filter = return_true;
  10322. }
  10323. }
  10324. var indentation = 0;
  10325. var current_col = 0;
  10326. var current_line = 1;
  10327. var current_pos = 0;
  10328. var OUTPUT = new Rope();
  10329. let printed_comments = new Set();
  10330. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  10331. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  10332. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  10333. var code = get_full_char_code(ch, 0).toString(16);
  10334. return "\\u{" + code + "}";
  10335. });
  10336. }
  10337. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  10338. var code = ch.charCodeAt(0).toString(16);
  10339. if (code.length <= 2 && !identifier) {
  10340. while (code.length < 2) code = "0" + code;
  10341. return "\\x" + code;
  10342. } else {
  10343. while (code.length < 4) code = "0" + code;
  10344. return "\\u" + code;
  10345. }
  10346. });
  10347. } : function(str) {
  10348. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  10349. if (lone) {
  10350. return "\\u" + lone.charCodeAt(0).toString(16);
  10351. }
  10352. return match;
  10353. });
  10354. };
  10355. function make_string(str, quote) {
  10356. var dq = 0, sq = 0;
  10357. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  10358. function(s, i) {
  10359. switch (s) {
  10360. case '"': ++dq; return '"';
  10361. case "'": ++sq; return "'";
  10362. case "\\": return "\\\\";
  10363. case "\n": return "\\n";
  10364. case "\r": return "\\r";
  10365. case "\t": return "\\t";
  10366. case "\b": return "\\b";
  10367. case "\f": return "\\f";
  10368. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  10369. case "\u2028": return "\\u2028";
  10370. case "\u2029": return "\\u2029";
  10371. case "\ufeff": return "\\ufeff";
  10372. case "\0":
  10373. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  10374. }
  10375. return s;
  10376. });
  10377. function quote_single() {
  10378. return "'" + str.replace(/\x27/g, "\\'") + "'";
  10379. }
  10380. function quote_double() {
  10381. return '"' + str.replace(/\x22/g, '\\"') + '"';
  10382. }
  10383. function quote_template() {
  10384. return "`" + str.replace(/`/g, "\\`") + "`";
  10385. }
  10386. str = to_utf8(str);
  10387. if (quote === "`") return quote_template();
  10388. switch (options.quote_style) {
  10389. case 1:
  10390. return quote_single();
  10391. case 2:
  10392. return quote_double();
  10393. case 3:
  10394. return quote == "'" ? quote_single() : quote_double();
  10395. default:
  10396. return dq > sq ? quote_single() : quote_double();
  10397. }
  10398. }
  10399. function encode_string(str, quote) {
  10400. var ret = make_string(str, quote);
  10401. if (options.inline_script) {
  10402. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  10403. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  10404. ret = ret.replace(/--\x3e/g, "--\\x3e");
  10405. }
  10406. return ret;
  10407. }
  10408. function make_name(name) {
  10409. name = name.toString();
  10410. name = to_utf8(name, true);
  10411. return name;
  10412. }
  10413. function make_indent(back) {
  10414. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  10415. }
  10416. /* -----[ beautification/minification ]----- */
  10417. var has_parens = false;
  10418. var might_need_space = false;
  10419. var might_need_semicolon = false;
  10420. var might_add_newline = 0;
  10421. var need_newline_indented = false;
  10422. var need_space = false;
  10423. var newline_insert = -1;
  10424. var last = "";
  10425. var mapping_token, mapping_name, mappings = options.source_map && [];
  10426. var do_add_mapping = mappings ? function() {
  10427. mappings.forEach(function(mapping) {
  10428. try {
  10429. let { name, token } = mapping;
  10430. if (token.type == "name" || token.type === "privatename") {
  10431. name = token.value;
  10432. } else if (name instanceof AST_Symbol) {
  10433. name = token.type === "string" ? token.value : name.name;
  10434. }
  10435. options.source_map.add(
  10436. mapping.token.file,
  10437. mapping.line, mapping.col,
  10438. mapping.token.line, mapping.token.col,
  10439. is_basic_identifier_string(name) ? name : undefined
  10440. );
  10441. } catch(ex) {
  10442. // Ignore bad mapping
  10443. }
  10444. });
  10445. mappings = [];
  10446. } : noop;
  10447. var ensure_line_len = options.max_line_len ? function() {
  10448. if (current_col > options.max_line_len) {
  10449. if (might_add_newline) {
  10450. OUTPUT.insertAt("\n", might_add_newline);
  10451. const curLength = OUTPUT.curLength();
  10452. if (mappings) {
  10453. var delta = curLength - current_col;
  10454. mappings.forEach(function(mapping) {
  10455. mapping.line++;
  10456. mapping.col += delta;
  10457. });
  10458. }
  10459. current_line++;
  10460. current_pos++;
  10461. current_col = curLength;
  10462. }
  10463. }
  10464. if (might_add_newline) {
  10465. might_add_newline = 0;
  10466. do_add_mapping();
  10467. }
  10468. } : noop;
  10469. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  10470. function print(str) {
  10471. str = String(str);
  10472. var ch = get_full_char(str, 0);
  10473. if (need_newline_indented && ch) {
  10474. need_newline_indented = false;
  10475. if (ch !== "\n") {
  10476. print("\n");
  10477. indent();
  10478. }
  10479. }
  10480. if (need_space && ch) {
  10481. need_space = false;
  10482. if (!/[\s;})]/.test(ch)) {
  10483. space();
  10484. }
  10485. }
  10486. newline_insert = -1;
  10487. var prev = last.charAt(last.length - 1);
  10488. if (might_need_semicolon) {
  10489. might_need_semicolon = false;
  10490. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  10491. if (options.semicolons || requireSemicolonChars.has(ch)) {
  10492. OUTPUT.append(";");
  10493. current_col++;
  10494. current_pos++;
  10495. } else {
  10496. ensure_line_len();
  10497. if (current_col > 0) {
  10498. OUTPUT.append("\n");
  10499. current_pos++;
  10500. current_line++;
  10501. current_col = 0;
  10502. }
  10503. if (/^\s+$/.test(str)) {
  10504. // reset the semicolon flag, since we didn't print one
  10505. // now and might still have to later
  10506. might_need_semicolon = true;
  10507. }
  10508. }
  10509. if (!options.beautify)
  10510. might_need_space = false;
  10511. }
  10512. }
  10513. if (might_need_space) {
  10514. if ((is_identifier_char(prev)
  10515. && (is_identifier_char(ch) || ch == "\\"))
  10516. || (ch == "/" && ch == prev)
  10517. || ((ch == "+" || ch == "-") && ch == last)
  10518. ) {
  10519. OUTPUT.append(" ");
  10520. current_col++;
  10521. current_pos++;
  10522. }
  10523. might_need_space = false;
  10524. }
  10525. if (mapping_token) {
  10526. mappings.push({
  10527. token: mapping_token,
  10528. name: mapping_name,
  10529. line: current_line,
  10530. col: current_col
  10531. });
  10532. mapping_token = false;
  10533. if (!might_add_newline) do_add_mapping();
  10534. }
  10535. OUTPUT.append(str);
  10536. has_parens = str[str.length - 1] == "(";
  10537. current_pos += str.length;
  10538. var a = str.split(/\r?\n/), n = a.length - 1;
  10539. current_line += n;
  10540. current_col += a[0].length;
  10541. if (n > 0) {
  10542. ensure_line_len();
  10543. current_col = a[n].length;
  10544. }
  10545. last = str;
  10546. }
  10547. var star = function() {
  10548. print("*");
  10549. };
  10550. var space = options.beautify ? function() {
  10551. print(" ");
  10552. } : function() {
  10553. might_need_space = true;
  10554. };
  10555. var indent = options.beautify ? function(half) {
  10556. if (options.beautify) {
  10557. print(make_indent(half ? 0.5 : 0));
  10558. }
  10559. } : noop;
  10560. var with_indent = options.beautify ? function(col, cont) {
  10561. if (col === true) col = next_indent();
  10562. var save_indentation = indentation;
  10563. indentation = col;
  10564. var ret = cont();
  10565. indentation = save_indentation;
  10566. return ret;
  10567. } : function(col, cont) { return cont(); };
  10568. var newline = options.beautify ? function() {
  10569. if (newline_insert < 0) return print("\n");
  10570. if (OUTPUT.charAt(newline_insert) != "\n") {
  10571. OUTPUT.insertAt("\n", newline_insert);
  10572. current_pos++;
  10573. current_line++;
  10574. }
  10575. newline_insert++;
  10576. } : options.max_line_len ? function() {
  10577. ensure_line_len();
  10578. might_add_newline = OUTPUT.length();
  10579. } : noop;
  10580. var semicolon = options.beautify ? function() {
  10581. print(";");
  10582. } : function() {
  10583. might_need_semicolon = true;
  10584. };
  10585. function force_semicolon() {
  10586. might_need_semicolon = false;
  10587. print(";");
  10588. }
  10589. function next_indent() {
  10590. return indentation + options.indent_level;
  10591. }
  10592. function with_block(cont) {
  10593. var ret;
  10594. print("{");
  10595. newline();
  10596. with_indent(next_indent(), function() {
  10597. ret = cont();
  10598. });
  10599. indent();
  10600. print("}");
  10601. return ret;
  10602. }
  10603. function with_parens(cont) {
  10604. print("(");
  10605. //XXX: still nice to have that for argument lists
  10606. //var ret = with_indent(current_col, cont);
  10607. var ret = cont();
  10608. print(")");
  10609. return ret;
  10610. }
  10611. function with_square(cont) {
  10612. print("[");
  10613. //var ret = with_indent(current_col, cont);
  10614. var ret = cont();
  10615. print("]");
  10616. return ret;
  10617. }
  10618. function comma() {
  10619. print(",");
  10620. space();
  10621. }
  10622. function colon() {
  10623. print(":");
  10624. space();
  10625. }
  10626. var add_mapping = mappings ? function(token, name) {
  10627. mapping_token = token;
  10628. mapping_name = name;
  10629. } : noop;
  10630. function get() {
  10631. if (might_add_newline) {
  10632. ensure_line_len();
  10633. }
  10634. return OUTPUT.toString();
  10635. }
  10636. function has_nlb() {
  10637. const output = OUTPUT.toString();
  10638. let n = output.length - 1;
  10639. while (n >= 0) {
  10640. const code = output.charCodeAt(n);
  10641. if (code === CODE_LINE_BREAK) {
  10642. return true;
  10643. }
  10644. if (code !== CODE_SPACE) {
  10645. return false;
  10646. }
  10647. n--;
  10648. }
  10649. return true;
  10650. }
  10651. function filter_comment(comment) {
  10652. if (!options.preserve_annotations) {
  10653. comment = comment.replace(r_annotation, " ");
  10654. }
  10655. if (/^\s*$/.test(comment)) {
  10656. return "";
  10657. }
  10658. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  10659. }
  10660. function prepend_comments(node) {
  10661. var self = this;
  10662. var start = node.start;
  10663. if (!start) return;
  10664. var printed_comments = self.printed_comments;
  10665. // There cannot be a newline between return and its value.
  10666. const return_with_value = node instanceof AST_Exit && node.value;
  10667. if (
  10668. start.comments_before
  10669. && printed_comments.has(start.comments_before)
  10670. ) {
  10671. if (return_with_value) {
  10672. start.comments_before = [];
  10673. } else {
  10674. return;
  10675. }
  10676. }
  10677. var comments = start.comments_before;
  10678. if (!comments) {
  10679. comments = start.comments_before = [];
  10680. }
  10681. printed_comments.add(comments);
  10682. if (return_with_value) {
  10683. var tw = new TreeWalker(function(node) {
  10684. var parent = tw.parent();
  10685. if (parent instanceof AST_Exit
  10686. || parent instanceof AST_Binary && parent.left === node
  10687. || parent.TYPE == "Call" && parent.expression === node
  10688. || parent instanceof AST_Conditional && parent.condition === node
  10689. || parent instanceof AST_Dot && parent.expression === node
  10690. || parent instanceof AST_Sequence && parent.expressions[0] === node
  10691. || parent instanceof AST_Sub && parent.expression === node
  10692. || parent instanceof AST_UnaryPostfix) {
  10693. if (!node.start) return;
  10694. var text = node.start.comments_before;
  10695. if (text && !printed_comments.has(text)) {
  10696. printed_comments.add(text);
  10697. comments = comments.concat(text);
  10698. }
  10699. } else {
  10700. return true;
  10701. }
  10702. });
  10703. tw.push(node);
  10704. node.value.walk(tw);
  10705. }
  10706. if (current_pos == 0) {
  10707. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  10708. && !printed_comments.has(comments[0])) {
  10709. print("#!" + comments.shift().value + "\n");
  10710. indent();
  10711. }
  10712. var preamble = options.preamble;
  10713. if (preamble) {
  10714. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  10715. }
  10716. }
  10717. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  10718. if (comments.length == 0) return;
  10719. var last_nlb = has_nlb();
  10720. comments.forEach(function(c, i) {
  10721. printed_comments.add(c);
  10722. if (!last_nlb) {
  10723. if (c.nlb) {
  10724. print("\n");
  10725. indent();
  10726. last_nlb = true;
  10727. } else if (i > 0) {
  10728. space();
  10729. }
  10730. }
  10731. if (/comment[134]/.test(c.type)) {
  10732. var value = filter_comment(c.value);
  10733. if (value) {
  10734. print("//" + value + "\n");
  10735. indent();
  10736. }
  10737. last_nlb = true;
  10738. } else if (c.type == "comment2") {
  10739. var value = filter_comment(c.value);
  10740. if (value) {
  10741. print("/*" + value + "*/");
  10742. }
  10743. last_nlb = false;
  10744. }
  10745. });
  10746. if (!last_nlb) {
  10747. if (start.nlb) {
  10748. print("\n");
  10749. indent();
  10750. } else {
  10751. space();
  10752. }
  10753. }
  10754. }
  10755. function append_comments(node, tail) {
  10756. var self = this;
  10757. var token = node.end;
  10758. if (!token) return;
  10759. var printed_comments = self.printed_comments;
  10760. var comments = token[tail ? "comments_before" : "comments_after"];
  10761. if (!comments || printed_comments.has(comments)) return;
  10762. if (!(node instanceof AST_Statement || comments.every((c) =>
  10763. !/comment[134]/.test(c.type)
  10764. ))) return;
  10765. printed_comments.add(comments);
  10766. var insert = OUTPUT.length();
  10767. comments.filter(comment_filter, node).forEach(function(c, i) {
  10768. if (printed_comments.has(c)) return;
  10769. printed_comments.add(c);
  10770. need_space = false;
  10771. if (need_newline_indented) {
  10772. print("\n");
  10773. indent();
  10774. need_newline_indented = false;
  10775. } else if (c.nlb && (i > 0 || !has_nlb())) {
  10776. print("\n");
  10777. indent();
  10778. } else if (i > 0 || !tail) {
  10779. space();
  10780. }
  10781. if (/comment[134]/.test(c.type)) {
  10782. const value = filter_comment(c.value);
  10783. if (value) {
  10784. print("//" + value);
  10785. }
  10786. need_newline_indented = true;
  10787. } else if (c.type == "comment2") {
  10788. const value = filter_comment(c.value);
  10789. if (value) {
  10790. print("/*" + value + "*/");
  10791. }
  10792. need_space = true;
  10793. }
  10794. });
  10795. if (OUTPUT.length() > insert) newline_insert = insert;
  10796. }
  10797. var stack = [];
  10798. return {
  10799. get : get,
  10800. toString : get,
  10801. indent : indent,
  10802. in_directive : false,
  10803. use_asm : null,
  10804. active_scope : null,
  10805. indentation : function() { return indentation; },
  10806. current_width : function() { return current_col - indentation; },
  10807. should_break : function() { return options.width && this.current_width() >= options.width; },
  10808. has_parens : function() { return has_parens; },
  10809. newline : newline,
  10810. print : print,
  10811. star : star,
  10812. space : space,
  10813. comma : comma,
  10814. colon : colon,
  10815. last : function() { return last; },
  10816. semicolon : semicolon,
  10817. force_semicolon : force_semicolon,
  10818. to_utf8 : to_utf8,
  10819. print_name : function(name) { print(make_name(name)); },
  10820. print_string : function(str, quote, escape_directive) {
  10821. var encoded = encode_string(str, quote);
  10822. if (escape_directive === true && !encoded.includes("\\")) {
  10823. // Insert semicolons to break directive prologue
  10824. if (!EXPECT_DIRECTIVE.test(OUTPUT.toString())) {
  10825. force_semicolon();
  10826. }
  10827. force_semicolon();
  10828. }
  10829. print(encoded);
  10830. },
  10831. print_template_string_chars: function(str) {
  10832. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  10833. return print(encoded.substr(1, encoded.length - 2));
  10834. },
  10835. encode_string : encode_string,
  10836. next_indent : next_indent,
  10837. with_indent : with_indent,
  10838. with_block : with_block,
  10839. with_parens : with_parens,
  10840. with_square : with_square,
  10841. add_mapping : add_mapping,
  10842. option : function(opt) { return options[opt]; },
  10843. printed_comments: printed_comments,
  10844. prepend_comments: readonly ? noop : prepend_comments,
  10845. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  10846. line : function() { return current_line; },
  10847. col : function() { return current_col; },
  10848. pos : function() { return current_pos; },
  10849. push_node : function(node) { stack.push(node); },
  10850. pop_node : function() { return stack.pop(); },
  10851. parent : function(n) {
  10852. return stack[stack.length - 2 - (n || 0)];
  10853. }
  10854. };
  10855. }
  10856. /* -----[ code generators ]----- */
  10857. (function() {
  10858. /* -----[ utils ]----- */
  10859. function DEFPRINT(nodetype, generator) {
  10860. nodetype.DEFMETHOD("_codegen", generator);
  10861. }
  10862. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  10863. var self = this, generator = self._codegen;
  10864. if (self instanceof AST_Scope) {
  10865. output.active_scope = self;
  10866. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  10867. output.use_asm = output.active_scope;
  10868. }
  10869. function doit() {
  10870. output.prepend_comments(self);
  10871. self.add_source_map(output);
  10872. generator(self, output);
  10873. output.append_comments(self);
  10874. }
  10875. output.push_node(self);
  10876. if (force_parens || self.needs_parens(output)) {
  10877. output.with_parens(doit);
  10878. } else {
  10879. doit();
  10880. }
  10881. output.pop_node();
  10882. if (self === output.use_asm) {
  10883. output.use_asm = null;
  10884. }
  10885. });
  10886. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  10887. AST_Node.DEFMETHOD("print_to_string", function(options) {
  10888. var output = OutputStream(options);
  10889. this.print(output);
  10890. return output.get();
  10891. });
  10892. /* -----[ PARENTHESES ]----- */
  10893. function PARENS(nodetype, func) {
  10894. if (Array.isArray(nodetype)) {
  10895. nodetype.forEach(function(nodetype) {
  10896. PARENS(nodetype, func);
  10897. });
  10898. } else {
  10899. nodetype.DEFMETHOD("needs_parens", func);
  10900. }
  10901. }
  10902. PARENS(AST_Node, return_false);
  10903. // a function expression needs parens around it when it's provably
  10904. // the first token to appear in a statement.
  10905. PARENS(AST_Function, function(output) {
  10906. if (!output.has_parens() && first_in_statement(output)) {
  10907. return true;
  10908. }
  10909. if (output.option("webkit")) {
  10910. var p = output.parent();
  10911. if (p instanceof AST_PropAccess && p.expression === this) {
  10912. return true;
  10913. }
  10914. }
  10915. if (output.option("wrap_iife")) {
  10916. var p = output.parent();
  10917. if (p instanceof AST_Call && p.expression === this) {
  10918. return true;
  10919. }
  10920. }
  10921. if (output.option("wrap_func_args")) {
  10922. var p = output.parent();
  10923. if (p instanceof AST_Call && p.args.includes(this)) {
  10924. return true;
  10925. }
  10926. }
  10927. return false;
  10928. });
  10929. PARENS(AST_Arrow, function(output) {
  10930. var p = output.parent();
  10931. if (
  10932. output.option("wrap_func_args")
  10933. && p instanceof AST_Call
  10934. && p.args.includes(this)
  10935. ) {
  10936. return true;
  10937. }
  10938. return p instanceof AST_PropAccess && p.expression === this;
  10939. });
  10940. // same goes for an object literal (as in AST_Function), because
  10941. // otherwise {...} would be interpreted as a block of code.
  10942. PARENS(AST_Object, function(output) {
  10943. return !output.has_parens() && first_in_statement(output);
  10944. });
  10945. PARENS(AST_ClassExpression, first_in_statement);
  10946. PARENS(AST_Unary, function(output) {
  10947. var p = output.parent();
  10948. return p instanceof AST_PropAccess && p.expression === this
  10949. || p instanceof AST_Call && p.expression === this
  10950. || p instanceof AST_Binary
  10951. && p.operator === "**"
  10952. && this instanceof AST_UnaryPrefix
  10953. && p.left === this
  10954. && this.operator !== "++"
  10955. && this.operator !== "--";
  10956. });
  10957. PARENS(AST_Await, function(output) {
  10958. var p = output.parent();
  10959. return p instanceof AST_PropAccess && p.expression === this
  10960. || p instanceof AST_Call && p.expression === this
  10961. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  10962. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  10963. });
  10964. PARENS(AST_Sequence, function(output) {
  10965. var p = output.parent();
  10966. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  10967. || p instanceof AST_Unary // !(foo, bar, baz)
  10968. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  10969. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  10970. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  10971. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  10972. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  10973. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  10974. * ==> 20 (side effect, set a := 10 and b := 20) */
  10975. || p instanceof AST_Arrow // x => (x, x)
  10976. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  10977. || p instanceof AST_Expansion // [...(a, b)]
  10978. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  10979. || p instanceof AST_Yield // yield (foo, bar)
  10980. || p instanceof AST_Export // export default (foo, bar)
  10981. ;
  10982. });
  10983. PARENS(AST_Binary, function(output) {
  10984. var p = output.parent();
  10985. // (foo && bar)()
  10986. if (p instanceof AST_Call && p.expression === this)
  10987. return true;
  10988. // typeof (foo && bar)
  10989. if (p instanceof AST_Unary)
  10990. return true;
  10991. // (foo && bar)["prop"], (foo && bar).prop
  10992. if (p instanceof AST_PropAccess && p.expression === this)
  10993. return true;
  10994. // this deals with precedence: 3 * (2 + 1)
  10995. if (p instanceof AST_Binary) {
  10996. const po = p.operator;
  10997. const so = this.operator;
  10998. if (so === "??" && (po === "||" || po === "&&")) {
  10999. return true;
  11000. }
  11001. if (po === "??" && (so === "||" || so === "&&")) {
  11002. return true;
  11003. }
  11004. const pp = PRECEDENCE[po];
  11005. const sp = PRECEDENCE[so];
  11006. if (pp > sp
  11007. || (pp == sp
  11008. && (this === p.right || po == "**"))) {
  11009. return true;
  11010. }
  11011. }
  11012. });
  11013. PARENS(AST_Yield, function(output) {
  11014. var p = output.parent();
  11015. // (yield 1) + (yield 2)
  11016. // a = yield 3
  11017. if (p instanceof AST_Binary && p.operator !== "=")
  11018. return true;
  11019. // (yield 1)()
  11020. // new (yield 1)()
  11021. if (p instanceof AST_Call && p.expression === this)
  11022. return true;
  11023. // (yield 1) ? yield 2 : yield 3
  11024. if (p instanceof AST_Conditional && p.condition === this)
  11025. return true;
  11026. // -(yield 4)
  11027. if (p instanceof AST_Unary)
  11028. return true;
  11029. // (yield x).foo
  11030. // (yield x)['foo']
  11031. if (p instanceof AST_PropAccess && p.expression === this)
  11032. return true;
  11033. });
  11034. PARENS(AST_PropAccess, function(output) {
  11035. var p = output.parent();
  11036. if (p instanceof AST_New && p.expression === this) {
  11037. // i.e. new (foo.bar().baz)
  11038. //
  11039. // if there's one call into this subtree, then we need
  11040. // parens around it too, otherwise the call will be
  11041. // interpreted as passing the arguments to the upper New
  11042. // expression.
  11043. return walk(this, node => {
  11044. if (node instanceof AST_Scope) return true;
  11045. if (node instanceof AST_Call) {
  11046. return walk_abort; // makes walk() return true.
  11047. }
  11048. });
  11049. }
  11050. });
  11051. PARENS(AST_Call, function(output) {
  11052. var p = output.parent(), p1;
  11053. if (p instanceof AST_New && p.expression === this
  11054. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  11055. return true;
  11056. // workaround for Safari bug.
  11057. // https://bugs.webkit.org/show_bug.cgi?id=123506
  11058. return this.expression instanceof AST_Function
  11059. && p instanceof AST_PropAccess
  11060. && p.expression === this
  11061. && (p1 = output.parent(1)) instanceof AST_Assign
  11062. && p1.left === p;
  11063. });
  11064. PARENS(AST_New, function(output) {
  11065. var p = output.parent();
  11066. if (this.args.length === 0
  11067. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  11068. || p instanceof AST_Call && p.expression === this
  11069. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  11070. return true;
  11071. });
  11072. PARENS(AST_Number, function(output) {
  11073. var p = output.parent();
  11074. if (p instanceof AST_PropAccess && p.expression === this) {
  11075. var value = this.getValue();
  11076. if (value < 0 || /^0/.test(make_num(value))) {
  11077. return true;
  11078. }
  11079. }
  11080. });
  11081. PARENS(AST_BigInt, function(output) {
  11082. var p = output.parent();
  11083. if (p instanceof AST_PropAccess && p.expression === this) {
  11084. var value = this.getValue();
  11085. if (value.startsWith("-")) {
  11086. return true;
  11087. }
  11088. }
  11089. });
  11090. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  11091. var p = output.parent();
  11092. // !(a = false) → true
  11093. if (p instanceof AST_Unary)
  11094. return true;
  11095. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  11096. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  11097. return true;
  11098. // (a = func)() —or— new (a = Object)()
  11099. if (p instanceof AST_Call && p.expression === this)
  11100. return true;
  11101. // (a = foo) ? bar : baz
  11102. if (p instanceof AST_Conditional && p.condition === this)
  11103. return true;
  11104. // (a = foo)["prop"] —or— (a = foo).prop
  11105. if (p instanceof AST_PropAccess && p.expression === this)
  11106. return true;
  11107. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  11108. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  11109. return true;
  11110. });
  11111. /* -----[ PRINTERS ]----- */
  11112. DEFPRINT(AST_Directive, function(self, output) {
  11113. output.print_string(self.value, self.quote);
  11114. output.semicolon();
  11115. });
  11116. DEFPRINT(AST_Expansion, function (self, output) {
  11117. output.print("...");
  11118. self.expression.print(output);
  11119. });
  11120. DEFPRINT(AST_Destructuring, function (self, output) {
  11121. output.print(self.is_array ? "[" : "{");
  11122. var len = self.names.length;
  11123. self.names.forEach(function (name, i) {
  11124. if (i > 0) output.comma();
  11125. name.print(output);
  11126. // If the final element is a hole, we need to make sure it
  11127. // doesn't look like a trailing comma, by inserting an actual
  11128. // trailing comma.
  11129. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  11130. });
  11131. output.print(self.is_array ? "]" : "}");
  11132. });
  11133. DEFPRINT(AST_Debugger, function(self, output) {
  11134. output.print("debugger");
  11135. output.semicolon();
  11136. });
  11137. /* -----[ statements ]----- */
  11138. function display_body(body, is_toplevel, output, allow_directives) {
  11139. var last = body.length - 1;
  11140. output.in_directive = allow_directives;
  11141. body.forEach(function(stmt, i) {
  11142. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  11143. stmt instanceof AST_EmptyStatement ||
  11144. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  11145. )) {
  11146. output.in_directive = false;
  11147. }
  11148. if (!(stmt instanceof AST_EmptyStatement)) {
  11149. output.indent();
  11150. stmt.print(output);
  11151. if (!(i == last && is_toplevel)) {
  11152. output.newline();
  11153. if (is_toplevel) output.newline();
  11154. }
  11155. }
  11156. if (output.in_directive === true &&
  11157. stmt instanceof AST_SimpleStatement &&
  11158. stmt.body instanceof AST_String
  11159. ) {
  11160. output.in_directive = false;
  11161. }
  11162. });
  11163. output.in_directive = false;
  11164. }
  11165. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  11166. force_statement(this.body, output);
  11167. });
  11168. DEFPRINT(AST_Statement, function(self, output) {
  11169. self.body.print(output);
  11170. output.semicolon();
  11171. });
  11172. DEFPRINT(AST_Toplevel, function(self, output) {
  11173. display_body(self.body, true, output, true);
  11174. output.print("");
  11175. });
  11176. DEFPRINT(AST_LabeledStatement, function(self, output) {
  11177. self.label.print(output);
  11178. output.colon();
  11179. self.body.print(output);
  11180. });
  11181. DEFPRINT(AST_SimpleStatement, function(self, output) {
  11182. self.body.print(output);
  11183. output.semicolon();
  11184. });
  11185. function print_braced_empty(self, output) {
  11186. output.print("{");
  11187. output.with_indent(output.next_indent(), function() {
  11188. output.append_comments(self, true);
  11189. });
  11190. output.print("}");
  11191. }
  11192. function print_braced(self, output, allow_directives) {
  11193. if (self.body.length > 0) {
  11194. output.with_block(function() {
  11195. display_body(self.body, false, output, allow_directives);
  11196. });
  11197. } else print_braced_empty(self, output);
  11198. }
  11199. DEFPRINT(AST_BlockStatement, function(self, output) {
  11200. print_braced(self, output);
  11201. });
  11202. DEFPRINT(AST_EmptyStatement, function(self, output) {
  11203. output.semicolon();
  11204. });
  11205. DEFPRINT(AST_Do, function(self, output) {
  11206. output.print("do");
  11207. output.space();
  11208. make_block(self.body, output);
  11209. output.space();
  11210. output.print("while");
  11211. output.space();
  11212. output.with_parens(function() {
  11213. self.condition.print(output);
  11214. });
  11215. output.semicolon();
  11216. });
  11217. DEFPRINT(AST_While, function(self, output) {
  11218. output.print("while");
  11219. output.space();
  11220. output.with_parens(function() {
  11221. self.condition.print(output);
  11222. });
  11223. output.space();
  11224. self._do_print_body(output);
  11225. });
  11226. DEFPRINT(AST_For, function(self, output) {
  11227. output.print("for");
  11228. output.space();
  11229. output.with_parens(function() {
  11230. if (self.init) {
  11231. if (self.init instanceof AST_Definitions) {
  11232. self.init.print(output);
  11233. } else {
  11234. parenthesize_for_noin(self.init, output, true);
  11235. }
  11236. output.print(";");
  11237. output.space();
  11238. } else {
  11239. output.print(";");
  11240. }
  11241. if (self.condition) {
  11242. self.condition.print(output);
  11243. output.print(";");
  11244. output.space();
  11245. } else {
  11246. output.print(";");
  11247. }
  11248. if (self.step) {
  11249. self.step.print(output);
  11250. }
  11251. });
  11252. output.space();
  11253. self._do_print_body(output);
  11254. });
  11255. DEFPRINT(AST_ForIn, function(self, output) {
  11256. output.print("for");
  11257. if (self.await) {
  11258. output.space();
  11259. output.print("await");
  11260. }
  11261. output.space();
  11262. output.with_parens(function() {
  11263. self.init.print(output);
  11264. output.space();
  11265. output.print(self instanceof AST_ForOf ? "of" : "in");
  11266. output.space();
  11267. self.object.print(output);
  11268. });
  11269. output.space();
  11270. self._do_print_body(output);
  11271. });
  11272. DEFPRINT(AST_With, function(self, output) {
  11273. output.print("with");
  11274. output.space();
  11275. output.with_parens(function() {
  11276. self.expression.print(output);
  11277. });
  11278. output.space();
  11279. self._do_print_body(output);
  11280. });
  11281. /* -----[ functions ]----- */
  11282. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  11283. var self = this;
  11284. if (!nokeyword) {
  11285. if (self.async) {
  11286. output.print("async");
  11287. output.space();
  11288. }
  11289. output.print("function");
  11290. if (self.is_generator) {
  11291. output.star();
  11292. }
  11293. if (self.name) {
  11294. output.space();
  11295. }
  11296. }
  11297. if (self.name instanceof AST_Symbol) {
  11298. self.name.print(output);
  11299. } else if (nokeyword && self.name instanceof AST_Node) {
  11300. output.with_square(function() {
  11301. self.name.print(output); // Computed method name
  11302. });
  11303. }
  11304. output.with_parens(function() {
  11305. self.argnames.forEach(function(arg, i) {
  11306. if (i) output.comma();
  11307. arg.print(output);
  11308. });
  11309. });
  11310. output.space();
  11311. print_braced(self, output, true);
  11312. });
  11313. DEFPRINT(AST_Lambda, function(self, output) {
  11314. self._do_print(output);
  11315. });
  11316. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  11317. var tag = self.prefix;
  11318. var parenthesize_tag = tag instanceof AST_Lambda
  11319. || tag instanceof AST_Binary
  11320. || tag instanceof AST_Conditional
  11321. || tag instanceof AST_Sequence
  11322. || tag instanceof AST_Unary
  11323. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  11324. if (parenthesize_tag) output.print("(");
  11325. self.prefix.print(output);
  11326. if (parenthesize_tag) output.print(")");
  11327. self.template_string.print(output);
  11328. });
  11329. DEFPRINT(AST_TemplateString, function(self, output) {
  11330. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  11331. output.print("`");
  11332. for (var i = 0; i < self.segments.length; i++) {
  11333. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  11334. output.print("${");
  11335. self.segments[i].print(output);
  11336. output.print("}");
  11337. } else if (is_tagged) {
  11338. output.print(self.segments[i].raw);
  11339. } else {
  11340. output.print_template_string_chars(self.segments[i].value);
  11341. }
  11342. }
  11343. output.print("`");
  11344. });
  11345. DEFPRINT(AST_TemplateSegment, function(self, output) {
  11346. output.print_template_string_chars(self.value);
  11347. });
  11348. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  11349. var self = this;
  11350. var parent = output.parent();
  11351. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  11352. parent instanceof AST_Unary ||
  11353. (parent instanceof AST_Call && self === parent.expression);
  11354. if (needs_parens) { output.print("("); }
  11355. if (self.async) {
  11356. output.print("async");
  11357. output.space();
  11358. }
  11359. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  11360. self.argnames[0].print(output);
  11361. } else {
  11362. output.with_parens(function() {
  11363. self.argnames.forEach(function(arg, i) {
  11364. if (i) output.comma();
  11365. arg.print(output);
  11366. });
  11367. });
  11368. }
  11369. output.space();
  11370. output.print("=>");
  11371. output.space();
  11372. const first_statement = self.body[0];
  11373. if (
  11374. self.body.length === 1
  11375. && first_statement instanceof AST_Return
  11376. ) {
  11377. const returned = first_statement.value;
  11378. if (!returned) {
  11379. output.print("{}");
  11380. } else if (left_is_object(returned)) {
  11381. output.print("(");
  11382. returned.print(output);
  11383. output.print(")");
  11384. } else {
  11385. returned.print(output);
  11386. }
  11387. } else {
  11388. print_braced(self, output);
  11389. }
  11390. if (needs_parens) { output.print(")"); }
  11391. });
  11392. /* -----[ exits ]----- */
  11393. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  11394. output.print(kind);
  11395. if (this.value) {
  11396. output.space();
  11397. const comments = this.value.start.comments_before;
  11398. if (comments && comments.length && !output.printed_comments.has(comments)) {
  11399. output.print("(");
  11400. this.value.print(output);
  11401. output.print(")");
  11402. } else {
  11403. this.value.print(output);
  11404. }
  11405. }
  11406. output.semicolon();
  11407. });
  11408. DEFPRINT(AST_Return, function(self, output) {
  11409. self._do_print(output, "return");
  11410. });
  11411. DEFPRINT(AST_Throw, function(self, output) {
  11412. self._do_print(output, "throw");
  11413. });
  11414. /* -----[ yield ]----- */
  11415. DEFPRINT(AST_Yield, function(self, output) {
  11416. var star = self.is_star ? "*" : "";
  11417. output.print("yield" + star);
  11418. if (self.expression) {
  11419. output.space();
  11420. self.expression.print(output);
  11421. }
  11422. });
  11423. DEFPRINT(AST_Await, function(self, output) {
  11424. output.print("await");
  11425. output.space();
  11426. var e = self.expression;
  11427. var parens = !(
  11428. e instanceof AST_Call
  11429. || e instanceof AST_SymbolRef
  11430. || e instanceof AST_PropAccess
  11431. || e instanceof AST_Unary
  11432. || e instanceof AST_Constant
  11433. || e instanceof AST_Await
  11434. || e instanceof AST_Object
  11435. );
  11436. if (parens) output.print("(");
  11437. self.expression.print(output);
  11438. if (parens) output.print(")");
  11439. });
  11440. /* -----[ loop control ]----- */
  11441. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  11442. output.print(kind);
  11443. if (this.label) {
  11444. output.space();
  11445. this.label.print(output);
  11446. }
  11447. output.semicolon();
  11448. });
  11449. DEFPRINT(AST_Break, function(self, output) {
  11450. self._do_print(output, "break");
  11451. });
  11452. DEFPRINT(AST_Continue, function(self, output) {
  11453. self._do_print(output, "continue");
  11454. });
  11455. /* -----[ if ]----- */
  11456. function make_then(self, output) {
  11457. var b = self.body;
  11458. if (output.option("braces")
  11459. || output.option("ie8") && b instanceof AST_Do)
  11460. return make_block(b, output);
  11461. // The squeezer replaces "block"-s that contain only a single
  11462. // statement with the statement itself; technically, the AST
  11463. // is correct, but this can create problems when we output an
  11464. // IF having an ELSE clause where the THEN clause ends in an
  11465. // IF *without* an ELSE block (then the outer ELSE would refer
  11466. // to the inner IF). This function checks for this case and
  11467. // adds the block braces if needed.
  11468. if (!b) return output.force_semicolon();
  11469. while (true) {
  11470. if (b instanceof AST_If) {
  11471. if (!b.alternative) {
  11472. make_block(self.body, output);
  11473. return;
  11474. }
  11475. b = b.alternative;
  11476. } else if (b instanceof AST_StatementWithBody) {
  11477. b = b.body;
  11478. } else break;
  11479. }
  11480. force_statement(self.body, output);
  11481. }
  11482. DEFPRINT(AST_If, function(self, output) {
  11483. output.print("if");
  11484. output.space();
  11485. output.with_parens(function() {
  11486. self.condition.print(output);
  11487. });
  11488. output.space();
  11489. if (self.alternative) {
  11490. make_then(self, output);
  11491. output.space();
  11492. output.print("else");
  11493. output.space();
  11494. if (self.alternative instanceof AST_If)
  11495. self.alternative.print(output);
  11496. else
  11497. force_statement(self.alternative, output);
  11498. } else {
  11499. self._do_print_body(output);
  11500. }
  11501. });
  11502. /* -----[ switch ]----- */
  11503. DEFPRINT(AST_Switch, function(self, output) {
  11504. output.print("switch");
  11505. output.space();
  11506. output.with_parens(function() {
  11507. self.expression.print(output);
  11508. });
  11509. output.space();
  11510. var last = self.body.length - 1;
  11511. if (last < 0) print_braced_empty(self, output);
  11512. else output.with_block(function() {
  11513. self.body.forEach(function(branch, i) {
  11514. output.indent(true);
  11515. branch.print(output);
  11516. if (i < last && branch.body.length > 0)
  11517. output.newline();
  11518. });
  11519. });
  11520. });
  11521. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  11522. output.newline();
  11523. this.body.forEach(function(stmt) {
  11524. output.indent();
  11525. stmt.print(output);
  11526. output.newline();
  11527. });
  11528. });
  11529. DEFPRINT(AST_Default, function(self, output) {
  11530. output.print("default:");
  11531. self._do_print_body(output);
  11532. });
  11533. DEFPRINT(AST_Case, function(self, output) {
  11534. output.print("case");
  11535. output.space();
  11536. self.expression.print(output);
  11537. output.print(":");
  11538. self._do_print_body(output);
  11539. });
  11540. /* -----[ exceptions ]----- */
  11541. DEFPRINT(AST_Try, function(self, output) {
  11542. output.print("try");
  11543. output.space();
  11544. print_braced(self, output);
  11545. if (self.bcatch) {
  11546. output.space();
  11547. self.bcatch.print(output);
  11548. }
  11549. if (self.bfinally) {
  11550. output.space();
  11551. self.bfinally.print(output);
  11552. }
  11553. });
  11554. DEFPRINT(AST_Catch, function(self, output) {
  11555. output.print("catch");
  11556. if (self.argname) {
  11557. output.space();
  11558. output.with_parens(function() {
  11559. self.argname.print(output);
  11560. });
  11561. }
  11562. output.space();
  11563. print_braced(self, output);
  11564. });
  11565. DEFPRINT(AST_Finally, function(self, output) {
  11566. output.print("finally");
  11567. output.space();
  11568. print_braced(self, output);
  11569. });
  11570. /* -----[ var/const ]----- */
  11571. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  11572. output.print(kind);
  11573. output.space();
  11574. this.definitions.forEach(function(def, i) {
  11575. if (i) output.comma();
  11576. def.print(output);
  11577. });
  11578. var p = output.parent();
  11579. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  11580. var output_semicolon = !in_for || p && p.init !== this;
  11581. if (output_semicolon)
  11582. output.semicolon();
  11583. });
  11584. DEFPRINT(AST_Let, function(self, output) {
  11585. self._do_print(output, "let");
  11586. });
  11587. DEFPRINT(AST_Var, function(self, output) {
  11588. self._do_print(output, "var");
  11589. });
  11590. DEFPRINT(AST_Const, function(self, output) {
  11591. self._do_print(output, "const");
  11592. });
  11593. DEFPRINT(AST_Import, function(self, output) {
  11594. output.print("import");
  11595. output.space();
  11596. if (self.imported_name) {
  11597. self.imported_name.print(output);
  11598. }
  11599. if (self.imported_name && self.imported_names) {
  11600. output.print(",");
  11601. output.space();
  11602. }
  11603. if (self.imported_names) {
  11604. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  11605. self.imported_names[0].print(output);
  11606. } else {
  11607. output.print("{");
  11608. self.imported_names.forEach(function (name_import, i) {
  11609. output.space();
  11610. name_import.print(output);
  11611. if (i < self.imported_names.length - 1) {
  11612. output.print(",");
  11613. }
  11614. });
  11615. output.space();
  11616. output.print("}");
  11617. }
  11618. }
  11619. if (self.imported_name || self.imported_names) {
  11620. output.space();
  11621. output.print("from");
  11622. output.space();
  11623. }
  11624. self.module_name.print(output);
  11625. if (self.assert_clause) {
  11626. output.print("assert");
  11627. self.assert_clause.print(output);
  11628. }
  11629. output.semicolon();
  11630. });
  11631. DEFPRINT(AST_ImportMeta, function(self, output) {
  11632. output.print("import.meta");
  11633. });
  11634. DEFPRINT(AST_NameMapping, function(self, output) {
  11635. var is_import = output.parent() instanceof AST_Import;
  11636. var definition = self.name.definition();
  11637. var names_are_different =
  11638. (definition && definition.mangled_name || self.name.name) !==
  11639. self.foreign_name.name;
  11640. if (names_are_different) {
  11641. if (is_import) {
  11642. output.print(self.foreign_name.name);
  11643. } else {
  11644. self.name.print(output);
  11645. }
  11646. output.space();
  11647. output.print("as");
  11648. output.space();
  11649. if (is_import) {
  11650. self.name.print(output);
  11651. } else {
  11652. output.print(self.foreign_name.name);
  11653. }
  11654. } else {
  11655. self.name.print(output);
  11656. }
  11657. });
  11658. DEFPRINT(AST_Export, function(self, output) {
  11659. output.print("export");
  11660. output.space();
  11661. if (self.is_default) {
  11662. output.print("default");
  11663. output.space();
  11664. }
  11665. if (self.exported_names) {
  11666. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  11667. self.exported_names[0].print(output);
  11668. } else {
  11669. output.print("{");
  11670. self.exported_names.forEach(function(name_export, i) {
  11671. output.space();
  11672. name_export.print(output);
  11673. if (i < self.exported_names.length - 1) {
  11674. output.print(",");
  11675. }
  11676. });
  11677. output.space();
  11678. output.print("}");
  11679. }
  11680. } else if (self.exported_value) {
  11681. self.exported_value.print(output);
  11682. } else if (self.exported_definition) {
  11683. self.exported_definition.print(output);
  11684. if (self.exported_definition instanceof AST_Definitions) return;
  11685. }
  11686. if (self.module_name) {
  11687. output.space();
  11688. output.print("from");
  11689. output.space();
  11690. self.module_name.print(output);
  11691. }
  11692. if (self.assert_clause) {
  11693. output.print("assert");
  11694. self.assert_clause.print(output);
  11695. }
  11696. if (self.exported_value
  11697. && !(self.exported_value instanceof AST_Defun ||
  11698. self.exported_value instanceof AST_Function ||
  11699. self.exported_value instanceof AST_Class)
  11700. || self.module_name
  11701. || self.exported_names
  11702. ) {
  11703. output.semicolon();
  11704. }
  11705. });
  11706. function parenthesize_for_noin(node, output, noin) {
  11707. var parens = false;
  11708. // need to take some precautions here:
  11709. // https://github.com/mishoo/UglifyJS2/issues/60
  11710. if (noin) {
  11711. parens = walk(node, node => {
  11712. // Don't go into scopes -- except arrow functions:
  11713. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  11714. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  11715. return true;
  11716. }
  11717. if (node instanceof AST_Binary && node.operator == "in") {
  11718. return walk_abort; // makes walk() return true
  11719. }
  11720. });
  11721. }
  11722. node.print(output, parens);
  11723. }
  11724. DEFPRINT(AST_VarDef, function(self, output) {
  11725. self.name.print(output);
  11726. if (self.value) {
  11727. output.space();
  11728. output.print("=");
  11729. output.space();
  11730. var p = output.parent(1);
  11731. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  11732. parenthesize_for_noin(self.value, output, noin);
  11733. }
  11734. });
  11735. /* -----[ other expressions ]----- */
  11736. DEFPRINT(AST_Call, function(self, output) {
  11737. self.expression.print(output);
  11738. if (self instanceof AST_New && self.args.length === 0)
  11739. return;
  11740. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  11741. output.add_mapping(self.start);
  11742. }
  11743. if (self.optional) output.print("?.");
  11744. output.with_parens(function() {
  11745. self.args.forEach(function(expr, i) {
  11746. if (i) output.comma();
  11747. expr.print(output);
  11748. });
  11749. });
  11750. });
  11751. DEFPRINT(AST_New, function(self, output) {
  11752. output.print("new");
  11753. output.space();
  11754. AST_Call.prototype._codegen(self, output);
  11755. });
  11756. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  11757. this.expressions.forEach(function(node, index) {
  11758. if (index > 0) {
  11759. output.comma();
  11760. if (output.should_break()) {
  11761. output.newline();
  11762. output.indent();
  11763. }
  11764. }
  11765. node.print(output);
  11766. });
  11767. });
  11768. DEFPRINT(AST_Sequence, function(self, output) {
  11769. self._do_print(output);
  11770. // var p = output.parent();
  11771. // if (p instanceof AST_Statement) {
  11772. // output.with_indent(output.next_indent(), function(){
  11773. // self._do_print(output);
  11774. // });
  11775. // } else {
  11776. // self._do_print(output);
  11777. // }
  11778. });
  11779. DEFPRINT(AST_Dot, function(self, output) {
  11780. var expr = self.expression;
  11781. expr.print(output);
  11782. var prop = self.property;
  11783. var print_computed = ALL_RESERVED_WORDS.has(prop)
  11784. ? output.option("ie8")
  11785. : !is_identifier_string(
  11786. prop,
  11787. output.option("ecma") >= 2015 || output.option("safari10")
  11788. );
  11789. if (self.optional) output.print("?.");
  11790. if (print_computed) {
  11791. output.print("[");
  11792. output.add_mapping(self.end);
  11793. output.print_string(prop);
  11794. output.print("]");
  11795. } else {
  11796. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  11797. if (!/[xa-f.)]/i.test(output.last())) {
  11798. output.print(".");
  11799. }
  11800. }
  11801. if (!self.optional) output.print(".");
  11802. // the name after dot would be mapped about here.
  11803. output.add_mapping(self.end);
  11804. output.print_name(prop);
  11805. }
  11806. });
  11807. DEFPRINT(AST_DotHash, function(self, output) {
  11808. var expr = self.expression;
  11809. expr.print(output);
  11810. var prop = self.property;
  11811. if (self.optional) output.print("?");
  11812. output.print(".#");
  11813. output.add_mapping(self.end);
  11814. output.print_name(prop);
  11815. });
  11816. DEFPRINT(AST_Sub, function(self, output) {
  11817. self.expression.print(output);
  11818. if (self.optional) output.print("?.");
  11819. output.print("[");
  11820. self.property.print(output);
  11821. output.print("]");
  11822. });
  11823. DEFPRINT(AST_Chain, function(self, output) {
  11824. self.expression.print(output);
  11825. });
  11826. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  11827. var op = self.operator;
  11828. output.print(op);
  11829. if (/^[a-z]/i.test(op)
  11830. || (/[+-]$/.test(op)
  11831. && self.expression instanceof AST_UnaryPrefix
  11832. && /^[+-]/.test(self.expression.operator))) {
  11833. output.space();
  11834. }
  11835. self.expression.print(output);
  11836. });
  11837. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  11838. self.expression.print(output);
  11839. output.print(self.operator);
  11840. });
  11841. DEFPRINT(AST_Binary, function(self, output) {
  11842. var op = self.operator;
  11843. self.left.print(output);
  11844. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  11845. && self.left instanceof AST_UnaryPostfix
  11846. && self.left.operator == "--") {
  11847. // space is mandatory to avoid outputting -->
  11848. output.print(" ");
  11849. } else {
  11850. // the space is optional depending on "beautify"
  11851. output.space();
  11852. }
  11853. output.print(op);
  11854. if ((op == "<" || op == "<<")
  11855. && self.right instanceof AST_UnaryPrefix
  11856. && self.right.operator == "!"
  11857. && self.right.expression instanceof AST_UnaryPrefix
  11858. && self.right.expression.operator == "--") {
  11859. // space is mandatory to avoid outputting <!--
  11860. output.print(" ");
  11861. } else {
  11862. // the space is optional depending on "beautify"
  11863. output.space();
  11864. }
  11865. self.right.print(output);
  11866. });
  11867. DEFPRINT(AST_Conditional, function(self, output) {
  11868. self.condition.print(output);
  11869. output.space();
  11870. output.print("?");
  11871. output.space();
  11872. self.consequent.print(output);
  11873. output.space();
  11874. output.colon();
  11875. self.alternative.print(output);
  11876. });
  11877. /* -----[ literals ]----- */
  11878. DEFPRINT(AST_Array, function(self, output) {
  11879. output.with_square(function() {
  11880. var a = self.elements, len = a.length;
  11881. if (len > 0) output.space();
  11882. a.forEach(function(exp, i) {
  11883. if (i) output.comma();
  11884. exp.print(output);
  11885. // If the final element is a hole, we need to make sure it
  11886. // doesn't look like a trailing comma, by inserting an actual
  11887. // trailing comma.
  11888. if (i === len - 1 && exp instanceof AST_Hole)
  11889. output.comma();
  11890. });
  11891. if (len > 0) output.space();
  11892. });
  11893. });
  11894. DEFPRINT(AST_Object, function(self, output) {
  11895. if (self.properties.length > 0) output.with_block(function() {
  11896. self.properties.forEach(function(prop, i) {
  11897. if (i) {
  11898. output.print(",");
  11899. output.newline();
  11900. }
  11901. output.indent();
  11902. prop.print(output);
  11903. });
  11904. output.newline();
  11905. });
  11906. else print_braced_empty(self, output);
  11907. });
  11908. DEFPRINT(AST_Class, function(self, output) {
  11909. output.print("class");
  11910. output.space();
  11911. if (self.name) {
  11912. self.name.print(output);
  11913. output.space();
  11914. }
  11915. if (self.extends) {
  11916. var parens = (
  11917. !(self.extends instanceof AST_SymbolRef)
  11918. && !(self.extends instanceof AST_PropAccess)
  11919. && !(self.extends instanceof AST_ClassExpression)
  11920. && !(self.extends instanceof AST_Function)
  11921. );
  11922. output.print("extends");
  11923. if (parens) {
  11924. output.print("(");
  11925. } else {
  11926. output.space();
  11927. }
  11928. self.extends.print(output);
  11929. if (parens) {
  11930. output.print(")");
  11931. } else {
  11932. output.space();
  11933. }
  11934. }
  11935. if (self.properties.length > 0) output.with_block(function() {
  11936. self.properties.forEach(function(prop, i) {
  11937. if (i) {
  11938. output.newline();
  11939. }
  11940. output.indent();
  11941. prop.print(output);
  11942. });
  11943. output.newline();
  11944. });
  11945. else output.print("{}");
  11946. });
  11947. DEFPRINT(AST_NewTarget, function(self, output) {
  11948. output.print("new.target");
  11949. });
  11950. function print_property_name(key, quote, output) {
  11951. if (output.option("quote_keys")) {
  11952. return output.print_string(key);
  11953. }
  11954. if ("" + +key == key && key >= 0) {
  11955. if (output.option("keep_numbers")) {
  11956. return output.print(key);
  11957. }
  11958. return output.print(make_num(key));
  11959. }
  11960. var print_string = ALL_RESERVED_WORDS.has(key)
  11961. ? output.option("ie8")
  11962. : (
  11963. output.option("ecma") < 2015 || output.option("safari10")
  11964. ? !is_basic_identifier_string(key)
  11965. : !is_identifier_string(key, true)
  11966. );
  11967. if (print_string || (quote && output.option("keep_quoted_props"))) {
  11968. return output.print_string(key, quote);
  11969. }
  11970. return output.print_name(key);
  11971. }
  11972. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  11973. function get_name(self) {
  11974. var def = self.definition();
  11975. return def ? def.mangled_name || def.name : self.name;
  11976. }
  11977. var allowShortHand = output.option("shorthand");
  11978. if (allowShortHand &&
  11979. self.value instanceof AST_Symbol &&
  11980. is_identifier_string(
  11981. self.key,
  11982. output.option("ecma") >= 2015 || output.option("safari10")
  11983. ) &&
  11984. get_name(self.value) === self.key &&
  11985. !ALL_RESERVED_WORDS.has(self.key)
  11986. ) {
  11987. print_property_name(self.key, self.quote, output);
  11988. } else if (allowShortHand &&
  11989. self.value instanceof AST_DefaultAssign &&
  11990. self.value.left instanceof AST_Symbol &&
  11991. is_identifier_string(
  11992. self.key,
  11993. output.option("ecma") >= 2015 || output.option("safari10")
  11994. ) &&
  11995. get_name(self.value.left) === self.key
  11996. ) {
  11997. print_property_name(self.key, self.quote, output);
  11998. output.space();
  11999. output.print("=");
  12000. output.space();
  12001. self.value.right.print(output);
  12002. } else {
  12003. if (!(self.key instanceof AST_Node)) {
  12004. print_property_name(self.key, self.quote, output);
  12005. } else {
  12006. output.with_square(function() {
  12007. self.key.print(output);
  12008. });
  12009. }
  12010. output.colon();
  12011. self.value.print(output);
  12012. }
  12013. });
  12014. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  12015. if (self.static) {
  12016. output.print("static");
  12017. output.space();
  12018. }
  12019. output.print("#");
  12020. print_property_name(self.key.name, self.quote, output);
  12021. if (self.value) {
  12022. output.print("=");
  12023. self.value.print(output);
  12024. }
  12025. output.semicolon();
  12026. });
  12027. DEFPRINT(AST_ClassProperty, (self, output) => {
  12028. if (self.static) {
  12029. output.print("static");
  12030. output.space();
  12031. }
  12032. if (self.key instanceof AST_SymbolClassProperty) {
  12033. print_property_name(self.key.name, self.quote, output);
  12034. } else {
  12035. output.print("[");
  12036. self.key.print(output);
  12037. output.print("]");
  12038. }
  12039. if (self.value) {
  12040. output.print("=");
  12041. self.value.print(output);
  12042. }
  12043. output.semicolon();
  12044. });
  12045. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  12046. var self = this;
  12047. if (self.static) {
  12048. output.print("static");
  12049. output.space();
  12050. }
  12051. if (type) {
  12052. output.print(type);
  12053. output.space();
  12054. }
  12055. if (self.key instanceof AST_SymbolMethod) {
  12056. if (is_private) output.print("#");
  12057. print_property_name(self.key.name, self.quote, output);
  12058. } else {
  12059. output.with_square(function() {
  12060. self.key.print(output);
  12061. });
  12062. }
  12063. self.value._do_print(output, true);
  12064. });
  12065. DEFPRINT(AST_ObjectSetter, function(self, output) {
  12066. self._print_getter_setter("set", false, output);
  12067. });
  12068. DEFPRINT(AST_ObjectGetter, function(self, output) {
  12069. self._print_getter_setter("get", false, output);
  12070. });
  12071. DEFPRINT(AST_PrivateSetter, function(self, output) {
  12072. self._print_getter_setter("set", true, output);
  12073. });
  12074. DEFPRINT(AST_PrivateGetter, function(self, output) {
  12075. self._print_getter_setter("get", true, output);
  12076. });
  12077. DEFPRINT(AST_PrivateMethod, function(self, output) {
  12078. var type;
  12079. if (self.is_generator && self.async) {
  12080. type = "async*";
  12081. } else if (self.is_generator) {
  12082. type = "*";
  12083. } else if (self.async) {
  12084. type = "async";
  12085. }
  12086. self._print_getter_setter(type, true, output);
  12087. });
  12088. DEFPRINT(AST_ConciseMethod, function(self, output) {
  12089. var type;
  12090. if (self.is_generator && self.async) {
  12091. type = "async*";
  12092. } else if (self.is_generator) {
  12093. type = "*";
  12094. } else if (self.async) {
  12095. type = "async";
  12096. }
  12097. self._print_getter_setter(type, false, output);
  12098. });
  12099. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  12100. var def = this.definition();
  12101. output.print_name(def ? def.mangled_name || def.name : this.name);
  12102. });
  12103. DEFPRINT(AST_Symbol, function (self, output) {
  12104. self._do_print(output);
  12105. });
  12106. DEFPRINT(AST_Hole, noop);
  12107. DEFPRINT(AST_This, function(self, output) {
  12108. output.print("this");
  12109. });
  12110. DEFPRINT(AST_Super, function(self, output) {
  12111. output.print("super");
  12112. });
  12113. DEFPRINT(AST_Constant, function(self, output) {
  12114. output.print(self.getValue());
  12115. });
  12116. DEFPRINT(AST_String, function(self, output) {
  12117. output.print_string(self.getValue(), self.quote, output.in_directive);
  12118. });
  12119. DEFPRINT(AST_Number, function(self, output) {
  12120. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  12121. output.print(self.raw);
  12122. } else {
  12123. output.print(make_num(self.getValue()));
  12124. }
  12125. });
  12126. DEFPRINT(AST_BigInt, function(self, output) {
  12127. output.print(self.getValue() + "n");
  12128. });
  12129. const r_slash_script = /(<\s*\/\s*script)/i;
  12130. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  12131. DEFPRINT(AST_RegExp, function(self, output) {
  12132. let { source, flags } = self.getValue();
  12133. source = regexp_source_fix(source);
  12134. flags = flags ? sort_regexp_flags(flags) : "";
  12135. source = source.replace(r_slash_script, slash_script_replace);
  12136. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  12137. const parent = output.parent();
  12138. if (
  12139. parent instanceof AST_Binary
  12140. && /^\w/.test(parent.operator)
  12141. && parent.left === self
  12142. ) {
  12143. output.print(" ");
  12144. }
  12145. });
  12146. function force_statement(stat, output) {
  12147. if (output.option("braces")) {
  12148. make_block(stat, output);
  12149. } else {
  12150. if (!stat || stat instanceof AST_EmptyStatement)
  12151. output.force_semicolon();
  12152. else
  12153. stat.print(output);
  12154. }
  12155. }
  12156. function best_of(a) {
  12157. var best = a[0], len = best.length;
  12158. for (var i = 1; i < a.length; ++i) {
  12159. if (a[i].length < len) {
  12160. best = a[i];
  12161. len = best.length;
  12162. }
  12163. }
  12164. return best;
  12165. }
  12166. function make_num(num) {
  12167. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  12168. var candidates = [ str ];
  12169. if (Math.floor(num) === num) {
  12170. if (num < 0) {
  12171. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  12172. } else {
  12173. candidates.push("0x" + num.toString(16).toLowerCase());
  12174. }
  12175. }
  12176. var match, len, digits;
  12177. if (match = /^\.0+/.exec(str)) {
  12178. len = match[0].length;
  12179. digits = str.slice(len);
  12180. candidates.push(digits + "e-" + (digits.length + len - 1));
  12181. } else if (match = /0+$/.exec(str)) {
  12182. len = match[0].length;
  12183. candidates.push(str.slice(0, -len) + "e" + len);
  12184. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  12185. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  12186. }
  12187. return best_of(candidates);
  12188. }
  12189. function make_block(stmt, output) {
  12190. if (!stmt || stmt instanceof AST_EmptyStatement)
  12191. output.print("{}");
  12192. else if (stmt instanceof AST_BlockStatement)
  12193. stmt.print(output);
  12194. else output.with_block(function() {
  12195. output.indent();
  12196. stmt.print(output);
  12197. output.newline();
  12198. });
  12199. }
  12200. /* -----[ source map generators ]----- */
  12201. function DEFMAP(nodetype, generator) {
  12202. nodetype.forEach(function(nodetype) {
  12203. nodetype.DEFMETHOD("add_source_map", generator);
  12204. });
  12205. }
  12206. DEFMAP([
  12207. // We could easily add info for ALL nodes, but it seems to me that
  12208. // would be quite wasteful, hence this noop in the base class.
  12209. AST_Node,
  12210. // since the label symbol will mark it
  12211. AST_LabeledStatement,
  12212. AST_Toplevel,
  12213. ], noop);
  12214. // XXX: I'm not exactly sure if we need it for all of these nodes,
  12215. // or if we should add even more.
  12216. DEFMAP([
  12217. AST_Array,
  12218. AST_BlockStatement,
  12219. AST_Catch,
  12220. AST_Class,
  12221. AST_Constant,
  12222. AST_Debugger,
  12223. AST_Definitions,
  12224. AST_Directive,
  12225. AST_Finally,
  12226. AST_Jump,
  12227. AST_Lambda,
  12228. AST_New,
  12229. AST_Object,
  12230. AST_StatementWithBody,
  12231. AST_Symbol,
  12232. AST_Switch,
  12233. AST_SwitchBranch,
  12234. AST_TemplateString,
  12235. AST_TemplateSegment,
  12236. AST_Try,
  12237. ], function(output) {
  12238. output.add_mapping(this.start);
  12239. });
  12240. DEFMAP([
  12241. AST_ObjectGetter,
  12242. AST_ObjectSetter,
  12243. AST_PrivateGetter,
  12244. AST_PrivateSetter,
  12245. ], function(output) {
  12246. output.add_mapping(this.key.end, this.key.name);
  12247. });
  12248. DEFMAP([ AST_ObjectProperty ], function(output) {
  12249. output.add_mapping(this.start, this.key);
  12250. });
  12251. })();
  12252. const shallow_cmp = (node1, node2) => {
  12253. return (
  12254. node1 === null && node2 === null
  12255. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  12256. );
  12257. };
  12258. const equivalent_to = (tree1, tree2) => {
  12259. if (!shallow_cmp(tree1, tree2)) return false;
  12260. const walk_1_state = [tree1];
  12261. const walk_2_state = [tree2];
  12262. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  12263. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  12264. while (walk_1_state.length && walk_2_state.length) {
  12265. const node_1 = walk_1_state.pop();
  12266. const node_2 = walk_2_state.pop();
  12267. if (!shallow_cmp(node_1, node_2)) return false;
  12268. node_1._children_backwards(walk_1_push);
  12269. node_2._children_backwards(walk_2_push);
  12270. if (walk_1_state.length !== walk_2_state.length) {
  12271. // Different number of children
  12272. return false;
  12273. }
  12274. }
  12275. return walk_1_state.length == 0 && walk_2_state.length == 0;
  12276. };
  12277. const pass_through = () => true;
  12278. AST_Node.prototype.shallow_cmp = function () {
  12279. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  12280. };
  12281. AST_Debugger.prototype.shallow_cmp = pass_through;
  12282. AST_Directive.prototype.shallow_cmp = function(other) {
  12283. return this.value === other.value;
  12284. };
  12285. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  12286. AST_Block.prototype.shallow_cmp = pass_through;
  12287. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  12288. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  12289. return this.label.name === other.label.name;
  12290. };
  12291. AST_Do.prototype.shallow_cmp = pass_through;
  12292. AST_While.prototype.shallow_cmp = pass_through;
  12293. AST_For.prototype.shallow_cmp = function(other) {
  12294. return (this.init == null ? other.init == null : this.init === other.init) && (this.condition == null ? other.condition == null : this.condition === other.condition) && (this.step == null ? other.step == null : this.step === other.step);
  12295. };
  12296. AST_ForIn.prototype.shallow_cmp = pass_through;
  12297. AST_ForOf.prototype.shallow_cmp = pass_through;
  12298. AST_With.prototype.shallow_cmp = pass_through;
  12299. AST_Toplevel.prototype.shallow_cmp = pass_through;
  12300. AST_Expansion.prototype.shallow_cmp = pass_through;
  12301. AST_Lambda.prototype.shallow_cmp = function(other) {
  12302. return this.is_generator === other.is_generator && this.async === other.async;
  12303. };
  12304. AST_Destructuring.prototype.shallow_cmp = function(other) {
  12305. return this.is_array === other.is_array;
  12306. };
  12307. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  12308. AST_TemplateString.prototype.shallow_cmp = pass_through;
  12309. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  12310. return this.value === other.value;
  12311. };
  12312. AST_Jump.prototype.shallow_cmp = pass_through;
  12313. AST_LoopControl.prototype.shallow_cmp = pass_through;
  12314. AST_Await.prototype.shallow_cmp = pass_through;
  12315. AST_Yield.prototype.shallow_cmp = function(other) {
  12316. return this.is_star === other.is_star;
  12317. };
  12318. AST_If.prototype.shallow_cmp = function(other) {
  12319. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  12320. };
  12321. AST_Switch.prototype.shallow_cmp = pass_through;
  12322. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  12323. AST_Try.prototype.shallow_cmp = function(other) {
  12324. return (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
  12325. };
  12326. AST_Catch.prototype.shallow_cmp = function(other) {
  12327. return this.argname == null ? other.argname == null : this.argname === other.argname;
  12328. };
  12329. AST_Finally.prototype.shallow_cmp = pass_through;
  12330. AST_Definitions.prototype.shallow_cmp = pass_through;
  12331. AST_VarDef.prototype.shallow_cmp = function(other) {
  12332. return this.value == null ? other.value == null : this.value === other.value;
  12333. };
  12334. AST_NameMapping.prototype.shallow_cmp = pass_through;
  12335. AST_Import.prototype.shallow_cmp = function(other) {
  12336. return (this.imported_name == null ? other.imported_name == null : this.imported_name === other.imported_name) && (this.imported_names == null ? other.imported_names == null : this.imported_names === other.imported_names);
  12337. };
  12338. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  12339. AST_Export.prototype.shallow_cmp = function(other) {
  12340. return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && this.module_name === other.module_name && this.is_default === other.is_default;
  12341. };
  12342. AST_Call.prototype.shallow_cmp = pass_through;
  12343. AST_Sequence.prototype.shallow_cmp = pass_through;
  12344. AST_PropAccess.prototype.shallow_cmp = pass_through;
  12345. AST_Chain.prototype.shallow_cmp = pass_through;
  12346. AST_Dot.prototype.shallow_cmp = function(other) {
  12347. return this.property === other.property;
  12348. };
  12349. AST_DotHash.prototype.shallow_cmp = function(other) {
  12350. return this.property === other.property;
  12351. };
  12352. AST_Unary.prototype.shallow_cmp = function(other) {
  12353. return this.operator === other.operator;
  12354. };
  12355. AST_Binary.prototype.shallow_cmp = function(other) {
  12356. return this.operator === other.operator;
  12357. };
  12358. AST_Conditional.prototype.shallow_cmp = pass_through;
  12359. AST_Array.prototype.shallow_cmp = pass_through;
  12360. AST_Object.prototype.shallow_cmp = pass_through;
  12361. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  12362. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  12363. return this.key === other.key;
  12364. };
  12365. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  12366. return this.static === other.static;
  12367. };
  12368. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  12369. return this.static === other.static;
  12370. };
  12371. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  12372. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  12373. };
  12374. AST_Class.prototype.shallow_cmp = function(other) {
  12375. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  12376. };
  12377. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  12378. return this.static === other.static;
  12379. };
  12380. AST_Symbol.prototype.shallow_cmp = function(other) {
  12381. return this.name === other.name;
  12382. };
  12383. AST_NewTarget.prototype.shallow_cmp = pass_through;
  12384. AST_This.prototype.shallow_cmp = pass_through;
  12385. AST_Super.prototype.shallow_cmp = pass_through;
  12386. AST_String.prototype.shallow_cmp = function(other) {
  12387. return this.value === other.value;
  12388. };
  12389. AST_Number.prototype.shallow_cmp = function(other) {
  12390. return this.value === other.value;
  12391. };
  12392. AST_BigInt.prototype.shallow_cmp = function(other) {
  12393. return this.value === other.value;
  12394. };
  12395. AST_RegExp.prototype.shallow_cmp = function (other) {
  12396. return (
  12397. this.value.flags === other.value.flags
  12398. && this.value.source === other.value.source
  12399. );
  12400. };
  12401. AST_Atom.prototype.shallow_cmp = pass_through;
  12402. /***********************************************************************
  12403. A JavaScript tokenizer / parser / beautifier / compressor.
  12404. https://github.com/mishoo/UglifyJS2
  12405. -------------------------------- (C) ---------------------------------
  12406. Author: Mihai Bazon
  12407. <mihai.bazon@gmail.com>
  12408. http://mihai.bazon.net/blog
  12409. Distributed under the BSD license:
  12410. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12411. Redistribution and use in source and binary forms, with or without
  12412. modification, are permitted provided that the following conditions
  12413. are met:
  12414. * Redistributions of source code must retain the above
  12415. copyright notice, this list of conditions and the following
  12416. disclaimer.
  12417. * Redistributions in binary form must reproduce the above
  12418. copyright notice, this list of conditions and the following
  12419. disclaimer in the documentation and/or other materials
  12420. provided with the distribution.
  12421. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12422. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12423. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12424. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12425. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12426. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12427. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12428. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12429. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12430. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12431. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12432. SUCH DAMAGE.
  12433. ***********************************************************************/
  12434. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  12435. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  12436. let function_defs = null;
  12437. let unmangleable_names = null;
  12438. /**
  12439. * When defined, there is a function declaration somewhere that's inside of a block.
  12440. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  12441. */
  12442. let scopes_with_block_defuns = null;
  12443. class SymbolDef {
  12444. constructor(scope, orig, init) {
  12445. this.name = orig.name;
  12446. this.orig = [ orig ];
  12447. this.init = init;
  12448. this.eliminated = 0;
  12449. this.assignments = 0;
  12450. this.scope = scope;
  12451. this.replaced = 0;
  12452. this.global = false;
  12453. this.export = 0;
  12454. this.mangled_name = null;
  12455. this.undeclared = false;
  12456. this.id = SymbolDef.next_id++;
  12457. this.chained = false;
  12458. this.direct_access = false;
  12459. this.escaped = 0;
  12460. this.recursive_refs = 0;
  12461. this.references = [];
  12462. this.should_replace = undefined;
  12463. this.single_use = false;
  12464. this.fixed = false;
  12465. Object.seal(this);
  12466. }
  12467. fixed_value() {
  12468. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  12469. return this.fixed();
  12470. }
  12471. unmangleable(options) {
  12472. if (!options) options = {};
  12473. if (
  12474. function_defs &&
  12475. function_defs.has(this.id) &&
  12476. keep_name(options.keep_fnames, this.orig[0].name)
  12477. ) return true;
  12478. return this.global && !options.toplevel
  12479. || (this.export & MASK_EXPORT_DONT_MANGLE)
  12480. || this.undeclared
  12481. || !options.eval && this.scope.pinned()
  12482. || (this.orig[0] instanceof AST_SymbolLambda
  12483. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  12484. || this.orig[0] instanceof AST_SymbolMethod
  12485. || (this.orig[0] instanceof AST_SymbolClass
  12486. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  12487. }
  12488. mangle(options) {
  12489. const cache = options.cache && options.cache.props;
  12490. if (this.global && cache && cache.has(this.name)) {
  12491. this.mangled_name = cache.get(this.name);
  12492. } else if (!this.mangled_name && !this.unmangleable(options)) {
  12493. var s = this.scope;
  12494. var sym = this.orig[0];
  12495. if (options.ie8 && sym instanceof AST_SymbolLambda)
  12496. s = s.parent_scope;
  12497. const redefinition = redefined_catch_def(this);
  12498. this.mangled_name = redefinition
  12499. ? redefinition.mangled_name || redefinition.name
  12500. : s.next_mangled(options, this);
  12501. if (this.global && cache) {
  12502. cache.set(this.name, this.mangled_name);
  12503. }
  12504. }
  12505. }
  12506. }
  12507. SymbolDef.next_id = 1;
  12508. function redefined_catch_def(def) {
  12509. if (def.orig[0] instanceof AST_SymbolCatch
  12510. && def.scope.is_block_scope()
  12511. ) {
  12512. return def.scope.get_defun_scope().variables.get(def.name);
  12513. }
  12514. }
  12515. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  12516. options = defaults(options, {
  12517. cache: null,
  12518. ie8: false,
  12519. safari10: false,
  12520. });
  12521. if (!(toplevel instanceof AST_Toplevel)) {
  12522. throw new Error("Invalid toplevel scope");
  12523. }
  12524. // pass 1: setup scope chaining and handle definitions
  12525. var scope = this.parent_scope = parent_scope;
  12526. var labels = new Map();
  12527. var defun = null;
  12528. var in_destructuring = null;
  12529. var for_scopes = [];
  12530. var tw = new TreeWalker((node, descend) => {
  12531. if (node.is_block_scope()) {
  12532. const save_scope = scope;
  12533. node.block_scope = scope = new AST_Scope(node);
  12534. scope._block_scope = true;
  12535. // AST_Try in the AST sadly *is* (not has) a body itself,
  12536. // and its catch and finally branches are children of the AST_Try itself
  12537. const parent_scope = node instanceof AST_Catch
  12538. ? save_scope.parent_scope
  12539. : save_scope;
  12540. scope.init_scope_vars(parent_scope);
  12541. scope.uses_with = save_scope.uses_with;
  12542. scope.uses_eval = save_scope.uses_eval;
  12543. if (options.safari10) {
  12544. if (node instanceof AST_For || node instanceof AST_ForIn) {
  12545. for_scopes.push(scope);
  12546. }
  12547. }
  12548. if (node instanceof AST_Switch) {
  12549. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  12550. // AST_Switch has a scope within the body, but it itself "is a block scope"
  12551. // This means the switched expression has to belong to the outer scope
  12552. // while the body inside belongs to the switch itself.
  12553. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  12554. const the_block_scope = scope;
  12555. scope = save_scope;
  12556. node.expression.walk(tw);
  12557. scope = the_block_scope;
  12558. for (let i = 0; i < node.body.length; i++) {
  12559. node.body[i].walk(tw);
  12560. }
  12561. } else {
  12562. descend();
  12563. }
  12564. scope = save_scope;
  12565. return true;
  12566. }
  12567. if (node instanceof AST_Destructuring) {
  12568. const save_destructuring = in_destructuring;
  12569. in_destructuring = node;
  12570. descend();
  12571. in_destructuring = save_destructuring;
  12572. return true;
  12573. }
  12574. if (node instanceof AST_Scope) {
  12575. node.init_scope_vars(scope);
  12576. var save_scope = scope;
  12577. var save_defun = defun;
  12578. var save_labels = labels;
  12579. defun = scope = node;
  12580. labels = new Map();
  12581. descend();
  12582. scope = save_scope;
  12583. defun = save_defun;
  12584. labels = save_labels;
  12585. return true; // don't descend again in TreeWalker
  12586. }
  12587. if (node instanceof AST_LabeledStatement) {
  12588. var l = node.label;
  12589. if (labels.has(l.name)) {
  12590. throw new Error(string_template("Label {name} defined twice", l));
  12591. }
  12592. labels.set(l.name, l);
  12593. descend();
  12594. labels.delete(l.name);
  12595. return true; // no descend again
  12596. }
  12597. if (node instanceof AST_With) {
  12598. for (var s = scope; s; s = s.parent_scope)
  12599. s.uses_with = true;
  12600. return;
  12601. }
  12602. if (node instanceof AST_Symbol) {
  12603. node.scope = scope;
  12604. }
  12605. if (node instanceof AST_Label) {
  12606. node.thedef = node;
  12607. node.references = [];
  12608. }
  12609. if (node instanceof AST_SymbolLambda) {
  12610. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  12611. } else if (node instanceof AST_SymbolDefun) {
  12612. // Careful here, the scope where this should be defined is
  12613. // the parent scope. The reason is that we enter a new
  12614. // scope when we encounter the AST_Defun node (which is
  12615. // instanceof AST_Scope) but we get to the symbol a bit
  12616. // later.
  12617. const closest_scope = defun.parent_scope;
  12618. // In strict mode, function definitions are block-scoped
  12619. node.scope = tw.directives["use strict"]
  12620. ? closest_scope
  12621. : closest_scope.get_defun_scope();
  12622. mark_export(node.scope.def_function(node, defun), 1);
  12623. } else if (node instanceof AST_SymbolClass) {
  12624. mark_export(defun.def_variable(node, defun), 1);
  12625. } else if (node instanceof AST_SymbolImport) {
  12626. scope.def_variable(node);
  12627. } else if (node instanceof AST_SymbolDefClass) {
  12628. // This deals with the name of the class being available
  12629. // inside the class.
  12630. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  12631. } else if (
  12632. node instanceof AST_SymbolVar
  12633. || node instanceof AST_SymbolLet
  12634. || node instanceof AST_SymbolConst
  12635. || node instanceof AST_SymbolCatch
  12636. ) {
  12637. var def;
  12638. if (node instanceof AST_SymbolBlockDeclaration) {
  12639. def = scope.def_variable(node, null);
  12640. } else {
  12641. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  12642. }
  12643. if (!def.orig.every((sym) => {
  12644. if (sym === node) return true;
  12645. if (node instanceof AST_SymbolBlockDeclaration) {
  12646. return sym instanceof AST_SymbolLambda;
  12647. }
  12648. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  12649. })) {
  12650. js_error(
  12651. `"${node.name}" is redeclared`,
  12652. node.start.file,
  12653. node.start.line,
  12654. node.start.col,
  12655. node.start.pos
  12656. );
  12657. }
  12658. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  12659. if (defun !== scope) {
  12660. node.mark_enclosed();
  12661. var def = scope.find_variable(node);
  12662. if (node.thedef !== def) {
  12663. node.thedef = def;
  12664. node.reference();
  12665. }
  12666. }
  12667. } else if (node instanceof AST_LabelRef) {
  12668. var sym = labels.get(node.name);
  12669. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  12670. name: node.name,
  12671. line: node.start.line,
  12672. col: node.start.col
  12673. }));
  12674. node.thedef = sym;
  12675. }
  12676. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  12677. js_error(
  12678. `"${node.TYPE}" statement may only appear at the top level`,
  12679. node.start.file,
  12680. node.start.line,
  12681. node.start.col,
  12682. node.start.pos
  12683. );
  12684. }
  12685. });
  12686. this.walk(tw);
  12687. function mark_export(def, level) {
  12688. if (in_destructuring) {
  12689. var i = 0;
  12690. do {
  12691. level++;
  12692. } while (tw.parent(i++) !== in_destructuring);
  12693. }
  12694. var node = tw.parent(level);
  12695. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  12696. var exported = node.exported_definition;
  12697. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  12698. def.export = MASK_EXPORT_WANT_MANGLE;
  12699. }
  12700. }
  12701. }
  12702. // pass 2: find back references and eval
  12703. const is_toplevel = this instanceof AST_Toplevel;
  12704. if (is_toplevel) {
  12705. this.globals = new Map();
  12706. }
  12707. var tw = new TreeWalker(node => {
  12708. if (node instanceof AST_LoopControl && node.label) {
  12709. node.label.thedef.references.push(node);
  12710. return true;
  12711. }
  12712. if (node instanceof AST_SymbolRef) {
  12713. var name = node.name;
  12714. if (name == "eval" && tw.parent() instanceof AST_Call) {
  12715. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  12716. s.uses_eval = true;
  12717. }
  12718. }
  12719. var sym;
  12720. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  12721. || !(sym = node.scope.find_variable(name))) {
  12722. sym = toplevel.def_global(node);
  12723. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  12724. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  12725. sym.scope.uses_arguments = true;
  12726. }
  12727. node.thedef = sym;
  12728. node.reference();
  12729. if (node.scope.is_block_scope()
  12730. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  12731. node.scope = node.scope.get_defun_scope();
  12732. }
  12733. return true;
  12734. }
  12735. // ensure mangling works if catch reuses a scope variable
  12736. var def;
  12737. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  12738. var s = node.scope;
  12739. while (s) {
  12740. push_uniq(s.enclosed, def);
  12741. if (s === def.scope) break;
  12742. s = s.parent_scope;
  12743. }
  12744. }
  12745. });
  12746. this.walk(tw);
  12747. // pass 3: work around IE8 and Safari catch scope bugs
  12748. if (options.ie8 || options.safari10) {
  12749. walk(this, node => {
  12750. if (node instanceof AST_SymbolCatch) {
  12751. var name = node.name;
  12752. var refs = node.thedef.references;
  12753. var scope = node.scope.get_defun_scope();
  12754. var def = scope.find_variable(name)
  12755. || toplevel.globals.get(name)
  12756. || scope.def_variable(node);
  12757. refs.forEach(function(ref) {
  12758. ref.thedef = def;
  12759. ref.reference();
  12760. });
  12761. node.thedef = def;
  12762. node.reference();
  12763. return true;
  12764. }
  12765. });
  12766. }
  12767. // pass 4: add symbol definitions to loop scopes
  12768. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  12769. // https://github.com/mishoo/UglifyJS2/issues/1753
  12770. // https://bugs.webkit.org/show_bug.cgi?id=171041
  12771. if (options.safari10) {
  12772. for (const scope of for_scopes) {
  12773. scope.parent_scope.variables.forEach(function(def) {
  12774. push_uniq(scope.enclosed, def);
  12775. });
  12776. }
  12777. }
  12778. });
  12779. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  12780. var globals = this.globals, name = node.name;
  12781. if (globals.has(name)) {
  12782. return globals.get(name);
  12783. } else {
  12784. var g = new SymbolDef(this, node);
  12785. g.undeclared = true;
  12786. g.global = true;
  12787. globals.set(name, g);
  12788. return g;
  12789. }
  12790. });
  12791. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  12792. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  12793. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  12794. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  12795. this.parent_scope = parent_scope; // the parent scope
  12796. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  12797. this.cname = -1; // the current index for mangling functions/variables
  12798. });
  12799. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  12800. return (
  12801. this.enclosed.find(def => def.name === name)
  12802. || this.variables.has(name)
  12803. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  12804. );
  12805. });
  12806. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  12807. return (
  12808. this.enclosed.find(def => def.name === name)
  12809. || this.variables.has(name)
  12810. );
  12811. });
  12812. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  12813. // `scope` is going to be moved into `this` right now.
  12814. // Update the required scopes' information
  12815. if (scope.parent_scope === this) return;
  12816. scope.parent_scope = this;
  12817. // TODO uses_with, uses_eval, etc
  12818. const scope_ancestry = (() => {
  12819. const ancestry = [];
  12820. let cur = this;
  12821. do {
  12822. ancestry.push(cur);
  12823. } while ((cur = cur.parent_scope));
  12824. ancestry.reverse();
  12825. return ancestry;
  12826. })();
  12827. const new_scope_enclosed_set = new Set(scope.enclosed);
  12828. const to_enclose = [];
  12829. for (const scope_topdown of scope_ancestry) {
  12830. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  12831. for (const def of scope_topdown.variables.values()) {
  12832. if (new_scope_enclosed_set.has(def)) {
  12833. push_uniq(to_enclose, def);
  12834. push_uniq(scope_topdown.enclosed, def);
  12835. }
  12836. }
  12837. }
  12838. });
  12839. function find_scopes_visible_from(scopes) {
  12840. const found_scopes = new Set();
  12841. for (const scope of new Set(scopes)) {
  12842. (function bubble_up(scope) {
  12843. if (scope == null || found_scopes.has(scope)) return;
  12844. found_scopes.add(scope);
  12845. bubble_up(scope.parent_scope);
  12846. })(scope);
  12847. }
  12848. return [...found_scopes];
  12849. }
  12850. // Creates a symbol during compression
  12851. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  12852. source,
  12853. tentative_name,
  12854. scope,
  12855. conflict_scopes = [scope],
  12856. init = null
  12857. } = {}) {
  12858. let symbol_name;
  12859. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  12860. if (tentative_name) {
  12861. // Implement hygiene (no new names are conflicting with existing names)
  12862. tentative_name =
  12863. symbol_name =
  12864. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  12865. let i = 0;
  12866. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  12867. symbol_name = tentative_name + "$" + i++;
  12868. }
  12869. }
  12870. if (!symbol_name) {
  12871. throw new Error("No symbol name could be generated in create_symbol()");
  12872. }
  12873. const symbol = make_node(SymClass, source, {
  12874. name: symbol_name,
  12875. scope
  12876. });
  12877. this.def_variable(symbol, init || null);
  12878. symbol.mark_enclosed();
  12879. return symbol;
  12880. });
  12881. AST_Node.DEFMETHOD("is_block_scope", return_false);
  12882. AST_Class.DEFMETHOD("is_block_scope", return_false);
  12883. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  12884. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  12885. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  12886. AST_Block.DEFMETHOD("is_block_scope", return_true);
  12887. AST_Scope.DEFMETHOD("is_block_scope", function () {
  12888. return this._block_scope || false;
  12889. });
  12890. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  12891. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  12892. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  12893. this.uses_arguments = false;
  12894. this.def_variable(new AST_SymbolFunarg({
  12895. name: "arguments",
  12896. start: this.start,
  12897. end: this.end
  12898. }));
  12899. });
  12900. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  12901. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  12902. this.uses_arguments = false;
  12903. });
  12904. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  12905. var def = this.definition();
  12906. var s = this.scope;
  12907. while (s) {
  12908. push_uniq(s.enclosed, def);
  12909. if (s === def.scope) break;
  12910. s = s.parent_scope;
  12911. }
  12912. });
  12913. AST_Symbol.DEFMETHOD("reference", function() {
  12914. this.definition().references.push(this);
  12915. this.mark_enclosed();
  12916. });
  12917. AST_Scope.DEFMETHOD("find_variable", function(name) {
  12918. if (name instanceof AST_Symbol) name = name.name;
  12919. return this.variables.get(name)
  12920. || (this.parent_scope && this.parent_scope.find_variable(name));
  12921. });
  12922. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  12923. var def = this.def_variable(symbol, init);
  12924. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  12925. return def;
  12926. });
  12927. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  12928. var def = this.variables.get(symbol.name);
  12929. if (def) {
  12930. def.orig.push(symbol);
  12931. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  12932. def.init = init;
  12933. }
  12934. } else {
  12935. def = new SymbolDef(this, symbol, init);
  12936. this.variables.set(symbol.name, def);
  12937. def.global = !this.parent_scope;
  12938. }
  12939. return symbol.thedef = def;
  12940. });
  12941. function next_mangled(scope, options) {
  12942. let defun_scope;
  12943. if (
  12944. scopes_with_block_defuns
  12945. && (defun_scope = scope.get_defun_scope())
  12946. && scopes_with_block_defuns.has(defun_scope)
  12947. ) {
  12948. scope = defun_scope;
  12949. }
  12950. var ext = scope.enclosed;
  12951. var nth_identifier = options.nth_identifier;
  12952. out: while (true) {
  12953. var m = nth_identifier.get(++scope.cname);
  12954. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  12955. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  12956. // shadow a name reserved from mangling.
  12957. if (options.reserved.has(m)) continue;
  12958. // Functions with short names might collide with base54 output
  12959. // and therefore cause collisions when keep_fnames is true.
  12960. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  12961. // we must ensure that the mangled name does not shadow a name
  12962. // from some parent scope that is referenced in this or in
  12963. // inner scopes.
  12964. for (let i = ext.length; --i >= 0;) {
  12965. const def = ext[i];
  12966. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  12967. if (m == name) continue out;
  12968. }
  12969. return m;
  12970. }
  12971. }
  12972. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  12973. return next_mangled(this, options);
  12974. });
  12975. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  12976. let name;
  12977. const mangled_names = this.mangled_names;
  12978. do {
  12979. name = next_mangled(this, options);
  12980. } while (mangled_names.has(name));
  12981. return name;
  12982. });
  12983. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  12984. // #179, #326
  12985. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  12986. // a function expression's argument cannot shadow the function expression's name
  12987. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  12988. // the function's mangled_name is null when keep_fnames is true
  12989. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  12990. while (true) {
  12991. var name = next_mangled(this, options);
  12992. if (!tricky_name || tricky_name != name)
  12993. return name;
  12994. }
  12995. });
  12996. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  12997. var def = this.definition();
  12998. return !def || def.unmangleable(options);
  12999. });
  13000. // labels are always mangleable
  13001. AST_Label.DEFMETHOD("unmangleable", return_false);
  13002. AST_Symbol.DEFMETHOD("unreferenced", function() {
  13003. return !this.definition().references.length && !this.scope.pinned();
  13004. });
  13005. AST_Symbol.DEFMETHOD("definition", function() {
  13006. return this.thedef;
  13007. });
  13008. AST_Symbol.DEFMETHOD("global", function() {
  13009. return this.thedef.global;
  13010. });
  13011. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  13012. options = defaults(options, {
  13013. eval : false,
  13014. nth_identifier : base54,
  13015. ie8 : false,
  13016. keep_classnames: false,
  13017. keep_fnames : false,
  13018. module : false,
  13019. reserved : [],
  13020. toplevel : false,
  13021. });
  13022. if (options.module) options.toplevel = true;
  13023. if (!Array.isArray(options.reserved)
  13024. && !(options.reserved instanceof Set)
  13025. ) {
  13026. options.reserved = [];
  13027. }
  13028. options.reserved = new Set(options.reserved);
  13029. // Never mangle arguments
  13030. options.reserved.add("arguments");
  13031. return options;
  13032. });
  13033. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  13034. options = this._default_mangler_options(options);
  13035. var nth_identifier = options.nth_identifier;
  13036. // We only need to mangle declaration nodes. Special logic wired
  13037. // into the code generator will display the mangled name if it's
  13038. // present (and for AST_SymbolRef-s it'll use the mangled name of
  13039. // the AST_SymbolDeclaration that it points to).
  13040. var lname = -1;
  13041. var to_mangle = [];
  13042. if (options.keep_fnames) {
  13043. function_defs = new Set();
  13044. }
  13045. const mangled_names = this.mangled_names = new Set();
  13046. unmangleable_names = new Set();
  13047. if (options.cache) {
  13048. this.globals.forEach(collect);
  13049. if (options.cache.props) {
  13050. options.cache.props.forEach(function(mangled_name) {
  13051. mangled_names.add(mangled_name);
  13052. });
  13053. }
  13054. }
  13055. var tw = new TreeWalker(function(node, descend) {
  13056. if (node instanceof AST_LabeledStatement) {
  13057. // lname is incremented when we get to the AST_Label
  13058. var save_nesting = lname;
  13059. descend();
  13060. lname = save_nesting;
  13061. return true; // don't descend again in TreeWalker
  13062. }
  13063. if (
  13064. node instanceof AST_Defun
  13065. && !(tw.parent() instanceof AST_Scope)
  13066. ) {
  13067. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  13068. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  13069. }
  13070. if (node instanceof AST_Scope) {
  13071. node.variables.forEach(collect);
  13072. return;
  13073. }
  13074. if (node.is_block_scope()) {
  13075. node.block_scope.variables.forEach(collect);
  13076. return;
  13077. }
  13078. if (
  13079. function_defs
  13080. && node instanceof AST_VarDef
  13081. && node.value instanceof AST_Lambda
  13082. && !node.value.name
  13083. && keep_name(options.keep_fnames, node.name.name)
  13084. ) {
  13085. function_defs.add(node.name.definition().id);
  13086. return;
  13087. }
  13088. if (node instanceof AST_Label) {
  13089. let name;
  13090. do {
  13091. name = nth_identifier.get(++lname);
  13092. } while (ALL_RESERVED_WORDS.has(name));
  13093. node.mangled_name = name;
  13094. return true;
  13095. }
  13096. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  13097. to_mangle.push(node.definition());
  13098. return;
  13099. }
  13100. });
  13101. this.walk(tw);
  13102. if (options.keep_fnames || options.keep_classnames) {
  13103. // Collect a set of short names which are unmangleable,
  13104. // for use in avoiding collisions in next_mangled.
  13105. to_mangle.forEach(def => {
  13106. if (def.name.length < 6 && def.unmangleable(options)) {
  13107. unmangleable_names.add(def.name);
  13108. }
  13109. });
  13110. }
  13111. to_mangle.forEach(def => { def.mangle(options); });
  13112. function_defs = null;
  13113. unmangleable_names = null;
  13114. scopes_with_block_defuns = null;
  13115. function collect(symbol) {
  13116. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  13117. unmangleable_names.add(symbol.name);
  13118. } else if (!options.reserved.has(symbol.name)) {
  13119. to_mangle.push(symbol);
  13120. }
  13121. }
  13122. });
  13123. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  13124. const cache = options.cache && options.cache.props;
  13125. const avoid = new Set();
  13126. options.reserved.forEach(to_avoid);
  13127. this.globals.forEach(add_def);
  13128. this.walk(new TreeWalker(function(node) {
  13129. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  13130. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  13131. }));
  13132. return avoid;
  13133. function to_avoid(name) {
  13134. avoid.add(name);
  13135. }
  13136. function add_def(def) {
  13137. var name = def.name;
  13138. if (def.global && cache && cache.has(name)) name = cache.get(name);
  13139. else if (!def.unmangleable(options)) return;
  13140. to_avoid(name);
  13141. }
  13142. });
  13143. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  13144. options = this._default_mangler_options(options);
  13145. var nth_identifier = options.nth_identifier;
  13146. if (nth_identifier.reset && nth_identifier.sort) {
  13147. nth_identifier.reset();
  13148. nth_identifier.sort();
  13149. }
  13150. var avoid = this.find_colliding_names(options);
  13151. var cname = 0;
  13152. this.globals.forEach(rename);
  13153. this.walk(new TreeWalker(function(node) {
  13154. if (node instanceof AST_Scope) node.variables.forEach(rename);
  13155. if (node instanceof AST_SymbolCatch) rename(node.definition());
  13156. }));
  13157. function next_name() {
  13158. var name;
  13159. do {
  13160. name = nth_identifier.get(cname++);
  13161. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  13162. return name;
  13163. }
  13164. function rename(def) {
  13165. if (def.global && options.cache) return;
  13166. if (def.unmangleable(options)) return;
  13167. if (options.reserved.has(def.name)) return;
  13168. const redefinition = redefined_catch_def(def);
  13169. const name = def.name = redefinition ? redefinition.name : next_name();
  13170. def.orig.forEach(function(sym) {
  13171. sym.name = name;
  13172. });
  13173. def.references.forEach(function(sym) {
  13174. sym.name = name;
  13175. });
  13176. }
  13177. });
  13178. AST_Node.DEFMETHOD("tail_node", return_this);
  13179. AST_Sequence.DEFMETHOD("tail_node", function() {
  13180. return this.expressions[this.expressions.length - 1];
  13181. });
  13182. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  13183. options = this._default_mangler_options(options);
  13184. var nth_identifier = options.nth_identifier;
  13185. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  13186. // If the identifier mangler is invariant, skip computing character frequency.
  13187. return;
  13188. }
  13189. nth_identifier.reset();
  13190. try {
  13191. AST_Node.prototype.print = function(stream, force_parens) {
  13192. this._print(stream, force_parens);
  13193. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  13194. nth_identifier.consider(this.name, -1);
  13195. } else if (options.properties) {
  13196. if (this instanceof AST_DotHash) {
  13197. nth_identifier.consider("#" + this.property, -1);
  13198. } else if (this instanceof AST_Dot) {
  13199. nth_identifier.consider(this.property, -1);
  13200. } else if (this instanceof AST_Sub) {
  13201. skip_string(this.property);
  13202. }
  13203. }
  13204. };
  13205. nth_identifier.consider(this.print_to_string(), 1);
  13206. } finally {
  13207. AST_Node.prototype.print = AST_Node.prototype._print;
  13208. }
  13209. nth_identifier.sort();
  13210. function skip_string(node) {
  13211. if (node instanceof AST_String) {
  13212. nth_identifier.consider(node.value, -1);
  13213. } else if (node instanceof AST_Conditional) {
  13214. skip_string(node.consequent);
  13215. skip_string(node.alternative);
  13216. } else if (node instanceof AST_Sequence) {
  13217. skip_string(node.tail_node());
  13218. }
  13219. }
  13220. });
  13221. const base54 = (() => {
  13222. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  13223. const digits = "0123456789".split("");
  13224. let chars;
  13225. let frequency;
  13226. function reset() {
  13227. frequency = new Map();
  13228. leading.forEach(function(ch) {
  13229. frequency.set(ch, 0);
  13230. });
  13231. digits.forEach(function(ch) {
  13232. frequency.set(ch, 0);
  13233. });
  13234. }
  13235. function consider(str, delta) {
  13236. for (var i = str.length; --i >= 0;) {
  13237. frequency.set(str[i], frequency.get(str[i]) + delta);
  13238. }
  13239. }
  13240. function compare(a, b) {
  13241. return frequency.get(b) - frequency.get(a);
  13242. }
  13243. function sort() {
  13244. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  13245. }
  13246. // Ensure this is in a usable initial state.
  13247. reset();
  13248. sort();
  13249. function base54(num) {
  13250. var ret = "", base = 54;
  13251. num++;
  13252. do {
  13253. num--;
  13254. ret += chars[num % base];
  13255. num = Math.floor(num / base);
  13256. base = 64;
  13257. } while (num > 0);
  13258. return ret;
  13259. }
  13260. return {
  13261. get: base54,
  13262. consider,
  13263. reset,
  13264. sort
  13265. };
  13266. })();
  13267. let mangle_options = undefined;
  13268. AST_Node.prototype.size = function (compressor, stack) {
  13269. mangle_options = compressor && compressor.mangle_options;
  13270. let size = 0;
  13271. walk_parent(this, (node, info) => {
  13272. size += node._size(info);
  13273. // Braceless arrow functions have fake "return" statements
  13274. if (node instanceof AST_Arrow && node.is_braceless()) {
  13275. size += node.body[0].value._size(info);
  13276. return true;
  13277. }
  13278. }, stack || (compressor && compressor.stack));
  13279. // just to save a bit of memory
  13280. mangle_options = undefined;
  13281. return size;
  13282. };
  13283. AST_Node.prototype._size = () => 0;
  13284. AST_Debugger.prototype._size = () => 8;
  13285. AST_Directive.prototype._size = function () {
  13286. // TODO string encoding stuff
  13287. return 2 + this.value.length;
  13288. };
  13289. /** Count commas/semicolons necessary to show a list of expressions/statements */
  13290. const list_overhead = (array) => array.length && array.length - 1;
  13291. AST_Block.prototype._size = function () {
  13292. return 2 + list_overhead(this.body);
  13293. };
  13294. AST_Toplevel.prototype._size = function() {
  13295. return list_overhead(this.body);
  13296. };
  13297. AST_EmptyStatement.prototype._size = () => 1;
  13298. AST_LabeledStatement.prototype._size = () => 2; // x:
  13299. AST_Do.prototype._size = () => 9;
  13300. AST_While.prototype._size = () => 7;
  13301. AST_For.prototype._size = () => 8;
  13302. AST_ForIn.prototype._size = () => 8;
  13303. // AST_ForOf inherits ^
  13304. AST_With.prototype._size = () => 6;
  13305. AST_Expansion.prototype._size = () => 3;
  13306. const lambda_modifiers = func =>
  13307. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  13308. AST_Accessor.prototype._size = function () {
  13309. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  13310. };
  13311. AST_Function.prototype._size = function (info) {
  13312. const first = !!first_in_statement(info);
  13313. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  13314. };
  13315. AST_Defun.prototype._size = function () {
  13316. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  13317. };
  13318. AST_Arrow.prototype._size = function () {
  13319. let args_and_arrow = 2 + list_overhead(this.argnames);
  13320. if (
  13321. !(
  13322. this.argnames.length === 1
  13323. && this.argnames[0] instanceof AST_Symbol
  13324. )
  13325. ) {
  13326. args_and_arrow += 2; // parens around the args
  13327. }
  13328. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  13329. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  13330. };
  13331. AST_Destructuring.prototype._size = () => 2;
  13332. AST_TemplateString.prototype._size = function () {
  13333. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  13334. };
  13335. AST_TemplateSegment.prototype._size = function () {
  13336. return this.value.length;
  13337. };
  13338. AST_Return.prototype._size = function () {
  13339. return this.value ? 7 : 6;
  13340. };
  13341. AST_Throw.prototype._size = () => 6;
  13342. AST_Break.prototype._size = function () {
  13343. return this.label ? 6 : 5;
  13344. };
  13345. AST_Continue.prototype._size = function () {
  13346. return this.label ? 9 : 8;
  13347. };
  13348. AST_If.prototype._size = () => 4;
  13349. AST_Switch.prototype._size = function () {
  13350. return 8 + list_overhead(this.body);
  13351. };
  13352. AST_Case.prototype._size = function () {
  13353. return 5 + list_overhead(this.body);
  13354. };
  13355. AST_Default.prototype._size = function () {
  13356. return 8 + list_overhead(this.body);
  13357. };
  13358. AST_Try.prototype._size = function () {
  13359. return 3 + list_overhead(this.body);
  13360. };
  13361. AST_Catch.prototype._size = function () {
  13362. let size = 7 + list_overhead(this.body);
  13363. if (this.argname) {
  13364. size += 2;
  13365. }
  13366. return size;
  13367. };
  13368. AST_Finally.prototype._size = function () {
  13369. return 7 + list_overhead(this.body);
  13370. };
  13371. AST_Var.prototype._size = function () {
  13372. return 4 + list_overhead(this.definitions);
  13373. };
  13374. AST_Let.prototype._size = function () {
  13375. return 4 + list_overhead(this.definitions);
  13376. };
  13377. AST_Const.prototype._size = function () {
  13378. return 6 + list_overhead(this.definitions);
  13379. };
  13380. AST_VarDef.prototype._size = function () {
  13381. return this.value ? 1 : 0;
  13382. };
  13383. AST_NameMapping.prototype._size = function () {
  13384. // foreign name isn't mangled
  13385. return this.name ? 4 : 0;
  13386. };
  13387. AST_Import.prototype._size = function () {
  13388. // import
  13389. let size = 6;
  13390. if (this.imported_name) size += 1;
  13391. // from
  13392. if (this.imported_name || this.imported_names) size += 5;
  13393. // braces, and the commas
  13394. if (this.imported_names) {
  13395. size += 2 + list_overhead(this.imported_names);
  13396. }
  13397. return size;
  13398. };
  13399. AST_ImportMeta.prototype._size = () => 11;
  13400. AST_Export.prototype._size = function () {
  13401. let size = 7 + (this.is_default ? 8 : 0);
  13402. if (this.exported_value) {
  13403. size += this.exported_value._size();
  13404. }
  13405. if (this.exported_names) {
  13406. // Braces and commas
  13407. size += 2 + list_overhead(this.exported_names);
  13408. }
  13409. if (this.module_name) {
  13410. // "from "
  13411. size += 5;
  13412. }
  13413. return size;
  13414. };
  13415. AST_Call.prototype._size = function () {
  13416. if (this.optional) {
  13417. return 4 + list_overhead(this.args);
  13418. }
  13419. return 2 + list_overhead(this.args);
  13420. };
  13421. AST_New.prototype._size = function () {
  13422. return 6 + list_overhead(this.args);
  13423. };
  13424. AST_Sequence.prototype._size = function () {
  13425. return list_overhead(this.expressions);
  13426. };
  13427. AST_Dot.prototype._size = function () {
  13428. if (this.optional) {
  13429. return this.property.length + 2;
  13430. }
  13431. return this.property.length + 1;
  13432. };
  13433. AST_DotHash.prototype._size = function () {
  13434. if (this.optional) {
  13435. return this.property.length + 3;
  13436. }
  13437. return this.property.length + 2;
  13438. };
  13439. AST_Sub.prototype._size = function () {
  13440. return this.optional ? 4 : 2;
  13441. };
  13442. AST_Unary.prototype._size = function () {
  13443. if (this.operator === "typeof") return 7;
  13444. if (this.operator === "void") return 5;
  13445. return this.operator.length;
  13446. };
  13447. AST_Binary.prototype._size = function (info) {
  13448. if (this.operator === "in") return 4;
  13449. let size = this.operator.length;
  13450. if (
  13451. (this.operator === "+" || this.operator === "-")
  13452. && this.right instanceof AST_Unary && this.right.operator === this.operator
  13453. ) {
  13454. // 1+ +a > needs space between the +
  13455. size += 1;
  13456. }
  13457. if (this.needs_parens(info)) {
  13458. size += 2;
  13459. }
  13460. return size;
  13461. };
  13462. AST_Conditional.prototype._size = () => 3;
  13463. AST_Array.prototype._size = function () {
  13464. return 2 + list_overhead(this.elements);
  13465. };
  13466. AST_Object.prototype._size = function (info) {
  13467. let base = 2;
  13468. if (first_in_statement(info)) {
  13469. base += 2; // parens
  13470. }
  13471. return base + list_overhead(this.properties);
  13472. };
  13473. /*#__INLINE__*/
  13474. const key_size = key =>
  13475. typeof key === "string" ? key.length : 0;
  13476. AST_ObjectKeyVal.prototype._size = function () {
  13477. return key_size(this.key) + 1;
  13478. };
  13479. /*#__INLINE__*/
  13480. const static_size = is_static => is_static ? 7 : 0;
  13481. AST_ObjectGetter.prototype._size = function () {
  13482. return 5 + static_size(this.static) + key_size(this.key);
  13483. };
  13484. AST_ObjectSetter.prototype._size = function () {
  13485. return 5 + static_size(this.static) + key_size(this.key);
  13486. };
  13487. AST_ConciseMethod.prototype._size = function () {
  13488. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  13489. };
  13490. AST_PrivateMethod.prototype._size = function () {
  13491. return AST_ConciseMethod.prototype._size.call(this) + 1;
  13492. };
  13493. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  13494. return AST_ConciseMethod.prototype._size.call(this) + 4;
  13495. };
  13496. AST_Class.prototype._size = function () {
  13497. return (
  13498. (this.name ? 8 : 7)
  13499. + (this.extends ? 8 : 0)
  13500. );
  13501. };
  13502. AST_ClassProperty.prototype._size = function () {
  13503. return (
  13504. static_size(this.static)
  13505. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  13506. + (this.value ? 1 : 0)
  13507. );
  13508. };
  13509. AST_ClassPrivateProperty.prototype._size = function () {
  13510. return AST_ClassProperty.prototype._size.call(this) + 1;
  13511. };
  13512. AST_Symbol.prototype._size = function () {
  13513. return !mangle_options || this.definition().unmangleable(mangle_options)
  13514. ? this.name.length
  13515. : 1;
  13516. };
  13517. // TODO take propmangle into account
  13518. AST_SymbolClassProperty.prototype._size = function () {
  13519. return this.name.length;
  13520. };
  13521. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  13522. const { name, thedef } = this;
  13523. if (thedef && thedef.global) return name.length;
  13524. if (name === "arguments") return 9;
  13525. return AST_Symbol.prototype._size.call(this);
  13526. };
  13527. AST_NewTarget.prototype._size = () => 10;
  13528. AST_SymbolImportForeign.prototype._size = function () {
  13529. return this.name.length;
  13530. };
  13531. AST_SymbolExportForeign.prototype._size = function () {
  13532. return this.name.length;
  13533. };
  13534. AST_This.prototype._size = () => 4;
  13535. AST_Super.prototype._size = () => 5;
  13536. AST_String.prototype._size = function () {
  13537. return this.value.length + 2;
  13538. };
  13539. AST_Number.prototype._size = function () {
  13540. const { value } = this;
  13541. if (value === 0) return 1;
  13542. if (value > 0 && Math.floor(value) === value) {
  13543. return Math.floor(Math.log10(value) + 1);
  13544. }
  13545. return value.toString().length;
  13546. };
  13547. AST_BigInt.prototype._size = function () {
  13548. return this.value.length;
  13549. };
  13550. AST_RegExp.prototype._size = function () {
  13551. return this.value.toString().length;
  13552. };
  13553. AST_Null.prototype._size = () => 4;
  13554. AST_NaN.prototype._size = () => 3;
  13555. AST_Undefined.prototype._size = () => 6; // "void 0"
  13556. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  13557. AST_Infinity.prototype._size = () => 8;
  13558. AST_True.prototype._size = () => 4;
  13559. AST_False.prototype._size = () => 5;
  13560. AST_Await.prototype._size = () => 6;
  13561. AST_Yield.prototype._size = () => 6;
  13562. /***********************************************************************
  13563. A JavaScript tokenizer / parser / beautifier / compressor.
  13564. https://github.com/mishoo/UglifyJS2
  13565. -------------------------------- (C) ---------------------------------
  13566. Author: Mihai Bazon
  13567. <mihai.bazon@gmail.com>
  13568. http://mihai.bazon.net/blog
  13569. Distributed under the BSD license:
  13570. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13571. Redistribution and use in source and binary forms, with or without
  13572. modification, are permitted provided that the following conditions
  13573. are met:
  13574. * Redistributions of source code must retain the above
  13575. copyright notice, this list of conditions and the following
  13576. disclaimer.
  13577. * Redistributions in binary form must reproduce the above
  13578. copyright notice, this list of conditions and the following
  13579. disclaimer in the documentation and/or other materials
  13580. provided with the distribution.
  13581. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13582. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13583. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13584. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13585. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13586. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13587. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13588. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13589. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13590. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13591. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13592. SUCH DAMAGE.
  13593. ***********************************************************************/
  13594. // bitfield flags to be stored in node.flags.
  13595. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  13596. const UNUSED = 0b00000001;
  13597. const TRUTHY = 0b00000010;
  13598. const FALSY = 0b00000100;
  13599. const UNDEFINED = 0b00001000;
  13600. const INLINED = 0b00010000;
  13601. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  13602. const WRITE_ONLY = 0b00100000;
  13603. // information specific to a single compression pass
  13604. const SQUEEZED = 0b0000000100000000;
  13605. const OPTIMIZED = 0b0000001000000000;
  13606. const TOP = 0b0000010000000000;
  13607. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  13608. const has_flag = (node, flag) => node.flags & flag;
  13609. const set_flag = (node, flag) => { node.flags |= flag; };
  13610. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  13611. /***********************************************************************
  13612. A JavaScript tokenizer / parser / beautifier / compressor.
  13613. https://github.com/mishoo/UglifyJS2
  13614. -------------------------------- (C) ---------------------------------
  13615. Author: Mihai Bazon
  13616. <mihai.bazon@gmail.com>
  13617. http://mihai.bazon.net/blog
  13618. Distributed under the BSD license:
  13619. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13620. Redistribution and use in source and binary forms, with or without
  13621. modification, are permitted provided that the following conditions
  13622. are met:
  13623. * Redistributions of source code must retain the above
  13624. copyright notice, this list of conditions and the following
  13625. disclaimer.
  13626. * Redistributions in binary form must reproduce the above
  13627. copyright notice, this list of conditions and the following
  13628. disclaimer in the documentation and/or other materials
  13629. provided with the distribution.
  13630. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13631. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13632. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13633. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13634. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13635. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13636. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13637. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13638. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13639. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13640. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13641. SUCH DAMAGE.
  13642. ***********************************************************************/
  13643. function merge_sequence(array, node) {
  13644. if (node instanceof AST_Sequence) {
  13645. array.push(...node.expressions);
  13646. } else {
  13647. array.push(node);
  13648. }
  13649. return array;
  13650. }
  13651. function make_sequence(orig, expressions) {
  13652. if (expressions.length == 1) return expressions[0];
  13653. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  13654. return make_node(AST_Sequence, orig, {
  13655. expressions: expressions.reduce(merge_sequence, [])
  13656. });
  13657. }
  13658. function make_node_from_constant(val, orig) {
  13659. switch (typeof val) {
  13660. case "string":
  13661. return make_node(AST_String, orig, {
  13662. value: val
  13663. });
  13664. case "number":
  13665. if (isNaN(val)) return make_node(AST_NaN, orig);
  13666. if (isFinite(val)) {
  13667. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  13668. operator: "-",
  13669. expression: make_node(AST_Number, orig, { value: -val })
  13670. }) : make_node(AST_Number, orig, { value: val });
  13671. }
  13672. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  13673. operator: "-",
  13674. expression: make_node(AST_Infinity, orig)
  13675. }) : make_node(AST_Infinity, orig);
  13676. case "boolean":
  13677. return make_node(val ? AST_True : AST_False, orig);
  13678. case "undefined":
  13679. return make_node(AST_Undefined, orig);
  13680. default:
  13681. if (val === null) {
  13682. return make_node(AST_Null, orig, { value: null });
  13683. }
  13684. if (val instanceof RegExp) {
  13685. return make_node(AST_RegExp, orig, {
  13686. value: {
  13687. source: regexp_source_fix(val.source),
  13688. flags: val.flags
  13689. }
  13690. });
  13691. }
  13692. throw new Error(string_template("Can't handle constant of type: {type}", {
  13693. type: typeof val
  13694. }));
  13695. }
  13696. }
  13697. function best_of_expression(ast1, ast2) {
  13698. return ast1.size() > ast2.size() ? ast2 : ast1;
  13699. }
  13700. function best_of_statement(ast1, ast2) {
  13701. return best_of_expression(
  13702. make_node(AST_SimpleStatement, ast1, {
  13703. body: ast1
  13704. }),
  13705. make_node(AST_SimpleStatement, ast2, {
  13706. body: ast2
  13707. })
  13708. ).body;
  13709. }
  13710. /** Find which node is smaller, and return that */
  13711. function best_of(compressor, ast1, ast2) {
  13712. if (first_in_statement(compressor)) {
  13713. return best_of_statement(ast1, ast2);
  13714. } else {
  13715. return best_of_expression(ast1, ast2);
  13716. }
  13717. }
  13718. /** Simplify an object property's key, if possible */
  13719. function get_simple_key(key) {
  13720. if (key instanceof AST_Constant) {
  13721. return key.getValue();
  13722. }
  13723. if (key instanceof AST_UnaryPrefix
  13724. && key.operator == "void"
  13725. && key.expression instanceof AST_Constant) {
  13726. return;
  13727. }
  13728. return key;
  13729. }
  13730. function read_property(obj, key) {
  13731. key = get_simple_key(key);
  13732. if (key instanceof AST_Node) return;
  13733. var value;
  13734. if (obj instanceof AST_Array) {
  13735. var elements = obj.elements;
  13736. if (key == "length") return make_node_from_constant(elements.length, obj);
  13737. if (typeof key == "number" && key in elements) value = elements[key];
  13738. } else if (obj instanceof AST_Object) {
  13739. key = "" + key;
  13740. var props = obj.properties;
  13741. for (var i = props.length; --i >= 0;) {
  13742. var prop = props[i];
  13743. if (!(prop instanceof AST_ObjectKeyVal)) return;
  13744. if (!value && props[i].key === key) value = props[i].value;
  13745. }
  13746. }
  13747. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  13748. }
  13749. function has_break_or_continue(loop, parent) {
  13750. var found = false;
  13751. var tw = new TreeWalker(function(node) {
  13752. if (found || node instanceof AST_Scope) return true;
  13753. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  13754. return found = true;
  13755. }
  13756. });
  13757. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  13758. tw.push(loop);
  13759. loop.body.walk(tw);
  13760. return found;
  13761. }
  13762. // we shouldn't compress (1,func)(something) to
  13763. // func(something) because that changes the meaning of
  13764. // the func (becomes lexical instead of global).
  13765. function maintain_this_binding(parent, orig, val) {
  13766. if (
  13767. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  13768. || parent instanceof AST_Call && parent.expression === orig
  13769. && (
  13770. val instanceof AST_PropAccess
  13771. || val instanceof AST_SymbolRef && val.name == "eval"
  13772. )
  13773. ) {
  13774. const zero = make_node(AST_Number, orig, { value: 0 });
  13775. return make_sequence(orig, [ zero, val ]);
  13776. } else {
  13777. return val;
  13778. }
  13779. }
  13780. function is_func_expr(node) {
  13781. return node instanceof AST_Arrow || node instanceof AST_Function;
  13782. }
  13783. function is_iife_call(node) {
  13784. // Used to determine whether the node can benefit from negation.
  13785. // Not the case with arrow functions (you need an extra set of parens).
  13786. if (node.TYPE != "Call") return false;
  13787. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  13788. }
  13789. function is_empty(thing) {
  13790. if (thing === null) return true;
  13791. if (thing instanceof AST_EmptyStatement) return true;
  13792. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  13793. return false;
  13794. }
  13795. const identifier_atom = makePredicate("Infinity NaN undefined");
  13796. function is_identifier_atom(node) {
  13797. return node instanceof AST_Infinity
  13798. || node instanceof AST_NaN
  13799. || node instanceof AST_Undefined;
  13800. }
  13801. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  13802. function is_ref_of(ref, type) {
  13803. if (!(ref instanceof AST_SymbolRef)) return false;
  13804. var orig = ref.definition().orig;
  13805. for (var i = orig.length; --i >= 0;) {
  13806. if (orig[i] instanceof type) return true;
  13807. }
  13808. }
  13809. // Can we turn { block contents... } into just the block contents ?
  13810. // Not if one of these is inside.
  13811. function can_be_evicted_from_block(node) {
  13812. return !(
  13813. node instanceof AST_DefClass ||
  13814. node instanceof AST_Defun ||
  13815. node instanceof AST_Let ||
  13816. node instanceof AST_Const ||
  13817. node instanceof AST_Export ||
  13818. node instanceof AST_Import
  13819. );
  13820. }
  13821. function as_statement_array(thing) {
  13822. if (thing === null) return [];
  13823. if (thing instanceof AST_BlockStatement) return thing.body;
  13824. if (thing instanceof AST_EmptyStatement) return [];
  13825. if (thing instanceof AST_Statement) return [ thing ];
  13826. throw new Error("Can't convert thing to statement array");
  13827. }
  13828. function is_reachable(scope_node, defs) {
  13829. const find_ref = node => {
  13830. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  13831. return walk_abort;
  13832. }
  13833. };
  13834. return walk_parent(scope_node, (node, info) => {
  13835. if (node instanceof AST_Scope && node !== scope_node) {
  13836. var parent = info.parent();
  13837. if (
  13838. parent instanceof AST_Call
  13839. && parent.expression === node
  13840. // Async/Generators aren't guaranteed to sync evaluate all of
  13841. // their body steps, so it's possible they close over the variable.
  13842. && !(node.async || node.is_generator)
  13843. ) {
  13844. return;
  13845. }
  13846. if (walk(node, find_ref)) return walk_abort;
  13847. return true;
  13848. }
  13849. });
  13850. }
  13851. /** Check if a ref refers to the name of a function/class it's defined within */
  13852. function is_recursive_ref(compressor, def) {
  13853. var node;
  13854. for (var i = 0; node = compressor.parent(i); i++) {
  13855. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  13856. var name = node.name;
  13857. if (name && name.definition() === def) {
  13858. return true;
  13859. }
  13860. }
  13861. }
  13862. return false;
  13863. }
  13864. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  13865. function retain_top_func(fn, compressor) {
  13866. return compressor.top_retain
  13867. && fn instanceof AST_Defun
  13868. && has_flag(fn, TOP)
  13869. && fn.name
  13870. && compressor.top_retain(fn.name);
  13871. }
  13872. /***********************************************************************
  13873. A JavaScript tokenizer / parser / beautifier / compressor.
  13874. https://github.com/mishoo/UglifyJS2
  13875. -------------------------------- (C) ---------------------------------
  13876. Author: Mihai Bazon
  13877. <mihai.bazon@gmail.com>
  13878. http://mihai.bazon.net/blog
  13879. Distributed under the BSD license:
  13880. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13881. Redistribution and use in source and binary forms, with or without
  13882. modification, are permitted provided that the following conditions
  13883. are met:
  13884. * Redistributions of source code must retain the above
  13885. copyright notice, this list of conditions and the following
  13886. disclaimer.
  13887. * Redistributions in binary form must reproduce the above
  13888. copyright notice, this list of conditions and the following
  13889. disclaimer in the documentation and/or other materials
  13890. provided with the distribution.
  13891. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13892. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13893. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13894. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13895. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13896. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13897. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13898. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13899. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13900. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13901. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13902. SUCH DAMAGE.
  13903. ***********************************************************************/
  13904. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  13905. // Note: Lots of methods and functions are missing here, in case they aren't pure
  13906. // or not available in all JS environments.
  13907. function make_nested_lookup(obj) {
  13908. const out = new Map();
  13909. for (var key of Object.keys(obj)) {
  13910. out.set(key, makePredicate(obj[key]));
  13911. }
  13912. const does_have = (global_name, fname) => {
  13913. const inner_map = out.get(global_name);
  13914. return inner_map != null && inner_map.has(fname);
  13915. };
  13916. return does_have;
  13917. }
  13918. // Objects which are safe to access without throwing or causing a side effect.
  13919. // Usually we'd check the `unsafe` option first but these are way too common for that
  13920. const pure_prop_access_globals = new Set([
  13921. "Number",
  13922. "String",
  13923. "Array",
  13924. "Object",
  13925. "Function",
  13926. "Promise",
  13927. ]);
  13928. const object_methods = [
  13929. "constructor",
  13930. "toString",
  13931. "valueOf",
  13932. ];
  13933. const is_pure_native_method = make_nested_lookup({
  13934. Array: [
  13935. "indexOf",
  13936. "join",
  13937. "lastIndexOf",
  13938. "slice",
  13939. ...object_methods,
  13940. ],
  13941. Boolean: object_methods,
  13942. Function: object_methods,
  13943. Number: [
  13944. "toExponential",
  13945. "toFixed",
  13946. "toPrecision",
  13947. ...object_methods,
  13948. ],
  13949. Object: object_methods,
  13950. RegExp: [
  13951. "test",
  13952. ...object_methods,
  13953. ],
  13954. String: [
  13955. "charAt",
  13956. "charCodeAt",
  13957. "concat",
  13958. "indexOf",
  13959. "italics",
  13960. "lastIndexOf",
  13961. "match",
  13962. "replace",
  13963. "search",
  13964. "slice",
  13965. "split",
  13966. "substr",
  13967. "substring",
  13968. "toLowerCase",
  13969. "toUpperCase",
  13970. "trim",
  13971. ...object_methods,
  13972. ],
  13973. });
  13974. const is_pure_native_fn = make_nested_lookup({
  13975. Array: [
  13976. "isArray",
  13977. ],
  13978. Math: [
  13979. "abs",
  13980. "acos",
  13981. "asin",
  13982. "atan",
  13983. "ceil",
  13984. "cos",
  13985. "exp",
  13986. "floor",
  13987. "log",
  13988. "round",
  13989. "sin",
  13990. "sqrt",
  13991. "tan",
  13992. "atan2",
  13993. "pow",
  13994. "max",
  13995. "min",
  13996. ],
  13997. Number: [
  13998. "isFinite",
  13999. "isNaN",
  14000. ],
  14001. Object: [
  14002. "create",
  14003. "getOwnPropertyDescriptor",
  14004. "getOwnPropertyNames",
  14005. "getPrototypeOf",
  14006. "isExtensible",
  14007. "isFrozen",
  14008. "isSealed",
  14009. "hasOwn",
  14010. "keys",
  14011. ],
  14012. String: [
  14013. "fromCharCode",
  14014. ],
  14015. });
  14016. // Known numeric values which come with JS environments
  14017. const is_pure_native_value = make_nested_lookup({
  14018. Math: [
  14019. "E",
  14020. "LN10",
  14021. "LN2",
  14022. "LOG2E",
  14023. "LOG10E",
  14024. "PI",
  14025. "SQRT1_2",
  14026. "SQRT2",
  14027. ],
  14028. Number: [
  14029. "MAX_VALUE",
  14030. "MIN_VALUE",
  14031. "NaN",
  14032. "NEGATIVE_INFINITY",
  14033. "POSITIVE_INFINITY",
  14034. ],
  14035. });
  14036. /***********************************************************************
  14037. A JavaScript tokenizer / parser / beautifier / compressor.
  14038. https://github.com/mishoo/UglifyJS2
  14039. -------------------------------- (C) ---------------------------------
  14040. Author: Mihai Bazon
  14041. <mihai.bazon@gmail.com>
  14042. http://mihai.bazon.net/blog
  14043. Distributed under the BSD license:
  14044. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14045. Redistribution and use in source and binary forms, with or without
  14046. modification, are permitted provided that the following conditions
  14047. are met:
  14048. * Redistributions of source code must retain the above
  14049. copyright notice, this list of conditions and the following
  14050. disclaimer.
  14051. * Redistributions in binary form must reproduce the above
  14052. copyright notice, this list of conditions and the following
  14053. disclaimer in the documentation and/or other materials
  14054. provided with the distribution.
  14055. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14056. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14057. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14058. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14059. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14060. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14061. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14062. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14063. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14064. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14065. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14066. SUCH DAMAGE.
  14067. ***********************************************************************/
  14068. // Functions and methods to infer certain facts about expressions
  14069. // It's not always possible to be 100% sure about something just by static analysis,
  14070. // so `true` means yes, and `false` means maybe
  14071. const is_undeclared_ref = (node) =>
  14072. node instanceof AST_SymbolRef && node.definition().undeclared;
  14073. const lazy_op = makePredicate("&& || ??");
  14074. const unary_side_effects = makePredicate("delete ++ --");
  14075. // methods to determine whether an expression has a boolean result type
  14076. (function(def_is_boolean) {
  14077. const unary_bool = makePredicate("! delete");
  14078. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  14079. def_is_boolean(AST_Node, return_false);
  14080. def_is_boolean(AST_UnaryPrefix, function() {
  14081. return unary_bool.has(this.operator);
  14082. });
  14083. def_is_boolean(AST_Binary, function() {
  14084. return binary_bool.has(this.operator)
  14085. || lazy_op.has(this.operator)
  14086. && this.left.is_boolean()
  14087. && this.right.is_boolean();
  14088. });
  14089. def_is_boolean(AST_Conditional, function() {
  14090. return this.consequent.is_boolean() && this.alternative.is_boolean();
  14091. });
  14092. def_is_boolean(AST_Assign, function() {
  14093. return this.operator == "=" && this.right.is_boolean();
  14094. });
  14095. def_is_boolean(AST_Sequence, function() {
  14096. return this.tail_node().is_boolean();
  14097. });
  14098. def_is_boolean(AST_True, return_true);
  14099. def_is_boolean(AST_False, return_true);
  14100. })(function(node, func) {
  14101. node.DEFMETHOD("is_boolean", func);
  14102. });
  14103. // methods to determine if an expression has a numeric result type
  14104. (function(def_is_number) {
  14105. def_is_number(AST_Node, return_false);
  14106. def_is_number(AST_Number, return_true);
  14107. const unary = makePredicate("+ - ~ ++ --");
  14108. def_is_number(AST_Unary, function() {
  14109. return unary.has(this.operator);
  14110. });
  14111. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  14112. def_is_number(AST_Binary, function(compressor) {
  14113. return numeric_ops.has(this.operator) || this.operator == "+"
  14114. && this.left.is_number(compressor)
  14115. && this.right.is_number(compressor);
  14116. });
  14117. def_is_number(AST_Assign, function(compressor) {
  14118. return numeric_ops.has(this.operator.slice(0, -1))
  14119. || this.operator == "=" && this.right.is_number(compressor);
  14120. });
  14121. def_is_number(AST_Sequence, function(compressor) {
  14122. return this.tail_node().is_number(compressor);
  14123. });
  14124. def_is_number(AST_Conditional, function(compressor) {
  14125. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  14126. });
  14127. })(function(node, func) {
  14128. node.DEFMETHOD("is_number", func);
  14129. });
  14130. // methods to determine if an expression has a string result type
  14131. (function(def_is_string) {
  14132. def_is_string(AST_Node, return_false);
  14133. def_is_string(AST_String, return_true);
  14134. def_is_string(AST_TemplateString, return_true);
  14135. def_is_string(AST_UnaryPrefix, function() {
  14136. return this.operator == "typeof";
  14137. });
  14138. def_is_string(AST_Binary, function(compressor) {
  14139. return this.operator == "+" &&
  14140. (this.left.is_string(compressor) || this.right.is_string(compressor));
  14141. });
  14142. def_is_string(AST_Assign, function(compressor) {
  14143. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  14144. });
  14145. def_is_string(AST_Sequence, function(compressor) {
  14146. return this.tail_node().is_string(compressor);
  14147. });
  14148. def_is_string(AST_Conditional, function(compressor) {
  14149. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  14150. });
  14151. })(function(node, func) {
  14152. node.DEFMETHOD("is_string", func);
  14153. });
  14154. function is_undefined(node, compressor) {
  14155. return (
  14156. has_flag(node, UNDEFINED)
  14157. || node instanceof AST_Undefined
  14158. || node instanceof AST_UnaryPrefix
  14159. && node.operator == "void"
  14160. && !node.expression.has_side_effects(compressor)
  14161. );
  14162. }
  14163. // Is the node explicitly null or undefined.
  14164. function is_null_or_undefined(node, compressor) {
  14165. let fixed;
  14166. return (
  14167. node instanceof AST_Null
  14168. || is_undefined(node, compressor)
  14169. || (
  14170. node instanceof AST_SymbolRef
  14171. && (fixed = node.definition().fixed) instanceof AST_Node
  14172. && is_nullish(fixed, compressor)
  14173. )
  14174. );
  14175. }
  14176. // Find out if this expression is optionally chained from a base-point that we
  14177. // can statically analyze as null or undefined.
  14178. function is_nullish_shortcircuited(node, compressor) {
  14179. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  14180. return (
  14181. (node.optional && is_null_or_undefined(node.expression, compressor))
  14182. || is_nullish_shortcircuited(node.expression, compressor)
  14183. );
  14184. }
  14185. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  14186. return false;
  14187. }
  14188. // Find out if something is == null, or can short circuit into nullish.
  14189. // Used to optimize ?. and ??
  14190. function is_nullish(node, compressor) {
  14191. if (is_null_or_undefined(node, compressor)) return true;
  14192. return is_nullish_shortcircuited(node, compressor);
  14193. }
  14194. // Determine if expression might cause side effects
  14195. // If there's a possibility that a node may change something when it's executed, this returns true
  14196. (function(def_has_side_effects) {
  14197. def_has_side_effects(AST_Node, return_true);
  14198. def_has_side_effects(AST_EmptyStatement, return_false);
  14199. def_has_side_effects(AST_Constant, return_false);
  14200. def_has_side_effects(AST_This, return_false);
  14201. function any(list, compressor) {
  14202. for (var i = list.length; --i >= 0;)
  14203. if (list[i].has_side_effects(compressor))
  14204. return true;
  14205. return false;
  14206. }
  14207. def_has_side_effects(AST_Block, function(compressor) {
  14208. return any(this.body, compressor);
  14209. });
  14210. def_has_side_effects(AST_Call, function(compressor) {
  14211. if (
  14212. !this.is_callee_pure(compressor)
  14213. && (!this.expression.is_call_pure(compressor)
  14214. || this.expression.has_side_effects(compressor))
  14215. ) {
  14216. return true;
  14217. }
  14218. return any(this.args, compressor);
  14219. });
  14220. def_has_side_effects(AST_Switch, function(compressor) {
  14221. return this.expression.has_side_effects(compressor)
  14222. || any(this.body, compressor);
  14223. });
  14224. def_has_side_effects(AST_Case, function(compressor) {
  14225. return this.expression.has_side_effects(compressor)
  14226. || any(this.body, compressor);
  14227. });
  14228. def_has_side_effects(AST_Try, function(compressor) {
  14229. return any(this.body, compressor)
  14230. || this.bcatch && this.bcatch.has_side_effects(compressor)
  14231. || this.bfinally && this.bfinally.has_side_effects(compressor);
  14232. });
  14233. def_has_side_effects(AST_If, function(compressor) {
  14234. return this.condition.has_side_effects(compressor)
  14235. || this.body && this.body.has_side_effects(compressor)
  14236. || this.alternative && this.alternative.has_side_effects(compressor);
  14237. });
  14238. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  14239. return this.body.has_side_effects(compressor);
  14240. });
  14241. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  14242. return this.body.has_side_effects(compressor);
  14243. });
  14244. def_has_side_effects(AST_Lambda, return_false);
  14245. def_has_side_effects(AST_Class, function (compressor) {
  14246. if (this.extends && this.extends.has_side_effects(compressor)) {
  14247. return true;
  14248. }
  14249. return any(this.properties, compressor);
  14250. });
  14251. def_has_side_effects(AST_Binary, function(compressor) {
  14252. return this.left.has_side_effects(compressor)
  14253. || this.right.has_side_effects(compressor);
  14254. });
  14255. def_has_side_effects(AST_Assign, return_true);
  14256. def_has_side_effects(AST_Conditional, function(compressor) {
  14257. return this.condition.has_side_effects(compressor)
  14258. || this.consequent.has_side_effects(compressor)
  14259. || this.alternative.has_side_effects(compressor);
  14260. });
  14261. def_has_side_effects(AST_Unary, function(compressor) {
  14262. return unary_side_effects.has(this.operator)
  14263. || this.expression.has_side_effects(compressor);
  14264. });
  14265. def_has_side_effects(AST_SymbolRef, function(compressor) {
  14266. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  14267. });
  14268. def_has_side_effects(AST_SymbolClassProperty, return_false);
  14269. def_has_side_effects(AST_SymbolDeclaration, return_false);
  14270. def_has_side_effects(AST_Object, function(compressor) {
  14271. return any(this.properties, compressor);
  14272. });
  14273. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  14274. return (
  14275. this.computed_key() && this.key.has_side_effects(compressor)
  14276. || this.value && this.value.has_side_effects(compressor)
  14277. );
  14278. });
  14279. def_has_side_effects(AST_ClassProperty, function(compressor) {
  14280. return (
  14281. this.computed_key() && this.key.has_side_effects(compressor)
  14282. || this.static && this.value && this.value.has_side_effects(compressor)
  14283. );
  14284. });
  14285. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  14286. return this.computed_key() && this.key.has_side_effects(compressor);
  14287. });
  14288. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  14289. return this.computed_key() && this.key.has_side_effects(compressor);
  14290. });
  14291. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  14292. return this.computed_key() && this.key.has_side_effects(compressor);
  14293. });
  14294. def_has_side_effects(AST_Array, function(compressor) {
  14295. return any(this.elements, compressor);
  14296. });
  14297. def_has_side_effects(AST_Dot, function(compressor) {
  14298. if (is_nullish(this, compressor)) return false;
  14299. return !this.optional && this.expression.may_throw_on_access(compressor)
  14300. || this.expression.has_side_effects(compressor);
  14301. });
  14302. def_has_side_effects(AST_Sub, function(compressor) {
  14303. if (is_nullish(this, compressor)) return false;
  14304. return !this.optional && this.expression.may_throw_on_access(compressor)
  14305. || this.expression.has_side_effects(compressor)
  14306. || this.property.has_side_effects(compressor);
  14307. });
  14308. def_has_side_effects(AST_Chain, function (compressor) {
  14309. return this.expression.has_side_effects(compressor);
  14310. });
  14311. def_has_side_effects(AST_Sequence, function(compressor) {
  14312. return any(this.expressions, compressor);
  14313. });
  14314. def_has_side_effects(AST_Definitions, function(compressor) {
  14315. return any(this.definitions, compressor);
  14316. });
  14317. def_has_side_effects(AST_VarDef, function() {
  14318. return this.value;
  14319. });
  14320. def_has_side_effects(AST_TemplateSegment, return_false);
  14321. def_has_side_effects(AST_TemplateString, function(compressor) {
  14322. return any(this.segments, compressor);
  14323. });
  14324. })(function(node, func) {
  14325. node.DEFMETHOD("has_side_effects", func);
  14326. });
  14327. // determine if expression may throw
  14328. (function(def_may_throw) {
  14329. def_may_throw(AST_Node, return_true);
  14330. def_may_throw(AST_Constant, return_false);
  14331. def_may_throw(AST_EmptyStatement, return_false);
  14332. def_may_throw(AST_Lambda, return_false);
  14333. def_may_throw(AST_SymbolDeclaration, return_false);
  14334. def_may_throw(AST_This, return_false);
  14335. function any(list, compressor) {
  14336. for (var i = list.length; --i >= 0;)
  14337. if (list[i].may_throw(compressor))
  14338. return true;
  14339. return false;
  14340. }
  14341. def_may_throw(AST_Class, function(compressor) {
  14342. if (this.extends && this.extends.may_throw(compressor)) return true;
  14343. return any(this.properties, compressor);
  14344. });
  14345. def_may_throw(AST_Array, function(compressor) {
  14346. return any(this.elements, compressor);
  14347. });
  14348. def_may_throw(AST_Assign, function(compressor) {
  14349. if (this.right.may_throw(compressor)) return true;
  14350. if (!compressor.has_directive("use strict")
  14351. && this.operator == "="
  14352. && this.left instanceof AST_SymbolRef) {
  14353. return false;
  14354. }
  14355. return this.left.may_throw(compressor);
  14356. });
  14357. def_may_throw(AST_Binary, function(compressor) {
  14358. return this.left.may_throw(compressor)
  14359. || this.right.may_throw(compressor);
  14360. });
  14361. def_may_throw(AST_Block, function(compressor) {
  14362. return any(this.body, compressor);
  14363. });
  14364. def_may_throw(AST_Call, function(compressor) {
  14365. if (is_nullish(this, compressor)) return false;
  14366. if (any(this.args, compressor)) return true;
  14367. if (this.is_callee_pure(compressor)) return false;
  14368. if (this.expression.may_throw(compressor)) return true;
  14369. return !(this.expression instanceof AST_Lambda)
  14370. || any(this.expression.body, compressor);
  14371. });
  14372. def_may_throw(AST_Case, function(compressor) {
  14373. return this.expression.may_throw(compressor)
  14374. || any(this.body, compressor);
  14375. });
  14376. def_may_throw(AST_Conditional, function(compressor) {
  14377. return this.condition.may_throw(compressor)
  14378. || this.consequent.may_throw(compressor)
  14379. || this.alternative.may_throw(compressor);
  14380. });
  14381. def_may_throw(AST_Definitions, function(compressor) {
  14382. return any(this.definitions, compressor);
  14383. });
  14384. def_may_throw(AST_If, function(compressor) {
  14385. return this.condition.may_throw(compressor)
  14386. || this.body && this.body.may_throw(compressor)
  14387. || this.alternative && this.alternative.may_throw(compressor);
  14388. });
  14389. def_may_throw(AST_LabeledStatement, function(compressor) {
  14390. return this.body.may_throw(compressor);
  14391. });
  14392. def_may_throw(AST_Object, function(compressor) {
  14393. return any(this.properties, compressor);
  14394. });
  14395. def_may_throw(AST_ObjectProperty, function(compressor) {
  14396. // TODO key may throw too
  14397. return this.value ? this.value.may_throw(compressor) : false;
  14398. });
  14399. def_may_throw(AST_ClassProperty, function(compressor) {
  14400. return (
  14401. this.computed_key() && this.key.may_throw(compressor)
  14402. || this.static && this.value && this.value.may_throw(compressor)
  14403. );
  14404. });
  14405. def_may_throw(AST_ConciseMethod, function(compressor) {
  14406. return this.computed_key() && this.key.may_throw(compressor);
  14407. });
  14408. def_may_throw(AST_ObjectGetter, function(compressor) {
  14409. return this.computed_key() && this.key.may_throw(compressor);
  14410. });
  14411. def_may_throw(AST_ObjectSetter, function(compressor) {
  14412. return this.computed_key() && this.key.may_throw(compressor);
  14413. });
  14414. def_may_throw(AST_Return, function(compressor) {
  14415. return this.value && this.value.may_throw(compressor);
  14416. });
  14417. def_may_throw(AST_Sequence, function(compressor) {
  14418. return any(this.expressions, compressor);
  14419. });
  14420. def_may_throw(AST_SimpleStatement, function(compressor) {
  14421. return this.body.may_throw(compressor);
  14422. });
  14423. def_may_throw(AST_Dot, function(compressor) {
  14424. if (is_nullish(this, compressor)) return false;
  14425. return !this.optional && this.expression.may_throw_on_access(compressor)
  14426. || this.expression.may_throw(compressor);
  14427. });
  14428. def_may_throw(AST_Sub, function(compressor) {
  14429. if (is_nullish(this, compressor)) return false;
  14430. return !this.optional && this.expression.may_throw_on_access(compressor)
  14431. || this.expression.may_throw(compressor)
  14432. || this.property.may_throw(compressor);
  14433. });
  14434. def_may_throw(AST_Chain, function(compressor) {
  14435. return this.expression.may_throw(compressor);
  14436. });
  14437. def_may_throw(AST_Switch, function(compressor) {
  14438. return this.expression.may_throw(compressor)
  14439. || any(this.body, compressor);
  14440. });
  14441. def_may_throw(AST_SymbolRef, function(compressor) {
  14442. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  14443. });
  14444. def_may_throw(AST_SymbolClassProperty, return_false);
  14445. def_may_throw(AST_Try, function(compressor) {
  14446. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  14447. || this.bfinally && this.bfinally.may_throw(compressor);
  14448. });
  14449. def_may_throw(AST_Unary, function(compressor) {
  14450. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  14451. return false;
  14452. return this.expression.may_throw(compressor);
  14453. });
  14454. def_may_throw(AST_VarDef, function(compressor) {
  14455. if (!this.value) return false;
  14456. return this.value.may_throw(compressor);
  14457. });
  14458. })(function(node, func) {
  14459. node.DEFMETHOD("may_throw", func);
  14460. });
  14461. // determine if expression is constant
  14462. (function(def_is_constant_expression) {
  14463. function all_refs_local(scope) {
  14464. let result = true;
  14465. walk(this, node => {
  14466. if (node instanceof AST_SymbolRef) {
  14467. if (has_flag(this, INLINED)) {
  14468. result = false;
  14469. return walk_abort;
  14470. }
  14471. var def = node.definition();
  14472. if (
  14473. member(def, this.enclosed)
  14474. && !this.variables.has(def.name)
  14475. ) {
  14476. if (scope) {
  14477. var scope_def = scope.find_variable(node);
  14478. if (def.undeclared ? !scope_def : scope_def === def) {
  14479. result = "f";
  14480. return true;
  14481. }
  14482. }
  14483. result = false;
  14484. return walk_abort;
  14485. }
  14486. return true;
  14487. }
  14488. if (node instanceof AST_This && this instanceof AST_Arrow) {
  14489. // TODO check arguments too!
  14490. result = false;
  14491. return walk_abort;
  14492. }
  14493. });
  14494. return result;
  14495. }
  14496. def_is_constant_expression(AST_Node, return_false);
  14497. def_is_constant_expression(AST_Constant, return_true);
  14498. def_is_constant_expression(AST_Class, function(scope) {
  14499. if (this.extends && !this.extends.is_constant_expression(scope)) {
  14500. return false;
  14501. }
  14502. for (const prop of this.properties) {
  14503. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  14504. return false;
  14505. }
  14506. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  14507. return false;
  14508. }
  14509. }
  14510. return all_refs_local.call(this, scope);
  14511. });
  14512. def_is_constant_expression(AST_Lambda, all_refs_local);
  14513. def_is_constant_expression(AST_Unary, function() {
  14514. return this.expression.is_constant_expression();
  14515. });
  14516. def_is_constant_expression(AST_Binary, function() {
  14517. return this.left.is_constant_expression()
  14518. && this.right.is_constant_expression();
  14519. });
  14520. def_is_constant_expression(AST_Array, function() {
  14521. return this.elements.every((l) => l.is_constant_expression());
  14522. });
  14523. def_is_constant_expression(AST_Object, function() {
  14524. return this.properties.every((l) => l.is_constant_expression());
  14525. });
  14526. def_is_constant_expression(AST_ObjectProperty, function() {
  14527. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  14528. });
  14529. })(function(node, func) {
  14530. node.DEFMETHOD("is_constant_expression", func);
  14531. });
  14532. // may_throw_on_access()
  14533. // returns true if this node may be null, undefined or contain `AST_Accessor`
  14534. (function(def_may_throw_on_access) {
  14535. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  14536. return !compressor.option("pure_getters")
  14537. || this._dot_throw(compressor);
  14538. });
  14539. function is_strict(compressor) {
  14540. return /strict/.test(compressor.option("pure_getters"));
  14541. }
  14542. def_may_throw_on_access(AST_Node, is_strict);
  14543. def_may_throw_on_access(AST_Null, return_true);
  14544. def_may_throw_on_access(AST_Undefined, return_true);
  14545. def_may_throw_on_access(AST_Constant, return_false);
  14546. def_may_throw_on_access(AST_Array, return_false);
  14547. def_may_throw_on_access(AST_Object, function(compressor) {
  14548. if (!is_strict(compressor)) return false;
  14549. for (var i = this.properties.length; --i >=0;)
  14550. if (this.properties[i]._dot_throw(compressor)) return true;
  14551. return false;
  14552. });
  14553. // Do not be as strict with classes as we are with objects.
  14554. // Hopefully the community is not going to abuse static getters and setters.
  14555. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  14556. def_may_throw_on_access(AST_Class, return_false);
  14557. def_may_throw_on_access(AST_ObjectProperty, return_false);
  14558. def_may_throw_on_access(AST_ObjectGetter, return_true);
  14559. def_may_throw_on_access(AST_Expansion, function(compressor) {
  14560. return this.expression._dot_throw(compressor);
  14561. });
  14562. def_may_throw_on_access(AST_Function, return_false);
  14563. def_may_throw_on_access(AST_Arrow, return_false);
  14564. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  14565. def_may_throw_on_access(AST_UnaryPrefix, function() {
  14566. return this.operator == "void";
  14567. });
  14568. def_may_throw_on_access(AST_Binary, function(compressor) {
  14569. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  14570. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  14571. });
  14572. def_may_throw_on_access(AST_Assign, function(compressor) {
  14573. if (this.logical) return true;
  14574. return this.operator == "="
  14575. && this.right._dot_throw(compressor);
  14576. });
  14577. def_may_throw_on_access(AST_Conditional, function(compressor) {
  14578. return this.consequent._dot_throw(compressor)
  14579. || this.alternative._dot_throw(compressor);
  14580. });
  14581. def_may_throw_on_access(AST_Dot, function(compressor) {
  14582. if (!is_strict(compressor)) return false;
  14583. if (this.property == "prototype") {
  14584. return !(
  14585. this.expression instanceof AST_Function
  14586. || this.expression instanceof AST_Class
  14587. );
  14588. }
  14589. return true;
  14590. });
  14591. def_may_throw_on_access(AST_Chain, function(compressor) {
  14592. return this.expression._dot_throw(compressor);
  14593. });
  14594. def_may_throw_on_access(AST_Sequence, function(compressor) {
  14595. return this.tail_node()._dot_throw(compressor);
  14596. });
  14597. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  14598. if (this.name === "arguments") return false;
  14599. if (has_flag(this, UNDEFINED)) return true;
  14600. if (!is_strict(compressor)) return false;
  14601. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  14602. if (this.is_immutable()) return false;
  14603. var fixed = this.fixed_value();
  14604. return !fixed || fixed._dot_throw(compressor);
  14605. });
  14606. })(function(node, func) {
  14607. node.DEFMETHOD("_dot_throw", func);
  14608. });
  14609. function is_lhs(node, parent) {
  14610. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  14611. if (parent instanceof AST_Assign && parent.left === node) return node;
  14612. }
  14613. (function(def_find_defs) {
  14614. function to_node(value, orig) {
  14615. if (value instanceof AST_Node) {
  14616. if (!(value instanceof AST_Constant)) {
  14617. // Value may be a function, an array including functions and even a complex assign / block expression,
  14618. // so it should never be shared in different places.
  14619. // Otherwise wrong information may be used in the compression phase
  14620. value = value.clone(true);
  14621. }
  14622. return make_node(value.CTOR, orig, value);
  14623. }
  14624. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  14625. elements: value.map(function(value) {
  14626. return to_node(value, orig);
  14627. })
  14628. });
  14629. if (value && typeof value == "object") {
  14630. var props = [];
  14631. for (var key in value) if (HOP(value, key)) {
  14632. props.push(make_node(AST_ObjectKeyVal, orig, {
  14633. key: key,
  14634. value: to_node(value[key], orig)
  14635. }));
  14636. }
  14637. return make_node(AST_Object, orig, {
  14638. properties: props
  14639. });
  14640. }
  14641. return make_node_from_constant(value, orig);
  14642. }
  14643. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  14644. if (!compressor.option("global_defs")) return this;
  14645. this.figure_out_scope({ ie8: compressor.option("ie8") });
  14646. return this.transform(new TreeTransformer(function(node) {
  14647. var def = node._find_defs(compressor, "");
  14648. if (!def) return;
  14649. var level = 0, child = node, parent;
  14650. while (parent = this.parent(level++)) {
  14651. if (!(parent instanceof AST_PropAccess)) break;
  14652. if (parent.expression !== child) break;
  14653. child = parent;
  14654. }
  14655. if (is_lhs(child, parent)) {
  14656. return;
  14657. }
  14658. return def;
  14659. }));
  14660. });
  14661. def_find_defs(AST_Node, noop);
  14662. def_find_defs(AST_Chain, function(compressor, suffix) {
  14663. return this.expression._find_defs(compressor, suffix);
  14664. });
  14665. def_find_defs(AST_Dot, function(compressor, suffix) {
  14666. return this.expression._find_defs(compressor, "." + this.property + suffix);
  14667. });
  14668. def_find_defs(AST_SymbolDeclaration, function() {
  14669. if (!this.global()) return;
  14670. });
  14671. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  14672. if (!this.global()) return;
  14673. var defines = compressor.option("global_defs");
  14674. var name = this.name + suffix;
  14675. if (HOP(defines, name)) return to_node(defines[name], this);
  14676. });
  14677. })(function(node, func) {
  14678. node.DEFMETHOD("_find_defs", func);
  14679. });
  14680. // method to negate an expression
  14681. (function(def_negate) {
  14682. function basic_negation(exp) {
  14683. return make_node(AST_UnaryPrefix, exp, {
  14684. operator: "!",
  14685. expression: exp
  14686. });
  14687. }
  14688. function best(orig, alt, first_in_statement) {
  14689. var negated = basic_negation(orig);
  14690. if (first_in_statement) {
  14691. var stat = make_node(AST_SimpleStatement, alt, {
  14692. body: alt
  14693. });
  14694. return best_of_expression(negated, stat) === stat ? alt : negated;
  14695. }
  14696. return best_of_expression(negated, alt);
  14697. }
  14698. def_negate(AST_Node, function() {
  14699. return basic_negation(this);
  14700. });
  14701. def_negate(AST_Statement, function() {
  14702. throw new Error("Cannot negate a statement");
  14703. });
  14704. def_negate(AST_Function, function() {
  14705. return basic_negation(this);
  14706. });
  14707. def_negate(AST_Arrow, function() {
  14708. return basic_negation(this);
  14709. });
  14710. def_negate(AST_UnaryPrefix, function() {
  14711. if (this.operator == "!")
  14712. return this.expression;
  14713. return basic_negation(this);
  14714. });
  14715. def_negate(AST_Sequence, function(compressor) {
  14716. var expressions = this.expressions.slice();
  14717. expressions.push(expressions.pop().negate(compressor));
  14718. return make_sequence(this, expressions);
  14719. });
  14720. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  14721. var self = this.clone();
  14722. self.consequent = self.consequent.negate(compressor);
  14723. self.alternative = self.alternative.negate(compressor);
  14724. return best(this, self, first_in_statement);
  14725. });
  14726. def_negate(AST_Binary, function(compressor, first_in_statement) {
  14727. var self = this.clone(), op = this.operator;
  14728. if (compressor.option("unsafe_comps")) {
  14729. switch (op) {
  14730. case "<=" : self.operator = ">" ; return self;
  14731. case "<" : self.operator = ">=" ; return self;
  14732. case ">=" : self.operator = "<" ; return self;
  14733. case ">" : self.operator = "<=" ; return self;
  14734. }
  14735. }
  14736. switch (op) {
  14737. case "==" : self.operator = "!="; return self;
  14738. case "!=" : self.operator = "=="; return self;
  14739. case "===": self.operator = "!=="; return self;
  14740. case "!==": self.operator = "==="; return self;
  14741. case "&&":
  14742. self.operator = "||";
  14743. self.left = self.left.negate(compressor, first_in_statement);
  14744. self.right = self.right.negate(compressor);
  14745. return best(this, self, first_in_statement);
  14746. case "||":
  14747. self.operator = "&&";
  14748. self.left = self.left.negate(compressor, first_in_statement);
  14749. self.right = self.right.negate(compressor);
  14750. return best(this, self, first_in_statement);
  14751. }
  14752. return basic_negation(this);
  14753. });
  14754. })(function(node, func) {
  14755. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  14756. return func.call(this, compressor, first_in_statement);
  14757. });
  14758. });
  14759. // Is the callee of this function pure?
  14760. var global_pure_fns = makePredicate("Boolean decodeURI decodeURIComponent Date encodeURI encodeURIComponent Error escape EvalError isFinite isNaN Number Object parseFloat parseInt RangeError ReferenceError String SyntaxError TypeError unescape URIError");
  14761. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  14762. if (compressor.option("unsafe")) {
  14763. var expr = this.expression;
  14764. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  14765. if (
  14766. expr.expression && expr.expression.name === "hasOwnProperty" &&
  14767. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  14768. ) {
  14769. return false;
  14770. }
  14771. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  14772. if (
  14773. expr instanceof AST_Dot
  14774. && is_undeclared_ref(expr.expression)
  14775. && is_pure_native_fn(expr.expression.name, expr.property)
  14776. ) {
  14777. return true;
  14778. }
  14779. }
  14780. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  14781. });
  14782. // If I call this, is it a pure function?
  14783. AST_Node.DEFMETHOD("is_call_pure", return_false);
  14784. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  14785. if (!compressor.option("unsafe")) return;
  14786. const expr = this.expression;
  14787. let native_obj;
  14788. if (expr instanceof AST_Array) {
  14789. native_obj = "Array";
  14790. } else if (expr.is_boolean()) {
  14791. native_obj = "Boolean";
  14792. } else if (expr.is_number(compressor)) {
  14793. native_obj = "Number";
  14794. } else if (expr instanceof AST_RegExp) {
  14795. native_obj = "RegExp";
  14796. } else if (expr.is_string(compressor)) {
  14797. native_obj = "String";
  14798. } else if (!this.may_throw_on_access(compressor)) {
  14799. native_obj = "Object";
  14800. }
  14801. return native_obj != null && is_pure_native_method(native_obj, this.property);
  14802. });
  14803. // tell me if a statement aborts
  14804. const aborts = (thing) => thing && thing.aborts();
  14805. (function(def_aborts) {
  14806. def_aborts(AST_Statement, return_null);
  14807. def_aborts(AST_Jump, return_this);
  14808. function block_aborts() {
  14809. for (var i = 0; i < this.body.length; i++) {
  14810. if (aborts(this.body[i])) {
  14811. return this.body[i];
  14812. }
  14813. }
  14814. return null;
  14815. }
  14816. def_aborts(AST_Import, function() { return null; });
  14817. def_aborts(AST_BlockStatement, block_aborts);
  14818. def_aborts(AST_SwitchBranch, block_aborts);
  14819. def_aborts(AST_If, function() {
  14820. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  14821. });
  14822. })(function(node, func) {
  14823. node.DEFMETHOD("aborts", func);
  14824. });
  14825. function is_modified(compressor, tw, node, value, level, immutable) {
  14826. var parent = tw.parent(level);
  14827. var lhs = is_lhs(node, parent);
  14828. if (lhs) return lhs;
  14829. if (!immutable
  14830. && parent instanceof AST_Call
  14831. && parent.expression === node
  14832. && !(value instanceof AST_Arrow)
  14833. && !(value instanceof AST_Class)
  14834. && !parent.is_callee_pure(compressor)
  14835. && (!(value instanceof AST_Function)
  14836. || !(parent instanceof AST_New) && value.contains_this())) {
  14837. return true;
  14838. }
  14839. if (parent instanceof AST_Array) {
  14840. return is_modified(compressor, tw, parent, parent, level + 1);
  14841. }
  14842. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14843. var obj = tw.parent(level + 1);
  14844. return is_modified(compressor, tw, obj, obj, level + 2);
  14845. }
  14846. if (parent instanceof AST_PropAccess && parent.expression === node) {
  14847. var prop = read_property(value, parent.property);
  14848. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  14849. }
  14850. }
  14851. /***********************************************************************
  14852. A JavaScript tokenizer / parser / beautifier / compressor.
  14853. https://github.com/mishoo/UglifyJS2
  14854. -------------------------------- (C) ---------------------------------
  14855. Author: Mihai Bazon
  14856. <mihai.bazon@gmail.com>
  14857. http://mihai.bazon.net/blog
  14858. Distributed under the BSD license:
  14859. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14860. Redistribution and use in source and binary forms, with or without
  14861. modification, are permitted provided that the following conditions
  14862. are met:
  14863. * Redistributions of source code must retain the above
  14864. copyright notice, this list of conditions and the following
  14865. disclaimer.
  14866. * Redistributions in binary form must reproduce the above
  14867. copyright notice, this list of conditions and the following
  14868. disclaimer in the documentation and/or other materials
  14869. provided with the distribution.
  14870. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14871. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14872. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14873. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14874. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14875. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14876. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14877. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14878. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14879. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14880. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14881. SUCH DAMAGE.
  14882. ***********************************************************************/
  14883. // methods to evaluate a constant expression
  14884. function def_eval(node, func) {
  14885. node.DEFMETHOD("_eval", func);
  14886. }
  14887. // Used to propagate a nullish short-circuit signal upwards through the chain.
  14888. const nullish = Symbol("This AST_Chain is nullish");
  14889. // If the node has been successfully reduced to a constant,
  14890. // then its value is returned; otherwise the element itself
  14891. // is returned.
  14892. // They can be distinguished as constant value is never a
  14893. // descendant of AST_Node.
  14894. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  14895. if (!compressor.option("evaluate"))
  14896. return this;
  14897. var val = this._eval(compressor, 1);
  14898. if (!val || val instanceof RegExp)
  14899. return val;
  14900. if (typeof val == "function" || typeof val == "object" || val == nullish)
  14901. return this;
  14902. return val;
  14903. });
  14904. var unaryPrefix = makePredicate("! ~ - + void");
  14905. AST_Node.DEFMETHOD("is_constant", function () {
  14906. // Accomodate when compress option evaluate=false
  14907. // as well as the common constant expressions !0 and -1
  14908. if (this instanceof AST_Constant) {
  14909. return !(this instanceof AST_RegExp);
  14910. } else {
  14911. return this instanceof AST_UnaryPrefix
  14912. && this.expression instanceof AST_Constant
  14913. && unaryPrefix.has(this.operator);
  14914. }
  14915. });
  14916. def_eval(AST_Statement, function () {
  14917. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  14918. });
  14919. def_eval(AST_Lambda, return_this);
  14920. def_eval(AST_Class, return_this);
  14921. def_eval(AST_Node, return_this);
  14922. def_eval(AST_Constant, function () {
  14923. return this.getValue();
  14924. });
  14925. def_eval(AST_BigInt, return_this);
  14926. def_eval(AST_RegExp, function (compressor) {
  14927. let evaluated = compressor.evaluated_regexps.get(this.value);
  14928. if (evaluated === undefined) {
  14929. try {
  14930. const { source, flags } = this.value;
  14931. evaluated = new RegExp(source, flags);
  14932. } catch (e) {
  14933. evaluated = null;
  14934. }
  14935. compressor.evaluated_regexps.set(this.value, evaluated);
  14936. }
  14937. return evaluated || this;
  14938. });
  14939. def_eval(AST_TemplateString, function () {
  14940. if (this.segments.length !== 1) return this;
  14941. return this.segments[0].value;
  14942. });
  14943. def_eval(AST_Function, function (compressor) {
  14944. if (compressor.option("unsafe")) {
  14945. var fn = function () { };
  14946. fn.node = this;
  14947. fn.toString = () => this.print_to_string();
  14948. return fn;
  14949. }
  14950. return this;
  14951. });
  14952. def_eval(AST_Array, function (compressor, depth) {
  14953. if (compressor.option("unsafe")) {
  14954. var elements = [];
  14955. for (var i = 0, len = this.elements.length; i < len; i++) {
  14956. var element = this.elements[i];
  14957. var value = element._eval(compressor, depth);
  14958. if (element === value)
  14959. return this;
  14960. elements.push(value);
  14961. }
  14962. return elements;
  14963. }
  14964. return this;
  14965. });
  14966. def_eval(AST_Object, function (compressor, depth) {
  14967. if (compressor.option("unsafe")) {
  14968. var val = {};
  14969. for (var i = 0, len = this.properties.length; i < len; i++) {
  14970. var prop = this.properties[i];
  14971. if (prop instanceof AST_Expansion)
  14972. return this;
  14973. var key = prop.key;
  14974. if (key instanceof AST_Symbol) {
  14975. key = key.name;
  14976. } else if (key instanceof AST_Node) {
  14977. key = key._eval(compressor, depth);
  14978. if (key === prop.key)
  14979. return this;
  14980. }
  14981. if (typeof Object.prototype[key] === "function") {
  14982. return this;
  14983. }
  14984. if (prop.value instanceof AST_Function)
  14985. continue;
  14986. val[key] = prop.value._eval(compressor, depth);
  14987. if (val[key] === prop.value)
  14988. return this;
  14989. }
  14990. return val;
  14991. }
  14992. return this;
  14993. });
  14994. var non_converting_unary = makePredicate("! typeof void");
  14995. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  14996. var e = this.expression;
  14997. // Function would be evaluated to an array and so typeof would
  14998. // incorrectly return 'object'. Hence making is a special case.
  14999. if (compressor.option("typeofs")
  15000. && this.operator == "typeof"
  15001. && (e instanceof AST_Lambda
  15002. || e instanceof AST_SymbolRef
  15003. && e.fixed_value() instanceof AST_Lambda)) {
  15004. return typeof function () { };
  15005. }
  15006. if (!non_converting_unary.has(this.operator))
  15007. depth++;
  15008. e = e._eval(compressor, depth);
  15009. if (e === this.expression)
  15010. return this;
  15011. switch (this.operator) {
  15012. case "!": return !e;
  15013. case "typeof":
  15014. // typeof <RegExp> returns "object" or "function" on different platforms
  15015. // so cannot evaluate reliably
  15016. if (e instanceof RegExp)
  15017. return this;
  15018. return typeof e;
  15019. case "void": return void e;
  15020. case "~": return ~e;
  15021. case "-": return -e;
  15022. case "+": return +e;
  15023. }
  15024. return this;
  15025. });
  15026. var non_converting_binary = makePredicate("&& || ?? === !==");
  15027. const identity_comparison = makePredicate("== != === !==");
  15028. const has_identity = value => typeof value === "object"
  15029. || typeof value === "function"
  15030. || typeof value === "symbol";
  15031. def_eval(AST_Binary, function (compressor, depth) {
  15032. if (!non_converting_binary.has(this.operator))
  15033. depth++;
  15034. var left = this.left._eval(compressor, depth);
  15035. if (left === this.left)
  15036. return this;
  15037. var right = this.right._eval(compressor, depth);
  15038. if (right === this.right)
  15039. return this;
  15040. var result;
  15041. if (left != null
  15042. && right != null
  15043. && identity_comparison.has(this.operator)
  15044. && has_identity(left)
  15045. && has_identity(right)
  15046. && typeof left === typeof right) {
  15047. // Do not compare by reference
  15048. return this;
  15049. }
  15050. switch (this.operator) {
  15051. case "&&": result = left && right; break;
  15052. case "||": result = left || right; break;
  15053. case "??": result = left != null ? left : right; break;
  15054. case "|": result = left | right; break;
  15055. case "&": result = left & right; break;
  15056. case "^": result = left ^ right; break;
  15057. case "+": result = left + right; break;
  15058. case "*": result = left * right; break;
  15059. case "**": result = Math.pow(left, right); break;
  15060. case "/": result = left / right; break;
  15061. case "%": result = left % right; break;
  15062. case "-": result = left - right; break;
  15063. case "<<": result = left << right; break;
  15064. case ">>": result = left >> right; break;
  15065. case ">>>": result = left >>> right; break;
  15066. case "==": result = left == right; break;
  15067. case "===": result = left === right; break;
  15068. case "!=": result = left != right; break;
  15069. case "!==": result = left !== right; break;
  15070. case "<": result = left < right; break;
  15071. case "<=": result = left <= right; break;
  15072. case ">": result = left > right; break;
  15073. case ">=": result = left >= right; break;
  15074. default:
  15075. return this;
  15076. }
  15077. if (isNaN(result) && compressor.find_parent(AST_With)) {
  15078. // leave original expression as is
  15079. return this;
  15080. }
  15081. return result;
  15082. });
  15083. def_eval(AST_Conditional, function (compressor, depth) {
  15084. var condition = this.condition._eval(compressor, depth);
  15085. if (condition === this.condition)
  15086. return this;
  15087. var node = condition ? this.consequent : this.alternative;
  15088. var value = node._eval(compressor, depth);
  15089. return value === node ? this : value;
  15090. });
  15091. // Set of AST_SymbolRef which are currently being evaluated.
  15092. // Avoids infinite recursion of ._eval()
  15093. const reentrant_ref_eval = new Set();
  15094. def_eval(AST_SymbolRef, function (compressor, depth) {
  15095. if (reentrant_ref_eval.has(this))
  15096. return this;
  15097. var fixed = this.fixed_value();
  15098. if (!fixed)
  15099. return this;
  15100. reentrant_ref_eval.add(this);
  15101. const value = fixed._eval(compressor, depth);
  15102. reentrant_ref_eval.delete(this);
  15103. if (value === fixed)
  15104. return this;
  15105. if (value && typeof value == "object") {
  15106. var escaped = this.definition().escaped;
  15107. if (escaped && depth > escaped)
  15108. return this;
  15109. }
  15110. return value;
  15111. });
  15112. const global_objs = { Array, Math, Number, Object, String };
  15113. const regexp_flags = new Set([
  15114. "dotAll",
  15115. "global",
  15116. "ignoreCase",
  15117. "multiline",
  15118. "sticky",
  15119. "unicode",
  15120. ]);
  15121. def_eval(AST_PropAccess, function (compressor, depth) {
  15122. const obj = this.expression._eval(compressor, depth);
  15123. if (obj === nullish || (this.optional && obj == null)) return nullish;
  15124. if (compressor.option("unsafe")) {
  15125. var key = this.property;
  15126. if (key instanceof AST_Node) {
  15127. key = key._eval(compressor, depth);
  15128. if (key === this.property)
  15129. return this;
  15130. }
  15131. var exp = this.expression;
  15132. var val;
  15133. if (is_undeclared_ref(exp)) {
  15134. var aa;
  15135. var first_arg = exp.name === "hasOwnProperty"
  15136. && key === "call"
  15137. && (aa = compressor.parent() && compressor.parent().args)
  15138. && (aa && aa[0]
  15139. && aa[0].evaluate(compressor));
  15140. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  15141. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  15142. return this.clone();
  15143. }
  15144. if (!is_pure_native_value(exp.name, key))
  15145. return this;
  15146. val = global_objs[exp.name];
  15147. } else {
  15148. val = exp._eval(compressor, depth + 1);
  15149. if (val instanceof RegExp) {
  15150. if (key == "source") {
  15151. return regexp_source_fix(val.source);
  15152. } else if (key == "flags" || regexp_flags.has(key)) {
  15153. return val[key];
  15154. }
  15155. }
  15156. if (!val || val === exp || !HOP(val, key))
  15157. return this;
  15158. if (typeof val == "function")
  15159. switch (key) {
  15160. case "name":
  15161. return val.node.name ? val.node.name.name : "";
  15162. case "length":
  15163. return val.node.length_property();
  15164. default:
  15165. return this;
  15166. }
  15167. }
  15168. return val[key];
  15169. }
  15170. return this;
  15171. });
  15172. def_eval(AST_Chain, function (compressor, depth) {
  15173. const evaluated = this.expression._eval(compressor, depth);
  15174. return evaluated === nullish
  15175. ? undefined
  15176. : evaluated === this.expression
  15177. ? this
  15178. : evaluated;
  15179. });
  15180. def_eval(AST_Call, function (compressor, depth) {
  15181. var exp = this.expression;
  15182. const callee = exp._eval(compressor, depth);
  15183. if (callee === nullish || (this.optional && callee == null)) return nullish;
  15184. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  15185. var key = exp.property;
  15186. if (key instanceof AST_Node) {
  15187. key = key._eval(compressor, depth);
  15188. if (key === exp.property)
  15189. return this;
  15190. }
  15191. var val;
  15192. var e = exp.expression;
  15193. if (is_undeclared_ref(e)) {
  15194. var first_arg = e.name === "hasOwnProperty" &&
  15195. key === "call" &&
  15196. (this.args[0] && this.args[0].evaluate(compressor));
  15197. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  15198. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  15199. return this.clone();
  15200. }
  15201. if (!is_pure_native_fn(e.name, key)) return this;
  15202. val = global_objs[e.name];
  15203. } else {
  15204. val = e._eval(compressor, depth + 1);
  15205. if (val === e || !val)
  15206. return this;
  15207. if (!is_pure_native_method(val.constructor.name, key))
  15208. return this;
  15209. }
  15210. var args = [];
  15211. for (var i = 0, len = this.args.length; i < len; i++) {
  15212. var arg = this.args[i];
  15213. var value = arg._eval(compressor, depth);
  15214. if (arg === value)
  15215. return this;
  15216. if (arg instanceof AST_Lambda)
  15217. return this;
  15218. args.push(value);
  15219. }
  15220. try {
  15221. return val[key].apply(val, args);
  15222. } catch (ex) {
  15223. // We don't really care
  15224. }
  15225. }
  15226. return this;
  15227. });
  15228. // Also a subclass of AST_Call
  15229. def_eval(AST_New, return_this);
  15230. /***********************************************************************
  15231. A JavaScript tokenizer / parser / beautifier / compressor.
  15232. https://github.com/mishoo/UglifyJS2
  15233. -------------------------------- (C) ---------------------------------
  15234. Author: Mihai Bazon
  15235. <mihai.bazon@gmail.com>
  15236. http://mihai.bazon.net/blog
  15237. Distributed under the BSD license:
  15238. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15239. Redistribution and use in source and binary forms, with or without
  15240. modification, are permitted provided that the following conditions
  15241. are met:
  15242. * Redistributions of source code must retain the above
  15243. copyright notice, this list of conditions and the following
  15244. disclaimer.
  15245. * Redistributions in binary form must reproduce the above
  15246. copyright notice, this list of conditions and the following
  15247. disclaimer in the documentation and/or other materials
  15248. provided with the distribution.
  15249. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15250. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15251. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15252. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15253. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15254. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15255. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15256. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15257. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15258. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15259. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15260. SUCH DAMAGE.
  15261. ***********************************************************************/
  15262. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  15263. // only about side effects. We'll be defining this method for each node type in this module
  15264. //
  15265. // Examples:
  15266. // foo++ -> foo++
  15267. // 1 + func() -> func()
  15268. // 10 -> (nothing)
  15269. // knownPureFunc(foo++) -> foo++
  15270. function def_drop_side_effect_free(node, func) {
  15271. node.DEFMETHOD("drop_side_effect_free", func);
  15272. }
  15273. // Drop side-effect-free elements from an array of expressions.
  15274. // Returns an array of expressions with side-effects or null
  15275. // if all elements were dropped. Note: original array may be
  15276. // returned if nothing changed.
  15277. function trim(nodes, compressor, first_in_statement) {
  15278. var len = nodes.length;
  15279. if (!len) return null;
  15280. var ret = [], changed = false;
  15281. for (var i = 0; i < len; i++) {
  15282. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  15283. changed |= node !== nodes[i];
  15284. if (node) {
  15285. ret.push(node);
  15286. first_in_statement = false;
  15287. }
  15288. }
  15289. return changed ? ret.length ? ret : null : nodes;
  15290. }
  15291. def_drop_side_effect_free(AST_Node, return_this);
  15292. def_drop_side_effect_free(AST_Constant, return_null);
  15293. def_drop_side_effect_free(AST_This, return_null);
  15294. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  15295. if (is_nullish_shortcircuited(this, compressor)) {
  15296. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15297. }
  15298. if (!this.is_callee_pure(compressor)) {
  15299. if (this.expression.is_call_pure(compressor)) {
  15300. var exprs = this.args.slice();
  15301. exprs.unshift(this.expression.expression);
  15302. exprs = trim(exprs, compressor, first_in_statement);
  15303. return exprs && make_sequence(this, exprs);
  15304. }
  15305. if (is_func_expr(this.expression)
  15306. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  15307. var node = this.clone();
  15308. node.expression.process_expression(false, compressor);
  15309. return node;
  15310. }
  15311. return this;
  15312. }
  15313. var args = trim(this.args, compressor, first_in_statement);
  15314. return args && make_sequence(this, args);
  15315. });
  15316. def_drop_side_effect_free(AST_Accessor, return_null);
  15317. def_drop_side_effect_free(AST_Function, return_null);
  15318. def_drop_side_effect_free(AST_Arrow, return_null);
  15319. def_drop_side_effect_free(AST_Class, function (compressor) {
  15320. const with_effects = [];
  15321. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  15322. if (trimmed_extends)
  15323. with_effects.push(trimmed_extends);
  15324. for (const prop of this.properties) {
  15325. const trimmed_prop = prop.drop_side_effect_free(compressor);
  15326. if (trimmed_prop)
  15327. with_effects.push(trimmed_prop);
  15328. }
  15329. if (!with_effects.length)
  15330. return null;
  15331. return make_sequence(this, with_effects);
  15332. });
  15333. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  15334. var right = this.right.drop_side_effect_free(compressor);
  15335. if (!right)
  15336. return this.left.drop_side_effect_free(compressor, first_in_statement);
  15337. if (lazy_op.has(this.operator)) {
  15338. if (right === this.right)
  15339. return this;
  15340. var node = this.clone();
  15341. node.right = right;
  15342. return node;
  15343. } else {
  15344. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  15345. if (!left)
  15346. return this.right.drop_side_effect_free(compressor, first_in_statement);
  15347. return make_sequence(this, [left, right]);
  15348. }
  15349. });
  15350. def_drop_side_effect_free(AST_Assign, function (compressor) {
  15351. if (this.logical)
  15352. return this;
  15353. var left = this.left;
  15354. if (left.has_side_effects(compressor)
  15355. || compressor.has_directive("use strict")
  15356. && left instanceof AST_PropAccess
  15357. && left.expression.is_constant()) {
  15358. return this;
  15359. }
  15360. set_flag(this, WRITE_ONLY);
  15361. while (left instanceof AST_PropAccess) {
  15362. left = left.expression;
  15363. }
  15364. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  15365. return this.right.drop_side_effect_free(compressor);
  15366. }
  15367. return this;
  15368. });
  15369. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  15370. var consequent = this.consequent.drop_side_effect_free(compressor);
  15371. var alternative = this.alternative.drop_side_effect_free(compressor);
  15372. if (consequent === this.consequent && alternative === this.alternative)
  15373. return this;
  15374. if (!consequent)
  15375. return alternative ? make_node(AST_Binary, this, {
  15376. operator: "||",
  15377. left: this.condition,
  15378. right: alternative
  15379. }) : this.condition.drop_side_effect_free(compressor);
  15380. if (!alternative)
  15381. return make_node(AST_Binary, this, {
  15382. operator: "&&",
  15383. left: this.condition,
  15384. right: consequent
  15385. });
  15386. var node = this.clone();
  15387. node.consequent = consequent;
  15388. node.alternative = alternative;
  15389. return node;
  15390. });
  15391. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  15392. if (unary_side_effects.has(this.operator)) {
  15393. if (!this.expression.has_side_effects(compressor)) {
  15394. set_flag(this, WRITE_ONLY);
  15395. } else {
  15396. clear_flag(this, WRITE_ONLY);
  15397. }
  15398. return this;
  15399. }
  15400. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  15401. return null;
  15402. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  15403. if (first_in_statement && expression && is_iife_call(expression)) {
  15404. if (expression === this.expression && this.operator == "!")
  15405. return this;
  15406. return expression.negate(compressor, first_in_statement);
  15407. }
  15408. return expression;
  15409. });
  15410. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  15411. const safe_access = this.is_declared(compressor)
  15412. || pure_prop_access_globals.has(this.name);
  15413. return safe_access ? null : this;
  15414. });
  15415. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  15416. var values = trim(this.properties, compressor, first_in_statement);
  15417. return values && make_sequence(this, values);
  15418. });
  15419. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  15420. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  15421. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  15422. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  15423. if (key && value) {
  15424. return make_sequence(this, [key, value]);
  15425. }
  15426. return key || value;
  15427. });
  15428. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  15429. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  15430. const value = this.static && this.value
  15431. && this.value.drop_side_effect_free(compressor);
  15432. if (key && value)
  15433. return make_sequence(this, [key, value]);
  15434. return key || value || null;
  15435. });
  15436. def_drop_side_effect_free(AST_ConciseMethod, function () {
  15437. return this.computed_key() ? this.key : null;
  15438. });
  15439. def_drop_side_effect_free(AST_ObjectGetter, function () {
  15440. return this.computed_key() ? this.key : null;
  15441. });
  15442. def_drop_side_effect_free(AST_ObjectSetter, function () {
  15443. return this.computed_key() ? this.key : null;
  15444. });
  15445. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  15446. var values = trim(this.elements, compressor, first_in_statement);
  15447. return values && make_sequence(this, values);
  15448. });
  15449. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  15450. if (is_nullish_shortcircuited(this, compressor)) {
  15451. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15452. }
  15453. if (this.expression.may_throw_on_access(compressor)) return this;
  15454. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15455. });
  15456. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  15457. if (is_nullish_shortcircuited(this, compressor)) {
  15458. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15459. }
  15460. if (this.expression.may_throw_on_access(compressor)) return this;
  15461. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  15462. if (!expression)
  15463. return this.property.drop_side_effect_free(compressor, first_in_statement);
  15464. var property = this.property.drop_side_effect_free(compressor);
  15465. if (!property)
  15466. return expression;
  15467. return make_sequence(this, [expression, property]);
  15468. });
  15469. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  15470. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15471. });
  15472. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  15473. var last = this.tail_node();
  15474. var expr = last.drop_side_effect_free(compressor);
  15475. if (expr === last)
  15476. return this;
  15477. var expressions = this.expressions.slice(0, -1);
  15478. if (expr)
  15479. expressions.push(expr);
  15480. if (!expressions.length) {
  15481. return make_node(AST_Number, this, { value: 0 });
  15482. }
  15483. return make_sequence(this, expressions);
  15484. });
  15485. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  15486. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15487. });
  15488. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  15489. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  15490. var values = trim(this.segments, compressor, first_in_statement);
  15491. return values && make_sequence(this, values);
  15492. });
  15493. /***********************************************************************
  15494. A JavaScript tokenizer / parser / beautifier / compressor.
  15495. https://github.com/mishoo/UglifyJS2
  15496. -------------------------------- (C) ---------------------------------
  15497. Author: Mihai Bazon
  15498. <mihai.bazon@gmail.com>
  15499. http://mihai.bazon.net/blog
  15500. Distributed under the BSD license:
  15501. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15502. Redistribution and use in source and binary forms, with or without
  15503. modification, are permitted provided that the following conditions
  15504. are met:
  15505. * Redistributions of source code must retain the above
  15506. copyright notice, this list of conditions and the following
  15507. disclaimer.
  15508. * Redistributions in binary form must reproduce the above
  15509. copyright notice, this list of conditions and the following
  15510. disclaimer in the documentation and/or other materials
  15511. provided with the distribution.
  15512. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15513. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15514. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15515. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15516. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15517. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15518. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15519. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15520. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15521. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15522. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15523. SUCH DAMAGE.
  15524. ***********************************************************************/
  15525. // Define the method AST_Node#reduce_vars, which goes through the AST in
  15526. // execution order to perform basic flow analysis
  15527. function def_reduce_vars(node, func) {
  15528. node.DEFMETHOD("reduce_vars", func);
  15529. }
  15530. def_reduce_vars(AST_Node, noop);
  15531. function reset_def(compressor, def) {
  15532. def.assignments = 0;
  15533. def.chained = false;
  15534. def.direct_access = false;
  15535. def.escaped = 0;
  15536. def.recursive_refs = 0;
  15537. def.references = [];
  15538. def.single_use = undefined;
  15539. if (def.scope.pinned()) {
  15540. def.fixed = false;
  15541. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  15542. def.fixed = def.init;
  15543. } else {
  15544. def.fixed = false;
  15545. }
  15546. }
  15547. function reset_variables(tw, compressor, node) {
  15548. node.variables.forEach(function(def) {
  15549. reset_def(compressor, def);
  15550. if (def.fixed === null) {
  15551. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  15552. mark(tw, def, true);
  15553. } else if (def.fixed) {
  15554. tw.loop_ids.set(def.id, tw.in_loop);
  15555. mark(tw, def, true);
  15556. }
  15557. });
  15558. }
  15559. function reset_block_variables(compressor, node) {
  15560. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  15561. reset_def(compressor, def);
  15562. });
  15563. }
  15564. function push(tw) {
  15565. tw.safe_ids = Object.create(tw.safe_ids);
  15566. }
  15567. function pop(tw) {
  15568. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  15569. }
  15570. function mark(tw, def, safe) {
  15571. tw.safe_ids[def.id] = safe;
  15572. }
  15573. function safe_to_read(tw, def) {
  15574. if (def.single_use == "m") return false;
  15575. if (tw.safe_ids[def.id]) {
  15576. if (def.fixed == null) {
  15577. var orig = def.orig[0];
  15578. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  15579. def.fixed = make_node(AST_Undefined, orig);
  15580. }
  15581. return true;
  15582. }
  15583. return def.fixed instanceof AST_Defun;
  15584. }
  15585. function safe_to_assign(tw, def, scope, value) {
  15586. if (def.fixed === undefined) return true;
  15587. let def_safe_ids;
  15588. if (def.fixed === null
  15589. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  15590. ) {
  15591. def_safe_ids[def.id] = false;
  15592. tw.defs_to_safe_ids.delete(def.id);
  15593. return true;
  15594. }
  15595. if (!HOP(tw.safe_ids, def.id)) return false;
  15596. if (!safe_to_read(tw, def)) return false;
  15597. if (def.fixed === false) return false;
  15598. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  15599. if (def.fixed instanceof AST_Defun) {
  15600. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  15601. }
  15602. return def.orig.every((sym) => {
  15603. return !(sym instanceof AST_SymbolConst
  15604. || sym instanceof AST_SymbolDefun
  15605. || sym instanceof AST_SymbolLambda);
  15606. });
  15607. }
  15608. function ref_once(tw, compressor, def) {
  15609. return compressor.option("unused")
  15610. && !def.scope.pinned()
  15611. && def.references.length - def.recursive_refs == 1
  15612. && tw.loop_ids.get(def.id) === tw.in_loop;
  15613. }
  15614. function is_immutable(value) {
  15615. if (!value) return false;
  15616. return value.is_constant()
  15617. || value instanceof AST_Lambda
  15618. || value instanceof AST_This;
  15619. }
  15620. // A definition "escapes" when its value can leave the point of use.
  15621. // Example: `a = b || c`
  15622. // In this example, "b" and "c" are escaping, because they're going into "a"
  15623. //
  15624. // def.escaped is != 0 when it escapes.
  15625. //
  15626. // When greater than 1, it means that N chained properties will be read off
  15627. // of that def before an escape occurs. This is useful for evaluating
  15628. // property accesses, where you need to know when to stop.
  15629. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  15630. var parent = tw.parent(level);
  15631. if (value) {
  15632. if (value.is_constant()) return;
  15633. if (value instanceof AST_ClassExpression) return;
  15634. }
  15635. if (
  15636. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  15637. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  15638. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  15639. || parent instanceof AST_VarDef && node === parent.value
  15640. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  15641. ) {
  15642. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  15643. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  15644. return;
  15645. } else if (
  15646. parent instanceof AST_Array
  15647. || parent instanceof AST_Await
  15648. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  15649. || parent instanceof AST_Conditional && node !== parent.condition
  15650. || parent instanceof AST_Expansion
  15651. || parent instanceof AST_Sequence && node === parent.tail_node()
  15652. ) {
  15653. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  15654. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  15655. var obj = tw.parent(level + 1);
  15656. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  15657. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  15658. value = read_property(value, parent.property);
  15659. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  15660. if (value) return;
  15661. }
  15662. if (level > 0) return;
  15663. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  15664. if (parent instanceof AST_SimpleStatement) return;
  15665. d.direct_access = true;
  15666. }
  15667. const suppress = node => walk(node, node => {
  15668. if (!(node instanceof AST_Symbol)) return;
  15669. var d = node.definition();
  15670. if (!d) return;
  15671. if (node instanceof AST_SymbolRef) d.references.push(node);
  15672. d.fixed = false;
  15673. });
  15674. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  15675. push(tw);
  15676. reset_variables(tw, compressor, this);
  15677. descend();
  15678. pop(tw);
  15679. return true;
  15680. });
  15681. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  15682. var node = this;
  15683. if (node.left instanceof AST_Destructuring) {
  15684. suppress(node.left);
  15685. return;
  15686. }
  15687. const finish_walk = () => {
  15688. if (node.logical) {
  15689. node.left.walk(tw);
  15690. push(tw);
  15691. node.right.walk(tw);
  15692. pop(tw);
  15693. return true;
  15694. }
  15695. };
  15696. var sym = node.left;
  15697. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  15698. var def = sym.definition();
  15699. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  15700. def.assignments++;
  15701. if (!safe) return finish_walk();
  15702. var fixed = def.fixed;
  15703. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  15704. var eq = node.operator == "=";
  15705. var value = eq ? node.right : node;
  15706. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  15707. def.references.push(sym);
  15708. if (!node.logical) {
  15709. if (!eq) def.chained = true;
  15710. def.fixed = eq ? function() {
  15711. return node.right;
  15712. } : function() {
  15713. return make_node(AST_Binary, node, {
  15714. operator: node.operator.slice(0, -1),
  15715. left: fixed instanceof AST_Node ? fixed : fixed(),
  15716. right: node.right
  15717. });
  15718. };
  15719. }
  15720. if (node.logical) {
  15721. mark(tw, def, false);
  15722. push(tw);
  15723. node.right.walk(tw);
  15724. pop(tw);
  15725. return true;
  15726. }
  15727. mark(tw, def, false);
  15728. node.right.walk(tw);
  15729. mark(tw, def, true);
  15730. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  15731. return true;
  15732. });
  15733. def_reduce_vars(AST_Binary, function(tw) {
  15734. if (!lazy_op.has(this.operator)) return;
  15735. this.left.walk(tw);
  15736. push(tw);
  15737. this.right.walk(tw);
  15738. pop(tw);
  15739. return true;
  15740. });
  15741. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  15742. reset_block_variables(compressor, this);
  15743. });
  15744. def_reduce_vars(AST_Case, function(tw) {
  15745. push(tw);
  15746. this.expression.walk(tw);
  15747. pop(tw);
  15748. push(tw);
  15749. walk_body(this, tw);
  15750. pop(tw);
  15751. return true;
  15752. });
  15753. def_reduce_vars(AST_Class, function(tw, descend) {
  15754. clear_flag(this, INLINED);
  15755. push(tw);
  15756. descend();
  15757. pop(tw);
  15758. return true;
  15759. });
  15760. def_reduce_vars(AST_Conditional, function(tw) {
  15761. this.condition.walk(tw);
  15762. push(tw);
  15763. this.consequent.walk(tw);
  15764. pop(tw);
  15765. push(tw);
  15766. this.alternative.walk(tw);
  15767. pop(tw);
  15768. return true;
  15769. });
  15770. def_reduce_vars(AST_Chain, function(tw, descend) {
  15771. // Chains' conditions apply left-to-right, cumulatively.
  15772. // If we walk normally we don't go in that order because we would pop before pushing again
  15773. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  15774. // Then we pop everything when they are done being walked.
  15775. const safe_ids = tw.safe_ids;
  15776. descend();
  15777. // Unroll back to start
  15778. tw.safe_ids = safe_ids;
  15779. return true;
  15780. });
  15781. def_reduce_vars(AST_Call, function (tw) {
  15782. this.expression.walk(tw);
  15783. if (this.optional) {
  15784. // Never pop -- it's popped at AST_Chain above
  15785. push(tw);
  15786. }
  15787. for (const arg of this.args) arg.walk(tw);
  15788. return true;
  15789. });
  15790. def_reduce_vars(AST_PropAccess, function (tw) {
  15791. if (!this.optional) return;
  15792. this.expression.walk(tw);
  15793. // Never pop -- it's popped at AST_Chain above
  15794. push(tw);
  15795. if (this.property instanceof AST_Node) this.property.walk(tw);
  15796. return true;
  15797. });
  15798. def_reduce_vars(AST_Default, function(tw, descend) {
  15799. push(tw);
  15800. descend();
  15801. pop(tw);
  15802. return true;
  15803. });
  15804. function mark_lambda(tw, descend, compressor) {
  15805. clear_flag(this, INLINED);
  15806. push(tw);
  15807. reset_variables(tw, compressor, this);
  15808. if (this.uses_arguments) {
  15809. descend();
  15810. pop(tw);
  15811. return;
  15812. }
  15813. var iife;
  15814. if (!this.name
  15815. && (iife = tw.parent()) instanceof AST_Call
  15816. && iife.expression === this
  15817. && !iife.args.some(arg => arg instanceof AST_Expansion)
  15818. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  15819. ) {
  15820. // Virtually turn IIFE parameters into variable definitions:
  15821. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  15822. // So existing transformation rules can work on them.
  15823. this.argnames.forEach((arg, i) => {
  15824. if (!arg.definition) return;
  15825. var d = arg.definition();
  15826. // Avoid setting fixed when there's more than one origin for a variable value
  15827. if (d.orig.length > 1) return;
  15828. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  15829. d.fixed = function() {
  15830. return iife.args[i] || make_node(AST_Undefined, iife);
  15831. };
  15832. tw.loop_ids.set(d.id, tw.in_loop);
  15833. mark(tw, d, true);
  15834. } else {
  15835. d.fixed = false;
  15836. }
  15837. });
  15838. }
  15839. descend();
  15840. pop(tw);
  15841. return true;
  15842. }
  15843. def_reduce_vars(AST_Lambda, mark_lambda);
  15844. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  15845. reset_block_variables(compressor, this);
  15846. const saved_loop = tw.in_loop;
  15847. tw.in_loop = this;
  15848. push(tw);
  15849. this.body.walk(tw);
  15850. if (has_break_or_continue(this)) {
  15851. pop(tw);
  15852. push(tw);
  15853. }
  15854. this.condition.walk(tw);
  15855. pop(tw);
  15856. tw.in_loop = saved_loop;
  15857. return true;
  15858. });
  15859. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  15860. reset_block_variables(compressor, this);
  15861. if (this.init) this.init.walk(tw);
  15862. const saved_loop = tw.in_loop;
  15863. tw.in_loop = this;
  15864. push(tw);
  15865. if (this.condition) this.condition.walk(tw);
  15866. this.body.walk(tw);
  15867. if (this.step) {
  15868. if (has_break_or_continue(this)) {
  15869. pop(tw);
  15870. push(tw);
  15871. }
  15872. this.step.walk(tw);
  15873. }
  15874. pop(tw);
  15875. tw.in_loop = saved_loop;
  15876. return true;
  15877. });
  15878. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  15879. reset_block_variables(compressor, this);
  15880. suppress(this.init);
  15881. this.object.walk(tw);
  15882. const saved_loop = tw.in_loop;
  15883. tw.in_loop = this;
  15884. push(tw);
  15885. this.body.walk(tw);
  15886. pop(tw);
  15887. tw.in_loop = saved_loop;
  15888. return true;
  15889. });
  15890. def_reduce_vars(AST_If, function(tw) {
  15891. this.condition.walk(tw);
  15892. push(tw);
  15893. this.body.walk(tw);
  15894. pop(tw);
  15895. if (this.alternative) {
  15896. push(tw);
  15897. this.alternative.walk(tw);
  15898. pop(tw);
  15899. }
  15900. return true;
  15901. });
  15902. def_reduce_vars(AST_LabeledStatement, function(tw) {
  15903. push(tw);
  15904. this.body.walk(tw);
  15905. pop(tw);
  15906. return true;
  15907. });
  15908. def_reduce_vars(AST_SymbolCatch, function() {
  15909. this.definition().fixed = false;
  15910. });
  15911. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  15912. var d = this.definition();
  15913. d.references.push(this);
  15914. if (d.references.length == 1
  15915. && !d.fixed
  15916. && d.orig[0] instanceof AST_SymbolDefun) {
  15917. tw.loop_ids.set(d.id, tw.in_loop);
  15918. }
  15919. var fixed_value;
  15920. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  15921. d.fixed = false;
  15922. } else if (d.fixed) {
  15923. fixed_value = this.fixed_value();
  15924. if (
  15925. fixed_value instanceof AST_Lambda
  15926. && is_recursive_ref(tw, d)
  15927. ) {
  15928. d.recursive_refs++;
  15929. } else if (fixed_value
  15930. && !compressor.exposed(d)
  15931. && ref_once(tw, compressor, d)
  15932. ) {
  15933. d.single_use =
  15934. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  15935. || fixed_value instanceof AST_Class
  15936. || d.scope === this.scope && fixed_value.is_constant_expression();
  15937. } else {
  15938. d.single_use = false;
  15939. }
  15940. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  15941. if (d.single_use) {
  15942. d.single_use = "m";
  15943. } else {
  15944. d.fixed = false;
  15945. }
  15946. }
  15947. }
  15948. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  15949. });
  15950. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  15951. this.globals.forEach(function(def) {
  15952. reset_def(compressor, def);
  15953. });
  15954. reset_variables(tw, compressor, this);
  15955. });
  15956. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  15957. reset_block_variables(compressor, this);
  15958. push(tw);
  15959. walk_body(this, tw);
  15960. pop(tw);
  15961. if (this.bcatch) {
  15962. push(tw);
  15963. this.bcatch.walk(tw);
  15964. pop(tw);
  15965. }
  15966. if (this.bfinally) this.bfinally.walk(tw);
  15967. return true;
  15968. });
  15969. def_reduce_vars(AST_Unary, function(tw) {
  15970. var node = this;
  15971. if (node.operator !== "++" && node.operator !== "--") return;
  15972. var exp = node.expression;
  15973. if (!(exp instanceof AST_SymbolRef)) return;
  15974. var def = exp.definition();
  15975. var safe = safe_to_assign(tw, def, exp.scope, true);
  15976. def.assignments++;
  15977. if (!safe) return;
  15978. var fixed = def.fixed;
  15979. if (!fixed) return;
  15980. def.references.push(exp);
  15981. def.chained = true;
  15982. def.fixed = function() {
  15983. return make_node(AST_Binary, node, {
  15984. operator: node.operator.slice(0, -1),
  15985. left: make_node(AST_UnaryPrefix, node, {
  15986. operator: "+",
  15987. expression: fixed instanceof AST_Node ? fixed : fixed()
  15988. }),
  15989. right: make_node(AST_Number, node, {
  15990. value: 1
  15991. })
  15992. });
  15993. };
  15994. mark(tw, def, true);
  15995. return true;
  15996. });
  15997. def_reduce_vars(AST_VarDef, function(tw, descend) {
  15998. var node = this;
  15999. if (node.name instanceof AST_Destructuring) {
  16000. suppress(node.name);
  16001. return;
  16002. }
  16003. var d = node.name.definition();
  16004. if (node.value) {
  16005. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  16006. d.fixed = function() {
  16007. return node.value;
  16008. };
  16009. tw.loop_ids.set(d.id, tw.in_loop);
  16010. mark(tw, d, false);
  16011. descend();
  16012. mark(tw, d, true);
  16013. return true;
  16014. } else {
  16015. d.fixed = false;
  16016. }
  16017. }
  16018. });
  16019. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  16020. reset_block_variables(compressor, this);
  16021. const saved_loop = tw.in_loop;
  16022. tw.in_loop = this;
  16023. push(tw);
  16024. descend();
  16025. pop(tw);
  16026. tw.in_loop = saved_loop;
  16027. return true;
  16028. });
  16029. /***********************************************************************
  16030. A JavaScript tokenizer / parser / beautifier / compressor.
  16031. https://github.com/mishoo/UglifyJS2
  16032. -------------------------------- (C) ---------------------------------
  16033. Author: Mihai Bazon
  16034. <mihai.bazon@gmail.com>
  16035. http://mihai.bazon.net/blog
  16036. Distributed under the BSD license:
  16037. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16038. Redistribution and use in source and binary forms, with or without
  16039. modification, are permitted provided that the following conditions
  16040. are met:
  16041. * Redistributions of source code must retain the above
  16042. copyright notice, this list of conditions and the following
  16043. disclaimer.
  16044. * Redistributions in binary form must reproduce the above
  16045. copyright notice, this list of conditions and the following
  16046. disclaimer in the documentation and/or other materials
  16047. provided with the distribution.
  16048. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16049. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16050. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16051. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16052. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16053. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16054. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16055. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16056. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16057. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16058. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16059. SUCH DAMAGE.
  16060. ***********************************************************************/
  16061. function loop_body(x) {
  16062. if (x instanceof AST_IterationStatement) {
  16063. return x.body instanceof AST_BlockStatement ? x.body : x;
  16064. }
  16065. return x;
  16066. }
  16067. function is_lhs_read_only(lhs) {
  16068. if (lhs instanceof AST_This) return true;
  16069. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  16070. if (lhs instanceof AST_PropAccess) {
  16071. lhs = lhs.expression;
  16072. if (lhs instanceof AST_SymbolRef) {
  16073. if (lhs.is_immutable()) return false;
  16074. lhs = lhs.fixed_value();
  16075. }
  16076. if (!lhs) return true;
  16077. if (lhs instanceof AST_RegExp) return false;
  16078. if (lhs instanceof AST_Constant) return true;
  16079. return is_lhs_read_only(lhs);
  16080. }
  16081. return false;
  16082. }
  16083. // Remove code which we know is unreachable.
  16084. function trim_unreachable_code(compressor, stat, target) {
  16085. walk(stat, node => {
  16086. if (node instanceof AST_Var) {
  16087. node.remove_initializers();
  16088. target.push(node);
  16089. return true;
  16090. }
  16091. if (
  16092. node instanceof AST_Defun
  16093. && (node === stat || !compressor.has_directive("use strict"))
  16094. ) {
  16095. target.push(node === stat ? node : make_node(AST_Var, node, {
  16096. definitions: [
  16097. make_node(AST_VarDef, node, {
  16098. name: make_node(AST_SymbolVar, node.name, node.name),
  16099. value: null
  16100. })
  16101. ]
  16102. }));
  16103. return true;
  16104. }
  16105. if (node instanceof AST_Export || node instanceof AST_Import) {
  16106. target.push(node);
  16107. return true;
  16108. }
  16109. if (node instanceof AST_Scope) {
  16110. return true;
  16111. }
  16112. });
  16113. }
  16114. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  16115. function tighten_body(statements, compressor) {
  16116. var in_loop, in_try;
  16117. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  16118. find_loop_scope_try();
  16119. var CHANGED, max_iter = 10;
  16120. do {
  16121. CHANGED = false;
  16122. eliminate_spurious_blocks(statements);
  16123. if (compressor.option("dead_code")) {
  16124. eliminate_dead_code(statements, compressor);
  16125. }
  16126. if (compressor.option("if_return")) {
  16127. handle_if_return(statements, compressor);
  16128. }
  16129. if (compressor.sequences_limit > 0) {
  16130. sequencesize(statements, compressor);
  16131. sequencesize_2(statements, compressor);
  16132. }
  16133. if (compressor.option("join_vars")) {
  16134. join_consecutive_vars(statements);
  16135. }
  16136. if (compressor.option("collapse_vars")) {
  16137. collapse(statements, compressor);
  16138. }
  16139. } while (CHANGED && max_iter-- > 0);
  16140. function find_loop_scope_try() {
  16141. var node = compressor.self(), level = 0;
  16142. do {
  16143. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  16144. level++;
  16145. } else if (node instanceof AST_IterationStatement) {
  16146. in_loop = true;
  16147. } else if (node instanceof AST_Scope) {
  16148. scope = node;
  16149. break;
  16150. } else if (node instanceof AST_Try) {
  16151. in_try = true;
  16152. }
  16153. } while (node = compressor.parent(level++));
  16154. }
  16155. // Search from right to left for assignment-like expressions:
  16156. // - `var a = x;`
  16157. // - `a = x;`
  16158. // - `++a`
  16159. // For each candidate, scan from left to right for first usage, then try
  16160. // to fold assignment into the site for compression.
  16161. // Will not attempt to collapse assignments into or past code blocks
  16162. // which are not sequentially executed, e.g. loops and conditionals.
  16163. function collapse(statements, compressor) {
  16164. if (scope.pinned())
  16165. return statements;
  16166. var args;
  16167. var candidates = [];
  16168. var stat_index = statements.length;
  16169. var scanner = new TreeTransformer(function (node) {
  16170. if (abort)
  16171. return node;
  16172. // Skip nodes before `candidate` as quickly as possible
  16173. if (!hit) {
  16174. if (node !== hit_stack[hit_index])
  16175. return node;
  16176. hit_index++;
  16177. if (hit_index < hit_stack.length)
  16178. return handle_custom_scan_order(node);
  16179. hit = true;
  16180. stop_after = find_stop(node, 0);
  16181. if (stop_after === node)
  16182. abort = true;
  16183. return node;
  16184. }
  16185. // Stop immediately if these node types are encountered
  16186. var parent = scanner.parent();
  16187. if (node instanceof AST_Assign
  16188. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  16189. || node instanceof AST_Await
  16190. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  16191. || node instanceof AST_Debugger
  16192. || node instanceof AST_Destructuring
  16193. || node instanceof AST_Expansion
  16194. && node.expression instanceof AST_Symbol
  16195. && (
  16196. node.expression instanceof AST_This
  16197. || node.expression.definition().references.length > 1
  16198. )
  16199. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  16200. || node instanceof AST_LoopControl
  16201. || node instanceof AST_Try
  16202. || node instanceof AST_With
  16203. || node instanceof AST_Yield
  16204. || node instanceof AST_Export
  16205. || node instanceof AST_Class
  16206. || parent instanceof AST_For && node !== parent.init
  16207. || !replace_all
  16208. && (
  16209. node instanceof AST_SymbolRef
  16210. && !node.is_declared(compressor)
  16211. && !pure_prop_access_globals.has(node)
  16212. )
  16213. || node instanceof AST_SymbolRef
  16214. && parent instanceof AST_Call
  16215. && has_annotation(parent, _NOINLINE)
  16216. ) {
  16217. abort = true;
  16218. return node;
  16219. }
  16220. // Stop only if candidate is found within conditional branches
  16221. if (!stop_if_hit && (!lhs_local || !replace_all)
  16222. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  16223. || parent instanceof AST_Conditional && parent.condition !== node
  16224. || parent instanceof AST_If && parent.condition !== node)) {
  16225. stop_if_hit = parent;
  16226. }
  16227. // Replace variable with assignment when found
  16228. if (can_replace
  16229. && !(node instanceof AST_SymbolDeclaration)
  16230. && lhs.equivalent_to(node)
  16231. && !shadows(node.scope, lvalues)
  16232. ) {
  16233. if (stop_if_hit) {
  16234. abort = true;
  16235. return node;
  16236. }
  16237. if (is_lhs(node, parent)) {
  16238. if (value_def)
  16239. replaced++;
  16240. return node;
  16241. } else {
  16242. replaced++;
  16243. if (value_def && candidate instanceof AST_VarDef)
  16244. return node;
  16245. }
  16246. CHANGED = abort = true;
  16247. if (candidate instanceof AST_UnaryPostfix) {
  16248. return make_node(AST_UnaryPrefix, candidate, candidate);
  16249. }
  16250. if (candidate instanceof AST_VarDef) {
  16251. var def = candidate.name.definition();
  16252. var value = candidate.value;
  16253. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  16254. def.replaced++;
  16255. if (funarg && is_identifier_atom(value)) {
  16256. return value.transform(compressor);
  16257. } else {
  16258. return maintain_this_binding(parent, node, value);
  16259. }
  16260. }
  16261. return make_node(AST_Assign, candidate, {
  16262. operator: "=",
  16263. logical: false,
  16264. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  16265. right: value
  16266. });
  16267. }
  16268. clear_flag(candidate, WRITE_ONLY);
  16269. return candidate;
  16270. }
  16271. // These node types have child nodes that execute sequentially,
  16272. // but are otherwise not safe to scan into or beyond them.
  16273. var sym;
  16274. if (node instanceof AST_Call
  16275. || node instanceof AST_Exit
  16276. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  16277. || node instanceof AST_PropAccess
  16278. && (side_effects || node.expression.may_throw_on_access(compressor))
  16279. || node instanceof AST_SymbolRef
  16280. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  16281. || node instanceof AST_VarDef && node.value
  16282. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  16283. || (sym = is_lhs(node.left, node))
  16284. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  16285. || may_throw
  16286. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  16287. stop_after = node;
  16288. if (node instanceof AST_Scope)
  16289. abort = true;
  16290. }
  16291. return handle_custom_scan_order(node);
  16292. }, function (node) {
  16293. if (abort)
  16294. return;
  16295. if (stop_after === node)
  16296. abort = true;
  16297. if (stop_if_hit === node)
  16298. stop_if_hit = null;
  16299. });
  16300. var multi_replacer = new TreeTransformer(function (node) {
  16301. if (abort)
  16302. return node;
  16303. // Skip nodes before `candidate` as quickly as possible
  16304. if (!hit) {
  16305. if (node !== hit_stack[hit_index])
  16306. return node;
  16307. hit_index++;
  16308. if (hit_index < hit_stack.length)
  16309. return;
  16310. hit = true;
  16311. return node;
  16312. }
  16313. // Replace variable when found
  16314. if (node instanceof AST_SymbolRef
  16315. && node.name == def.name) {
  16316. if (!--replaced)
  16317. abort = true;
  16318. if (is_lhs(node, multi_replacer.parent()))
  16319. return node;
  16320. def.replaced++;
  16321. value_def.replaced--;
  16322. return candidate.value;
  16323. }
  16324. // Skip (non-executed) functions and (leading) default case in switch statements
  16325. if (node instanceof AST_Default || node instanceof AST_Scope)
  16326. return node;
  16327. });
  16328. while (--stat_index >= 0) {
  16329. // Treat parameters as collapsible in IIFE, i.e.
  16330. // function(a, b){ ... }(x());
  16331. // would be translated into equivalent assignments:
  16332. // var a = x(), b = undefined;
  16333. if (stat_index == 0 && compressor.option("unused"))
  16334. extract_args();
  16335. // Find collapsible assignments
  16336. var hit_stack = [];
  16337. extract_candidates(statements[stat_index]);
  16338. while (candidates.length > 0) {
  16339. hit_stack = candidates.pop();
  16340. var hit_index = 0;
  16341. var candidate = hit_stack[hit_stack.length - 1];
  16342. var value_def = null;
  16343. var stop_after = null;
  16344. var stop_if_hit = null;
  16345. var lhs = get_lhs(candidate);
  16346. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  16347. continue;
  16348. // Locate symbols which may execute code outside of scanning range
  16349. var lvalues = get_lvalues(candidate);
  16350. var lhs_local = is_lhs_local(lhs);
  16351. if (lhs instanceof AST_SymbolRef) {
  16352. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  16353. }
  16354. var side_effects = value_has_side_effects(candidate);
  16355. var replace_all = replace_all_symbols();
  16356. var may_throw = candidate.may_throw(compressor);
  16357. var funarg = candidate.name instanceof AST_SymbolFunarg;
  16358. var hit = funarg;
  16359. var abort = false, replaced = 0, can_replace = !args || !hit;
  16360. if (!can_replace) {
  16361. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  16362. args[j].transform(scanner);
  16363. }
  16364. can_replace = true;
  16365. }
  16366. for (var i = stat_index; !abort && i < statements.length; i++) {
  16367. statements[i].transform(scanner);
  16368. }
  16369. if (value_def) {
  16370. var def = candidate.name.definition();
  16371. if (abort && def.references.length - def.replaced > replaced)
  16372. replaced = false;
  16373. else {
  16374. abort = false;
  16375. hit_index = 0;
  16376. hit = funarg;
  16377. for (var i = stat_index; !abort && i < statements.length; i++) {
  16378. statements[i].transform(multi_replacer);
  16379. }
  16380. value_def.single_use = false;
  16381. }
  16382. }
  16383. if (replaced && !remove_candidate(candidate))
  16384. statements.splice(stat_index, 1);
  16385. }
  16386. }
  16387. function handle_custom_scan_order(node) {
  16388. // Skip (non-executed) functions
  16389. if (node instanceof AST_Scope)
  16390. return node;
  16391. // Scan case expressions first in a switch statement
  16392. if (node instanceof AST_Switch) {
  16393. node.expression = node.expression.transform(scanner);
  16394. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  16395. var branch = node.body[i];
  16396. if (branch instanceof AST_Case) {
  16397. if (!hit) {
  16398. if (branch !== hit_stack[hit_index])
  16399. continue;
  16400. hit_index++;
  16401. }
  16402. branch.expression = branch.expression.transform(scanner);
  16403. if (!replace_all)
  16404. break;
  16405. }
  16406. }
  16407. abort = true;
  16408. return node;
  16409. }
  16410. }
  16411. function redefined_within_scope(def, scope) {
  16412. if (def.global)
  16413. return false;
  16414. let cur_scope = def.scope;
  16415. while (cur_scope && cur_scope !== scope) {
  16416. if (cur_scope.variables.has(def.name)) {
  16417. return true;
  16418. }
  16419. cur_scope = cur_scope.parent_scope;
  16420. }
  16421. return false;
  16422. }
  16423. function has_overlapping_symbol(fn, arg, fn_strict) {
  16424. var found = false, scan_this = !(fn instanceof AST_Arrow);
  16425. arg.walk(new TreeWalker(function (node, descend) {
  16426. if (found)
  16427. return true;
  16428. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  16429. var s = node.definition().scope;
  16430. if (s !== scope)
  16431. while (s = s.parent_scope) {
  16432. if (s === scope)
  16433. return true;
  16434. }
  16435. return found = true;
  16436. }
  16437. if ((fn_strict || scan_this) && node instanceof AST_This) {
  16438. return found = true;
  16439. }
  16440. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  16441. var prev = scan_this;
  16442. scan_this = false;
  16443. descend();
  16444. scan_this = prev;
  16445. return true;
  16446. }
  16447. }));
  16448. return found;
  16449. }
  16450. function extract_args() {
  16451. var iife, fn = compressor.self();
  16452. if (is_func_expr(fn)
  16453. && !fn.name
  16454. && !fn.uses_arguments
  16455. && !fn.pinned()
  16456. && (iife = compressor.parent()) instanceof AST_Call
  16457. && iife.expression === fn
  16458. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  16459. var fn_strict = compressor.has_directive("use strict");
  16460. if (fn_strict && !member(fn_strict, fn.body))
  16461. fn_strict = false;
  16462. var len = fn.argnames.length;
  16463. args = iife.args.slice(len);
  16464. var names = new Set();
  16465. for (var i = len; --i >= 0;) {
  16466. var sym = fn.argnames[i];
  16467. var arg = iife.args[i];
  16468. // The following two line fix is a duplicate of the fix at
  16469. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  16470. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  16471. // Might be doing the exact same thing.
  16472. const def = sym.definition && sym.definition();
  16473. const is_reassigned = def && def.orig.length > 1;
  16474. if (is_reassigned)
  16475. continue;
  16476. args.unshift(make_node(AST_VarDef, sym, {
  16477. name: sym,
  16478. value: arg
  16479. }));
  16480. if (names.has(sym.name))
  16481. continue;
  16482. names.add(sym.name);
  16483. if (sym instanceof AST_Expansion) {
  16484. var elements = iife.args.slice(i);
  16485. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  16486. )) {
  16487. candidates.unshift([make_node(AST_VarDef, sym, {
  16488. name: sym.expression,
  16489. value: make_node(AST_Array, iife, {
  16490. elements: elements
  16491. })
  16492. })]);
  16493. }
  16494. } else {
  16495. if (!arg) {
  16496. arg = make_node(AST_Undefined, sym).transform(compressor);
  16497. } else if (arg instanceof AST_Lambda && arg.pinned()
  16498. || has_overlapping_symbol(fn, arg, fn_strict)) {
  16499. arg = null;
  16500. }
  16501. if (arg)
  16502. candidates.unshift([make_node(AST_VarDef, sym, {
  16503. name: sym,
  16504. value: arg
  16505. })]);
  16506. }
  16507. }
  16508. }
  16509. }
  16510. function extract_candidates(expr) {
  16511. hit_stack.push(expr);
  16512. if (expr instanceof AST_Assign) {
  16513. if (!expr.left.has_side_effects(compressor)
  16514. && !(expr.right instanceof AST_Chain)) {
  16515. candidates.push(hit_stack.slice());
  16516. }
  16517. extract_candidates(expr.right);
  16518. } else if (expr instanceof AST_Binary) {
  16519. extract_candidates(expr.left);
  16520. extract_candidates(expr.right);
  16521. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  16522. extract_candidates(expr.expression);
  16523. expr.args.forEach(extract_candidates);
  16524. } else if (expr instanceof AST_Case) {
  16525. extract_candidates(expr.expression);
  16526. } else if (expr instanceof AST_Conditional) {
  16527. extract_candidates(expr.condition);
  16528. extract_candidates(expr.consequent);
  16529. extract_candidates(expr.alternative);
  16530. } else if (expr instanceof AST_Definitions) {
  16531. var len = expr.definitions.length;
  16532. // limit number of trailing variable definitions for consideration
  16533. var i = len - 200;
  16534. if (i < 0)
  16535. i = 0;
  16536. for (; i < len; i++) {
  16537. extract_candidates(expr.definitions[i]);
  16538. }
  16539. } else if (expr instanceof AST_DWLoop) {
  16540. extract_candidates(expr.condition);
  16541. if (!(expr.body instanceof AST_Block)) {
  16542. extract_candidates(expr.body);
  16543. }
  16544. } else if (expr instanceof AST_Exit) {
  16545. if (expr.value)
  16546. extract_candidates(expr.value);
  16547. } else if (expr instanceof AST_For) {
  16548. if (expr.init)
  16549. extract_candidates(expr.init);
  16550. if (expr.condition)
  16551. extract_candidates(expr.condition);
  16552. if (expr.step)
  16553. extract_candidates(expr.step);
  16554. if (!(expr.body instanceof AST_Block)) {
  16555. extract_candidates(expr.body);
  16556. }
  16557. } else if (expr instanceof AST_ForIn) {
  16558. extract_candidates(expr.object);
  16559. if (!(expr.body instanceof AST_Block)) {
  16560. extract_candidates(expr.body);
  16561. }
  16562. } else if (expr instanceof AST_If) {
  16563. extract_candidates(expr.condition);
  16564. if (!(expr.body instanceof AST_Block)) {
  16565. extract_candidates(expr.body);
  16566. }
  16567. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  16568. extract_candidates(expr.alternative);
  16569. }
  16570. } else if (expr instanceof AST_Sequence) {
  16571. expr.expressions.forEach(extract_candidates);
  16572. } else if (expr instanceof AST_SimpleStatement) {
  16573. extract_candidates(expr.body);
  16574. } else if (expr instanceof AST_Switch) {
  16575. extract_candidates(expr.expression);
  16576. expr.body.forEach(extract_candidates);
  16577. } else if (expr instanceof AST_Unary) {
  16578. if (expr.operator == "++" || expr.operator == "--") {
  16579. candidates.push(hit_stack.slice());
  16580. }
  16581. } else if (expr instanceof AST_VarDef) {
  16582. if (expr.value && !(expr.value instanceof AST_Chain)) {
  16583. candidates.push(hit_stack.slice());
  16584. extract_candidates(expr.value);
  16585. }
  16586. }
  16587. hit_stack.pop();
  16588. }
  16589. function find_stop(node, level, write_only) {
  16590. var parent = scanner.parent(level);
  16591. if (parent instanceof AST_Assign) {
  16592. if (write_only
  16593. && !parent.logical
  16594. && !(parent.left instanceof AST_PropAccess
  16595. || lvalues.has(parent.left.name))) {
  16596. return find_stop(parent, level + 1, write_only);
  16597. }
  16598. return node;
  16599. }
  16600. if (parent instanceof AST_Binary) {
  16601. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  16602. return find_stop(parent, level + 1, write_only);
  16603. }
  16604. return node;
  16605. }
  16606. if (parent instanceof AST_Call)
  16607. return node;
  16608. if (parent instanceof AST_Case)
  16609. return node;
  16610. if (parent instanceof AST_Conditional) {
  16611. if (write_only && parent.condition === node) {
  16612. return find_stop(parent, level + 1, write_only);
  16613. }
  16614. return node;
  16615. }
  16616. if (parent instanceof AST_Definitions) {
  16617. return find_stop(parent, level + 1, true);
  16618. }
  16619. if (parent instanceof AST_Exit) {
  16620. return write_only ? find_stop(parent, level + 1, write_only) : node;
  16621. }
  16622. if (parent instanceof AST_If) {
  16623. if (write_only && parent.condition === node) {
  16624. return find_stop(parent, level + 1, write_only);
  16625. }
  16626. return node;
  16627. }
  16628. if (parent instanceof AST_IterationStatement)
  16629. return node;
  16630. if (parent instanceof AST_Sequence) {
  16631. return find_stop(parent, level + 1, parent.tail_node() !== node);
  16632. }
  16633. if (parent instanceof AST_SimpleStatement) {
  16634. return find_stop(parent, level + 1, true);
  16635. }
  16636. if (parent instanceof AST_Switch)
  16637. return node;
  16638. if (parent instanceof AST_VarDef)
  16639. return node;
  16640. return null;
  16641. }
  16642. function mangleable_var(var_def) {
  16643. var value = var_def.value;
  16644. if (!(value instanceof AST_SymbolRef))
  16645. return;
  16646. if (value.name == "arguments")
  16647. return;
  16648. var def = value.definition();
  16649. if (def.undeclared)
  16650. return;
  16651. return value_def = def;
  16652. }
  16653. function get_lhs(expr) {
  16654. if (expr instanceof AST_Assign && expr.logical) {
  16655. return false;
  16656. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  16657. var def = expr.name.definition();
  16658. if (!member(expr.name, def.orig))
  16659. return;
  16660. var referenced = def.references.length - def.replaced;
  16661. if (!referenced)
  16662. return;
  16663. var declared = def.orig.length - def.eliminated;
  16664. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  16665. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  16666. return make_node(AST_SymbolRef, expr.name, expr.name);
  16667. }
  16668. } else {
  16669. const lhs = expr instanceof AST_Assign
  16670. ? expr.left
  16671. : expr.expression;
  16672. return !is_ref_of(lhs, AST_SymbolConst)
  16673. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  16674. }
  16675. }
  16676. function get_rvalue(expr) {
  16677. if (expr instanceof AST_Assign) {
  16678. return expr.right;
  16679. } else {
  16680. return expr.value;
  16681. }
  16682. }
  16683. function get_lvalues(expr) {
  16684. var lvalues = new Map();
  16685. if (expr instanceof AST_Unary)
  16686. return lvalues;
  16687. var tw = new TreeWalker(function (node) {
  16688. var sym = node;
  16689. while (sym instanceof AST_PropAccess)
  16690. sym = sym.expression;
  16691. if (sym instanceof AST_SymbolRef) {
  16692. const prev = lvalues.get(sym.name);
  16693. if (!prev || !prev.modified) {
  16694. lvalues.set(sym.name, {
  16695. def: sym.definition(),
  16696. modified: is_modified(compressor, tw, node, node, 0)
  16697. });
  16698. }
  16699. }
  16700. });
  16701. get_rvalue(expr).walk(tw);
  16702. return lvalues;
  16703. }
  16704. function remove_candidate(expr) {
  16705. if (expr.name instanceof AST_SymbolFunarg) {
  16706. var iife = compressor.parent(), argnames = compressor.self().argnames;
  16707. var index = argnames.indexOf(expr.name);
  16708. if (index < 0) {
  16709. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  16710. } else {
  16711. var args = iife.args;
  16712. if (args[index])
  16713. args[index] = make_node(AST_Number, args[index], {
  16714. value: 0
  16715. });
  16716. }
  16717. return true;
  16718. }
  16719. var found = false;
  16720. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  16721. if (found)
  16722. return node;
  16723. if (node === expr || node.body === expr) {
  16724. found = true;
  16725. if (node instanceof AST_VarDef) {
  16726. node.value = node.name instanceof AST_SymbolConst
  16727. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  16728. : null;
  16729. return node;
  16730. }
  16731. return in_list ? MAP.skip : null;
  16732. }
  16733. }, function (node) {
  16734. if (node instanceof AST_Sequence)
  16735. switch (node.expressions.length) {
  16736. case 0: return null;
  16737. case 1: return node.expressions[0];
  16738. }
  16739. }));
  16740. }
  16741. function is_lhs_local(lhs) {
  16742. while (lhs instanceof AST_PropAccess)
  16743. lhs = lhs.expression;
  16744. return lhs instanceof AST_SymbolRef
  16745. && lhs.definition().scope === scope
  16746. && !(in_loop
  16747. && (lvalues.has(lhs.name)
  16748. || candidate instanceof AST_Unary
  16749. || (candidate instanceof AST_Assign
  16750. && !candidate.logical
  16751. && candidate.operator != "=")));
  16752. }
  16753. function value_has_side_effects(expr) {
  16754. if (expr instanceof AST_Unary)
  16755. return unary_side_effects.has(expr.operator);
  16756. return get_rvalue(expr).has_side_effects(compressor);
  16757. }
  16758. function replace_all_symbols() {
  16759. if (side_effects)
  16760. return false;
  16761. if (value_def)
  16762. return true;
  16763. if (lhs instanceof AST_SymbolRef) {
  16764. var def = lhs.definition();
  16765. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  16766. return true;
  16767. }
  16768. }
  16769. return false;
  16770. }
  16771. function may_modify(sym) {
  16772. if (!sym.definition)
  16773. return true; // AST_Destructuring
  16774. var def = sym.definition();
  16775. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  16776. return false;
  16777. if (def.scope.get_defun_scope() !== scope)
  16778. return true;
  16779. return !def.references.every((ref) => {
  16780. var s = ref.scope.get_defun_scope();
  16781. // "block" scope within AST_Catch
  16782. if (s.TYPE == "Scope")
  16783. s = s.parent_scope;
  16784. return s === scope;
  16785. });
  16786. }
  16787. function side_effects_external(node, lhs) {
  16788. if (node instanceof AST_Assign)
  16789. return side_effects_external(node.left, true);
  16790. if (node instanceof AST_Unary)
  16791. return side_effects_external(node.expression, true);
  16792. if (node instanceof AST_VarDef)
  16793. return node.value && side_effects_external(node.value);
  16794. if (lhs) {
  16795. if (node instanceof AST_Dot)
  16796. return side_effects_external(node.expression, true);
  16797. if (node instanceof AST_Sub)
  16798. return side_effects_external(node.expression, true);
  16799. if (node instanceof AST_SymbolRef)
  16800. return node.definition().scope !== scope;
  16801. }
  16802. return false;
  16803. }
  16804. function shadows(newScope, lvalues) {
  16805. for (const {def} of lvalues.values()) {
  16806. let current = newScope;
  16807. while (current && current !== def.scope) {
  16808. let nested_def = current.variables.get(def.name);
  16809. if (nested_def && nested_def !== def) return true;
  16810. current = current.parent_scope;
  16811. }
  16812. }
  16813. return false;
  16814. }
  16815. }
  16816. function eliminate_spurious_blocks(statements) {
  16817. var seen_dirs = [];
  16818. for (var i = 0; i < statements.length;) {
  16819. var stat = statements[i];
  16820. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  16821. CHANGED = true;
  16822. eliminate_spurious_blocks(stat.body);
  16823. statements.splice(i, 1, ...stat.body);
  16824. i += stat.body.length;
  16825. } else if (stat instanceof AST_EmptyStatement) {
  16826. CHANGED = true;
  16827. statements.splice(i, 1);
  16828. } else if (stat instanceof AST_Directive) {
  16829. if (seen_dirs.indexOf(stat.value) < 0) {
  16830. i++;
  16831. seen_dirs.push(stat.value);
  16832. } else {
  16833. CHANGED = true;
  16834. statements.splice(i, 1);
  16835. }
  16836. } else
  16837. i++;
  16838. }
  16839. }
  16840. function handle_if_return(statements, compressor) {
  16841. var self = compressor.self();
  16842. var multiple_if_returns = has_multiple_if_returns(statements);
  16843. var in_lambda = self instanceof AST_Lambda;
  16844. for (var i = statements.length; --i >= 0;) {
  16845. var stat = statements[i];
  16846. var j = next_index(i);
  16847. var next = statements[j];
  16848. if (in_lambda && !next && stat instanceof AST_Return) {
  16849. if (!stat.value) {
  16850. CHANGED = true;
  16851. statements.splice(i, 1);
  16852. continue;
  16853. }
  16854. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  16855. CHANGED = true;
  16856. statements[i] = make_node(AST_SimpleStatement, stat, {
  16857. body: stat.value.expression
  16858. });
  16859. continue;
  16860. }
  16861. }
  16862. if (stat instanceof AST_If) {
  16863. var ab = aborts(stat.body);
  16864. if (can_merge_flow(ab)) {
  16865. if (ab.label) {
  16866. remove(ab.label.thedef.references, ab);
  16867. }
  16868. CHANGED = true;
  16869. stat = stat.clone();
  16870. stat.condition = stat.condition.negate(compressor);
  16871. var body = as_statement_array_with_return(stat.body, ab);
  16872. stat.body = make_node(AST_BlockStatement, stat, {
  16873. body: as_statement_array(stat.alternative).concat(extract_functions())
  16874. });
  16875. stat.alternative = make_node(AST_BlockStatement, stat, {
  16876. body: body
  16877. });
  16878. statements[i] = stat.transform(compressor);
  16879. continue;
  16880. }
  16881. var ab = aborts(stat.alternative);
  16882. if (can_merge_flow(ab)) {
  16883. if (ab.label) {
  16884. remove(ab.label.thedef.references, ab);
  16885. }
  16886. CHANGED = true;
  16887. stat = stat.clone();
  16888. stat.body = make_node(AST_BlockStatement, stat.body, {
  16889. body: as_statement_array(stat.body).concat(extract_functions())
  16890. });
  16891. var body = as_statement_array_with_return(stat.alternative, ab);
  16892. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  16893. body: body
  16894. });
  16895. statements[i] = stat.transform(compressor);
  16896. continue;
  16897. }
  16898. }
  16899. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  16900. var value = stat.body.value;
  16901. //---
  16902. // pretty silly case, but:
  16903. // if (foo()) return; return; ==> foo(); return;
  16904. if (!value && !stat.alternative
  16905. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  16906. CHANGED = true;
  16907. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  16908. body: stat.condition
  16909. });
  16910. continue;
  16911. }
  16912. //---
  16913. // if (foo()) return x; return y; ==> return foo() ? x : y;
  16914. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  16915. CHANGED = true;
  16916. stat = stat.clone();
  16917. stat.alternative = next;
  16918. statements[i] = stat.transform(compressor);
  16919. statements.splice(j, 1);
  16920. continue;
  16921. }
  16922. //---
  16923. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  16924. if (value && !stat.alternative
  16925. && (!next && in_lambda && multiple_if_returns
  16926. || next instanceof AST_Return)) {
  16927. CHANGED = true;
  16928. stat = stat.clone();
  16929. stat.alternative = next || make_node(AST_Return, stat, {
  16930. value: null
  16931. });
  16932. statements[i] = stat.transform(compressor);
  16933. if (next)
  16934. statements.splice(j, 1);
  16935. continue;
  16936. }
  16937. //---
  16938. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  16939. //
  16940. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  16941. // however, with sequences on this helps producing slightly better output for
  16942. // the example code.
  16943. var prev = statements[prev_index(i)];
  16944. if (compressor.option("sequences") && in_lambda && !stat.alternative
  16945. && prev instanceof AST_If && prev.body instanceof AST_Return
  16946. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  16947. CHANGED = true;
  16948. stat = stat.clone();
  16949. stat.alternative = make_node(AST_BlockStatement, next, {
  16950. body: [
  16951. next,
  16952. make_node(AST_Return, next, {
  16953. value: null
  16954. })
  16955. ]
  16956. });
  16957. statements[i] = stat.transform(compressor);
  16958. statements.splice(j, 1);
  16959. continue;
  16960. }
  16961. }
  16962. }
  16963. function has_multiple_if_returns(statements) {
  16964. var n = 0;
  16965. for (var i = statements.length; --i >= 0;) {
  16966. var stat = statements[i];
  16967. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  16968. if (++n > 1)
  16969. return true;
  16970. }
  16971. }
  16972. return false;
  16973. }
  16974. function is_return_void(value) {
  16975. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  16976. }
  16977. function can_merge_flow(ab) {
  16978. if (!ab)
  16979. return false;
  16980. for (var j = i + 1, len = statements.length; j < len; j++) {
  16981. var stat = statements[j];
  16982. if (stat instanceof AST_Const || stat instanceof AST_Let)
  16983. return false;
  16984. }
  16985. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  16986. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  16987. || ab instanceof AST_Continue && self === loop_body(lct)
  16988. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  16989. }
  16990. function extract_functions() {
  16991. var tail = statements.slice(i + 1);
  16992. statements.length = i + 1;
  16993. return tail.filter(function (stat) {
  16994. if (stat instanceof AST_Defun) {
  16995. statements.push(stat);
  16996. return false;
  16997. }
  16998. return true;
  16999. });
  17000. }
  17001. function as_statement_array_with_return(node, ab) {
  17002. var body = as_statement_array(node).slice(0, -1);
  17003. if (ab.value) {
  17004. body.push(make_node(AST_SimpleStatement, ab.value, {
  17005. body: ab.value.expression
  17006. }));
  17007. }
  17008. return body;
  17009. }
  17010. function next_index(i) {
  17011. for (var j = i + 1, len = statements.length; j < len; j++) {
  17012. var stat = statements[j];
  17013. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  17014. break;
  17015. }
  17016. }
  17017. return j;
  17018. }
  17019. function prev_index(i) {
  17020. for (var j = i; --j >= 0;) {
  17021. var stat = statements[j];
  17022. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  17023. break;
  17024. }
  17025. }
  17026. return j;
  17027. }
  17028. }
  17029. function eliminate_dead_code(statements, compressor) {
  17030. var has_quit;
  17031. var self = compressor.self();
  17032. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  17033. var stat = statements[i];
  17034. if (stat instanceof AST_LoopControl) {
  17035. var lct = compressor.loopcontrol_target(stat);
  17036. if (stat instanceof AST_Break
  17037. && !(lct instanceof AST_IterationStatement)
  17038. && loop_body(lct) === self
  17039. || stat instanceof AST_Continue
  17040. && loop_body(lct) === self) {
  17041. if (stat.label) {
  17042. remove(stat.label.thedef.references, stat);
  17043. }
  17044. } else {
  17045. statements[n++] = stat;
  17046. }
  17047. } else {
  17048. statements[n++] = stat;
  17049. }
  17050. if (aborts(stat)) {
  17051. has_quit = statements.slice(i + 1);
  17052. break;
  17053. }
  17054. }
  17055. statements.length = n;
  17056. CHANGED = n != len;
  17057. if (has_quit)
  17058. has_quit.forEach(function (stat) {
  17059. trim_unreachable_code(compressor, stat, statements);
  17060. });
  17061. }
  17062. function declarations_only(node) {
  17063. return node.definitions.every((var_def) => !var_def.value
  17064. );
  17065. }
  17066. function sequencesize(statements, compressor) {
  17067. if (statements.length < 2)
  17068. return;
  17069. var seq = [], n = 0;
  17070. function push_seq() {
  17071. if (!seq.length)
  17072. return;
  17073. var body = make_sequence(seq[0], seq);
  17074. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  17075. seq = [];
  17076. }
  17077. for (var i = 0, len = statements.length; i < len; i++) {
  17078. var stat = statements[i];
  17079. if (stat instanceof AST_SimpleStatement) {
  17080. if (seq.length >= compressor.sequences_limit)
  17081. push_seq();
  17082. var body = stat.body;
  17083. if (seq.length > 0)
  17084. body = body.drop_side_effect_free(compressor);
  17085. if (body)
  17086. merge_sequence(seq, body);
  17087. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  17088. || stat instanceof AST_Defun) {
  17089. statements[n++] = stat;
  17090. } else {
  17091. push_seq();
  17092. statements[n++] = stat;
  17093. }
  17094. }
  17095. push_seq();
  17096. statements.length = n;
  17097. if (n != len)
  17098. CHANGED = true;
  17099. }
  17100. function to_simple_statement(block, decls) {
  17101. if (!(block instanceof AST_BlockStatement))
  17102. return block;
  17103. var stat = null;
  17104. for (var i = 0, len = block.body.length; i < len; i++) {
  17105. var line = block.body[i];
  17106. if (line instanceof AST_Var && declarations_only(line)) {
  17107. decls.push(line);
  17108. } else if (stat) {
  17109. return false;
  17110. } else {
  17111. stat = line;
  17112. }
  17113. }
  17114. return stat;
  17115. }
  17116. function sequencesize_2(statements, compressor) {
  17117. function cons_seq(right) {
  17118. n--;
  17119. CHANGED = true;
  17120. var left = prev.body;
  17121. return make_sequence(left, [left, right]).transform(compressor);
  17122. }
  17123. var n = 0, prev;
  17124. for (var i = 0; i < statements.length; i++) {
  17125. var stat = statements[i];
  17126. if (prev) {
  17127. if (stat instanceof AST_Exit) {
  17128. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  17129. } else if (stat instanceof AST_For) {
  17130. if (!(stat.init instanceof AST_Definitions)) {
  17131. const abort = walk(prev.body, node => {
  17132. if (node instanceof AST_Scope)
  17133. return true;
  17134. if (node instanceof AST_Binary
  17135. && node.operator === "in") {
  17136. return walk_abort;
  17137. }
  17138. });
  17139. if (!abort) {
  17140. if (stat.init)
  17141. stat.init = cons_seq(stat.init);
  17142. else {
  17143. stat.init = prev.body;
  17144. n--;
  17145. CHANGED = true;
  17146. }
  17147. }
  17148. }
  17149. } else if (stat instanceof AST_ForIn) {
  17150. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  17151. stat.object = cons_seq(stat.object);
  17152. }
  17153. } else if (stat instanceof AST_If) {
  17154. stat.condition = cons_seq(stat.condition);
  17155. } else if (stat instanceof AST_Switch) {
  17156. stat.expression = cons_seq(stat.expression);
  17157. } else if (stat instanceof AST_With) {
  17158. stat.expression = cons_seq(stat.expression);
  17159. }
  17160. }
  17161. if (compressor.option("conditionals") && stat instanceof AST_If) {
  17162. var decls = [];
  17163. var body = to_simple_statement(stat.body, decls);
  17164. var alt = to_simple_statement(stat.alternative, decls);
  17165. if (body !== false && alt !== false && decls.length > 0) {
  17166. var len = decls.length;
  17167. decls.push(make_node(AST_If, stat, {
  17168. condition: stat.condition,
  17169. body: body || make_node(AST_EmptyStatement, stat.body),
  17170. alternative: alt
  17171. }));
  17172. decls.unshift(n, 1);
  17173. [].splice.apply(statements, decls);
  17174. i += len;
  17175. n += len + 1;
  17176. prev = null;
  17177. CHANGED = true;
  17178. continue;
  17179. }
  17180. }
  17181. statements[n++] = stat;
  17182. prev = stat instanceof AST_SimpleStatement ? stat : null;
  17183. }
  17184. statements.length = n;
  17185. }
  17186. function join_object_assignments(defn, body) {
  17187. if (!(defn instanceof AST_Definitions))
  17188. return;
  17189. var def = defn.definitions[defn.definitions.length - 1];
  17190. if (!(def.value instanceof AST_Object))
  17191. return;
  17192. var exprs;
  17193. if (body instanceof AST_Assign && !body.logical) {
  17194. exprs = [body];
  17195. } else if (body instanceof AST_Sequence) {
  17196. exprs = body.expressions.slice();
  17197. }
  17198. if (!exprs)
  17199. return;
  17200. var trimmed = false;
  17201. do {
  17202. var node = exprs[0];
  17203. if (!(node instanceof AST_Assign))
  17204. break;
  17205. if (node.operator != "=")
  17206. break;
  17207. if (!(node.left instanceof AST_PropAccess))
  17208. break;
  17209. var sym = node.left.expression;
  17210. if (!(sym instanceof AST_SymbolRef))
  17211. break;
  17212. if (def.name.name != sym.name)
  17213. break;
  17214. if (!node.right.is_constant_expression(scope))
  17215. break;
  17216. var prop = node.left.property;
  17217. if (prop instanceof AST_Node) {
  17218. prop = prop.evaluate(compressor);
  17219. }
  17220. if (prop instanceof AST_Node)
  17221. break;
  17222. prop = "" + prop;
  17223. var diff = compressor.option("ecma") < 2015
  17224. && compressor.has_directive("use strict") ? function (node) {
  17225. return node.key != prop && (node.key && node.key.name != prop);
  17226. } : function (node) {
  17227. return node.key && node.key.name != prop;
  17228. };
  17229. if (!def.value.properties.every(diff))
  17230. break;
  17231. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  17232. if (!p) {
  17233. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  17234. key: prop,
  17235. value: node.right
  17236. }));
  17237. } else {
  17238. p.value = new AST_Sequence({
  17239. start: p.start,
  17240. expressions: [p.value.clone(), node.right.clone()],
  17241. end: p.end
  17242. });
  17243. }
  17244. exprs.shift();
  17245. trimmed = true;
  17246. } while (exprs.length);
  17247. return trimmed && exprs;
  17248. }
  17249. function join_consecutive_vars(statements) {
  17250. var defs;
  17251. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  17252. var stat = statements[i];
  17253. var prev = statements[j];
  17254. if (stat instanceof AST_Definitions) {
  17255. if (prev && prev.TYPE == stat.TYPE) {
  17256. prev.definitions = prev.definitions.concat(stat.definitions);
  17257. CHANGED = true;
  17258. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  17259. defs.definitions = defs.definitions.concat(stat.definitions);
  17260. CHANGED = true;
  17261. } else {
  17262. statements[++j] = stat;
  17263. defs = stat;
  17264. }
  17265. } else if (stat instanceof AST_Exit) {
  17266. stat.value = extract_object_assignments(stat.value);
  17267. } else if (stat instanceof AST_For) {
  17268. var exprs = join_object_assignments(prev, stat.init);
  17269. if (exprs) {
  17270. CHANGED = true;
  17271. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  17272. statements[++j] = stat;
  17273. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  17274. if (stat.init) {
  17275. prev.definitions = prev.definitions.concat(stat.init.definitions);
  17276. }
  17277. stat.init = prev;
  17278. statements[j] = stat;
  17279. CHANGED = true;
  17280. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  17281. defs.definitions = defs.definitions.concat(stat.init.definitions);
  17282. stat.init = null;
  17283. statements[++j] = stat;
  17284. CHANGED = true;
  17285. } else {
  17286. statements[++j] = stat;
  17287. }
  17288. } else if (stat instanceof AST_ForIn) {
  17289. stat.object = extract_object_assignments(stat.object);
  17290. } else if (stat instanceof AST_If) {
  17291. stat.condition = extract_object_assignments(stat.condition);
  17292. } else if (stat instanceof AST_SimpleStatement) {
  17293. var exprs = join_object_assignments(prev, stat.body);
  17294. if (exprs) {
  17295. CHANGED = true;
  17296. if (!exprs.length)
  17297. continue;
  17298. stat.body = make_sequence(stat.body, exprs);
  17299. }
  17300. statements[++j] = stat;
  17301. } else if (stat instanceof AST_Switch) {
  17302. stat.expression = extract_object_assignments(stat.expression);
  17303. } else if (stat instanceof AST_With) {
  17304. stat.expression = extract_object_assignments(stat.expression);
  17305. } else {
  17306. statements[++j] = stat;
  17307. }
  17308. }
  17309. statements.length = j + 1;
  17310. function extract_object_assignments(value) {
  17311. statements[++j] = stat;
  17312. var exprs = join_object_assignments(prev, value);
  17313. if (exprs) {
  17314. CHANGED = true;
  17315. if (exprs.length) {
  17316. return make_sequence(value, exprs);
  17317. } else if (value instanceof AST_Sequence) {
  17318. return value.tail_node().left;
  17319. } else {
  17320. return value.left;
  17321. }
  17322. }
  17323. return value;
  17324. }
  17325. }
  17326. }
  17327. /***********************************************************************
  17328. A JavaScript tokenizer / parser / beautifier / compressor.
  17329. https://github.com/mishoo/UglifyJS2
  17330. -------------------------------- (C) ---------------------------------
  17331. Author: Mihai Bazon
  17332. <mihai.bazon@gmail.com>
  17333. http://mihai.bazon.net/blog
  17334. Distributed under the BSD license:
  17335. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17336. Redistribution and use in source and binary forms, with or without
  17337. modification, are permitted provided that the following conditions
  17338. are met:
  17339. * Redistributions of source code must retain the above
  17340. copyright notice, this list of conditions and the following
  17341. disclaimer.
  17342. * Redistributions in binary form must reproduce the above
  17343. copyright notice, this list of conditions and the following
  17344. disclaimer in the documentation and/or other materials
  17345. provided with the distribution.
  17346. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17347. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17348. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17349. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17350. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17351. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17352. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17353. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17354. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17355. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17356. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17357. SUCH DAMAGE.
  17358. ***********************************************************************/
  17359. function within_array_or_object_literal(compressor) {
  17360. var node, level = 0;
  17361. while (node = compressor.parent(level++)) {
  17362. if (node instanceof AST_Statement) return false;
  17363. if (node instanceof AST_Array
  17364. || node instanceof AST_ObjectKeyVal
  17365. || node instanceof AST_Object) {
  17366. return true;
  17367. }
  17368. }
  17369. return false;
  17370. }
  17371. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  17372. for (const enclosed of pulled_scope.enclosed) {
  17373. if (pulled_scope.variables.has(enclosed.name)) {
  17374. continue;
  17375. }
  17376. const looked_up = scope.find_variable(enclosed.name);
  17377. if (looked_up) {
  17378. if (looked_up === enclosed) continue;
  17379. return true;
  17380. }
  17381. }
  17382. return false;
  17383. }
  17384. function inline_into_symbolref(self, compressor) {
  17385. if (
  17386. !compressor.option("ie8")
  17387. && is_undeclared_ref(self)
  17388. && !compressor.find_parent(AST_With)
  17389. ) {
  17390. switch (self.name) {
  17391. case "undefined":
  17392. return make_node(AST_Undefined, self).optimize(compressor);
  17393. case "NaN":
  17394. return make_node(AST_NaN, self).optimize(compressor);
  17395. case "Infinity":
  17396. return make_node(AST_Infinity, self).optimize(compressor);
  17397. }
  17398. }
  17399. const parent = compressor.parent();
  17400. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  17401. const def = self.definition();
  17402. const nearest_scope = compressor.find_scope();
  17403. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  17404. def.fixed = false;
  17405. def.single_use = false;
  17406. return self;
  17407. }
  17408. let fixed = self.fixed_value();
  17409. let single_use = def.single_use
  17410. && !(parent instanceof AST_Call
  17411. && (parent.is_callee_pure(compressor))
  17412. || has_annotation(parent, _NOINLINE))
  17413. && !(parent instanceof AST_Export
  17414. && fixed instanceof AST_Lambda
  17415. && fixed.name);
  17416. if (single_use && fixed instanceof AST_Node) {
  17417. single_use =
  17418. !fixed.has_side_effects(compressor)
  17419. && !fixed.may_throw(compressor);
  17420. }
  17421. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  17422. if (retain_top_func(fixed, compressor)) {
  17423. single_use = false;
  17424. } else if (def.scope !== self.scope
  17425. && (def.escaped == 1
  17426. || has_flag(fixed, INLINED)
  17427. || within_array_or_object_literal(compressor)
  17428. || !compressor.option("reduce_funcs"))) {
  17429. single_use = false;
  17430. } else if (is_recursive_ref(compressor, def)) {
  17431. single_use = false;
  17432. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  17433. single_use = fixed.is_constant_expression(self.scope);
  17434. if (single_use == "f") {
  17435. var scope = self.scope;
  17436. do {
  17437. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  17438. set_flag(scope, INLINED);
  17439. }
  17440. } while (scope = scope.parent_scope);
  17441. }
  17442. }
  17443. }
  17444. if (single_use && fixed instanceof AST_Lambda) {
  17445. single_use =
  17446. def.scope === self.scope
  17447. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  17448. || parent instanceof AST_Call
  17449. && parent.expression === self
  17450. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  17451. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  17452. }
  17453. if (single_use && fixed) {
  17454. if (fixed instanceof AST_DefClass) {
  17455. set_flag(fixed, SQUEEZED);
  17456. fixed = make_node(AST_ClassExpression, fixed, fixed);
  17457. }
  17458. if (fixed instanceof AST_Defun) {
  17459. set_flag(fixed, SQUEEZED);
  17460. fixed = make_node(AST_Function, fixed, fixed);
  17461. }
  17462. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  17463. const defun_def = fixed.name.definition();
  17464. let lambda_def = fixed.variables.get(fixed.name.name);
  17465. let name = lambda_def && lambda_def.orig[0];
  17466. if (!(name instanceof AST_SymbolLambda)) {
  17467. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  17468. name.scope = fixed;
  17469. fixed.name = name;
  17470. lambda_def = fixed.def_function(name);
  17471. }
  17472. walk(fixed, node => {
  17473. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  17474. node.thedef = lambda_def;
  17475. lambda_def.references.push(node);
  17476. }
  17477. });
  17478. }
  17479. if (
  17480. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  17481. && fixed.parent_scope !== nearest_scope
  17482. ) {
  17483. fixed = fixed.clone(true, compressor.get_toplevel());
  17484. nearest_scope.add_child_scope(fixed);
  17485. }
  17486. return fixed.optimize(compressor);
  17487. }
  17488. // multiple uses
  17489. if (fixed) {
  17490. let replace;
  17491. if (fixed instanceof AST_This) {
  17492. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  17493. && def.references.every((ref) =>
  17494. def.scope === ref.scope
  17495. )) {
  17496. replace = fixed;
  17497. }
  17498. } else {
  17499. var ev = fixed.evaluate(compressor);
  17500. if (
  17501. ev !== fixed
  17502. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  17503. ) {
  17504. replace = make_node_from_constant(ev, fixed);
  17505. }
  17506. }
  17507. if (replace) {
  17508. const name_length = self.size(compressor);
  17509. const replace_size = replace.size(compressor);
  17510. let overhead = 0;
  17511. if (compressor.option("unused") && !compressor.exposed(def)) {
  17512. overhead =
  17513. (name_length + 2 + replace_size) /
  17514. (def.references.length - def.assignments);
  17515. }
  17516. if (replace_size <= name_length + overhead) {
  17517. return replace;
  17518. }
  17519. }
  17520. }
  17521. }
  17522. return self;
  17523. }
  17524. function inline_into_call(self, fn, compressor) {
  17525. var exp = self.expression;
  17526. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  17527. if (compressor.option("reduce_vars")
  17528. && fn instanceof AST_SymbolRef
  17529. && !has_annotation(self, _NOINLINE)
  17530. ) {
  17531. const fixed = fn.fixed_value();
  17532. if (!retain_top_func(fixed, compressor)) {
  17533. fn = fixed;
  17534. }
  17535. }
  17536. var is_func = fn instanceof AST_Lambda;
  17537. var stat = is_func && fn.body[0];
  17538. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  17539. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  17540. if (can_inline && stat instanceof AST_Return) {
  17541. let returned = stat.value;
  17542. if (!returned || returned.is_constant_expression()) {
  17543. if (returned) {
  17544. returned = returned.clone(true);
  17545. } else {
  17546. returned = make_node(AST_Undefined, self);
  17547. }
  17548. const args = self.args.concat(returned);
  17549. return make_sequence(self, args).optimize(compressor);
  17550. }
  17551. // optimize identity function
  17552. if (
  17553. fn.argnames.length === 1
  17554. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  17555. && self.args.length < 2
  17556. && returned instanceof AST_SymbolRef
  17557. && returned.name === fn.argnames[0].name
  17558. ) {
  17559. const replacement =
  17560. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  17561. let parent;
  17562. if (
  17563. replacement instanceof AST_PropAccess
  17564. && (parent = compressor.parent()) instanceof AST_Call
  17565. && parent.expression === self
  17566. ) {
  17567. // identity function was being used to remove `this`, like in
  17568. //
  17569. // id(bag.no_this)(...)
  17570. //
  17571. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  17572. return make_sequence(self, [
  17573. make_node(AST_Number, self, { value: 0 }),
  17574. replacement
  17575. ]);
  17576. }
  17577. // replace call with first argument or undefined if none passed
  17578. return replacement;
  17579. }
  17580. }
  17581. if (can_inline) {
  17582. var scope, in_loop, level = -1;
  17583. let def;
  17584. let returned_value;
  17585. let nearest_scope;
  17586. if (simple_args
  17587. && !fn.uses_arguments
  17588. && !(compressor.parent() instanceof AST_Class)
  17589. && !(fn.name && fn instanceof AST_Function)
  17590. && (returned_value = can_flatten_body(stat))
  17591. && (exp === fn
  17592. || has_annotation(self, _INLINE)
  17593. || compressor.option("unused")
  17594. && (def = exp.definition()).references.length == 1
  17595. && !is_recursive_ref(compressor, def)
  17596. && fn.is_constant_expression(exp.scope))
  17597. && !has_annotation(self, _PURE | _NOINLINE)
  17598. && !fn.contains_this()
  17599. && can_inject_symbols()
  17600. && (nearest_scope = compressor.find_scope())
  17601. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  17602. && !(function in_default_assign() {
  17603. // Due to the fact function parameters have their own scope
  17604. // which can't use `var something` in the function body within,
  17605. // we simply don't inline into DefaultAssign.
  17606. let i = 0;
  17607. let p;
  17608. while ((p = compressor.parent(i++))) {
  17609. if (p instanceof AST_DefaultAssign) return true;
  17610. if (p instanceof AST_Block) break;
  17611. }
  17612. return false;
  17613. })()
  17614. && !(scope instanceof AST_Class)
  17615. ) {
  17616. set_flag(fn, SQUEEZED);
  17617. nearest_scope.add_child_scope(fn);
  17618. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  17619. }
  17620. }
  17621. if (can_inline && has_annotation(self, _INLINE)) {
  17622. set_flag(fn, SQUEEZED);
  17623. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  17624. fn = fn.clone(true);
  17625. fn.figure_out_scope({}, {
  17626. parent_scope: compressor.find_scope(),
  17627. toplevel: compressor.get_toplevel()
  17628. });
  17629. return make_node(AST_Call, self, {
  17630. expression: fn,
  17631. args: self.args,
  17632. }).optimize(compressor);
  17633. }
  17634. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  17635. if (can_drop_this_call) {
  17636. var args = self.args.concat(make_node(AST_Undefined, self));
  17637. return make_sequence(self, args).optimize(compressor);
  17638. }
  17639. if (compressor.option("negate_iife")
  17640. && compressor.parent() instanceof AST_SimpleStatement
  17641. && is_iife_call(self)) {
  17642. return self.negate(compressor, true);
  17643. }
  17644. var ev = self.evaluate(compressor);
  17645. if (ev !== self) {
  17646. ev = make_node_from_constant(ev, self).optimize(compressor);
  17647. return best_of(compressor, ev, self);
  17648. }
  17649. return self;
  17650. function return_value(stat) {
  17651. if (!stat) return make_node(AST_Undefined, self);
  17652. if (stat instanceof AST_Return) {
  17653. if (!stat.value) return make_node(AST_Undefined, self);
  17654. return stat.value.clone(true);
  17655. }
  17656. if (stat instanceof AST_SimpleStatement) {
  17657. return make_node(AST_UnaryPrefix, stat, {
  17658. operator: "void",
  17659. expression: stat.body.clone(true)
  17660. });
  17661. }
  17662. }
  17663. function can_flatten_body(stat) {
  17664. var body = fn.body;
  17665. var len = body.length;
  17666. if (compressor.option("inline") < 3) {
  17667. return len == 1 && return_value(stat);
  17668. }
  17669. stat = null;
  17670. for (var i = 0; i < len; i++) {
  17671. var line = body[i];
  17672. if (line instanceof AST_Var) {
  17673. if (stat && !line.definitions.every((var_def) =>
  17674. !var_def.value
  17675. )) {
  17676. return false;
  17677. }
  17678. } else if (stat) {
  17679. return false;
  17680. } else if (!(line instanceof AST_EmptyStatement)) {
  17681. stat = line;
  17682. }
  17683. }
  17684. return return_value(stat);
  17685. }
  17686. function can_inject_args(block_scoped, safe_to_inject) {
  17687. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  17688. var arg = fn.argnames[i];
  17689. if (arg instanceof AST_DefaultAssign) {
  17690. if (has_flag(arg.left, UNUSED)) continue;
  17691. return false;
  17692. }
  17693. if (arg instanceof AST_Destructuring) return false;
  17694. if (arg instanceof AST_Expansion) {
  17695. if (has_flag(arg.expression, UNUSED)) continue;
  17696. return false;
  17697. }
  17698. if (has_flag(arg, UNUSED)) continue;
  17699. if (!safe_to_inject
  17700. || block_scoped.has(arg.name)
  17701. || identifier_atom.has(arg.name)
  17702. || scope.conflicting_def(arg.name)) {
  17703. return false;
  17704. }
  17705. if (in_loop) in_loop.push(arg.definition());
  17706. }
  17707. return true;
  17708. }
  17709. function can_inject_vars(block_scoped, safe_to_inject) {
  17710. var len = fn.body.length;
  17711. for (var i = 0; i < len; i++) {
  17712. var stat = fn.body[i];
  17713. if (!(stat instanceof AST_Var)) continue;
  17714. if (!safe_to_inject) return false;
  17715. for (var j = stat.definitions.length; --j >= 0;) {
  17716. var name = stat.definitions[j].name;
  17717. if (name instanceof AST_Destructuring
  17718. || block_scoped.has(name.name)
  17719. || identifier_atom.has(name.name)
  17720. || scope.conflicting_def(name.name)) {
  17721. return false;
  17722. }
  17723. if (in_loop) in_loop.push(name.definition());
  17724. }
  17725. }
  17726. return true;
  17727. }
  17728. function can_inject_symbols() {
  17729. var block_scoped = new Set();
  17730. do {
  17731. scope = compressor.parent(++level);
  17732. if (scope.is_block_scope() && scope.block_scope) {
  17733. // TODO this is sometimes undefined during compression.
  17734. // But it should always have a value!
  17735. scope.block_scope.variables.forEach(function (variable) {
  17736. block_scoped.add(variable.name);
  17737. });
  17738. }
  17739. if (scope instanceof AST_Catch) {
  17740. // TODO can we delete? AST_Catch is a block scope.
  17741. if (scope.argname) {
  17742. block_scoped.add(scope.argname.name);
  17743. }
  17744. } else if (scope instanceof AST_IterationStatement) {
  17745. in_loop = [];
  17746. } else if (scope instanceof AST_SymbolRef) {
  17747. if (scope.fixed_value() instanceof AST_Scope) return false;
  17748. }
  17749. } while (!(scope instanceof AST_Scope));
  17750. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  17751. var inline = compressor.option("inline");
  17752. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  17753. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  17754. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  17755. }
  17756. function append_var(decls, expressions, name, value) {
  17757. var def = name.definition();
  17758. // Name already exists, only when a function argument had the same name
  17759. const already_appended = scope.variables.has(name.name);
  17760. if (!already_appended) {
  17761. scope.variables.set(name.name, def);
  17762. scope.enclosed.push(def);
  17763. decls.push(make_node(AST_VarDef, name, {
  17764. name: name,
  17765. value: null
  17766. }));
  17767. }
  17768. var sym = make_node(AST_SymbolRef, name, name);
  17769. def.references.push(sym);
  17770. if (value) expressions.push(make_node(AST_Assign, self, {
  17771. operator: "=",
  17772. logical: false,
  17773. left: sym,
  17774. right: value.clone()
  17775. }));
  17776. }
  17777. function flatten_args(decls, expressions) {
  17778. var len = fn.argnames.length;
  17779. for (var i = self.args.length; --i >= len;) {
  17780. expressions.push(self.args[i]);
  17781. }
  17782. for (i = len; --i >= 0;) {
  17783. var name = fn.argnames[i];
  17784. var value = self.args[i];
  17785. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  17786. if (value) expressions.push(value);
  17787. } else {
  17788. var symbol = make_node(AST_SymbolVar, name, name);
  17789. name.definition().orig.push(symbol);
  17790. if (!value && in_loop) value = make_node(AST_Undefined, self);
  17791. append_var(decls, expressions, symbol, value);
  17792. }
  17793. }
  17794. decls.reverse();
  17795. expressions.reverse();
  17796. }
  17797. function flatten_vars(decls, expressions) {
  17798. var pos = expressions.length;
  17799. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  17800. var stat = fn.body[i];
  17801. if (!(stat instanceof AST_Var)) continue;
  17802. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  17803. var var_def = stat.definitions[j];
  17804. var name = var_def.name;
  17805. append_var(decls, expressions, name, var_def.value);
  17806. if (in_loop && fn.argnames.every((argname) =>
  17807. argname.name != name.name
  17808. )) {
  17809. var def = fn.variables.get(name.name);
  17810. var sym = make_node(AST_SymbolRef, name, name);
  17811. def.references.push(sym);
  17812. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  17813. operator: "=",
  17814. logical: false,
  17815. left: sym,
  17816. right: make_node(AST_Undefined, name)
  17817. }));
  17818. }
  17819. }
  17820. }
  17821. }
  17822. function flatten_fn(returned_value) {
  17823. var decls = [];
  17824. var expressions = [];
  17825. flatten_args(decls, expressions);
  17826. flatten_vars(decls, expressions);
  17827. expressions.push(returned_value);
  17828. if (decls.length) {
  17829. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  17830. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  17831. definitions: decls
  17832. }));
  17833. }
  17834. return expressions.map(exp => exp.clone(true));
  17835. }
  17836. }
  17837. /***********************************************************************
  17838. A JavaScript tokenizer / parser / beautifier / compressor.
  17839. https://github.com/mishoo/UglifyJS2
  17840. -------------------------------- (C) ---------------------------------
  17841. Author: Mihai Bazon
  17842. <mihai.bazon@gmail.com>
  17843. http://mihai.bazon.net/blog
  17844. Distributed under the BSD license:
  17845. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17846. Redistribution and use in source and binary forms, with or without
  17847. modification, are permitted provided that the following conditions
  17848. are met:
  17849. * Redistributions of source code must retain the above
  17850. copyright notice, this list of conditions and the following
  17851. disclaimer.
  17852. * Redistributions in binary form must reproduce the above
  17853. copyright notice, this list of conditions and the following
  17854. disclaimer in the documentation and/or other materials
  17855. provided with the distribution.
  17856. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17857. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17858. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17859. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17860. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17861. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17862. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17863. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17864. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17865. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17866. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17867. SUCH DAMAGE.
  17868. ***********************************************************************/
  17869. class Compressor extends TreeWalker {
  17870. constructor(options, { false_by_default = false, mangle_options = false }) {
  17871. super();
  17872. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  17873. this.options = defaults(options, {
  17874. arguments : false,
  17875. arrows : !false_by_default,
  17876. booleans : !false_by_default,
  17877. booleans_as_integers : false,
  17878. collapse_vars : !false_by_default,
  17879. comparisons : !false_by_default,
  17880. computed_props: !false_by_default,
  17881. conditionals : !false_by_default,
  17882. dead_code : !false_by_default,
  17883. defaults : true,
  17884. directives : !false_by_default,
  17885. drop_console : false,
  17886. drop_debugger : !false_by_default,
  17887. ecma : 5,
  17888. evaluate : !false_by_default,
  17889. expression : false,
  17890. global_defs : false,
  17891. hoist_funs : false,
  17892. hoist_props : !false_by_default,
  17893. hoist_vars : false,
  17894. ie8 : false,
  17895. if_return : !false_by_default,
  17896. inline : !false_by_default,
  17897. join_vars : !false_by_default,
  17898. keep_classnames: false,
  17899. keep_fargs : true,
  17900. keep_fnames : false,
  17901. keep_infinity : false,
  17902. loops : !false_by_default,
  17903. module : false,
  17904. negate_iife : !false_by_default,
  17905. passes : 1,
  17906. properties : !false_by_default,
  17907. pure_getters : !false_by_default && "strict",
  17908. pure_funcs : null,
  17909. reduce_funcs : !false_by_default,
  17910. reduce_vars : !false_by_default,
  17911. sequences : !false_by_default,
  17912. side_effects : !false_by_default,
  17913. switches : !false_by_default,
  17914. top_retain : null,
  17915. toplevel : !!(options && options["top_retain"]),
  17916. typeofs : !false_by_default,
  17917. unsafe : false,
  17918. unsafe_arrows : false,
  17919. unsafe_comps : false,
  17920. unsafe_Function: false,
  17921. unsafe_math : false,
  17922. unsafe_symbols: false,
  17923. unsafe_methods: false,
  17924. unsafe_proto : false,
  17925. unsafe_regexp : false,
  17926. unsafe_undefined: false,
  17927. unused : !false_by_default,
  17928. warnings : false // legacy
  17929. }, true);
  17930. var global_defs = this.options["global_defs"];
  17931. if (typeof global_defs == "object") for (var key in global_defs) {
  17932. if (key[0] === "@" && HOP(global_defs, key)) {
  17933. global_defs[key.slice(1)] = parse(global_defs[key], {
  17934. expression: true
  17935. });
  17936. }
  17937. }
  17938. if (this.options["inline"] === true) this.options["inline"] = 3;
  17939. var pure_funcs = this.options["pure_funcs"];
  17940. if (typeof pure_funcs == "function") {
  17941. this.pure_funcs = pure_funcs;
  17942. } else {
  17943. this.pure_funcs = pure_funcs ? function(node) {
  17944. return !pure_funcs.includes(node.expression.print_to_string());
  17945. } : return_true;
  17946. }
  17947. var top_retain = this.options["top_retain"];
  17948. if (top_retain instanceof RegExp) {
  17949. this.top_retain = function(def) {
  17950. return top_retain.test(def.name);
  17951. };
  17952. } else if (typeof top_retain == "function") {
  17953. this.top_retain = top_retain;
  17954. } else if (top_retain) {
  17955. if (typeof top_retain == "string") {
  17956. top_retain = top_retain.split(/,/);
  17957. }
  17958. this.top_retain = function(def) {
  17959. return top_retain.includes(def.name);
  17960. };
  17961. }
  17962. if (this.options["module"]) {
  17963. this.directives["use strict"] = true;
  17964. this.options["toplevel"] = true;
  17965. }
  17966. var toplevel = this.options["toplevel"];
  17967. this.toplevel = typeof toplevel == "string" ? {
  17968. funcs: /funcs/.test(toplevel),
  17969. vars: /vars/.test(toplevel)
  17970. } : {
  17971. funcs: toplevel,
  17972. vars: toplevel
  17973. };
  17974. var sequences = this.options["sequences"];
  17975. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  17976. this.evaluated_regexps = new Map();
  17977. this._toplevel = undefined;
  17978. this.mangle_options = mangle_options;
  17979. }
  17980. option(key) {
  17981. return this.options[key];
  17982. }
  17983. exposed(def) {
  17984. if (def.export) return true;
  17985. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  17986. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  17987. return true;
  17988. return false;
  17989. }
  17990. in_boolean_context() {
  17991. if (!this.option("booleans")) return false;
  17992. var self = this.self();
  17993. for (var i = 0, p; p = this.parent(i); i++) {
  17994. if (p instanceof AST_SimpleStatement
  17995. || p instanceof AST_Conditional && p.condition === self
  17996. || p instanceof AST_DWLoop && p.condition === self
  17997. || p instanceof AST_For && p.condition === self
  17998. || p instanceof AST_If && p.condition === self
  17999. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  18000. return true;
  18001. }
  18002. if (
  18003. p instanceof AST_Binary
  18004. && (
  18005. p.operator == "&&"
  18006. || p.operator == "||"
  18007. || p.operator == "??"
  18008. )
  18009. || p instanceof AST_Conditional
  18010. || p.tail_node() === self
  18011. ) {
  18012. self = p;
  18013. } else {
  18014. return false;
  18015. }
  18016. }
  18017. }
  18018. get_toplevel() {
  18019. return this._toplevel;
  18020. }
  18021. compress(toplevel) {
  18022. toplevel = toplevel.resolve_defines(this);
  18023. this._toplevel = toplevel;
  18024. if (this.option("expression")) {
  18025. this._toplevel.process_expression(true);
  18026. }
  18027. var passes = +this.options.passes || 1;
  18028. var min_count = 1 / 0;
  18029. var stopping = false;
  18030. var nth_identifier = this.mangle_options && this.mangle_options.nth_identifier || base54;
  18031. var mangle = { ie8: this.option("ie8"), nth_identifier: nth_identifier };
  18032. for (var pass = 0; pass < passes; pass++) {
  18033. this._toplevel.figure_out_scope(mangle);
  18034. if (pass === 0 && this.option("drop_console")) {
  18035. // must be run before reduce_vars and compress pass
  18036. this._toplevel = this._toplevel.drop_console();
  18037. }
  18038. if (pass > 0 || this.option("reduce_vars")) {
  18039. this._toplevel.reset_opt_flags(this);
  18040. }
  18041. this._toplevel = this._toplevel.transform(this);
  18042. if (passes > 1) {
  18043. let count = 0;
  18044. walk(this._toplevel, () => { count++; });
  18045. if (count < min_count) {
  18046. min_count = count;
  18047. stopping = false;
  18048. } else if (stopping) {
  18049. break;
  18050. } else {
  18051. stopping = true;
  18052. }
  18053. }
  18054. }
  18055. if (this.option("expression")) {
  18056. this._toplevel.process_expression(false);
  18057. }
  18058. toplevel = this._toplevel;
  18059. this._toplevel = undefined;
  18060. return toplevel;
  18061. }
  18062. before(node, descend) {
  18063. if (has_flag(node, SQUEEZED)) return node;
  18064. var was_scope = false;
  18065. if (node instanceof AST_Scope) {
  18066. node = node.hoist_properties(this);
  18067. node = node.hoist_declarations(this);
  18068. was_scope = true;
  18069. }
  18070. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  18071. // would call AST_Node.transform() if a different instance of AST_Node is
  18072. // produced after def_optimize().
  18073. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  18074. // Migrate and defer all children's AST_Node.transform() to below, which
  18075. // will now happen after this parent AST_Node has been properly substituted
  18076. // thus gives a consistent AST snapshot.
  18077. descend(node, this);
  18078. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  18079. // following replacement call would result in degraded efficiency of both
  18080. // output and performance.
  18081. descend(node, this);
  18082. var opt = node.optimize(this);
  18083. if (was_scope && opt instanceof AST_Scope) {
  18084. opt.drop_unused(this);
  18085. descend(opt, this);
  18086. }
  18087. if (opt === node) set_flag(opt, SQUEEZED);
  18088. return opt;
  18089. }
  18090. }
  18091. function def_optimize(node, optimizer) {
  18092. node.DEFMETHOD("optimize", function(compressor) {
  18093. var self = this;
  18094. if (has_flag(self, OPTIMIZED)) return self;
  18095. if (compressor.has_directive("use asm")) return self;
  18096. var opt = optimizer(self, compressor);
  18097. set_flag(opt, OPTIMIZED);
  18098. return opt;
  18099. });
  18100. }
  18101. def_optimize(AST_Node, function(self) {
  18102. return self;
  18103. });
  18104. AST_Toplevel.DEFMETHOD("drop_console", function() {
  18105. return this.transform(new TreeTransformer(function(self) {
  18106. if (self.TYPE == "Call") {
  18107. var exp = self.expression;
  18108. if (exp instanceof AST_PropAccess) {
  18109. var name = exp.expression;
  18110. while (name.expression) {
  18111. name = name.expression;
  18112. }
  18113. if (is_undeclared_ref(name) && name.name == "console") {
  18114. return make_node(AST_Undefined, self);
  18115. }
  18116. }
  18117. }
  18118. }));
  18119. });
  18120. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  18121. return equivalent_to(this, node);
  18122. });
  18123. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  18124. var self = this;
  18125. var tt = new TreeTransformer(function(node) {
  18126. if (insert && node instanceof AST_SimpleStatement) {
  18127. return make_node(AST_Return, node, {
  18128. value: node.body
  18129. });
  18130. }
  18131. if (!insert && node instanceof AST_Return) {
  18132. if (compressor) {
  18133. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  18134. return value
  18135. ? make_node(AST_SimpleStatement, node, { body: value })
  18136. : make_node(AST_EmptyStatement, node);
  18137. }
  18138. return make_node(AST_SimpleStatement, node, {
  18139. body: node.value || make_node(AST_UnaryPrefix, node, {
  18140. operator: "void",
  18141. expression: make_node(AST_Number, node, {
  18142. value: 0
  18143. })
  18144. })
  18145. });
  18146. }
  18147. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  18148. return node;
  18149. }
  18150. if (node instanceof AST_Block) {
  18151. var index = node.body.length - 1;
  18152. if (index >= 0) {
  18153. node.body[index] = node.body[index].transform(tt);
  18154. }
  18155. } else if (node instanceof AST_If) {
  18156. node.body = node.body.transform(tt);
  18157. if (node.alternative) {
  18158. node.alternative = node.alternative.transform(tt);
  18159. }
  18160. } else if (node instanceof AST_With) {
  18161. node.body = node.body.transform(tt);
  18162. }
  18163. return node;
  18164. });
  18165. self.transform(tt);
  18166. });
  18167. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  18168. const self = this;
  18169. const reduce_vars = compressor.option("reduce_vars");
  18170. const preparation = new TreeWalker(function(node, descend) {
  18171. clear_flag(node, CLEAR_BETWEEN_PASSES);
  18172. if (reduce_vars) {
  18173. if (compressor.top_retain
  18174. && node instanceof AST_Defun // Only functions are retained
  18175. && preparation.parent() === self
  18176. ) {
  18177. set_flag(node, TOP);
  18178. }
  18179. return node.reduce_vars(preparation, descend, compressor);
  18180. }
  18181. });
  18182. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  18183. // properly assigned before use:
  18184. // - `push()` & `pop()` when visiting conditional branches
  18185. preparation.safe_ids = Object.create(null);
  18186. preparation.in_loop = null;
  18187. preparation.loop_ids = new Map();
  18188. preparation.defs_to_safe_ids = new Map();
  18189. self.walk(preparation);
  18190. });
  18191. AST_Symbol.DEFMETHOD("fixed_value", function() {
  18192. var fixed = this.thedef.fixed;
  18193. if (!fixed || fixed instanceof AST_Node) return fixed;
  18194. return fixed();
  18195. });
  18196. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  18197. var orig = this.definition().orig;
  18198. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  18199. });
  18200. function find_variable(compressor, name) {
  18201. var scope, i = 0;
  18202. while (scope = compressor.parent(i++)) {
  18203. if (scope instanceof AST_Scope) break;
  18204. if (scope instanceof AST_Catch && scope.argname) {
  18205. scope = scope.argname.definition().scope;
  18206. break;
  18207. }
  18208. }
  18209. return scope.find_variable(name);
  18210. }
  18211. var global_names = makePredicate("Array Boolean clearInterval clearTimeout console Date decodeURI decodeURIComponent encodeURI encodeURIComponent Error escape eval EvalError Function isFinite isNaN JSON Math Number parseFloat parseInt RangeError ReferenceError RegExp Object setInterval setTimeout String SyntaxError TypeError unescape URIError");
  18212. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  18213. return !this.definition().undeclared
  18214. || compressor.option("unsafe") && global_names.has(this.name);
  18215. });
  18216. /* -----[ optimizers ]----- */
  18217. var directives = new Set(["use asm", "use strict"]);
  18218. def_optimize(AST_Directive, function(self, compressor) {
  18219. if (compressor.option("directives")
  18220. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  18221. return make_node(AST_EmptyStatement, self);
  18222. }
  18223. return self;
  18224. });
  18225. def_optimize(AST_Debugger, function(self, compressor) {
  18226. if (compressor.option("drop_debugger"))
  18227. return make_node(AST_EmptyStatement, self);
  18228. return self;
  18229. });
  18230. def_optimize(AST_LabeledStatement, function(self, compressor) {
  18231. if (self.body instanceof AST_Break
  18232. && compressor.loopcontrol_target(self.body) === self.body) {
  18233. return make_node(AST_EmptyStatement, self);
  18234. }
  18235. return self.label.references.length == 0 ? self.body : self;
  18236. });
  18237. def_optimize(AST_Block, function(self, compressor) {
  18238. tighten_body(self.body, compressor);
  18239. return self;
  18240. });
  18241. function can_be_extracted_from_if_block(node) {
  18242. return !(
  18243. node instanceof AST_Const
  18244. || node instanceof AST_Let
  18245. || node instanceof AST_Class
  18246. );
  18247. }
  18248. def_optimize(AST_BlockStatement, function(self, compressor) {
  18249. tighten_body(self.body, compressor);
  18250. switch (self.body.length) {
  18251. case 1:
  18252. if (!compressor.has_directive("use strict")
  18253. && compressor.parent() instanceof AST_If
  18254. && can_be_extracted_from_if_block(self.body[0])
  18255. || can_be_evicted_from_block(self.body[0])) {
  18256. return self.body[0];
  18257. }
  18258. break;
  18259. case 0: return make_node(AST_EmptyStatement, self);
  18260. }
  18261. return self;
  18262. });
  18263. function opt_AST_Lambda(self, compressor) {
  18264. tighten_body(self.body, compressor);
  18265. if (compressor.option("side_effects")
  18266. && self.body.length == 1
  18267. && self.body[0] === compressor.has_directive("use strict")) {
  18268. self.body.length = 0;
  18269. }
  18270. return self;
  18271. }
  18272. def_optimize(AST_Lambda, opt_AST_Lambda);
  18273. const r_keep_assign = /keep_assign/;
  18274. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  18275. if (!compressor.option("unused")) return;
  18276. if (compressor.has_directive("use asm")) return;
  18277. var self = this;
  18278. if (self.pinned()) return;
  18279. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  18280. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  18281. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  18282. if (node instanceof AST_Assign
  18283. && !node.logical
  18284. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  18285. ) {
  18286. return node.left;
  18287. }
  18288. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  18289. return node.expression;
  18290. }
  18291. };
  18292. var in_use_ids = new Map();
  18293. var fixed_ids = new Map();
  18294. if (self instanceof AST_Toplevel && compressor.top_retain) {
  18295. self.variables.forEach(function(def) {
  18296. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  18297. in_use_ids.set(def.id, def);
  18298. }
  18299. });
  18300. }
  18301. var var_defs_by_id = new Map();
  18302. var initializations = new Map();
  18303. // pass 1: find out which symbols are directly used in
  18304. // this scope (not in nested scopes).
  18305. var scope = this;
  18306. var tw = new TreeWalker(function(node, descend) {
  18307. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  18308. node.argnames.forEach(function(argname) {
  18309. if (!(argname instanceof AST_SymbolDeclaration)) return;
  18310. var def = argname.definition();
  18311. if (!in_use_ids.has(def.id)) {
  18312. in_use_ids.set(def.id, def);
  18313. }
  18314. });
  18315. }
  18316. if (node === self) return;
  18317. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  18318. var node_def = node.name.definition();
  18319. const in_export = tw.parent() instanceof AST_Export;
  18320. if (in_export || !drop_funcs && scope === self) {
  18321. if (node_def.global && !in_use_ids.has(node_def.id)) {
  18322. in_use_ids.set(node_def.id, node_def);
  18323. }
  18324. }
  18325. if (node instanceof AST_DefClass) {
  18326. if (
  18327. node.extends
  18328. && (node.extends.has_side_effects(compressor)
  18329. || node.extends.may_throw(compressor))
  18330. ) {
  18331. node.extends.walk(tw);
  18332. }
  18333. for (const prop of node.properties) {
  18334. if (
  18335. prop.has_side_effects(compressor) ||
  18336. prop.may_throw(compressor)
  18337. ) {
  18338. prop.walk(tw);
  18339. }
  18340. }
  18341. }
  18342. map_add(initializations, node_def.id, node);
  18343. return true; // don't go in nested scopes
  18344. }
  18345. if (node instanceof AST_SymbolFunarg && scope === self) {
  18346. map_add(var_defs_by_id, node.definition().id, node);
  18347. }
  18348. if (node instanceof AST_Definitions && scope === self) {
  18349. const in_export = tw.parent() instanceof AST_Export;
  18350. node.definitions.forEach(function(def) {
  18351. if (def.name instanceof AST_SymbolVar) {
  18352. map_add(var_defs_by_id, def.name.definition().id, def);
  18353. }
  18354. if (in_export || !drop_vars) {
  18355. walk(def.name, node => {
  18356. if (node instanceof AST_SymbolDeclaration) {
  18357. const def = node.definition();
  18358. if (
  18359. (in_export || def.global)
  18360. && !in_use_ids.has(def.id)
  18361. ) {
  18362. in_use_ids.set(def.id, def);
  18363. }
  18364. }
  18365. });
  18366. }
  18367. if (def.value) {
  18368. if (def.name instanceof AST_Destructuring) {
  18369. def.walk(tw);
  18370. } else {
  18371. var node_def = def.name.definition();
  18372. map_add(initializations, node_def.id, def.value);
  18373. if (!node_def.chained && def.name.fixed_value() === def.value) {
  18374. fixed_ids.set(node_def.id, def);
  18375. }
  18376. }
  18377. if (def.value.has_side_effects(compressor)) {
  18378. def.value.walk(tw);
  18379. }
  18380. }
  18381. });
  18382. return true;
  18383. }
  18384. return scan_ref_scoped(node, descend);
  18385. });
  18386. self.walk(tw);
  18387. // pass 2: for every used symbol we need to walk its
  18388. // initialization code to figure out if it uses other
  18389. // symbols (that may not be in_use).
  18390. tw = new TreeWalker(scan_ref_scoped);
  18391. in_use_ids.forEach(function (def) {
  18392. var init = initializations.get(def.id);
  18393. if (init) init.forEach(function(init) {
  18394. init.walk(tw);
  18395. });
  18396. });
  18397. // pass 3: we should drop declarations not in_use
  18398. var tt = new TreeTransformer(
  18399. function before(node, descend, in_list) {
  18400. var parent = tt.parent();
  18401. if (drop_vars) {
  18402. const sym = assign_as_unused(node);
  18403. if (sym instanceof AST_SymbolRef) {
  18404. var def = sym.definition();
  18405. var in_use = in_use_ids.has(def.id);
  18406. if (node instanceof AST_Assign) {
  18407. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  18408. return maintain_this_binding(parent, node, node.right.transform(tt));
  18409. }
  18410. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  18411. value: 0
  18412. });
  18413. }
  18414. }
  18415. if (scope !== self) return;
  18416. var def;
  18417. if (node.name
  18418. && (node instanceof AST_ClassExpression
  18419. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  18420. || node instanceof AST_Function
  18421. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  18422. // any declarations with same name will overshadow
  18423. // name of this anonymous function and can therefore
  18424. // never be used anywhere
  18425. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  18426. }
  18427. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  18428. var trim = !compressor.option("keep_fargs");
  18429. for (var a = node.argnames, i = a.length; --i >= 0;) {
  18430. var sym = a[i];
  18431. if (sym instanceof AST_Expansion) {
  18432. sym = sym.expression;
  18433. }
  18434. if (sym instanceof AST_DefaultAssign) {
  18435. sym = sym.left;
  18436. }
  18437. // Do not drop destructuring arguments.
  18438. // They constitute a type assertion, so dropping
  18439. // them would stop that TypeError which would happen
  18440. // if someone called it with an incorrectly formatted
  18441. // parameter.
  18442. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  18443. set_flag(sym, UNUSED);
  18444. if (trim) {
  18445. a.pop();
  18446. }
  18447. } else {
  18448. trim = false;
  18449. }
  18450. }
  18451. }
  18452. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  18453. const def = node.name.definition();
  18454. let keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  18455. if (!keep) {
  18456. def.eliminated++;
  18457. if (node instanceof AST_DefClass) {
  18458. // Classes might have extends with side effects
  18459. const side_effects = node.drop_side_effect_free(compressor);
  18460. if (side_effects) {
  18461. return make_node(AST_SimpleStatement, node, {
  18462. body: side_effects
  18463. });
  18464. }
  18465. }
  18466. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  18467. }
  18468. }
  18469. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  18470. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  18471. // place uninitialized names at the start
  18472. var body = [], head = [], tail = [];
  18473. // for unused names whose initialization has
  18474. // side effects, we can cascade the init. code
  18475. // into the next one, or next statement.
  18476. var side_effects = [];
  18477. node.definitions.forEach(function(def) {
  18478. if (def.value) def.value = def.value.transform(tt);
  18479. var is_destructure = def.name instanceof AST_Destructuring;
  18480. var sym = is_destructure
  18481. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  18482. : def.name.definition();
  18483. if (drop_block && sym.global) return tail.push(def);
  18484. if (!(drop_vars || drop_block)
  18485. || is_destructure
  18486. && (def.name.names.length
  18487. || def.name.is_array
  18488. || compressor.option("pure_getters") != true)
  18489. || in_use_ids.has(sym.id)
  18490. ) {
  18491. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  18492. def.value = def.value.drop_side_effect_free(compressor);
  18493. }
  18494. if (def.name instanceof AST_SymbolVar) {
  18495. var var_defs = var_defs_by_id.get(sym.id);
  18496. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  18497. if (def.value) {
  18498. var ref = make_node(AST_SymbolRef, def.name, def.name);
  18499. sym.references.push(ref);
  18500. var assign = make_node(AST_Assign, def, {
  18501. operator: "=",
  18502. logical: false,
  18503. left: ref,
  18504. right: def.value
  18505. });
  18506. if (fixed_ids.get(sym.id) === def) {
  18507. fixed_ids.set(sym.id, assign);
  18508. }
  18509. side_effects.push(assign.transform(tt));
  18510. }
  18511. remove(var_defs, def);
  18512. sym.eliminated++;
  18513. return;
  18514. }
  18515. }
  18516. if (def.value) {
  18517. if (side_effects.length > 0) {
  18518. if (tail.length > 0) {
  18519. side_effects.push(def.value);
  18520. def.value = make_sequence(def.value, side_effects);
  18521. } else {
  18522. body.push(make_node(AST_SimpleStatement, node, {
  18523. body: make_sequence(node, side_effects)
  18524. }));
  18525. }
  18526. side_effects = [];
  18527. }
  18528. tail.push(def);
  18529. } else {
  18530. head.push(def);
  18531. }
  18532. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  18533. var value = def.value && def.value.drop_side_effect_free(compressor);
  18534. if (value) side_effects.push(value);
  18535. def.value = null;
  18536. head.push(def);
  18537. } else {
  18538. var value = def.value && def.value.drop_side_effect_free(compressor);
  18539. if (value) {
  18540. side_effects.push(value);
  18541. }
  18542. sym.eliminated++;
  18543. }
  18544. });
  18545. if (head.length > 0 || tail.length > 0) {
  18546. node.definitions = head.concat(tail);
  18547. body.push(node);
  18548. }
  18549. if (side_effects.length > 0) {
  18550. body.push(make_node(AST_SimpleStatement, node, {
  18551. body: make_sequence(node, side_effects)
  18552. }));
  18553. }
  18554. switch (body.length) {
  18555. case 0:
  18556. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  18557. case 1:
  18558. return body[0];
  18559. default:
  18560. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  18561. body: body
  18562. });
  18563. }
  18564. }
  18565. // certain combination of unused name + side effect leads to:
  18566. // https://github.com/mishoo/UglifyJS2/issues/44
  18567. // https://github.com/mishoo/UglifyJS2/issues/1830
  18568. // https://github.com/mishoo/UglifyJS2/issues/1838
  18569. // that's an invalid AST.
  18570. // We fix it at this stage by moving the `var` outside the `for`.
  18571. if (node instanceof AST_For) {
  18572. descend(node, this);
  18573. var block;
  18574. if (node.init instanceof AST_BlockStatement) {
  18575. block = node.init;
  18576. node.init = block.body.pop();
  18577. block.body.push(node);
  18578. }
  18579. if (node.init instanceof AST_SimpleStatement) {
  18580. node.init = node.init.body;
  18581. } else if (is_empty(node.init)) {
  18582. node.init = null;
  18583. }
  18584. return !block ? node : in_list ? MAP.splice(block.body) : block;
  18585. }
  18586. if (node instanceof AST_LabeledStatement
  18587. && node.body instanceof AST_For
  18588. ) {
  18589. descend(node, this);
  18590. if (node.body instanceof AST_BlockStatement) {
  18591. var block = node.body;
  18592. node.body = block.body.pop();
  18593. block.body.push(node);
  18594. return in_list ? MAP.splice(block.body) : block;
  18595. }
  18596. return node;
  18597. }
  18598. if (node instanceof AST_BlockStatement) {
  18599. descend(node, this);
  18600. if (in_list && node.body.every(can_be_evicted_from_block)) {
  18601. return MAP.splice(node.body);
  18602. }
  18603. return node;
  18604. }
  18605. if (node instanceof AST_Scope) {
  18606. const save_scope = scope;
  18607. scope = node;
  18608. descend(node, this);
  18609. scope = save_scope;
  18610. return node;
  18611. }
  18612. }
  18613. );
  18614. self.transform(tt);
  18615. function scan_ref_scoped(node, descend) {
  18616. var node_def;
  18617. const sym = assign_as_unused(node);
  18618. if (sym instanceof AST_SymbolRef
  18619. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  18620. && self.variables.get(sym.name) === (node_def = sym.definition())
  18621. ) {
  18622. if (node instanceof AST_Assign) {
  18623. node.right.walk(tw);
  18624. if (!node_def.chained && node.left.fixed_value() === node.right) {
  18625. fixed_ids.set(node_def.id, node);
  18626. }
  18627. }
  18628. return true;
  18629. }
  18630. if (node instanceof AST_SymbolRef) {
  18631. node_def = node.definition();
  18632. if (!in_use_ids.has(node_def.id)) {
  18633. in_use_ids.set(node_def.id, node_def);
  18634. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  18635. const redef = node_def.scope.is_block_scope()
  18636. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  18637. if (redef) in_use_ids.set(redef.id, redef);
  18638. }
  18639. }
  18640. return true;
  18641. }
  18642. if (node instanceof AST_Scope) {
  18643. var save_scope = scope;
  18644. scope = node;
  18645. descend();
  18646. scope = save_scope;
  18647. return true;
  18648. }
  18649. }
  18650. });
  18651. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  18652. var self = this;
  18653. if (compressor.has_directive("use asm")) return self;
  18654. // Hoisting makes no sense in an arrow func
  18655. if (!Array.isArray(self.body)) return self;
  18656. var hoist_funs = compressor.option("hoist_funs");
  18657. var hoist_vars = compressor.option("hoist_vars");
  18658. if (hoist_funs || hoist_vars) {
  18659. var dirs = [];
  18660. var hoisted = [];
  18661. var vars = new Map(), vars_found = 0, var_decl = 0;
  18662. // let's count var_decl first, we seem to waste a lot of
  18663. // space if we hoist `var` when there's only one.
  18664. walk(self, node => {
  18665. if (node instanceof AST_Scope && node !== self)
  18666. return true;
  18667. if (node instanceof AST_Var) {
  18668. ++var_decl;
  18669. return true;
  18670. }
  18671. });
  18672. hoist_vars = hoist_vars && var_decl > 1;
  18673. var tt = new TreeTransformer(
  18674. function before(node) {
  18675. if (node !== self) {
  18676. if (node instanceof AST_Directive) {
  18677. dirs.push(node);
  18678. return make_node(AST_EmptyStatement, node);
  18679. }
  18680. if (hoist_funs && node instanceof AST_Defun
  18681. && !(tt.parent() instanceof AST_Export)
  18682. && tt.parent() === self) {
  18683. hoisted.push(node);
  18684. return make_node(AST_EmptyStatement, node);
  18685. }
  18686. if (
  18687. hoist_vars
  18688. && node instanceof AST_Var
  18689. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  18690. ) {
  18691. node.definitions.forEach(function(def) {
  18692. vars.set(def.name.name, def);
  18693. ++vars_found;
  18694. });
  18695. var seq = node.to_assignments(compressor);
  18696. var p = tt.parent();
  18697. if (p instanceof AST_ForIn && p.init === node) {
  18698. if (seq == null) {
  18699. var def = node.definitions[0].name;
  18700. return make_node(AST_SymbolRef, def, def);
  18701. }
  18702. return seq;
  18703. }
  18704. if (p instanceof AST_For && p.init === node) {
  18705. return seq;
  18706. }
  18707. if (!seq) return make_node(AST_EmptyStatement, node);
  18708. return make_node(AST_SimpleStatement, node, {
  18709. body: seq
  18710. });
  18711. }
  18712. if (node instanceof AST_Scope)
  18713. return node; // to avoid descending in nested scopes
  18714. }
  18715. }
  18716. );
  18717. self = self.transform(tt);
  18718. if (vars_found > 0) {
  18719. // collect only vars which don't show up in self's arguments list
  18720. var defs = [];
  18721. const is_lambda = self instanceof AST_Lambda;
  18722. const args_as_names = is_lambda ? self.args_as_names() : null;
  18723. vars.forEach((def, name) => {
  18724. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  18725. vars.delete(name);
  18726. } else {
  18727. def = def.clone();
  18728. def.value = null;
  18729. defs.push(def);
  18730. vars.set(name, def);
  18731. }
  18732. });
  18733. if (defs.length > 0) {
  18734. // try to merge in assignments
  18735. for (var i = 0; i < self.body.length;) {
  18736. if (self.body[i] instanceof AST_SimpleStatement) {
  18737. var expr = self.body[i].body, sym, assign;
  18738. if (expr instanceof AST_Assign
  18739. && expr.operator == "="
  18740. && (sym = expr.left) instanceof AST_Symbol
  18741. && vars.has(sym.name)
  18742. ) {
  18743. var def = vars.get(sym.name);
  18744. if (def.value) break;
  18745. def.value = expr.right;
  18746. remove(defs, def);
  18747. defs.push(def);
  18748. self.body.splice(i, 1);
  18749. continue;
  18750. }
  18751. if (expr instanceof AST_Sequence
  18752. && (assign = expr.expressions[0]) instanceof AST_Assign
  18753. && assign.operator == "="
  18754. && (sym = assign.left) instanceof AST_Symbol
  18755. && vars.has(sym.name)
  18756. ) {
  18757. var def = vars.get(sym.name);
  18758. if (def.value) break;
  18759. def.value = assign.right;
  18760. remove(defs, def);
  18761. defs.push(def);
  18762. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  18763. continue;
  18764. }
  18765. }
  18766. if (self.body[i] instanceof AST_EmptyStatement) {
  18767. self.body.splice(i, 1);
  18768. continue;
  18769. }
  18770. if (self.body[i] instanceof AST_BlockStatement) {
  18771. self.body.splice(i, 1, ...self.body[i].body);
  18772. continue;
  18773. }
  18774. break;
  18775. }
  18776. defs = make_node(AST_Var, self, {
  18777. definitions: defs
  18778. });
  18779. hoisted.push(defs);
  18780. }
  18781. }
  18782. self.body = dirs.concat(hoisted, self.body);
  18783. }
  18784. return self;
  18785. });
  18786. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  18787. var self = this;
  18788. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  18789. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  18790. var defs_by_id = new Map();
  18791. var hoister = new TreeTransformer(function(node, descend) {
  18792. if (node instanceof AST_Definitions
  18793. && hoister.parent() instanceof AST_Export) return node;
  18794. if (node instanceof AST_VarDef) {
  18795. const sym = node.name;
  18796. let def;
  18797. let value;
  18798. if (sym.scope === self
  18799. && (def = sym.definition()).escaped != 1
  18800. && !def.assignments
  18801. && !def.direct_access
  18802. && !def.single_use
  18803. && !compressor.exposed(def)
  18804. && !top_retain(def)
  18805. && (value = sym.fixed_value()) === node.value
  18806. && value instanceof AST_Object
  18807. && !value.properties.some(prop =>
  18808. prop instanceof AST_Expansion || prop.computed_key()
  18809. )
  18810. ) {
  18811. descend(node, this);
  18812. const defs = new Map();
  18813. const assignments = [];
  18814. value.properties.forEach(({ key, value }) => {
  18815. const scope = hoister.find_scope();
  18816. const symbol = self.create_symbol(sym.CTOR, {
  18817. source: sym,
  18818. scope,
  18819. conflict_scopes: new Set([
  18820. scope,
  18821. ...sym.definition().references.map(ref => ref.scope)
  18822. ]),
  18823. tentative_name: sym.name + "_" + key
  18824. });
  18825. defs.set(String(key), symbol.definition());
  18826. assignments.push(make_node(AST_VarDef, node, {
  18827. name: symbol,
  18828. value
  18829. }));
  18830. });
  18831. defs_by_id.set(def.id, defs);
  18832. return MAP.splice(assignments);
  18833. }
  18834. } else if (node instanceof AST_PropAccess
  18835. && node.expression instanceof AST_SymbolRef
  18836. ) {
  18837. const defs = defs_by_id.get(node.expression.definition().id);
  18838. if (defs) {
  18839. const def = defs.get(String(get_simple_key(node.property)));
  18840. const sym = make_node(AST_SymbolRef, node, {
  18841. name: def.name,
  18842. scope: node.expression.scope,
  18843. thedef: def
  18844. });
  18845. sym.reference({});
  18846. return sym;
  18847. }
  18848. }
  18849. });
  18850. return self.transform(hoister);
  18851. });
  18852. def_optimize(AST_SimpleStatement, function(self, compressor) {
  18853. if (compressor.option("side_effects")) {
  18854. var body = self.body;
  18855. var node = body.drop_side_effect_free(compressor, true);
  18856. if (!node) {
  18857. return make_node(AST_EmptyStatement, self);
  18858. }
  18859. if (node !== body) {
  18860. return make_node(AST_SimpleStatement, self, { body: node });
  18861. }
  18862. }
  18863. return self;
  18864. });
  18865. def_optimize(AST_While, function(self, compressor) {
  18866. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  18867. });
  18868. def_optimize(AST_Do, function(self, compressor) {
  18869. if (!compressor.option("loops")) return self;
  18870. var cond = self.condition.tail_node().evaluate(compressor);
  18871. if (!(cond instanceof AST_Node)) {
  18872. if (cond) return make_node(AST_For, self, {
  18873. body: make_node(AST_BlockStatement, self.body, {
  18874. body: [
  18875. self.body,
  18876. make_node(AST_SimpleStatement, self.condition, {
  18877. body: self.condition
  18878. })
  18879. ]
  18880. })
  18881. }).optimize(compressor);
  18882. if (!has_break_or_continue(self, compressor.parent())) {
  18883. return make_node(AST_BlockStatement, self.body, {
  18884. body: [
  18885. self.body,
  18886. make_node(AST_SimpleStatement, self.condition, {
  18887. body: self.condition
  18888. })
  18889. ]
  18890. }).optimize(compressor);
  18891. }
  18892. }
  18893. return self;
  18894. });
  18895. function if_break_in_loop(self, compressor) {
  18896. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  18897. if (compressor.option("dead_code") && is_break(first)) {
  18898. var body = [];
  18899. if (self.init instanceof AST_Statement) {
  18900. body.push(self.init);
  18901. } else if (self.init) {
  18902. body.push(make_node(AST_SimpleStatement, self.init, {
  18903. body: self.init
  18904. }));
  18905. }
  18906. if (self.condition) {
  18907. body.push(make_node(AST_SimpleStatement, self.condition, {
  18908. body: self.condition
  18909. }));
  18910. }
  18911. trim_unreachable_code(compressor, self.body, body);
  18912. return make_node(AST_BlockStatement, self, {
  18913. body: body
  18914. });
  18915. }
  18916. if (first instanceof AST_If) {
  18917. if (is_break(first.body)) {
  18918. if (self.condition) {
  18919. self.condition = make_node(AST_Binary, self.condition, {
  18920. left: self.condition,
  18921. operator: "&&",
  18922. right: first.condition.negate(compressor),
  18923. });
  18924. } else {
  18925. self.condition = first.condition.negate(compressor);
  18926. }
  18927. drop_it(first.alternative);
  18928. } else if (is_break(first.alternative)) {
  18929. if (self.condition) {
  18930. self.condition = make_node(AST_Binary, self.condition, {
  18931. left: self.condition,
  18932. operator: "&&",
  18933. right: first.condition,
  18934. });
  18935. } else {
  18936. self.condition = first.condition;
  18937. }
  18938. drop_it(first.body);
  18939. }
  18940. }
  18941. return self;
  18942. function is_break(node) {
  18943. return node instanceof AST_Break
  18944. && compressor.loopcontrol_target(node) === compressor.self();
  18945. }
  18946. function drop_it(rest) {
  18947. rest = as_statement_array(rest);
  18948. if (self.body instanceof AST_BlockStatement) {
  18949. self.body = self.body.clone();
  18950. self.body.body = rest.concat(self.body.body.slice(1));
  18951. self.body = self.body.transform(compressor);
  18952. } else {
  18953. self.body = make_node(AST_BlockStatement, self.body, {
  18954. body: rest
  18955. }).transform(compressor);
  18956. }
  18957. self = if_break_in_loop(self, compressor);
  18958. }
  18959. }
  18960. def_optimize(AST_For, function(self, compressor) {
  18961. if (!compressor.option("loops")) return self;
  18962. if (compressor.option("side_effects") && self.init) {
  18963. self.init = self.init.drop_side_effect_free(compressor);
  18964. }
  18965. if (self.condition) {
  18966. var cond = self.condition.evaluate(compressor);
  18967. if (!(cond instanceof AST_Node)) {
  18968. if (cond) self.condition = null;
  18969. else if (!compressor.option("dead_code")) {
  18970. var orig = self.condition;
  18971. self.condition = make_node_from_constant(cond, self.condition);
  18972. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  18973. }
  18974. }
  18975. if (compressor.option("dead_code")) {
  18976. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  18977. if (!cond) {
  18978. var body = [];
  18979. trim_unreachable_code(compressor, self.body, body);
  18980. if (self.init instanceof AST_Statement) {
  18981. body.push(self.init);
  18982. } else if (self.init) {
  18983. body.push(make_node(AST_SimpleStatement, self.init, {
  18984. body: self.init
  18985. }));
  18986. }
  18987. body.push(make_node(AST_SimpleStatement, self.condition, {
  18988. body: self.condition
  18989. }));
  18990. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  18991. }
  18992. }
  18993. }
  18994. return if_break_in_loop(self, compressor);
  18995. });
  18996. def_optimize(AST_If, function(self, compressor) {
  18997. if (is_empty(self.alternative)) self.alternative = null;
  18998. if (!compressor.option("conditionals")) return self;
  18999. // if condition can be statically determined, drop
  19000. // one of the blocks. note, statically determined implies
  19001. // “has no side effects”; also it doesn't work for cases like
  19002. // `x && true`, though it probably should.
  19003. var cond = self.condition.evaluate(compressor);
  19004. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  19005. var orig = self.condition;
  19006. self.condition = make_node_from_constant(cond, orig);
  19007. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  19008. }
  19009. if (compressor.option("dead_code")) {
  19010. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  19011. if (!cond) {
  19012. var body = [];
  19013. trim_unreachable_code(compressor, self.body, body);
  19014. body.push(make_node(AST_SimpleStatement, self.condition, {
  19015. body: self.condition
  19016. }));
  19017. if (self.alternative) body.push(self.alternative);
  19018. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  19019. } else if (!(cond instanceof AST_Node)) {
  19020. var body = [];
  19021. body.push(make_node(AST_SimpleStatement, self.condition, {
  19022. body: self.condition
  19023. }));
  19024. body.push(self.body);
  19025. if (self.alternative) {
  19026. trim_unreachable_code(compressor, self.alternative, body);
  19027. }
  19028. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  19029. }
  19030. }
  19031. var negated = self.condition.negate(compressor);
  19032. var self_condition_length = self.condition.size();
  19033. var negated_length = negated.size();
  19034. var negated_is_best = negated_length < self_condition_length;
  19035. if (self.alternative && negated_is_best) {
  19036. negated_is_best = false; // because we already do the switch here.
  19037. // no need to swap values of self_condition_length and negated_length
  19038. // here because they are only used in an equality comparison later on.
  19039. self.condition = negated;
  19040. var tmp = self.body;
  19041. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  19042. self.alternative = tmp;
  19043. }
  19044. if (is_empty(self.body) && is_empty(self.alternative)) {
  19045. return make_node(AST_SimpleStatement, self.condition, {
  19046. body: self.condition.clone()
  19047. }).optimize(compressor);
  19048. }
  19049. if (self.body instanceof AST_SimpleStatement
  19050. && self.alternative instanceof AST_SimpleStatement) {
  19051. return make_node(AST_SimpleStatement, self, {
  19052. body: make_node(AST_Conditional, self, {
  19053. condition : self.condition,
  19054. consequent : self.body.body,
  19055. alternative : self.alternative.body
  19056. })
  19057. }).optimize(compressor);
  19058. }
  19059. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  19060. if (self_condition_length === negated_length && !negated_is_best
  19061. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  19062. // although the code length of self.condition and negated are the same,
  19063. // negated does not require additional surrounding parentheses.
  19064. // see https://github.com/mishoo/UglifyJS2/issues/979
  19065. negated_is_best = true;
  19066. }
  19067. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  19068. body: make_node(AST_Binary, self, {
  19069. operator : "||",
  19070. left : negated,
  19071. right : self.body.body
  19072. })
  19073. }).optimize(compressor);
  19074. return make_node(AST_SimpleStatement, self, {
  19075. body: make_node(AST_Binary, self, {
  19076. operator : "&&",
  19077. left : self.condition,
  19078. right : self.body.body
  19079. })
  19080. }).optimize(compressor);
  19081. }
  19082. if (self.body instanceof AST_EmptyStatement
  19083. && self.alternative instanceof AST_SimpleStatement) {
  19084. return make_node(AST_SimpleStatement, self, {
  19085. body: make_node(AST_Binary, self, {
  19086. operator : "||",
  19087. left : self.condition,
  19088. right : self.alternative.body
  19089. })
  19090. }).optimize(compressor);
  19091. }
  19092. if (self.body instanceof AST_Exit
  19093. && self.alternative instanceof AST_Exit
  19094. && self.body.TYPE == self.alternative.TYPE) {
  19095. return make_node(self.body.CTOR, self, {
  19096. value: make_node(AST_Conditional, self, {
  19097. condition : self.condition,
  19098. consequent : self.body.value || make_node(AST_Undefined, self.body),
  19099. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  19100. }).transform(compressor)
  19101. }).optimize(compressor);
  19102. }
  19103. if (self.body instanceof AST_If
  19104. && !self.body.alternative
  19105. && !self.alternative) {
  19106. self = make_node(AST_If, self, {
  19107. condition: make_node(AST_Binary, self.condition, {
  19108. operator: "&&",
  19109. left: self.condition,
  19110. right: self.body.condition
  19111. }),
  19112. body: self.body.body,
  19113. alternative: null
  19114. });
  19115. }
  19116. if (aborts(self.body)) {
  19117. if (self.alternative) {
  19118. var alt = self.alternative;
  19119. self.alternative = null;
  19120. return make_node(AST_BlockStatement, self, {
  19121. body: [ self, alt ]
  19122. }).optimize(compressor);
  19123. }
  19124. }
  19125. if (aborts(self.alternative)) {
  19126. var body = self.body;
  19127. self.body = self.alternative;
  19128. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  19129. self.alternative = null;
  19130. return make_node(AST_BlockStatement, self, {
  19131. body: [ self, body ]
  19132. }).optimize(compressor);
  19133. }
  19134. return self;
  19135. });
  19136. def_optimize(AST_Switch, function(self, compressor) {
  19137. if (!compressor.option("switches")) return self;
  19138. var branch;
  19139. var value = self.expression.evaluate(compressor);
  19140. if (!(value instanceof AST_Node)) {
  19141. var orig = self.expression;
  19142. self.expression = make_node_from_constant(value, orig);
  19143. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  19144. }
  19145. if (!compressor.option("dead_code")) return self;
  19146. if (value instanceof AST_Node) {
  19147. value = self.expression.tail_node().evaluate(compressor);
  19148. }
  19149. var decl = [];
  19150. var body = [];
  19151. var default_branch;
  19152. var exact_match;
  19153. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  19154. branch = self.body[i];
  19155. if (branch instanceof AST_Default) {
  19156. if (!default_branch) {
  19157. default_branch = branch;
  19158. } else {
  19159. eliminate_branch(branch, body[body.length - 1]);
  19160. }
  19161. } else if (!(value instanceof AST_Node)) {
  19162. var exp = branch.expression.evaluate(compressor);
  19163. if (!(exp instanceof AST_Node) && exp !== value) {
  19164. eliminate_branch(branch, body[body.length - 1]);
  19165. continue;
  19166. }
  19167. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  19168. if (exp === value) {
  19169. exact_match = branch;
  19170. if (default_branch) {
  19171. var default_index = body.indexOf(default_branch);
  19172. body.splice(default_index, 1);
  19173. eliminate_branch(default_branch, body[default_index - 1]);
  19174. default_branch = null;
  19175. }
  19176. }
  19177. }
  19178. body.push(branch);
  19179. }
  19180. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  19181. self.body = body;
  19182. let default_or_exact = default_branch || exact_match;
  19183. default_branch = null;
  19184. exact_match = null;
  19185. // group equivalent branches so they will be located next to each other,
  19186. // that way the next micro-optimization will merge them.
  19187. // ** bail micro-optimization if not a simple switch case with breaks
  19188. if (body.every((branch, i) =>
  19189. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  19190. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  19191. ) {
  19192. for (let i = 0; i < body.length; i++) {
  19193. const branch = body[i];
  19194. for (let j = i + 1; j < body.length; j++) {
  19195. const next = body[j];
  19196. if (next.body.length === 0) continue;
  19197. const last_branch = j === (body.length - 1);
  19198. const equivalentBranch = branches_equivalent(next, branch, false);
  19199. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  19200. if (!equivalentBranch && last_branch) {
  19201. next.body.push(make_node(AST_Break));
  19202. }
  19203. // let's find previous siblings with inert fallthrough...
  19204. let x = j - 1;
  19205. let fallthroughDepth = 0;
  19206. while (x > i) {
  19207. if (is_inert_body(body[x--])) {
  19208. fallthroughDepth++;
  19209. } else {
  19210. break;
  19211. }
  19212. }
  19213. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  19214. body.splice(i + 1, 0, ...plucked);
  19215. i += plucked.length;
  19216. }
  19217. }
  19218. }
  19219. }
  19220. // merge equivalent branches in a row
  19221. for (let i = 0; i < body.length; i++) {
  19222. let branch = body[i];
  19223. if (branch.body.length === 0) continue;
  19224. if (!aborts(branch)) continue;
  19225. for (let j = i + 1; j < body.length; i++, j++) {
  19226. let next = body[j];
  19227. if (next.body.length === 0) continue;
  19228. if (
  19229. branches_equivalent(next, branch, false)
  19230. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  19231. ) {
  19232. branch.body = [];
  19233. branch = next;
  19234. continue;
  19235. }
  19236. break;
  19237. }
  19238. }
  19239. // Prune any empty branches at the end of the switch statement.
  19240. {
  19241. let i = body.length - 1;
  19242. for (; i >= 0; i--) {
  19243. let bbody = body[i].body;
  19244. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  19245. if (!is_inert_body(body[i])) break;
  19246. }
  19247. // i now points to the index of a branch that contains a body. By incrementing, it's
  19248. // pointing to the first branch that's empty.
  19249. i++;
  19250. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  19251. // The default behavior is to do nothing. We can take advantage of that to
  19252. // remove all case expressions that are side-effect free that also do
  19253. // nothing, since they'll default to doing nothing. But we can't remove any
  19254. // case expressions before one that would side-effect, since they may cause
  19255. // the side-effect to be skipped.
  19256. for (let j = body.length - 1; j >= i; j--) {
  19257. let branch = body[j];
  19258. if (branch === default_or_exact) {
  19259. default_or_exact = null;
  19260. body.pop();
  19261. } else if (!branch.expression.has_side_effects(compressor)) {
  19262. body.pop();
  19263. } else {
  19264. break;
  19265. }
  19266. }
  19267. }
  19268. }
  19269. // Prune side-effect free branches that fall into default.
  19270. DEFAULT: if (default_or_exact) {
  19271. let default_index = body.indexOf(default_or_exact);
  19272. let default_body_index = default_index;
  19273. for (; default_body_index < body.length - 1; default_body_index++) {
  19274. if (!is_inert_body(body[default_body_index])) break;
  19275. }
  19276. if (default_body_index < body.length - 1) {
  19277. break DEFAULT;
  19278. }
  19279. let side_effect_index = body.length - 1;
  19280. for (; side_effect_index >= 0; side_effect_index--) {
  19281. let branch = body[side_effect_index];
  19282. if (branch === default_or_exact) continue;
  19283. if (branch.expression.has_side_effects(compressor)) break;
  19284. }
  19285. // If the default behavior comes after any side-effect case expressions,
  19286. // then we can fold all side-effect free cases into the default branch.
  19287. // If the side-effect case is after the default, then any side-effect
  19288. // free cases could prevent the side-effect from occurring.
  19289. if (default_body_index > side_effect_index) {
  19290. let prev_body_index = default_index - 1;
  19291. for (; prev_body_index >= 0; prev_body_index--) {
  19292. if (!is_inert_body(body[prev_body_index])) break;
  19293. }
  19294. let before = Math.max(side_effect_index, prev_body_index) + 1;
  19295. let after = default_index;
  19296. if (side_effect_index > default_index) {
  19297. // If the default falls into the same body as a side-effect
  19298. // case, then we need preserve that case and only prune the
  19299. // cases after it.
  19300. after = side_effect_index;
  19301. body[side_effect_index].body = body[default_body_index].body;
  19302. } else {
  19303. // The default will be the last branch.
  19304. default_or_exact.body = body[default_body_index].body;
  19305. }
  19306. // Prune everything after the default (or last side-effect case)
  19307. // until the next case with a body.
  19308. body.splice(after + 1, default_body_index - after);
  19309. // Prune everything before the default that falls into it.
  19310. body.splice(before, default_index - before);
  19311. }
  19312. }
  19313. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  19314. DEFAULT: if (default_or_exact) {
  19315. let i = body.findIndex(branch => !is_inert_body(branch));
  19316. let caseBody;
  19317. // `i` is equal to one of the following:
  19318. // - `-1`, there is no body in the switch statement.
  19319. // - `body.length - 1`, all cases fall into the same body.
  19320. // - anything else, there are multiple bodies in the switch.
  19321. if (i === body.length - 1) {
  19322. // All cases fall into the case body.
  19323. let branch = body[i];
  19324. if (has_nested_break(self)) break DEFAULT;
  19325. // This is the last case body, and we've already pruned any breaks, so it's
  19326. // safe to hoist.
  19327. caseBody = make_node(AST_BlockStatement, branch, {
  19328. body: branch.body
  19329. });
  19330. branch.body = [];
  19331. } else if (i !== -1) {
  19332. // If there are multiple bodies, then we cannot optimize anything.
  19333. break DEFAULT;
  19334. }
  19335. let sideEffect = body.find(branch => {
  19336. return (
  19337. branch !== default_or_exact
  19338. && branch.expression.has_side_effects(compressor)
  19339. );
  19340. });
  19341. // If no cases cause a side-effect, we can eliminate the switch entirely.
  19342. if (!sideEffect) {
  19343. return make_node(AST_BlockStatement, self, {
  19344. body: decl.concat(
  19345. statement(self.expression),
  19346. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  19347. caseBody || []
  19348. )
  19349. }).optimize(compressor);
  19350. }
  19351. // If we're this far, either there was no body or all cases fell into the same body.
  19352. // If there was no body, then we don't need a default branch (because the default is
  19353. // do nothing). If there was a body, we'll extract it to after the switch, so the
  19354. // switch's new default is to do nothing and we can still prune it.
  19355. const default_index = body.indexOf(default_or_exact);
  19356. body.splice(default_index, 1);
  19357. default_or_exact = null;
  19358. if (caseBody) {
  19359. // Recurse into switch statement one more time so that we can append the case body
  19360. // outside of the switch. This recursion will only happen once since we've pruned
  19361. // the default case.
  19362. return make_node(AST_BlockStatement, self, {
  19363. body: decl.concat(self, caseBody)
  19364. }).optimize(compressor);
  19365. }
  19366. // If we fall here, there is a default branch somewhere, there are no case bodies,
  19367. // and there's a side-effect somewhere. Just let the below paths take care of it.
  19368. }
  19369. if (body.length > 0) {
  19370. body[0].body = decl.concat(body[0].body);
  19371. }
  19372. if (body.length == 0) {
  19373. return make_node(AST_BlockStatement, self, {
  19374. body: decl.concat(statement(self.expression))
  19375. }).optimize(compressor);
  19376. }
  19377. if (body.length == 1 && !has_nested_break(self)) {
  19378. // This is the last case body, and we've already pruned any breaks, so it's
  19379. // safe to hoist.
  19380. let branch = body[0];
  19381. return make_node(AST_If, self, {
  19382. condition: make_node(AST_Binary, self, {
  19383. operator: "===",
  19384. left: self.expression,
  19385. right: branch.expression,
  19386. }),
  19387. body: make_node(AST_BlockStatement, branch, {
  19388. body: branch.body
  19389. }),
  19390. alternative: null
  19391. }).optimize(compressor);
  19392. }
  19393. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  19394. let branch = body[0] === default_or_exact ? body[1] : body[0];
  19395. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  19396. if (aborts(body[0])) {
  19397. // Only the first branch body could have a break (at the last statement)
  19398. let first = body[0];
  19399. if (is_break(first.body[first.body.length - 1], compressor)) {
  19400. first.body.pop();
  19401. }
  19402. return make_node(AST_If, self, {
  19403. condition: make_node(AST_Binary, self, {
  19404. operator: "===",
  19405. left: self.expression,
  19406. right: branch.expression,
  19407. }),
  19408. body: make_node(AST_BlockStatement, branch, {
  19409. body: branch.body
  19410. }),
  19411. alternative: make_node(AST_BlockStatement, default_or_exact, {
  19412. body: [].concat(
  19413. exact_exp || [],
  19414. default_or_exact.body
  19415. )
  19416. })
  19417. }).optimize(compressor);
  19418. }
  19419. let operator = "===";
  19420. let consequent = make_node(AST_BlockStatement, branch, {
  19421. body: branch.body,
  19422. });
  19423. let always = make_node(AST_BlockStatement, default_or_exact, {
  19424. body: [].concat(
  19425. exact_exp || [],
  19426. default_or_exact.body
  19427. )
  19428. });
  19429. if (body[0] === default_or_exact) {
  19430. operator = "!==";
  19431. let tmp = always;
  19432. always = consequent;
  19433. consequent = tmp;
  19434. }
  19435. return make_node(AST_BlockStatement, self, {
  19436. body: [
  19437. make_node(AST_If, self, {
  19438. condition: make_node(AST_Binary, self, {
  19439. operator: operator,
  19440. left: self.expression,
  19441. right: branch.expression,
  19442. }),
  19443. body: consequent,
  19444. alternative: null
  19445. })
  19446. ].concat(always)
  19447. }).optimize(compressor);
  19448. }
  19449. return self;
  19450. function eliminate_branch(branch, prev) {
  19451. if (prev && !aborts(prev)) {
  19452. prev.body = prev.body.concat(branch.body);
  19453. } else {
  19454. trim_unreachable_code(compressor, branch, decl);
  19455. }
  19456. }
  19457. function branches_equivalent(branch, prev, insertBreak) {
  19458. let bbody = branch.body;
  19459. let pbody = prev.body;
  19460. if (insertBreak) {
  19461. bbody = bbody.concat(make_node(AST_Break));
  19462. }
  19463. if (bbody.length !== pbody.length) return false;
  19464. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  19465. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  19466. return bblock.equivalent_to(pblock);
  19467. }
  19468. function statement(expression) {
  19469. return make_node(AST_SimpleStatement, expression, {
  19470. body: expression
  19471. });
  19472. }
  19473. function has_nested_break(root) {
  19474. let has_break = false;
  19475. let tw = new TreeWalker(node => {
  19476. if (has_break) return true;
  19477. if (node instanceof AST_Lambda) return true;
  19478. if (node instanceof AST_SimpleStatement) return true;
  19479. if (!is_break(node, tw)) return;
  19480. let parent = tw.parent();
  19481. if (
  19482. parent instanceof AST_SwitchBranch
  19483. && parent.body[parent.body.length - 1] === node
  19484. ) {
  19485. return;
  19486. }
  19487. has_break = true;
  19488. });
  19489. root.walk(tw);
  19490. return has_break;
  19491. }
  19492. function is_break(node, stack) {
  19493. return node instanceof AST_Break
  19494. && stack.loopcontrol_target(node) === self;
  19495. }
  19496. function is_inert_body(branch) {
  19497. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  19498. body: branch.body
  19499. }).has_side_effects(compressor);
  19500. }
  19501. });
  19502. def_optimize(AST_Try, function(self, compressor) {
  19503. tighten_body(self.body, compressor);
  19504. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  19505. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  19506. var body = [];
  19507. if (self.bcatch) {
  19508. trim_unreachable_code(compressor, self.bcatch, body);
  19509. }
  19510. if (self.bfinally) body.push(...self.bfinally.body);
  19511. return make_node(AST_BlockStatement, self, {
  19512. body: body
  19513. }).optimize(compressor);
  19514. }
  19515. return self;
  19516. });
  19517. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  19518. var decls = [];
  19519. this.definitions.forEach(function(def) {
  19520. if (def.name instanceof AST_SymbolDeclaration) {
  19521. def.value = null;
  19522. decls.push(def);
  19523. } else {
  19524. walk(def.name, node => {
  19525. if (node instanceof AST_SymbolDeclaration) {
  19526. decls.push(make_node(AST_VarDef, def, {
  19527. name: node,
  19528. value: null
  19529. }));
  19530. }
  19531. });
  19532. }
  19533. });
  19534. this.definitions = decls;
  19535. });
  19536. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  19537. var reduce_vars = compressor.option("reduce_vars");
  19538. var assignments = [];
  19539. for (const def of this.definitions) {
  19540. if (def.value) {
  19541. var name = make_node(AST_SymbolRef, def.name, def.name);
  19542. assignments.push(make_node(AST_Assign, def, {
  19543. operator : "=",
  19544. logical: false,
  19545. left : name,
  19546. right : def.value
  19547. }));
  19548. if (reduce_vars) name.definition().fixed = false;
  19549. } else if (def.value) {
  19550. // Because it's a destructuring, do not turn into an assignment.
  19551. var varDef = make_node(AST_VarDef, def, {
  19552. name: def.name,
  19553. value: def.value
  19554. });
  19555. var var_ = make_node(AST_Var, def, {
  19556. definitions: [ varDef ]
  19557. });
  19558. assignments.push(var_);
  19559. }
  19560. const thedef = def.name.definition();
  19561. thedef.eliminated++;
  19562. thedef.replaced--;
  19563. }
  19564. if (assignments.length == 0) return null;
  19565. return make_sequence(this, assignments);
  19566. });
  19567. def_optimize(AST_Definitions, function(self) {
  19568. if (self.definitions.length == 0)
  19569. return make_node(AST_EmptyStatement, self);
  19570. return self;
  19571. });
  19572. def_optimize(AST_VarDef, function(self, compressor) {
  19573. if (
  19574. self.name instanceof AST_SymbolLet
  19575. && self.value != null
  19576. && is_undefined(self.value, compressor)
  19577. ) {
  19578. self.value = null;
  19579. }
  19580. return self;
  19581. });
  19582. def_optimize(AST_Import, function(self) {
  19583. return self;
  19584. });
  19585. def_optimize(AST_Call, function(self, compressor) {
  19586. var exp = self.expression;
  19587. var fn = exp;
  19588. inline_array_like_spread(self.args);
  19589. var simple_args = self.args.every((arg) =>
  19590. !(arg instanceof AST_Expansion)
  19591. );
  19592. if (compressor.option("reduce_vars")
  19593. && fn instanceof AST_SymbolRef
  19594. && !has_annotation(self, _NOINLINE)
  19595. ) {
  19596. const fixed = fn.fixed_value();
  19597. if (!retain_top_func(fixed, compressor)) {
  19598. fn = fixed;
  19599. }
  19600. }
  19601. var is_func = fn instanceof AST_Lambda;
  19602. if (is_func && fn.pinned()) return self;
  19603. if (compressor.option("unused")
  19604. && simple_args
  19605. && is_func
  19606. && !fn.uses_arguments) {
  19607. var pos = 0, last = 0;
  19608. for (var i = 0, len = self.args.length; i < len; i++) {
  19609. if (fn.argnames[i] instanceof AST_Expansion) {
  19610. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  19611. var node = self.args[i++].drop_side_effect_free(compressor);
  19612. if (node) {
  19613. self.args[pos++] = node;
  19614. }
  19615. } else while (i < len) {
  19616. self.args[pos++] = self.args[i++];
  19617. }
  19618. last = pos;
  19619. break;
  19620. }
  19621. var trim = i >= fn.argnames.length;
  19622. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  19623. var node = self.args[i].drop_side_effect_free(compressor);
  19624. if (node) {
  19625. self.args[pos++] = node;
  19626. } else if (!trim) {
  19627. self.args[pos++] = make_node(AST_Number, self.args[i], {
  19628. value: 0
  19629. });
  19630. continue;
  19631. }
  19632. } else {
  19633. self.args[pos++] = self.args[i];
  19634. }
  19635. last = pos;
  19636. }
  19637. self.args.length = last;
  19638. }
  19639. if (compressor.option("unsafe")) {
  19640. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  19641. const [argument] = self.args;
  19642. if (argument instanceof AST_Array) {
  19643. return make_node(AST_Array, argument, {
  19644. elements: argument.elements
  19645. }).optimize(compressor);
  19646. }
  19647. }
  19648. if (is_undeclared_ref(exp)) switch (exp.name) {
  19649. case "Array":
  19650. if (self.args.length != 1) {
  19651. return make_node(AST_Array, self, {
  19652. elements: self.args
  19653. }).optimize(compressor);
  19654. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  19655. const elements = [];
  19656. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  19657. return new AST_Array({ elements });
  19658. }
  19659. break;
  19660. case "Object":
  19661. if (self.args.length == 0) {
  19662. return make_node(AST_Object, self, {
  19663. properties: []
  19664. });
  19665. }
  19666. break;
  19667. case "String":
  19668. if (self.args.length == 0) return make_node(AST_String, self, {
  19669. value: ""
  19670. });
  19671. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  19672. left: self.args[0],
  19673. operator: "+",
  19674. right: make_node(AST_String, self, { value: "" })
  19675. }).optimize(compressor);
  19676. break;
  19677. case "Number":
  19678. if (self.args.length == 0) return make_node(AST_Number, self, {
  19679. value: 0
  19680. });
  19681. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  19682. return make_node(AST_UnaryPrefix, self, {
  19683. expression: self.args[0],
  19684. operator: "+"
  19685. }).optimize(compressor);
  19686. }
  19687. break;
  19688. case "Symbol":
  19689. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  19690. self.args.length = 0;
  19691. break;
  19692. case "Boolean":
  19693. if (self.args.length == 0) return make_node(AST_False, self);
  19694. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  19695. expression: make_node(AST_UnaryPrefix, self, {
  19696. expression: self.args[0],
  19697. operator: "!"
  19698. }),
  19699. operator: "!"
  19700. }).optimize(compressor);
  19701. break;
  19702. case "RegExp":
  19703. var params = [];
  19704. if (self.args.length >= 1
  19705. && self.args.length <= 2
  19706. && self.args.every((arg) => {
  19707. var value = arg.evaluate(compressor);
  19708. params.push(value);
  19709. return arg !== value;
  19710. })
  19711. ) {
  19712. let [ source, flags ] = params;
  19713. source = regexp_source_fix(new RegExp(source).source);
  19714. const rx = make_node(AST_RegExp, self, {
  19715. value: { source, flags }
  19716. });
  19717. if (rx._eval(compressor) !== rx) {
  19718. return rx;
  19719. }
  19720. }
  19721. break;
  19722. } else if (exp instanceof AST_Dot) switch(exp.property) {
  19723. case "toString":
  19724. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  19725. return make_node(AST_Binary, self, {
  19726. left: make_node(AST_String, self, { value: "" }),
  19727. operator: "+",
  19728. right: exp.expression
  19729. }).optimize(compressor);
  19730. }
  19731. break;
  19732. case "join":
  19733. if (exp.expression instanceof AST_Array) EXIT: {
  19734. var separator;
  19735. if (self.args.length > 0) {
  19736. separator = self.args[0].evaluate(compressor);
  19737. if (separator === self.args[0]) break EXIT; // not a constant
  19738. }
  19739. var elements = [];
  19740. var consts = [];
  19741. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  19742. var el = exp.expression.elements[i];
  19743. if (el instanceof AST_Expansion) break EXIT;
  19744. var value = el.evaluate(compressor);
  19745. if (value !== el) {
  19746. consts.push(value);
  19747. } else {
  19748. if (consts.length > 0) {
  19749. elements.push(make_node(AST_String, self, {
  19750. value: consts.join(separator)
  19751. }));
  19752. consts.length = 0;
  19753. }
  19754. elements.push(el);
  19755. }
  19756. }
  19757. if (consts.length > 0) {
  19758. elements.push(make_node(AST_String, self, {
  19759. value: consts.join(separator)
  19760. }));
  19761. }
  19762. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  19763. if (elements.length == 1) {
  19764. if (elements[0].is_string(compressor)) {
  19765. return elements[0];
  19766. }
  19767. return make_node(AST_Binary, elements[0], {
  19768. operator : "+",
  19769. left : make_node(AST_String, self, { value: "" }),
  19770. right : elements[0]
  19771. });
  19772. }
  19773. if (separator == "") {
  19774. var first;
  19775. if (elements[0].is_string(compressor)
  19776. || elements[1].is_string(compressor)) {
  19777. first = elements.shift();
  19778. } else {
  19779. first = make_node(AST_String, self, { value: "" });
  19780. }
  19781. return elements.reduce(function(prev, el) {
  19782. return make_node(AST_Binary, el, {
  19783. operator : "+",
  19784. left : prev,
  19785. right : el
  19786. });
  19787. }, first).optimize(compressor);
  19788. }
  19789. // need this awkward cloning to not affect original element
  19790. // best_of will decide which one to get through.
  19791. var node = self.clone();
  19792. node.expression = node.expression.clone();
  19793. node.expression.expression = node.expression.expression.clone();
  19794. node.expression.expression.elements = elements;
  19795. return best_of(compressor, self, node);
  19796. }
  19797. break;
  19798. case "charAt":
  19799. if (exp.expression.is_string(compressor)) {
  19800. var arg = self.args[0];
  19801. var index = arg ? arg.evaluate(compressor) : 0;
  19802. if (index !== arg) {
  19803. return make_node(AST_Sub, exp, {
  19804. expression: exp.expression,
  19805. property: make_node_from_constant(index | 0, arg || exp)
  19806. }).optimize(compressor);
  19807. }
  19808. }
  19809. break;
  19810. case "apply":
  19811. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  19812. var args = self.args[1].elements.slice();
  19813. args.unshift(self.args[0]);
  19814. return make_node(AST_Call, self, {
  19815. expression: make_node(AST_Dot, exp, {
  19816. expression: exp.expression,
  19817. optional: false,
  19818. property: "call"
  19819. }),
  19820. args: args
  19821. }).optimize(compressor);
  19822. }
  19823. break;
  19824. case "call":
  19825. var func = exp.expression;
  19826. if (func instanceof AST_SymbolRef) {
  19827. func = func.fixed_value();
  19828. }
  19829. if (func instanceof AST_Lambda && !func.contains_this()) {
  19830. return (self.args.length ? make_sequence(this, [
  19831. self.args[0],
  19832. make_node(AST_Call, self, {
  19833. expression: exp.expression,
  19834. args: self.args.slice(1)
  19835. })
  19836. ]) : make_node(AST_Call, self, {
  19837. expression: exp.expression,
  19838. args: []
  19839. })).optimize(compressor);
  19840. }
  19841. break;
  19842. }
  19843. }
  19844. if (compressor.option("unsafe_Function")
  19845. && is_undeclared_ref(exp)
  19846. && exp.name == "Function") {
  19847. // new Function() => function(){}
  19848. if (self.args.length == 0) return make_node(AST_Function, self, {
  19849. argnames: [],
  19850. body: []
  19851. }).optimize(compressor);
  19852. var nth_identifier = compressor.mangle_options && compressor.mangle_options.nth_identifier || base54;
  19853. if (self.args.every((x) => x instanceof AST_String)) {
  19854. // quite a corner-case, but we can handle it:
  19855. // https://github.com/mishoo/UglifyJS2/issues/203
  19856. // if the code argument is a constant, then we can minify it.
  19857. try {
  19858. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  19859. return arg.value;
  19860. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  19861. var ast = parse(code);
  19862. var mangle = { ie8: compressor.option("ie8"), nth_identifier: nth_identifier };
  19863. ast.figure_out_scope(mangle);
  19864. var comp = new Compressor(compressor.options, {
  19865. mangle_options: compressor.mangle_options
  19866. });
  19867. ast = ast.transform(comp);
  19868. ast.figure_out_scope(mangle);
  19869. ast.compute_char_frequency(mangle);
  19870. ast.mangle_names(mangle);
  19871. var fun;
  19872. walk(ast, node => {
  19873. if (is_func_expr(node)) {
  19874. fun = node;
  19875. return walk_abort;
  19876. }
  19877. });
  19878. var code = OutputStream();
  19879. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  19880. self.args = [
  19881. make_node(AST_String, self, {
  19882. value: fun.argnames.map(function(arg) {
  19883. return arg.print_to_string();
  19884. }).join(",")
  19885. }),
  19886. make_node(AST_String, self.args[self.args.length - 1], {
  19887. value: code.get().replace(/^{|}$/g, "")
  19888. })
  19889. ];
  19890. return self;
  19891. } catch (ex) {
  19892. if (!(ex instanceof JS_Parse_Error)) {
  19893. throw ex;
  19894. }
  19895. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  19896. }
  19897. }
  19898. }
  19899. return inline_into_call(self, fn, compressor);
  19900. });
  19901. def_optimize(AST_New, function(self, compressor) {
  19902. if (
  19903. compressor.option("unsafe") &&
  19904. is_undeclared_ref(self.expression) &&
  19905. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  19906. ) return make_node(AST_Call, self, self).transform(compressor);
  19907. return self;
  19908. });
  19909. def_optimize(AST_Sequence, function(self, compressor) {
  19910. if (!compressor.option("side_effects")) return self;
  19911. var expressions = [];
  19912. filter_for_side_effects();
  19913. var end = expressions.length - 1;
  19914. trim_right_for_undefined();
  19915. if (end == 0) {
  19916. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  19917. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  19918. return self;
  19919. }
  19920. self.expressions = expressions;
  19921. return self;
  19922. function filter_for_side_effects() {
  19923. var first = first_in_statement(compressor);
  19924. var last = self.expressions.length - 1;
  19925. self.expressions.forEach(function(expr, index) {
  19926. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  19927. if (expr) {
  19928. merge_sequence(expressions, expr);
  19929. first = false;
  19930. }
  19931. });
  19932. }
  19933. function trim_right_for_undefined() {
  19934. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  19935. if (end < expressions.length - 1) {
  19936. expressions[end] = make_node(AST_UnaryPrefix, self, {
  19937. operator : "void",
  19938. expression : expressions[end]
  19939. });
  19940. expressions.length = end + 1;
  19941. }
  19942. }
  19943. });
  19944. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  19945. if (compressor.option("sequences")) {
  19946. if (this.expression instanceof AST_Sequence) {
  19947. var x = this.expression.expressions.slice();
  19948. var e = this.clone();
  19949. e.expression = x.pop();
  19950. x.push(e);
  19951. return make_sequence(this, x).optimize(compressor);
  19952. }
  19953. }
  19954. return this;
  19955. });
  19956. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  19957. return self.lift_sequences(compressor);
  19958. });
  19959. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  19960. var e = self.expression;
  19961. if (
  19962. self.operator == "delete" &&
  19963. !(
  19964. e instanceof AST_SymbolRef ||
  19965. e instanceof AST_PropAccess ||
  19966. e instanceof AST_Chain ||
  19967. is_identifier_atom(e)
  19968. )
  19969. ) {
  19970. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  19971. }
  19972. var seq = self.lift_sequences(compressor);
  19973. if (seq !== self) {
  19974. return seq;
  19975. }
  19976. if (compressor.option("side_effects") && self.operator == "void") {
  19977. e = e.drop_side_effect_free(compressor);
  19978. if (e) {
  19979. self.expression = e;
  19980. return self;
  19981. } else {
  19982. return make_node(AST_Undefined, self).optimize(compressor);
  19983. }
  19984. }
  19985. if (compressor.in_boolean_context()) {
  19986. switch (self.operator) {
  19987. case "!":
  19988. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  19989. // !!foo ==> foo, if we're in boolean context
  19990. return e.expression;
  19991. }
  19992. if (e instanceof AST_Binary) {
  19993. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  19994. }
  19995. break;
  19996. case "typeof":
  19997. // typeof always returns a non-empty string, thus it's
  19998. // always true in booleans
  19999. // And we don't need to check if it's undeclared, because in typeof, that's OK
  20000. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  20001. e,
  20002. make_node(AST_True, self)
  20003. ])).optimize(compressor);
  20004. }
  20005. }
  20006. if (self.operator == "-" && e instanceof AST_Infinity) {
  20007. e = e.transform(compressor);
  20008. }
  20009. if (e instanceof AST_Binary
  20010. && (self.operator == "+" || self.operator == "-")
  20011. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  20012. return make_node(AST_Binary, self, {
  20013. operator: e.operator,
  20014. left: make_node(AST_UnaryPrefix, e.left, {
  20015. operator: self.operator,
  20016. expression: e.left
  20017. }),
  20018. right: e.right
  20019. });
  20020. }
  20021. // avoids infinite recursion of numerals
  20022. if (self.operator != "-"
  20023. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  20024. var ev = self.evaluate(compressor);
  20025. if (ev !== self) {
  20026. ev = make_node_from_constant(ev, self).optimize(compressor);
  20027. return best_of(compressor, ev, self);
  20028. }
  20029. }
  20030. return self;
  20031. });
  20032. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  20033. if (compressor.option("sequences")) {
  20034. if (this.left instanceof AST_Sequence) {
  20035. var x = this.left.expressions.slice();
  20036. var e = this.clone();
  20037. e.left = x.pop();
  20038. x.push(e);
  20039. return make_sequence(this, x).optimize(compressor);
  20040. }
  20041. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  20042. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  20043. var x = this.right.expressions;
  20044. var last = x.length - 1;
  20045. for (var i = 0; i < last; i++) {
  20046. if (!assign && x[i].has_side_effects(compressor)) break;
  20047. }
  20048. if (i == last) {
  20049. x = x.slice();
  20050. var e = this.clone();
  20051. e.right = x.pop();
  20052. x.push(e);
  20053. return make_sequence(this, x).optimize(compressor);
  20054. } else if (i > 0) {
  20055. var e = this.clone();
  20056. e.right = make_sequence(this.right, x.slice(i));
  20057. x = x.slice(0, i);
  20058. x.push(e);
  20059. return make_sequence(this, x).optimize(compressor);
  20060. }
  20061. }
  20062. }
  20063. return this;
  20064. });
  20065. var commutativeOperators = makePredicate("== === != !== * & | ^");
  20066. function is_object(node) {
  20067. return node instanceof AST_Array
  20068. || node instanceof AST_Lambda
  20069. || node instanceof AST_Object
  20070. || node instanceof AST_Class;
  20071. }
  20072. def_optimize(AST_Binary, function(self, compressor) {
  20073. function reversible() {
  20074. return self.left.is_constant()
  20075. || self.right.is_constant()
  20076. || !self.left.has_side_effects(compressor)
  20077. && !self.right.has_side_effects(compressor);
  20078. }
  20079. function reverse(op) {
  20080. if (reversible()) {
  20081. if (op) self.operator = op;
  20082. var tmp = self.left;
  20083. self.left = self.right;
  20084. self.right = tmp;
  20085. }
  20086. }
  20087. if (commutativeOperators.has(self.operator)) {
  20088. if (self.right.is_constant()
  20089. && !self.left.is_constant()) {
  20090. // if right is a constant, whatever side effects the
  20091. // left side might have could not influence the
  20092. // result. hence, force switch.
  20093. if (!(self.left instanceof AST_Binary
  20094. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  20095. reverse();
  20096. }
  20097. }
  20098. }
  20099. self = self.lift_sequences(compressor);
  20100. if (compressor.option("comparisons")) switch (self.operator) {
  20101. case "===":
  20102. case "!==":
  20103. var is_strict_comparison = true;
  20104. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  20105. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  20106. (self.left.is_boolean() && self.right.is_boolean()) ||
  20107. self.left.equivalent_to(self.right)) {
  20108. self.operator = self.operator.substr(0, 2);
  20109. }
  20110. // XXX: intentionally falling down to the next case
  20111. case "==":
  20112. case "!=":
  20113. // void 0 == x => null == x
  20114. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  20115. self.left = make_node(AST_Null, self.left);
  20116. } else if (compressor.option("typeofs")
  20117. // "undefined" == typeof x => undefined === x
  20118. && self.left instanceof AST_String
  20119. && self.left.value == "undefined"
  20120. && self.right instanceof AST_UnaryPrefix
  20121. && self.right.operator == "typeof") {
  20122. var expr = self.right.expression;
  20123. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  20124. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  20125. self.right = expr;
  20126. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  20127. if (self.operator.length == 2) self.operator += "=";
  20128. }
  20129. } else if (self.left instanceof AST_SymbolRef
  20130. // obj !== obj => false
  20131. && self.right instanceof AST_SymbolRef
  20132. && self.left.definition() === self.right.definition()
  20133. && is_object(self.left.fixed_value())) {
  20134. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  20135. }
  20136. break;
  20137. case "&&":
  20138. case "||":
  20139. var lhs = self.left;
  20140. if (lhs.operator == self.operator) {
  20141. lhs = lhs.right;
  20142. }
  20143. if (lhs instanceof AST_Binary
  20144. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  20145. && self.right instanceof AST_Binary
  20146. && lhs.operator == self.right.operator
  20147. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  20148. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  20149. && !lhs.right.has_side_effects(compressor)
  20150. && lhs.right.equivalent_to(self.right.right)) {
  20151. var combined = make_node(AST_Binary, self, {
  20152. operator: lhs.operator.slice(0, -1),
  20153. left: make_node(AST_Null, self),
  20154. right: lhs.right
  20155. });
  20156. if (lhs !== self.left) {
  20157. combined = make_node(AST_Binary, self, {
  20158. operator: self.operator,
  20159. left: self.left.left,
  20160. right: combined
  20161. });
  20162. }
  20163. return combined;
  20164. }
  20165. break;
  20166. }
  20167. if (self.operator == "+" && compressor.in_boolean_context()) {
  20168. var ll = self.left.evaluate(compressor);
  20169. var rr = self.right.evaluate(compressor);
  20170. if (ll && typeof ll == "string") {
  20171. return make_sequence(self, [
  20172. self.right,
  20173. make_node(AST_True, self)
  20174. ]).optimize(compressor);
  20175. }
  20176. if (rr && typeof rr == "string") {
  20177. return make_sequence(self, [
  20178. self.left,
  20179. make_node(AST_True, self)
  20180. ]).optimize(compressor);
  20181. }
  20182. }
  20183. if (compressor.option("comparisons") && self.is_boolean()) {
  20184. if (!(compressor.parent() instanceof AST_Binary)
  20185. || compressor.parent() instanceof AST_Assign) {
  20186. var negated = make_node(AST_UnaryPrefix, self, {
  20187. operator: "!",
  20188. expression: self.negate(compressor, first_in_statement(compressor))
  20189. });
  20190. self = best_of(compressor, self, negated);
  20191. }
  20192. if (compressor.option("unsafe_comps")) {
  20193. switch (self.operator) {
  20194. case "<": reverse(">"); break;
  20195. case "<=": reverse(">="); break;
  20196. }
  20197. }
  20198. }
  20199. if (self.operator == "+") {
  20200. if (self.right instanceof AST_String
  20201. && self.right.getValue() == ""
  20202. && self.left.is_string(compressor)) {
  20203. return self.left;
  20204. }
  20205. if (self.left instanceof AST_String
  20206. && self.left.getValue() == ""
  20207. && self.right.is_string(compressor)) {
  20208. return self.right;
  20209. }
  20210. if (self.left instanceof AST_Binary
  20211. && self.left.operator == "+"
  20212. && self.left.left instanceof AST_String
  20213. && self.left.left.getValue() == ""
  20214. && self.right.is_string(compressor)) {
  20215. self.left = self.left.right;
  20216. return self;
  20217. }
  20218. }
  20219. if (compressor.option("evaluate")) {
  20220. switch (self.operator) {
  20221. case "&&":
  20222. var ll = has_flag(self.left, TRUTHY)
  20223. ? true
  20224. : has_flag(self.left, FALSY)
  20225. ? false
  20226. : self.left.evaluate(compressor);
  20227. if (!ll) {
  20228. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  20229. } else if (!(ll instanceof AST_Node)) {
  20230. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  20231. }
  20232. var rr = self.right.evaluate(compressor);
  20233. if (!rr) {
  20234. if (compressor.in_boolean_context()) {
  20235. return make_sequence(self, [
  20236. self.left,
  20237. make_node(AST_False, self)
  20238. ]).optimize(compressor);
  20239. } else {
  20240. set_flag(self, FALSY);
  20241. }
  20242. } else if (!(rr instanceof AST_Node)) {
  20243. var parent = compressor.parent();
  20244. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  20245. return self.left.optimize(compressor);
  20246. }
  20247. }
  20248. // x || false && y ---> x ? y : false
  20249. if (self.left.operator == "||") {
  20250. var lr = self.left.right.evaluate(compressor);
  20251. if (!lr) return make_node(AST_Conditional, self, {
  20252. condition: self.left.left,
  20253. consequent: self.right,
  20254. alternative: self.left.right
  20255. }).optimize(compressor);
  20256. }
  20257. break;
  20258. case "||":
  20259. var ll = has_flag(self.left, TRUTHY)
  20260. ? true
  20261. : has_flag(self.left, FALSY)
  20262. ? false
  20263. : self.left.evaluate(compressor);
  20264. if (!ll) {
  20265. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  20266. } else if (!(ll instanceof AST_Node)) {
  20267. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  20268. }
  20269. var rr = self.right.evaluate(compressor);
  20270. if (!rr) {
  20271. var parent = compressor.parent();
  20272. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  20273. return self.left.optimize(compressor);
  20274. }
  20275. } else if (!(rr instanceof AST_Node)) {
  20276. if (compressor.in_boolean_context()) {
  20277. return make_sequence(self, [
  20278. self.left,
  20279. make_node(AST_True, self)
  20280. ]).optimize(compressor);
  20281. } else {
  20282. set_flag(self, TRUTHY);
  20283. }
  20284. }
  20285. if (self.left.operator == "&&") {
  20286. var lr = self.left.right.evaluate(compressor);
  20287. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  20288. condition: self.left.left,
  20289. consequent: self.left.right,
  20290. alternative: self.right
  20291. }).optimize(compressor);
  20292. }
  20293. break;
  20294. case "??":
  20295. if (is_nullish(self.left, compressor)) {
  20296. return self.right;
  20297. }
  20298. var ll = self.left.evaluate(compressor);
  20299. if (!(ll instanceof AST_Node)) {
  20300. // if we know the value for sure we can simply compute right away.
  20301. return ll == null ? self.right : self.left;
  20302. }
  20303. if (compressor.in_boolean_context()) {
  20304. const rr = self.right.evaluate(compressor);
  20305. if (!(rr instanceof AST_Node) && !rr) {
  20306. return self.left;
  20307. }
  20308. }
  20309. }
  20310. var associative = true;
  20311. switch (self.operator) {
  20312. case "+":
  20313. // (x + "foo") + "bar" => x + "foobar"
  20314. if (self.right instanceof AST_Constant
  20315. && self.left instanceof AST_Binary
  20316. && self.left.operator == "+"
  20317. && self.left.is_string(compressor)) {
  20318. var binary = make_node(AST_Binary, self, {
  20319. operator: "+",
  20320. left: self.left.right,
  20321. right: self.right,
  20322. });
  20323. var r = binary.optimize(compressor);
  20324. if (binary !== r) {
  20325. self = make_node(AST_Binary, self, {
  20326. operator: "+",
  20327. left: self.left.left,
  20328. right: r
  20329. });
  20330. }
  20331. }
  20332. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  20333. if (self.left instanceof AST_Binary
  20334. && self.left.operator == "+"
  20335. && self.left.is_string(compressor)
  20336. && self.right instanceof AST_Binary
  20337. && self.right.operator == "+"
  20338. && self.right.is_string(compressor)) {
  20339. var binary = make_node(AST_Binary, self, {
  20340. operator: "+",
  20341. left: self.left.right,
  20342. right: self.right.left,
  20343. });
  20344. var m = binary.optimize(compressor);
  20345. if (binary !== m) {
  20346. self = make_node(AST_Binary, self, {
  20347. operator: "+",
  20348. left: make_node(AST_Binary, self.left, {
  20349. operator: "+",
  20350. left: self.left.left,
  20351. right: m
  20352. }),
  20353. right: self.right.right
  20354. });
  20355. }
  20356. }
  20357. // a + -b => a - b
  20358. if (self.right instanceof AST_UnaryPrefix
  20359. && self.right.operator == "-"
  20360. && self.left.is_number(compressor)) {
  20361. self = make_node(AST_Binary, self, {
  20362. operator: "-",
  20363. left: self.left,
  20364. right: self.right.expression
  20365. });
  20366. break;
  20367. }
  20368. // -a + b => b - a
  20369. if (self.left instanceof AST_UnaryPrefix
  20370. && self.left.operator == "-"
  20371. && reversible()
  20372. && self.right.is_number(compressor)) {
  20373. self = make_node(AST_Binary, self, {
  20374. operator: "-",
  20375. left: self.right,
  20376. right: self.left.expression
  20377. });
  20378. break;
  20379. }
  20380. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  20381. if (self.left instanceof AST_TemplateString) {
  20382. var l = self.left;
  20383. var r = self.right.evaluate(compressor);
  20384. if (r != self.right) {
  20385. l.segments[l.segments.length - 1].value += String(r);
  20386. return l;
  20387. }
  20388. }
  20389. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  20390. if (self.right instanceof AST_TemplateString) {
  20391. var r = self.right;
  20392. var l = self.left.evaluate(compressor);
  20393. if (l != self.left) {
  20394. r.segments[0].value = String(l) + r.segments[0].value;
  20395. return r;
  20396. }
  20397. }
  20398. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  20399. if (self.left instanceof AST_TemplateString
  20400. && self.right instanceof AST_TemplateString) {
  20401. var l = self.left;
  20402. var segments = l.segments;
  20403. var r = self.right;
  20404. segments[segments.length - 1].value += r.segments[0].value;
  20405. for (var i = 1; i < r.segments.length; i++) {
  20406. segments.push(r.segments[i]);
  20407. }
  20408. return l;
  20409. }
  20410. case "*":
  20411. associative = compressor.option("unsafe_math");
  20412. case "&":
  20413. case "|":
  20414. case "^":
  20415. // a + +b => +b + a
  20416. if (self.left.is_number(compressor)
  20417. && self.right.is_number(compressor)
  20418. && reversible()
  20419. && !(self.left instanceof AST_Binary
  20420. && self.left.operator != self.operator
  20421. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  20422. var reversed = make_node(AST_Binary, self, {
  20423. operator: self.operator,
  20424. left: self.right,
  20425. right: self.left
  20426. });
  20427. if (self.right instanceof AST_Constant
  20428. && !(self.left instanceof AST_Constant)) {
  20429. self = best_of(compressor, reversed, self);
  20430. } else {
  20431. self = best_of(compressor, self, reversed);
  20432. }
  20433. }
  20434. if (associative && self.is_number(compressor)) {
  20435. // a + (b + c) => (a + b) + c
  20436. if (self.right instanceof AST_Binary
  20437. && self.right.operator == self.operator) {
  20438. self = make_node(AST_Binary, self, {
  20439. operator: self.operator,
  20440. left: make_node(AST_Binary, self.left, {
  20441. operator: self.operator,
  20442. left: self.left,
  20443. right: self.right.left,
  20444. start: self.left.start,
  20445. end: self.right.left.end
  20446. }),
  20447. right: self.right.right
  20448. });
  20449. }
  20450. // (n + 2) + 3 => 5 + n
  20451. // (2 * n) * 3 => 6 + n
  20452. if (self.right instanceof AST_Constant
  20453. && self.left instanceof AST_Binary
  20454. && self.left.operator == self.operator) {
  20455. if (self.left.left instanceof AST_Constant) {
  20456. self = make_node(AST_Binary, self, {
  20457. operator: self.operator,
  20458. left: make_node(AST_Binary, self.left, {
  20459. operator: self.operator,
  20460. left: self.left.left,
  20461. right: self.right,
  20462. start: self.left.left.start,
  20463. end: self.right.end
  20464. }),
  20465. right: self.left.right
  20466. });
  20467. } else if (self.left.right instanceof AST_Constant) {
  20468. self = make_node(AST_Binary, self, {
  20469. operator: self.operator,
  20470. left: make_node(AST_Binary, self.left, {
  20471. operator: self.operator,
  20472. left: self.left.right,
  20473. right: self.right,
  20474. start: self.left.right.start,
  20475. end: self.right.end
  20476. }),
  20477. right: self.left.left
  20478. });
  20479. }
  20480. }
  20481. // (a | 1) | (2 | d) => (3 | a) | b
  20482. if (self.left instanceof AST_Binary
  20483. && self.left.operator == self.operator
  20484. && self.left.right instanceof AST_Constant
  20485. && self.right instanceof AST_Binary
  20486. && self.right.operator == self.operator
  20487. && self.right.left instanceof AST_Constant) {
  20488. self = make_node(AST_Binary, self, {
  20489. operator: self.operator,
  20490. left: make_node(AST_Binary, self.left, {
  20491. operator: self.operator,
  20492. left: make_node(AST_Binary, self.left.left, {
  20493. operator: self.operator,
  20494. left: self.left.right,
  20495. right: self.right.left,
  20496. start: self.left.right.start,
  20497. end: self.right.left.end
  20498. }),
  20499. right: self.left.left
  20500. }),
  20501. right: self.right.right
  20502. });
  20503. }
  20504. }
  20505. }
  20506. }
  20507. // x && (y && z) ==> x && y && z
  20508. // x || (y || z) ==> x || y || z
  20509. // x + ("y" + z) ==> x + "y" + z
  20510. // "x" + (y + "z")==> "x" + y + "z"
  20511. if (self.right instanceof AST_Binary
  20512. && self.right.operator == self.operator
  20513. && (lazy_op.has(self.operator)
  20514. || (self.operator == "+"
  20515. && (self.right.left.is_string(compressor)
  20516. || (self.left.is_string(compressor)
  20517. && self.right.right.is_string(compressor)))))
  20518. ) {
  20519. self.left = make_node(AST_Binary, self.left, {
  20520. operator : self.operator,
  20521. left : self.left.transform(compressor),
  20522. right : self.right.left.transform(compressor)
  20523. });
  20524. self.right = self.right.right.transform(compressor);
  20525. return self.transform(compressor);
  20526. }
  20527. var ev = self.evaluate(compressor);
  20528. if (ev !== self) {
  20529. ev = make_node_from_constant(ev, self).optimize(compressor);
  20530. return best_of(compressor, ev, self);
  20531. }
  20532. return self;
  20533. });
  20534. def_optimize(AST_SymbolExport, function(self) {
  20535. return self;
  20536. });
  20537. def_optimize(AST_SymbolRef, function(self, compressor) {
  20538. if (
  20539. !compressor.option("ie8")
  20540. && is_undeclared_ref(self)
  20541. && !compressor.find_parent(AST_With)
  20542. ) {
  20543. switch (self.name) {
  20544. case "undefined":
  20545. return make_node(AST_Undefined, self).optimize(compressor);
  20546. case "NaN":
  20547. return make_node(AST_NaN, self).optimize(compressor);
  20548. case "Infinity":
  20549. return make_node(AST_Infinity, self).optimize(compressor);
  20550. }
  20551. }
  20552. const parent = compressor.parent();
  20553. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  20554. return inline_into_symbolref(self, compressor);
  20555. } else {
  20556. return self;
  20557. }
  20558. });
  20559. function is_atomic(lhs, self) {
  20560. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  20561. }
  20562. def_optimize(AST_Undefined, function(self, compressor) {
  20563. if (compressor.option("unsafe_undefined")) {
  20564. var undef = find_variable(compressor, "undefined");
  20565. if (undef) {
  20566. var ref = make_node(AST_SymbolRef, self, {
  20567. name : "undefined",
  20568. scope : undef.scope,
  20569. thedef : undef
  20570. });
  20571. set_flag(ref, UNDEFINED);
  20572. return ref;
  20573. }
  20574. }
  20575. var lhs = is_lhs(compressor.self(), compressor.parent());
  20576. if (lhs && is_atomic(lhs, self)) return self;
  20577. return make_node(AST_UnaryPrefix, self, {
  20578. operator: "void",
  20579. expression: make_node(AST_Number, self, {
  20580. value: 0
  20581. })
  20582. });
  20583. });
  20584. def_optimize(AST_Infinity, function(self, compressor) {
  20585. var lhs = is_lhs(compressor.self(), compressor.parent());
  20586. if (lhs && is_atomic(lhs, self)) return self;
  20587. if (
  20588. compressor.option("keep_infinity")
  20589. && !(lhs && !is_atomic(lhs, self))
  20590. && !find_variable(compressor, "Infinity")
  20591. ) {
  20592. return self;
  20593. }
  20594. return make_node(AST_Binary, self, {
  20595. operator: "/",
  20596. left: make_node(AST_Number, self, {
  20597. value: 1
  20598. }),
  20599. right: make_node(AST_Number, self, {
  20600. value: 0
  20601. })
  20602. });
  20603. });
  20604. def_optimize(AST_NaN, function(self, compressor) {
  20605. var lhs = is_lhs(compressor.self(), compressor.parent());
  20606. if (lhs && !is_atomic(lhs, self)
  20607. || find_variable(compressor, "NaN")) {
  20608. return make_node(AST_Binary, self, {
  20609. operator: "/",
  20610. left: make_node(AST_Number, self, {
  20611. value: 0
  20612. }),
  20613. right: make_node(AST_Number, self, {
  20614. value: 0
  20615. })
  20616. });
  20617. }
  20618. return self;
  20619. });
  20620. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  20621. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  20622. def_optimize(AST_Assign, function(self, compressor) {
  20623. if (self.logical) {
  20624. return self.lift_sequences(compressor);
  20625. }
  20626. var def;
  20627. // x = x ---> x
  20628. if (
  20629. self.operator === "="
  20630. && self.left instanceof AST_SymbolRef
  20631. && self.left.name !== "arguments"
  20632. && !(def = self.left.definition()).undeclared
  20633. && self.right.equivalent_to(self.left)
  20634. ) {
  20635. return self.right;
  20636. }
  20637. if (compressor.option("dead_code")
  20638. && self.left instanceof AST_SymbolRef
  20639. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  20640. var level = 0, node, parent = self;
  20641. do {
  20642. node = parent;
  20643. parent = compressor.parent(level++);
  20644. if (parent instanceof AST_Exit) {
  20645. if (in_try(level, parent)) break;
  20646. if (is_reachable(def.scope, [ def ])) break;
  20647. if (self.operator == "=") return self.right;
  20648. def.fixed = false;
  20649. return make_node(AST_Binary, self, {
  20650. operator: self.operator.slice(0, -1),
  20651. left: self.left,
  20652. right: self.right
  20653. }).optimize(compressor);
  20654. }
  20655. } while (parent instanceof AST_Binary && parent.right === node
  20656. || parent instanceof AST_Sequence && parent.tail_node() === node);
  20657. }
  20658. self = self.lift_sequences(compressor);
  20659. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  20660. // x = expr1 OP expr2
  20661. if (self.right.left instanceof AST_SymbolRef
  20662. && self.right.left.name == self.left.name
  20663. && ASSIGN_OPS.has(self.right.operator)) {
  20664. // x = x - 2 ---> x -= 2
  20665. self.operator = self.right.operator + "=";
  20666. self.right = self.right.right;
  20667. } else if (self.right.right instanceof AST_SymbolRef
  20668. && self.right.right.name == self.left.name
  20669. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  20670. && !self.right.left.has_side_effects(compressor)) {
  20671. // x = 2 & x ---> x &= 2
  20672. self.operator = self.right.operator + "=";
  20673. self.right = self.right.left;
  20674. }
  20675. }
  20676. return self;
  20677. function in_try(level, node) {
  20678. var right = self.right;
  20679. self.right = make_node(AST_Null, right);
  20680. var may_throw = node.may_throw(compressor);
  20681. self.right = right;
  20682. var scope = self.left.definition().scope;
  20683. var parent;
  20684. while ((parent = compressor.parent(level++)) !== scope) {
  20685. if (parent instanceof AST_Try) {
  20686. if (parent.bfinally) return true;
  20687. if (may_throw && parent.bcatch) return true;
  20688. }
  20689. }
  20690. }
  20691. });
  20692. def_optimize(AST_DefaultAssign, function(self, compressor) {
  20693. if (!compressor.option("evaluate")) {
  20694. return self;
  20695. }
  20696. var evaluateRight = self.right.evaluate(compressor);
  20697. // `[x = undefined] = foo` ---> `[x] = foo`
  20698. if (evaluateRight === undefined) {
  20699. self = self.left;
  20700. } else if (evaluateRight !== self.right) {
  20701. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  20702. self.right = best_of_expression(evaluateRight, self.right);
  20703. }
  20704. return self;
  20705. });
  20706. function is_nullish_check(check, check_subject, compressor) {
  20707. if (check_subject.may_throw(compressor)) return false;
  20708. let nullish_side;
  20709. // foo == null
  20710. if (
  20711. check instanceof AST_Binary
  20712. && check.operator === "=="
  20713. // which side is nullish?
  20714. && (
  20715. (nullish_side = is_nullish(check.left, compressor) && check.left)
  20716. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  20717. )
  20718. // is the other side the same as the check_subject
  20719. && (
  20720. nullish_side === check.left
  20721. ? check.right
  20722. : check.left
  20723. ).equivalent_to(check_subject)
  20724. ) {
  20725. return true;
  20726. }
  20727. // foo === null || foo === undefined
  20728. if (check instanceof AST_Binary && check.operator === "||") {
  20729. let null_cmp;
  20730. let undefined_cmp;
  20731. const find_comparison = cmp => {
  20732. if (!(
  20733. cmp instanceof AST_Binary
  20734. && (cmp.operator === "===" || cmp.operator === "==")
  20735. )) {
  20736. return false;
  20737. }
  20738. let found = 0;
  20739. let defined_side;
  20740. if (cmp.left instanceof AST_Null) {
  20741. found++;
  20742. null_cmp = cmp;
  20743. defined_side = cmp.right;
  20744. }
  20745. if (cmp.right instanceof AST_Null) {
  20746. found++;
  20747. null_cmp = cmp;
  20748. defined_side = cmp.left;
  20749. }
  20750. if (is_undefined(cmp.left, compressor)) {
  20751. found++;
  20752. undefined_cmp = cmp;
  20753. defined_side = cmp.right;
  20754. }
  20755. if (is_undefined(cmp.right, compressor)) {
  20756. found++;
  20757. undefined_cmp = cmp;
  20758. defined_side = cmp.left;
  20759. }
  20760. if (found !== 1) {
  20761. return false;
  20762. }
  20763. if (!defined_side.equivalent_to(check_subject)) {
  20764. return false;
  20765. }
  20766. return true;
  20767. };
  20768. if (!find_comparison(check.left)) return false;
  20769. if (!find_comparison(check.right)) return false;
  20770. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  20771. return true;
  20772. }
  20773. }
  20774. return false;
  20775. }
  20776. def_optimize(AST_Conditional, function(self, compressor) {
  20777. if (!compressor.option("conditionals")) return self;
  20778. // This looks like lift_sequences(), should probably be under "sequences"
  20779. if (self.condition instanceof AST_Sequence) {
  20780. var expressions = self.condition.expressions.slice();
  20781. self.condition = expressions.pop();
  20782. expressions.push(self);
  20783. return make_sequence(self, expressions);
  20784. }
  20785. var cond = self.condition.evaluate(compressor);
  20786. if (cond !== self.condition) {
  20787. if (cond) {
  20788. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  20789. } else {
  20790. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  20791. }
  20792. }
  20793. var negated = cond.negate(compressor, first_in_statement(compressor));
  20794. if (best_of(compressor, cond, negated) === negated) {
  20795. self = make_node(AST_Conditional, self, {
  20796. condition: negated,
  20797. consequent: self.alternative,
  20798. alternative: self.consequent
  20799. });
  20800. }
  20801. var condition = self.condition;
  20802. var consequent = self.consequent;
  20803. var alternative = self.alternative;
  20804. // x?x:y --> x||y
  20805. if (condition instanceof AST_SymbolRef
  20806. && consequent instanceof AST_SymbolRef
  20807. && condition.definition() === consequent.definition()) {
  20808. return make_node(AST_Binary, self, {
  20809. operator: "||",
  20810. left: condition,
  20811. right: alternative
  20812. });
  20813. }
  20814. // if (foo) exp = something; else exp = something_else;
  20815. // |
  20816. // v
  20817. // exp = foo ? something : something_else;
  20818. if (
  20819. consequent instanceof AST_Assign
  20820. && alternative instanceof AST_Assign
  20821. && consequent.operator === alternative.operator
  20822. && consequent.logical === alternative.logical
  20823. && consequent.left.equivalent_to(alternative.left)
  20824. && (!self.condition.has_side_effects(compressor)
  20825. || consequent.operator == "="
  20826. && !consequent.left.has_side_effects(compressor))
  20827. ) {
  20828. return make_node(AST_Assign, self, {
  20829. operator: consequent.operator,
  20830. left: consequent.left,
  20831. logical: consequent.logical,
  20832. right: make_node(AST_Conditional, self, {
  20833. condition: self.condition,
  20834. consequent: consequent.right,
  20835. alternative: alternative.right
  20836. })
  20837. });
  20838. }
  20839. // x ? y(a) : y(b) --> y(x ? a : b)
  20840. var arg_index;
  20841. if (consequent instanceof AST_Call
  20842. && alternative.TYPE === consequent.TYPE
  20843. && consequent.args.length > 0
  20844. && consequent.args.length == alternative.args.length
  20845. && consequent.expression.equivalent_to(alternative.expression)
  20846. && !self.condition.has_side_effects(compressor)
  20847. && !consequent.expression.has_side_effects(compressor)
  20848. && typeof (arg_index = single_arg_diff()) == "number") {
  20849. var node = consequent.clone();
  20850. node.args[arg_index] = make_node(AST_Conditional, self, {
  20851. condition: self.condition,
  20852. consequent: consequent.args[arg_index],
  20853. alternative: alternative.args[arg_index]
  20854. });
  20855. return node;
  20856. }
  20857. // a ? b : c ? b : d --> (a || c) ? b : d
  20858. if (alternative instanceof AST_Conditional
  20859. && consequent.equivalent_to(alternative.consequent)) {
  20860. return make_node(AST_Conditional, self, {
  20861. condition: make_node(AST_Binary, self, {
  20862. operator: "||",
  20863. left: condition,
  20864. right: alternative.condition
  20865. }),
  20866. consequent: consequent,
  20867. alternative: alternative.alternative
  20868. }).optimize(compressor);
  20869. }
  20870. // a == null ? b : a -> a ?? b
  20871. if (
  20872. compressor.option("ecma") >= 2020 &&
  20873. is_nullish_check(condition, alternative, compressor)
  20874. ) {
  20875. return make_node(AST_Binary, self, {
  20876. operator: "??",
  20877. left: alternative,
  20878. right: consequent
  20879. }).optimize(compressor);
  20880. }
  20881. // a ? b : (c, b) --> (a || c), b
  20882. if (alternative instanceof AST_Sequence
  20883. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  20884. return make_sequence(self, [
  20885. make_node(AST_Binary, self, {
  20886. operator: "||",
  20887. left: condition,
  20888. right: make_sequence(self, alternative.expressions.slice(0, -1))
  20889. }),
  20890. consequent
  20891. ]).optimize(compressor);
  20892. }
  20893. // a ? b : (c && b) --> (a || c) && b
  20894. if (alternative instanceof AST_Binary
  20895. && alternative.operator == "&&"
  20896. && consequent.equivalent_to(alternative.right)) {
  20897. return make_node(AST_Binary, self, {
  20898. operator: "&&",
  20899. left: make_node(AST_Binary, self, {
  20900. operator: "||",
  20901. left: condition,
  20902. right: alternative.left
  20903. }),
  20904. right: consequent
  20905. }).optimize(compressor);
  20906. }
  20907. // x?y?z:a:a --> x&&y?z:a
  20908. if (consequent instanceof AST_Conditional
  20909. && consequent.alternative.equivalent_to(alternative)) {
  20910. return make_node(AST_Conditional, self, {
  20911. condition: make_node(AST_Binary, self, {
  20912. left: self.condition,
  20913. operator: "&&",
  20914. right: consequent.condition
  20915. }),
  20916. consequent: consequent.consequent,
  20917. alternative: alternative
  20918. });
  20919. }
  20920. // x ? y : y --> x, y
  20921. if (consequent.equivalent_to(alternative)) {
  20922. return make_sequence(self, [
  20923. self.condition,
  20924. consequent
  20925. ]).optimize(compressor);
  20926. }
  20927. // x ? y || z : z --> x && y || z
  20928. if (consequent instanceof AST_Binary
  20929. && consequent.operator == "||"
  20930. && consequent.right.equivalent_to(alternative)) {
  20931. return make_node(AST_Binary, self, {
  20932. operator: "||",
  20933. left: make_node(AST_Binary, self, {
  20934. operator: "&&",
  20935. left: self.condition,
  20936. right: consequent.left
  20937. }),
  20938. right: alternative
  20939. }).optimize(compressor);
  20940. }
  20941. const in_bool = compressor.in_boolean_context();
  20942. if (is_true(self.consequent)) {
  20943. if (is_false(self.alternative)) {
  20944. // c ? true : false ---> !!c
  20945. return booleanize(self.condition);
  20946. }
  20947. // c ? true : x ---> !!c || x
  20948. return make_node(AST_Binary, self, {
  20949. operator: "||",
  20950. left: booleanize(self.condition),
  20951. right: self.alternative
  20952. });
  20953. }
  20954. if (is_false(self.consequent)) {
  20955. if (is_true(self.alternative)) {
  20956. // c ? false : true ---> !c
  20957. return booleanize(self.condition.negate(compressor));
  20958. }
  20959. // c ? false : x ---> !c && x
  20960. return make_node(AST_Binary, self, {
  20961. operator: "&&",
  20962. left: booleanize(self.condition.negate(compressor)),
  20963. right: self.alternative
  20964. });
  20965. }
  20966. if (is_true(self.alternative)) {
  20967. // c ? x : true ---> !c || x
  20968. return make_node(AST_Binary, self, {
  20969. operator: "||",
  20970. left: booleanize(self.condition.negate(compressor)),
  20971. right: self.consequent
  20972. });
  20973. }
  20974. if (is_false(self.alternative)) {
  20975. // c ? x : false ---> !!c && x
  20976. return make_node(AST_Binary, self, {
  20977. operator: "&&",
  20978. left: booleanize(self.condition),
  20979. right: self.consequent
  20980. });
  20981. }
  20982. return self;
  20983. function booleanize(node) {
  20984. if (node.is_boolean()) return node;
  20985. // !!expression
  20986. return make_node(AST_UnaryPrefix, node, {
  20987. operator: "!",
  20988. expression: node.negate(compressor)
  20989. });
  20990. }
  20991. // AST_True or !0
  20992. function is_true(node) {
  20993. return node instanceof AST_True
  20994. || in_bool
  20995. && node instanceof AST_Constant
  20996. && node.getValue()
  20997. || (node instanceof AST_UnaryPrefix
  20998. && node.operator == "!"
  20999. && node.expression instanceof AST_Constant
  21000. && !node.expression.getValue());
  21001. }
  21002. // AST_False or !1
  21003. function is_false(node) {
  21004. return node instanceof AST_False
  21005. || in_bool
  21006. && node instanceof AST_Constant
  21007. && !node.getValue()
  21008. || (node instanceof AST_UnaryPrefix
  21009. && node.operator == "!"
  21010. && node.expression instanceof AST_Constant
  21011. && node.expression.getValue());
  21012. }
  21013. function single_arg_diff() {
  21014. var a = consequent.args;
  21015. var b = alternative.args;
  21016. for (var i = 0, len = a.length; i < len; i++) {
  21017. if (a[i] instanceof AST_Expansion) return;
  21018. if (!a[i].equivalent_to(b[i])) {
  21019. if (b[i] instanceof AST_Expansion) return;
  21020. for (var j = i + 1; j < len; j++) {
  21021. if (a[j] instanceof AST_Expansion) return;
  21022. if (!a[j].equivalent_to(b[j])) return;
  21023. }
  21024. return i;
  21025. }
  21026. }
  21027. }
  21028. });
  21029. def_optimize(AST_Boolean, function(self, compressor) {
  21030. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  21031. value: +self.value
  21032. });
  21033. var p = compressor.parent();
  21034. if (compressor.option("booleans_as_integers")) {
  21035. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  21036. p.operator = p.operator.replace(/=$/, "");
  21037. }
  21038. return make_node(AST_Number, self, {
  21039. value: +self.value
  21040. });
  21041. }
  21042. if (compressor.option("booleans")) {
  21043. if (p instanceof AST_Binary && (p.operator == "=="
  21044. || p.operator == "!=")) {
  21045. return make_node(AST_Number, self, {
  21046. value: +self.value
  21047. });
  21048. }
  21049. return make_node(AST_UnaryPrefix, self, {
  21050. operator: "!",
  21051. expression: make_node(AST_Number, self, {
  21052. value: 1 - self.value
  21053. })
  21054. });
  21055. }
  21056. return self;
  21057. });
  21058. function safe_to_flatten(value, compressor) {
  21059. if (value instanceof AST_SymbolRef) {
  21060. value = value.fixed_value();
  21061. }
  21062. if (!value) return false;
  21063. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  21064. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  21065. return compressor.parent() instanceof AST_New;
  21066. }
  21067. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  21068. if (!compressor.option("properties")) return;
  21069. if (key === "__proto__") return;
  21070. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  21071. var expr = this.expression;
  21072. if (expr instanceof AST_Object) {
  21073. var props = expr.properties;
  21074. for (var i = props.length; --i >= 0;) {
  21075. var prop = props[i];
  21076. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  21077. const all_props_flattenable = props.every((p) =>
  21078. (p instanceof AST_ObjectKeyVal
  21079. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  21080. )
  21081. && !p.computed_key()
  21082. );
  21083. if (!all_props_flattenable) return;
  21084. if (!safe_to_flatten(prop.value, compressor)) return;
  21085. return make_node(AST_Sub, this, {
  21086. expression: make_node(AST_Array, expr, {
  21087. elements: props.map(function(prop) {
  21088. var v = prop.value;
  21089. if (v instanceof AST_Accessor) {
  21090. v = make_node(AST_Function, v, v);
  21091. }
  21092. var k = prop.key;
  21093. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  21094. return make_sequence(prop, [ k, v ]);
  21095. }
  21096. return v;
  21097. })
  21098. }),
  21099. property: make_node(AST_Number, this, {
  21100. value: i
  21101. })
  21102. });
  21103. }
  21104. }
  21105. }
  21106. });
  21107. def_optimize(AST_Sub, function(self, compressor) {
  21108. var expr = self.expression;
  21109. var prop = self.property;
  21110. if (compressor.option("properties")) {
  21111. var key = prop.evaluate(compressor);
  21112. if (key !== prop) {
  21113. if (typeof key == "string") {
  21114. if (key == "undefined") {
  21115. key = undefined;
  21116. } else {
  21117. var value = parseFloat(key);
  21118. if (value.toString() == key) {
  21119. key = value;
  21120. }
  21121. }
  21122. }
  21123. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  21124. var property = "" + key;
  21125. if (is_basic_identifier_string(property)
  21126. && property.length <= prop.size() + 1) {
  21127. return make_node(AST_Dot, self, {
  21128. expression: expr,
  21129. optional: self.optional,
  21130. property: property,
  21131. quote: prop.quote,
  21132. }).optimize(compressor);
  21133. }
  21134. }
  21135. }
  21136. var fn;
  21137. OPT_ARGUMENTS: if (compressor.option("arguments")
  21138. && expr instanceof AST_SymbolRef
  21139. && expr.name == "arguments"
  21140. && expr.definition().orig.length == 1
  21141. && (fn = expr.scope) instanceof AST_Lambda
  21142. && fn.uses_arguments
  21143. && !(fn instanceof AST_Arrow)
  21144. && prop instanceof AST_Number) {
  21145. var index = prop.getValue();
  21146. var params = new Set();
  21147. var argnames = fn.argnames;
  21148. for (var n = 0; n < argnames.length; n++) {
  21149. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  21150. break OPT_ARGUMENTS; // destructuring parameter - bail
  21151. }
  21152. var param = argnames[n].name;
  21153. if (params.has(param)) {
  21154. break OPT_ARGUMENTS; // duplicate parameter - bail
  21155. }
  21156. params.add(param);
  21157. }
  21158. var argname = fn.argnames[index];
  21159. if (argname && compressor.has_directive("use strict")) {
  21160. var def = argname.definition();
  21161. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  21162. argname = null;
  21163. }
  21164. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  21165. while (index >= fn.argnames.length) {
  21166. argname = fn.create_symbol(AST_SymbolFunarg, {
  21167. source: fn,
  21168. scope: fn,
  21169. tentative_name: "argument_" + fn.argnames.length,
  21170. });
  21171. fn.argnames.push(argname);
  21172. }
  21173. }
  21174. if (argname) {
  21175. var sym = make_node(AST_SymbolRef, self, argname);
  21176. sym.reference({});
  21177. clear_flag(argname, UNUSED);
  21178. return sym;
  21179. }
  21180. }
  21181. if (is_lhs(self, compressor.parent())) return self;
  21182. if (key !== prop) {
  21183. var sub = self.flatten_object(property, compressor);
  21184. if (sub) {
  21185. expr = self.expression = sub.expression;
  21186. prop = self.property = sub.property;
  21187. }
  21188. }
  21189. if (compressor.option("properties") && compressor.option("side_effects")
  21190. && prop instanceof AST_Number && expr instanceof AST_Array) {
  21191. var index = prop.getValue();
  21192. var elements = expr.elements;
  21193. var retValue = elements[index];
  21194. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  21195. var flatten = true;
  21196. var values = [];
  21197. for (var i = elements.length; --i > index;) {
  21198. var value = elements[i].drop_side_effect_free(compressor);
  21199. if (value) {
  21200. values.unshift(value);
  21201. if (flatten && value.has_side_effects(compressor)) flatten = false;
  21202. }
  21203. }
  21204. if (retValue instanceof AST_Expansion) break FLATTEN;
  21205. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  21206. if (!flatten) values.unshift(retValue);
  21207. while (--i >= 0) {
  21208. var value = elements[i];
  21209. if (value instanceof AST_Expansion) break FLATTEN;
  21210. value = value.drop_side_effect_free(compressor);
  21211. if (value) values.unshift(value);
  21212. else index--;
  21213. }
  21214. if (flatten) {
  21215. values.push(retValue);
  21216. return make_sequence(self, values).optimize(compressor);
  21217. } else return make_node(AST_Sub, self, {
  21218. expression: make_node(AST_Array, expr, {
  21219. elements: values
  21220. }),
  21221. property: make_node(AST_Number, prop, {
  21222. value: index
  21223. })
  21224. });
  21225. }
  21226. }
  21227. var ev = self.evaluate(compressor);
  21228. if (ev !== self) {
  21229. ev = make_node_from_constant(ev, self).optimize(compressor);
  21230. return best_of(compressor, ev, self);
  21231. }
  21232. return self;
  21233. });
  21234. def_optimize(AST_Chain, function (self, compressor) {
  21235. if (is_nullish(self.expression, compressor)) {
  21236. let parent = compressor.parent();
  21237. // It's valid to delete a nullish optional chain, but if we optimized
  21238. // this to `delete undefined` then it would appear to be a syntax error
  21239. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  21240. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  21241. return make_node_from_constant(0, self);
  21242. }
  21243. return make_node(AST_Undefined, self);
  21244. }
  21245. return self;
  21246. });
  21247. AST_Lambda.DEFMETHOD("contains_this", function() {
  21248. return walk(this, node => {
  21249. if (node instanceof AST_This) return walk_abort;
  21250. if (
  21251. node !== this
  21252. && node instanceof AST_Scope
  21253. && !(node instanceof AST_Arrow)
  21254. ) {
  21255. return true;
  21256. }
  21257. });
  21258. });
  21259. def_optimize(AST_Dot, function(self, compressor) {
  21260. const parent = compressor.parent();
  21261. if (is_lhs(self, parent)) return self;
  21262. if (compressor.option("unsafe_proto")
  21263. && self.expression instanceof AST_Dot
  21264. && self.expression.property == "prototype") {
  21265. var exp = self.expression.expression;
  21266. if (is_undeclared_ref(exp)) switch (exp.name) {
  21267. case "Array":
  21268. self.expression = make_node(AST_Array, self.expression, {
  21269. elements: []
  21270. });
  21271. break;
  21272. case "Function":
  21273. self.expression = make_node(AST_Function, self.expression, {
  21274. argnames: [],
  21275. body: []
  21276. });
  21277. break;
  21278. case "Number":
  21279. self.expression = make_node(AST_Number, self.expression, {
  21280. value: 0
  21281. });
  21282. break;
  21283. case "Object":
  21284. self.expression = make_node(AST_Object, self.expression, {
  21285. properties: []
  21286. });
  21287. break;
  21288. case "RegExp":
  21289. self.expression = make_node(AST_RegExp, self.expression, {
  21290. value: { source: "t", flags: "" }
  21291. });
  21292. break;
  21293. case "String":
  21294. self.expression = make_node(AST_String, self.expression, {
  21295. value: ""
  21296. });
  21297. break;
  21298. }
  21299. }
  21300. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  21301. const sub = self.flatten_object(self.property, compressor);
  21302. if (sub) return sub.optimize(compressor);
  21303. }
  21304. let ev = self.evaluate(compressor);
  21305. if (ev !== self) {
  21306. ev = make_node_from_constant(ev, self).optimize(compressor);
  21307. return best_of(compressor, ev, self);
  21308. }
  21309. return self;
  21310. });
  21311. function literals_in_boolean_context(self, compressor) {
  21312. if (compressor.in_boolean_context()) {
  21313. return best_of(compressor, self, make_sequence(self, [
  21314. self,
  21315. make_node(AST_True, self)
  21316. ]).optimize(compressor));
  21317. }
  21318. return self;
  21319. }
  21320. function inline_array_like_spread(elements) {
  21321. for (var i = 0; i < elements.length; i++) {
  21322. var el = elements[i];
  21323. if (el instanceof AST_Expansion) {
  21324. var expr = el.expression;
  21325. if (
  21326. expr instanceof AST_Array
  21327. && !expr.elements.some(elm => elm instanceof AST_Hole)
  21328. ) {
  21329. elements.splice(i, 1, ...expr.elements);
  21330. // Step back one, as the element at i is now new.
  21331. i--;
  21332. }
  21333. // In array-like spread, spreading a non-iterable value is TypeError.
  21334. // We therefore can’t optimize anything else, unlike with object spread.
  21335. }
  21336. }
  21337. }
  21338. def_optimize(AST_Array, function(self, compressor) {
  21339. var optimized = literals_in_boolean_context(self, compressor);
  21340. if (optimized !== self) {
  21341. return optimized;
  21342. }
  21343. inline_array_like_spread(self.elements);
  21344. return self;
  21345. });
  21346. function inline_object_prop_spread(props, compressor) {
  21347. for (var i = 0; i < props.length; i++) {
  21348. var prop = props[i];
  21349. if (prop instanceof AST_Expansion) {
  21350. const expr = prop.expression;
  21351. if (
  21352. expr instanceof AST_Object
  21353. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  21354. ) {
  21355. props.splice(i, 1, ...expr.properties);
  21356. // Step back one, as the property at i is now new.
  21357. i--;
  21358. } else if (expr instanceof AST_Constant
  21359. && !(expr instanceof AST_String)) {
  21360. // Unlike array-like spread, in object spread, spreading a
  21361. // non-iterable value silently does nothing; it is thus safe
  21362. // to remove. AST_String is the only iterable AST_Constant.
  21363. props.splice(i, 1);
  21364. i--;
  21365. } else if (is_nullish(expr, compressor)) {
  21366. // Likewise, null and undefined can be silently removed.
  21367. props.splice(i, 1);
  21368. i--;
  21369. }
  21370. }
  21371. }
  21372. }
  21373. def_optimize(AST_Object, function(self, compressor) {
  21374. var optimized = literals_in_boolean_context(self, compressor);
  21375. if (optimized !== self) {
  21376. return optimized;
  21377. }
  21378. inline_object_prop_spread(self.properties, compressor);
  21379. return self;
  21380. });
  21381. def_optimize(AST_RegExp, literals_in_boolean_context);
  21382. def_optimize(AST_Return, function(self, compressor) {
  21383. if (self.value && is_undefined(self.value, compressor)) {
  21384. self.value = null;
  21385. }
  21386. return self;
  21387. });
  21388. def_optimize(AST_Arrow, opt_AST_Lambda);
  21389. def_optimize(AST_Function, function(self, compressor) {
  21390. self = opt_AST_Lambda(self, compressor);
  21391. if (compressor.option("unsafe_arrows")
  21392. && compressor.option("ecma") >= 2015
  21393. && !self.name
  21394. && !self.is_generator
  21395. && !self.uses_arguments
  21396. && !self.pinned()) {
  21397. const uses_this = walk(self, node => {
  21398. if (node instanceof AST_This) return walk_abort;
  21399. });
  21400. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  21401. }
  21402. return self;
  21403. });
  21404. def_optimize(AST_Class, function(self) {
  21405. // HACK to avoid compress failure.
  21406. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  21407. return self;
  21408. });
  21409. def_optimize(AST_Yield, function(self, compressor) {
  21410. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  21411. self.expression = null;
  21412. }
  21413. return self;
  21414. });
  21415. def_optimize(AST_TemplateString, function(self, compressor) {
  21416. if (
  21417. !compressor.option("evaluate")
  21418. || compressor.parent() instanceof AST_PrefixedTemplateString
  21419. ) {
  21420. return self;
  21421. }
  21422. var segments = [];
  21423. for (var i = 0; i < self.segments.length; i++) {
  21424. var segment = self.segments[i];
  21425. if (segment instanceof AST_Node) {
  21426. var result = segment.evaluate(compressor);
  21427. // Evaluate to constant value
  21428. // Constant value shorter than ${segment}
  21429. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  21430. // There should always be a previous and next segment if segment is a node
  21431. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  21432. continue;
  21433. }
  21434. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  21435. // TODO:
  21436. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  21437. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  21438. if (segment instanceof AST_TemplateString) {
  21439. var inners = segment.segments;
  21440. segments[segments.length - 1].value += inners[0].value;
  21441. for (var j = 1; j < inners.length; j++) {
  21442. segment = inners[j];
  21443. segments.push(segment);
  21444. }
  21445. continue;
  21446. }
  21447. }
  21448. segments.push(segment);
  21449. }
  21450. self.segments = segments;
  21451. // `foo` => "foo"
  21452. if (segments.length == 1) {
  21453. return make_node(AST_String, self, segments[0]);
  21454. }
  21455. if (
  21456. segments.length === 3
  21457. && segments[1] instanceof AST_Node
  21458. && (
  21459. segments[1].is_string(compressor)
  21460. || segments[1].is_number(compressor)
  21461. || is_nullish(segments[1], compressor)
  21462. || compressor.option("unsafe")
  21463. )
  21464. ) {
  21465. // `foo${bar}` => "foo" + bar
  21466. if (segments[2].value === "") {
  21467. return make_node(AST_Binary, self, {
  21468. operator: "+",
  21469. left: make_node(AST_String, self, {
  21470. value: segments[0].value,
  21471. }),
  21472. right: segments[1],
  21473. });
  21474. }
  21475. // `${bar}baz` => bar + "baz"
  21476. if (segments[0].value === "") {
  21477. return make_node(AST_Binary, self, {
  21478. operator: "+",
  21479. left: segments[1],
  21480. right: make_node(AST_String, self, {
  21481. value: segments[2].value,
  21482. }),
  21483. });
  21484. }
  21485. }
  21486. return self;
  21487. });
  21488. def_optimize(AST_PrefixedTemplateString, function(self) {
  21489. return self;
  21490. });
  21491. // ["p"]:1 ---> p:1
  21492. // [42]:1 ---> 42:1
  21493. function lift_key(self, compressor) {
  21494. if (!compressor.option("computed_props")) return self;
  21495. // save a comparison in the typical case
  21496. if (!(self.key instanceof AST_Constant)) return self;
  21497. // allow certain acceptable props as not all AST_Constants are true constants
  21498. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  21499. if (self.key.value === "__proto__") return self;
  21500. if (self.key.value == "constructor"
  21501. && compressor.parent() instanceof AST_Class) return self;
  21502. if (self instanceof AST_ObjectKeyVal) {
  21503. self.quote = self.key.quote;
  21504. self.key = self.key.value;
  21505. } else if (self instanceof AST_ClassProperty) {
  21506. self.quote = self.key.quote;
  21507. self.key = make_node(AST_SymbolClassProperty, self.key, {
  21508. name: self.key.value
  21509. });
  21510. } else {
  21511. self.quote = self.key.quote;
  21512. self.key = make_node(AST_SymbolMethod, self.key, {
  21513. name: self.key.value
  21514. });
  21515. }
  21516. }
  21517. return self;
  21518. }
  21519. def_optimize(AST_ObjectProperty, lift_key);
  21520. def_optimize(AST_ConciseMethod, function(self, compressor) {
  21521. lift_key(self, compressor);
  21522. // p(){return x;} ---> p:()=>x
  21523. if (compressor.option("arrows")
  21524. && compressor.parent() instanceof AST_Object
  21525. && !self.is_generator
  21526. && !self.value.uses_arguments
  21527. && !self.value.pinned()
  21528. && self.value.body.length == 1
  21529. && self.value.body[0] instanceof AST_Return
  21530. && self.value.body[0].value
  21531. && !self.value.contains_this()) {
  21532. var arrow = make_node(AST_Arrow, self.value, self.value);
  21533. arrow.async = self.async;
  21534. arrow.is_generator = self.is_generator;
  21535. return make_node(AST_ObjectKeyVal, self, {
  21536. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  21537. value: arrow,
  21538. quote: self.quote,
  21539. });
  21540. }
  21541. return self;
  21542. });
  21543. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  21544. lift_key(self, compressor);
  21545. // p:function(){} ---> p(){}
  21546. // p:function*(){} ---> *p(){}
  21547. // p:async function(){} ---> async p(){}
  21548. // p:()=>{} ---> p(){}
  21549. // p:async()=>{} ---> async p(){}
  21550. var unsafe_methods = compressor.option("unsafe_methods");
  21551. if (unsafe_methods
  21552. && compressor.option("ecma") >= 2015
  21553. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  21554. var key = self.key;
  21555. var value = self.value;
  21556. var is_arrow_with_block = value instanceof AST_Arrow
  21557. && Array.isArray(value.body)
  21558. && !value.contains_this();
  21559. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  21560. return make_node(AST_ConciseMethod, self, {
  21561. async: value.async,
  21562. is_generator: value.is_generator,
  21563. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  21564. name: key,
  21565. }),
  21566. value: make_node(AST_Accessor, value, value),
  21567. quote: self.quote,
  21568. });
  21569. }
  21570. }
  21571. return self;
  21572. });
  21573. def_optimize(AST_Destructuring, function(self, compressor) {
  21574. if (compressor.option("pure_getters") == true
  21575. && compressor.option("unused")
  21576. && !self.is_array
  21577. && Array.isArray(self.names)
  21578. && !is_destructuring_export_decl(compressor)
  21579. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  21580. var keep = [];
  21581. for (var i = 0; i < self.names.length; i++) {
  21582. var elem = self.names[i];
  21583. if (!(elem instanceof AST_ObjectKeyVal
  21584. && typeof elem.key == "string"
  21585. && elem.value instanceof AST_SymbolDeclaration
  21586. && !should_retain(compressor, elem.value.definition()))) {
  21587. keep.push(elem);
  21588. }
  21589. }
  21590. if (keep.length != self.names.length) {
  21591. self.names = keep;
  21592. }
  21593. }
  21594. return self;
  21595. function is_destructuring_export_decl(compressor) {
  21596. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  21597. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  21598. var parent = compressor.parent(p);
  21599. if (!parent) return false;
  21600. if (a === 0 && parent.TYPE == "Destructuring") continue;
  21601. if (!ancestors[a].test(parent.TYPE)) {
  21602. return false;
  21603. }
  21604. a++;
  21605. }
  21606. return true;
  21607. }
  21608. function should_retain(compressor, def) {
  21609. if (def.references.length) return true;
  21610. if (!def.global) return false;
  21611. if (compressor.toplevel.vars) {
  21612. if (compressor.top_retain) {
  21613. return compressor.top_retain(def);
  21614. }
  21615. return false;
  21616. }
  21617. return true;
  21618. }
  21619. });
  21620. /***********************************************************************
  21621. A JavaScript tokenizer / parser / beautifier / compressor.
  21622. https://github.com/mishoo/UglifyJS2
  21623. -------------------------------- (C) ---------------------------------
  21624. Author: Mihai Bazon
  21625. <mihai.bazon@gmail.com>
  21626. http://mihai.bazon.net/blog
  21627. Distributed under the BSD license:
  21628. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  21629. Redistribution and use in source and binary forms, with or without
  21630. modification, are permitted provided that the following conditions
  21631. are met:
  21632. * Redistributions of source code must retain the above
  21633. copyright notice, this list of conditions and the following
  21634. disclaimer.
  21635. * Redistributions in binary form must reproduce the above
  21636. copyright notice, this list of conditions and the following
  21637. disclaimer in the documentation and/or other materials
  21638. provided with the distribution.
  21639. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  21640. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21641. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21642. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  21643. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  21644. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21645. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21646. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21647. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  21648. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  21649. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21650. SUCH DAMAGE.
  21651. ***********************************************************************/
  21652. // a small wrapper around fitzgen's source-map library
  21653. async function SourceMap(options) {
  21654. options = defaults(options, {
  21655. file : null,
  21656. root : null,
  21657. orig : null,
  21658. orig_line_diff : 0,
  21659. dest_line_diff : 0,
  21660. });
  21661. var orig_map;
  21662. var generator = new MOZ_SourceMap__default['default'].SourceMapGenerator({
  21663. file : options.file,
  21664. sourceRoot : options.root
  21665. });
  21666. if (options.orig) {
  21667. orig_map = await new MOZ_SourceMap__default['default'].SourceMapConsumer(options.orig);
  21668. orig_map.sources.forEach(function(source) {
  21669. var sourceContent = orig_map.sourceContentFor(source, true);
  21670. if (sourceContent) {
  21671. generator.setSourceContent(source, sourceContent);
  21672. }
  21673. });
  21674. }
  21675. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  21676. if (orig_map) {
  21677. var info = orig_map.originalPositionFor({
  21678. line: orig_line,
  21679. column: orig_col
  21680. });
  21681. if (info.source === null) {
  21682. return;
  21683. }
  21684. source = info.source;
  21685. orig_line = info.line;
  21686. orig_col = info.column;
  21687. name = info.name || name;
  21688. }
  21689. generator.addMapping({
  21690. generated : { line: gen_line + options.dest_line_diff, column: gen_col },
  21691. original : { line: orig_line + options.orig_line_diff, column: orig_col },
  21692. source : source,
  21693. name : name
  21694. });
  21695. }
  21696. return {
  21697. add : add,
  21698. get : function() { return generator; },
  21699. toString : function() { return generator.toString(); },
  21700. destroy : function () {
  21701. if (orig_map && orig_map.destroy) {
  21702. orig_map.destroy();
  21703. }
  21704. }
  21705. };
  21706. }
  21707. var domprops = [
  21708. "$&",
  21709. "$'",
  21710. "$*",
  21711. "$+",
  21712. "$1",
  21713. "$2",
  21714. "$3",
  21715. "$4",
  21716. "$5",
  21717. "$6",
  21718. "$7",
  21719. "$8",
  21720. "$9",
  21721. "$_",
  21722. "$`",
  21723. "$input",
  21724. "-moz-animation",
  21725. "-moz-animation-delay",
  21726. "-moz-animation-direction",
  21727. "-moz-animation-duration",
  21728. "-moz-animation-fill-mode",
  21729. "-moz-animation-iteration-count",
  21730. "-moz-animation-name",
  21731. "-moz-animation-play-state",
  21732. "-moz-animation-timing-function",
  21733. "-moz-appearance",
  21734. "-moz-backface-visibility",
  21735. "-moz-border-end",
  21736. "-moz-border-end-color",
  21737. "-moz-border-end-style",
  21738. "-moz-border-end-width",
  21739. "-moz-border-image",
  21740. "-moz-border-start",
  21741. "-moz-border-start-color",
  21742. "-moz-border-start-style",
  21743. "-moz-border-start-width",
  21744. "-moz-box-align",
  21745. "-moz-box-direction",
  21746. "-moz-box-flex",
  21747. "-moz-box-ordinal-group",
  21748. "-moz-box-orient",
  21749. "-moz-box-pack",
  21750. "-moz-box-sizing",
  21751. "-moz-float-edge",
  21752. "-moz-font-feature-settings",
  21753. "-moz-font-language-override",
  21754. "-moz-force-broken-image-icon",
  21755. "-moz-hyphens",
  21756. "-moz-image-region",
  21757. "-moz-margin-end",
  21758. "-moz-margin-start",
  21759. "-moz-orient",
  21760. "-moz-osx-font-smoothing",
  21761. "-moz-outline-radius",
  21762. "-moz-outline-radius-bottomleft",
  21763. "-moz-outline-radius-bottomright",
  21764. "-moz-outline-radius-topleft",
  21765. "-moz-outline-radius-topright",
  21766. "-moz-padding-end",
  21767. "-moz-padding-start",
  21768. "-moz-perspective",
  21769. "-moz-perspective-origin",
  21770. "-moz-tab-size",
  21771. "-moz-text-size-adjust",
  21772. "-moz-transform",
  21773. "-moz-transform-origin",
  21774. "-moz-transform-style",
  21775. "-moz-transition",
  21776. "-moz-transition-delay",
  21777. "-moz-transition-duration",
  21778. "-moz-transition-property",
  21779. "-moz-transition-timing-function",
  21780. "-moz-user-focus",
  21781. "-moz-user-input",
  21782. "-moz-user-modify",
  21783. "-moz-user-select",
  21784. "-moz-window-dragging",
  21785. "-webkit-align-content",
  21786. "-webkit-align-items",
  21787. "-webkit-align-self",
  21788. "-webkit-animation",
  21789. "-webkit-animation-delay",
  21790. "-webkit-animation-direction",
  21791. "-webkit-animation-duration",
  21792. "-webkit-animation-fill-mode",
  21793. "-webkit-animation-iteration-count",
  21794. "-webkit-animation-name",
  21795. "-webkit-animation-play-state",
  21796. "-webkit-animation-timing-function",
  21797. "-webkit-appearance",
  21798. "-webkit-backface-visibility",
  21799. "-webkit-background-clip",
  21800. "-webkit-background-origin",
  21801. "-webkit-background-size",
  21802. "-webkit-border-bottom-left-radius",
  21803. "-webkit-border-bottom-right-radius",
  21804. "-webkit-border-image",
  21805. "-webkit-border-radius",
  21806. "-webkit-border-top-left-radius",
  21807. "-webkit-border-top-right-radius",
  21808. "-webkit-box-align",
  21809. "-webkit-box-direction",
  21810. "-webkit-box-flex",
  21811. "-webkit-box-ordinal-group",
  21812. "-webkit-box-orient",
  21813. "-webkit-box-pack",
  21814. "-webkit-box-shadow",
  21815. "-webkit-box-sizing",
  21816. "-webkit-filter",
  21817. "-webkit-flex",
  21818. "-webkit-flex-basis",
  21819. "-webkit-flex-direction",
  21820. "-webkit-flex-flow",
  21821. "-webkit-flex-grow",
  21822. "-webkit-flex-shrink",
  21823. "-webkit-flex-wrap",
  21824. "-webkit-justify-content",
  21825. "-webkit-line-clamp",
  21826. "-webkit-mask",
  21827. "-webkit-mask-clip",
  21828. "-webkit-mask-composite",
  21829. "-webkit-mask-image",
  21830. "-webkit-mask-origin",
  21831. "-webkit-mask-position",
  21832. "-webkit-mask-position-x",
  21833. "-webkit-mask-position-y",
  21834. "-webkit-mask-repeat",
  21835. "-webkit-mask-size",
  21836. "-webkit-order",
  21837. "-webkit-perspective",
  21838. "-webkit-perspective-origin",
  21839. "-webkit-text-fill-color",
  21840. "-webkit-text-size-adjust",
  21841. "-webkit-text-stroke",
  21842. "-webkit-text-stroke-color",
  21843. "-webkit-text-stroke-width",
  21844. "-webkit-transform",
  21845. "-webkit-transform-origin",
  21846. "-webkit-transform-style",
  21847. "-webkit-transition",
  21848. "-webkit-transition-delay",
  21849. "-webkit-transition-duration",
  21850. "-webkit-transition-property",
  21851. "-webkit-transition-timing-function",
  21852. "-webkit-user-select",
  21853. "0",
  21854. "1",
  21855. "10",
  21856. "11",
  21857. "12",
  21858. "13",
  21859. "14",
  21860. "15",
  21861. "16",
  21862. "17",
  21863. "18",
  21864. "19",
  21865. "2",
  21866. "20",
  21867. "3",
  21868. "4",
  21869. "5",
  21870. "6",
  21871. "7",
  21872. "8",
  21873. "9",
  21874. "@@iterator",
  21875. "ABORT_ERR",
  21876. "ACTIVE",
  21877. "ACTIVE_ATTRIBUTES",
  21878. "ACTIVE_TEXTURE",
  21879. "ACTIVE_UNIFORMS",
  21880. "ACTIVE_UNIFORM_BLOCKS",
  21881. "ADDITION",
  21882. "ALIASED_LINE_WIDTH_RANGE",
  21883. "ALIASED_POINT_SIZE_RANGE",
  21884. "ALLOW_KEYBOARD_INPUT",
  21885. "ALLPASS",
  21886. "ALPHA",
  21887. "ALPHA_BITS",
  21888. "ALREADY_SIGNALED",
  21889. "ALT_MASK",
  21890. "ALWAYS",
  21891. "ANY_SAMPLES_PASSED",
  21892. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  21893. "ANY_TYPE",
  21894. "ANY_UNORDERED_NODE_TYPE",
  21895. "ARRAY_BUFFER",
  21896. "ARRAY_BUFFER_BINDING",
  21897. "ATTACHED_SHADERS",
  21898. "ATTRIBUTE_NODE",
  21899. "AT_TARGET",
  21900. "AbortController",
  21901. "AbortSignal",
  21902. "AbsoluteOrientationSensor",
  21903. "AbstractRange",
  21904. "Accelerometer",
  21905. "AddSearchProvider",
  21906. "AggregateError",
  21907. "AnalyserNode",
  21908. "Animation",
  21909. "AnimationEffect",
  21910. "AnimationEvent",
  21911. "AnimationPlaybackEvent",
  21912. "AnimationTimeline",
  21913. "AnonXMLHttpRequest",
  21914. "Any",
  21915. "ApplicationCache",
  21916. "ApplicationCacheErrorEvent",
  21917. "Array",
  21918. "ArrayBuffer",
  21919. "ArrayType",
  21920. "Atomics",
  21921. "Attr",
  21922. "Audio",
  21923. "AudioBuffer",
  21924. "AudioBufferSourceNode",
  21925. "AudioContext",
  21926. "AudioDestinationNode",
  21927. "AudioListener",
  21928. "AudioNode",
  21929. "AudioParam",
  21930. "AudioParamMap",
  21931. "AudioProcessingEvent",
  21932. "AudioScheduledSourceNode",
  21933. "AudioStreamTrack",
  21934. "AudioWorklet",
  21935. "AudioWorkletNode",
  21936. "AuthenticatorAssertionResponse",
  21937. "AuthenticatorAttestationResponse",
  21938. "AuthenticatorResponse",
  21939. "AutocompleteErrorEvent",
  21940. "BACK",
  21941. "BAD_BOUNDARYPOINTS_ERR",
  21942. "BAD_REQUEST",
  21943. "BANDPASS",
  21944. "BLEND",
  21945. "BLEND_COLOR",
  21946. "BLEND_DST_ALPHA",
  21947. "BLEND_DST_RGB",
  21948. "BLEND_EQUATION",
  21949. "BLEND_EQUATION_ALPHA",
  21950. "BLEND_EQUATION_RGB",
  21951. "BLEND_SRC_ALPHA",
  21952. "BLEND_SRC_RGB",
  21953. "BLUE_BITS",
  21954. "BLUR",
  21955. "BOOL",
  21956. "BOOLEAN_TYPE",
  21957. "BOOL_VEC2",
  21958. "BOOL_VEC3",
  21959. "BOOL_VEC4",
  21960. "BOTH",
  21961. "BROWSER_DEFAULT_WEBGL",
  21962. "BUBBLING_PHASE",
  21963. "BUFFER_SIZE",
  21964. "BUFFER_USAGE",
  21965. "BYTE",
  21966. "BYTES_PER_ELEMENT",
  21967. "BackgroundFetchManager",
  21968. "BackgroundFetchRecord",
  21969. "BackgroundFetchRegistration",
  21970. "BarProp",
  21971. "BarcodeDetector",
  21972. "BaseAudioContext",
  21973. "BaseHref",
  21974. "BatteryManager",
  21975. "BeforeInstallPromptEvent",
  21976. "BeforeLoadEvent",
  21977. "BeforeUnloadEvent",
  21978. "BigInt",
  21979. "BigInt64Array",
  21980. "BigUint64Array",
  21981. "BiquadFilterNode",
  21982. "Blob",
  21983. "BlobEvent",
  21984. "Bluetooth",
  21985. "BluetoothCharacteristicProperties",
  21986. "BluetoothDevice",
  21987. "BluetoothRemoteGATTCharacteristic",
  21988. "BluetoothRemoteGATTDescriptor",
  21989. "BluetoothRemoteGATTServer",
  21990. "BluetoothRemoteGATTService",
  21991. "BluetoothUUID",
  21992. "Boolean",
  21993. "BroadcastChannel",
  21994. "ByteLengthQueuingStrategy",
  21995. "CAPTURING_PHASE",
  21996. "CCW",
  21997. "CDATASection",
  21998. "CDATA_SECTION_NODE",
  21999. "CHANGE",
  22000. "CHARSET_RULE",
  22001. "CHECKING",
  22002. "CLAMP_TO_EDGE",
  22003. "CLICK",
  22004. "CLOSED",
  22005. "CLOSING",
  22006. "COLOR",
  22007. "COLOR_ATTACHMENT0",
  22008. "COLOR_ATTACHMENT1",
  22009. "COLOR_ATTACHMENT10",
  22010. "COLOR_ATTACHMENT11",
  22011. "COLOR_ATTACHMENT12",
  22012. "COLOR_ATTACHMENT13",
  22013. "COLOR_ATTACHMENT14",
  22014. "COLOR_ATTACHMENT15",
  22015. "COLOR_ATTACHMENT2",
  22016. "COLOR_ATTACHMENT3",
  22017. "COLOR_ATTACHMENT4",
  22018. "COLOR_ATTACHMENT5",
  22019. "COLOR_ATTACHMENT6",
  22020. "COLOR_ATTACHMENT7",
  22021. "COLOR_ATTACHMENT8",
  22022. "COLOR_ATTACHMENT9",
  22023. "COLOR_BUFFER_BIT",
  22024. "COLOR_CLEAR_VALUE",
  22025. "COLOR_WRITEMASK",
  22026. "COMMENT_NODE",
  22027. "COMPARE_REF_TO_TEXTURE",
  22028. "COMPILE_STATUS",
  22029. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  22030. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  22031. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  22032. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  22033. "COMPRESSED_TEXTURE_FORMATS",
  22034. "CONDITION_SATISFIED",
  22035. "CONFIGURATION_UNSUPPORTED",
  22036. "CONNECTING",
  22037. "CONSTANT_ALPHA",
  22038. "CONSTANT_COLOR",
  22039. "CONSTRAINT_ERR",
  22040. "CONTEXT_LOST_WEBGL",
  22041. "CONTROL_MASK",
  22042. "COPY_READ_BUFFER",
  22043. "COPY_READ_BUFFER_BINDING",
  22044. "COPY_WRITE_BUFFER",
  22045. "COPY_WRITE_BUFFER_BINDING",
  22046. "COUNTER_STYLE_RULE",
  22047. "CSS",
  22048. "CSS2Properties",
  22049. "CSSAnimation",
  22050. "CSSCharsetRule",
  22051. "CSSConditionRule",
  22052. "CSSCounterStyleRule",
  22053. "CSSFontFaceRule",
  22054. "CSSFontFeatureValuesRule",
  22055. "CSSGroupingRule",
  22056. "CSSImageValue",
  22057. "CSSImportRule",
  22058. "CSSKeyframeRule",
  22059. "CSSKeyframesRule",
  22060. "CSSKeywordValue",
  22061. "CSSMathInvert",
  22062. "CSSMathMax",
  22063. "CSSMathMin",
  22064. "CSSMathNegate",
  22065. "CSSMathProduct",
  22066. "CSSMathSum",
  22067. "CSSMathValue",
  22068. "CSSMatrixComponent",
  22069. "CSSMediaRule",
  22070. "CSSMozDocumentRule",
  22071. "CSSNameSpaceRule",
  22072. "CSSNamespaceRule",
  22073. "CSSNumericArray",
  22074. "CSSNumericValue",
  22075. "CSSPageRule",
  22076. "CSSPerspective",
  22077. "CSSPositionValue",
  22078. "CSSPrimitiveValue",
  22079. "CSSRotate",
  22080. "CSSRule",
  22081. "CSSRuleList",
  22082. "CSSScale",
  22083. "CSSSkew",
  22084. "CSSSkewX",
  22085. "CSSSkewY",
  22086. "CSSStyleDeclaration",
  22087. "CSSStyleRule",
  22088. "CSSStyleSheet",
  22089. "CSSStyleValue",
  22090. "CSSSupportsRule",
  22091. "CSSTransformComponent",
  22092. "CSSTransformValue",
  22093. "CSSTransition",
  22094. "CSSTranslate",
  22095. "CSSUnitValue",
  22096. "CSSUnknownRule",
  22097. "CSSUnparsedValue",
  22098. "CSSValue",
  22099. "CSSValueList",
  22100. "CSSVariableReferenceValue",
  22101. "CSSVariablesDeclaration",
  22102. "CSSVariablesRule",
  22103. "CSSViewportRule",
  22104. "CSS_ATTR",
  22105. "CSS_CM",
  22106. "CSS_COUNTER",
  22107. "CSS_CUSTOM",
  22108. "CSS_DEG",
  22109. "CSS_DIMENSION",
  22110. "CSS_EMS",
  22111. "CSS_EXS",
  22112. "CSS_FILTER_BLUR",
  22113. "CSS_FILTER_BRIGHTNESS",
  22114. "CSS_FILTER_CONTRAST",
  22115. "CSS_FILTER_CUSTOM",
  22116. "CSS_FILTER_DROP_SHADOW",
  22117. "CSS_FILTER_GRAYSCALE",
  22118. "CSS_FILTER_HUE_ROTATE",
  22119. "CSS_FILTER_INVERT",
  22120. "CSS_FILTER_OPACITY",
  22121. "CSS_FILTER_REFERENCE",
  22122. "CSS_FILTER_SATURATE",
  22123. "CSS_FILTER_SEPIA",
  22124. "CSS_GRAD",
  22125. "CSS_HZ",
  22126. "CSS_IDENT",
  22127. "CSS_IN",
  22128. "CSS_INHERIT",
  22129. "CSS_KHZ",
  22130. "CSS_MATRIX",
  22131. "CSS_MATRIX3D",
  22132. "CSS_MM",
  22133. "CSS_MS",
  22134. "CSS_NUMBER",
  22135. "CSS_PC",
  22136. "CSS_PERCENTAGE",
  22137. "CSS_PERSPECTIVE",
  22138. "CSS_PRIMITIVE_VALUE",
  22139. "CSS_PT",
  22140. "CSS_PX",
  22141. "CSS_RAD",
  22142. "CSS_RECT",
  22143. "CSS_RGBCOLOR",
  22144. "CSS_ROTATE",
  22145. "CSS_ROTATE3D",
  22146. "CSS_ROTATEX",
  22147. "CSS_ROTATEY",
  22148. "CSS_ROTATEZ",
  22149. "CSS_S",
  22150. "CSS_SCALE",
  22151. "CSS_SCALE3D",
  22152. "CSS_SCALEX",
  22153. "CSS_SCALEY",
  22154. "CSS_SCALEZ",
  22155. "CSS_SKEW",
  22156. "CSS_SKEWX",
  22157. "CSS_SKEWY",
  22158. "CSS_STRING",
  22159. "CSS_TRANSLATE",
  22160. "CSS_TRANSLATE3D",
  22161. "CSS_TRANSLATEX",
  22162. "CSS_TRANSLATEY",
  22163. "CSS_TRANSLATEZ",
  22164. "CSS_UNKNOWN",
  22165. "CSS_URI",
  22166. "CSS_VALUE_LIST",
  22167. "CSS_VH",
  22168. "CSS_VMAX",
  22169. "CSS_VMIN",
  22170. "CSS_VW",
  22171. "CULL_FACE",
  22172. "CULL_FACE_MODE",
  22173. "CURRENT_PROGRAM",
  22174. "CURRENT_QUERY",
  22175. "CURRENT_VERTEX_ATTRIB",
  22176. "CUSTOM",
  22177. "CW",
  22178. "Cache",
  22179. "CacheStorage",
  22180. "CanvasCaptureMediaStream",
  22181. "CanvasCaptureMediaStreamTrack",
  22182. "CanvasGradient",
  22183. "CanvasPattern",
  22184. "CanvasRenderingContext2D",
  22185. "CaretPosition",
  22186. "ChannelMergerNode",
  22187. "ChannelSplitterNode",
  22188. "CharacterData",
  22189. "ClientRect",
  22190. "ClientRectList",
  22191. "Clipboard",
  22192. "ClipboardEvent",
  22193. "ClipboardItem",
  22194. "CloseEvent",
  22195. "Collator",
  22196. "CommandEvent",
  22197. "Comment",
  22198. "CompileError",
  22199. "CompositionEvent",
  22200. "CompressionStream",
  22201. "Console",
  22202. "ConstantSourceNode",
  22203. "Controllers",
  22204. "ConvolverNode",
  22205. "CountQueuingStrategy",
  22206. "Counter",
  22207. "Credential",
  22208. "CredentialsContainer",
  22209. "Crypto",
  22210. "CryptoKey",
  22211. "CustomElementRegistry",
  22212. "CustomEvent",
  22213. "DATABASE_ERR",
  22214. "DATA_CLONE_ERR",
  22215. "DATA_ERR",
  22216. "DBLCLICK",
  22217. "DECR",
  22218. "DECR_WRAP",
  22219. "DELETE_STATUS",
  22220. "DEPTH",
  22221. "DEPTH24_STENCIL8",
  22222. "DEPTH32F_STENCIL8",
  22223. "DEPTH_ATTACHMENT",
  22224. "DEPTH_BITS",
  22225. "DEPTH_BUFFER_BIT",
  22226. "DEPTH_CLEAR_VALUE",
  22227. "DEPTH_COMPONENT",
  22228. "DEPTH_COMPONENT16",
  22229. "DEPTH_COMPONENT24",
  22230. "DEPTH_COMPONENT32F",
  22231. "DEPTH_FUNC",
  22232. "DEPTH_RANGE",
  22233. "DEPTH_STENCIL",
  22234. "DEPTH_STENCIL_ATTACHMENT",
  22235. "DEPTH_TEST",
  22236. "DEPTH_WRITEMASK",
  22237. "DEVICE_INELIGIBLE",
  22238. "DIRECTION_DOWN",
  22239. "DIRECTION_LEFT",
  22240. "DIRECTION_RIGHT",
  22241. "DIRECTION_UP",
  22242. "DISABLED",
  22243. "DISPATCH_REQUEST_ERR",
  22244. "DITHER",
  22245. "DOCUMENT_FRAGMENT_NODE",
  22246. "DOCUMENT_NODE",
  22247. "DOCUMENT_POSITION_CONTAINED_BY",
  22248. "DOCUMENT_POSITION_CONTAINS",
  22249. "DOCUMENT_POSITION_DISCONNECTED",
  22250. "DOCUMENT_POSITION_FOLLOWING",
  22251. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  22252. "DOCUMENT_POSITION_PRECEDING",
  22253. "DOCUMENT_TYPE_NODE",
  22254. "DOMCursor",
  22255. "DOMError",
  22256. "DOMException",
  22257. "DOMImplementation",
  22258. "DOMImplementationLS",
  22259. "DOMMatrix",
  22260. "DOMMatrixReadOnly",
  22261. "DOMParser",
  22262. "DOMPoint",
  22263. "DOMPointReadOnly",
  22264. "DOMQuad",
  22265. "DOMRect",
  22266. "DOMRectList",
  22267. "DOMRectReadOnly",
  22268. "DOMRequest",
  22269. "DOMSTRING_SIZE_ERR",
  22270. "DOMSettableTokenList",
  22271. "DOMStringList",
  22272. "DOMStringMap",
  22273. "DOMTokenList",
  22274. "DOMTransactionEvent",
  22275. "DOM_DELTA_LINE",
  22276. "DOM_DELTA_PAGE",
  22277. "DOM_DELTA_PIXEL",
  22278. "DOM_INPUT_METHOD_DROP",
  22279. "DOM_INPUT_METHOD_HANDWRITING",
  22280. "DOM_INPUT_METHOD_IME",
  22281. "DOM_INPUT_METHOD_KEYBOARD",
  22282. "DOM_INPUT_METHOD_MULTIMODAL",
  22283. "DOM_INPUT_METHOD_OPTION",
  22284. "DOM_INPUT_METHOD_PASTE",
  22285. "DOM_INPUT_METHOD_SCRIPT",
  22286. "DOM_INPUT_METHOD_UNKNOWN",
  22287. "DOM_INPUT_METHOD_VOICE",
  22288. "DOM_KEY_LOCATION_JOYSTICK",
  22289. "DOM_KEY_LOCATION_LEFT",
  22290. "DOM_KEY_LOCATION_MOBILE",
  22291. "DOM_KEY_LOCATION_NUMPAD",
  22292. "DOM_KEY_LOCATION_RIGHT",
  22293. "DOM_KEY_LOCATION_STANDARD",
  22294. "DOM_VK_0",
  22295. "DOM_VK_1",
  22296. "DOM_VK_2",
  22297. "DOM_VK_3",
  22298. "DOM_VK_4",
  22299. "DOM_VK_5",
  22300. "DOM_VK_6",
  22301. "DOM_VK_7",
  22302. "DOM_VK_8",
  22303. "DOM_VK_9",
  22304. "DOM_VK_A",
  22305. "DOM_VK_ACCEPT",
  22306. "DOM_VK_ADD",
  22307. "DOM_VK_ALT",
  22308. "DOM_VK_ALTGR",
  22309. "DOM_VK_AMPERSAND",
  22310. "DOM_VK_ASTERISK",
  22311. "DOM_VK_AT",
  22312. "DOM_VK_ATTN",
  22313. "DOM_VK_B",
  22314. "DOM_VK_BACKSPACE",
  22315. "DOM_VK_BACK_QUOTE",
  22316. "DOM_VK_BACK_SLASH",
  22317. "DOM_VK_BACK_SPACE",
  22318. "DOM_VK_C",
  22319. "DOM_VK_CANCEL",
  22320. "DOM_VK_CAPS_LOCK",
  22321. "DOM_VK_CIRCUMFLEX",
  22322. "DOM_VK_CLEAR",
  22323. "DOM_VK_CLOSE_BRACKET",
  22324. "DOM_VK_CLOSE_CURLY_BRACKET",
  22325. "DOM_VK_CLOSE_PAREN",
  22326. "DOM_VK_COLON",
  22327. "DOM_VK_COMMA",
  22328. "DOM_VK_CONTEXT_MENU",
  22329. "DOM_VK_CONTROL",
  22330. "DOM_VK_CONVERT",
  22331. "DOM_VK_CRSEL",
  22332. "DOM_VK_CTRL",
  22333. "DOM_VK_D",
  22334. "DOM_VK_DECIMAL",
  22335. "DOM_VK_DELETE",
  22336. "DOM_VK_DIVIDE",
  22337. "DOM_VK_DOLLAR",
  22338. "DOM_VK_DOUBLE_QUOTE",
  22339. "DOM_VK_DOWN",
  22340. "DOM_VK_E",
  22341. "DOM_VK_EISU",
  22342. "DOM_VK_END",
  22343. "DOM_VK_ENTER",
  22344. "DOM_VK_EQUALS",
  22345. "DOM_VK_EREOF",
  22346. "DOM_VK_ESCAPE",
  22347. "DOM_VK_EXCLAMATION",
  22348. "DOM_VK_EXECUTE",
  22349. "DOM_VK_EXSEL",
  22350. "DOM_VK_F",
  22351. "DOM_VK_F1",
  22352. "DOM_VK_F10",
  22353. "DOM_VK_F11",
  22354. "DOM_VK_F12",
  22355. "DOM_VK_F13",
  22356. "DOM_VK_F14",
  22357. "DOM_VK_F15",
  22358. "DOM_VK_F16",
  22359. "DOM_VK_F17",
  22360. "DOM_VK_F18",
  22361. "DOM_VK_F19",
  22362. "DOM_VK_F2",
  22363. "DOM_VK_F20",
  22364. "DOM_VK_F21",
  22365. "DOM_VK_F22",
  22366. "DOM_VK_F23",
  22367. "DOM_VK_F24",
  22368. "DOM_VK_F25",
  22369. "DOM_VK_F26",
  22370. "DOM_VK_F27",
  22371. "DOM_VK_F28",
  22372. "DOM_VK_F29",
  22373. "DOM_VK_F3",
  22374. "DOM_VK_F30",
  22375. "DOM_VK_F31",
  22376. "DOM_VK_F32",
  22377. "DOM_VK_F33",
  22378. "DOM_VK_F34",
  22379. "DOM_VK_F35",
  22380. "DOM_VK_F36",
  22381. "DOM_VK_F4",
  22382. "DOM_VK_F5",
  22383. "DOM_VK_F6",
  22384. "DOM_VK_F7",
  22385. "DOM_VK_F8",
  22386. "DOM_VK_F9",
  22387. "DOM_VK_FINAL",
  22388. "DOM_VK_FRONT",
  22389. "DOM_VK_G",
  22390. "DOM_VK_GREATER_THAN",
  22391. "DOM_VK_H",
  22392. "DOM_VK_HANGUL",
  22393. "DOM_VK_HANJA",
  22394. "DOM_VK_HASH",
  22395. "DOM_VK_HELP",
  22396. "DOM_VK_HK_TOGGLE",
  22397. "DOM_VK_HOME",
  22398. "DOM_VK_HYPHEN_MINUS",
  22399. "DOM_VK_I",
  22400. "DOM_VK_INSERT",
  22401. "DOM_VK_J",
  22402. "DOM_VK_JUNJA",
  22403. "DOM_VK_K",
  22404. "DOM_VK_KANA",
  22405. "DOM_VK_KANJI",
  22406. "DOM_VK_L",
  22407. "DOM_VK_LEFT",
  22408. "DOM_VK_LEFT_TAB",
  22409. "DOM_VK_LESS_THAN",
  22410. "DOM_VK_M",
  22411. "DOM_VK_META",
  22412. "DOM_VK_MODECHANGE",
  22413. "DOM_VK_MULTIPLY",
  22414. "DOM_VK_N",
  22415. "DOM_VK_NONCONVERT",
  22416. "DOM_VK_NUMPAD0",
  22417. "DOM_VK_NUMPAD1",
  22418. "DOM_VK_NUMPAD2",
  22419. "DOM_VK_NUMPAD3",
  22420. "DOM_VK_NUMPAD4",
  22421. "DOM_VK_NUMPAD5",
  22422. "DOM_VK_NUMPAD6",
  22423. "DOM_VK_NUMPAD7",
  22424. "DOM_VK_NUMPAD8",
  22425. "DOM_VK_NUMPAD9",
  22426. "DOM_VK_NUM_LOCK",
  22427. "DOM_VK_O",
  22428. "DOM_VK_OEM_1",
  22429. "DOM_VK_OEM_102",
  22430. "DOM_VK_OEM_2",
  22431. "DOM_VK_OEM_3",
  22432. "DOM_VK_OEM_4",
  22433. "DOM_VK_OEM_5",
  22434. "DOM_VK_OEM_6",
  22435. "DOM_VK_OEM_7",
  22436. "DOM_VK_OEM_8",
  22437. "DOM_VK_OEM_COMMA",
  22438. "DOM_VK_OEM_MINUS",
  22439. "DOM_VK_OEM_PERIOD",
  22440. "DOM_VK_OEM_PLUS",
  22441. "DOM_VK_OPEN_BRACKET",
  22442. "DOM_VK_OPEN_CURLY_BRACKET",
  22443. "DOM_VK_OPEN_PAREN",
  22444. "DOM_VK_P",
  22445. "DOM_VK_PA1",
  22446. "DOM_VK_PAGEDOWN",
  22447. "DOM_VK_PAGEUP",
  22448. "DOM_VK_PAGE_DOWN",
  22449. "DOM_VK_PAGE_UP",
  22450. "DOM_VK_PAUSE",
  22451. "DOM_VK_PERCENT",
  22452. "DOM_VK_PERIOD",
  22453. "DOM_VK_PIPE",
  22454. "DOM_VK_PLAY",
  22455. "DOM_VK_PLUS",
  22456. "DOM_VK_PRINT",
  22457. "DOM_VK_PRINTSCREEN",
  22458. "DOM_VK_PROCESSKEY",
  22459. "DOM_VK_PROPERITES",
  22460. "DOM_VK_Q",
  22461. "DOM_VK_QUESTION_MARK",
  22462. "DOM_VK_QUOTE",
  22463. "DOM_VK_R",
  22464. "DOM_VK_REDO",
  22465. "DOM_VK_RETURN",
  22466. "DOM_VK_RIGHT",
  22467. "DOM_VK_S",
  22468. "DOM_VK_SCROLL_LOCK",
  22469. "DOM_VK_SELECT",
  22470. "DOM_VK_SEMICOLON",
  22471. "DOM_VK_SEPARATOR",
  22472. "DOM_VK_SHIFT",
  22473. "DOM_VK_SLASH",
  22474. "DOM_VK_SLEEP",
  22475. "DOM_VK_SPACE",
  22476. "DOM_VK_SUBTRACT",
  22477. "DOM_VK_T",
  22478. "DOM_VK_TAB",
  22479. "DOM_VK_TILDE",
  22480. "DOM_VK_U",
  22481. "DOM_VK_UNDERSCORE",
  22482. "DOM_VK_UNDO",
  22483. "DOM_VK_UNICODE",
  22484. "DOM_VK_UP",
  22485. "DOM_VK_V",
  22486. "DOM_VK_VOLUME_DOWN",
  22487. "DOM_VK_VOLUME_MUTE",
  22488. "DOM_VK_VOLUME_UP",
  22489. "DOM_VK_W",
  22490. "DOM_VK_WIN",
  22491. "DOM_VK_WINDOW",
  22492. "DOM_VK_WIN_ICO_00",
  22493. "DOM_VK_WIN_ICO_CLEAR",
  22494. "DOM_VK_WIN_ICO_HELP",
  22495. "DOM_VK_WIN_OEM_ATTN",
  22496. "DOM_VK_WIN_OEM_AUTO",
  22497. "DOM_VK_WIN_OEM_BACKTAB",
  22498. "DOM_VK_WIN_OEM_CLEAR",
  22499. "DOM_VK_WIN_OEM_COPY",
  22500. "DOM_VK_WIN_OEM_CUSEL",
  22501. "DOM_VK_WIN_OEM_ENLW",
  22502. "DOM_VK_WIN_OEM_FINISH",
  22503. "DOM_VK_WIN_OEM_FJ_JISHO",
  22504. "DOM_VK_WIN_OEM_FJ_LOYA",
  22505. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  22506. "DOM_VK_WIN_OEM_FJ_ROYA",
  22507. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  22508. "DOM_VK_WIN_OEM_JUMP",
  22509. "DOM_VK_WIN_OEM_PA1",
  22510. "DOM_VK_WIN_OEM_PA2",
  22511. "DOM_VK_WIN_OEM_PA3",
  22512. "DOM_VK_WIN_OEM_RESET",
  22513. "DOM_VK_WIN_OEM_WSCTRL",
  22514. "DOM_VK_X",
  22515. "DOM_VK_XF86XK_ADD_FAVORITE",
  22516. "DOM_VK_XF86XK_APPLICATION_LEFT",
  22517. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  22518. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  22519. "DOM_VK_XF86XK_AUDIO_FORWARD",
  22520. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  22521. "DOM_VK_XF86XK_AUDIO_MEDIA",
  22522. "DOM_VK_XF86XK_AUDIO_MUTE",
  22523. "DOM_VK_XF86XK_AUDIO_NEXT",
  22524. "DOM_VK_XF86XK_AUDIO_PAUSE",
  22525. "DOM_VK_XF86XK_AUDIO_PLAY",
  22526. "DOM_VK_XF86XK_AUDIO_PREV",
  22527. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  22528. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  22529. "DOM_VK_XF86XK_AUDIO_RECORD",
  22530. "DOM_VK_XF86XK_AUDIO_REPEAT",
  22531. "DOM_VK_XF86XK_AUDIO_REWIND",
  22532. "DOM_VK_XF86XK_AUDIO_STOP",
  22533. "DOM_VK_XF86XK_AWAY",
  22534. "DOM_VK_XF86XK_BACK",
  22535. "DOM_VK_XF86XK_BACK_FORWARD",
  22536. "DOM_VK_XF86XK_BATTERY",
  22537. "DOM_VK_XF86XK_BLUE",
  22538. "DOM_VK_XF86XK_BLUETOOTH",
  22539. "DOM_VK_XF86XK_BOOK",
  22540. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  22541. "DOM_VK_XF86XK_CALCULATOR",
  22542. "DOM_VK_XF86XK_CALENDAR",
  22543. "DOM_VK_XF86XK_CD",
  22544. "DOM_VK_XF86XK_CLOSE",
  22545. "DOM_VK_XF86XK_COMMUNITY",
  22546. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  22547. "DOM_VK_XF86XK_COPY",
  22548. "DOM_VK_XF86XK_CUT",
  22549. "DOM_VK_XF86XK_CYCLE_ANGLE",
  22550. "DOM_VK_XF86XK_DISPLAY",
  22551. "DOM_VK_XF86XK_DOCUMENTS",
  22552. "DOM_VK_XF86XK_DOS",
  22553. "DOM_VK_XF86XK_EJECT",
  22554. "DOM_VK_XF86XK_EXCEL",
  22555. "DOM_VK_XF86XK_EXPLORER",
  22556. "DOM_VK_XF86XK_FAVORITES",
  22557. "DOM_VK_XF86XK_FINANCE",
  22558. "DOM_VK_XF86XK_FORWARD",
  22559. "DOM_VK_XF86XK_FRAME_BACK",
  22560. "DOM_VK_XF86XK_FRAME_FORWARD",
  22561. "DOM_VK_XF86XK_GAME",
  22562. "DOM_VK_XF86XK_GO",
  22563. "DOM_VK_XF86XK_GREEN",
  22564. "DOM_VK_XF86XK_HIBERNATE",
  22565. "DOM_VK_XF86XK_HISTORY",
  22566. "DOM_VK_XF86XK_HOME_PAGE",
  22567. "DOM_VK_XF86XK_HOT_LINKS",
  22568. "DOM_VK_XF86XK_I_TOUCH",
  22569. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  22570. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  22571. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  22572. "DOM_VK_XF86XK_LAUNCH0",
  22573. "DOM_VK_XF86XK_LAUNCH1",
  22574. "DOM_VK_XF86XK_LAUNCH2",
  22575. "DOM_VK_XF86XK_LAUNCH3",
  22576. "DOM_VK_XF86XK_LAUNCH4",
  22577. "DOM_VK_XF86XK_LAUNCH5",
  22578. "DOM_VK_XF86XK_LAUNCH6",
  22579. "DOM_VK_XF86XK_LAUNCH7",
  22580. "DOM_VK_XF86XK_LAUNCH8",
  22581. "DOM_VK_XF86XK_LAUNCH9",
  22582. "DOM_VK_XF86XK_LAUNCH_A",
  22583. "DOM_VK_XF86XK_LAUNCH_B",
  22584. "DOM_VK_XF86XK_LAUNCH_C",
  22585. "DOM_VK_XF86XK_LAUNCH_D",
  22586. "DOM_VK_XF86XK_LAUNCH_E",
  22587. "DOM_VK_XF86XK_LAUNCH_F",
  22588. "DOM_VK_XF86XK_LIGHT_BULB",
  22589. "DOM_VK_XF86XK_LOG_OFF",
  22590. "DOM_VK_XF86XK_MAIL",
  22591. "DOM_VK_XF86XK_MAIL_FORWARD",
  22592. "DOM_VK_XF86XK_MARKET",
  22593. "DOM_VK_XF86XK_MEETING",
  22594. "DOM_VK_XF86XK_MEMO",
  22595. "DOM_VK_XF86XK_MENU_KB",
  22596. "DOM_VK_XF86XK_MENU_PB",
  22597. "DOM_VK_XF86XK_MESSENGER",
  22598. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  22599. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  22600. "DOM_VK_XF86XK_MUSIC",
  22601. "DOM_VK_XF86XK_MY_COMPUTER",
  22602. "DOM_VK_XF86XK_MY_SITES",
  22603. "DOM_VK_XF86XK_NEW",
  22604. "DOM_VK_XF86XK_NEWS",
  22605. "DOM_VK_XF86XK_OFFICE_HOME",
  22606. "DOM_VK_XF86XK_OPEN",
  22607. "DOM_VK_XF86XK_OPEN_URL",
  22608. "DOM_VK_XF86XK_OPTION",
  22609. "DOM_VK_XF86XK_PASTE",
  22610. "DOM_VK_XF86XK_PHONE",
  22611. "DOM_VK_XF86XK_PICTURES",
  22612. "DOM_VK_XF86XK_POWER_DOWN",
  22613. "DOM_VK_XF86XK_POWER_OFF",
  22614. "DOM_VK_XF86XK_RED",
  22615. "DOM_VK_XF86XK_REFRESH",
  22616. "DOM_VK_XF86XK_RELOAD",
  22617. "DOM_VK_XF86XK_REPLY",
  22618. "DOM_VK_XF86XK_ROCKER_DOWN",
  22619. "DOM_VK_XF86XK_ROCKER_ENTER",
  22620. "DOM_VK_XF86XK_ROCKER_UP",
  22621. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  22622. "DOM_VK_XF86XK_ROTATION_KB",
  22623. "DOM_VK_XF86XK_ROTATION_PB",
  22624. "DOM_VK_XF86XK_SAVE",
  22625. "DOM_VK_XF86XK_SCREEN_SAVER",
  22626. "DOM_VK_XF86XK_SCROLL_CLICK",
  22627. "DOM_VK_XF86XK_SCROLL_DOWN",
  22628. "DOM_VK_XF86XK_SCROLL_UP",
  22629. "DOM_VK_XF86XK_SEARCH",
  22630. "DOM_VK_XF86XK_SEND",
  22631. "DOM_VK_XF86XK_SHOP",
  22632. "DOM_VK_XF86XK_SPELL",
  22633. "DOM_VK_XF86XK_SPLIT_SCREEN",
  22634. "DOM_VK_XF86XK_STANDBY",
  22635. "DOM_VK_XF86XK_START",
  22636. "DOM_VK_XF86XK_STOP",
  22637. "DOM_VK_XF86XK_SUBTITLE",
  22638. "DOM_VK_XF86XK_SUPPORT",
  22639. "DOM_VK_XF86XK_SUSPEND",
  22640. "DOM_VK_XF86XK_TASK_PANE",
  22641. "DOM_VK_XF86XK_TERMINAL",
  22642. "DOM_VK_XF86XK_TIME",
  22643. "DOM_VK_XF86XK_TOOLS",
  22644. "DOM_VK_XF86XK_TOP_MENU",
  22645. "DOM_VK_XF86XK_TO_DO_LIST",
  22646. "DOM_VK_XF86XK_TRAVEL",
  22647. "DOM_VK_XF86XK_USER1KB",
  22648. "DOM_VK_XF86XK_USER2KB",
  22649. "DOM_VK_XF86XK_USER_PB",
  22650. "DOM_VK_XF86XK_UWB",
  22651. "DOM_VK_XF86XK_VENDOR_HOME",
  22652. "DOM_VK_XF86XK_VIDEO",
  22653. "DOM_VK_XF86XK_VIEW",
  22654. "DOM_VK_XF86XK_WAKE_UP",
  22655. "DOM_VK_XF86XK_WEB_CAM",
  22656. "DOM_VK_XF86XK_WHEEL_BUTTON",
  22657. "DOM_VK_XF86XK_WLAN",
  22658. "DOM_VK_XF86XK_WORD",
  22659. "DOM_VK_XF86XK_WWW",
  22660. "DOM_VK_XF86XK_XFER",
  22661. "DOM_VK_XF86XK_YELLOW",
  22662. "DOM_VK_XF86XK_ZOOM_IN",
  22663. "DOM_VK_XF86XK_ZOOM_OUT",
  22664. "DOM_VK_Y",
  22665. "DOM_VK_Z",
  22666. "DOM_VK_ZOOM",
  22667. "DONE",
  22668. "DONT_CARE",
  22669. "DOWNLOADING",
  22670. "DRAGDROP",
  22671. "DRAW_BUFFER0",
  22672. "DRAW_BUFFER1",
  22673. "DRAW_BUFFER10",
  22674. "DRAW_BUFFER11",
  22675. "DRAW_BUFFER12",
  22676. "DRAW_BUFFER13",
  22677. "DRAW_BUFFER14",
  22678. "DRAW_BUFFER15",
  22679. "DRAW_BUFFER2",
  22680. "DRAW_BUFFER3",
  22681. "DRAW_BUFFER4",
  22682. "DRAW_BUFFER5",
  22683. "DRAW_BUFFER6",
  22684. "DRAW_BUFFER7",
  22685. "DRAW_BUFFER8",
  22686. "DRAW_BUFFER9",
  22687. "DRAW_FRAMEBUFFER",
  22688. "DRAW_FRAMEBUFFER_BINDING",
  22689. "DST_ALPHA",
  22690. "DST_COLOR",
  22691. "DYNAMIC_COPY",
  22692. "DYNAMIC_DRAW",
  22693. "DYNAMIC_READ",
  22694. "DataChannel",
  22695. "DataTransfer",
  22696. "DataTransferItem",
  22697. "DataTransferItemList",
  22698. "DataView",
  22699. "Date",
  22700. "DateTimeFormat",
  22701. "DecompressionStream",
  22702. "DelayNode",
  22703. "DeprecationReportBody",
  22704. "DesktopNotification",
  22705. "DesktopNotificationCenter",
  22706. "DeviceLightEvent",
  22707. "DeviceMotionEvent",
  22708. "DeviceMotionEventAcceleration",
  22709. "DeviceMotionEventRotationRate",
  22710. "DeviceOrientationEvent",
  22711. "DeviceProximityEvent",
  22712. "DeviceStorage",
  22713. "DeviceStorageChangeEvent",
  22714. "Directory",
  22715. "DisplayNames",
  22716. "Document",
  22717. "DocumentFragment",
  22718. "DocumentTimeline",
  22719. "DocumentType",
  22720. "DragEvent",
  22721. "DynamicsCompressorNode",
  22722. "E",
  22723. "ELEMENT_ARRAY_BUFFER",
  22724. "ELEMENT_ARRAY_BUFFER_BINDING",
  22725. "ELEMENT_NODE",
  22726. "EMPTY",
  22727. "ENCODING_ERR",
  22728. "ENDED",
  22729. "END_TO_END",
  22730. "END_TO_START",
  22731. "ENTITY_NODE",
  22732. "ENTITY_REFERENCE_NODE",
  22733. "EPSILON",
  22734. "EQUAL",
  22735. "EQUALPOWER",
  22736. "ERROR",
  22737. "EXPONENTIAL_DISTANCE",
  22738. "Element",
  22739. "ElementInternals",
  22740. "ElementQuery",
  22741. "EnterPictureInPictureEvent",
  22742. "Entity",
  22743. "EntityReference",
  22744. "Error",
  22745. "ErrorEvent",
  22746. "EvalError",
  22747. "Event",
  22748. "EventException",
  22749. "EventSource",
  22750. "EventTarget",
  22751. "External",
  22752. "FASTEST",
  22753. "FIDOSDK",
  22754. "FILTER_ACCEPT",
  22755. "FILTER_INTERRUPT",
  22756. "FILTER_REJECT",
  22757. "FILTER_SKIP",
  22758. "FINISHED_STATE",
  22759. "FIRST_ORDERED_NODE_TYPE",
  22760. "FLOAT",
  22761. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  22762. "FLOAT_MAT2",
  22763. "FLOAT_MAT2x3",
  22764. "FLOAT_MAT2x4",
  22765. "FLOAT_MAT3",
  22766. "FLOAT_MAT3x2",
  22767. "FLOAT_MAT3x4",
  22768. "FLOAT_MAT4",
  22769. "FLOAT_MAT4x2",
  22770. "FLOAT_MAT4x3",
  22771. "FLOAT_VEC2",
  22772. "FLOAT_VEC3",
  22773. "FLOAT_VEC4",
  22774. "FOCUS",
  22775. "FONT_FACE_RULE",
  22776. "FONT_FEATURE_VALUES_RULE",
  22777. "FRAGMENT_SHADER",
  22778. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  22779. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  22780. "FRAMEBUFFER",
  22781. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  22782. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  22783. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  22784. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  22785. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  22786. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  22787. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  22788. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  22789. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  22790. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  22791. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  22792. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  22793. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  22794. "FRAMEBUFFER_BINDING",
  22795. "FRAMEBUFFER_COMPLETE",
  22796. "FRAMEBUFFER_DEFAULT",
  22797. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  22798. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  22799. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  22800. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  22801. "FRAMEBUFFER_UNSUPPORTED",
  22802. "FRONT",
  22803. "FRONT_AND_BACK",
  22804. "FRONT_FACE",
  22805. "FUNC_ADD",
  22806. "FUNC_REVERSE_SUBTRACT",
  22807. "FUNC_SUBTRACT",
  22808. "FeaturePolicy",
  22809. "FeaturePolicyViolationReportBody",
  22810. "FederatedCredential",
  22811. "Feed",
  22812. "FeedEntry",
  22813. "File",
  22814. "FileError",
  22815. "FileList",
  22816. "FileReader",
  22817. "FileSystem",
  22818. "FileSystemDirectoryEntry",
  22819. "FileSystemDirectoryReader",
  22820. "FileSystemEntry",
  22821. "FileSystemFileEntry",
  22822. "FinalizationRegistry",
  22823. "FindInPage",
  22824. "Float32Array",
  22825. "Float64Array",
  22826. "FocusEvent",
  22827. "FontFace",
  22828. "FontFaceSet",
  22829. "FontFaceSetLoadEvent",
  22830. "FormData",
  22831. "FormDataEvent",
  22832. "FragmentDirective",
  22833. "Function",
  22834. "GENERATE_MIPMAP_HINT",
  22835. "GEQUAL",
  22836. "GREATER",
  22837. "GREEN_BITS",
  22838. "GainNode",
  22839. "Gamepad",
  22840. "GamepadAxisMoveEvent",
  22841. "GamepadButton",
  22842. "GamepadButtonEvent",
  22843. "GamepadEvent",
  22844. "GamepadHapticActuator",
  22845. "GamepadPose",
  22846. "Geolocation",
  22847. "GeolocationCoordinates",
  22848. "GeolocationPosition",
  22849. "GeolocationPositionError",
  22850. "GestureEvent",
  22851. "Global",
  22852. "Gyroscope",
  22853. "HALF_FLOAT",
  22854. "HAVE_CURRENT_DATA",
  22855. "HAVE_ENOUGH_DATA",
  22856. "HAVE_FUTURE_DATA",
  22857. "HAVE_METADATA",
  22858. "HAVE_NOTHING",
  22859. "HEADERS_RECEIVED",
  22860. "HIDDEN",
  22861. "HIERARCHY_REQUEST_ERR",
  22862. "HIGHPASS",
  22863. "HIGHSHELF",
  22864. "HIGH_FLOAT",
  22865. "HIGH_INT",
  22866. "HORIZONTAL",
  22867. "HORIZONTAL_AXIS",
  22868. "HRTF",
  22869. "HTMLAllCollection",
  22870. "HTMLAnchorElement",
  22871. "HTMLAppletElement",
  22872. "HTMLAreaElement",
  22873. "HTMLAudioElement",
  22874. "HTMLBRElement",
  22875. "HTMLBaseElement",
  22876. "HTMLBaseFontElement",
  22877. "HTMLBlockquoteElement",
  22878. "HTMLBodyElement",
  22879. "HTMLButtonElement",
  22880. "HTMLCanvasElement",
  22881. "HTMLCollection",
  22882. "HTMLCommandElement",
  22883. "HTMLContentElement",
  22884. "HTMLDListElement",
  22885. "HTMLDataElement",
  22886. "HTMLDataListElement",
  22887. "HTMLDetailsElement",
  22888. "HTMLDialogElement",
  22889. "HTMLDirectoryElement",
  22890. "HTMLDivElement",
  22891. "HTMLDocument",
  22892. "HTMLElement",
  22893. "HTMLEmbedElement",
  22894. "HTMLFieldSetElement",
  22895. "HTMLFontElement",
  22896. "HTMLFormControlsCollection",
  22897. "HTMLFormElement",
  22898. "HTMLFrameElement",
  22899. "HTMLFrameSetElement",
  22900. "HTMLHRElement",
  22901. "HTMLHeadElement",
  22902. "HTMLHeadingElement",
  22903. "HTMLHtmlElement",
  22904. "HTMLIFrameElement",
  22905. "HTMLImageElement",
  22906. "HTMLInputElement",
  22907. "HTMLIsIndexElement",
  22908. "HTMLKeygenElement",
  22909. "HTMLLIElement",
  22910. "HTMLLabelElement",
  22911. "HTMLLegendElement",
  22912. "HTMLLinkElement",
  22913. "HTMLMapElement",
  22914. "HTMLMarqueeElement",
  22915. "HTMLMediaElement",
  22916. "HTMLMenuElement",
  22917. "HTMLMenuItemElement",
  22918. "HTMLMetaElement",
  22919. "HTMLMeterElement",
  22920. "HTMLModElement",
  22921. "HTMLOListElement",
  22922. "HTMLObjectElement",
  22923. "HTMLOptGroupElement",
  22924. "HTMLOptionElement",
  22925. "HTMLOptionsCollection",
  22926. "HTMLOutputElement",
  22927. "HTMLParagraphElement",
  22928. "HTMLParamElement",
  22929. "HTMLPictureElement",
  22930. "HTMLPreElement",
  22931. "HTMLProgressElement",
  22932. "HTMLPropertiesCollection",
  22933. "HTMLQuoteElement",
  22934. "HTMLScriptElement",
  22935. "HTMLSelectElement",
  22936. "HTMLShadowElement",
  22937. "HTMLSlotElement",
  22938. "HTMLSourceElement",
  22939. "HTMLSpanElement",
  22940. "HTMLStyleElement",
  22941. "HTMLTableCaptionElement",
  22942. "HTMLTableCellElement",
  22943. "HTMLTableColElement",
  22944. "HTMLTableElement",
  22945. "HTMLTableRowElement",
  22946. "HTMLTableSectionElement",
  22947. "HTMLTemplateElement",
  22948. "HTMLTextAreaElement",
  22949. "HTMLTimeElement",
  22950. "HTMLTitleElement",
  22951. "HTMLTrackElement",
  22952. "HTMLUListElement",
  22953. "HTMLUnknownElement",
  22954. "HTMLVideoElement",
  22955. "HashChangeEvent",
  22956. "Headers",
  22957. "History",
  22958. "Hz",
  22959. "ICE_CHECKING",
  22960. "ICE_CLOSED",
  22961. "ICE_COMPLETED",
  22962. "ICE_CONNECTED",
  22963. "ICE_FAILED",
  22964. "ICE_GATHERING",
  22965. "ICE_WAITING",
  22966. "IDBCursor",
  22967. "IDBCursorWithValue",
  22968. "IDBDatabase",
  22969. "IDBDatabaseException",
  22970. "IDBFactory",
  22971. "IDBFileHandle",
  22972. "IDBFileRequest",
  22973. "IDBIndex",
  22974. "IDBKeyRange",
  22975. "IDBMutableFile",
  22976. "IDBObjectStore",
  22977. "IDBOpenDBRequest",
  22978. "IDBRequest",
  22979. "IDBTransaction",
  22980. "IDBVersionChangeEvent",
  22981. "IDLE",
  22982. "IIRFilterNode",
  22983. "IMPLEMENTATION_COLOR_READ_FORMAT",
  22984. "IMPLEMENTATION_COLOR_READ_TYPE",
  22985. "IMPORT_RULE",
  22986. "INCR",
  22987. "INCR_WRAP",
  22988. "INDEX_SIZE_ERR",
  22989. "INT",
  22990. "INTERLEAVED_ATTRIBS",
  22991. "INT_2_10_10_10_REV",
  22992. "INT_SAMPLER_2D",
  22993. "INT_SAMPLER_2D_ARRAY",
  22994. "INT_SAMPLER_3D",
  22995. "INT_SAMPLER_CUBE",
  22996. "INT_VEC2",
  22997. "INT_VEC3",
  22998. "INT_VEC4",
  22999. "INUSE_ATTRIBUTE_ERR",
  23000. "INVALID_ACCESS_ERR",
  23001. "INVALID_CHARACTER_ERR",
  23002. "INVALID_ENUM",
  23003. "INVALID_EXPRESSION_ERR",
  23004. "INVALID_FRAMEBUFFER_OPERATION",
  23005. "INVALID_INDEX",
  23006. "INVALID_MODIFICATION_ERR",
  23007. "INVALID_NODE_TYPE_ERR",
  23008. "INVALID_OPERATION",
  23009. "INVALID_STATE_ERR",
  23010. "INVALID_VALUE",
  23011. "INVERSE_DISTANCE",
  23012. "INVERT",
  23013. "IceCandidate",
  23014. "IdleDeadline",
  23015. "Image",
  23016. "ImageBitmap",
  23017. "ImageBitmapRenderingContext",
  23018. "ImageCapture",
  23019. "ImageData",
  23020. "Infinity",
  23021. "InputDeviceCapabilities",
  23022. "InputDeviceInfo",
  23023. "InputEvent",
  23024. "InputMethodContext",
  23025. "InstallTrigger",
  23026. "InstallTriggerImpl",
  23027. "Instance",
  23028. "Int16Array",
  23029. "Int32Array",
  23030. "Int8Array",
  23031. "Intent",
  23032. "InternalError",
  23033. "IntersectionObserver",
  23034. "IntersectionObserverEntry",
  23035. "Intl",
  23036. "IsSearchProviderInstalled",
  23037. "Iterator",
  23038. "JSON",
  23039. "KEEP",
  23040. "KEYDOWN",
  23041. "KEYFRAMES_RULE",
  23042. "KEYFRAME_RULE",
  23043. "KEYPRESS",
  23044. "KEYUP",
  23045. "KeyEvent",
  23046. "Keyboard",
  23047. "KeyboardEvent",
  23048. "KeyboardLayoutMap",
  23049. "KeyframeEffect",
  23050. "LENGTHADJUST_SPACING",
  23051. "LENGTHADJUST_SPACINGANDGLYPHS",
  23052. "LENGTHADJUST_UNKNOWN",
  23053. "LEQUAL",
  23054. "LESS",
  23055. "LINEAR",
  23056. "LINEAR_DISTANCE",
  23057. "LINEAR_MIPMAP_LINEAR",
  23058. "LINEAR_MIPMAP_NEAREST",
  23059. "LINES",
  23060. "LINE_LOOP",
  23061. "LINE_STRIP",
  23062. "LINE_WIDTH",
  23063. "LINK_STATUS",
  23064. "LIVE",
  23065. "LN10",
  23066. "LN2",
  23067. "LOADED",
  23068. "LOADING",
  23069. "LOG10E",
  23070. "LOG2E",
  23071. "LOWPASS",
  23072. "LOWSHELF",
  23073. "LOW_FLOAT",
  23074. "LOW_INT",
  23075. "LSException",
  23076. "LSParserFilter",
  23077. "LUMINANCE",
  23078. "LUMINANCE_ALPHA",
  23079. "LargestContentfulPaint",
  23080. "LayoutShift",
  23081. "LayoutShiftAttribution",
  23082. "LinearAccelerationSensor",
  23083. "LinkError",
  23084. "ListFormat",
  23085. "LocalMediaStream",
  23086. "Locale",
  23087. "Location",
  23088. "Lock",
  23089. "LockManager",
  23090. "MAX",
  23091. "MAX_3D_TEXTURE_SIZE",
  23092. "MAX_ARRAY_TEXTURE_LAYERS",
  23093. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  23094. "MAX_COLOR_ATTACHMENTS",
  23095. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  23096. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  23097. "MAX_COMBINED_UNIFORM_BLOCKS",
  23098. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  23099. "MAX_CUBE_MAP_TEXTURE_SIZE",
  23100. "MAX_DRAW_BUFFERS",
  23101. "MAX_ELEMENTS_INDICES",
  23102. "MAX_ELEMENTS_VERTICES",
  23103. "MAX_ELEMENT_INDEX",
  23104. "MAX_FRAGMENT_INPUT_COMPONENTS",
  23105. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  23106. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  23107. "MAX_FRAGMENT_UNIFORM_VECTORS",
  23108. "MAX_PROGRAM_TEXEL_OFFSET",
  23109. "MAX_RENDERBUFFER_SIZE",
  23110. "MAX_SAFE_INTEGER",
  23111. "MAX_SAMPLES",
  23112. "MAX_SERVER_WAIT_TIMEOUT",
  23113. "MAX_TEXTURE_IMAGE_UNITS",
  23114. "MAX_TEXTURE_LOD_BIAS",
  23115. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  23116. "MAX_TEXTURE_SIZE",
  23117. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  23118. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  23119. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  23120. "MAX_UNIFORM_BLOCK_SIZE",
  23121. "MAX_UNIFORM_BUFFER_BINDINGS",
  23122. "MAX_VALUE",
  23123. "MAX_VARYING_COMPONENTS",
  23124. "MAX_VARYING_VECTORS",
  23125. "MAX_VERTEX_ATTRIBS",
  23126. "MAX_VERTEX_OUTPUT_COMPONENTS",
  23127. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  23128. "MAX_VERTEX_UNIFORM_BLOCKS",
  23129. "MAX_VERTEX_UNIFORM_COMPONENTS",
  23130. "MAX_VERTEX_UNIFORM_VECTORS",
  23131. "MAX_VIEWPORT_DIMS",
  23132. "MEDIA_ERR_ABORTED",
  23133. "MEDIA_ERR_DECODE",
  23134. "MEDIA_ERR_ENCRYPTED",
  23135. "MEDIA_ERR_NETWORK",
  23136. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  23137. "MEDIA_KEYERR_CLIENT",
  23138. "MEDIA_KEYERR_DOMAIN",
  23139. "MEDIA_KEYERR_HARDWARECHANGE",
  23140. "MEDIA_KEYERR_OUTPUT",
  23141. "MEDIA_KEYERR_SERVICE",
  23142. "MEDIA_KEYERR_UNKNOWN",
  23143. "MEDIA_RULE",
  23144. "MEDIUM_FLOAT",
  23145. "MEDIUM_INT",
  23146. "META_MASK",
  23147. "MIDIAccess",
  23148. "MIDIConnectionEvent",
  23149. "MIDIInput",
  23150. "MIDIInputMap",
  23151. "MIDIMessageEvent",
  23152. "MIDIOutput",
  23153. "MIDIOutputMap",
  23154. "MIDIPort",
  23155. "MIN",
  23156. "MIN_PROGRAM_TEXEL_OFFSET",
  23157. "MIN_SAFE_INTEGER",
  23158. "MIN_VALUE",
  23159. "MIRRORED_REPEAT",
  23160. "MODE_ASYNCHRONOUS",
  23161. "MODE_SYNCHRONOUS",
  23162. "MODIFICATION",
  23163. "MOUSEDOWN",
  23164. "MOUSEDRAG",
  23165. "MOUSEMOVE",
  23166. "MOUSEOUT",
  23167. "MOUSEOVER",
  23168. "MOUSEUP",
  23169. "MOZ_KEYFRAMES_RULE",
  23170. "MOZ_KEYFRAME_RULE",
  23171. "MOZ_SOURCE_CURSOR",
  23172. "MOZ_SOURCE_ERASER",
  23173. "MOZ_SOURCE_KEYBOARD",
  23174. "MOZ_SOURCE_MOUSE",
  23175. "MOZ_SOURCE_PEN",
  23176. "MOZ_SOURCE_TOUCH",
  23177. "MOZ_SOURCE_UNKNOWN",
  23178. "MSGESTURE_FLAG_BEGIN",
  23179. "MSGESTURE_FLAG_CANCEL",
  23180. "MSGESTURE_FLAG_END",
  23181. "MSGESTURE_FLAG_INERTIA",
  23182. "MSGESTURE_FLAG_NONE",
  23183. "MSPOINTER_TYPE_MOUSE",
  23184. "MSPOINTER_TYPE_PEN",
  23185. "MSPOINTER_TYPE_TOUCH",
  23186. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  23187. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  23188. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  23189. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  23190. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  23191. "MS_ASYNC_OP_STATUS_CANCELED",
  23192. "MS_ASYNC_OP_STATUS_ERROR",
  23193. "MS_ASYNC_OP_STATUS_SUCCESS",
  23194. "MS_MANIPULATION_STATE_ACTIVE",
  23195. "MS_MANIPULATION_STATE_CANCELLED",
  23196. "MS_MANIPULATION_STATE_COMMITTED",
  23197. "MS_MANIPULATION_STATE_DRAGGING",
  23198. "MS_MANIPULATION_STATE_INERTIA",
  23199. "MS_MANIPULATION_STATE_PRESELECT",
  23200. "MS_MANIPULATION_STATE_SELECTING",
  23201. "MS_MANIPULATION_STATE_STOPPED",
  23202. "MS_MEDIA_ERR_ENCRYPTED",
  23203. "MS_MEDIA_KEYERR_CLIENT",
  23204. "MS_MEDIA_KEYERR_DOMAIN",
  23205. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  23206. "MS_MEDIA_KEYERR_OUTPUT",
  23207. "MS_MEDIA_KEYERR_SERVICE",
  23208. "MS_MEDIA_KEYERR_UNKNOWN",
  23209. "Map",
  23210. "Math",
  23211. "MathMLElement",
  23212. "MediaCapabilities",
  23213. "MediaCapabilitiesInfo",
  23214. "MediaController",
  23215. "MediaDeviceInfo",
  23216. "MediaDevices",
  23217. "MediaElementAudioSourceNode",
  23218. "MediaEncryptedEvent",
  23219. "MediaError",
  23220. "MediaKeyError",
  23221. "MediaKeyEvent",
  23222. "MediaKeyMessageEvent",
  23223. "MediaKeyNeededEvent",
  23224. "MediaKeySession",
  23225. "MediaKeyStatusMap",
  23226. "MediaKeySystemAccess",
  23227. "MediaKeys",
  23228. "MediaList",
  23229. "MediaMetadata",
  23230. "MediaQueryList",
  23231. "MediaQueryListEvent",
  23232. "MediaRecorder",
  23233. "MediaRecorderErrorEvent",
  23234. "MediaSession",
  23235. "MediaSettingsRange",
  23236. "MediaSource",
  23237. "MediaStream",
  23238. "MediaStreamAudioDestinationNode",
  23239. "MediaStreamAudioSourceNode",
  23240. "MediaStreamEvent",
  23241. "MediaStreamTrack",
  23242. "MediaStreamTrackAudioSourceNode",
  23243. "MediaStreamTrackEvent",
  23244. "Memory",
  23245. "MessageChannel",
  23246. "MessageEvent",
  23247. "MessagePort",
  23248. "Methods",
  23249. "MimeType",
  23250. "MimeTypeArray",
  23251. "Module",
  23252. "MouseEvent",
  23253. "MouseScrollEvent",
  23254. "MozAnimation",
  23255. "MozAnimationDelay",
  23256. "MozAnimationDirection",
  23257. "MozAnimationDuration",
  23258. "MozAnimationFillMode",
  23259. "MozAnimationIterationCount",
  23260. "MozAnimationName",
  23261. "MozAnimationPlayState",
  23262. "MozAnimationTimingFunction",
  23263. "MozAppearance",
  23264. "MozBackfaceVisibility",
  23265. "MozBinding",
  23266. "MozBorderBottomColors",
  23267. "MozBorderEnd",
  23268. "MozBorderEndColor",
  23269. "MozBorderEndStyle",
  23270. "MozBorderEndWidth",
  23271. "MozBorderImage",
  23272. "MozBorderLeftColors",
  23273. "MozBorderRightColors",
  23274. "MozBorderStart",
  23275. "MozBorderStartColor",
  23276. "MozBorderStartStyle",
  23277. "MozBorderStartWidth",
  23278. "MozBorderTopColors",
  23279. "MozBoxAlign",
  23280. "MozBoxDirection",
  23281. "MozBoxFlex",
  23282. "MozBoxOrdinalGroup",
  23283. "MozBoxOrient",
  23284. "MozBoxPack",
  23285. "MozBoxSizing",
  23286. "MozCSSKeyframeRule",
  23287. "MozCSSKeyframesRule",
  23288. "MozColumnCount",
  23289. "MozColumnFill",
  23290. "MozColumnGap",
  23291. "MozColumnRule",
  23292. "MozColumnRuleColor",
  23293. "MozColumnRuleStyle",
  23294. "MozColumnRuleWidth",
  23295. "MozColumnWidth",
  23296. "MozColumns",
  23297. "MozContactChangeEvent",
  23298. "MozFloatEdge",
  23299. "MozFontFeatureSettings",
  23300. "MozFontLanguageOverride",
  23301. "MozForceBrokenImageIcon",
  23302. "MozHyphens",
  23303. "MozImageRegion",
  23304. "MozMarginEnd",
  23305. "MozMarginStart",
  23306. "MozMmsEvent",
  23307. "MozMmsMessage",
  23308. "MozMobileMessageThread",
  23309. "MozOSXFontSmoothing",
  23310. "MozOrient",
  23311. "MozOsxFontSmoothing",
  23312. "MozOutlineRadius",
  23313. "MozOutlineRadiusBottomleft",
  23314. "MozOutlineRadiusBottomright",
  23315. "MozOutlineRadiusTopleft",
  23316. "MozOutlineRadiusTopright",
  23317. "MozPaddingEnd",
  23318. "MozPaddingStart",
  23319. "MozPerspective",
  23320. "MozPerspectiveOrigin",
  23321. "MozPowerManager",
  23322. "MozSettingsEvent",
  23323. "MozSmsEvent",
  23324. "MozSmsMessage",
  23325. "MozStackSizing",
  23326. "MozTabSize",
  23327. "MozTextAlignLast",
  23328. "MozTextDecorationColor",
  23329. "MozTextDecorationLine",
  23330. "MozTextDecorationStyle",
  23331. "MozTextSizeAdjust",
  23332. "MozTransform",
  23333. "MozTransformOrigin",
  23334. "MozTransformStyle",
  23335. "MozTransition",
  23336. "MozTransitionDelay",
  23337. "MozTransitionDuration",
  23338. "MozTransitionProperty",
  23339. "MozTransitionTimingFunction",
  23340. "MozUserFocus",
  23341. "MozUserInput",
  23342. "MozUserModify",
  23343. "MozUserSelect",
  23344. "MozWindowDragging",
  23345. "MozWindowShadow",
  23346. "MutationEvent",
  23347. "MutationObserver",
  23348. "MutationRecord",
  23349. "NAMESPACE_ERR",
  23350. "NAMESPACE_RULE",
  23351. "NEAREST",
  23352. "NEAREST_MIPMAP_LINEAR",
  23353. "NEAREST_MIPMAP_NEAREST",
  23354. "NEGATIVE_INFINITY",
  23355. "NETWORK_EMPTY",
  23356. "NETWORK_ERR",
  23357. "NETWORK_IDLE",
  23358. "NETWORK_LOADED",
  23359. "NETWORK_LOADING",
  23360. "NETWORK_NO_SOURCE",
  23361. "NEVER",
  23362. "NEW",
  23363. "NEXT",
  23364. "NEXT_NO_DUPLICATE",
  23365. "NICEST",
  23366. "NODE_AFTER",
  23367. "NODE_BEFORE",
  23368. "NODE_BEFORE_AND_AFTER",
  23369. "NODE_INSIDE",
  23370. "NONE",
  23371. "NON_TRANSIENT_ERR",
  23372. "NOTATION_NODE",
  23373. "NOTCH",
  23374. "NOTEQUAL",
  23375. "NOT_ALLOWED_ERR",
  23376. "NOT_FOUND_ERR",
  23377. "NOT_READABLE_ERR",
  23378. "NOT_SUPPORTED_ERR",
  23379. "NO_DATA_ALLOWED_ERR",
  23380. "NO_ERR",
  23381. "NO_ERROR",
  23382. "NO_MODIFICATION_ALLOWED_ERR",
  23383. "NUMBER_TYPE",
  23384. "NUM_COMPRESSED_TEXTURE_FORMATS",
  23385. "NaN",
  23386. "NamedNodeMap",
  23387. "NavigationPreloadManager",
  23388. "Navigator",
  23389. "NearbyLinks",
  23390. "NetworkInformation",
  23391. "Node",
  23392. "NodeFilter",
  23393. "NodeIterator",
  23394. "NodeList",
  23395. "Notation",
  23396. "Notification",
  23397. "NotifyPaintEvent",
  23398. "Number",
  23399. "NumberFormat",
  23400. "OBJECT_TYPE",
  23401. "OBSOLETE",
  23402. "OK",
  23403. "ONE",
  23404. "ONE_MINUS_CONSTANT_ALPHA",
  23405. "ONE_MINUS_CONSTANT_COLOR",
  23406. "ONE_MINUS_DST_ALPHA",
  23407. "ONE_MINUS_DST_COLOR",
  23408. "ONE_MINUS_SRC_ALPHA",
  23409. "ONE_MINUS_SRC_COLOR",
  23410. "OPEN",
  23411. "OPENED",
  23412. "OPENING",
  23413. "ORDERED_NODE_ITERATOR_TYPE",
  23414. "ORDERED_NODE_SNAPSHOT_TYPE",
  23415. "OTHER_ERROR",
  23416. "OUT_OF_MEMORY",
  23417. "Object",
  23418. "OfflineAudioCompletionEvent",
  23419. "OfflineAudioContext",
  23420. "OfflineResourceList",
  23421. "OffscreenCanvas",
  23422. "OffscreenCanvasRenderingContext2D",
  23423. "Option",
  23424. "OrientationSensor",
  23425. "OscillatorNode",
  23426. "OverconstrainedError",
  23427. "OverflowEvent",
  23428. "PACK_ALIGNMENT",
  23429. "PACK_ROW_LENGTH",
  23430. "PACK_SKIP_PIXELS",
  23431. "PACK_SKIP_ROWS",
  23432. "PAGE_RULE",
  23433. "PARSE_ERR",
  23434. "PATHSEG_ARC_ABS",
  23435. "PATHSEG_ARC_REL",
  23436. "PATHSEG_CLOSEPATH",
  23437. "PATHSEG_CURVETO_CUBIC_ABS",
  23438. "PATHSEG_CURVETO_CUBIC_REL",
  23439. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  23440. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  23441. "PATHSEG_CURVETO_QUADRATIC_ABS",
  23442. "PATHSEG_CURVETO_QUADRATIC_REL",
  23443. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  23444. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  23445. "PATHSEG_LINETO_ABS",
  23446. "PATHSEG_LINETO_HORIZONTAL_ABS",
  23447. "PATHSEG_LINETO_HORIZONTAL_REL",
  23448. "PATHSEG_LINETO_REL",
  23449. "PATHSEG_LINETO_VERTICAL_ABS",
  23450. "PATHSEG_LINETO_VERTICAL_REL",
  23451. "PATHSEG_MOVETO_ABS",
  23452. "PATHSEG_MOVETO_REL",
  23453. "PATHSEG_UNKNOWN",
  23454. "PATH_EXISTS_ERR",
  23455. "PEAKING",
  23456. "PERMISSION_DENIED",
  23457. "PERSISTENT",
  23458. "PI",
  23459. "PIXEL_PACK_BUFFER",
  23460. "PIXEL_PACK_BUFFER_BINDING",
  23461. "PIXEL_UNPACK_BUFFER",
  23462. "PIXEL_UNPACK_BUFFER_BINDING",
  23463. "PLAYING_STATE",
  23464. "POINTS",
  23465. "POLYGON_OFFSET_FACTOR",
  23466. "POLYGON_OFFSET_FILL",
  23467. "POLYGON_OFFSET_UNITS",
  23468. "POSITION_UNAVAILABLE",
  23469. "POSITIVE_INFINITY",
  23470. "PREV",
  23471. "PREV_NO_DUPLICATE",
  23472. "PROCESSING_INSTRUCTION_NODE",
  23473. "PageChangeEvent",
  23474. "PageTransitionEvent",
  23475. "PaintRequest",
  23476. "PaintRequestList",
  23477. "PannerNode",
  23478. "PasswordCredential",
  23479. "Path2D",
  23480. "PaymentAddress",
  23481. "PaymentInstruments",
  23482. "PaymentManager",
  23483. "PaymentMethodChangeEvent",
  23484. "PaymentRequest",
  23485. "PaymentRequestUpdateEvent",
  23486. "PaymentResponse",
  23487. "Performance",
  23488. "PerformanceElementTiming",
  23489. "PerformanceEntry",
  23490. "PerformanceEventTiming",
  23491. "PerformanceLongTaskTiming",
  23492. "PerformanceMark",
  23493. "PerformanceMeasure",
  23494. "PerformanceNavigation",
  23495. "PerformanceNavigationTiming",
  23496. "PerformanceObserver",
  23497. "PerformanceObserverEntryList",
  23498. "PerformancePaintTiming",
  23499. "PerformanceResourceTiming",
  23500. "PerformanceServerTiming",
  23501. "PerformanceTiming",
  23502. "PeriodicSyncManager",
  23503. "PeriodicWave",
  23504. "PermissionStatus",
  23505. "Permissions",
  23506. "PhotoCapabilities",
  23507. "PictureInPictureWindow",
  23508. "Plugin",
  23509. "PluginArray",
  23510. "PluralRules",
  23511. "PointerEvent",
  23512. "PopStateEvent",
  23513. "PopupBlockedEvent",
  23514. "Presentation",
  23515. "PresentationAvailability",
  23516. "PresentationConnection",
  23517. "PresentationConnectionAvailableEvent",
  23518. "PresentationConnectionCloseEvent",
  23519. "PresentationConnectionList",
  23520. "PresentationReceiver",
  23521. "PresentationRequest",
  23522. "ProcessingInstruction",
  23523. "ProgressEvent",
  23524. "Promise",
  23525. "PromiseRejectionEvent",
  23526. "PropertyNodeList",
  23527. "Proxy",
  23528. "PublicKeyCredential",
  23529. "PushManager",
  23530. "PushSubscription",
  23531. "PushSubscriptionOptions",
  23532. "Q",
  23533. "QUERY_RESULT",
  23534. "QUERY_RESULT_AVAILABLE",
  23535. "QUOTA_ERR",
  23536. "QUOTA_EXCEEDED_ERR",
  23537. "QueryInterface",
  23538. "R11F_G11F_B10F",
  23539. "R16F",
  23540. "R16I",
  23541. "R16UI",
  23542. "R32F",
  23543. "R32I",
  23544. "R32UI",
  23545. "R8",
  23546. "R8I",
  23547. "R8UI",
  23548. "R8_SNORM",
  23549. "RASTERIZER_DISCARD",
  23550. "READ_BUFFER",
  23551. "READ_FRAMEBUFFER",
  23552. "READ_FRAMEBUFFER_BINDING",
  23553. "READ_ONLY",
  23554. "READ_ONLY_ERR",
  23555. "READ_WRITE",
  23556. "RED",
  23557. "RED_BITS",
  23558. "RED_INTEGER",
  23559. "REMOVAL",
  23560. "RENDERBUFFER",
  23561. "RENDERBUFFER_ALPHA_SIZE",
  23562. "RENDERBUFFER_BINDING",
  23563. "RENDERBUFFER_BLUE_SIZE",
  23564. "RENDERBUFFER_DEPTH_SIZE",
  23565. "RENDERBUFFER_GREEN_SIZE",
  23566. "RENDERBUFFER_HEIGHT",
  23567. "RENDERBUFFER_INTERNAL_FORMAT",
  23568. "RENDERBUFFER_RED_SIZE",
  23569. "RENDERBUFFER_SAMPLES",
  23570. "RENDERBUFFER_STENCIL_SIZE",
  23571. "RENDERBUFFER_WIDTH",
  23572. "RENDERER",
  23573. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  23574. "RENDERING_INTENT_AUTO",
  23575. "RENDERING_INTENT_PERCEPTUAL",
  23576. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  23577. "RENDERING_INTENT_SATURATION",
  23578. "RENDERING_INTENT_UNKNOWN",
  23579. "REPEAT",
  23580. "REPLACE",
  23581. "RG",
  23582. "RG16F",
  23583. "RG16I",
  23584. "RG16UI",
  23585. "RG32F",
  23586. "RG32I",
  23587. "RG32UI",
  23588. "RG8",
  23589. "RG8I",
  23590. "RG8UI",
  23591. "RG8_SNORM",
  23592. "RGB",
  23593. "RGB10_A2",
  23594. "RGB10_A2UI",
  23595. "RGB16F",
  23596. "RGB16I",
  23597. "RGB16UI",
  23598. "RGB32F",
  23599. "RGB32I",
  23600. "RGB32UI",
  23601. "RGB565",
  23602. "RGB5_A1",
  23603. "RGB8",
  23604. "RGB8I",
  23605. "RGB8UI",
  23606. "RGB8_SNORM",
  23607. "RGB9_E5",
  23608. "RGBA",
  23609. "RGBA16F",
  23610. "RGBA16I",
  23611. "RGBA16UI",
  23612. "RGBA32F",
  23613. "RGBA32I",
  23614. "RGBA32UI",
  23615. "RGBA4",
  23616. "RGBA8",
  23617. "RGBA8I",
  23618. "RGBA8UI",
  23619. "RGBA8_SNORM",
  23620. "RGBA_INTEGER",
  23621. "RGBColor",
  23622. "RGB_INTEGER",
  23623. "RG_INTEGER",
  23624. "ROTATION_CLOCKWISE",
  23625. "ROTATION_COUNTERCLOCKWISE",
  23626. "RTCCertificate",
  23627. "RTCDTMFSender",
  23628. "RTCDTMFToneChangeEvent",
  23629. "RTCDataChannel",
  23630. "RTCDataChannelEvent",
  23631. "RTCDtlsTransport",
  23632. "RTCError",
  23633. "RTCErrorEvent",
  23634. "RTCIceCandidate",
  23635. "RTCIceTransport",
  23636. "RTCPeerConnection",
  23637. "RTCPeerConnectionIceErrorEvent",
  23638. "RTCPeerConnectionIceEvent",
  23639. "RTCRtpReceiver",
  23640. "RTCRtpSender",
  23641. "RTCRtpTransceiver",
  23642. "RTCSctpTransport",
  23643. "RTCSessionDescription",
  23644. "RTCStatsReport",
  23645. "RTCTrackEvent",
  23646. "RadioNodeList",
  23647. "Range",
  23648. "RangeError",
  23649. "RangeException",
  23650. "ReadableStream",
  23651. "ReadableStreamDefaultReader",
  23652. "RecordErrorEvent",
  23653. "Rect",
  23654. "ReferenceError",
  23655. "Reflect",
  23656. "RegExp",
  23657. "RelativeOrientationSensor",
  23658. "RelativeTimeFormat",
  23659. "RemotePlayback",
  23660. "Report",
  23661. "ReportBody",
  23662. "ReportingObserver",
  23663. "Request",
  23664. "ResizeObserver",
  23665. "ResizeObserverEntry",
  23666. "ResizeObserverSize",
  23667. "Response",
  23668. "RuntimeError",
  23669. "SAMPLER_2D",
  23670. "SAMPLER_2D_ARRAY",
  23671. "SAMPLER_2D_ARRAY_SHADOW",
  23672. "SAMPLER_2D_SHADOW",
  23673. "SAMPLER_3D",
  23674. "SAMPLER_BINDING",
  23675. "SAMPLER_CUBE",
  23676. "SAMPLER_CUBE_SHADOW",
  23677. "SAMPLES",
  23678. "SAMPLE_ALPHA_TO_COVERAGE",
  23679. "SAMPLE_BUFFERS",
  23680. "SAMPLE_COVERAGE",
  23681. "SAMPLE_COVERAGE_INVERT",
  23682. "SAMPLE_COVERAGE_VALUE",
  23683. "SAWTOOTH",
  23684. "SCHEDULED_STATE",
  23685. "SCISSOR_BOX",
  23686. "SCISSOR_TEST",
  23687. "SCROLL_PAGE_DOWN",
  23688. "SCROLL_PAGE_UP",
  23689. "SDP_ANSWER",
  23690. "SDP_OFFER",
  23691. "SDP_PRANSWER",
  23692. "SECURITY_ERR",
  23693. "SELECT",
  23694. "SEPARATE_ATTRIBS",
  23695. "SERIALIZE_ERR",
  23696. "SEVERITY_ERROR",
  23697. "SEVERITY_FATAL_ERROR",
  23698. "SEVERITY_WARNING",
  23699. "SHADER_COMPILER",
  23700. "SHADER_TYPE",
  23701. "SHADING_LANGUAGE_VERSION",
  23702. "SHIFT_MASK",
  23703. "SHORT",
  23704. "SHOWING",
  23705. "SHOW_ALL",
  23706. "SHOW_ATTRIBUTE",
  23707. "SHOW_CDATA_SECTION",
  23708. "SHOW_COMMENT",
  23709. "SHOW_DOCUMENT",
  23710. "SHOW_DOCUMENT_FRAGMENT",
  23711. "SHOW_DOCUMENT_TYPE",
  23712. "SHOW_ELEMENT",
  23713. "SHOW_ENTITY",
  23714. "SHOW_ENTITY_REFERENCE",
  23715. "SHOW_NOTATION",
  23716. "SHOW_PROCESSING_INSTRUCTION",
  23717. "SHOW_TEXT",
  23718. "SIGNALED",
  23719. "SIGNED_NORMALIZED",
  23720. "SINE",
  23721. "SOUNDFIELD",
  23722. "SQLException",
  23723. "SQRT1_2",
  23724. "SQRT2",
  23725. "SQUARE",
  23726. "SRC_ALPHA",
  23727. "SRC_ALPHA_SATURATE",
  23728. "SRC_COLOR",
  23729. "SRGB",
  23730. "SRGB8",
  23731. "SRGB8_ALPHA8",
  23732. "START_TO_END",
  23733. "START_TO_START",
  23734. "STATIC_COPY",
  23735. "STATIC_DRAW",
  23736. "STATIC_READ",
  23737. "STENCIL",
  23738. "STENCIL_ATTACHMENT",
  23739. "STENCIL_BACK_FAIL",
  23740. "STENCIL_BACK_FUNC",
  23741. "STENCIL_BACK_PASS_DEPTH_FAIL",
  23742. "STENCIL_BACK_PASS_DEPTH_PASS",
  23743. "STENCIL_BACK_REF",
  23744. "STENCIL_BACK_VALUE_MASK",
  23745. "STENCIL_BACK_WRITEMASK",
  23746. "STENCIL_BITS",
  23747. "STENCIL_BUFFER_BIT",
  23748. "STENCIL_CLEAR_VALUE",
  23749. "STENCIL_FAIL",
  23750. "STENCIL_FUNC",
  23751. "STENCIL_INDEX",
  23752. "STENCIL_INDEX8",
  23753. "STENCIL_PASS_DEPTH_FAIL",
  23754. "STENCIL_PASS_DEPTH_PASS",
  23755. "STENCIL_REF",
  23756. "STENCIL_TEST",
  23757. "STENCIL_VALUE_MASK",
  23758. "STENCIL_WRITEMASK",
  23759. "STREAM_COPY",
  23760. "STREAM_DRAW",
  23761. "STREAM_READ",
  23762. "STRING_TYPE",
  23763. "STYLE_RULE",
  23764. "SUBPIXEL_BITS",
  23765. "SUPPORTS_RULE",
  23766. "SVGAElement",
  23767. "SVGAltGlyphDefElement",
  23768. "SVGAltGlyphElement",
  23769. "SVGAltGlyphItemElement",
  23770. "SVGAngle",
  23771. "SVGAnimateColorElement",
  23772. "SVGAnimateElement",
  23773. "SVGAnimateMotionElement",
  23774. "SVGAnimateTransformElement",
  23775. "SVGAnimatedAngle",
  23776. "SVGAnimatedBoolean",
  23777. "SVGAnimatedEnumeration",
  23778. "SVGAnimatedInteger",
  23779. "SVGAnimatedLength",
  23780. "SVGAnimatedLengthList",
  23781. "SVGAnimatedNumber",
  23782. "SVGAnimatedNumberList",
  23783. "SVGAnimatedPreserveAspectRatio",
  23784. "SVGAnimatedRect",
  23785. "SVGAnimatedString",
  23786. "SVGAnimatedTransformList",
  23787. "SVGAnimationElement",
  23788. "SVGCircleElement",
  23789. "SVGClipPathElement",
  23790. "SVGColor",
  23791. "SVGComponentTransferFunctionElement",
  23792. "SVGCursorElement",
  23793. "SVGDefsElement",
  23794. "SVGDescElement",
  23795. "SVGDiscardElement",
  23796. "SVGDocument",
  23797. "SVGElement",
  23798. "SVGElementInstance",
  23799. "SVGElementInstanceList",
  23800. "SVGEllipseElement",
  23801. "SVGException",
  23802. "SVGFEBlendElement",
  23803. "SVGFEColorMatrixElement",
  23804. "SVGFEComponentTransferElement",
  23805. "SVGFECompositeElement",
  23806. "SVGFEConvolveMatrixElement",
  23807. "SVGFEDiffuseLightingElement",
  23808. "SVGFEDisplacementMapElement",
  23809. "SVGFEDistantLightElement",
  23810. "SVGFEDropShadowElement",
  23811. "SVGFEFloodElement",
  23812. "SVGFEFuncAElement",
  23813. "SVGFEFuncBElement",
  23814. "SVGFEFuncGElement",
  23815. "SVGFEFuncRElement",
  23816. "SVGFEGaussianBlurElement",
  23817. "SVGFEImageElement",
  23818. "SVGFEMergeElement",
  23819. "SVGFEMergeNodeElement",
  23820. "SVGFEMorphologyElement",
  23821. "SVGFEOffsetElement",
  23822. "SVGFEPointLightElement",
  23823. "SVGFESpecularLightingElement",
  23824. "SVGFESpotLightElement",
  23825. "SVGFETileElement",
  23826. "SVGFETurbulenceElement",
  23827. "SVGFilterElement",
  23828. "SVGFontElement",
  23829. "SVGFontFaceElement",
  23830. "SVGFontFaceFormatElement",
  23831. "SVGFontFaceNameElement",
  23832. "SVGFontFaceSrcElement",
  23833. "SVGFontFaceUriElement",
  23834. "SVGForeignObjectElement",
  23835. "SVGGElement",
  23836. "SVGGeometryElement",
  23837. "SVGGlyphElement",
  23838. "SVGGlyphRefElement",
  23839. "SVGGradientElement",
  23840. "SVGGraphicsElement",
  23841. "SVGHKernElement",
  23842. "SVGImageElement",
  23843. "SVGLength",
  23844. "SVGLengthList",
  23845. "SVGLineElement",
  23846. "SVGLinearGradientElement",
  23847. "SVGMPathElement",
  23848. "SVGMarkerElement",
  23849. "SVGMaskElement",
  23850. "SVGMatrix",
  23851. "SVGMetadataElement",
  23852. "SVGMissingGlyphElement",
  23853. "SVGNumber",
  23854. "SVGNumberList",
  23855. "SVGPaint",
  23856. "SVGPathElement",
  23857. "SVGPathSeg",
  23858. "SVGPathSegArcAbs",
  23859. "SVGPathSegArcRel",
  23860. "SVGPathSegClosePath",
  23861. "SVGPathSegCurvetoCubicAbs",
  23862. "SVGPathSegCurvetoCubicRel",
  23863. "SVGPathSegCurvetoCubicSmoothAbs",
  23864. "SVGPathSegCurvetoCubicSmoothRel",
  23865. "SVGPathSegCurvetoQuadraticAbs",
  23866. "SVGPathSegCurvetoQuadraticRel",
  23867. "SVGPathSegCurvetoQuadraticSmoothAbs",
  23868. "SVGPathSegCurvetoQuadraticSmoothRel",
  23869. "SVGPathSegLinetoAbs",
  23870. "SVGPathSegLinetoHorizontalAbs",
  23871. "SVGPathSegLinetoHorizontalRel",
  23872. "SVGPathSegLinetoRel",
  23873. "SVGPathSegLinetoVerticalAbs",
  23874. "SVGPathSegLinetoVerticalRel",
  23875. "SVGPathSegList",
  23876. "SVGPathSegMovetoAbs",
  23877. "SVGPathSegMovetoRel",
  23878. "SVGPatternElement",
  23879. "SVGPoint",
  23880. "SVGPointList",
  23881. "SVGPolygonElement",
  23882. "SVGPolylineElement",
  23883. "SVGPreserveAspectRatio",
  23884. "SVGRadialGradientElement",
  23885. "SVGRect",
  23886. "SVGRectElement",
  23887. "SVGRenderingIntent",
  23888. "SVGSVGElement",
  23889. "SVGScriptElement",
  23890. "SVGSetElement",
  23891. "SVGStopElement",
  23892. "SVGStringList",
  23893. "SVGStyleElement",
  23894. "SVGSwitchElement",
  23895. "SVGSymbolElement",
  23896. "SVGTRefElement",
  23897. "SVGTSpanElement",
  23898. "SVGTextContentElement",
  23899. "SVGTextElement",
  23900. "SVGTextPathElement",
  23901. "SVGTextPositioningElement",
  23902. "SVGTitleElement",
  23903. "SVGTransform",
  23904. "SVGTransformList",
  23905. "SVGUnitTypes",
  23906. "SVGUseElement",
  23907. "SVGVKernElement",
  23908. "SVGViewElement",
  23909. "SVGViewSpec",
  23910. "SVGZoomAndPan",
  23911. "SVGZoomEvent",
  23912. "SVG_ANGLETYPE_DEG",
  23913. "SVG_ANGLETYPE_GRAD",
  23914. "SVG_ANGLETYPE_RAD",
  23915. "SVG_ANGLETYPE_UNKNOWN",
  23916. "SVG_ANGLETYPE_UNSPECIFIED",
  23917. "SVG_CHANNEL_A",
  23918. "SVG_CHANNEL_B",
  23919. "SVG_CHANNEL_G",
  23920. "SVG_CHANNEL_R",
  23921. "SVG_CHANNEL_UNKNOWN",
  23922. "SVG_COLORTYPE_CURRENTCOLOR",
  23923. "SVG_COLORTYPE_RGBCOLOR",
  23924. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  23925. "SVG_COLORTYPE_UNKNOWN",
  23926. "SVG_EDGEMODE_DUPLICATE",
  23927. "SVG_EDGEMODE_NONE",
  23928. "SVG_EDGEMODE_UNKNOWN",
  23929. "SVG_EDGEMODE_WRAP",
  23930. "SVG_FEBLEND_MODE_COLOR",
  23931. "SVG_FEBLEND_MODE_COLOR_BURN",
  23932. "SVG_FEBLEND_MODE_COLOR_DODGE",
  23933. "SVG_FEBLEND_MODE_DARKEN",
  23934. "SVG_FEBLEND_MODE_DIFFERENCE",
  23935. "SVG_FEBLEND_MODE_EXCLUSION",
  23936. "SVG_FEBLEND_MODE_HARD_LIGHT",
  23937. "SVG_FEBLEND_MODE_HUE",
  23938. "SVG_FEBLEND_MODE_LIGHTEN",
  23939. "SVG_FEBLEND_MODE_LUMINOSITY",
  23940. "SVG_FEBLEND_MODE_MULTIPLY",
  23941. "SVG_FEBLEND_MODE_NORMAL",
  23942. "SVG_FEBLEND_MODE_OVERLAY",
  23943. "SVG_FEBLEND_MODE_SATURATION",
  23944. "SVG_FEBLEND_MODE_SCREEN",
  23945. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  23946. "SVG_FEBLEND_MODE_UNKNOWN",
  23947. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  23948. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  23949. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  23950. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  23951. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  23952. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  23953. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  23954. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  23955. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  23956. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  23957. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  23958. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  23959. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  23960. "SVG_FECOMPOSITE_OPERATOR_IN",
  23961. "SVG_FECOMPOSITE_OPERATOR_OUT",
  23962. "SVG_FECOMPOSITE_OPERATOR_OVER",
  23963. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  23964. "SVG_FECOMPOSITE_OPERATOR_XOR",
  23965. "SVG_INVALID_VALUE_ERR",
  23966. "SVG_LENGTHTYPE_CM",
  23967. "SVG_LENGTHTYPE_EMS",
  23968. "SVG_LENGTHTYPE_EXS",
  23969. "SVG_LENGTHTYPE_IN",
  23970. "SVG_LENGTHTYPE_MM",
  23971. "SVG_LENGTHTYPE_NUMBER",
  23972. "SVG_LENGTHTYPE_PC",
  23973. "SVG_LENGTHTYPE_PERCENTAGE",
  23974. "SVG_LENGTHTYPE_PT",
  23975. "SVG_LENGTHTYPE_PX",
  23976. "SVG_LENGTHTYPE_UNKNOWN",
  23977. "SVG_MARKERUNITS_STROKEWIDTH",
  23978. "SVG_MARKERUNITS_UNKNOWN",
  23979. "SVG_MARKERUNITS_USERSPACEONUSE",
  23980. "SVG_MARKER_ORIENT_ANGLE",
  23981. "SVG_MARKER_ORIENT_AUTO",
  23982. "SVG_MARKER_ORIENT_UNKNOWN",
  23983. "SVG_MASKTYPE_ALPHA",
  23984. "SVG_MASKTYPE_LUMINANCE",
  23985. "SVG_MATRIX_NOT_INVERTABLE",
  23986. "SVG_MEETORSLICE_MEET",
  23987. "SVG_MEETORSLICE_SLICE",
  23988. "SVG_MEETORSLICE_UNKNOWN",
  23989. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  23990. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  23991. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  23992. "SVG_PAINTTYPE_CURRENTCOLOR",
  23993. "SVG_PAINTTYPE_NONE",
  23994. "SVG_PAINTTYPE_RGBCOLOR",
  23995. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  23996. "SVG_PAINTTYPE_UNKNOWN",
  23997. "SVG_PAINTTYPE_URI",
  23998. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  23999. "SVG_PAINTTYPE_URI_NONE",
  24000. "SVG_PAINTTYPE_URI_RGBCOLOR",
  24001. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  24002. "SVG_PRESERVEASPECTRATIO_NONE",
  24003. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  24004. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  24005. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  24006. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  24007. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  24008. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  24009. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  24010. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  24011. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  24012. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  24013. "SVG_SPREADMETHOD_PAD",
  24014. "SVG_SPREADMETHOD_REFLECT",
  24015. "SVG_SPREADMETHOD_REPEAT",
  24016. "SVG_SPREADMETHOD_UNKNOWN",
  24017. "SVG_STITCHTYPE_NOSTITCH",
  24018. "SVG_STITCHTYPE_STITCH",
  24019. "SVG_STITCHTYPE_UNKNOWN",
  24020. "SVG_TRANSFORM_MATRIX",
  24021. "SVG_TRANSFORM_ROTATE",
  24022. "SVG_TRANSFORM_SCALE",
  24023. "SVG_TRANSFORM_SKEWX",
  24024. "SVG_TRANSFORM_SKEWY",
  24025. "SVG_TRANSFORM_TRANSLATE",
  24026. "SVG_TRANSFORM_UNKNOWN",
  24027. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  24028. "SVG_TURBULENCE_TYPE_TURBULENCE",
  24029. "SVG_TURBULENCE_TYPE_UNKNOWN",
  24030. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  24031. "SVG_UNIT_TYPE_UNKNOWN",
  24032. "SVG_UNIT_TYPE_USERSPACEONUSE",
  24033. "SVG_WRONG_TYPE_ERR",
  24034. "SVG_ZOOMANDPAN_DISABLE",
  24035. "SVG_ZOOMANDPAN_MAGNIFY",
  24036. "SVG_ZOOMANDPAN_UNKNOWN",
  24037. "SYNC_CONDITION",
  24038. "SYNC_FENCE",
  24039. "SYNC_FLAGS",
  24040. "SYNC_FLUSH_COMMANDS_BIT",
  24041. "SYNC_GPU_COMMANDS_COMPLETE",
  24042. "SYNC_STATUS",
  24043. "SYNTAX_ERR",
  24044. "SavedPages",
  24045. "Screen",
  24046. "ScreenOrientation",
  24047. "Script",
  24048. "ScriptProcessorNode",
  24049. "ScrollAreaEvent",
  24050. "SecurityPolicyViolationEvent",
  24051. "Selection",
  24052. "Sensor",
  24053. "SensorErrorEvent",
  24054. "ServiceWorker",
  24055. "ServiceWorkerContainer",
  24056. "ServiceWorkerRegistration",
  24057. "SessionDescription",
  24058. "Set",
  24059. "ShadowRoot",
  24060. "SharedArrayBuffer",
  24061. "SharedWorker",
  24062. "SimpleGestureEvent",
  24063. "SourceBuffer",
  24064. "SourceBufferList",
  24065. "SpeechSynthesis",
  24066. "SpeechSynthesisErrorEvent",
  24067. "SpeechSynthesisEvent",
  24068. "SpeechSynthesisUtterance",
  24069. "SpeechSynthesisVoice",
  24070. "StaticRange",
  24071. "StereoPannerNode",
  24072. "StopIteration",
  24073. "Storage",
  24074. "StorageEvent",
  24075. "StorageManager",
  24076. "String",
  24077. "StructType",
  24078. "StylePropertyMap",
  24079. "StylePropertyMapReadOnly",
  24080. "StyleSheet",
  24081. "StyleSheetList",
  24082. "SubmitEvent",
  24083. "SubtleCrypto",
  24084. "Symbol",
  24085. "SyncManager",
  24086. "SyntaxError",
  24087. "TEMPORARY",
  24088. "TEXTPATH_METHODTYPE_ALIGN",
  24089. "TEXTPATH_METHODTYPE_STRETCH",
  24090. "TEXTPATH_METHODTYPE_UNKNOWN",
  24091. "TEXTPATH_SPACINGTYPE_AUTO",
  24092. "TEXTPATH_SPACINGTYPE_EXACT",
  24093. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  24094. "TEXTURE",
  24095. "TEXTURE0",
  24096. "TEXTURE1",
  24097. "TEXTURE10",
  24098. "TEXTURE11",
  24099. "TEXTURE12",
  24100. "TEXTURE13",
  24101. "TEXTURE14",
  24102. "TEXTURE15",
  24103. "TEXTURE16",
  24104. "TEXTURE17",
  24105. "TEXTURE18",
  24106. "TEXTURE19",
  24107. "TEXTURE2",
  24108. "TEXTURE20",
  24109. "TEXTURE21",
  24110. "TEXTURE22",
  24111. "TEXTURE23",
  24112. "TEXTURE24",
  24113. "TEXTURE25",
  24114. "TEXTURE26",
  24115. "TEXTURE27",
  24116. "TEXTURE28",
  24117. "TEXTURE29",
  24118. "TEXTURE3",
  24119. "TEXTURE30",
  24120. "TEXTURE31",
  24121. "TEXTURE4",
  24122. "TEXTURE5",
  24123. "TEXTURE6",
  24124. "TEXTURE7",
  24125. "TEXTURE8",
  24126. "TEXTURE9",
  24127. "TEXTURE_2D",
  24128. "TEXTURE_2D_ARRAY",
  24129. "TEXTURE_3D",
  24130. "TEXTURE_BASE_LEVEL",
  24131. "TEXTURE_BINDING_2D",
  24132. "TEXTURE_BINDING_2D_ARRAY",
  24133. "TEXTURE_BINDING_3D",
  24134. "TEXTURE_BINDING_CUBE_MAP",
  24135. "TEXTURE_COMPARE_FUNC",
  24136. "TEXTURE_COMPARE_MODE",
  24137. "TEXTURE_CUBE_MAP",
  24138. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  24139. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  24140. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  24141. "TEXTURE_CUBE_MAP_POSITIVE_X",
  24142. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  24143. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  24144. "TEXTURE_IMMUTABLE_FORMAT",
  24145. "TEXTURE_IMMUTABLE_LEVELS",
  24146. "TEXTURE_MAG_FILTER",
  24147. "TEXTURE_MAX_ANISOTROPY_EXT",
  24148. "TEXTURE_MAX_LEVEL",
  24149. "TEXTURE_MAX_LOD",
  24150. "TEXTURE_MIN_FILTER",
  24151. "TEXTURE_MIN_LOD",
  24152. "TEXTURE_WRAP_R",
  24153. "TEXTURE_WRAP_S",
  24154. "TEXTURE_WRAP_T",
  24155. "TEXT_NODE",
  24156. "TIMEOUT",
  24157. "TIMEOUT_ERR",
  24158. "TIMEOUT_EXPIRED",
  24159. "TIMEOUT_IGNORED",
  24160. "TOO_LARGE_ERR",
  24161. "TRANSACTION_INACTIVE_ERR",
  24162. "TRANSFORM_FEEDBACK",
  24163. "TRANSFORM_FEEDBACK_ACTIVE",
  24164. "TRANSFORM_FEEDBACK_BINDING",
  24165. "TRANSFORM_FEEDBACK_BUFFER",
  24166. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  24167. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  24168. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  24169. "TRANSFORM_FEEDBACK_BUFFER_START",
  24170. "TRANSFORM_FEEDBACK_PAUSED",
  24171. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  24172. "TRANSFORM_FEEDBACK_VARYINGS",
  24173. "TRIANGLE",
  24174. "TRIANGLES",
  24175. "TRIANGLE_FAN",
  24176. "TRIANGLE_STRIP",
  24177. "TYPE_BACK_FORWARD",
  24178. "TYPE_ERR",
  24179. "TYPE_MISMATCH_ERR",
  24180. "TYPE_NAVIGATE",
  24181. "TYPE_RELOAD",
  24182. "TYPE_RESERVED",
  24183. "Table",
  24184. "TaskAttributionTiming",
  24185. "Text",
  24186. "TextDecoder",
  24187. "TextDecoderStream",
  24188. "TextEncoder",
  24189. "TextEncoderStream",
  24190. "TextEvent",
  24191. "TextMetrics",
  24192. "TextTrack",
  24193. "TextTrackCue",
  24194. "TextTrackCueList",
  24195. "TextTrackList",
  24196. "TimeEvent",
  24197. "TimeRanges",
  24198. "Touch",
  24199. "TouchEvent",
  24200. "TouchList",
  24201. "TrackEvent",
  24202. "TransformStream",
  24203. "TransitionEvent",
  24204. "TreeWalker",
  24205. "TrustedHTML",
  24206. "TrustedScript",
  24207. "TrustedScriptURL",
  24208. "TrustedTypePolicy",
  24209. "TrustedTypePolicyFactory",
  24210. "TypeError",
  24211. "TypedObject",
  24212. "U2F",
  24213. "UIEvent",
  24214. "UNCACHED",
  24215. "UNIFORM_ARRAY_STRIDE",
  24216. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  24217. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  24218. "UNIFORM_BLOCK_BINDING",
  24219. "UNIFORM_BLOCK_DATA_SIZE",
  24220. "UNIFORM_BLOCK_INDEX",
  24221. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  24222. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  24223. "UNIFORM_BUFFER",
  24224. "UNIFORM_BUFFER_BINDING",
  24225. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  24226. "UNIFORM_BUFFER_SIZE",
  24227. "UNIFORM_BUFFER_START",
  24228. "UNIFORM_IS_ROW_MAJOR",
  24229. "UNIFORM_MATRIX_STRIDE",
  24230. "UNIFORM_OFFSET",
  24231. "UNIFORM_SIZE",
  24232. "UNIFORM_TYPE",
  24233. "UNKNOWN_ERR",
  24234. "UNKNOWN_RULE",
  24235. "UNMASKED_RENDERER_WEBGL",
  24236. "UNMASKED_VENDOR_WEBGL",
  24237. "UNORDERED_NODE_ITERATOR_TYPE",
  24238. "UNORDERED_NODE_SNAPSHOT_TYPE",
  24239. "UNPACK_ALIGNMENT",
  24240. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  24241. "UNPACK_FLIP_Y_WEBGL",
  24242. "UNPACK_IMAGE_HEIGHT",
  24243. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  24244. "UNPACK_ROW_LENGTH",
  24245. "UNPACK_SKIP_IMAGES",
  24246. "UNPACK_SKIP_PIXELS",
  24247. "UNPACK_SKIP_ROWS",
  24248. "UNSCHEDULED_STATE",
  24249. "UNSENT",
  24250. "UNSIGNALED",
  24251. "UNSIGNED_BYTE",
  24252. "UNSIGNED_INT",
  24253. "UNSIGNED_INT_10F_11F_11F_REV",
  24254. "UNSIGNED_INT_24_8",
  24255. "UNSIGNED_INT_2_10_10_10_REV",
  24256. "UNSIGNED_INT_5_9_9_9_REV",
  24257. "UNSIGNED_INT_SAMPLER_2D",
  24258. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  24259. "UNSIGNED_INT_SAMPLER_3D",
  24260. "UNSIGNED_INT_SAMPLER_CUBE",
  24261. "UNSIGNED_INT_VEC2",
  24262. "UNSIGNED_INT_VEC3",
  24263. "UNSIGNED_INT_VEC4",
  24264. "UNSIGNED_NORMALIZED",
  24265. "UNSIGNED_SHORT",
  24266. "UNSIGNED_SHORT_4_4_4_4",
  24267. "UNSIGNED_SHORT_5_5_5_1",
  24268. "UNSIGNED_SHORT_5_6_5",
  24269. "UNSPECIFIED_EVENT_TYPE_ERR",
  24270. "UPDATEREADY",
  24271. "URIError",
  24272. "URL",
  24273. "URLSearchParams",
  24274. "URLUnencoded",
  24275. "URL_MISMATCH_ERR",
  24276. "USB",
  24277. "USBAlternateInterface",
  24278. "USBConfiguration",
  24279. "USBConnectionEvent",
  24280. "USBDevice",
  24281. "USBEndpoint",
  24282. "USBInTransferResult",
  24283. "USBInterface",
  24284. "USBIsochronousInTransferPacket",
  24285. "USBIsochronousInTransferResult",
  24286. "USBIsochronousOutTransferPacket",
  24287. "USBIsochronousOutTransferResult",
  24288. "USBOutTransferResult",
  24289. "UTC",
  24290. "Uint16Array",
  24291. "Uint32Array",
  24292. "Uint8Array",
  24293. "Uint8ClampedArray",
  24294. "UserActivation",
  24295. "UserMessageHandler",
  24296. "UserMessageHandlersNamespace",
  24297. "UserProximityEvent",
  24298. "VALIDATE_STATUS",
  24299. "VALIDATION_ERR",
  24300. "VARIABLES_RULE",
  24301. "VENDOR",
  24302. "VERSION",
  24303. "VERSION_CHANGE",
  24304. "VERSION_ERR",
  24305. "VERTEX_ARRAY_BINDING",
  24306. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  24307. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  24308. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  24309. "VERTEX_ATTRIB_ARRAY_ENABLED",
  24310. "VERTEX_ATTRIB_ARRAY_INTEGER",
  24311. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  24312. "VERTEX_ATTRIB_ARRAY_POINTER",
  24313. "VERTEX_ATTRIB_ARRAY_SIZE",
  24314. "VERTEX_ATTRIB_ARRAY_STRIDE",
  24315. "VERTEX_ATTRIB_ARRAY_TYPE",
  24316. "VERTEX_SHADER",
  24317. "VERTICAL",
  24318. "VERTICAL_AXIS",
  24319. "VER_ERR",
  24320. "VIEWPORT",
  24321. "VIEWPORT_RULE",
  24322. "VRDisplay",
  24323. "VRDisplayCapabilities",
  24324. "VRDisplayEvent",
  24325. "VREyeParameters",
  24326. "VRFieldOfView",
  24327. "VRFrameData",
  24328. "VRPose",
  24329. "VRStageParameters",
  24330. "VTTCue",
  24331. "VTTRegion",
  24332. "ValidityState",
  24333. "VideoPlaybackQuality",
  24334. "VideoStreamTrack",
  24335. "VisualViewport",
  24336. "WAIT_FAILED",
  24337. "WEBKIT_FILTER_RULE",
  24338. "WEBKIT_KEYFRAMES_RULE",
  24339. "WEBKIT_KEYFRAME_RULE",
  24340. "WEBKIT_REGION_RULE",
  24341. "WRONG_DOCUMENT_ERR",
  24342. "WakeLock",
  24343. "WakeLockSentinel",
  24344. "WasmAnyRef",
  24345. "WaveShaperNode",
  24346. "WeakMap",
  24347. "WeakRef",
  24348. "WeakSet",
  24349. "WebAssembly",
  24350. "WebGL2RenderingContext",
  24351. "WebGLActiveInfo",
  24352. "WebGLBuffer",
  24353. "WebGLContextEvent",
  24354. "WebGLFramebuffer",
  24355. "WebGLProgram",
  24356. "WebGLQuery",
  24357. "WebGLRenderbuffer",
  24358. "WebGLRenderingContext",
  24359. "WebGLSampler",
  24360. "WebGLShader",
  24361. "WebGLShaderPrecisionFormat",
  24362. "WebGLSync",
  24363. "WebGLTexture",
  24364. "WebGLTransformFeedback",
  24365. "WebGLUniformLocation",
  24366. "WebGLVertexArray",
  24367. "WebGLVertexArrayObject",
  24368. "WebKitAnimationEvent",
  24369. "WebKitBlobBuilder",
  24370. "WebKitCSSFilterRule",
  24371. "WebKitCSSFilterValue",
  24372. "WebKitCSSKeyframeRule",
  24373. "WebKitCSSKeyframesRule",
  24374. "WebKitCSSMatrix",
  24375. "WebKitCSSRegionRule",
  24376. "WebKitCSSTransformValue",
  24377. "WebKitDataCue",
  24378. "WebKitGamepad",
  24379. "WebKitMediaKeyError",
  24380. "WebKitMediaKeyMessageEvent",
  24381. "WebKitMediaKeySession",
  24382. "WebKitMediaKeys",
  24383. "WebKitMediaSource",
  24384. "WebKitMutationObserver",
  24385. "WebKitNamespace",
  24386. "WebKitPlaybackTargetAvailabilityEvent",
  24387. "WebKitPoint",
  24388. "WebKitShadowRoot",
  24389. "WebKitSourceBuffer",
  24390. "WebKitSourceBufferList",
  24391. "WebKitTransitionEvent",
  24392. "WebSocket",
  24393. "WebkitAlignContent",
  24394. "WebkitAlignItems",
  24395. "WebkitAlignSelf",
  24396. "WebkitAnimation",
  24397. "WebkitAnimationDelay",
  24398. "WebkitAnimationDirection",
  24399. "WebkitAnimationDuration",
  24400. "WebkitAnimationFillMode",
  24401. "WebkitAnimationIterationCount",
  24402. "WebkitAnimationName",
  24403. "WebkitAnimationPlayState",
  24404. "WebkitAnimationTimingFunction",
  24405. "WebkitAppearance",
  24406. "WebkitBackfaceVisibility",
  24407. "WebkitBackgroundClip",
  24408. "WebkitBackgroundOrigin",
  24409. "WebkitBackgroundSize",
  24410. "WebkitBorderBottomLeftRadius",
  24411. "WebkitBorderBottomRightRadius",
  24412. "WebkitBorderImage",
  24413. "WebkitBorderRadius",
  24414. "WebkitBorderTopLeftRadius",
  24415. "WebkitBorderTopRightRadius",
  24416. "WebkitBoxAlign",
  24417. "WebkitBoxDirection",
  24418. "WebkitBoxFlex",
  24419. "WebkitBoxOrdinalGroup",
  24420. "WebkitBoxOrient",
  24421. "WebkitBoxPack",
  24422. "WebkitBoxShadow",
  24423. "WebkitBoxSizing",
  24424. "WebkitFilter",
  24425. "WebkitFlex",
  24426. "WebkitFlexBasis",
  24427. "WebkitFlexDirection",
  24428. "WebkitFlexFlow",
  24429. "WebkitFlexGrow",
  24430. "WebkitFlexShrink",
  24431. "WebkitFlexWrap",
  24432. "WebkitJustifyContent",
  24433. "WebkitLineClamp",
  24434. "WebkitMask",
  24435. "WebkitMaskClip",
  24436. "WebkitMaskComposite",
  24437. "WebkitMaskImage",
  24438. "WebkitMaskOrigin",
  24439. "WebkitMaskPosition",
  24440. "WebkitMaskPositionX",
  24441. "WebkitMaskPositionY",
  24442. "WebkitMaskRepeat",
  24443. "WebkitMaskSize",
  24444. "WebkitOrder",
  24445. "WebkitPerspective",
  24446. "WebkitPerspectiveOrigin",
  24447. "WebkitTextFillColor",
  24448. "WebkitTextSizeAdjust",
  24449. "WebkitTextStroke",
  24450. "WebkitTextStrokeColor",
  24451. "WebkitTextStrokeWidth",
  24452. "WebkitTransform",
  24453. "WebkitTransformOrigin",
  24454. "WebkitTransformStyle",
  24455. "WebkitTransition",
  24456. "WebkitTransitionDelay",
  24457. "WebkitTransitionDuration",
  24458. "WebkitTransitionProperty",
  24459. "WebkitTransitionTimingFunction",
  24460. "WebkitUserSelect",
  24461. "WheelEvent",
  24462. "Window",
  24463. "Worker",
  24464. "Worklet",
  24465. "WritableStream",
  24466. "WritableStreamDefaultWriter",
  24467. "XMLDocument",
  24468. "XMLHttpRequest",
  24469. "XMLHttpRequestEventTarget",
  24470. "XMLHttpRequestException",
  24471. "XMLHttpRequestProgressEvent",
  24472. "XMLHttpRequestUpload",
  24473. "XMLSerializer",
  24474. "XMLStylesheetProcessingInstruction",
  24475. "XPathEvaluator",
  24476. "XPathException",
  24477. "XPathExpression",
  24478. "XPathNSResolver",
  24479. "XPathResult",
  24480. "XRBoundedReferenceSpace",
  24481. "XRDOMOverlayState",
  24482. "XRFrame",
  24483. "XRHitTestResult",
  24484. "XRHitTestSource",
  24485. "XRInputSource",
  24486. "XRInputSourceArray",
  24487. "XRInputSourceEvent",
  24488. "XRInputSourcesChangeEvent",
  24489. "XRLayer",
  24490. "XRPose",
  24491. "XRRay",
  24492. "XRReferenceSpace",
  24493. "XRReferenceSpaceEvent",
  24494. "XRRenderState",
  24495. "XRRigidTransform",
  24496. "XRSession",
  24497. "XRSessionEvent",
  24498. "XRSpace",
  24499. "XRSystem",
  24500. "XRTransientInputHitTestResult",
  24501. "XRTransientInputHitTestSource",
  24502. "XRView",
  24503. "XRViewerPose",
  24504. "XRViewport",
  24505. "XRWebGLLayer",
  24506. "XSLTProcessor",
  24507. "ZERO",
  24508. "_XD0M_",
  24509. "_YD0M_",
  24510. "__defineGetter__",
  24511. "__defineSetter__",
  24512. "__lookupGetter__",
  24513. "__lookupSetter__",
  24514. "__opera",
  24515. "__proto__",
  24516. "_browserjsran",
  24517. "a",
  24518. "aLink",
  24519. "abbr",
  24520. "abort",
  24521. "aborted",
  24522. "abs",
  24523. "absolute",
  24524. "acceleration",
  24525. "accelerationIncludingGravity",
  24526. "accelerator",
  24527. "accept",
  24528. "acceptCharset",
  24529. "acceptNode",
  24530. "accessKey",
  24531. "accessKeyLabel",
  24532. "accuracy",
  24533. "acos",
  24534. "acosh",
  24535. "action",
  24536. "actionURL",
  24537. "actions",
  24538. "activated",
  24539. "active",
  24540. "activeCues",
  24541. "activeElement",
  24542. "activeSourceBuffers",
  24543. "activeSourceCount",
  24544. "activeTexture",
  24545. "activeVRDisplays",
  24546. "actualBoundingBoxAscent",
  24547. "actualBoundingBoxDescent",
  24548. "actualBoundingBoxLeft",
  24549. "actualBoundingBoxRight",
  24550. "add",
  24551. "addAll",
  24552. "addBehavior",
  24553. "addCandidate",
  24554. "addColorStop",
  24555. "addCue",
  24556. "addElement",
  24557. "addEventListener",
  24558. "addFilter",
  24559. "addFromString",
  24560. "addFromUri",
  24561. "addIceCandidate",
  24562. "addImport",
  24563. "addListener",
  24564. "addModule",
  24565. "addNamed",
  24566. "addPageRule",
  24567. "addPath",
  24568. "addPointer",
  24569. "addRange",
  24570. "addRegion",
  24571. "addRule",
  24572. "addSearchEngine",
  24573. "addSourceBuffer",
  24574. "addStream",
  24575. "addTextTrack",
  24576. "addTrack",
  24577. "addTransceiver",
  24578. "addWakeLockListener",
  24579. "added",
  24580. "addedNodes",
  24581. "additionalName",
  24582. "additiveSymbols",
  24583. "addons",
  24584. "address",
  24585. "addressLine",
  24586. "adoptNode",
  24587. "adoptedStyleSheets",
  24588. "adr",
  24589. "advance",
  24590. "after",
  24591. "album",
  24592. "alert",
  24593. "algorithm",
  24594. "align",
  24595. "align-content",
  24596. "align-items",
  24597. "align-self",
  24598. "alignContent",
  24599. "alignItems",
  24600. "alignSelf",
  24601. "alignmentBaseline",
  24602. "alinkColor",
  24603. "all",
  24604. "allSettled",
  24605. "allow",
  24606. "allowFullscreen",
  24607. "allowPaymentRequest",
  24608. "allowedDirections",
  24609. "allowedFeatures",
  24610. "allowedToPlay",
  24611. "allowsFeature",
  24612. "alpha",
  24613. "alt",
  24614. "altGraphKey",
  24615. "altHtml",
  24616. "altKey",
  24617. "altLeft",
  24618. "alternate",
  24619. "alternateSetting",
  24620. "alternates",
  24621. "altitude",
  24622. "altitudeAccuracy",
  24623. "amplitude",
  24624. "ancestorOrigins",
  24625. "anchor",
  24626. "anchorNode",
  24627. "anchorOffset",
  24628. "anchors",
  24629. "and",
  24630. "angle",
  24631. "angularAcceleration",
  24632. "angularVelocity",
  24633. "animVal",
  24634. "animate",
  24635. "animatedInstanceRoot",
  24636. "animatedNormalizedPathSegList",
  24637. "animatedPathSegList",
  24638. "animatedPoints",
  24639. "animation",
  24640. "animation-delay",
  24641. "animation-direction",
  24642. "animation-duration",
  24643. "animation-fill-mode",
  24644. "animation-iteration-count",
  24645. "animation-name",
  24646. "animation-play-state",
  24647. "animation-timing-function",
  24648. "animationDelay",
  24649. "animationDirection",
  24650. "animationDuration",
  24651. "animationFillMode",
  24652. "animationIterationCount",
  24653. "animationName",
  24654. "animationPlayState",
  24655. "animationStartTime",
  24656. "animationTimingFunction",
  24657. "animationsPaused",
  24658. "anniversary",
  24659. "antialias",
  24660. "anticipatedRemoval",
  24661. "any",
  24662. "app",
  24663. "appCodeName",
  24664. "appMinorVersion",
  24665. "appName",
  24666. "appNotifications",
  24667. "appVersion",
  24668. "appearance",
  24669. "append",
  24670. "appendBuffer",
  24671. "appendChild",
  24672. "appendData",
  24673. "appendItem",
  24674. "appendMedium",
  24675. "appendNamed",
  24676. "appendRule",
  24677. "appendStream",
  24678. "appendWindowEnd",
  24679. "appendWindowStart",
  24680. "applets",
  24681. "applicationCache",
  24682. "applicationServerKey",
  24683. "apply",
  24684. "applyConstraints",
  24685. "applyElement",
  24686. "arc",
  24687. "arcTo",
  24688. "architecture",
  24689. "archive",
  24690. "areas",
  24691. "arguments",
  24692. "ariaAtomic",
  24693. "ariaAutoComplete",
  24694. "ariaBusy",
  24695. "ariaChecked",
  24696. "ariaColCount",
  24697. "ariaColIndex",
  24698. "ariaColSpan",
  24699. "ariaCurrent",
  24700. "ariaDescription",
  24701. "ariaDisabled",
  24702. "ariaExpanded",
  24703. "ariaHasPopup",
  24704. "ariaHidden",
  24705. "ariaKeyShortcuts",
  24706. "ariaLabel",
  24707. "ariaLevel",
  24708. "ariaLive",
  24709. "ariaModal",
  24710. "ariaMultiLine",
  24711. "ariaMultiSelectable",
  24712. "ariaOrientation",
  24713. "ariaPlaceholder",
  24714. "ariaPosInSet",
  24715. "ariaPressed",
  24716. "ariaReadOnly",
  24717. "ariaRelevant",
  24718. "ariaRequired",
  24719. "ariaRoleDescription",
  24720. "ariaRowCount",
  24721. "ariaRowIndex",
  24722. "ariaRowSpan",
  24723. "ariaSelected",
  24724. "ariaSetSize",
  24725. "ariaSort",
  24726. "ariaValueMax",
  24727. "ariaValueMin",
  24728. "ariaValueNow",
  24729. "ariaValueText",
  24730. "arrayBuffer",
  24731. "artist",
  24732. "artwork",
  24733. "as",
  24734. "asIntN",
  24735. "asUintN",
  24736. "asin",
  24737. "asinh",
  24738. "assert",
  24739. "assign",
  24740. "assignedElements",
  24741. "assignedNodes",
  24742. "assignedSlot",
  24743. "async",
  24744. "asyncIterator",
  24745. "atEnd",
  24746. "atan",
  24747. "atan2",
  24748. "atanh",
  24749. "atob",
  24750. "attachEvent",
  24751. "attachInternals",
  24752. "attachShader",
  24753. "attachShadow",
  24754. "attachments",
  24755. "attack",
  24756. "attestationObject",
  24757. "attrChange",
  24758. "attrName",
  24759. "attributeFilter",
  24760. "attributeName",
  24761. "attributeNamespace",
  24762. "attributeOldValue",
  24763. "attributeStyleMap",
  24764. "attributes",
  24765. "attribution",
  24766. "audioBitsPerSecond",
  24767. "audioTracks",
  24768. "audioWorklet",
  24769. "authenticatedSignedWrites",
  24770. "authenticatorData",
  24771. "autoIncrement",
  24772. "autobuffer",
  24773. "autocapitalize",
  24774. "autocomplete",
  24775. "autocorrect",
  24776. "autofocus",
  24777. "automationRate",
  24778. "autoplay",
  24779. "availHeight",
  24780. "availLeft",
  24781. "availTop",
  24782. "availWidth",
  24783. "availability",
  24784. "available",
  24785. "aversion",
  24786. "ax",
  24787. "axes",
  24788. "axis",
  24789. "ay",
  24790. "azimuth",
  24791. "b",
  24792. "back",
  24793. "backface-visibility",
  24794. "backfaceVisibility",
  24795. "background",
  24796. "background-attachment",
  24797. "background-blend-mode",
  24798. "background-clip",
  24799. "background-color",
  24800. "background-image",
  24801. "background-origin",
  24802. "background-position",
  24803. "background-position-x",
  24804. "background-position-y",
  24805. "background-repeat",
  24806. "background-size",
  24807. "backgroundAttachment",
  24808. "backgroundBlendMode",
  24809. "backgroundClip",
  24810. "backgroundColor",
  24811. "backgroundFetch",
  24812. "backgroundImage",
  24813. "backgroundOrigin",
  24814. "backgroundPosition",
  24815. "backgroundPositionX",
  24816. "backgroundPositionY",
  24817. "backgroundRepeat",
  24818. "backgroundSize",
  24819. "badInput",
  24820. "badge",
  24821. "balance",
  24822. "baseFrequencyX",
  24823. "baseFrequencyY",
  24824. "baseLatency",
  24825. "baseLayer",
  24826. "baseNode",
  24827. "baseOffset",
  24828. "baseURI",
  24829. "baseVal",
  24830. "baselineShift",
  24831. "battery",
  24832. "bday",
  24833. "before",
  24834. "beginElement",
  24835. "beginElementAt",
  24836. "beginPath",
  24837. "beginQuery",
  24838. "beginTransformFeedback",
  24839. "behavior",
  24840. "behaviorCookie",
  24841. "behaviorPart",
  24842. "behaviorUrns",
  24843. "beta",
  24844. "bezierCurveTo",
  24845. "bgColor",
  24846. "bgProperties",
  24847. "bias",
  24848. "big",
  24849. "bigint64",
  24850. "biguint64",
  24851. "binaryType",
  24852. "bind",
  24853. "bindAttribLocation",
  24854. "bindBuffer",
  24855. "bindBufferBase",
  24856. "bindBufferRange",
  24857. "bindFramebuffer",
  24858. "bindRenderbuffer",
  24859. "bindSampler",
  24860. "bindTexture",
  24861. "bindTransformFeedback",
  24862. "bindVertexArray",
  24863. "bitness",
  24864. "blendColor",
  24865. "blendEquation",
  24866. "blendEquationSeparate",
  24867. "blendFunc",
  24868. "blendFuncSeparate",
  24869. "blink",
  24870. "blitFramebuffer",
  24871. "blob",
  24872. "block-size",
  24873. "blockDirection",
  24874. "blockSize",
  24875. "blockedURI",
  24876. "blue",
  24877. "bluetooth",
  24878. "blur",
  24879. "body",
  24880. "bodyUsed",
  24881. "bold",
  24882. "bookmarks",
  24883. "booleanValue",
  24884. "border",
  24885. "border-block",
  24886. "border-block-color",
  24887. "border-block-end",
  24888. "border-block-end-color",
  24889. "border-block-end-style",
  24890. "border-block-end-width",
  24891. "border-block-start",
  24892. "border-block-start-color",
  24893. "border-block-start-style",
  24894. "border-block-start-width",
  24895. "border-block-style",
  24896. "border-block-width",
  24897. "border-bottom",
  24898. "border-bottom-color",
  24899. "border-bottom-left-radius",
  24900. "border-bottom-right-radius",
  24901. "border-bottom-style",
  24902. "border-bottom-width",
  24903. "border-collapse",
  24904. "border-color",
  24905. "border-end-end-radius",
  24906. "border-end-start-radius",
  24907. "border-image",
  24908. "border-image-outset",
  24909. "border-image-repeat",
  24910. "border-image-slice",
  24911. "border-image-source",
  24912. "border-image-width",
  24913. "border-inline",
  24914. "border-inline-color",
  24915. "border-inline-end",
  24916. "border-inline-end-color",
  24917. "border-inline-end-style",
  24918. "border-inline-end-width",
  24919. "border-inline-start",
  24920. "border-inline-start-color",
  24921. "border-inline-start-style",
  24922. "border-inline-start-width",
  24923. "border-inline-style",
  24924. "border-inline-width",
  24925. "border-left",
  24926. "border-left-color",
  24927. "border-left-style",
  24928. "border-left-width",
  24929. "border-radius",
  24930. "border-right",
  24931. "border-right-color",
  24932. "border-right-style",
  24933. "border-right-width",
  24934. "border-spacing",
  24935. "border-start-end-radius",
  24936. "border-start-start-radius",
  24937. "border-style",
  24938. "border-top",
  24939. "border-top-color",
  24940. "border-top-left-radius",
  24941. "border-top-right-radius",
  24942. "border-top-style",
  24943. "border-top-width",
  24944. "border-width",
  24945. "borderBlock",
  24946. "borderBlockColor",
  24947. "borderBlockEnd",
  24948. "borderBlockEndColor",
  24949. "borderBlockEndStyle",
  24950. "borderBlockEndWidth",
  24951. "borderBlockStart",
  24952. "borderBlockStartColor",
  24953. "borderBlockStartStyle",
  24954. "borderBlockStartWidth",
  24955. "borderBlockStyle",
  24956. "borderBlockWidth",
  24957. "borderBottom",
  24958. "borderBottomColor",
  24959. "borderBottomLeftRadius",
  24960. "borderBottomRightRadius",
  24961. "borderBottomStyle",
  24962. "borderBottomWidth",
  24963. "borderBoxSize",
  24964. "borderCollapse",
  24965. "borderColor",
  24966. "borderColorDark",
  24967. "borderColorLight",
  24968. "borderEndEndRadius",
  24969. "borderEndStartRadius",
  24970. "borderImage",
  24971. "borderImageOutset",
  24972. "borderImageRepeat",
  24973. "borderImageSlice",
  24974. "borderImageSource",
  24975. "borderImageWidth",
  24976. "borderInline",
  24977. "borderInlineColor",
  24978. "borderInlineEnd",
  24979. "borderInlineEndColor",
  24980. "borderInlineEndStyle",
  24981. "borderInlineEndWidth",
  24982. "borderInlineStart",
  24983. "borderInlineStartColor",
  24984. "borderInlineStartStyle",
  24985. "borderInlineStartWidth",
  24986. "borderInlineStyle",
  24987. "borderInlineWidth",
  24988. "borderLeft",
  24989. "borderLeftColor",
  24990. "borderLeftStyle",
  24991. "borderLeftWidth",
  24992. "borderRadius",
  24993. "borderRight",
  24994. "borderRightColor",
  24995. "borderRightStyle",
  24996. "borderRightWidth",
  24997. "borderSpacing",
  24998. "borderStartEndRadius",
  24999. "borderStartStartRadius",
  25000. "borderStyle",
  25001. "borderTop",
  25002. "borderTopColor",
  25003. "borderTopLeftRadius",
  25004. "borderTopRightRadius",
  25005. "borderTopStyle",
  25006. "borderTopWidth",
  25007. "borderWidth",
  25008. "bottom",
  25009. "bottomMargin",
  25010. "bound",
  25011. "boundElements",
  25012. "boundingClientRect",
  25013. "boundingHeight",
  25014. "boundingLeft",
  25015. "boundingTop",
  25016. "boundingWidth",
  25017. "bounds",
  25018. "boundsGeometry",
  25019. "box-decoration-break",
  25020. "box-shadow",
  25021. "box-sizing",
  25022. "boxDecorationBreak",
  25023. "boxShadow",
  25024. "boxSizing",
  25025. "brand",
  25026. "brands",
  25027. "break-after",
  25028. "break-before",
  25029. "break-inside",
  25030. "breakAfter",
  25031. "breakBefore",
  25032. "breakInside",
  25033. "broadcast",
  25034. "browserLanguage",
  25035. "btoa",
  25036. "bubbles",
  25037. "buffer",
  25038. "bufferData",
  25039. "bufferDepth",
  25040. "bufferSize",
  25041. "bufferSubData",
  25042. "buffered",
  25043. "bufferedAmount",
  25044. "bufferedAmountLowThreshold",
  25045. "buildID",
  25046. "buildNumber",
  25047. "button",
  25048. "buttonID",
  25049. "buttons",
  25050. "byteLength",
  25051. "byteOffset",
  25052. "bytesWritten",
  25053. "c",
  25054. "cache",
  25055. "caches",
  25056. "call",
  25057. "caller",
  25058. "canBeFormatted",
  25059. "canBeMounted",
  25060. "canBeShared",
  25061. "canHaveChildren",
  25062. "canHaveHTML",
  25063. "canInsertDTMF",
  25064. "canMakePayment",
  25065. "canPlayType",
  25066. "canPresent",
  25067. "canTrickleIceCandidates",
  25068. "cancel",
  25069. "cancelAndHoldAtTime",
  25070. "cancelAnimationFrame",
  25071. "cancelBubble",
  25072. "cancelIdleCallback",
  25073. "cancelScheduledValues",
  25074. "cancelVideoFrameCallback",
  25075. "cancelWatchAvailability",
  25076. "cancelable",
  25077. "candidate",
  25078. "canonicalUUID",
  25079. "canvas",
  25080. "capabilities",
  25081. "caption",
  25082. "caption-side",
  25083. "captionSide",
  25084. "capture",
  25085. "captureEvents",
  25086. "captureStackTrace",
  25087. "captureStream",
  25088. "caret-color",
  25089. "caretBidiLevel",
  25090. "caretColor",
  25091. "caretPositionFromPoint",
  25092. "caretRangeFromPoint",
  25093. "cast",
  25094. "catch",
  25095. "category",
  25096. "cbrt",
  25097. "cd",
  25098. "ceil",
  25099. "cellIndex",
  25100. "cellPadding",
  25101. "cellSpacing",
  25102. "cells",
  25103. "ch",
  25104. "chOff",
  25105. "chain",
  25106. "challenge",
  25107. "changeType",
  25108. "changedTouches",
  25109. "channel",
  25110. "channelCount",
  25111. "channelCountMode",
  25112. "channelInterpretation",
  25113. "char",
  25114. "charAt",
  25115. "charCode",
  25116. "charCodeAt",
  25117. "charIndex",
  25118. "charLength",
  25119. "characterData",
  25120. "characterDataOldValue",
  25121. "characterSet",
  25122. "characteristic",
  25123. "charging",
  25124. "chargingTime",
  25125. "charset",
  25126. "check",
  25127. "checkEnclosure",
  25128. "checkFramebufferStatus",
  25129. "checkIntersection",
  25130. "checkValidity",
  25131. "checked",
  25132. "childElementCount",
  25133. "childList",
  25134. "childNodes",
  25135. "children",
  25136. "chrome",
  25137. "ciphertext",
  25138. "cite",
  25139. "city",
  25140. "claimInterface",
  25141. "claimed",
  25142. "classList",
  25143. "className",
  25144. "classid",
  25145. "clear",
  25146. "clearAppBadge",
  25147. "clearAttributes",
  25148. "clearBufferfi",
  25149. "clearBufferfv",
  25150. "clearBufferiv",
  25151. "clearBufferuiv",
  25152. "clearColor",
  25153. "clearData",
  25154. "clearDepth",
  25155. "clearHalt",
  25156. "clearImmediate",
  25157. "clearInterval",
  25158. "clearLiveSeekableRange",
  25159. "clearMarks",
  25160. "clearMaxGCPauseAccumulator",
  25161. "clearMeasures",
  25162. "clearParameters",
  25163. "clearRect",
  25164. "clearResourceTimings",
  25165. "clearShadow",
  25166. "clearStencil",
  25167. "clearTimeout",
  25168. "clearWatch",
  25169. "click",
  25170. "clickCount",
  25171. "clientDataJSON",
  25172. "clientHeight",
  25173. "clientInformation",
  25174. "clientLeft",
  25175. "clientRect",
  25176. "clientRects",
  25177. "clientTop",
  25178. "clientWaitSync",
  25179. "clientWidth",
  25180. "clientX",
  25181. "clientY",
  25182. "clip",
  25183. "clip-path",
  25184. "clip-rule",
  25185. "clipBottom",
  25186. "clipLeft",
  25187. "clipPath",
  25188. "clipPathUnits",
  25189. "clipRight",
  25190. "clipRule",
  25191. "clipTop",
  25192. "clipboard",
  25193. "clipboardData",
  25194. "clone",
  25195. "cloneContents",
  25196. "cloneNode",
  25197. "cloneRange",
  25198. "close",
  25199. "closePath",
  25200. "closed",
  25201. "closest",
  25202. "clz",
  25203. "clz32",
  25204. "cm",
  25205. "cmp",
  25206. "code",
  25207. "codeBase",
  25208. "codePointAt",
  25209. "codeType",
  25210. "colSpan",
  25211. "collapse",
  25212. "collapseToEnd",
  25213. "collapseToStart",
  25214. "collapsed",
  25215. "collect",
  25216. "colno",
  25217. "color",
  25218. "color-adjust",
  25219. "color-interpolation",
  25220. "color-interpolation-filters",
  25221. "colorAdjust",
  25222. "colorDepth",
  25223. "colorInterpolation",
  25224. "colorInterpolationFilters",
  25225. "colorMask",
  25226. "colorType",
  25227. "cols",
  25228. "column-count",
  25229. "column-fill",
  25230. "column-gap",
  25231. "column-rule",
  25232. "column-rule-color",
  25233. "column-rule-style",
  25234. "column-rule-width",
  25235. "column-span",
  25236. "column-width",
  25237. "columnCount",
  25238. "columnFill",
  25239. "columnGap",
  25240. "columnNumber",
  25241. "columnRule",
  25242. "columnRuleColor",
  25243. "columnRuleStyle",
  25244. "columnRuleWidth",
  25245. "columnSpan",
  25246. "columnWidth",
  25247. "columns",
  25248. "command",
  25249. "commit",
  25250. "commitPreferences",
  25251. "commitStyles",
  25252. "commonAncestorContainer",
  25253. "compact",
  25254. "compareBoundaryPoints",
  25255. "compareDocumentPosition",
  25256. "compareEndPoints",
  25257. "compareExchange",
  25258. "compareNode",
  25259. "comparePoint",
  25260. "compatMode",
  25261. "compatible",
  25262. "compile",
  25263. "compileShader",
  25264. "compileStreaming",
  25265. "complete",
  25266. "component",
  25267. "componentFromPoint",
  25268. "composed",
  25269. "composedPath",
  25270. "composite",
  25271. "compositionEndOffset",
  25272. "compositionStartOffset",
  25273. "compressedTexImage2D",
  25274. "compressedTexImage3D",
  25275. "compressedTexSubImage2D",
  25276. "compressedTexSubImage3D",
  25277. "computedStyleMap",
  25278. "concat",
  25279. "conditionText",
  25280. "coneInnerAngle",
  25281. "coneOuterAngle",
  25282. "coneOuterGain",
  25283. "configuration",
  25284. "configurationName",
  25285. "configurationValue",
  25286. "configurations",
  25287. "confirm",
  25288. "confirmComposition",
  25289. "confirmSiteSpecificTrackingException",
  25290. "confirmWebWideTrackingException",
  25291. "connect",
  25292. "connectEnd",
  25293. "connectShark",
  25294. "connectStart",
  25295. "connected",
  25296. "connection",
  25297. "connectionList",
  25298. "connectionSpeed",
  25299. "connectionState",
  25300. "connections",
  25301. "console",
  25302. "consolidate",
  25303. "constraint",
  25304. "constrictionActive",
  25305. "construct",
  25306. "constructor",
  25307. "contactID",
  25308. "contain",
  25309. "containerId",
  25310. "containerName",
  25311. "containerSrc",
  25312. "containerType",
  25313. "contains",
  25314. "containsNode",
  25315. "content",
  25316. "contentBoxSize",
  25317. "contentDocument",
  25318. "contentEditable",
  25319. "contentHint",
  25320. "contentOverflow",
  25321. "contentRect",
  25322. "contentScriptType",
  25323. "contentStyleType",
  25324. "contentType",
  25325. "contentWindow",
  25326. "context",
  25327. "contextMenu",
  25328. "contextmenu",
  25329. "continue",
  25330. "continuePrimaryKey",
  25331. "continuous",
  25332. "control",
  25333. "controlTransferIn",
  25334. "controlTransferOut",
  25335. "controller",
  25336. "controls",
  25337. "controlsList",
  25338. "convertPointFromNode",
  25339. "convertQuadFromNode",
  25340. "convertRectFromNode",
  25341. "convertToBlob",
  25342. "convertToSpecifiedUnits",
  25343. "cookie",
  25344. "cookieEnabled",
  25345. "coords",
  25346. "copyBufferSubData",
  25347. "copyFromChannel",
  25348. "copyTexImage2D",
  25349. "copyTexSubImage2D",
  25350. "copyTexSubImage3D",
  25351. "copyToChannel",
  25352. "copyWithin",
  25353. "correspondingElement",
  25354. "correspondingUseElement",
  25355. "corruptedVideoFrames",
  25356. "cos",
  25357. "cosh",
  25358. "count",
  25359. "countReset",
  25360. "counter-increment",
  25361. "counter-reset",
  25362. "counter-set",
  25363. "counterIncrement",
  25364. "counterReset",
  25365. "counterSet",
  25366. "country",
  25367. "cpuClass",
  25368. "cpuSleepAllowed",
  25369. "create",
  25370. "createAnalyser",
  25371. "createAnswer",
  25372. "createAttribute",
  25373. "createAttributeNS",
  25374. "createBiquadFilter",
  25375. "createBuffer",
  25376. "createBufferSource",
  25377. "createCDATASection",
  25378. "createCSSStyleSheet",
  25379. "createCaption",
  25380. "createChannelMerger",
  25381. "createChannelSplitter",
  25382. "createComment",
  25383. "createConstantSource",
  25384. "createContextualFragment",
  25385. "createControlRange",
  25386. "createConvolver",
  25387. "createDTMFSender",
  25388. "createDataChannel",
  25389. "createDelay",
  25390. "createDelayNode",
  25391. "createDocument",
  25392. "createDocumentFragment",
  25393. "createDocumentType",
  25394. "createDynamicsCompressor",
  25395. "createElement",
  25396. "createElementNS",
  25397. "createEntityReference",
  25398. "createEvent",
  25399. "createEventObject",
  25400. "createExpression",
  25401. "createFramebuffer",
  25402. "createFunction",
  25403. "createGain",
  25404. "createGainNode",
  25405. "createHTML",
  25406. "createHTMLDocument",
  25407. "createIIRFilter",
  25408. "createImageBitmap",
  25409. "createImageData",
  25410. "createIndex",
  25411. "createJavaScriptNode",
  25412. "createLinearGradient",
  25413. "createMediaElementSource",
  25414. "createMediaKeys",
  25415. "createMediaStreamDestination",
  25416. "createMediaStreamSource",
  25417. "createMediaStreamTrackSource",
  25418. "createMutableFile",
  25419. "createNSResolver",
  25420. "createNodeIterator",
  25421. "createNotification",
  25422. "createObjectStore",
  25423. "createObjectURL",
  25424. "createOffer",
  25425. "createOscillator",
  25426. "createPanner",
  25427. "createPattern",
  25428. "createPeriodicWave",
  25429. "createPolicy",
  25430. "createPopup",
  25431. "createProcessingInstruction",
  25432. "createProgram",
  25433. "createQuery",
  25434. "createRadialGradient",
  25435. "createRange",
  25436. "createRangeCollection",
  25437. "createReader",
  25438. "createRenderbuffer",
  25439. "createSVGAngle",
  25440. "createSVGLength",
  25441. "createSVGMatrix",
  25442. "createSVGNumber",
  25443. "createSVGPathSegArcAbs",
  25444. "createSVGPathSegArcRel",
  25445. "createSVGPathSegClosePath",
  25446. "createSVGPathSegCurvetoCubicAbs",
  25447. "createSVGPathSegCurvetoCubicRel",
  25448. "createSVGPathSegCurvetoCubicSmoothAbs",
  25449. "createSVGPathSegCurvetoCubicSmoothRel",
  25450. "createSVGPathSegCurvetoQuadraticAbs",
  25451. "createSVGPathSegCurvetoQuadraticRel",
  25452. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  25453. "createSVGPathSegCurvetoQuadraticSmoothRel",
  25454. "createSVGPathSegLinetoAbs",
  25455. "createSVGPathSegLinetoHorizontalAbs",
  25456. "createSVGPathSegLinetoHorizontalRel",
  25457. "createSVGPathSegLinetoRel",
  25458. "createSVGPathSegLinetoVerticalAbs",
  25459. "createSVGPathSegLinetoVerticalRel",
  25460. "createSVGPathSegMovetoAbs",
  25461. "createSVGPathSegMovetoRel",
  25462. "createSVGPoint",
  25463. "createSVGRect",
  25464. "createSVGTransform",
  25465. "createSVGTransformFromMatrix",
  25466. "createSampler",
  25467. "createScript",
  25468. "createScriptProcessor",
  25469. "createScriptURL",
  25470. "createSession",
  25471. "createShader",
  25472. "createShadowRoot",
  25473. "createStereoPanner",
  25474. "createStyleSheet",
  25475. "createTBody",
  25476. "createTFoot",
  25477. "createTHead",
  25478. "createTextNode",
  25479. "createTextRange",
  25480. "createTexture",
  25481. "createTouch",
  25482. "createTouchList",
  25483. "createTransformFeedback",
  25484. "createTreeWalker",
  25485. "createVertexArray",
  25486. "createWaveShaper",
  25487. "creationTime",
  25488. "credentials",
  25489. "crossOrigin",
  25490. "crossOriginIsolated",
  25491. "crypto",
  25492. "csi",
  25493. "csp",
  25494. "cssFloat",
  25495. "cssRules",
  25496. "cssText",
  25497. "cssValueType",
  25498. "ctrlKey",
  25499. "ctrlLeft",
  25500. "cues",
  25501. "cullFace",
  25502. "currentDirection",
  25503. "currentLocalDescription",
  25504. "currentNode",
  25505. "currentPage",
  25506. "currentRect",
  25507. "currentRemoteDescription",
  25508. "currentScale",
  25509. "currentScript",
  25510. "currentSrc",
  25511. "currentState",
  25512. "currentStyle",
  25513. "currentTarget",
  25514. "currentTime",
  25515. "currentTranslate",
  25516. "currentView",
  25517. "cursor",
  25518. "curve",
  25519. "customElements",
  25520. "customError",
  25521. "cx",
  25522. "cy",
  25523. "d",
  25524. "data",
  25525. "dataFld",
  25526. "dataFormatAs",
  25527. "dataLoss",
  25528. "dataLossMessage",
  25529. "dataPageSize",
  25530. "dataSrc",
  25531. "dataTransfer",
  25532. "database",
  25533. "databases",
  25534. "dataset",
  25535. "dateTime",
  25536. "db",
  25537. "debug",
  25538. "debuggerEnabled",
  25539. "declare",
  25540. "decode",
  25541. "decodeAudioData",
  25542. "decodeURI",
  25543. "decodeURIComponent",
  25544. "decodedBodySize",
  25545. "decoding",
  25546. "decodingInfo",
  25547. "decrypt",
  25548. "default",
  25549. "defaultCharset",
  25550. "defaultChecked",
  25551. "defaultMuted",
  25552. "defaultPlaybackRate",
  25553. "defaultPolicy",
  25554. "defaultPrevented",
  25555. "defaultRequest",
  25556. "defaultSelected",
  25557. "defaultStatus",
  25558. "defaultURL",
  25559. "defaultValue",
  25560. "defaultView",
  25561. "defaultstatus",
  25562. "defer",
  25563. "define",
  25564. "defineMagicFunction",
  25565. "defineMagicVariable",
  25566. "defineProperties",
  25567. "defineProperty",
  25568. "deg",
  25569. "delay",
  25570. "delayTime",
  25571. "delegatesFocus",
  25572. "delete",
  25573. "deleteBuffer",
  25574. "deleteCaption",
  25575. "deleteCell",
  25576. "deleteContents",
  25577. "deleteData",
  25578. "deleteDatabase",
  25579. "deleteFramebuffer",
  25580. "deleteFromDocument",
  25581. "deleteIndex",
  25582. "deleteMedium",
  25583. "deleteObjectStore",
  25584. "deleteProgram",
  25585. "deleteProperty",
  25586. "deleteQuery",
  25587. "deleteRenderbuffer",
  25588. "deleteRow",
  25589. "deleteRule",
  25590. "deleteSampler",
  25591. "deleteShader",
  25592. "deleteSync",
  25593. "deleteTFoot",
  25594. "deleteTHead",
  25595. "deleteTexture",
  25596. "deleteTransformFeedback",
  25597. "deleteVertexArray",
  25598. "deliverChangeRecords",
  25599. "delivery",
  25600. "deliveryInfo",
  25601. "deliveryStatus",
  25602. "deliveryTimestamp",
  25603. "delta",
  25604. "deltaMode",
  25605. "deltaX",
  25606. "deltaY",
  25607. "deltaZ",
  25608. "dependentLocality",
  25609. "depthFar",
  25610. "depthFunc",
  25611. "depthMask",
  25612. "depthNear",
  25613. "depthRange",
  25614. "deref",
  25615. "deriveBits",
  25616. "deriveKey",
  25617. "description",
  25618. "deselectAll",
  25619. "designMode",
  25620. "desiredSize",
  25621. "destination",
  25622. "destinationURL",
  25623. "detach",
  25624. "detachEvent",
  25625. "detachShader",
  25626. "detail",
  25627. "details",
  25628. "detect",
  25629. "detune",
  25630. "device",
  25631. "deviceClass",
  25632. "deviceId",
  25633. "deviceMemory",
  25634. "devicePixelContentBoxSize",
  25635. "devicePixelRatio",
  25636. "deviceProtocol",
  25637. "deviceSubclass",
  25638. "deviceVersionMajor",
  25639. "deviceVersionMinor",
  25640. "deviceVersionSubminor",
  25641. "deviceXDPI",
  25642. "deviceYDPI",
  25643. "didTimeout",
  25644. "diffuseConstant",
  25645. "digest",
  25646. "dimensions",
  25647. "dir",
  25648. "dirName",
  25649. "direction",
  25650. "dirxml",
  25651. "disable",
  25652. "disablePictureInPicture",
  25653. "disableRemotePlayback",
  25654. "disableVertexAttribArray",
  25655. "disabled",
  25656. "dischargingTime",
  25657. "disconnect",
  25658. "disconnectShark",
  25659. "dispatchEvent",
  25660. "display",
  25661. "displayId",
  25662. "displayName",
  25663. "disposition",
  25664. "distanceModel",
  25665. "div",
  25666. "divisor",
  25667. "djsapi",
  25668. "djsproxy",
  25669. "doImport",
  25670. "doNotTrack",
  25671. "doScroll",
  25672. "doctype",
  25673. "document",
  25674. "documentElement",
  25675. "documentMode",
  25676. "documentURI",
  25677. "dolphin",
  25678. "dolphinGameCenter",
  25679. "dolphininfo",
  25680. "dolphinmeta",
  25681. "domComplete",
  25682. "domContentLoadedEventEnd",
  25683. "domContentLoadedEventStart",
  25684. "domInteractive",
  25685. "domLoading",
  25686. "domOverlayState",
  25687. "domain",
  25688. "domainLookupEnd",
  25689. "domainLookupStart",
  25690. "dominant-baseline",
  25691. "dominantBaseline",
  25692. "done",
  25693. "dopplerFactor",
  25694. "dotAll",
  25695. "downDegrees",
  25696. "downlink",
  25697. "download",
  25698. "downloadTotal",
  25699. "downloaded",
  25700. "dpcm",
  25701. "dpi",
  25702. "dppx",
  25703. "dragDrop",
  25704. "draggable",
  25705. "drawArrays",
  25706. "drawArraysInstanced",
  25707. "drawArraysInstancedANGLE",
  25708. "drawBuffers",
  25709. "drawCustomFocusRing",
  25710. "drawElements",
  25711. "drawElementsInstanced",
  25712. "drawElementsInstancedANGLE",
  25713. "drawFocusIfNeeded",
  25714. "drawImage",
  25715. "drawImageFromRect",
  25716. "drawRangeElements",
  25717. "drawSystemFocusRing",
  25718. "drawingBufferHeight",
  25719. "drawingBufferWidth",
  25720. "dropEffect",
  25721. "droppedVideoFrames",
  25722. "dropzone",
  25723. "dtmf",
  25724. "dump",
  25725. "dumpProfile",
  25726. "duplicate",
  25727. "durability",
  25728. "duration",
  25729. "dvname",
  25730. "dvnum",
  25731. "dx",
  25732. "dy",
  25733. "dynsrc",
  25734. "e",
  25735. "edgeMode",
  25736. "effect",
  25737. "effectAllowed",
  25738. "effectiveDirective",
  25739. "effectiveType",
  25740. "elapsedTime",
  25741. "element",
  25742. "elementFromPoint",
  25743. "elementTiming",
  25744. "elements",
  25745. "elementsFromPoint",
  25746. "elevation",
  25747. "ellipse",
  25748. "em",
  25749. "email",
  25750. "embeds",
  25751. "emma",
  25752. "empty",
  25753. "empty-cells",
  25754. "emptyCells",
  25755. "emptyHTML",
  25756. "emptyScript",
  25757. "emulatedPosition",
  25758. "enable",
  25759. "enableBackground",
  25760. "enableDelegations",
  25761. "enableStyleSheetsForSet",
  25762. "enableVertexAttribArray",
  25763. "enabled",
  25764. "enabledPlugin",
  25765. "encode",
  25766. "encodeInto",
  25767. "encodeURI",
  25768. "encodeURIComponent",
  25769. "encodedBodySize",
  25770. "encoding",
  25771. "encodingInfo",
  25772. "encrypt",
  25773. "enctype",
  25774. "end",
  25775. "endContainer",
  25776. "endElement",
  25777. "endElementAt",
  25778. "endOfStream",
  25779. "endOffset",
  25780. "endQuery",
  25781. "endTime",
  25782. "endTransformFeedback",
  25783. "ended",
  25784. "endpoint",
  25785. "endpointNumber",
  25786. "endpoints",
  25787. "endsWith",
  25788. "enterKeyHint",
  25789. "entities",
  25790. "entries",
  25791. "entryType",
  25792. "enumerate",
  25793. "enumerateDevices",
  25794. "enumerateEditable",
  25795. "environmentBlendMode",
  25796. "equals",
  25797. "error",
  25798. "errorCode",
  25799. "errorDetail",
  25800. "errorText",
  25801. "escape",
  25802. "estimate",
  25803. "eval",
  25804. "evaluate",
  25805. "event",
  25806. "eventPhase",
  25807. "every",
  25808. "ex",
  25809. "exception",
  25810. "exchange",
  25811. "exec",
  25812. "execCommand",
  25813. "execCommandShowHelp",
  25814. "execScript",
  25815. "exitFullscreen",
  25816. "exitPictureInPicture",
  25817. "exitPointerLock",
  25818. "exitPresent",
  25819. "exp",
  25820. "expand",
  25821. "expandEntityReferences",
  25822. "expando",
  25823. "expansion",
  25824. "expiration",
  25825. "expirationTime",
  25826. "expires",
  25827. "expiryDate",
  25828. "explicitOriginalTarget",
  25829. "expm1",
  25830. "exponent",
  25831. "exponentialRampToValueAtTime",
  25832. "exportKey",
  25833. "exports",
  25834. "extend",
  25835. "extensions",
  25836. "extentNode",
  25837. "extentOffset",
  25838. "external",
  25839. "externalResourcesRequired",
  25840. "extractContents",
  25841. "extractable",
  25842. "eye",
  25843. "f",
  25844. "face",
  25845. "factoryReset",
  25846. "failureReason",
  25847. "fallback",
  25848. "family",
  25849. "familyName",
  25850. "farthestViewportElement",
  25851. "fastSeek",
  25852. "fatal",
  25853. "featureId",
  25854. "featurePolicy",
  25855. "featureSettings",
  25856. "features",
  25857. "fenceSync",
  25858. "fetch",
  25859. "fetchStart",
  25860. "fftSize",
  25861. "fgColor",
  25862. "fieldOfView",
  25863. "file",
  25864. "fileCreatedDate",
  25865. "fileHandle",
  25866. "fileModifiedDate",
  25867. "fileName",
  25868. "fileSize",
  25869. "fileUpdatedDate",
  25870. "filename",
  25871. "files",
  25872. "filesystem",
  25873. "fill",
  25874. "fill-opacity",
  25875. "fill-rule",
  25876. "fillLightMode",
  25877. "fillOpacity",
  25878. "fillRect",
  25879. "fillRule",
  25880. "fillStyle",
  25881. "fillText",
  25882. "filter",
  25883. "filterResX",
  25884. "filterResY",
  25885. "filterUnits",
  25886. "filters",
  25887. "finally",
  25888. "find",
  25889. "findIndex",
  25890. "findRule",
  25891. "findText",
  25892. "finish",
  25893. "finished",
  25894. "fireEvent",
  25895. "firesTouchEvents",
  25896. "firstChild",
  25897. "firstElementChild",
  25898. "firstPage",
  25899. "fixed",
  25900. "flags",
  25901. "flat",
  25902. "flatMap",
  25903. "flex",
  25904. "flex-basis",
  25905. "flex-direction",
  25906. "flex-flow",
  25907. "flex-grow",
  25908. "flex-shrink",
  25909. "flex-wrap",
  25910. "flexBasis",
  25911. "flexDirection",
  25912. "flexFlow",
  25913. "flexGrow",
  25914. "flexShrink",
  25915. "flexWrap",
  25916. "flipX",
  25917. "flipY",
  25918. "float",
  25919. "float32",
  25920. "float64",
  25921. "flood-color",
  25922. "flood-opacity",
  25923. "floodColor",
  25924. "floodOpacity",
  25925. "floor",
  25926. "flush",
  25927. "focus",
  25928. "focusNode",
  25929. "focusOffset",
  25930. "font",
  25931. "font-family",
  25932. "font-feature-settings",
  25933. "font-kerning",
  25934. "font-language-override",
  25935. "font-optical-sizing",
  25936. "font-size",
  25937. "font-size-adjust",
  25938. "font-stretch",
  25939. "font-style",
  25940. "font-synthesis",
  25941. "font-variant",
  25942. "font-variant-alternates",
  25943. "font-variant-caps",
  25944. "font-variant-east-asian",
  25945. "font-variant-ligatures",
  25946. "font-variant-numeric",
  25947. "font-variant-position",
  25948. "font-variation-settings",
  25949. "font-weight",
  25950. "fontFamily",
  25951. "fontFeatureSettings",
  25952. "fontKerning",
  25953. "fontLanguageOverride",
  25954. "fontOpticalSizing",
  25955. "fontSize",
  25956. "fontSizeAdjust",
  25957. "fontSmoothingEnabled",
  25958. "fontStretch",
  25959. "fontStyle",
  25960. "fontSynthesis",
  25961. "fontVariant",
  25962. "fontVariantAlternates",
  25963. "fontVariantCaps",
  25964. "fontVariantEastAsian",
  25965. "fontVariantLigatures",
  25966. "fontVariantNumeric",
  25967. "fontVariantPosition",
  25968. "fontVariationSettings",
  25969. "fontWeight",
  25970. "fontcolor",
  25971. "fontfaces",
  25972. "fonts",
  25973. "fontsize",
  25974. "for",
  25975. "forEach",
  25976. "force",
  25977. "forceRedraw",
  25978. "form",
  25979. "formAction",
  25980. "formData",
  25981. "formEnctype",
  25982. "formMethod",
  25983. "formNoValidate",
  25984. "formTarget",
  25985. "format",
  25986. "formatToParts",
  25987. "forms",
  25988. "forward",
  25989. "forwardX",
  25990. "forwardY",
  25991. "forwardZ",
  25992. "foundation",
  25993. "fr",
  25994. "fragmentDirective",
  25995. "frame",
  25996. "frameBorder",
  25997. "frameElement",
  25998. "frameSpacing",
  25999. "framebuffer",
  26000. "framebufferHeight",
  26001. "framebufferRenderbuffer",
  26002. "framebufferTexture2D",
  26003. "framebufferTextureLayer",
  26004. "framebufferWidth",
  26005. "frames",
  26006. "freeSpace",
  26007. "freeze",
  26008. "frequency",
  26009. "frequencyBinCount",
  26010. "from",
  26011. "fromCharCode",
  26012. "fromCodePoint",
  26013. "fromElement",
  26014. "fromEntries",
  26015. "fromFloat32Array",
  26016. "fromFloat64Array",
  26017. "fromMatrix",
  26018. "fromPoint",
  26019. "fromQuad",
  26020. "fromRect",
  26021. "frontFace",
  26022. "fround",
  26023. "fullPath",
  26024. "fullScreen",
  26025. "fullVersionList",
  26026. "fullscreen",
  26027. "fullscreenElement",
  26028. "fullscreenEnabled",
  26029. "fx",
  26030. "fy",
  26031. "gain",
  26032. "gamepad",
  26033. "gamma",
  26034. "gap",
  26035. "gatheringState",
  26036. "gatt",
  26037. "genderIdentity",
  26038. "generateCertificate",
  26039. "generateKey",
  26040. "generateMipmap",
  26041. "generateRequest",
  26042. "geolocation",
  26043. "gestureObject",
  26044. "get",
  26045. "getActiveAttrib",
  26046. "getActiveUniform",
  26047. "getActiveUniformBlockName",
  26048. "getActiveUniformBlockParameter",
  26049. "getActiveUniforms",
  26050. "getAdjacentText",
  26051. "getAll",
  26052. "getAllKeys",
  26053. "getAllResponseHeaders",
  26054. "getAllowlistForFeature",
  26055. "getAnimations",
  26056. "getAsFile",
  26057. "getAsString",
  26058. "getAttachedShaders",
  26059. "getAttribLocation",
  26060. "getAttribute",
  26061. "getAttributeNS",
  26062. "getAttributeNames",
  26063. "getAttributeNode",
  26064. "getAttributeNodeNS",
  26065. "getAttributeType",
  26066. "getAudioTracks",
  26067. "getAvailability",
  26068. "getBBox",
  26069. "getBattery",
  26070. "getBigInt64",
  26071. "getBigUint64",
  26072. "getBlob",
  26073. "getBookmark",
  26074. "getBoundingClientRect",
  26075. "getBounds",
  26076. "getBoxQuads",
  26077. "getBufferParameter",
  26078. "getBufferSubData",
  26079. "getByteFrequencyData",
  26080. "getByteTimeDomainData",
  26081. "getCSSCanvasContext",
  26082. "getCTM",
  26083. "getCandidateWindowClientRect",
  26084. "getCanonicalLocales",
  26085. "getCapabilities",
  26086. "getChannelData",
  26087. "getCharNumAtPosition",
  26088. "getCharacteristic",
  26089. "getCharacteristics",
  26090. "getClientExtensionResults",
  26091. "getClientRect",
  26092. "getClientRects",
  26093. "getCoalescedEvents",
  26094. "getCompositionAlternatives",
  26095. "getComputedStyle",
  26096. "getComputedTextLength",
  26097. "getComputedTiming",
  26098. "getConfiguration",
  26099. "getConstraints",
  26100. "getContext",
  26101. "getContextAttributes",
  26102. "getContributingSources",
  26103. "getCounterValue",
  26104. "getCueAsHTML",
  26105. "getCueById",
  26106. "getCurrentPosition",
  26107. "getCurrentTime",
  26108. "getData",
  26109. "getDatabaseNames",
  26110. "getDate",
  26111. "getDay",
  26112. "getDefaultComputedStyle",
  26113. "getDescriptor",
  26114. "getDescriptors",
  26115. "getDestinationInsertionPoints",
  26116. "getDevices",
  26117. "getDirectory",
  26118. "getDisplayMedia",
  26119. "getDistributedNodes",
  26120. "getEditable",
  26121. "getElementById",
  26122. "getElementsByClassName",
  26123. "getElementsByName",
  26124. "getElementsByTagName",
  26125. "getElementsByTagNameNS",
  26126. "getEnclosureList",
  26127. "getEndPositionOfChar",
  26128. "getEntries",
  26129. "getEntriesByName",
  26130. "getEntriesByType",
  26131. "getError",
  26132. "getExtension",
  26133. "getExtentOfChar",
  26134. "getEyeParameters",
  26135. "getFeature",
  26136. "getFile",
  26137. "getFiles",
  26138. "getFilesAndDirectories",
  26139. "getFingerprints",
  26140. "getFloat32",
  26141. "getFloat64",
  26142. "getFloatFrequencyData",
  26143. "getFloatTimeDomainData",
  26144. "getFloatValue",
  26145. "getFragDataLocation",
  26146. "getFrameData",
  26147. "getFramebufferAttachmentParameter",
  26148. "getFrequencyResponse",
  26149. "getFullYear",
  26150. "getGamepads",
  26151. "getHighEntropyValues",
  26152. "getHitTestResults",
  26153. "getHitTestResultsForTransientInput",
  26154. "getHours",
  26155. "getIdentityAssertion",
  26156. "getIds",
  26157. "getImageData",
  26158. "getIndexedParameter",
  26159. "getInstalledRelatedApps",
  26160. "getInt16",
  26161. "getInt32",
  26162. "getInt8",
  26163. "getInternalformatParameter",
  26164. "getIntersectionList",
  26165. "getItem",
  26166. "getItems",
  26167. "getKey",
  26168. "getKeyframes",
  26169. "getLayers",
  26170. "getLayoutMap",
  26171. "getLineDash",
  26172. "getLocalCandidates",
  26173. "getLocalParameters",
  26174. "getLocalStreams",
  26175. "getMarks",
  26176. "getMatchedCSSRules",
  26177. "getMaxGCPauseSinceClear",
  26178. "getMeasures",
  26179. "getMetadata",
  26180. "getMilliseconds",
  26181. "getMinutes",
  26182. "getModifierState",
  26183. "getMonth",
  26184. "getNamedItem",
  26185. "getNamedItemNS",
  26186. "getNativeFramebufferScaleFactor",
  26187. "getNotifications",
  26188. "getNotifier",
  26189. "getNumberOfChars",
  26190. "getOffsetReferenceSpace",
  26191. "getOutputTimestamp",
  26192. "getOverrideHistoryNavigationMode",
  26193. "getOverrideStyle",
  26194. "getOwnPropertyDescriptor",
  26195. "getOwnPropertyDescriptors",
  26196. "getOwnPropertyNames",
  26197. "getOwnPropertySymbols",
  26198. "getParameter",
  26199. "getParameters",
  26200. "getParent",
  26201. "getPathSegAtLength",
  26202. "getPhotoCapabilities",
  26203. "getPhotoSettings",
  26204. "getPointAtLength",
  26205. "getPose",
  26206. "getPredictedEvents",
  26207. "getPreference",
  26208. "getPreferenceDefault",
  26209. "getPresentationAttribute",
  26210. "getPreventDefault",
  26211. "getPrimaryService",
  26212. "getPrimaryServices",
  26213. "getProgramInfoLog",
  26214. "getProgramParameter",
  26215. "getPropertyCSSValue",
  26216. "getPropertyPriority",
  26217. "getPropertyShorthand",
  26218. "getPropertyType",
  26219. "getPropertyValue",
  26220. "getPrototypeOf",
  26221. "getQuery",
  26222. "getQueryParameter",
  26223. "getRGBColorValue",
  26224. "getRandomValues",
  26225. "getRangeAt",
  26226. "getReader",
  26227. "getReceivers",
  26228. "getRectValue",
  26229. "getRegistration",
  26230. "getRegistrations",
  26231. "getRemoteCandidates",
  26232. "getRemoteCertificates",
  26233. "getRemoteParameters",
  26234. "getRemoteStreams",
  26235. "getRenderbufferParameter",
  26236. "getResponseHeader",
  26237. "getRoot",
  26238. "getRootNode",
  26239. "getRotationOfChar",
  26240. "getSVGDocument",
  26241. "getSamplerParameter",
  26242. "getScreenCTM",
  26243. "getSeconds",
  26244. "getSelectedCandidatePair",
  26245. "getSelection",
  26246. "getSenders",
  26247. "getService",
  26248. "getSettings",
  26249. "getShaderInfoLog",
  26250. "getShaderParameter",
  26251. "getShaderPrecisionFormat",
  26252. "getShaderSource",
  26253. "getSimpleDuration",
  26254. "getSiteIcons",
  26255. "getSources",
  26256. "getSpeculativeParserUrls",
  26257. "getStartPositionOfChar",
  26258. "getStartTime",
  26259. "getState",
  26260. "getStats",
  26261. "getStatusForPolicy",
  26262. "getStorageUpdates",
  26263. "getStreamById",
  26264. "getStringValue",
  26265. "getSubStringLength",
  26266. "getSubscription",
  26267. "getSupportedConstraints",
  26268. "getSupportedExtensions",
  26269. "getSupportedFormats",
  26270. "getSyncParameter",
  26271. "getSynchronizationSources",
  26272. "getTags",
  26273. "getTargetRanges",
  26274. "getTexParameter",
  26275. "getTime",
  26276. "getTimezoneOffset",
  26277. "getTiming",
  26278. "getTotalLength",
  26279. "getTrackById",
  26280. "getTracks",
  26281. "getTransceivers",
  26282. "getTransform",
  26283. "getTransformFeedbackVarying",
  26284. "getTransformToElement",
  26285. "getTransports",
  26286. "getType",
  26287. "getTypeMapping",
  26288. "getUTCDate",
  26289. "getUTCDay",
  26290. "getUTCFullYear",
  26291. "getUTCHours",
  26292. "getUTCMilliseconds",
  26293. "getUTCMinutes",
  26294. "getUTCMonth",
  26295. "getUTCSeconds",
  26296. "getUint16",
  26297. "getUint32",
  26298. "getUint8",
  26299. "getUniform",
  26300. "getUniformBlockIndex",
  26301. "getUniformIndices",
  26302. "getUniformLocation",
  26303. "getUserMedia",
  26304. "getVRDisplays",
  26305. "getValues",
  26306. "getVarDate",
  26307. "getVariableValue",
  26308. "getVertexAttrib",
  26309. "getVertexAttribOffset",
  26310. "getVideoPlaybackQuality",
  26311. "getVideoTracks",
  26312. "getViewerPose",
  26313. "getViewport",
  26314. "getVoices",
  26315. "getWakeLockState",
  26316. "getWriter",
  26317. "getYear",
  26318. "givenName",
  26319. "global",
  26320. "globalAlpha",
  26321. "globalCompositeOperation",
  26322. "globalThis",
  26323. "glyphOrientationHorizontal",
  26324. "glyphOrientationVertical",
  26325. "glyphRef",
  26326. "go",
  26327. "grabFrame",
  26328. "grad",
  26329. "gradientTransform",
  26330. "gradientUnits",
  26331. "grammars",
  26332. "green",
  26333. "grid",
  26334. "grid-area",
  26335. "grid-auto-columns",
  26336. "grid-auto-flow",
  26337. "grid-auto-rows",
  26338. "grid-column",
  26339. "grid-column-end",
  26340. "grid-column-gap",
  26341. "grid-column-start",
  26342. "grid-gap",
  26343. "grid-row",
  26344. "grid-row-end",
  26345. "grid-row-gap",
  26346. "grid-row-start",
  26347. "grid-template",
  26348. "grid-template-areas",
  26349. "grid-template-columns",
  26350. "grid-template-rows",
  26351. "gridArea",
  26352. "gridAutoColumns",
  26353. "gridAutoFlow",
  26354. "gridAutoRows",
  26355. "gridColumn",
  26356. "gridColumnEnd",
  26357. "gridColumnGap",
  26358. "gridColumnStart",
  26359. "gridGap",
  26360. "gridRow",
  26361. "gridRowEnd",
  26362. "gridRowGap",
  26363. "gridRowStart",
  26364. "gridTemplate",
  26365. "gridTemplateAreas",
  26366. "gridTemplateColumns",
  26367. "gridTemplateRows",
  26368. "gripSpace",
  26369. "group",
  26370. "groupCollapsed",
  26371. "groupEnd",
  26372. "groupId",
  26373. "hadRecentInput",
  26374. "hand",
  26375. "handedness",
  26376. "hapticActuators",
  26377. "hardwareConcurrency",
  26378. "has",
  26379. "hasAttribute",
  26380. "hasAttributeNS",
  26381. "hasAttributes",
  26382. "hasBeenActive",
  26383. "hasChildNodes",
  26384. "hasComposition",
  26385. "hasEnrolledInstrument",
  26386. "hasExtension",
  26387. "hasExternalDisplay",
  26388. "hasFeature",
  26389. "hasFocus",
  26390. "hasInstance",
  26391. "hasLayout",
  26392. "hasOrientation",
  26393. "hasOwnProperty",
  26394. "hasPointerCapture",
  26395. "hasPosition",
  26396. "hasReading",
  26397. "hasStorageAccess",
  26398. "hash",
  26399. "head",
  26400. "headers",
  26401. "heading",
  26402. "height",
  26403. "hidden",
  26404. "hide",
  26405. "hideFocus",
  26406. "high",
  26407. "highWaterMark",
  26408. "hint",
  26409. "history",
  26410. "honorificPrefix",
  26411. "honorificSuffix",
  26412. "horizontalOverflow",
  26413. "host",
  26414. "hostCandidate",
  26415. "hostname",
  26416. "href",
  26417. "hrefTranslate",
  26418. "hreflang",
  26419. "hspace",
  26420. "html5TagCheckInerface",
  26421. "htmlFor",
  26422. "htmlText",
  26423. "httpEquiv",
  26424. "httpRequestStatusCode",
  26425. "hwTimestamp",
  26426. "hyphens",
  26427. "hypot",
  26428. "iccId",
  26429. "iceConnectionState",
  26430. "iceGatheringState",
  26431. "iceTransport",
  26432. "icon",
  26433. "iconURL",
  26434. "id",
  26435. "identifier",
  26436. "identity",
  26437. "idpLoginUrl",
  26438. "ignoreBOM",
  26439. "ignoreCase",
  26440. "ignoreDepthValues",
  26441. "image-orientation",
  26442. "image-rendering",
  26443. "imageHeight",
  26444. "imageOrientation",
  26445. "imageRendering",
  26446. "imageSizes",
  26447. "imageSmoothingEnabled",
  26448. "imageSmoothingQuality",
  26449. "imageSrcset",
  26450. "imageWidth",
  26451. "images",
  26452. "ime-mode",
  26453. "imeMode",
  26454. "implementation",
  26455. "importKey",
  26456. "importNode",
  26457. "importStylesheet",
  26458. "imports",
  26459. "impp",
  26460. "imul",
  26461. "in",
  26462. "in1",
  26463. "in2",
  26464. "inBandMetadataTrackDispatchType",
  26465. "inRange",
  26466. "includes",
  26467. "incremental",
  26468. "indeterminate",
  26469. "index",
  26470. "indexNames",
  26471. "indexOf",
  26472. "indexedDB",
  26473. "indicate",
  26474. "inertiaDestinationX",
  26475. "inertiaDestinationY",
  26476. "info",
  26477. "init",
  26478. "initAnimationEvent",
  26479. "initBeforeLoadEvent",
  26480. "initClipboardEvent",
  26481. "initCloseEvent",
  26482. "initCommandEvent",
  26483. "initCompositionEvent",
  26484. "initCustomEvent",
  26485. "initData",
  26486. "initDataType",
  26487. "initDeviceMotionEvent",
  26488. "initDeviceOrientationEvent",
  26489. "initDragEvent",
  26490. "initErrorEvent",
  26491. "initEvent",
  26492. "initFocusEvent",
  26493. "initGestureEvent",
  26494. "initHashChangeEvent",
  26495. "initKeyEvent",
  26496. "initKeyboardEvent",
  26497. "initMSManipulationEvent",
  26498. "initMessageEvent",
  26499. "initMouseEvent",
  26500. "initMouseScrollEvent",
  26501. "initMouseWheelEvent",
  26502. "initMutationEvent",
  26503. "initNSMouseEvent",
  26504. "initOverflowEvent",
  26505. "initPageEvent",
  26506. "initPageTransitionEvent",
  26507. "initPointerEvent",
  26508. "initPopStateEvent",
  26509. "initProgressEvent",
  26510. "initScrollAreaEvent",
  26511. "initSimpleGestureEvent",
  26512. "initStorageEvent",
  26513. "initTextEvent",
  26514. "initTimeEvent",
  26515. "initTouchEvent",
  26516. "initTransitionEvent",
  26517. "initUIEvent",
  26518. "initWebKitAnimationEvent",
  26519. "initWebKitTransitionEvent",
  26520. "initWebKitWheelEvent",
  26521. "initWheelEvent",
  26522. "initialTime",
  26523. "initialize",
  26524. "initiatorType",
  26525. "inline-size",
  26526. "inlineSize",
  26527. "inlineVerticalFieldOfView",
  26528. "inner",
  26529. "innerHTML",
  26530. "innerHeight",
  26531. "innerText",
  26532. "innerWidth",
  26533. "input",
  26534. "inputBuffer",
  26535. "inputEncoding",
  26536. "inputMethod",
  26537. "inputMode",
  26538. "inputSource",
  26539. "inputSources",
  26540. "inputType",
  26541. "inputs",
  26542. "insertAdjacentElement",
  26543. "insertAdjacentHTML",
  26544. "insertAdjacentText",
  26545. "insertBefore",
  26546. "insertCell",
  26547. "insertDTMF",
  26548. "insertData",
  26549. "insertItemBefore",
  26550. "insertNode",
  26551. "insertRow",
  26552. "insertRule",
  26553. "inset",
  26554. "inset-block",
  26555. "inset-block-end",
  26556. "inset-block-start",
  26557. "inset-inline",
  26558. "inset-inline-end",
  26559. "inset-inline-start",
  26560. "insetBlock",
  26561. "insetBlockEnd",
  26562. "insetBlockStart",
  26563. "insetInline",
  26564. "insetInlineEnd",
  26565. "insetInlineStart",
  26566. "installing",
  26567. "instanceRoot",
  26568. "instantiate",
  26569. "instantiateStreaming",
  26570. "instruments",
  26571. "int16",
  26572. "int32",
  26573. "int8",
  26574. "integrity",
  26575. "interactionMode",
  26576. "intercept",
  26577. "interfaceClass",
  26578. "interfaceName",
  26579. "interfaceNumber",
  26580. "interfaceProtocol",
  26581. "interfaceSubclass",
  26582. "interfaces",
  26583. "interimResults",
  26584. "internalSubset",
  26585. "interpretation",
  26586. "intersectionRatio",
  26587. "intersectionRect",
  26588. "intersectsNode",
  26589. "interval",
  26590. "invalidIteratorState",
  26591. "invalidateFramebuffer",
  26592. "invalidateSubFramebuffer",
  26593. "inverse",
  26594. "invertSelf",
  26595. "is",
  26596. "is2D",
  26597. "isActive",
  26598. "isAlternate",
  26599. "isArray",
  26600. "isBingCurrentSearchDefault",
  26601. "isBuffer",
  26602. "isCandidateWindowVisible",
  26603. "isChar",
  26604. "isCollapsed",
  26605. "isComposing",
  26606. "isConcatSpreadable",
  26607. "isConnected",
  26608. "isContentEditable",
  26609. "isContentHandlerRegistered",
  26610. "isContextLost",
  26611. "isDefaultNamespace",
  26612. "isDirectory",
  26613. "isDisabled",
  26614. "isEnabled",
  26615. "isEqual",
  26616. "isEqualNode",
  26617. "isExtensible",
  26618. "isExternalCTAP2SecurityKeySupported",
  26619. "isFile",
  26620. "isFinite",
  26621. "isFramebuffer",
  26622. "isFrozen",
  26623. "isGenerator",
  26624. "isHTML",
  26625. "isHistoryNavigation",
  26626. "isId",
  26627. "isIdentity",
  26628. "isInjected",
  26629. "isInteger",
  26630. "isIntersecting",
  26631. "isLockFree",
  26632. "isMap",
  26633. "isMultiLine",
  26634. "isNaN",
  26635. "isOpen",
  26636. "isPointInFill",
  26637. "isPointInPath",
  26638. "isPointInRange",
  26639. "isPointInStroke",
  26640. "isPrefAlternate",
  26641. "isPresenting",
  26642. "isPrimary",
  26643. "isProgram",
  26644. "isPropertyImplicit",
  26645. "isProtocolHandlerRegistered",
  26646. "isPrototypeOf",
  26647. "isQuery",
  26648. "isRenderbuffer",
  26649. "isSafeInteger",
  26650. "isSameNode",
  26651. "isSampler",
  26652. "isScript",
  26653. "isScriptURL",
  26654. "isSealed",
  26655. "isSecureContext",
  26656. "isSessionSupported",
  26657. "isShader",
  26658. "isSupported",
  26659. "isSync",
  26660. "isTextEdit",
  26661. "isTexture",
  26662. "isTransformFeedback",
  26663. "isTrusted",
  26664. "isTypeSupported",
  26665. "isUserVerifyingPlatformAuthenticatorAvailable",
  26666. "isVertexArray",
  26667. "isView",
  26668. "isVisible",
  26669. "isochronousTransferIn",
  26670. "isochronousTransferOut",
  26671. "isolation",
  26672. "italics",
  26673. "item",
  26674. "itemId",
  26675. "itemProp",
  26676. "itemRef",
  26677. "itemScope",
  26678. "itemType",
  26679. "itemValue",
  26680. "items",
  26681. "iterateNext",
  26682. "iterationComposite",
  26683. "iterator",
  26684. "javaEnabled",
  26685. "jobTitle",
  26686. "join",
  26687. "json",
  26688. "justify-content",
  26689. "justify-items",
  26690. "justify-self",
  26691. "justifyContent",
  26692. "justifyItems",
  26693. "justifySelf",
  26694. "k1",
  26695. "k2",
  26696. "k3",
  26697. "k4",
  26698. "kHz",
  26699. "keepalive",
  26700. "kernelMatrix",
  26701. "kernelUnitLengthX",
  26702. "kernelUnitLengthY",
  26703. "kerning",
  26704. "key",
  26705. "keyCode",
  26706. "keyFor",
  26707. "keyIdentifier",
  26708. "keyLightEnabled",
  26709. "keyLocation",
  26710. "keyPath",
  26711. "keyStatuses",
  26712. "keySystem",
  26713. "keyText",
  26714. "keyUsage",
  26715. "keyboard",
  26716. "keys",
  26717. "keytype",
  26718. "kind",
  26719. "knee",
  26720. "label",
  26721. "labels",
  26722. "lang",
  26723. "language",
  26724. "languages",
  26725. "largeArcFlag",
  26726. "lastChild",
  26727. "lastElementChild",
  26728. "lastEventId",
  26729. "lastIndex",
  26730. "lastIndexOf",
  26731. "lastInputTime",
  26732. "lastMatch",
  26733. "lastMessageSubject",
  26734. "lastMessageType",
  26735. "lastModified",
  26736. "lastModifiedDate",
  26737. "lastPage",
  26738. "lastParen",
  26739. "lastState",
  26740. "lastStyleSheetSet",
  26741. "latitude",
  26742. "layerX",
  26743. "layerY",
  26744. "layoutFlow",
  26745. "layoutGrid",
  26746. "layoutGridChar",
  26747. "layoutGridLine",
  26748. "layoutGridMode",
  26749. "layoutGridType",
  26750. "lbound",
  26751. "left",
  26752. "leftContext",
  26753. "leftDegrees",
  26754. "leftMargin",
  26755. "leftProjectionMatrix",
  26756. "leftViewMatrix",
  26757. "length",
  26758. "lengthAdjust",
  26759. "lengthComputable",
  26760. "letter-spacing",
  26761. "letterSpacing",
  26762. "level",
  26763. "lighting-color",
  26764. "lightingColor",
  26765. "limitingConeAngle",
  26766. "line",
  26767. "line-break",
  26768. "line-height",
  26769. "lineAlign",
  26770. "lineBreak",
  26771. "lineCap",
  26772. "lineDashOffset",
  26773. "lineHeight",
  26774. "lineJoin",
  26775. "lineNumber",
  26776. "lineTo",
  26777. "lineWidth",
  26778. "linearAcceleration",
  26779. "linearRampToValueAtTime",
  26780. "linearVelocity",
  26781. "lineno",
  26782. "lines",
  26783. "link",
  26784. "linkColor",
  26785. "linkProgram",
  26786. "links",
  26787. "list",
  26788. "list-style",
  26789. "list-style-image",
  26790. "list-style-position",
  26791. "list-style-type",
  26792. "listStyle",
  26793. "listStyleImage",
  26794. "listStylePosition",
  26795. "listStyleType",
  26796. "listener",
  26797. "load",
  26798. "loadEventEnd",
  26799. "loadEventStart",
  26800. "loadTime",
  26801. "loadTimes",
  26802. "loaded",
  26803. "loading",
  26804. "localDescription",
  26805. "localName",
  26806. "localService",
  26807. "localStorage",
  26808. "locale",
  26809. "localeCompare",
  26810. "location",
  26811. "locationbar",
  26812. "lock",
  26813. "locked",
  26814. "lockedFile",
  26815. "locks",
  26816. "log",
  26817. "log10",
  26818. "log1p",
  26819. "log2",
  26820. "logicalXDPI",
  26821. "logicalYDPI",
  26822. "longDesc",
  26823. "longitude",
  26824. "lookupNamespaceURI",
  26825. "lookupPrefix",
  26826. "loop",
  26827. "loopEnd",
  26828. "loopStart",
  26829. "looping",
  26830. "low",
  26831. "lower",
  26832. "lowerBound",
  26833. "lowerOpen",
  26834. "lowsrc",
  26835. "m11",
  26836. "m12",
  26837. "m13",
  26838. "m14",
  26839. "m21",
  26840. "m22",
  26841. "m23",
  26842. "m24",
  26843. "m31",
  26844. "m32",
  26845. "m33",
  26846. "m34",
  26847. "m41",
  26848. "m42",
  26849. "m43",
  26850. "m44",
  26851. "makeXRCompatible",
  26852. "manifest",
  26853. "manufacturer",
  26854. "manufacturerName",
  26855. "map",
  26856. "mapping",
  26857. "margin",
  26858. "margin-block",
  26859. "margin-block-end",
  26860. "margin-block-start",
  26861. "margin-bottom",
  26862. "margin-inline",
  26863. "margin-inline-end",
  26864. "margin-inline-start",
  26865. "margin-left",
  26866. "margin-right",
  26867. "margin-top",
  26868. "marginBlock",
  26869. "marginBlockEnd",
  26870. "marginBlockStart",
  26871. "marginBottom",
  26872. "marginHeight",
  26873. "marginInline",
  26874. "marginInlineEnd",
  26875. "marginInlineStart",
  26876. "marginLeft",
  26877. "marginRight",
  26878. "marginTop",
  26879. "marginWidth",
  26880. "mark",
  26881. "marker",
  26882. "marker-end",
  26883. "marker-mid",
  26884. "marker-offset",
  26885. "marker-start",
  26886. "markerEnd",
  26887. "markerHeight",
  26888. "markerMid",
  26889. "markerOffset",
  26890. "markerStart",
  26891. "markerUnits",
  26892. "markerWidth",
  26893. "marks",
  26894. "mask",
  26895. "mask-clip",
  26896. "mask-composite",
  26897. "mask-image",
  26898. "mask-mode",
  26899. "mask-origin",
  26900. "mask-position",
  26901. "mask-position-x",
  26902. "mask-position-y",
  26903. "mask-repeat",
  26904. "mask-size",
  26905. "mask-type",
  26906. "maskClip",
  26907. "maskComposite",
  26908. "maskContentUnits",
  26909. "maskImage",
  26910. "maskMode",
  26911. "maskOrigin",
  26912. "maskPosition",
  26913. "maskPositionX",
  26914. "maskPositionY",
  26915. "maskRepeat",
  26916. "maskSize",
  26917. "maskType",
  26918. "maskUnits",
  26919. "match",
  26920. "matchAll",
  26921. "matchMedia",
  26922. "matchMedium",
  26923. "matches",
  26924. "matrix",
  26925. "matrixTransform",
  26926. "max",
  26927. "max-block-size",
  26928. "max-height",
  26929. "max-inline-size",
  26930. "max-width",
  26931. "maxActions",
  26932. "maxAlternatives",
  26933. "maxBlockSize",
  26934. "maxChannelCount",
  26935. "maxChannels",
  26936. "maxConnectionsPerServer",
  26937. "maxDecibels",
  26938. "maxDistance",
  26939. "maxHeight",
  26940. "maxInlineSize",
  26941. "maxLayers",
  26942. "maxLength",
  26943. "maxMessageSize",
  26944. "maxPacketLifeTime",
  26945. "maxRetransmits",
  26946. "maxTouchPoints",
  26947. "maxValue",
  26948. "maxWidth",
  26949. "measure",
  26950. "measureText",
  26951. "media",
  26952. "mediaCapabilities",
  26953. "mediaDevices",
  26954. "mediaElement",
  26955. "mediaGroup",
  26956. "mediaKeys",
  26957. "mediaSession",
  26958. "mediaStream",
  26959. "mediaText",
  26960. "meetOrSlice",
  26961. "memory",
  26962. "menubar",
  26963. "mergeAttributes",
  26964. "message",
  26965. "messageClass",
  26966. "messageHandlers",
  26967. "messageType",
  26968. "metaKey",
  26969. "metadata",
  26970. "method",
  26971. "methodDetails",
  26972. "methodName",
  26973. "mid",
  26974. "mimeType",
  26975. "mimeTypes",
  26976. "min",
  26977. "min-block-size",
  26978. "min-height",
  26979. "min-inline-size",
  26980. "min-width",
  26981. "minBlockSize",
  26982. "minDecibels",
  26983. "minHeight",
  26984. "minInlineSize",
  26985. "minLength",
  26986. "minValue",
  26987. "minWidth",
  26988. "miterLimit",
  26989. "mix-blend-mode",
  26990. "mixBlendMode",
  26991. "mm",
  26992. "mobile",
  26993. "mode",
  26994. "model",
  26995. "modify",
  26996. "mount",
  26997. "move",
  26998. "moveBy",
  26999. "moveEnd",
  27000. "moveFirst",
  27001. "moveFocusDown",
  27002. "moveFocusLeft",
  27003. "moveFocusRight",
  27004. "moveFocusUp",
  27005. "moveNext",
  27006. "moveRow",
  27007. "moveStart",
  27008. "moveTo",
  27009. "moveToBookmark",
  27010. "moveToElementText",
  27011. "moveToPoint",
  27012. "movementX",
  27013. "movementY",
  27014. "mozAdd",
  27015. "mozAnimationStartTime",
  27016. "mozAnon",
  27017. "mozApps",
  27018. "mozAudioCaptured",
  27019. "mozAudioChannelType",
  27020. "mozAutoplayEnabled",
  27021. "mozCancelAnimationFrame",
  27022. "mozCancelFullScreen",
  27023. "mozCancelRequestAnimationFrame",
  27024. "mozCaptureStream",
  27025. "mozCaptureStreamUntilEnded",
  27026. "mozClearDataAt",
  27027. "mozContact",
  27028. "mozContacts",
  27029. "mozCreateFileHandle",
  27030. "mozCurrentTransform",
  27031. "mozCurrentTransformInverse",
  27032. "mozCursor",
  27033. "mozDash",
  27034. "mozDashOffset",
  27035. "mozDecodedFrames",
  27036. "mozExitPointerLock",
  27037. "mozFillRule",
  27038. "mozFragmentEnd",
  27039. "mozFrameDelay",
  27040. "mozFullScreen",
  27041. "mozFullScreenElement",
  27042. "mozFullScreenEnabled",
  27043. "mozGetAll",
  27044. "mozGetAllKeys",
  27045. "mozGetAsFile",
  27046. "mozGetDataAt",
  27047. "mozGetMetadata",
  27048. "mozGetUserMedia",
  27049. "mozHasAudio",
  27050. "mozHasItem",
  27051. "mozHidden",
  27052. "mozImageSmoothingEnabled",
  27053. "mozIndexedDB",
  27054. "mozInnerScreenX",
  27055. "mozInnerScreenY",
  27056. "mozInputSource",
  27057. "mozIsTextField",
  27058. "mozItem",
  27059. "mozItemCount",
  27060. "mozItems",
  27061. "mozLength",
  27062. "mozLockOrientation",
  27063. "mozMatchesSelector",
  27064. "mozMovementX",
  27065. "mozMovementY",
  27066. "mozOpaque",
  27067. "mozOrientation",
  27068. "mozPaintCount",
  27069. "mozPaintedFrames",
  27070. "mozParsedFrames",
  27071. "mozPay",
  27072. "mozPointerLockElement",
  27073. "mozPresentedFrames",
  27074. "mozPreservesPitch",
  27075. "mozPressure",
  27076. "mozPrintCallback",
  27077. "mozRTCIceCandidate",
  27078. "mozRTCPeerConnection",
  27079. "mozRTCSessionDescription",
  27080. "mozRemove",
  27081. "mozRequestAnimationFrame",
  27082. "mozRequestFullScreen",
  27083. "mozRequestPointerLock",
  27084. "mozSetDataAt",
  27085. "mozSetImageElement",
  27086. "mozSourceNode",
  27087. "mozSrcObject",
  27088. "mozSystem",
  27089. "mozTCPSocket",
  27090. "mozTextStyle",
  27091. "mozTypesAt",
  27092. "mozUnlockOrientation",
  27093. "mozUserCancelled",
  27094. "mozVisibilityState",
  27095. "ms",
  27096. "msAnimation",
  27097. "msAnimationDelay",
  27098. "msAnimationDirection",
  27099. "msAnimationDuration",
  27100. "msAnimationFillMode",
  27101. "msAnimationIterationCount",
  27102. "msAnimationName",
  27103. "msAnimationPlayState",
  27104. "msAnimationStartTime",
  27105. "msAnimationTimingFunction",
  27106. "msBackfaceVisibility",
  27107. "msBlockProgression",
  27108. "msCSSOMElementFloatMetrics",
  27109. "msCaching",
  27110. "msCachingEnabled",
  27111. "msCancelRequestAnimationFrame",
  27112. "msCapsLockWarningOff",
  27113. "msClearImmediate",
  27114. "msClose",
  27115. "msContentZoomChaining",
  27116. "msContentZoomFactor",
  27117. "msContentZoomLimit",
  27118. "msContentZoomLimitMax",
  27119. "msContentZoomLimitMin",
  27120. "msContentZoomSnap",
  27121. "msContentZoomSnapPoints",
  27122. "msContentZoomSnapType",
  27123. "msContentZooming",
  27124. "msConvertURL",
  27125. "msCrypto",
  27126. "msDoNotTrack",
  27127. "msElementsFromPoint",
  27128. "msElementsFromRect",
  27129. "msExitFullscreen",
  27130. "msExtendedCode",
  27131. "msFillRule",
  27132. "msFirstPaint",
  27133. "msFlex",
  27134. "msFlexAlign",
  27135. "msFlexDirection",
  27136. "msFlexFlow",
  27137. "msFlexItemAlign",
  27138. "msFlexLinePack",
  27139. "msFlexNegative",
  27140. "msFlexOrder",
  27141. "msFlexPack",
  27142. "msFlexPositive",
  27143. "msFlexPreferredSize",
  27144. "msFlexWrap",
  27145. "msFlowFrom",
  27146. "msFlowInto",
  27147. "msFontFeatureSettings",
  27148. "msFullscreenElement",
  27149. "msFullscreenEnabled",
  27150. "msGetInputContext",
  27151. "msGetRegionContent",
  27152. "msGetUntransformedBounds",
  27153. "msGraphicsTrustStatus",
  27154. "msGridColumn",
  27155. "msGridColumnAlign",
  27156. "msGridColumnSpan",
  27157. "msGridColumns",
  27158. "msGridRow",
  27159. "msGridRowAlign",
  27160. "msGridRowSpan",
  27161. "msGridRows",
  27162. "msHidden",
  27163. "msHighContrastAdjust",
  27164. "msHyphenateLimitChars",
  27165. "msHyphenateLimitLines",
  27166. "msHyphenateLimitZone",
  27167. "msHyphens",
  27168. "msImageSmoothingEnabled",
  27169. "msImeAlign",
  27170. "msIndexedDB",
  27171. "msInterpolationMode",
  27172. "msIsStaticHTML",
  27173. "msKeySystem",
  27174. "msKeys",
  27175. "msLaunchUri",
  27176. "msLockOrientation",
  27177. "msManipulationViewsEnabled",
  27178. "msMatchMedia",
  27179. "msMatchesSelector",
  27180. "msMaxTouchPoints",
  27181. "msOrientation",
  27182. "msOverflowStyle",
  27183. "msPerspective",
  27184. "msPerspectiveOrigin",
  27185. "msPlayToDisabled",
  27186. "msPlayToPreferredSourceUri",
  27187. "msPlayToPrimary",
  27188. "msPointerEnabled",
  27189. "msRegionOverflow",
  27190. "msReleasePointerCapture",
  27191. "msRequestAnimationFrame",
  27192. "msRequestFullscreen",
  27193. "msSaveBlob",
  27194. "msSaveOrOpenBlob",
  27195. "msScrollChaining",
  27196. "msScrollLimit",
  27197. "msScrollLimitXMax",
  27198. "msScrollLimitXMin",
  27199. "msScrollLimitYMax",
  27200. "msScrollLimitYMin",
  27201. "msScrollRails",
  27202. "msScrollSnapPointsX",
  27203. "msScrollSnapPointsY",
  27204. "msScrollSnapType",
  27205. "msScrollSnapX",
  27206. "msScrollSnapY",
  27207. "msScrollTranslation",
  27208. "msSetImmediate",
  27209. "msSetMediaKeys",
  27210. "msSetPointerCapture",
  27211. "msTextCombineHorizontal",
  27212. "msTextSizeAdjust",
  27213. "msToBlob",
  27214. "msTouchAction",
  27215. "msTouchSelect",
  27216. "msTraceAsyncCallbackCompleted",
  27217. "msTraceAsyncCallbackStarting",
  27218. "msTraceAsyncOperationCompleted",
  27219. "msTraceAsyncOperationStarting",
  27220. "msTransform",
  27221. "msTransformOrigin",
  27222. "msTransformStyle",
  27223. "msTransition",
  27224. "msTransitionDelay",
  27225. "msTransitionDuration",
  27226. "msTransitionProperty",
  27227. "msTransitionTimingFunction",
  27228. "msUnlockOrientation",
  27229. "msUpdateAsyncCallbackRelation",
  27230. "msUserSelect",
  27231. "msVisibilityState",
  27232. "msWrapFlow",
  27233. "msWrapMargin",
  27234. "msWrapThrough",
  27235. "msWriteProfilerMark",
  27236. "msZoom",
  27237. "msZoomTo",
  27238. "mt",
  27239. "mul",
  27240. "multiEntry",
  27241. "multiSelectionObj",
  27242. "multiline",
  27243. "multiple",
  27244. "multiply",
  27245. "multiplySelf",
  27246. "mutableFile",
  27247. "muted",
  27248. "n",
  27249. "name",
  27250. "nameProp",
  27251. "namedItem",
  27252. "namedRecordset",
  27253. "names",
  27254. "namespaceURI",
  27255. "namespaces",
  27256. "naturalHeight",
  27257. "naturalWidth",
  27258. "navigate",
  27259. "navigation",
  27260. "navigationMode",
  27261. "navigationPreload",
  27262. "navigationStart",
  27263. "navigator",
  27264. "near",
  27265. "nearestViewportElement",
  27266. "negative",
  27267. "negotiated",
  27268. "netscape",
  27269. "networkState",
  27270. "newScale",
  27271. "newTranslate",
  27272. "newURL",
  27273. "newValue",
  27274. "newValueSpecifiedUnits",
  27275. "newVersion",
  27276. "newhome",
  27277. "next",
  27278. "nextElementSibling",
  27279. "nextHopProtocol",
  27280. "nextNode",
  27281. "nextPage",
  27282. "nextSibling",
  27283. "nickname",
  27284. "noHref",
  27285. "noModule",
  27286. "noResize",
  27287. "noShade",
  27288. "noValidate",
  27289. "noWrap",
  27290. "node",
  27291. "nodeName",
  27292. "nodeType",
  27293. "nodeValue",
  27294. "nonce",
  27295. "normalize",
  27296. "normalizedPathSegList",
  27297. "notationName",
  27298. "notations",
  27299. "note",
  27300. "noteGrainOn",
  27301. "noteOff",
  27302. "noteOn",
  27303. "notify",
  27304. "now",
  27305. "numOctaves",
  27306. "number",
  27307. "numberOfChannels",
  27308. "numberOfInputs",
  27309. "numberOfItems",
  27310. "numberOfOutputs",
  27311. "numberValue",
  27312. "oMatchesSelector",
  27313. "object",
  27314. "object-fit",
  27315. "object-position",
  27316. "objectFit",
  27317. "objectPosition",
  27318. "objectStore",
  27319. "objectStoreNames",
  27320. "objectType",
  27321. "observe",
  27322. "of",
  27323. "offscreenBuffering",
  27324. "offset",
  27325. "offset-anchor",
  27326. "offset-distance",
  27327. "offset-path",
  27328. "offset-rotate",
  27329. "offsetAnchor",
  27330. "offsetDistance",
  27331. "offsetHeight",
  27332. "offsetLeft",
  27333. "offsetNode",
  27334. "offsetParent",
  27335. "offsetPath",
  27336. "offsetRotate",
  27337. "offsetTop",
  27338. "offsetWidth",
  27339. "offsetX",
  27340. "offsetY",
  27341. "ok",
  27342. "oldURL",
  27343. "oldValue",
  27344. "oldVersion",
  27345. "olderShadowRoot",
  27346. "onLine",
  27347. "onabort",
  27348. "onabsolutedeviceorientation",
  27349. "onactivate",
  27350. "onactive",
  27351. "onaddsourcebuffer",
  27352. "onaddstream",
  27353. "onaddtrack",
  27354. "onafterprint",
  27355. "onafterscriptexecute",
  27356. "onafterupdate",
  27357. "onanimationcancel",
  27358. "onanimationend",
  27359. "onanimationiteration",
  27360. "onanimationstart",
  27361. "onappinstalled",
  27362. "onaudioend",
  27363. "onaudioprocess",
  27364. "onaudiostart",
  27365. "onautocomplete",
  27366. "onautocompleteerror",
  27367. "onauxclick",
  27368. "onbeforeactivate",
  27369. "onbeforecopy",
  27370. "onbeforecut",
  27371. "onbeforedeactivate",
  27372. "onbeforeeditfocus",
  27373. "onbeforeinstallprompt",
  27374. "onbeforepaste",
  27375. "onbeforeprint",
  27376. "onbeforescriptexecute",
  27377. "onbeforeunload",
  27378. "onbeforeupdate",
  27379. "onbeforexrselect",
  27380. "onbegin",
  27381. "onblocked",
  27382. "onblur",
  27383. "onbounce",
  27384. "onboundary",
  27385. "onbufferedamountlow",
  27386. "oncached",
  27387. "oncancel",
  27388. "oncandidatewindowhide",
  27389. "oncandidatewindowshow",
  27390. "oncandidatewindowupdate",
  27391. "oncanplay",
  27392. "oncanplaythrough",
  27393. "once",
  27394. "oncellchange",
  27395. "onchange",
  27396. "oncharacteristicvaluechanged",
  27397. "onchargingchange",
  27398. "onchargingtimechange",
  27399. "onchecking",
  27400. "onclick",
  27401. "onclose",
  27402. "onclosing",
  27403. "oncompassneedscalibration",
  27404. "oncomplete",
  27405. "onconnect",
  27406. "onconnecting",
  27407. "onconnectionavailable",
  27408. "onconnectionstatechange",
  27409. "oncontextmenu",
  27410. "oncontrollerchange",
  27411. "oncontrolselect",
  27412. "oncopy",
  27413. "oncuechange",
  27414. "oncut",
  27415. "ondataavailable",
  27416. "ondatachannel",
  27417. "ondatasetchanged",
  27418. "ondatasetcomplete",
  27419. "ondblclick",
  27420. "ondeactivate",
  27421. "ondevicechange",
  27422. "ondevicelight",
  27423. "ondevicemotion",
  27424. "ondeviceorientation",
  27425. "ondeviceorientationabsolute",
  27426. "ondeviceproximity",
  27427. "ondischargingtimechange",
  27428. "ondisconnect",
  27429. "ondisplay",
  27430. "ondownloading",
  27431. "ondrag",
  27432. "ondragend",
  27433. "ondragenter",
  27434. "ondragexit",
  27435. "ondragleave",
  27436. "ondragover",
  27437. "ondragstart",
  27438. "ondrop",
  27439. "ondurationchange",
  27440. "onemptied",
  27441. "onencrypted",
  27442. "onend",
  27443. "onended",
  27444. "onenter",
  27445. "onenterpictureinpicture",
  27446. "onerror",
  27447. "onerrorupdate",
  27448. "onexit",
  27449. "onfilterchange",
  27450. "onfinish",
  27451. "onfocus",
  27452. "onfocusin",
  27453. "onfocusout",
  27454. "onformdata",
  27455. "onfreeze",
  27456. "onfullscreenchange",
  27457. "onfullscreenerror",
  27458. "ongatheringstatechange",
  27459. "ongattserverdisconnected",
  27460. "ongesturechange",
  27461. "ongestureend",
  27462. "ongesturestart",
  27463. "ongotpointercapture",
  27464. "onhashchange",
  27465. "onhelp",
  27466. "onicecandidate",
  27467. "onicecandidateerror",
  27468. "oniceconnectionstatechange",
  27469. "onicegatheringstatechange",
  27470. "oninactive",
  27471. "oninput",
  27472. "oninputsourceschange",
  27473. "oninvalid",
  27474. "onkeydown",
  27475. "onkeypress",
  27476. "onkeystatuseschange",
  27477. "onkeyup",
  27478. "onlanguagechange",
  27479. "onlayoutcomplete",
  27480. "onleavepictureinpicture",
  27481. "onlevelchange",
  27482. "onload",
  27483. "onloadeddata",
  27484. "onloadedmetadata",
  27485. "onloadend",
  27486. "onloading",
  27487. "onloadingdone",
  27488. "onloadingerror",
  27489. "onloadstart",
  27490. "onlosecapture",
  27491. "onlostpointercapture",
  27492. "only",
  27493. "onmark",
  27494. "onmessage",
  27495. "onmessageerror",
  27496. "onmidimessage",
  27497. "onmousedown",
  27498. "onmouseenter",
  27499. "onmouseleave",
  27500. "onmousemove",
  27501. "onmouseout",
  27502. "onmouseover",
  27503. "onmouseup",
  27504. "onmousewheel",
  27505. "onmove",
  27506. "onmoveend",
  27507. "onmovestart",
  27508. "onmozfullscreenchange",
  27509. "onmozfullscreenerror",
  27510. "onmozorientationchange",
  27511. "onmozpointerlockchange",
  27512. "onmozpointerlockerror",
  27513. "onmscontentzoom",
  27514. "onmsfullscreenchange",
  27515. "onmsfullscreenerror",
  27516. "onmsgesturechange",
  27517. "onmsgesturedoubletap",
  27518. "onmsgestureend",
  27519. "onmsgesturehold",
  27520. "onmsgesturestart",
  27521. "onmsgesturetap",
  27522. "onmsgotpointercapture",
  27523. "onmsinertiastart",
  27524. "onmslostpointercapture",
  27525. "onmsmanipulationstatechanged",
  27526. "onmsneedkey",
  27527. "onmsorientationchange",
  27528. "onmspointercancel",
  27529. "onmspointerdown",
  27530. "onmspointerenter",
  27531. "onmspointerhover",
  27532. "onmspointerleave",
  27533. "onmspointermove",
  27534. "onmspointerout",
  27535. "onmspointerover",
  27536. "onmspointerup",
  27537. "onmssitemodejumplistitemremoved",
  27538. "onmsthumbnailclick",
  27539. "onmute",
  27540. "onnegotiationneeded",
  27541. "onnomatch",
  27542. "onnoupdate",
  27543. "onobsolete",
  27544. "onoffline",
  27545. "ononline",
  27546. "onopen",
  27547. "onorientationchange",
  27548. "onpagechange",
  27549. "onpagehide",
  27550. "onpageshow",
  27551. "onpaste",
  27552. "onpause",
  27553. "onpayerdetailchange",
  27554. "onpaymentmethodchange",
  27555. "onplay",
  27556. "onplaying",
  27557. "onpluginstreamstart",
  27558. "onpointercancel",
  27559. "onpointerdown",
  27560. "onpointerenter",
  27561. "onpointerleave",
  27562. "onpointerlockchange",
  27563. "onpointerlockerror",
  27564. "onpointermove",
  27565. "onpointerout",
  27566. "onpointerover",
  27567. "onpointerrawupdate",
  27568. "onpointerup",
  27569. "onpopstate",
  27570. "onprocessorerror",
  27571. "onprogress",
  27572. "onpropertychange",
  27573. "onratechange",
  27574. "onreading",
  27575. "onreadystatechange",
  27576. "onrejectionhandled",
  27577. "onrelease",
  27578. "onremove",
  27579. "onremovesourcebuffer",
  27580. "onremovestream",
  27581. "onremovetrack",
  27582. "onrepeat",
  27583. "onreset",
  27584. "onresize",
  27585. "onresizeend",
  27586. "onresizestart",
  27587. "onresourcetimingbufferfull",
  27588. "onresult",
  27589. "onresume",
  27590. "onrowenter",
  27591. "onrowexit",
  27592. "onrowsdelete",
  27593. "onrowsinserted",
  27594. "onscroll",
  27595. "onsearch",
  27596. "onsecuritypolicyviolation",
  27597. "onseeked",
  27598. "onseeking",
  27599. "onselect",
  27600. "onselectedcandidatepairchange",
  27601. "onselectend",
  27602. "onselectionchange",
  27603. "onselectstart",
  27604. "onshippingaddresschange",
  27605. "onshippingoptionchange",
  27606. "onshow",
  27607. "onsignalingstatechange",
  27608. "onsoundend",
  27609. "onsoundstart",
  27610. "onsourceclose",
  27611. "onsourceclosed",
  27612. "onsourceended",
  27613. "onsourceopen",
  27614. "onspeechend",
  27615. "onspeechstart",
  27616. "onsqueeze",
  27617. "onsqueezeend",
  27618. "onsqueezestart",
  27619. "onstalled",
  27620. "onstart",
  27621. "onstatechange",
  27622. "onstop",
  27623. "onstorage",
  27624. "onstoragecommit",
  27625. "onsubmit",
  27626. "onsuccess",
  27627. "onsuspend",
  27628. "onterminate",
  27629. "ontextinput",
  27630. "ontimeout",
  27631. "ontimeupdate",
  27632. "ontoggle",
  27633. "ontonechange",
  27634. "ontouchcancel",
  27635. "ontouchend",
  27636. "ontouchmove",
  27637. "ontouchstart",
  27638. "ontrack",
  27639. "ontransitioncancel",
  27640. "ontransitionend",
  27641. "ontransitionrun",
  27642. "ontransitionstart",
  27643. "onunhandledrejection",
  27644. "onunload",
  27645. "onunmute",
  27646. "onupdate",
  27647. "onupdateend",
  27648. "onupdatefound",
  27649. "onupdateready",
  27650. "onupdatestart",
  27651. "onupgradeneeded",
  27652. "onuserproximity",
  27653. "onversionchange",
  27654. "onvisibilitychange",
  27655. "onvoiceschanged",
  27656. "onvolumechange",
  27657. "onvrdisplayactivate",
  27658. "onvrdisplayconnect",
  27659. "onvrdisplaydeactivate",
  27660. "onvrdisplaydisconnect",
  27661. "onvrdisplaypresentchange",
  27662. "onwaiting",
  27663. "onwaitingforkey",
  27664. "onwarning",
  27665. "onwebkitanimationend",
  27666. "onwebkitanimationiteration",
  27667. "onwebkitanimationstart",
  27668. "onwebkitcurrentplaybacktargetiswirelesschanged",
  27669. "onwebkitfullscreenchange",
  27670. "onwebkitfullscreenerror",
  27671. "onwebkitkeyadded",
  27672. "onwebkitkeyerror",
  27673. "onwebkitkeymessage",
  27674. "onwebkitneedkey",
  27675. "onwebkitorientationchange",
  27676. "onwebkitplaybacktargetavailabilitychanged",
  27677. "onwebkitpointerlockchange",
  27678. "onwebkitpointerlockerror",
  27679. "onwebkitresourcetimingbufferfull",
  27680. "onwebkittransitionend",
  27681. "onwheel",
  27682. "onzoom",
  27683. "opacity",
  27684. "open",
  27685. "openCursor",
  27686. "openDatabase",
  27687. "openKeyCursor",
  27688. "opened",
  27689. "opener",
  27690. "opera",
  27691. "operationType",
  27692. "operator",
  27693. "opr",
  27694. "optimum",
  27695. "options",
  27696. "or",
  27697. "order",
  27698. "orderX",
  27699. "orderY",
  27700. "ordered",
  27701. "org",
  27702. "organization",
  27703. "orient",
  27704. "orientAngle",
  27705. "orientType",
  27706. "orientation",
  27707. "orientationX",
  27708. "orientationY",
  27709. "orientationZ",
  27710. "origin",
  27711. "originalPolicy",
  27712. "originalTarget",
  27713. "orphans",
  27714. "oscpu",
  27715. "outerHTML",
  27716. "outerHeight",
  27717. "outerText",
  27718. "outerWidth",
  27719. "outline",
  27720. "outline-color",
  27721. "outline-offset",
  27722. "outline-style",
  27723. "outline-width",
  27724. "outlineColor",
  27725. "outlineOffset",
  27726. "outlineStyle",
  27727. "outlineWidth",
  27728. "outputBuffer",
  27729. "outputLatency",
  27730. "outputs",
  27731. "overflow",
  27732. "overflow-anchor",
  27733. "overflow-block",
  27734. "overflow-inline",
  27735. "overflow-wrap",
  27736. "overflow-x",
  27737. "overflow-y",
  27738. "overflowAnchor",
  27739. "overflowBlock",
  27740. "overflowInline",
  27741. "overflowWrap",
  27742. "overflowX",
  27743. "overflowY",
  27744. "overrideMimeType",
  27745. "oversample",
  27746. "overscroll-behavior",
  27747. "overscroll-behavior-block",
  27748. "overscroll-behavior-inline",
  27749. "overscroll-behavior-x",
  27750. "overscroll-behavior-y",
  27751. "overscrollBehavior",
  27752. "overscrollBehaviorBlock",
  27753. "overscrollBehaviorInline",
  27754. "overscrollBehaviorX",
  27755. "overscrollBehaviorY",
  27756. "ownKeys",
  27757. "ownerDocument",
  27758. "ownerElement",
  27759. "ownerNode",
  27760. "ownerRule",
  27761. "ownerSVGElement",
  27762. "owningElement",
  27763. "p1",
  27764. "p2",
  27765. "p3",
  27766. "p4",
  27767. "packetSize",
  27768. "packets",
  27769. "pad",
  27770. "padEnd",
  27771. "padStart",
  27772. "padding",
  27773. "padding-block",
  27774. "padding-block-end",
  27775. "padding-block-start",
  27776. "padding-bottom",
  27777. "padding-inline",
  27778. "padding-inline-end",
  27779. "padding-inline-start",
  27780. "padding-left",
  27781. "padding-right",
  27782. "padding-top",
  27783. "paddingBlock",
  27784. "paddingBlockEnd",
  27785. "paddingBlockStart",
  27786. "paddingBottom",
  27787. "paddingInline",
  27788. "paddingInlineEnd",
  27789. "paddingInlineStart",
  27790. "paddingLeft",
  27791. "paddingRight",
  27792. "paddingTop",
  27793. "page",
  27794. "page-break-after",
  27795. "page-break-before",
  27796. "page-break-inside",
  27797. "pageBreakAfter",
  27798. "pageBreakBefore",
  27799. "pageBreakInside",
  27800. "pageCount",
  27801. "pageLeft",
  27802. "pageTop",
  27803. "pageX",
  27804. "pageXOffset",
  27805. "pageY",
  27806. "pageYOffset",
  27807. "pages",
  27808. "paint-order",
  27809. "paintOrder",
  27810. "paintRequests",
  27811. "paintType",
  27812. "paintWorklet",
  27813. "palette",
  27814. "pan",
  27815. "panningModel",
  27816. "parameters",
  27817. "parent",
  27818. "parentElement",
  27819. "parentNode",
  27820. "parentRule",
  27821. "parentStyleSheet",
  27822. "parentTextEdit",
  27823. "parentWindow",
  27824. "parse",
  27825. "parseAll",
  27826. "parseFloat",
  27827. "parseFromString",
  27828. "parseInt",
  27829. "part",
  27830. "participants",
  27831. "passive",
  27832. "password",
  27833. "pasteHTML",
  27834. "path",
  27835. "pathLength",
  27836. "pathSegList",
  27837. "pathSegType",
  27838. "pathSegTypeAsLetter",
  27839. "pathname",
  27840. "pattern",
  27841. "patternContentUnits",
  27842. "patternMismatch",
  27843. "patternTransform",
  27844. "patternUnits",
  27845. "pause",
  27846. "pauseAnimations",
  27847. "pauseOnExit",
  27848. "pauseProfilers",
  27849. "pauseTransformFeedback",
  27850. "paused",
  27851. "payerEmail",
  27852. "payerName",
  27853. "payerPhone",
  27854. "paymentManager",
  27855. "pc",
  27856. "peerIdentity",
  27857. "pending",
  27858. "pendingLocalDescription",
  27859. "pendingRemoteDescription",
  27860. "percent",
  27861. "performance",
  27862. "periodicSync",
  27863. "permission",
  27864. "permissionState",
  27865. "permissions",
  27866. "persist",
  27867. "persisted",
  27868. "personalbar",
  27869. "perspective",
  27870. "perspective-origin",
  27871. "perspectiveOrigin",
  27872. "phone",
  27873. "phoneticFamilyName",
  27874. "phoneticGivenName",
  27875. "photo",
  27876. "pictureInPictureElement",
  27877. "pictureInPictureEnabled",
  27878. "pictureInPictureWindow",
  27879. "ping",
  27880. "pipeThrough",
  27881. "pipeTo",
  27882. "pitch",
  27883. "pixelBottom",
  27884. "pixelDepth",
  27885. "pixelHeight",
  27886. "pixelLeft",
  27887. "pixelRight",
  27888. "pixelStorei",
  27889. "pixelTop",
  27890. "pixelUnitToMillimeterX",
  27891. "pixelUnitToMillimeterY",
  27892. "pixelWidth",
  27893. "place-content",
  27894. "place-items",
  27895. "place-self",
  27896. "placeContent",
  27897. "placeItems",
  27898. "placeSelf",
  27899. "placeholder",
  27900. "platformVersion",
  27901. "platform",
  27902. "platforms",
  27903. "play",
  27904. "playEffect",
  27905. "playState",
  27906. "playbackRate",
  27907. "playbackState",
  27908. "playbackTime",
  27909. "played",
  27910. "playoutDelayHint",
  27911. "playsInline",
  27912. "plugins",
  27913. "pluginspage",
  27914. "pname",
  27915. "pointer-events",
  27916. "pointerBeforeReferenceNode",
  27917. "pointerEnabled",
  27918. "pointerEvents",
  27919. "pointerId",
  27920. "pointerLockElement",
  27921. "pointerType",
  27922. "points",
  27923. "pointsAtX",
  27924. "pointsAtY",
  27925. "pointsAtZ",
  27926. "polygonOffset",
  27927. "pop",
  27928. "populateMatrix",
  27929. "popupWindowFeatures",
  27930. "popupWindowName",
  27931. "popupWindowURI",
  27932. "port",
  27933. "port1",
  27934. "port2",
  27935. "ports",
  27936. "posBottom",
  27937. "posHeight",
  27938. "posLeft",
  27939. "posRight",
  27940. "posTop",
  27941. "posWidth",
  27942. "pose",
  27943. "position",
  27944. "positionAlign",
  27945. "positionX",
  27946. "positionY",
  27947. "positionZ",
  27948. "postError",
  27949. "postMessage",
  27950. "postalCode",
  27951. "poster",
  27952. "pow",
  27953. "powerEfficient",
  27954. "powerOff",
  27955. "preMultiplySelf",
  27956. "precision",
  27957. "preferredStyleSheetSet",
  27958. "preferredStylesheetSet",
  27959. "prefix",
  27960. "preload",
  27961. "prepend",
  27962. "presentation",
  27963. "preserveAlpha",
  27964. "preserveAspectRatio",
  27965. "preserveAspectRatioString",
  27966. "pressed",
  27967. "pressure",
  27968. "prevValue",
  27969. "preventDefault",
  27970. "preventExtensions",
  27971. "preventSilentAccess",
  27972. "previousElementSibling",
  27973. "previousNode",
  27974. "previousPage",
  27975. "previousRect",
  27976. "previousScale",
  27977. "previousSibling",
  27978. "previousTranslate",
  27979. "primaryKey",
  27980. "primitiveType",
  27981. "primitiveUnits",
  27982. "principals",
  27983. "print",
  27984. "priority",
  27985. "privateKey",
  27986. "probablySupportsContext",
  27987. "process",
  27988. "processIceMessage",
  27989. "processingEnd",
  27990. "processingStart",
  27991. "product",
  27992. "productId",
  27993. "productName",
  27994. "productSub",
  27995. "profile",
  27996. "profileEnd",
  27997. "profiles",
  27998. "projectionMatrix",
  27999. "promise",
  28000. "prompt",
  28001. "properties",
  28002. "propertyIsEnumerable",
  28003. "propertyName",
  28004. "protocol",
  28005. "protocolLong",
  28006. "prototype",
  28007. "provider",
  28008. "pseudoClass",
  28009. "pseudoElement",
  28010. "pt",
  28011. "publicId",
  28012. "publicKey",
  28013. "published",
  28014. "pulse",
  28015. "push",
  28016. "pushManager",
  28017. "pushNotification",
  28018. "pushState",
  28019. "put",
  28020. "putImageData",
  28021. "px",
  28022. "quadraticCurveTo",
  28023. "qualifier",
  28024. "quaternion",
  28025. "query",
  28026. "queryCommandEnabled",
  28027. "queryCommandIndeterm",
  28028. "queryCommandState",
  28029. "queryCommandSupported",
  28030. "queryCommandText",
  28031. "queryCommandValue",
  28032. "querySelector",
  28033. "querySelectorAll",
  28034. "queueMicrotask",
  28035. "quote",
  28036. "quotes",
  28037. "r",
  28038. "r1",
  28039. "r2",
  28040. "race",
  28041. "rad",
  28042. "radiogroup",
  28043. "radiusX",
  28044. "radiusY",
  28045. "random",
  28046. "range",
  28047. "rangeCount",
  28048. "rangeMax",
  28049. "rangeMin",
  28050. "rangeOffset",
  28051. "rangeOverflow",
  28052. "rangeParent",
  28053. "rangeUnderflow",
  28054. "rate",
  28055. "ratio",
  28056. "raw",
  28057. "rawId",
  28058. "read",
  28059. "readAsArrayBuffer",
  28060. "readAsBinaryString",
  28061. "readAsBlob",
  28062. "readAsDataURL",
  28063. "readAsText",
  28064. "readBuffer",
  28065. "readEntries",
  28066. "readOnly",
  28067. "readPixels",
  28068. "readReportRequested",
  28069. "readText",
  28070. "readValue",
  28071. "readable",
  28072. "ready",
  28073. "readyState",
  28074. "reason",
  28075. "reboot",
  28076. "receivedAlert",
  28077. "receiver",
  28078. "receivers",
  28079. "recipient",
  28080. "reconnect",
  28081. "recordNumber",
  28082. "recordsAvailable",
  28083. "recordset",
  28084. "rect",
  28085. "red",
  28086. "redEyeReduction",
  28087. "redirect",
  28088. "redirectCount",
  28089. "redirectEnd",
  28090. "redirectStart",
  28091. "redirected",
  28092. "reduce",
  28093. "reduceRight",
  28094. "reduction",
  28095. "refDistance",
  28096. "refX",
  28097. "refY",
  28098. "referenceNode",
  28099. "referenceSpace",
  28100. "referrer",
  28101. "referrerPolicy",
  28102. "refresh",
  28103. "region",
  28104. "regionAnchorX",
  28105. "regionAnchorY",
  28106. "regionId",
  28107. "regions",
  28108. "register",
  28109. "registerContentHandler",
  28110. "registerElement",
  28111. "registerProperty",
  28112. "registerProtocolHandler",
  28113. "reject",
  28114. "rel",
  28115. "relList",
  28116. "relatedAddress",
  28117. "relatedNode",
  28118. "relatedPort",
  28119. "relatedTarget",
  28120. "release",
  28121. "releaseCapture",
  28122. "releaseEvents",
  28123. "releaseInterface",
  28124. "releaseLock",
  28125. "releasePointerCapture",
  28126. "releaseShaderCompiler",
  28127. "reliable",
  28128. "reliableWrite",
  28129. "reload",
  28130. "rem",
  28131. "remainingSpace",
  28132. "remote",
  28133. "remoteDescription",
  28134. "remove",
  28135. "removeAllRanges",
  28136. "removeAttribute",
  28137. "removeAttributeNS",
  28138. "removeAttributeNode",
  28139. "removeBehavior",
  28140. "removeChild",
  28141. "removeCue",
  28142. "removeEventListener",
  28143. "removeFilter",
  28144. "removeImport",
  28145. "removeItem",
  28146. "removeListener",
  28147. "removeNamedItem",
  28148. "removeNamedItemNS",
  28149. "removeNode",
  28150. "removeParameter",
  28151. "removeProperty",
  28152. "removeRange",
  28153. "removeRegion",
  28154. "removeRule",
  28155. "removeSiteSpecificTrackingException",
  28156. "removeSourceBuffer",
  28157. "removeStream",
  28158. "removeTrack",
  28159. "removeVariable",
  28160. "removeWakeLockListener",
  28161. "removeWebWideTrackingException",
  28162. "removed",
  28163. "removedNodes",
  28164. "renderHeight",
  28165. "renderState",
  28166. "renderTime",
  28167. "renderWidth",
  28168. "renderbufferStorage",
  28169. "renderbufferStorageMultisample",
  28170. "renderedBuffer",
  28171. "renderingMode",
  28172. "renotify",
  28173. "repeat",
  28174. "replace",
  28175. "replaceAdjacentText",
  28176. "replaceAll",
  28177. "replaceChild",
  28178. "replaceChildren",
  28179. "replaceData",
  28180. "replaceId",
  28181. "replaceItem",
  28182. "replaceNode",
  28183. "replaceState",
  28184. "replaceSync",
  28185. "replaceTrack",
  28186. "replaceWholeText",
  28187. "replaceWith",
  28188. "reportValidity",
  28189. "request",
  28190. "requestAnimationFrame",
  28191. "requestAutocomplete",
  28192. "requestData",
  28193. "requestDevice",
  28194. "requestFrame",
  28195. "requestFullscreen",
  28196. "requestHitTestSource",
  28197. "requestHitTestSourceForTransientInput",
  28198. "requestId",
  28199. "requestIdleCallback",
  28200. "requestMIDIAccess",
  28201. "requestMediaKeySystemAccess",
  28202. "requestPermission",
  28203. "requestPictureInPicture",
  28204. "requestPointerLock",
  28205. "requestPresent",
  28206. "requestReferenceSpace",
  28207. "requestSession",
  28208. "requestStart",
  28209. "requestStorageAccess",
  28210. "requestSubmit",
  28211. "requestVideoFrameCallback",
  28212. "requestingWindow",
  28213. "requireInteraction",
  28214. "required",
  28215. "requiredExtensions",
  28216. "requiredFeatures",
  28217. "reset",
  28218. "resetPose",
  28219. "resetTransform",
  28220. "resize",
  28221. "resizeBy",
  28222. "resizeTo",
  28223. "resolve",
  28224. "response",
  28225. "responseBody",
  28226. "responseEnd",
  28227. "responseReady",
  28228. "responseStart",
  28229. "responseText",
  28230. "responseType",
  28231. "responseURL",
  28232. "responseXML",
  28233. "restartIce",
  28234. "restore",
  28235. "result",
  28236. "resultIndex",
  28237. "resultType",
  28238. "results",
  28239. "resume",
  28240. "resumeProfilers",
  28241. "resumeTransformFeedback",
  28242. "retry",
  28243. "returnValue",
  28244. "rev",
  28245. "reverse",
  28246. "reversed",
  28247. "revocable",
  28248. "revokeObjectURL",
  28249. "rgbColor",
  28250. "right",
  28251. "rightContext",
  28252. "rightDegrees",
  28253. "rightMargin",
  28254. "rightProjectionMatrix",
  28255. "rightViewMatrix",
  28256. "role",
  28257. "rolloffFactor",
  28258. "root",
  28259. "rootBounds",
  28260. "rootElement",
  28261. "rootMargin",
  28262. "rotate",
  28263. "rotateAxisAngle",
  28264. "rotateAxisAngleSelf",
  28265. "rotateFromVector",
  28266. "rotateFromVectorSelf",
  28267. "rotateSelf",
  28268. "rotation",
  28269. "rotationAngle",
  28270. "rotationRate",
  28271. "round",
  28272. "row-gap",
  28273. "rowGap",
  28274. "rowIndex",
  28275. "rowSpan",
  28276. "rows",
  28277. "rtcpTransport",
  28278. "rtt",
  28279. "ruby-align",
  28280. "ruby-position",
  28281. "rubyAlign",
  28282. "rubyOverhang",
  28283. "rubyPosition",
  28284. "rules",
  28285. "runtime",
  28286. "runtimeStyle",
  28287. "rx",
  28288. "ry",
  28289. "s",
  28290. "safari",
  28291. "sample",
  28292. "sampleCoverage",
  28293. "sampleRate",
  28294. "samplerParameterf",
  28295. "samplerParameteri",
  28296. "sandbox",
  28297. "save",
  28298. "saveData",
  28299. "scale",
  28300. "scale3d",
  28301. "scale3dSelf",
  28302. "scaleNonUniform",
  28303. "scaleNonUniformSelf",
  28304. "scaleSelf",
  28305. "scheme",
  28306. "scissor",
  28307. "scope",
  28308. "scopeName",
  28309. "scoped",
  28310. "screen",
  28311. "screenBrightness",
  28312. "screenEnabled",
  28313. "screenLeft",
  28314. "screenPixelToMillimeterX",
  28315. "screenPixelToMillimeterY",
  28316. "screenTop",
  28317. "screenX",
  28318. "screenY",
  28319. "scriptURL",
  28320. "scripts",
  28321. "scroll",
  28322. "scroll-behavior",
  28323. "scroll-margin",
  28324. "scroll-margin-block",
  28325. "scroll-margin-block-end",
  28326. "scroll-margin-block-start",
  28327. "scroll-margin-bottom",
  28328. "scroll-margin-inline",
  28329. "scroll-margin-inline-end",
  28330. "scroll-margin-inline-start",
  28331. "scroll-margin-left",
  28332. "scroll-margin-right",
  28333. "scroll-margin-top",
  28334. "scroll-padding",
  28335. "scroll-padding-block",
  28336. "scroll-padding-block-end",
  28337. "scroll-padding-block-start",
  28338. "scroll-padding-bottom",
  28339. "scroll-padding-inline",
  28340. "scroll-padding-inline-end",
  28341. "scroll-padding-inline-start",
  28342. "scroll-padding-left",
  28343. "scroll-padding-right",
  28344. "scroll-padding-top",
  28345. "scroll-snap-align",
  28346. "scroll-snap-type",
  28347. "scrollAmount",
  28348. "scrollBehavior",
  28349. "scrollBy",
  28350. "scrollByLines",
  28351. "scrollByPages",
  28352. "scrollDelay",
  28353. "scrollHeight",
  28354. "scrollIntoView",
  28355. "scrollIntoViewIfNeeded",
  28356. "scrollLeft",
  28357. "scrollLeftMax",
  28358. "scrollMargin",
  28359. "scrollMarginBlock",
  28360. "scrollMarginBlockEnd",
  28361. "scrollMarginBlockStart",
  28362. "scrollMarginBottom",
  28363. "scrollMarginInline",
  28364. "scrollMarginInlineEnd",
  28365. "scrollMarginInlineStart",
  28366. "scrollMarginLeft",
  28367. "scrollMarginRight",
  28368. "scrollMarginTop",
  28369. "scrollMaxX",
  28370. "scrollMaxY",
  28371. "scrollPadding",
  28372. "scrollPaddingBlock",
  28373. "scrollPaddingBlockEnd",
  28374. "scrollPaddingBlockStart",
  28375. "scrollPaddingBottom",
  28376. "scrollPaddingInline",
  28377. "scrollPaddingInlineEnd",
  28378. "scrollPaddingInlineStart",
  28379. "scrollPaddingLeft",
  28380. "scrollPaddingRight",
  28381. "scrollPaddingTop",
  28382. "scrollRestoration",
  28383. "scrollSnapAlign",
  28384. "scrollSnapType",
  28385. "scrollTo",
  28386. "scrollTop",
  28387. "scrollTopMax",
  28388. "scrollWidth",
  28389. "scrollX",
  28390. "scrollY",
  28391. "scrollbar-color",
  28392. "scrollbar-width",
  28393. "scrollbar3dLightColor",
  28394. "scrollbarArrowColor",
  28395. "scrollbarBaseColor",
  28396. "scrollbarColor",
  28397. "scrollbarDarkShadowColor",
  28398. "scrollbarFaceColor",
  28399. "scrollbarHighlightColor",
  28400. "scrollbarShadowColor",
  28401. "scrollbarTrackColor",
  28402. "scrollbarWidth",
  28403. "scrollbars",
  28404. "scrolling",
  28405. "scrollingElement",
  28406. "sctp",
  28407. "sctpCauseCode",
  28408. "sdp",
  28409. "sdpLineNumber",
  28410. "sdpMLineIndex",
  28411. "sdpMid",
  28412. "seal",
  28413. "search",
  28414. "searchBox",
  28415. "searchBoxJavaBridge_",
  28416. "searchParams",
  28417. "sectionRowIndex",
  28418. "secureConnectionStart",
  28419. "security",
  28420. "seed",
  28421. "seekToNextFrame",
  28422. "seekable",
  28423. "seeking",
  28424. "select",
  28425. "selectAllChildren",
  28426. "selectAlternateInterface",
  28427. "selectConfiguration",
  28428. "selectNode",
  28429. "selectNodeContents",
  28430. "selectNodes",
  28431. "selectSingleNode",
  28432. "selectSubString",
  28433. "selected",
  28434. "selectedIndex",
  28435. "selectedOptions",
  28436. "selectedStyleSheetSet",
  28437. "selectedStylesheetSet",
  28438. "selection",
  28439. "selectionDirection",
  28440. "selectionEnd",
  28441. "selectionStart",
  28442. "selector",
  28443. "selectorText",
  28444. "self",
  28445. "send",
  28446. "sendAsBinary",
  28447. "sendBeacon",
  28448. "sender",
  28449. "sentAlert",
  28450. "sentTimestamp",
  28451. "separator",
  28452. "serialNumber",
  28453. "serializeToString",
  28454. "serverTiming",
  28455. "service",
  28456. "serviceWorker",
  28457. "session",
  28458. "sessionId",
  28459. "sessionStorage",
  28460. "set",
  28461. "setActionHandler",
  28462. "setActive",
  28463. "setAlpha",
  28464. "setAppBadge",
  28465. "setAttribute",
  28466. "setAttributeNS",
  28467. "setAttributeNode",
  28468. "setAttributeNodeNS",
  28469. "setBaseAndExtent",
  28470. "setBigInt64",
  28471. "setBigUint64",
  28472. "setBingCurrentSearchDefault",
  28473. "setCapture",
  28474. "setCodecPreferences",
  28475. "setColor",
  28476. "setCompositeOperation",
  28477. "setConfiguration",
  28478. "setCurrentTime",
  28479. "setCustomValidity",
  28480. "setData",
  28481. "setDate",
  28482. "setDragImage",
  28483. "setEnd",
  28484. "setEndAfter",
  28485. "setEndBefore",
  28486. "setEndPoint",
  28487. "setFillColor",
  28488. "setFilterRes",
  28489. "setFloat32",
  28490. "setFloat64",
  28491. "setFloatValue",
  28492. "setFormValue",
  28493. "setFullYear",
  28494. "setHeaderValue",
  28495. "setHours",
  28496. "setIdentityProvider",
  28497. "setImmediate",
  28498. "setInt16",
  28499. "setInt32",
  28500. "setInt8",
  28501. "setInterval",
  28502. "setItem",
  28503. "setKeyframes",
  28504. "setLineCap",
  28505. "setLineDash",
  28506. "setLineJoin",
  28507. "setLineWidth",
  28508. "setLiveSeekableRange",
  28509. "setLocalDescription",
  28510. "setMatrix",
  28511. "setMatrixValue",
  28512. "setMediaKeys",
  28513. "setMilliseconds",
  28514. "setMinutes",
  28515. "setMiterLimit",
  28516. "setMonth",
  28517. "setNamedItem",
  28518. "setNamedItemNS",
  28519. "setNonUserCodeExceptions",
  28520. "setOrientToAngle",
  28521. "setOrientToAuto",
  28522. "setOrientation",
  28523. "setOverrideHistoryNavigationMode",
  28524. "setPaint",
  28525. "setParameter",
  28526. "setParameters",
  28527. "setPeriodicWave",
  28528. "setPointerCapture",
  28529. "setPosition",
  28530. "setPositionState",
  28531. "setPreference",
  28532. "setProperty",
  28533. "setPrototypeOf",
  28534. "setRGBColor",
  28535. "setRGBColorICCColor",
  28536. "setRadius",
  28537. "setRangeText",
  28538. "setRemoteDescription",
  28539. "setRequestHeader",
  28540. "setResizable",
  28541. "setResourceTimingBufferSize",
  28542. "setRotate",
  28543. "setScale",
  28544. "setSeconds",
  28545. "setSelectionRange",
  28546. "setServerCertificate",
  28547. "setShadow",
  28548. "setSinkId",
  28549. "setSkewX",
  28550. "setSkewY",
  28551. "setStart",
  28552. "setStartAfter",
  28553. "setStartBefore",
  28554. "setStdDeviation",
  28555. "setStreams",
  28556. "setStringValue",
  28557. "setStrokeColor",
  28558. "setSuggestResult",
  28559. "setTargetAtTime",
  28560. "setTargetValueAtTime",
  28561. "setTime",
  28562. "setTimeout",
  28563. "setTransform",
  28564. "setTranslate",
  28565. "setUTCDate",
  28566. "setUTCFullYear",
  28567. "setUTCHours",
  28568. "setUTCMilliseconds",
  28569. "setUTCMinutes",
  28570. "setUTCMonth",
  28571. "setUTCSeconds",
  28572. "setUint16",
  28573. "setUint32",
  28574. "setUint8",
  28575. "setUri",
  28576. "setValidity",
  28577. "setValueAtTime",
  28578. "setValueCurveAtTime",
  28579. "setVariable",
  28580. "setVelocity",
  28581. "setVersion",
  28582. "setYear",
  28583. "settingName",
  28584. "settingValue",
  28585. "sex",
  28586. "shaderSource",
  28587. "shadowBlur",
  28588. "shadowColor",
  28589. "shadowOffsetX",
  28590. "shadowOffsetY",
  28591. "shadowRoot",
  28592. "shape",
  28593. "shape-image-threshold",
  28594. "shape-margin",
  28595. "shape-outside",
  28596. "shape-rendering",
  28597. "shapeImageThreshold",
  28598. "shapeMargin",
  28599. "shapeOutside",
  28600. "shapeRendering",
  28601. "sheet",
  28602. "shift",
  28603. "shiftKey",
  28604. "shiftLeft",
  28605. "shippingAddress",
  28606. "shippingOption",
  28607. "shippingType",
  28608. "show",
  28609. "showHelp",
  28610. "showModal",
  28611. "showModalDialog",
  28612. "showModelessDialog",
  28613. "showNotification",
  28614. "sidebar",
  28615. "sign",
  28616. "signal",
  28617. "signalingState",
  28618. "signature",
  28619. "silent",
  28620. "sin",
  28621. "singleNodeValue",
  28622. "sinh",
  28623. "sinkId",
  28624. "sittingToStandingTransform",
  28625. "size",
  28626. "sizeToContent",
  28627. "sizeX",
  28628. "sizeZ",
  28629. "sizes",
  28630. "skewX",
  28631. "skewXSelf",
  28632. "skewY",
  28633. "skewYSelf",
  28634. "slice",
  28635. "slope",
  28636. "slot",
  28637. "small",
  28638. "smil",
  28639. "smooth",
  28640. "smoothingTimeConstant",
  28641. "snapToLines",
  28642. "snapshotItem",
  28643. "snapshotLength",
  28644. "some",
  28645. "sort",
  28646. "sortingCode",
  28647. "source",
  28648. "sourceBuffer",
  28649. "sourceBuffers",
  28650. "sourceCapabilities",
  28651. "sourceFile",
  28652. "sourceIndex",
  28653. "sources",
  28654. "spacing",
  28655. "span",
  28656. "speak",
  28657. "speakAs",
  28658. "speaking",
  28659. "species",
  28660. "specified",
  28661. "specularConstant",
  28662. "specularExponent",
  28663. "speechSynthesis",
  28664. "speed",
  28665. "speedOfSound",
  28666. "spellcheck",
  28667. "splice",
  28668. "split",
  28669. "splitText",
  28670. "spreadMethod",
  28671. "sqrt",
  28672. "src",
  28673. "srcElement",
  28674. "srcFilter",
  28675. "srcObject",
  28676. "srcUrn",
  28677. "srcdoc",
  28678. "srclang",
  28679. "srcset",
  28680. "stack",
  28681. "stackTraceLimit",
  28682. "stacktrace",
  28683. "stageParameters",
  28684. "standalone",
  28685. "standby",
  28686. "start",
  28687. "startContainer",
  28688. "startIce",
  28689. "startMessages",
  28690. "startNotifications",
  28691. "startOffset",
  28692. "startProfiling",
  28693. "startRendering",
  28694. "startShark",
  28695. "startTime",
  28696. "startsWith",
  28697. "state",
  28698. "status",
  28699. "statusCode",
  28700. "statusMessage",
  28701. "statusText",
  28702. "statusbar",
  28703. "stdDeviationX",
  28704. "stdDeviationY",
  28705. "stencilFunc",
  28706. "stencilFuncSeparate",
  28707. "stencilMask",
  28708. "stencilMaskSeparate",
  28709. "stencilOp",
  28710. "stencilOpSeparate",
  28711. "step",
  28712. "stepDown",
  28713. "stepMismatch",
  28714. "stepUp",
  28715. "sticky",
  28716. "stitchTiles",
  28717. "stop",
  28718. "stop-color",
  28719. "stop-opacity",
  28720. "stopColor",
  28721. "stopImmediatePropagation",
  28722. "stopNotifications",
  28723. "stopOpacity",
  28724. "stopProfiling",
  28725. "stopPropagation",
  28726. "stopShark",
  28727. "stopped",
  28728. "storage",
  28729. "storageArea",
  28730. "storageName",
  28731. "storageStatus",
  28732. "store",
  28733. "storeSiteSpecificTrackingException",
  28734. "storeWebWideTrackingException",
  28735. "stpVersion",
  28736. "stream",
  28737. "streams",
  28738. "stretch",
  28739. "strike",
  28740. "string",
  28741. "stringValue",
  28742. "stringify",
  28743. "stroke",
  28744. "stroke-dasharray",
  28745. "stroke-dashoffset",
  28746. "stroke-linecap",
  28747. "stroke-linejoin",
  28748. "stroke-miterlimit",
  28749. "stroke-opacity",
  28750. "stroke-width",
  28751. "strokeDasharray",
  28752. "strokeDashoffset",
  28753. "strokeLinecap",
  28754. "strokeLinejoin",
  28755. "strokeMiterlimit",
  28756. "strokeOpacity",
  28757. "strokeRect",
  28758. "strokeStyle",
  28759. "strokeText",
  28760. "strokeWidth",
  28761. "style",
  28762. "styleFloat",
  28763. "styleMap",
  28764. "styleMedia",
  28765. "styleSheet",
  28766. "styleSheetSets",
  28767. "styleSheets",
  28768. "sub",
  28769. "subarray",
  28770. "subject",
  28771. "submit",
  28772. "submitFrame",
  28773. "submitter",
  28774. "subscribe",
  28775. "substr",
  28776. "substring",
  28777. "substringData",
  28778. "subtle",
  28779. "subtree",
  28780. "suffix",
  28781. "suffixes",
  28782. "summary",
  28783. "sup",
  28784. "supported",
  28785. "supportedContentEncodings",
  28786. "supportedEntryTypes",
  28787. "supports",
  28788. "supportsSession",
  28789. "surfaceScale",
  28790. "surroundContents",
  28791. "suspend",
  28792. "suspendRedraw",
  28793. "swapCache",
  28794. "swapNode",
  28795. "sweepFlag",
  28796. "symbols",
  28797. "sync",
  28798. "sysexEnabled",
  28799. "system",
  28800. "systemCode",
  28801. "systemId",
  28802. "systemLanguage",
  28803. "systemXDPI",
  28804. "systemYDPI",
  28805. "tBodies",
  28806. "tFoot",
  28807. "tHead",
  28808. "tabIndex",
  28809. "table",
  28810. "table-layout",
  28811. "tableLayout",
  28812. "tableValues",
  28813. "tag",
  28814. "tagName",
  28815. "tagUrn",
  28816. "tags",
  28817. "taintEnabled",
  28818. "takePhoto",
  28819. "takeRecords",
  28820. "tan",
  28821. "tangentialPressure",
  28822. "tanh",
  28823. "target",
  28824. "targetElement",
  28825. "targetRayMode",
  28826. "targetRaySpace",
  28827. "targetTouches",
  28828. "targetX",
  28829. "targetY",
  28830. "tcpType",
  28831. "tee",
  28832. "tel",
  28833. "terminate",
  28834. "test",
  28835. "texImage2D",
  28836. "texImage3D",
  28837. "texParameterf",
  28838. "texParameteri",
  28839. "texStorage2D",
  28840. "texStorage3D",
  28841. "texSubImage2D",
  28842. "texSubImage3D",
  28843. "text",
  28844. "text-align",
  28845. "text-align-last",
  28846. "text-anchor",
  28847. "text-combine-upright",
  28848. "text-decoration",
  28849. "text-decoration-color",
  28850. "text-decoration-line",
  28851. "text-decoration-skip-ink",
  28852. "text-decoration-style",
  28853. "text-decoration-thickness",
  28854. "text-emphasis",
  28855. "text-emphasis-color",
  28856. "text-emphasis-position",
  28857. "text-emphasis-style",
  28858. "text-indent",
  28859. "text-justify",
  28860. "text-orientation",
  28861. "text-overflow",
  28862. "text-rendering",
  28863. "text-shadow",
  28864. "text-transform",
  28865. "text-underline-offset",
  28866. "text-underline-position",
  28867. "textAlign",
  28868. "textAlignLast",
  28869. "textAnchor",
  28870. "textAutospace",
  28871. "textBaseline",
  28872. "textCombineUpright",
  28873. "textContent",
  28874. "textDecoration",
  28875. "textDecorationBlink",
  28876. "textDecorationColor",
  28877. "textDecorationLine",
  28878. "textDecorationLineThrough",
  28879. "textDecorationNone",
  28880. "textDecorationOverline",
  28881. "textDecorationSkipInk",
  28882. "textDecorationStyle",
  28883. "textDecorationThickness",
  28884. "textDecorationUnderline",
  28885. "textEmphasis",
  28886. "textEmphasisColor",
  28887. "textEmphasisPosition",
  28888. "textEmphasisStyle",
  28889. "textIndent",
  28890. "textJustify",
  28891. "textJustifyTrim",
  28892. "textKashida",
  28893. "textKashidaSpace",
  28894. "textLength",
  28895. "textOrientation",
  28896. "textOverflow",
  28897. "textRendering",
  28898. "textShadow",
  28899. "textTracks",
  28900. "textTransform",
  28901. "textUnderlineOffset",
  28902. "textUnderlinePosition",
  28903. "then",
  28904. "threadId",
  28905. "threshold",
  28906. "thresholds",
  28907. "tiltX",
  28908. "tiltY",
  28909. "time",
  28910. "timeEnd",
  28911. "timeLog",
  28912. "timeOrigin",
  28913. "timeRemaining",
  28914. "timeStamp",
  28915. "timecode",
  28916. "timeline",
  28917. "timelineTime",
  28918. "timeout",
  28919. "timestamp",
  28920. "timestampOffset",
  28921. "timing",
  28922. "title",
  28923. "to",
  28924. "toArray",
  28925. "toBlob",
  28926. "toDataURL",
  28927. "toDateString",
  28928. "toElement",
  28929. "toExponential",
  28930. "toFixed",
  28931. "toFloat32Array",
  28932. "toFloat64Array",
  28933. "toGMTString",
  28934. "toISOString",
  28935. "toJSON",
  28936. "toLocaleDateString",
  28937. "toLocaleFormat",
  28938. "toLocaleLowerCase",
  28939. "toLocaleString",
  28940. "toLocaleTimeString",
  28941. "toLocaleUpperCase",
  28942. "toLowerCase",
  28943. "toMatrix",
  28944. "toMethod",
  28945. "toPrecision",
  28946. "toPrimitive",
  28947. "toSdp",
  28948. "toSource",
  28949. "toStaticHTML",
  28950. "toString",
  28951. "toStringTag",
  28952. "toSum",
  28953. "toTimeString",
  28954. "toUTCString",
  28955. "toUpperCase",
  28956. "toggle",
  28957. "toggleAttribute",
  28958. "toggleLongPressEnabled",
  28959. "tone",
  28960. "toneBuffer",
  28961. "tooLong",
  28962. "tooShort",
  28963. "toolbar",
  28964. "top",
  28965. "topMargin",
  28966. "total",
  28967. "totalFrameDelay",
  28968. "totalVideoFrames",
  28969. "touch-action",
  28970. "touchAction",
  28971. "touched",
  28972. "touches",
  28973. "trace",
  28974. "track",
  28975. "trackVisibility",
  28976. "transaction",
  28977. "transactions",
  28978. "transceiver",
  28979. "transferControlToOffscreen",
  28980. "transferFromImageBitmap",
  28981. "transferImageBitmap",
  28982. "transferIn",
  28983. "transferOut",
  28984. "transferSize",
  28985. "transferToImageBitmap",
  28986. "transform",
  28987. "transform-box",
  28988. "transform-origin",
  28989. "transform-style",
  28990. "transformBox",
  28991. "transformFeedbackVaryings",
  28992. "transformOrigin",
  28993. "transformPoint",
  28994. "transformString",
  28995. "transformStyle",
  28996. "transformToDocument",
  28997. "transformToFragment",
  28998. "transition",
  28999. "transition-delay",
  29000. "transition-duration",
  29001. "transition-property",
  29002. "transition-timing-function",
  29003. "transitionDelay",
  29004. "transitionDuration",
  29005. "transitionProperty",
  29006. "transitionTimingFunction",
  29007. "translate",
  29008. "translateSelf",
  29009. "translationX",
  29010. "translationY",
  29011. "transport",
  29012. "trim",
  29013. "trimEnd",
  29014. "trimLeft",
  29015. "trimRight",
  29016. "trimStart",
  29017. "trueSpeed",
  29018. "trunc",
  29019. "truncate",
  29020. "trustedTypes",
  29021. "turn",
  29022. "twist",
  29023. "type",
  29024. "typeDetail",
  29025. "typeMismatch",
  29026. "typeMustMatch",
  29027. "types",
  29028. "u2f",
  29029. "ubound",
  29030. "uint16",
  29031. "uint32",
  29032. "uint8",
  29033. "uint8Clamped",
  29034. "undefined",
  29035. "unescape",
  29036. "uneval",
  29037. "unicode",
  29038. "unicode-bidi",
  29039. "unicodeBidi",
  29040. "unicodeRange",
  29041. "uniform1f",
  29042. "uniform1fv",
  29043. "uniform1i",
  29044. "uniform1iv",
  29045. "uniform1ui",
  29046. "uniform1uiv",
  29047. "uniform2f",
  29048. "uniform2fv",
  29049. "uniform2i",
  29050. "uniform2iv",
  29051. "uniform2ui",
  29052. "uniform2uiv",
  29053. "uniform3f",
  29054. "uniform3fv",
  29055. "uniform3i",
  29056. "uniform3iv",
  29057. "uniform3ui",
  29058. "uniform3uiv",
  29059. "uniform4f",
  29060. "uniform4fv",
  29061. "uniform4i",
  29062. "uniform4iv",
  29063. "uniform4ui",
  29064. "uniform4uiv",
  29065. "uniformBlockBinding",
  29066. "uniformMatrix2fv",
  29067. "uniformMatrix2x3fv",
  29068. "uniformMatrix2x4fv",
  29069. "uniformMatrix3fv",
  29070. "uniformMatrix3x2fv",
  29071. "uniformMatrix3x4fv",
  29072. "uniformMatrix4fv",
  29073. "uniformMatrix4x2fv",
  29074. "uniformMatrix4x3fv",
  29075. "unique",
  29076. "uniqueID",
  29077. "uniqueNumber",
  29078. "unit",
  29079. "unitType",
  29080. "units",
  29081. "unloadEventEnd",
  29082. "unloadEventStart",
  29083. "unlock",
  29084. "unmount",
  29085. "unobserve",
  29086. "unpause",
  29087. "unpauseAnimations",
  29088. "unreadCount",
  29089. "unregister",
  29090. "unregisterContentHandler",
  29091. "unregisterProtocolHandler",
  29092. "unscopables",
  29093. "unselectable",
  29094. "unshift",
  29095. "unsubscribe",
  29096. "unsuspendRedraw",
  29097. "unsuspendRedrawAll",
  29098. "unwatch",
  29099. "unwrapKey",
  29100. "upDegrees",
  29101. "upX",
  29102. "upY",
  29103. "upZ",
  29104. "update",
  29105. "updateCommands",
  29106. "updateIce",
  29107. "updateInterval",
  29108. "updatePlaybackRate",
  29109. "updateRenderState",
  29110. "updateSettings",
  29111. "updateTiming",
  29112. "updateViaCache",
  29113. "updateWith",
  29114. "updated",
  29115. "updating",
  29116. "upgrade",
  29117. "upload",
  29118. "uploadTotal",
  29119. "uploaded",
  29120. "upper",
  29121. "upperBound",
  29122. "upperOpen",
  29123. "uri",
  29124. "url",
  29125. "urn",
  29126. "urns",
  29127. "usages",
  29128. "usb",
  29129. "usbVersionMajor",
  29130. "usbVersionMinor",
  29131. "usbVersionSubminor",
  29132. "useCurrentView",
  29133. "useMap",
  29134. "useProgram",
  29135. "usedSpace",
  29136. "user-select",
  29137. "userActivation",
  29138. "userAgent",
  29139. "userAgentData",
  29140. "userChoice",
  29141. "userHandle",
  29142. "userHint",
  29143. "userLanguage",
  29144. "userSelect",
  29145. "userVisibleOnly",
  29146. "username",
  29147. "usernameFragment",
  29148. "utterance",
  29149. "uuid",
  29150. "v8BreakIterator",
  29151. "vAlign",
  29152. "vLink",
  29153. "valid",
  29154. "validate",
  29155. "validateProgram",
  29156. "validationMessage",
  29157. "validity",
  29158. "value",
  29159. "valueAsDate",
  29160. "valueAsNumber",
  29161. "valueAsString",
  29162. "valueInSpecifiedUnits",
  29163. "valueMissing",
  29164. "valueOf",
  29165. "valueText",
  29166. "valueType",
  29167. "values",
  29168. "variable",
  29169. "variant",
  29170. "variationSettings",
  29171. "vector-effect",
  29172. "vectorEffect",
  29173. "velocityAngular",
  29174. "velocityExpansion",
  29175. "velocityX",
  29176. "velocityY",
  29177. "vendor",
  29178. "vendorId",
  29179. "vendorSub",
  29180. "verify",
  29181. "version",
  29182. "vertexAttrib1f",
  29183. "vertexAttrib1fv",
  29184. "vertexAttrib2f",
  29185. "vertexAttrib2fv",
  29186. "vertexAttrib3f",
  29187. "vertexAttrib3fv",
  29188. "vertexAttrib4f",
  29189. "vertexAttrib4fv",
  29190. "vertexAttribDivisor",
  29191. "vertexAttribDivisorANGLE",
  29192. "vertexAttribI4i",
  29193. "vertexAttribI4iv",
  29194. "vertexAttribI4ui",
  29195. "vertexAttribI4uiv",
  29196. "vertexAttribIPointer",
  29197. "vertexAttribPointer",
  29198. "vertical",
  29199. "vertical-align",
  29200. "verticalAlign",
  29201. "verticalOverflow",
  29202. "vh",
  29203. "vibrate",
  29204. "vibrationActuator",
  29205. "videoBitsPerSecond",
  29206. "videoHeight",
  29207. "videoTracks",
  29208. "videoWidth",
  29209. "view",
  29210. "viewBox",
  29211. "viewBoxString",
  29212. "viewTarget",
  29213. "viewTargetString",
  29214. "viewport",
  29215. "viewportAnchorX",
  29216. "viewportAnchorY",
  29217. "viewportElement",
  29218. "views",
  29219. "violatedDirective",
  29220. "visibility",
  29221. "visibilityState",
  29222. "visible",
  29223. "visualViewport",
  29224. "vlinkColor",
  29225. "vmax",
  29226. "vmin",
  29227. "voice",
  29228. "voiceURI",
  29229. "volume",
  29230. "vrml",
  29231. "vspace",
  29232. "vw",
  29233. "w",
  29234. "wait",
  29235. "waitSync",
  29236. "waiting",
  29237. "wake",
  29238. "wakeLock",
  29239. "wand",
  29240. "warn",
  29241. "wasClean",
  29242. "wasDiscarded",
  29243. "watch",
  29244. "watchAvailability",
  29245. "watchPosition",
  29246. "webdriver",
  29247. "webkitAddKey",
  29248. "webkitAlignContent",
  29249. "webkitAlignItems",
  29250. "webkitAlignSelf",
  29251. "webkitAnimation",
  29252. "webkitAnimationDelay",
  29253. "webkitAnimationDirection",
  29254. "webkitAnimationDuration",
  29255. "webkitAnimationFillMode",
  29256. "webkitAnimationIterationCount",
  29257. "webkitAnimationName",
  29258. "webkitAnimationPlayState",
  29259. "webkitAnimationTimingFunction",
  29260. "webkitAppearance",
  29261. "webkitAudioContext",
  29262. "webkitAudioDecodedByteCount",
  29263. "webkitAudioPannerNode",
  29264. "webkitBackfaceVisibility",
  29265. "webkitBackground",
  29266. "webkitBackgroundAttachment",
  29267. "webkitBackgroundClip",
  29268. "webkitBackgroundColor",
  29269. "webkitBackgroundImage",
  29270. "webkitBackgroundOrigin",
  29271. "webkitBackgroundPosition",
  29272. "webkitBackgroundPositionX",
  29273. "webkitBackgroundPositionY",
  29274. "webkitBackgroundRepeat",
  29275. "webkitBackgroundSize",
  29276. "webkitBackingStorePixelRatio",
  29277. "webkitBorderBottomLeftRadius",
  29278. "webkitBorderBottomRightRadius",
  29279. "webkitBorderImage",
  29280. "webkitBorderImageOutset",
  29281. "webkitBorderImageRepeat",
  29282. "webkitBorderImageSlice",
  29283. "webkitBorderImageSource",
  29284. "webkitBorderImageWidth",
  29285. "webkitBorderRadius",
  29286. "webkitBorderTopLeftRadius",
  29287. "webkitBorderTopRightRadius",
  29288. "webkitBoxAlign",
  29289. "webkitBoxDirection",
  29290. "webkitBoxFlex",
  29291. "webkitBoxOrdinalGroup",
  29292. "webkitBoxOrient",
  29293. "webkitBoxPack",
  29294. "webkitBoxShadow",
  29295. "webkitBoxSizing",
  29296. "webkitCancelAnimationFrame",
  29297. "webkitCancelFullScreen",
  29298. "webkitCancelKeyRequest",
  29299. "webkitCancelRequestAnimationFrame",
  29300. "webkitClearResourceTimings",
  29301. "webkitClosedCaptionsVisible",
  29302. "webkitConvertPointFromNodeToPage",
  29303. "webkitConvertPointFromPageToNode",
  29304. "webkitCreateShadowRoot",
  29305. "webkitCurrentFullScreenElement",
  29306. "webkitCurrentPlaybackTargetIsWireless",
  29307. "webkitDecodedFrameCount",
  29308. "webkitDirectionInvertedFromDevice",
  29309. "webkitDisplayingFullscreen",
  29310. "webkitDroppedFrameCount",
  29311. "webkitEnterFullScreen",
  29312. "webkitEnterFullscreen",
  29313. "webkitEntries",
  29314. "webkitExitFullScreen",
  29315. "webkitExitFullscreen",
  29316. "webkitExitPointerLock",
  29317. "webkitFilter",
  29318. "webkitFlex",
  29319. "webkitFlexBasis",
  29320. "webkitFlexDirection",
  29321. "webkitFlexFlow",
  29322. "webkitFlexGrow",
  29323. "webkitFlexShrink",
  29324. "webkitFlexWrap",
  29325. "webkitFullScreenKeyboardInputAllowed",
  29326. "webkitFullscreenElement",
  29327. "webkitFullscreenEnabled",
  29328. "webkitGenerateKeyRequest",
  29329. "webkitGetAsEntry",
  29330. "webkitGetDatabaseNames",
  29331. "webkitGetEntries",
  29332. "webkitGetEntriesByName",
  29333. "webkitGetEntriesByType",
  29334. "webkitGetFlowByName",
  29335. "webkitGetGamepads",
  29336. "webkitGetImageDataHD",
  29337. "webkitGetNamedFlows",
  29338. "webkitGetRegionFlowRanges",
  29339. "webkitGetUserMedia",
  29340. "webkitHasClosedCaptions",
  29341. "webkitHidden",
  29342. "webkitIDBCursor",
  29343. "webkitIDBDatabase",
  29344. "webkitIDBDatabaseError",
  29345. "webkitIDBDatabaseException",
  29346. "webkitIDBFactory",
  29347. "webkitIDBIndex",
  29348. "webkitIDBKeyRange",
  29349. "webkitIDBObjectStore",
  29350. "webkitIDBRequest",
  29351. "webkitIDBTransaction",
  29352. "webkitImageSmoothingEnabled",
  29353. "webkitIndexedDB",
  29354. "webkitInitMessageEvent",
  29355. "webkitIsFullScreen",
  29356. "webkitJustifyContent",
  29357. "webkitKeys",
  29358. "webkitLineClamp",
  29359. "webkitLineDashOffset",
  29360. "webkitLockOrientation",
  29361. "webkitMask",
  29362. "webkitMaskClip",
  29363. "webkitMaskComposite",
  29364. "webkitMaskImage",
  29365. "webkitMaskOrigin",
  29366. "webkitMaskPosition",
  29367. "webkitMaskPositionX",
  29368. "webkitMaskPositionY",
  29369. "webkitMaskRepeat",
  29370. "webkitMaskSize",
  29371. "webkitMatchesSelector",
  29372. "webkitMediaStream",
  29373. "webkitNotifications",
  29374. "webkitOfflineAudioContext",
  29375. "webkitOrder",
  29376. "webkitOrientation",
  29377. "webkitPeerConnection00",
  29378. "webkitPersistentStorage",
  29379. "webkitPerspective",
  29380. "webkitPerspectiveOrigin",
  29381. "webkitPointerLockElement",
  29382. "webkitPostMessage",
  29383. "webkitPreservesPitch",
  29384. "webkitPutImageDataHD",
  29385. "webkitRTCPeerConnection",
  29386. "webkitRegionOverset",
  29387. "webkitRelativePath",
  29388. "webkitRequestAnimationFrame",
  29389. "webkitRequestFileSystem",
  29390. "webkitRequestFullScreen",
  29391. "webkitRequestFullscreen",
  29392. "webkitRequestPointerLock",
  29393. "webkitResolveLocalFileSystemURL",
  29394. "webkitSetMediaKeys",
  29395. "webkitSetResourceTimingBufferSize",
  29396. "webkitShadowRoot",
  29397. "webkitShowPlaybackTargetPicker",
  29398. "webkitSlice",
  29399. "webkitSpeechGrammar",
  29400. "webkitSpeechGrammarList",
  29401. "webkitSpeechRecognition",
  29402. "webkitSpeechRecognitionError",
  29403. "webkitSpeechRecognitionEvent",
  29404. "webkitStorageInfo",
  29405. "webkitSupportsFullscreen",
  29406. "webkitTemporaryStorage",
  29407. "webkitTextFillColor",
  29408. "webkitTextSizeAdjust",
  29409. "webkitTextStroke",
  29410. "webkitTextStrokeColor",
  29411. "webkitTextStrokeWidth",
  29412. "webkitTransform",
  29413. "webkitTransformOrigin",
  29414. "webkitTransformStyle",
  29415. "webkitTransition",
  29416. "webkitTransitionDelay",
  29417. "webkitTransitionDuration",
  29418. "webkitTransitionProperty",
  29419. "webkitTransitionTimingFunction",
  29420. "webkitURL",
  29421. "webkitUnlockOrientation",
  29422. "webkitUserSelect",
  29423. "webkitVideoDecodedByteCount",
  29424. "webkitVisibilityState",
  29425. "webkitWirelessVideoPlaybackDisabled",
  29426. "webkitdirectory",
  29427. "webkitdropzone",
  29428. "webstore",
  29429. "weight",
  29430. "whatToShow",
  29431. "wheelDelta",
  29432. "wheelDeltaX",
  29433. "wheelDeltaY",
  29434. "whenDefined",
  29435. "which",
  29436. "white-space",
  29437. "whiteSpace",
  29438. "wholeText",
  29439. "widows",
  29440. "width",
  29441. "will-change",
  29442. "willChange",
  29443. "willValidate",
  29444. "window",
  29445. "withCredentials",
  29446. "word-break",
  29447. "word-spacing",
  29448. "word-wrap",
  29449. "wordBreak",
  29450. "wordSpacing",
  29451. "wordWrap",
  29452. "workerStart",
  29453. "wow64",
  29454. "wrap",
  29455. "wrapKey",
  29456. "writable",
  29457. "writableAuxiliaries",
  29458. "write",
  29459. "writeText",
  29460. "writeValue",
  29461. "writeWithoutResponse",
  29462. "writeln",
  29463. "writing-mode",
  29464. "writingMode",
  29465. "x",
  29466. "x1",
  29467. "x2",
  29468. "xChannelSelector",
  29469. "xmlEncoding",
  29470. "xmlStandalone",
  29471. "xmlVersion",
  29472. "xmlbase",
  29473. "xmllang",
  29474. "xmlspace",
  29475. "xor",
  29476. "xr",
  29477. "y",
  29478. "y1",
  29479. "y2",
  29480. "yChannelSelector",
  29481. "yandex",
  29482. "z",
  29483. "z-index",
  29484. "zIndex",
  29485. "zoom",
  29486. "zoomAndPan",
  29487. "zoomRectScreen",
  29488. ];
  29489. /***********************************************************************
  29490. A JavaScript tokenizer / parser / beautifier / compressor.
  29491. https://github.com/mishoo/UglifyJS2
  29492. -------------------------------- (C) ---------------------------------
  29493. Author: Mihai Bazon
  29494. <mihai.bazon@gmail.com>
  29495. http://mihai.bazon.net/blog
  29496. Distributed under the BSD license:
  29497. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  29498. Redistribution and use in source and binary forms, with or without
  29499. modification, are permitted provided that the following conditions
  29500. are met:
  29501. * Redistributions of source code must retain the above
  29502. copyright notice, this list of conditions and the following
  29503. disclaimer.
  29504. * Redistributions in binary form must reproduce the above
  29505. copyright notice, this list of conditions and the following
  29506. disclaimer in the documentation and/or other materials
  29507. provided with the distribution.
  29508. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  29509. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29510. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29511. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29512. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  29513. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29514. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29515. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29516. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  29517. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29518. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29519. SUCH DAMAGE.
  29520. ***********************************************************************/
  29521. function find_builtins(reserved) {
  29522. domprops.forEach(add);
  29523. // Compatibility fix for some standard defined globals not defined on every js environment
  29524. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  29525. var objects = {};
  29526. var global_ref = typeof commonjsGlobal === "object" ? commonjsGlobal : self;
  29527. new_globals.forEach(function (new_global) {
  29528. objects[new_global] = global_ref[new_global] || function() {};
  29529. });
  29530. [
  29531. "null",
  29532. "true",
  29533. "false",
  29534. "NaN",
  29535. "Infinity",
  29536. "-Infinity",
  29537. "undefined",
  29538. ].forEach(add);
  29539. [ Object, Array, Function, Number,
  29540. String, Boolean, Error, Math,
  29541. Date, RegExp, objects.Symbol, ArrayBuffer,
  29542. DataView, decodeURI, decodeURIComponent,
  29543. encodeURI, encodeURIComponent, eval, EvalError,
  29544. Float32Array, Float64Array, Int8Array, Int16Array,
  29545. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  29546. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  29547. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  29548. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  29549. objects.WeakMap, objects.WeakSet
  29550. ].forEach(function(ctor) {
  29551. Object.getOwnPropertyNames(ctor).map(add);
  29552. if (ctor.prototype) {
  29553. Object.getOwnPropertyNames(ctor.prototype).map(add);
  29554. }
  29555. });
  29556. function add(name) {
  29557. reserved.add(name);
  29558. }
  29559. }
  29560. function reserve_quoted_keys(ast, reserved) {
  29561. function add(name) {
  29562. push_uniq(reserved, name);
  29563. }
  29564. ast.walk(new TreeWalker(function(node) {
  29565. if (node instanceof AST_ObjectKeyVal && node.quote) {
  29566. add(node.key);
  29567. } else if (node instanceof AST_ObjectProperty && node.quote) {
  29568. add(node.key.name);
  29569. } else if (node instanceof AST_Sub) {
  29570. addStrings(node.property, add);
  29571. }
  29572. }));
  29573. }
  29574. function addStrings(node, add) {
  29575. node.walk(new TreeWalker(function(node) {
  29576. if (node instanceof AST_Sequence) {
  29577. addStrings(node.tail_node(), add);
  29578. } else if (node instanceof AST_String) {
  29579. add(node.value);
  29580. } else if (node instanceof AST_Conditional) {
  29581. addStrings(node.consequent, add);
  29582. addStrings(node.alternative, add);
  29583. }
  29584. return true;
  29585. }));
  29586. }
  29587. function mangle_private_properties(ast, options) {
  29588. var cprivate = -1;
  29589. var private_cache = new Map();
  29590. var nth_identifier = options.nth_identifier || base54;
  29591. ast = ast.transform(new TreeTransformer(function(node) {
  29592. if (
  29593. node instanceof AST_ClassPrivateProperty
  29594. || node instanceof AST_PrivateMethod
  29595. || node instanceof AST_PrivateGetter
  29596. || node instanceof AST_PrivateSetter
  29597. ) {
  29598. node.key.name = mangle_private(node.key.name);
  29599. } else if (node instanceof AST_DotHash) {
  29600. node.property = mangle_private(node.property);
  29601. }
  29602. }));
  29603. return ast;
  29604. function mangle_private(name) {
  29605. let mangled = private_cache.get(name);
  29606. if (!mangled) {
  29607. mangled = nth_identifier.get(++cprivate);
  29608. private_cache.set(name, mangled);
  29609. }
  29610. return mangled;
  29611. }
  29612. }
  29613. function mangle_properties(ast, options) {
  29614. options = defaults(options, {
  29615. builtins: false,
  29616. cache: null,
  29617. debug: false,
  29618. keep_quoted: false,
  29619. nth_identifier: base54,
  29620. only_cache: false,
  29621. regex: null,
  29622. reserved: null,
  29623. undeclared: false,
  29624. }, true);
  29625. var nth_identifier = options.nth_identifier;
  29626. var reserved_option = options.reserved;
  29627. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  29628. var reserved = new Set(reserved_option);
  29629. if (!options.builtins) find_builtins(reserved);
  29630. var cname = -1;
  29631. var cache;
  29632. if (options.cache) {
  29633. cache = options.cache.props;
  29634. } else {
  29635. cache = new Map();
  29636. }
  29637. var regex = options.regex && new RegExp(options.regex);
  29638. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  29639. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  29640. // the same as passing an empty string.
  29641. var debug = options.debug !== false;
  29642. var debug_name_suffix;
  29643. if (debug) {
  29644. debug_name_suffix = (options.debug === true ? "" : options.debug);
  29645. }
  29646. var names_to_mangle = new Set();
  29647. var unmangleable = new Set();
  29648. // Track each already-mangled name to prevent nth_identifier from generating
  29649. // the same name.
  29650. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  29651. var keep_quoted = !!options.keep_quoted;
  29652. // step 1: find candidates to mangle
  29653. ast.walk(new TreeWalker(function(node) {
  29654. if (
  29655. node instanceof AST_ClassPrivateProperty
  29656. || node instanceof AST_PrivateMethod
  29657. || node instanceof AST_PrivateGetter
  29658. || node instanceof AST_PrivateSetter
  29659. || node instanceof AST_DotHash
  29660. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29661. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29662. add(node.key);
  29663. }
  29664. } else if (node instanceof AST_ObjectProperty) {
  29665. // setter or getter, since KeyVal is handled above
  29666. if (!keep_quoted || !node.quote) {
  29667. add(node.key.name);
  29668. }
  29669. } else if (node instanceof AST_Dot) {
  29670. var declared = !!options.undeclared;
  29671. if (!declared) {
  29672. var root = node;
  29673. while (root.expression) {
  29674. root = root.expression;
  29675. }
  29676. declared = !(root.thedef && root.thedef.undeclared);
  29677. }
  29678. if (declared &&
  29679. (!keep_quoted || !node.quote)) {
  29680. add(node.property);
  29681. }
  29682. } else if (node instanceof AST_Sub) {
  29683. if (!keep_quoted) {
  29684. addStrings(node.property, add);
  29685. }
  29686. } else if (node instanceof AST_Call
  29687. && node.expression.print_to_string() == "Object.defineProperty") {
  29688. addStrings(node.args[1], add);
  29689. } else if (node instanceof AST_Binary && node.operator === "in") {
  29690. addStrings(node.left, add);
  29691. }
  29692. }));
  29693. // step 2: transform the tree, renaming properties
  29694. return ast.transform(new TreeTransformer(function(node) {
  29695. if (
  29696. node instanceof AST_ClassPrivateProperty
  29697. || node instanceof AST_PrivateMethod
  29698. || node instanceof AST_PrivateGetter
  29699. || node instanceof AST_PrivateSetter
  29700. || node instanceof AST_DotHash
  29701. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29702. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29703. node.key = mangle(node.key);
  29704. }
  29705. } else if (node instanceof AST_ObjectProperty) {
  29706. // setter, getter, method or class field
  29707. if (!keep_quoted || !node.quote) {
  29708. node.key.name = mangle(node.key.name);
  29709. }
  29710. } else if (node instanceof AST_Dot) {
  29711. if (!keep_quoted || !node.quote) {
  29712. node.property = mangle(node.property);
  29713. }
  29714. } else if (!keep_quoted && node instanceof AST_Sub) {
  29715. node.property = mangleStrings(node.property);
  29716. } else if (node instanceof AST_Call
  29717. && node.expression.print_to_string() == "Object.defineProperty") {
  29718. node.args[1] = mangleStrings(node.args[1]);
  29719. } else if (node instanceof AST_Binary && node.operator === "in") {
  29720. node.left = mangleStrings(node.left);
  29721. }
  29722. }));
  29723. // only function declarations after this line
  29724. function can_mangle(name) {
  29725. if (unmangleable.has(name)) return false;
  29726. if (reserved.has(name)) return false;
  29727. if (options.only_cache) {
  29728. return cache.has(name);
  29729. }
  29730. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  29731. return true;
  29732. }
  29733. function should_mangle(name) {
  29734. if (regex && !regex.test(name)) return false;
  29735. if (reserved.has(name)) return false;
  29736. return cache.has(name)
  29737. || names_to_mangle.has(name);
  29738. }
  29739. function add(name) {
  29740. if (can_mangle(name))
  29741. names_to_mangle.add(name);
  29742. if (!should_mangle(name)) {
  29743. unmangleable.add(name);
  29744. }
  29745. }
  29746. function mangle(name) {
  29747. if (!should_mangle(name)) {
  29748. return name;
  29749. }
  29750. var mangled = cache.get(name);
  29751. if (!mangled) {
  29752. if (debug) {
  29753. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  29754. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  29755. if (can_mangle(debug_mangled)) {
  29756. mangled = debug_mangled;
  29757. }
  29758. }
  29759. // either debug mode is off, or it is on and we could not use the mangled name
  29760. if (!mangled) {
  29761. do {
  29762. mangled = nth_identifier.get(++cname);
  29763. } while (!can_mangle(mangled));
  29764. }
  29765. cache.set(name, mangled);
  29766. }
  29767. return mangled;
  29768. }
  29769. function mangleStrings(node) {
  29770. return node.transform(new TreeTransformer(function(node) {
  29771. if (node instanceof AST_Sequence) {
  29772. var last = node.expressions.length - 1;
  29773. node.expressions[last] = mangleStrings(node.expressions[last]);
  29774. } else if (node instanceof AST_String) {
  29775. node.value = mangle(node.value);
  29776. } else if (node instanceof AST_Conditional) {
  29777. node.consequent = mangleStrings(node.consequent);
  29778. node.alternative = mangleStrings(node.alternative);
  29779. }
  29780. return node;
  29781. }));
  29782. }
  29783. }
  29784. var to_ascii = typeof atob == "undefined" ? function(b64) {
  29785. return Buffer.from(b64, "base64").toString();
  29786. } : atob;
  29787. var to_base64 = typeof btoa == "undefined" ? function(str) {
  29788. return Buffer.from(str).toString("base64");
  29789. } : btoa;
  29790. function read_source_map(code) {
  29791. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  29792. if (!match) {
  29793. console.warn("inline source map not found");
  29794. return null;
  29795. }
  29796. return to_ascii(match[2]);
  29797. }
  29798. function set_shorthand(name, options, keys) {
  29799. if (options[name]) {
  29800. keys.forEach(function(key) {
  29801. if (options[key]) {
  29802. if (typeof options[key] != "object") options[key] = {};
  29803. if (!(name in options[key])) options[key][name] = options[name];
  29804. }
  29805. });
  29806. }
  29807. }
  29808. function init_cache(cache) {
  29809. if (!cache) return;
  29810. if (!("props" in cache)) {
  29811. cache.props = new Map();
  29812. } else if (!(cache.props instanceof Map)) {
  29813. cache.props = map_from_object(cache.props);
  29814. }
  29815. }
  29816. function cache_to_json(cache) {
  29817. return {
  29818. props: map_to_object(cache.props)
  29819. };
  29820. }
  29821. function log_input(files, options, fs, debug_folder) {
  29822. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  29823. return;
  29824. }
  29825. try {
  29826. fs.mkdirSync(debug_folder);
  29827. } catch (e) {
  29828. if (e.code !== "EEXIST") throw e;
  29829. }
  29830. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  29831. options = options || {};
  29832. const options_str = JSON.stringify(options, (_key, thing) => {
  29833. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  29834. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  29835. return thing;
  29836. }, 4);
  29837. const files_str = (file) => {
  29838. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  29839. return JSON.stringify(file, null, 2);
  29840. } else if (typeof file === "object") {
  29841. return Object.keys(file)
  29842. .map((key) => key + ": " + files_str(file[key]))
  29843. .join("\n\n");
  29844. } else if (typeof file === "string") {
  29845. return "```\n" + file + "\n```";
  29846. } else {
  29847. return file; // What do?
  29848. }
  29849. };
  29850. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  29851. }
  29852. async function minify(files, options, _fs_module) {
  29853. if (
  29854. _fs_module
  29855. && typeof process === "object"
  29856. && process.env
  29857. && typeof process.env.TERSER_DEBUG_DIR === "string"
  29858. ) {
  29859. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  29860. }
  29861. options = defaults(options, {
  29862. compress: {},
  29863. ecma: undefined,
  29864. enclose: false,
  29865. ie8: false,
  29866. keep_classnames: undefined,
  29867. keep_fnames: false,
  29868. mangle: {},
  29869. module: false,
  29870. nameCache: null,
  29871. output: null,
  29872. format: null,
  29873. parse: {},
  29874. rename: undefined,
  29875. safari10: false,
  29876. sourceMap: false,
  29877. spidermonkey: false,
  29878. timings: false,
  29879. toplevel: false,
  29880. warnings: false,
  29881. wrap: false,
  29882. }, true);
  29883. var timings = options.timings && {
  29884. start: Date.now()
  29885. };
  29886. if (options.keep_classnames === undefined) {
  29887. options.keep_classnames = options.keep_fnames;
  29888. }
  29889. if (options.rename === undefined) {
  29890. options.rename = options.compress && options.mangle;
  29891. }
  29892. if (options.output && options.format) {
  29893. throw new Error("Please only specify either output or format option, preferrably format.");
  29894. }
  29895. options.format = options.format || options.output || {};
  29896. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  29897. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  29898. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  29899. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  29900. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  29901. set_shorthand("safari10", options, [ "mangle", "format" ]);
  29902. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  29903. set_shorthand("warnings", options, [ "compress" ]); // legacy
  29904. var quoted_props;
  29905. if (options.mangle) {
  29906. options.mangle = defaults(options.mangle, {
  29907. cache: options.nameCache && (options.nameCache.vars || {}),
  29908. eval: false,
  29909. ie8: false,
  29910. keep_classnames: false,
  29911. keep_fnames: false,
  29912. module: false,
  29913. nth_identifier: base54,
  29914. properties: false,
  29915. reserved: [],
  29916. safari10: false,
  29917. toplevel: false,
  29918. }, true);
  29919. if (options.mangle.properties) {
  29920. if (typeof options.mangle.properties != "object") {
  29921. options.mangle.properties = {};
  29922. }
  29923. if (options.mangle.properties.keep_quoted) {
  29924. quoted_props = options.mangle.properties.reserved;
  29925. if (!Array.isArray(quoted_props)) quoted_props = [];
  29926. options.mangle.properties.reserved = quoted_props;
  29927. }
  29928. if (options.nameCache && !("cache" in options.mangle.properties)) {
  29929. options.mangle.properties.cache = options.nameCache.props || {};
  29930. }
  29931. }
  29932. init_cache(options.mangle.cache);
  29933. init_cache(options.mangle.properties.cache);
  29934. }
  29935. if (options.sourceMap) {
  29936. options.sourceMap = defaults(options.sourceMap, {
  29937. asObject: false,
  29938. content: null,
  29939. filename: null,
  29940. includeSources: false,
  29941. root: null,
  29942. url: null,
  29943. }, true);
  29944. }
  29945. if (timings) timings.parse = Date.now();
  29946. var toplevel;
  29947. if (files instanceof AST_Toplevel) {
  29948. toplevel = files;
  29949. } else {
  29950. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  29951. files = [ files ];
  29952. }
  29953. options.parse = options.parse || {};
  29954. options.parse.toplevel = null;
  29955. if (options.parse.spidermonkey) {
  29956. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  29957. if (!toplevel) return files[name];
  29958. toplevel.body = toplevel.body.concat(files[name].body);
  29959. return toplevel;
  29960. }, null));
  29961. } else {
  29962. delete options.parse.spidermonkey;
  29963. for (var name in files) if (HOP(files, name)) {
  29964. options.parse.filename = name;
  29965. options.parse.toplevel = parse(files[name], options.parse);
  29966. if (options.sourceMap && options.sourceMap.content == "inline") {
  29967. if (Object.keys(files).length > 1)
  29968. throw new Error("inline source map only works with singular input");
  29969. options.sourceMap.content = read_source_map(files[name]);
  29970. }
  29971. }
  29972. }
  29973. toplevel = options.parse.toplevel;
  29974. }
  29975. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  29976. reserve_quoted_keys(toplevel, quoted_props);
  29977. }
  29978. if (options.wrap) {
  29979. toplevel = toplevel.wrap_commonjs(options.wrap);
  29980. }
  29981. if (options.enclose) {
  29982. toplevel = toplevel.wrap_enclose(options.enclose);
  29983. }
  29984. if (timings) timings.rename = Date.now();
  29985. if (timings) timings.compress = Date.now();
  29986. if (options.compress) {
  29987. toplevel = new Compressor(options.compress, {
  29988. mangle_options: options.mangle
  29989. }).compress(toplevel);
  29990. }
  29991. if (timings) timings.scope = Date.now();
  29992. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  29993. if (timings) timings.mangle = Date.now();
  29994. if (options.mangle) {
  29995. toplevel.compute_char_frequency(options.mangle);
  29996. toplevel.mangle_names(options.mangle);
  29997. toplevel = mangle_private_properties(toplevel, options.mangle);
  29998. }
  29999. if (timings) timings.properties = Date.now();
  30000. if (options.mangle && options.mangle.properties) {
  30001. toplevel = mangle_properties(toplevel, options.mangle.properties);
  30002. }
  30003. if (timings) timings.format = Date.now();
  30004. var result = {};
  30005. if (options.format.ast) {
  30006. result.ast = toplevel;
  30007. }
  30008. if (options.format.spidermonkey) {
  30009. result.ast = toplevel.to_mozilla_ast();
  30010. }
  30011. if (!HOP(options.format, "code") || options.format.code) {
  30012. if (options.sourceMap) {
  30013. options.format.source_map = await SourceMap({
  30014. file: options.sourceMap.filename,
  30015. orig: options.sourceMap.content,
  30016. root: options.sourceMap.root
  30017. });
  30018. if (options.sourceMap.includeSources) {
  30019. if (files instanceof AST_Toplevel) {
  30020. throw new Error("original source content unavailable");
  30021. } else for (var name in files) if (HOP(files, name)) {
  30022. options.format.source_map.get().setSourceContent(name, files[name]);
  30023. }
  30024. }
  30025. }
  30026. delete options.format.ast;
  30027. delete options.format.code;
  30028. delete options.format.spidermonkey;
  30029. var stream = OutputStream(options.format);
  30030. toplevel.print(stream);
  30031. result.code = stream.get();
  30032. if (options.sourceMap) {
  30033. if(options.sourceMap.asObject) {
  30034. result.map = options.format.source_map.get().toJSON();
  30035. } else {
  30036. result.map = options.format.source_map.toString();
  30037. }
  30038. if (options.sourceMap.url == "inline") {
  30039. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  30040. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  30041. } else if (options.sourceMap.url) {
  30042. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  30043. }
  30044. }
  30045. }
  30046. if (options.nameCache && options.mangle) {
  30047. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  30048. if (options.mangle.properties && options.mangle.properties.cache) {
  30049. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  30050. }
  30051. }
  30052. if (options.format && options.format.source_map) {
  30053. options.format.source_map.destroy();
  30054. }
  30055. if (timings) {
  30056. timings.end = Date.now();
  30057. result.timings = {
  30058. parse: 1e-3 * (timings.rename - timings.parse),
  30059. rename: 1e-3 * (timings.compress - timings.rename),
  30060. compress: 1e-3 * (timings.scope - timings.compress),
  30061. scope: 1e-3 * (timings.mangle - timings.scope),
  30062. mangle: 1e-3 * (timings.properties - timings.mangle),
  30063. properties: 1e-3 * (timings.format - timings.properties),
  30064. format: 1e-3 * (timings.end - timings.format),
  30065. total: 1e-3 * (timings.end - timings.start)
  30066. };
  30067. }
  30068. return result;
  30069. }
  30070. async function run_cli({ program, packageJson, fs, path }) {
  30071. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  30072. var files = {};
  30073. var options = {
  30074. compress: false,
  30075. mangle: false
  30076. };
  30077. const default_options = await _default_options();
  30078. program.version(packageJson.name + " " + packageJson.version);
  30079. program.parseArgv = program.parse;
  30080. program.parse = undefined;
  30081. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  30082. else if (process.argv.includes("options")) program.helpInformation = function() {
  30083. var text = [];
  30084. for (var option in default_options) {
  30085. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  30086. text.push(format_object(default_options[option]));
  30087. text.push("");
  30088. }
  30089. return text.join("\n");
  30090. };
  30091. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  30092. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  30093. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  30094. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  30095. program.option("-f, --format [options]", "Format options.", parse_js());
  30096. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  30097. program.option("-o, --output <file>", "Output file (default STDOUT).");
  30098. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  30099. program.option("--config-file <file>", "Read minify() options from JSON file.");
  30100. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  30101. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  30102. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  30103. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  30104. program.option("--keep-classnames", "Do not mangle/drop class names.");
  30105. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  30106. program.option("--module", "Input is an ES6 module");
  30107. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  30108. program.option("--rename", "Force symbol expansion.");
  30109. program.option("--no-rename", "Disable symbol expansion.");
  30110. program.option("--safari10", "Support non-standard Safari 10.");
  30111. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  30112. program.option("--timings", "Display operations run time on STDERR.");
  30113. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  30114. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  30115. program.arguments("[files...]").parseArgv(process.argv);
  30116. if (program.configFile) {
  30117. options = JSON.parse(read_file(program.configFile));
  30118. }
  30119. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  30120. fatal("ERROR: cannot write source map to STDOUT");
  30121. }
  30122. [
  30123. "compress",
  30124. "enclose",
  30125. "ie8",
  30126. "mangle",
  30127. "module",
  30128. "safari10",
  30129. "sourceMap",
  30130. "toplevel",
  30131. "wrap"
  30132. ].forEach(function(name) {
  30133. if (name in program) {
  30134. options[name] = program[name];
  30135. }
  30136. });
  30137. if ("ecma" in program) {
  30138. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  30139. const ecma = program.ecma | 0;
  30140. if (ecma > 5 && ecma < 2015)
  30141. options.ecma = ecma + 2009;
  30142. else
  30143. options.ecma = ecma;
  30144. }
  30145. if (program.format || program.beautify) {
  30146. const chosenOption = program.format || program.beautify;
  30147. options.format = typeof chosenOption === "object" ? chosenOption : {};
  30148. }
  30149. if (program.comments) {
  30150. if (typeof options.format != "object") options.format = {};
  30151. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  30152. }
  30153. if (program.define) {
  30154. if (typeof options.compress != "object") options.compress = {};
  30155. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  30156. for (var expr in program.define) {
  30157. options.compress.global_defs[expr] = program.define[expr];
  30158. }
  30159. }
  30160. if (program.keepClassnames) {
  30161. options.keep_classnames = true;
  30162. }
  30163. if (program.keepFnames) {
  30164. options.keep_fnames = true;
  30165. }
  30166. if (program.mangleProps) {
  30167. if (program.mangleProps.domprops) {
  30168. delete program.mangleProps.domprops;
  30169. } else {
  30170. if (typeof program.mangleProps != "object") program.mangleProps = {};
  30171. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  30172. }
  30173. if (typeof options.mangle != "object") options.mangle = {};
  30174. options.mangle.properties = program.mangleProps;
  30175. }
  30176. if (program.nameCache) {
  30177. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  30178. }
  30179. if (program.output == "ast") {
  30180. options.format = {
  30181. ast: true,
  30182. code: false
  30183. };
  30184. }
  30185. if (program.parse) {
  30186. if (!program.parse.acorn && !program.parse.spidermonkey) {
  30187. options.parse = program.parse;
  30188. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  30189. fatal("ERROR: inline source map only works with built-in parser");
  30190. }
  30191. }
  30192. if (~program.rawArgs.indexOf("--rename")) {
  30193. options.rename = true;
  30194. } else if (!program.rename) {
  30195. options.rename = false;
  30196. }
  30197. let convert_path = name => name;
  30198. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  30199. convert_path = function() {
  30200. var base = program.sourceMap.base;
  30201. delete options.sourceMap.base;
  30202. return function(name) {
  30203. return path.relative(base, name);
  30204. };
  30205. }();
  30206. }
  30207. let filesList;
  30208. if (options.files && options.files.length) {
  30209. filesList = options.files;
  30210. delete options.files;
  30211. } else if (program.args.length) {
  30212. filesList = program.args;
  30213. }
  30214. if (filesList) {
  30215. simple_glob(filesList).forEach(function(name) {
  30216. files[convert_path(name)] = read_file(name);
  30217. });
  30218. } else {
  30219. await new Promise((resolve) => {
  30220. var chunks = [];
  30221. process.stdin.setEncoding("utf8");
  30222. process.stdin.on("data", function(chunk) {
  30223. chunks.push(chunk);
  30224. }).on("end", function() {
  30225. files = [ chunks.join("") ];
  30226. resolve();
  30227. });
  30228. process.stdin.resume();
  30229. });
  30230. }
  30231. await run_cli();
  30232. function convert_ast(fn) {
  30233. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  30234. }
  30235. async function run_cli() {
  30236. var content = program.sourceMap && program.sourceMap.content;
  30237. if (content && content !== "inline") {
  30238. options.sourceMap.content = read_file(content, content);
  30239. }
  30240. if (program.timings) options.timings = true;
  30241. try {
  30242. if (program.parse) {
  30243. if (program.parse.acorn) {
  30244. files = convert_ast(function(toplevel, name) {
  30245. return require("acorn").parse(files[name], {
  30246. ecmaVersion: 2018,
  30247. locations: true,
  30248. program: toplevel,
  30249. sourceFile: name,
  30250. sourceType: options.module || program.parse.module ? "module" : "script"
  30251. });
  30252. });
  30253. } else if (program.parse.spidermonkey) {
  30254. files = convert_ast(function(toplevel, name) {
  30255. var obj = JSON.parse(files[name]);
  30256. if (!toplevel) return obj;
  30257. toplevel.body = toplevel.body.concat(obj.body);
  30258. return toplevel;
  30259. });
  30260. }
  30261. }
  30262. } catch (ex) {
  30263. fatal(ex);
  30264. }
  30265. let result;
  30266. try {
  30267. result = await minify(files, options, fs);
  30268. } catch (ex) {
  30269. if (ex.name == "SyntaxError") {
  30270. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  30271. var col = ex.col;
  30272. var lines = files[ex.filename].split(/\r?\n/);
  30273. var line = lines[ex.line - 1];
  30274. if (!line && !col) {
  30275. line = lines[ex.line - 2];
  30276. col = line.length;
  30277. }
  30278. if (line) {
  30279. var limit = 70;
  30280. if (col > limit) {
  30281. line = line.slice(col - limit);
  30282. col = limit;
  30283. }
  30284. print_error(line.slice(0, 80));
  30285. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  30286. }
  30287. }
  30288. if (ex.defs) {
  30289. print_error("Supported options:");
  30290. print_error(format_object(ex.defs));
  30291. }
  30292. fatal(ex);
  30293. return;
  30294. }
  30295. if (program.output == "ast") {
  30296. if (!options.compress && !options.mangle) {
  30297. result.ast.figure_out_scope({});
  30298. }
  30299. console.log(JSON.stringify(result.ast, function(key, value) {
  30300. if (value) switch (key) {
  30301. case "thedef":
  30302. return symdef(value);
  30303. case "enclosed":
  30304. return value.length ? value.map(symdef) : undefined;
  30305. case "variables":
  30306. case "globals":
  30307. return value.size ? collect_from_map(value, symdef) : undefined;
  30308. }
  30309. if (skip_keys.has(key)) return;
  30310. if (value instanceof AST_Token) return;
  30311. if (value instanceof Map) return;
  30312. if (value instanceof AST_Node) {
  30313. var result = {
  30314. _class: "AST_" + value.TYPE
  30315. };
  30316. if (value.block_scope) {
  30317. result.variables = value.block_scope.variables;
  30318. result.enclosed = value.block_scope.enclosed;
  30319. }
  30320. value.CTOR.PROPS.forEach(function(prop) {
  30321. result[prop] = value[prop];
  30322. });
  30323. return result;
  30324. }
  30325. return value;
  30326. }, 2));
  30327. } else if (program.output == "spidermonkey") {
  30328. try {
  30329. const minified = await minify(
  30330. result.code,
  30331. {
  30332. compress: false,
  30333. mangle: false,
  30334. format: {
  30335. ast: true,
  30336. code: false
  30337. }
  30338. },
  30339. fs
  30340. );
  30341. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  30342. } catch (ex) {
  30343. fatal(ex);
  30344. return;
  30345. }
  30346. } else if (program.output) {
  30347. fs.writeFileSync(program.output, result.code);
  30348. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  30349. fs.writeFileSync(program.output + ".map", result.map);
  30350. }
  30351. } else {
  30352. console.log(result.code);
  30353. }
  30354. if (program.nameCache) {
  30355. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  30356. }
  30357. if (result.timings) for (var phase in result.timings) {
  30358. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  30359. }
  30360. }
  30361. function fatal(message) {
  30362. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  30363. print_error(message);
  30364. process.exit(1);
  30365. }
  30366. // A file glob function that only supports "*" and "?" wildcards in the basename.
  30367. // Example: "foo/bar/*baz??.*.js"
  30368. // Argument `glob` may be a string or an array of strings.
  30369. // Returns an array of strings. Garbage in, garbage out.
  30370. function simple_glob(glob) {
  30371. if (Array.isArray(glob)) {
  30372. return [].concat.apply([], glob.map(simple_glob));
  30373. }
  30374. if (glob && glob.match(/[*?]/)) {
  30375. var dir = path.dirname(glob);
  30376. try {
  30377. var entries = fs.readdirSync(dir);
  30378. } catch (ex) {}
  30379. if (entries) {
  30380. var pattern = "^" + path.basename(glob)
  30381. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  30382. .replace(/\*/g, "[^/\\\\]*")
  30383. .replace(/\?/g, "[^/\\\\]") + "$";
  30384. var mod = process.platform === "win32" ? "i" : "";
  30385. var rx = new RegExp(pattern, mod);
  30386. var results = entries.filter(function(name) {
  30387. return rx.test(name);
  30388. }).map(function(name) {
  30389. return path.join(dir, name);
  30390. });
  30391. if (results.length) return results;
  30392. }
  30393. }
  30394. return [ glob ];
  30395. }
  30396. function read_file(path, default_value) {
  30397. try {
  30398. return fs.readFileSync(path, "utf8");
  30399. } catch (ex) {
  30400. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  30401. fatal(ex);
  30402. }
  30403. }
  30404. function parse_js(flag) {
  30405. return function(value, options) {
  30406. options = options || {};
  30407. try {
  30408. walk(parse(value, { expression: true }), node => {
  30409. if (node instanceof AST_Assign) {
  30410. var name = node.left.print_to_string();
  30411. var value = node.right;
  30412. if (flag) {
  30413. options[name] = value;
  30414. } else if (value instanceof AST_Array) {
  30415. options[name] = value.elements.map(to_string);
  30416. } else if (value instanceof AST_RegExp) {
  30417. value = value.value;
  30418. options[name] = new RegExp(value.source, value.flags);
  30419. } else {
  30420. options[name] = to_string(value);
  30421. }
  30422. return true;
  30423. }
  30424. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  30425. var name = node.print_to_string();
  30426. options[name] = true;
  30427. return true;
  30428. }
  30429. if (!(node instanceof AST_Sequence)) throw node;
  30430. function to_string(value) {
  30431. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  30432. quote_keys: true
  30433. });
  30434. }
  30435. });
  30436. } catch(ex) {
  30437. if (flag) {
  30438. fatal("Error parsing arguments for '" + flag + "': " + value);
  30439. } else {
  30440. options[value] = null;
  30441. }
  30442. }
  30443. return options;
  30444. };
  30445. }
  30446. function symdef(def) {
  30447. var ret = (1e6 + def.id) + " " + def.name;
  30448. if (def.mangled_name) ret += " " + def.mangled_name;
  30449. return ret;
  30450. }
  30451. function collect_from_map(map, callback) {
  30452. var result = [];
  30453. map.forEach(function (def) {
  30454. result.push(callback(def));
  30455. });
  30456. return result;
  30457. }
  30458. function format_object(obj) {
  30459. var lines = [];
  30460. var padding = "";
  30461. Object.keys(obj).map(function(name) {
  30462. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  30463. return [ name, JSON.stringify(obj[name]) ];
  30464. }).forEach(function(tokens) {
  30465. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  30466. });
  30467. return lines.join("\n");
  30468. }
  30469. function print_error(msg) {
  30470. process.stderr.write(msg);
  30471. process.stderr.write("\n");
  30472. }
  30473. function describe_ast() {
  30474. var out = OutputStream({ beautify: true });
  30475. function doitem(ctor) {
  30476. out.print("AST_" + ctor.TYPE);
  30477. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  30478. if (props.length > 0) {
  30479. out.space();
  30480. out.with_parens(function() {
  30481. props.forEach(function(prop, i) {
  30482. if (i) out.space();
  30483. out.print(prop);
  30484. });
  30485. });
  30486. }
  30487. if (ctor.documentation) {
  30488. out.space();
  30489. out.print_string(ctor.documentation);
  30490. }
  30491. if (ctor.SUBCLASSES.length > 0) {
  30492. out.space();
  30493. out.with_block(function() {
  30494. ctor.SUBCLASSES.forEach(function(ctor) {
  30495. out.indent();
  30496. doitem(ctor);
  30497. out.newline();
  30498. });
  30499. });
  30500. }
  30501. }
  30502. doitem(AST_Node);
  30503. return out + "\n";
  30504. }
  30505. }
  30506. async function _default_options() {
  30507. const defs = {};
  30508. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  30509. const options = infer_options({
  30510. [component]: {0: 0}
  30511. });
  30512. if (options) defs[component] = options;
  30513. });
  30514. return defs;
  30515. }
  30516. async function infer_options(options) {
  30517. try {
  30518. await minify("", options);
  30519. } catch (error) {
  30520. return error.defs;
  30521. }
  30522. }
  30523. exports._default_options = _default_options;
  30524. exports._run_cli = run_cli;
  30525. exports.minify = minify;
  30526. })));
  30527. }(bundle_min$1, bundle_min$1.exports));
  30528. var bundle_min = bundle_min$1.exports;
  30529. module.exports = bundle_min;